linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RESEND 0/7] mmc: omap: Fixes, cleanup and add ERASE capability
@ 2014-02-22 16:01 Jarkko Nikula
  2014-02-22 16:01 ` [RESEND 1/7] mmc: omap: Fix NULL pointer dereference due uninitialized cover_tasklet Jarkko Nikula
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Jarkko Nikula @ 2014-02-22 16:01 UTC (permalink / raw)
  To: linux-mmc
  Cc: Chris Ball, linux-omap, Tony Lindgren, Aaro Koskinen,
	Jarkko Nikula

I've sent these patches earlier early December. See
http://www.spinics.net/lists/linux-mmc/msg23540.html

Resending now as mmc.git is updated over v3.13-rc2-208-g8ecffd791448.
No other changes than added Acked-by and Tested-by lines from Tony and Aaro.
Note Jarkko Lavinen is not cc'ed since he no longer works for Samsung and I
don't know his personal address.

Set goes on top of mmc.git v3.14-rc2-10-g7536d3f83aa4.

Jarkko Nikula (7):
  mmc: omap: Fix NULL pointer dereference due uninitialized
    cover_tasklet
  mmc: omap: Convert to devm_kzalloc
  mmc: omap: Remove duplicate host->irq assignment
  mmc: omap: Remove mem_res field from struct mmc_omap_host
  mmc: omap: Convert to devm_ioremap_resource
  mmc: omap: Remove always set use_dma flag from struct mmc_omap_host
  mmc: omap: Add erase capability

 drivers/mmc/host/omap.c | 93 +++++++++++++++++++------------------------------
 1 file changed, 36 insertions(+), 57 deletions(-)

-- 
1.8.5.3


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [RESEND 1/7] mmc: omap: Fix NULL pointer dereference due uninitialized cover_tasklet
  2014-02-22 16:01 [RESEND 0/7] mmc: omap: Fixes, cleanup and add ERASE capability Jarkko Nikula
@ 2014-02-22 16:01 ` Jarkko Nikula
  2014-02-22 16:01 ` [RESEND 2/7] mmc: omap: Convert to devm_kzalloc Jarkko Nikula
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Jarkko Nikula @ 2014-02-22 16:01 UTC (permalink / raw)
  To: linux-mmc
  Cc: Chris Ball, linux-omap, Tony Lindgren, Aaro Koskinen,
	Jarkko Nikula

Omap MMC driver initialization can cause a NULL pointer dereference in
tasklet_hi_action on Nokia N810 if its miniSD cover is open during driver
initialization.

[    1.070000] Unable to handle kernel NULL pointer dereference at virtual address 00000000
[    1.080000] pgd = c0004000
[    1.080000] [00000000] *pgd=00000000
[    1.080000] Internal error: Oops: 80000005 [#1] PREEMPT ARM
[    1.080000] Modules linked in:
[    1.080000] CPU: 0 PID: 24 Comm: kworker/0:1 Not tainted 3.13.0-rc2+ #95
[    1.080000] Workqueue: events menelaus_work
[    1.080000] task: c7863340 ti: c7878000 task.ti: c7878000
[    1.080000] PC is at 0x0
[    1.080000] LR is at tasklet_hi_action+0x68/0xa4
...
[    1.080000] [<c003543c>] (tasklet_hi_action+0x68/0xa4) from [<c0034dd0>] (__do_softirq+0xbc/0x208)
[    1.080000] [<c0034dd0>] (__do_softirq+0xbc/0x208) from [<c003521c>] (irq_exit+0x84/0xac)
[    1.080000] [<c003521c>] (irq_exit+0x84/0xac) from [<c00135cc>] (handle_IRQ+0x64/0x84)
[    1.080000] [<c00135cc>] (handle_IRQ+0x64/0x84) from [<c000859c>] (omap2_intc_handle_irq+0x54/0x68)
[    1.080000] [<c000859c>] (omap2_intc_handle_irq+0x54/0x68) from [<c0015be0>] (__irq_svc+0x40/0x74)
[    1.080000] Exception stack(0xc7879d70 to 0xc7879db8)
[    1.080000] 9d60:                                     000003f1 0000000a 00000009 0000001c
[    1.080000] 9d80: c7879e70 c780bc10 c780bc10 00000000 00000001 00008603 c780bc78 c7879e4e
[    1.080000] 9da0: 00000002 c7879db8 c00343b0 c0160c9c 20000113 ffffffff
[    1.080000] [<c0015be0>] (__irq_svc+0x40/0x74) from [<c0160c9c>] (__aeabi_uidiv+0x20/0x9c)
[    1.080000] [<c0160c9c>] (__aeabi_uidiv+0x20/0x9c) from [<c00343b0>] (msecs_to_jiffies+0x18/0x24)
[    1.080000] [<c00343b0>] (msecs_to_jiffies+0x18/0x24) from [<c01ec3ec>] (omap_i2c_xfer+0x30c/0x458)
[    1.080000] [<c01ec3ec>] (omap_i2c_xfer+0x30c/0x458) from [<c01e9724>] (__i2c_transfer+0x3c/0x74)
[    1.080000] [<c01e9724>] (__i2c_transfer+0x3c/0x74) from [<c01eac4c>] (i2c_transfer+0x78/0x94)
[    1.080000] [<c01eac4c>] (i2c_transfer+0x78/0x94) from [<c01eb0bc>] (i2c_smbus_xfer+0x3c0/0x4f8)
[    1.080000] [<c01eb0bc>] (i2c_smbus_xfer+0x3c0/0x4f8) from [<c01eb414>] (i2c_smbus_write_byte_data+0x34/0x3c)
[    1.080000] [<c01eb414>] (i2c_smbus_write_byte_data+0x34/0x3c) from [<c01bb308>] (menelaus_write_reg+0x1c/0x40)
[    1.080000] [<c01bb308>] (menelaus_write_reg+0x1c/0x40) from [<c01bb904>] (menelaus_work+0xa0/0xc4)
[    1.080000] [<c01bb904>] (menelaus_work+0xa0/0xc4) from [<c00439c4>] (process_one_work+0x1fc/0x334)
[    1.080000] [<c00439c4>] (process_one_work+0x1fc/0x334) from [<c0043d6c>] (worker_thread+0x244/0x380)
[    1.080000] [<c0043d6c>] (worker_thread+0x244/0x380) from [<c0049d04>] (kthread+0xc0/0xd4)
[    1.080000] [<c0049d04>] (kthread+0xc0/0xd4) from [<c0012758>] (ret_from_fork+0x14/0x3c)
[    1.080000] Code: bad PC value
[    1.090000] ---[ end trace 7bc2fc7cd14f1d95 ]---
[    1.100000] Kernel panic - not syncing: Fatal exception in interrupt

Reason for this is that omap_notify_cover_event which calls
tasklet_hi_schedule gets called before struct cover_tasklet is initialized.

Call to omap_notify_cover_event on Nokia N810 happens from menelaus.c PMIC
driver via board-n8x0.c during execution of mmc_add_host in case of open
miniSD cover.

Fix this by moving cover_timer and cover_tasklet initialization before
mmc_add_host call in mmc_omap_new_slot.

Signed-off-by: Jarkko Nikula <jarkko.nikula@bitmer.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Tested-by: Aaro Koskinen <aaro.koskinen@iki.fi>
---
v2: a snip of stack dump added to commit log
---
 drivers/mmc/host/omap.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c
index 98b6b6ef7e5c..42b665dfaa73 100644
--- a/drivers/mmc/host/omap.c
+++ b/drivers/mmc/host/omap.c
@@ -1262,6 +1262,13 @@ static int mmc_omap_new_slot(struct mmc_omap_host *host, int id)
 	mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count;
 	mmc->max_seg_size = mmc->max_req_size;
 
+	if (slot->pdata->get_cover_state != NULL) {
+		setup_timer(&slot->cover_timer, mmc_omap_cover_timer,
+			    (unsigned long)slot);
+		tasklet_init(&slot->cover_tasklet, mmc_omap_cover_handler,
+			     (unsigned long)slot);
+	}
+
 	r = mmc_add_host(mmc);
 	if (r < 0)
 		goto err_remove_host;
@@ -1278,11 +1285,6 @@ static int mmc_omap_new_slot(struct mmc_omap_host *host, int id)
 					&dev_attr_cover_switch);
 		if (r < 0)
 			goto err_remove_slot_name;
-
-		setup_timer(&slot->cover_timer, mmc_omap_cover_timer,
-			    (unsigned long)slot);
-		tasklet_init(&slot->cover_tasklet, mmc_omap_cover_handler,
-			     (unsigned long)slot);
 		tasklet_schedule(&slot->cover_tasklet);
 	}
 
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [RESEND 2/7] mmc: omap: Convert to devm_kzalloc
  2014-02-22 16:01 [RESEND 0/7] mmc: omap: Fixes, cleanup and add ERASE capability Jarkko Nikula
  2014-02-22 16:01 ` [RESEND 1/7] mmc: omap: Fix NULL pointer dereference due uninitialized cover_tasklet Jarkko Nikula
