Re: [PATCH 0/4] atmel-mci: fixes for 2.6.27

Previous thread: none

Next thread: FW: E200i controllers on BL465C Blades - kernel fails to boot by Miller, Mike (OS Dev) on Friday, September 19, 2008 - 12:20 pm. (1 message)
From: Haavard Skinnemoen
Date: Friday, September 19, 2008 - 12:09 pm

Hi Pierre,

Here is a small handful of fixes for problems I've found while testing
the new atmel-mci driver. I hope they can be applied before 2.6.27
goes out the door.

I guess it's too late to add DMA support at this point, so I'll post
that separately along with a few other improvements.

Haavard Skinnemoen (4):
      atmel-mci: debugfs: enable clock before dumping regs
      atmel-mci: Fix memory leak in atmci_regs_show
      atmel-mci: Fix bogus debugfs file size
      atmel-mci: Set MMC_CAP_NEEDS_POLL if no detect_pin

 drivers/mmc/host/atmel-mci.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

Haavard
--

From: Haavard Skinnemoen
Date: Friday, September 19, 2008 - 12:09 pm

Make sure that the peripheral clock is enabled before reading the MMIO
registers for the debugfs "regs" dump.

Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
---
 drivers/mmc/host/atmel-mci.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index 0bd06f5..6de773d 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -195,7 +195,9 @@ static int atmci_regs_show(struct seq_file *s, void *v)
 
 	/* Grab a more or less consistent snapshot */
 	spin_lock_irq(&host->mmc->lock);
+	clk_enable(host->mck);
 	memcpy_fromio(buf, host->regs, MCI_REGS_SIZE);
+	clk_disable(host->mck);
 	spin_unlock_irq(&host->mmc->lock);
 
 	seq_printf(s, "MR:\t0x%08x%s%s CLKDIV=%u\n",
-- 
1.5.6.5

--

From: Haavard Skinnemoen
Date: Friday, September 19, 2008 - 12:09 pm

The debugfs hook atmci_regs_show allocates a temporary buffer for
storing a register snapshot, but it doesn't free it before returning.
Plug this leak.

Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
---
 drivers/mmc/host/atmel-mci.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index 6de773d..becca91 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -218,6 +218,8 @@ static int atmci_regs_show(struct seq_file *s, void *v)
 	atmci_show_status_reg(s, "SR", buf[MCI_SR / 4]);
 	atmci_show_status_reg(s, "IMR", buf[MCI_IMR / 4]);
 
+	kfree(buf);
+
 	return 0;
 }
 
-- 
1.5.6.5

--

From: Haavard Skinnemoen
Date: Friday, September 19, 2008 - 12:09 pm

We used to store a binary register snapshot in the "regs" file, so we
set the file size to be the size of this snapshot. This is no longer
valid since we switched to using seq_file.

Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
---
 drivers/mmc/host/atmel-mci.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index becca91..3909608 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -241,7 +241,6 @@ static void atmci_init_debugfs(struct atmel_mci *host)
 	struct mmc_host	*mmc;
 	struct dentry	*root;
 	struct dentry	*node;
-	struct resource	*res;
 
 	mmc = host->mmc;
 	root = mmc->debugfs_root;
@@ -255,9 +254,6 @@ static void atmci_init_debugfs(struct atmel_mci *host)
 	if (!node)
 		goto err;
 
-	res = platform_get_resource(host->pdev, IORESOURCE_MEM, 0);
-	node->d_inode->i_size = res->end - res->start + 1;
-
 	node = debugfs_create_file("req", S_IRUSR, root, host, &atmci_req_fops);
 	if (!node)
 		goto err;
-- 
1.5.6.5

--

From: Haavard Skinnemoen
Date: Friday, September 19, 2008 - 12:09 pm

This allows the mmc core to detect card insertion/removal for slots that
don't have any CD pin wired up.

Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
---
 drivers/mmc/host/atmel-mci.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index 3909608..917035e 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -1059,6 +1059,10 @@ static int __init atmci_probe(struct platform_device *pdev)
 			host->present = !gpio_get_value(host->detect_pin);
 		}
 	}
+
+	if (!gpio_is_valid(host->detect_pin))
+		mmc->caps |= MMC_CAP_NEEDS_POLL;
+
 	if (gpio_is_valid(host->wp_pin)) {
 		if (gpio_request(host->wp_pin, "mmc_wp")) {
 			dev_dbg(&mmc->class_dev, "no WP pin available\n");
-- 
1.5.6.5

--

From: Pierre Ossman
Date: Saturday, September 20, 2008 - 3:13 am

On Fri, 19 Sep 2008 21:09:26 +0200


Yeah, no features at this point. I do appreciate getting patches some
time before the merge window (preferably right after it closes).

--=20
     -- Pierre Ossman

  Linux kernel, MMC maintainer        http://www.kernel.org
  rdesktop, core developer          http://www.rdesktop.org

  WARNING: This correspondence is being monitored by the
  Swedish government. Make sure your server uses encryption
  for SMTP traffic and consider using PGP for end-to-end
  encryption.
Previous thread: none

Next thread: FW: E200i controllers on BL465C Blades - kernel fails to boot by Miller, Mike (OS Dev) on Friday, September 19, 2008 - 12:20 pm. (1 message)