@ 2014-02-22 16:01 ` Jarkko Nikula
  2014-02-22 16:01 ` [RESEND 3/7] mmc: omap: Remove duplicate host->irq assignment Jarkko Nikula
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Jarkko Nikula @ 2014-02-22 16:01 UTC (permalink / raw)
  To: linux-mmc
  Cc: Chris Ball, linux-omap, Tony Lindgren, Aaro Koskinen,
	Jarkko Nikula

Signed-off-by: Jarkko Nikula <jarkko.nikula@bitmer.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Tested-by: Aaro Koskinen <aaro.koskinen@iki.fi>
---
 drivers/mmc/host/omap.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c
index 42b665dfaa73..927ed24d0708 100644
--- a/drivers/mmc/host/omap.c
+++ b/drivers/mmc/host/omap.c
@@ -1345,7 +1345,8 @@ static int mmc_omap_probe(struct platform_device *pdev)
 	if (res == NULL)
 		return -EBUSY;
 
-	host = kzalloc(sizeof(struct mmc_omap_host), GFP_KERNEL);
+	host = devm_kzalloc(&pdev->dev, sizeof(struct mmc_omap_host),
+			    GFP_KERNEL);
 	if (host == NULL) {
 		ret = -ENOMEM;
 		goto err_free_mem_region;
@@ -1465,7 +1466,6 @@ err_free_iclk:
 err_free_mmc_host:
 	iounmap(host->virt_base);
 err_ioremap:
-	kfree(host);
 err_free_mem_region:
 	release_mem_region(res->start, resource_size(res));
 	return ret;
@@ -1500,8 +1500,6 @@ static int mmc_omap_remove(struct platform_device *pdev)
 			   pdev->resource[0].end - pdev->resource[0].start + 1);
 	destroy_workqueue(host->mmc_omap_wq);
 
-	kfree(host);
-
 	return 0;
 }
 
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [RESEND 3/7] mmc: omap: Remove duplicate host->irq assignment
  2014-02-22 16:01 [RESEND 0/7] mmc: omap: Fixes, cleanup and add ERASE capability Jarkko Nikula
  2014-02-22 16:01 ` [RESEND 1/7] mmc: omap: Fix NULL pointer dereference due uninitialized cover_tasklet Jarkko Nikula
  2014-02-22 16:01 ` [RESEND 2/7] mmc: omap: Convert to devm_kzalloc Jarkko Nikula
@ 2014-02-22 16:01 ` Jarkko Nikula
  2014-02-22 16:01 ` [RESEND 4/7] mmc: omap: Remove mem_res field from struct mmc_omap_host Jarkko Nikula
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Jarkko Nikula @ 2014-02-22 16:01 UTC (permalink / raw)
  To: linux-mmc
  Cc: Chris Ball, linux-omap, Tony Lindgren, Aaro Koskinen,
	Jarkko Nikula

host-irq is set twice so remove needless one.

Signed-off-by: Jarkko Nikula <jarkko.nikula@bitmer.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Tested-by: Aaro Koskinen <aaro.koskinen@iki.fi>
---
 drivers/mmc/host/omap.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c
index 927ed24d0708..b438f0addb3c 100644
--- a/drivers/mmc/host/omap.c
+++ b/drivers/mmc/host/omap.c
@@ -1375,7 +1375,6 @@ static int mmc_omap_probe(struct platform_device *pdev)
 	host->mem_res = res;
 	host->irq = irq;
 	host->use_dma = 1;
-	host->irq = irq;
 	host->phys_base = host->mem_res->start;
 	host->virt_base = ioremap(res->start, resource_size(res));
 	if (!host->virt_base)
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [RESEND 4/7] mmc: omap: Remove mem_res field from struct mmc_omap_host
  2014-02-22 16:01 [RESEND 0/7] mmc: omap: Fixes, cleanup and add ERASE capability Jarkko Nikula
                   ` (2 preceding siblings ...)
  2014-02-22 16:01 ` [RESEND 3/7] mmc: omap: Remove duplicate host->irq assignment Jarkko Nikula
@ 2014-02-22 16:01 ` Jarkko Nikula
  2014-02-22 16:01 ` [RESEND 5/7] mmc: omap: Convert to devm_ioremap_resource Jarkko Nikula
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Jarkko Nikula @ 2014-02-22 16:01 UTC (permalink / raw)
  To: linux-mmc
  Cc: Chris Ball, linux-omap, Tony Lindgren, Aaro Koskinen,
	Jarkko Nikula

Field mem_res in struct mmc_omap_host is used only once in mmc_omap_probe
when setting the phys_base field so we may just se the phys_base straight
and remove needless mem_res.

Signed-off-by: Jarkko Nikula <jarkko.nikula@bitmer.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Tested-by: Aaro Koskinen <aaro.koskinen@iki.fi>
---
 drivers/mmc/host/omap.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c
index b438f0addb3c..0d669cfa6af6 100644
--- a/drivers/mmc/host/omap.c
+++ b/drivers/mmc/host/omap.c
@@ -130,7 +130,6 @@ struct mmc_omap_host {
 	u32			dma_rx_burst;
 	struct dma_chan		*dma_tx;
 	u32			dma_tx_burst;
-	struct resource		*mem_res;
 	void __iomem		*virt_base;
 	unsigned int		phys_base;
 	int			irq;
@@ -1372,10 +1371,9 @@ static int mmc_omap_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, host);
 
 	host->id = pdev->id;
-	host->mem_res = res;
 	host->irq = irq;
 	host->use_dma = 1;
-	host->phys_base = host->mem_res->start;
+	host->phys_base = res->start;
 	host->virt_base = ioremap(res->start, resource_size(res));
 	if (!host->virt_base)
 		goto err_ioremap;
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [RESEND 5/7] mmc: omap: Convert to devm_ioremap_resource
  2014-02-22 16:01 [RESEND 0/7] mmc: omap: Fixes, cleanup and add ERASE capability Jarkko Nikula
                   ` (3 preceding siblings ...)
  2014-02-22 16:01 ` [RESEND 4/7] mmc: omap: Remove mem_res field from struct mmc_omap_host Jarkko Nikula
@ 2014-02-22 16:01 ` Jarkko Nikula
  2014-02-22 16:01 ` [RESEND 6/7] mmc: omap: Remove always set use_dma flag from struct mmc_omap_host Jarkko Nikula
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Jarkko Nikula @ 2014-02-22 16:01 UTC (permalink / raw)
  To: linux-mmc
  Cc: Chris Ball, linux-omap, Tony Lindgren, Aaro Koskinen,
	Jarkko Nikula

Simplify probe and cleanup code by using devm_ioremap_resource. This also
makes probe code to follow more common allocate private struct followed by
other initialization style.

Signed-off-by: Jarkko Nikula <jarkko.nikula@bitmer.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Tested-by: Aaro Koskinen <aaro.koskinen@iki.fi>
---
 drivers/mmc/host/omap.c | 41 ++++++++++++-----------------------------
 1 file changed, 12 insertions(+), 29 deletions(-)

diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c
index 0d669cfa6af6..e4c7a0380a63 100644
--- a/drivers/mmc/host/omap.c
+++ b/drivers/mmc/host/omap.c
@@ -1334,22 +1334,19 @@ static int mmc_omap_probe(struct platform_device *pdev)
 		return -EPROBE_DEFER;
 	}
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	host = devm_kzalloc(&pdev->dev, sizeof(struct mmc_omap_host),
+			    GFP_KERNEL);
+	if (host == NULL)
+		return -ENOMEM;
+
 	irq = platform_get_irq(pdev, 0);
-	if (res == NULL || irq < 0)
+	if (irq < 0)
 		return -ENXIO;
 
-	res = request_mem_region(res->start, resource_size(res),
-				 pdev->name);
-	if (res == NULL)
-		return -EBUSY;
-
-	host = devm_kzalloc(&pdev->dev, sizeof(struct mmc_omap_host),
-			    GFP_KERNEL);
-	if (host == NULL) {
-		ret = -ENOMEM;
-		goto err_free_mem_region;
-	}
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	host->virt_base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(host->virt_base))
+		return PTR_ERR(host->virt_base);
 
 	INIT_WORK(&host->slot_release_work, mmc_omap_slot_release_work);
 	INIT_WORK(&host->send_stop_work, mmc_omap_send_stop_work);
@@ -1374,15 +1371,9 @@ static int mmc_omap_probe(struct platform_device *pdev)
 	host->irq = irq;
 	host->use_dma = 1;
 	host->phys_base = res->start;
-	host->virt_base = ioremap(res->start, resource_size(res));
-	if (!host->virt_base)
-		goto err_ioremap;
-
 	host->iclk = clk_get(&pdev->dev, "ick");
-	if (IS_ERR(host->iclk)) {
-		ret = PTR_ERR(host->iclk);
-		goto err_free_mmc_host;
-	}
+	if (IS_ERR(host->iclk))
+		return PTR_ERR(host->iclk);
 	clk_enable(host->iclk);
 
 	host->fclk = clk_get(&pdev->dev, "fck");
@@ -1460,11 +1451,6 @@ err_free_dma:
 err_free_iclk:
 	clk_disable(host->iclk);
 	clk_put(host->iclk);
-err_free_mmc_host:
-	iounmap(host->virt_base);
-err_ioremap:
-err_free_mem_region:
-	release_mem_region(res->start, resource_size(res));
 	return ret;
 }
 
@@ -1492,9 +1478,6 @@ static int mmc_omap_remove(struct platform_device *pdev)
 	if (host->dma_rx)
 		dma_release_channel(host->dma_rx);
 
-	iounmap(host->virt_base);
-	release_mem_region(pdev->resource[0].start,
-			   pdev->resource[0].end - pdev->resource[0].start + 1);
 	destroy_workqueue(host->mmc_omap_wq);
 
 	return 0;
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [RESEND 6/7] mmc: omap: Remove always set use_dma flag from struct mmc_omap_host
  2014-02-22 16:01 [RESEND 0/7] mmc: omap: Fixes, cleanup and add ERASE capability Jarkko Nikula
                   ` (4 preceding siblings ...)
  2014-02-22 16:01 ` [RESEND 5/7] mmc: omap: Convert to devm_ioremap_resource Jarkko Nikula
@ 2014-02-22 16:01 ` Jarkko Nikula
  2014-02-22 16:01 ` [RESEND 7/7] mmc: omap: Add erase capability Jarkko Nikula
  2014-02-22 18:18 ` [RESEND 0/7] mmc: omap: Fixes, cleanup and add ERASE capability Chris Ball
  7 siblings, 0 replies; 9+ messages in thread
From: Jarkko Nikula @ 2014-02-22 16:01 UTC (permalink / raw)
  To: linux-mmc
  Cc: Chris Ball, linux-omap, Tony Lindgren, Aaro Koskinen,
	Jarkko Nikula

Because use_dma is set only in mmc_omap_probe and unset nowhere there is no
need to carry that flag in struct mmc_omap_host for mmc_omap_prepare_data
function.

Signed-off-by: Jarkko Nikula <jarkko.nikula@bitmer.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Tested-by: Aaro Koskinen <aaro.koskinen@iki.fi>
---
 drivers/mmc/host/omap.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c
index e4c7a0380a63..42175cd90435 100644
--- a/drivers/mmc/host/omap.c
+++ b/drivers/mmc/host/omap.c
@@ -152,7 +152,6 @@ struct mmc_omap_host {
 	u32			total_bytes_left;
 
 	unsigned		features;
-	unsigned		use_dma:1;
 	unsigned		brs_received:1, dma_done:1;
 	unsigned		dma_in_use:1;
 	spinlock_t		dma_lock;
@@ -944,7 +943,7 @@ static void
 mmc_omap_prepare_data(struct mmc_omap_host *host, struct mmc_request *req)
 {
 	struct mmc_data *data = req->data;
-	int i, use_dma, block_size;
+	int i, use_dma = 1, block_size;
 	unsigned sg_len;
 
 	host->data = data;
@@ -969,13 +968,10 @@ mmc_omap_prepare_data(struct mmc_omap_host *host, struct mmc_request *req)
 	sg_len = (data->blocks == 1) ? 1 : data->sg_len;
 
 	/* Only do DMA for entire blocks */
-	use_dma = host->use_dma;
-	if (use_dma) {
-		for (i = 0; i < sg_len; i++) {
-			if ((data->sg[i].length % block_size) != 0) {
-				use_dma = 0;
-				break;
-			}
+	for (i = 0; i < sg_len; i++) {
+		if ((data->sg[i].length % block_size) != 0) {
+			use_dma = 0;
+			break;
 		}
 	}
 
@@ -1369,7 +1365,6 @@ static int mmc_omap_probe(struct platform_device *pdev)
 
 	host->id = pdev->id;
 	host->irq = irq;
-	host->use_dma = 1;
 	host->phys_base = res->start;
 	host->iclk = clk_get(&pdev->dev, "ick");
 	if (IS_ERR(host->iclk))
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [RESEND 7/7] mmc: omap: Add erase capability
  2014-02-22 16:01 [RESEND 0/7] mmc: omap: Fixes, cleanup and add ERASE capability Jarkko Nikula
                   ` (5 preceding siblings ...)
  2014-02-22 16:01 ` [RESEND 6/7] mmc: omap: Remove always set use_dma flag from struct mmc_omap_host Jarkko Nikula
@ 2014-02-22 16:01 ` Jarkko Nikula
  2014-02-22 18:18 ` [RESEND 0/7] mmc: omap: Fixes, cleanup and add ERASE capability Chris Ball
  7 siblings, 0 replies; 9+ messages in thread
From: Jarkko Nikula @ 2014-02-22 16:01 UTC (permalink / raw)
  To: linux-mmc
  Cc: Chris Ball, linux-omap, Tony Lindgren, Aaro Koskinen,
	Jarkko Nikula

This patch adds the erase capability to OMAP1/OMAP2420 MMC driver. Idea is
the same than in commit 93caf8e ("omap_hsmmc: add erase capability") that we
disable the data timeout interrupt for erases.

Signed-off-by: Jarkko Nikula <jarkko.nikula@bitmer.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Tested-by: Aaro Koskinen <aaro.koskinen@iki.fi>
---
 drivers/mmc/host/omap.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c
index 42175cd90435..5c2e58b29305 100644
--- a/drivers/mmc/host/omap.c
+++ b/drivers/mmc/host/omap.c
@@ -26,6 +26,7 @@
 #include <linux/omap-dma.h>
 #include <linux/mmc/host.h>
 #include <linux/mmc/card.h>
+#include <linux/mmc/mmc.h>
 #include <linux/clk.h>
 #include <linux/scatterlist.h>
 #include <linux/slab.h>
@@ -336,6 +337,7 @@ mmc_omap_start_command(struct mmc_omap_host *host, struct mmc_command *cmd)
 	u32 cmdreg;
 	u32 resptype;
 	u32 cmdtype;
+	u16 irq_mask;
 
 	host->cmd = cmd;
 
@@ -388,12 +390,14 @@ mmc_omap_start_command(struct mmc_omap_host *host, struct mmc_command *cmd)
 	OMAP_MMC_WRITE(host, CTO, 200);
 	OMAP_MMC_WRITE(host, ARGL, cmd->arg & 0xffff);
 	OMAP_MMC_WRITE(host, ARGH, cmd->arg >> 16);
-	OMAP_MMC_WRITE(host, IE,
-		       OMAP_MMC_STAT_A_EMPTY    | OMAP_MMC_STAT_A_FULL    |
-		       OMAP_MMC_STAT_CMD_CRC    | OMAP_MMC_STAT_CMD_TOUT  |
-		       OMAP_MMC_STAT_DATA_CRC   | OMAP_MMC_STAT_DATA_TOUT |
-		       OMAP_MMC_STAT_END_OF_CMD | OMAP_MMC_STAT_CARD_ERR  |
-		       OMAP_MMC_STAT_END_OF_DATA);
+	irq_mask = OMAP_MMC_STAT_A_EMPTY    | OMAP_MMC_STAT_A_FULL    |
+		   OMAP_MMC_STAT_CMD_CRC    | OMAP_MMC_STAT_CMD_TOUT  |
+		   OMAP_MMC_STAT_DATA_CRC   | OMAP_MMC_STAT_DATA_TOUT |
+		   OMAP_MMC_STAT_END_OF_CMD | OMAP_MMC_STAT_CARD_ERR  |
+		   OMAP_MMC_STAT_END_OF_DATA;
+	if (cmd->opcode == MMC_ERASE)
+		irq_mask &= ~OMAP_MMC_STAT_DATA_TOUT;
+	OMAP_MMC_WRITE(host, IE, irq_mask);
 	OMAP_MMC_WRITE(host, CMD, cmdreg);
 }
 
@@ -1234,7 +1238,7 @@ static int mmc_omap_new_slot(struct mmc_omap_host *host, int id)
 
 	mmc->caps = 0;
 	if (host->pdata->slots[id].wires >= 4)
-		mmc->caps |= MMC_CAP_4_BIT_DATA;
+		mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_ERASE;
 
 	mmc->ops = &mmc_omap_ops;
 	mmc->f_min = 400000;
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [RESEND 0/7] mmc: omap: Fixes, cleanup and add ERASE capability
  2014-02-22 16:01 [RESEND 0/7] mmc: omap: Fixes, cleanup and add ERASE capability Jarkko Nikula
                   ` (6 preceding siblings ...)
  2014-02-22 16:01 ` [RESEND 7/7] mmc: omap: Add erase capability Jarkko Nikula
@ 2014-02-22 18:18 ` Chris Ball
  7 siblings, 0 replies; 9+ messages in thread
From: Chris Ball @ 2014-02-22 18:18 UTC (permalink / raw)
  To: Jarkko Nikula; +Cc: linux-mmc, linux-omap, Tony Lindgren, Aaro Koskinen

Hi Jarkko,

On Sat, Feb 22 2014, Jarkko Nikula wrote:
> I've sent these patches earlier early December. See
> http://www.spinics.net/lists/linux-mmc/msg23540.html
>
> Resending now as mmc.git is updated over v3.13-rc2-208-g8ecffd791448.
> No other changes than added Acked-by and Tested-by lines from Tony and Aaro.
> Note Jarkko Lavinen is not cc'ed since he no longer works for Samsung and I
> don't know his personal address.
>
> Set goes on top of mmc.git v3.14-rc2-10-g7536d3f83aa4.

Thanks, all 7 pushed to mmc-next for 3.15.

- Chris.
-- 
Chris Ball   <chris@printf.net>   <http://printf.net/>

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-02-22 18:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-22 16:01 [RESEND 0/7] mmc: omap: Fixes, cleanup and add ERASE capability Jarkko Nikula
2014-02-22 16:01 ` [RESEND 1/7] mmc: omap: Fix NULL pointer dereference due uninitialized cover_tasklet Jarkko Nikula
2014-02-22 16:01 ` [RESEND 2/7] mmc: omap: Convert to devm_kzalloc Jarkko Nikula
2014-02-22 16:01 ` [RESEND 3/7] mmc: omap: Remove duplicate host->irq assignment Jarkko Nikula
2014-02-22 16:01 ` [RESEND 4/7] mmc: omap: Remove mem_res field from struct mmc_omap_host Jarkko Nikula
2014-02-22 16:01 ` [RESEND 5/7] mmc: omap: Convert to devm_ioremap_resource Jarkko Nikula
2014-02-22 16:01 ` [RESEND 6/7] mmc: omap: Remove always set use_dma flag from struct mmc_omap_host Jarkko Nikula
2014-02-22 16:01 ` [RESEND 7/7] mmc: omap: Add erase capability Jarkko Nikula
2014-02-22 18:18 ` [RESEND 0/7] mmc: omap: Fixes, cleanup and add ERASE capability Chris Ball

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).