mmc: omap: Fix NULL pointer dereference due uninitialized cover_tasklet
Subsystems (2)
PATCH 1/7 mmc: omap: Fix NULL pointer dereference due uninitialized cover_tasklet
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.
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.
--- drivers/mmc/host/omap.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/mmc/host/omap.c +7 -5
@@ -1273,6 +1273,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;
@@ -1289,11 +1296,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); }
Signature · 1 line
1.8.4.rc3
PATCH 2/7 mmc: omap: Convert to devm_kzalloc
--- drivers/mmc/host/omap.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/mmc/host/omap.c +2 -4
@@ -1356,7 +1356,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;
@@ -1475,7 +1476,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;
@@ -1510,8 +1510,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 ; }
Signature · 1 line
1.8.4.rc3
PATCH 3/7 mmc: omap: Remove duplicate host->irq assignment
In reply to Jarkko Nikulahost-irq is set twice so remove needless one.
--- drivers/mmc/host/omap.c | 1 - 1 file changed, 1 deletion(-)
drivers/mmc/host/omap.c +0 -1
@@ -1386,7 +1386,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)
Signature · 1 line
1.8.4.rc3
PATCH 4/7 mmc: omap: Remove mem_res field from struct mmc_omap_host
In reply to Jarkko NikulaField 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.
--- drivers/mmc/host/omap.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/mmc/host/omap.c +1 -3
@@ -141,7 +141,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;
@@ -1383,10 +1382,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;
Signature · 1 line
1.8.4.rc3
PATCH 5/7 mmc: omap: Convert to devm_ioremap_resource
In reply to Jarkko NikulaSimplify 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.
--- drivers/mmc/host/omap.c | 41 ++++++++++++----------------------------- 1 file changed, 12 insertions(+), 29 deletions(-)
drivers/mmc/host/omap.c +12 -29
@@ -1345,22 +1345,19 @@ static int mmc_omap_probe(struct platform_device *pdev)return -ENXIO ; } - 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);
@@ -1385,15 +1382,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" );
@@ -1470,11 +1461,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; }
@@ -1502,9 +1488,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 ;
Signature · 1 line
1.8.4.rc3
PATCH 6/7 mmc: omap: Remove always set use_dma flag from struct mmc_omap_host
In reply to Jarkko NikulaBecause 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.
--- drivers/mmc/host/omap.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
drivers/mmc/host/omap.c +5 -10
@@ -163,7 +163,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;
@@ -955,7 +954,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;
@@ -980,13 +979,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 ; } }
@@ -1380,7 +1376,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))
Signature · 1 line
1.8.4.rc3
PATCH 7/7 mmc: omap: Get DMA request numbers via platform resource
In reply to Jarkko NikulaThere is no need to define MMC DMA TX and RX request numbers locally for OMAP1xxx and OMAP24xx and assign them non-portable way since they already come via platform resources. See commits
6c432f7 ("ARM: OMAP1: Pass dma request lines in platform data to MMC driver") b955eef ("ARM: OMAP2: Use hwmod to initialize mmc for 2420")
Note that mmc_omap_probe doesn't change failure mechanism in case if it fails get DMA request number or DMA channel. In that case it just falls back to PIO transfer for TX and/or RX.
---
Aaro:
Sorry to bother you but I know you have OMAP1xxx based boards and I apreciate if you can give a quick test :-)
I have tested this set on OMAP2420 based Nokia N810.
--- drivers/mmc/host/omap.c | 39 +++++++++++++-------------------------- 1 file changed, 13 insertions(+), 26 deletions(-)
drivers/mmc/host/omap.c +13 -26
@@ -90,17 +90,6 @@#define OMAP_MMC_CMDTYPE_AC 2#define OMAP_MMC_CMDTYPE_ADTC 3 -#define OMAP_DMA_MMC_TX 21 -#define OMAP_DMA_MMC_RX 22 -#define OMAP_DMA_MMC2_TX 54 -#define OMAP_DMA_MMC2_RX 55 - -#define OMAP24XX_DMA_MMC2_TX 47 -#define OMAP24XX_DMA_MMC2_RX 48 -#define OMAP24XX_DMA_MMC1_TX 61 -#define OMAP24XX_DMA_MMC1_RX 62 - -#define DRIVER_NAME "mmci-omap"/* Specifies how often in millisecs to poll for card status changes
@@ -1328,7 +1317,6 @@ static int mmc_omap_probe(struct platform_device *pdev)struct mmc_omap_host *host =NULL ;struct resource *res;dma_cap_mask_t mask; -unsigned sig;int i, ret =0 ;int irq;
@@ -1394,22 +1382,21 @@ static int mmc_omap_probe(struct platform_device *pdev) host->dma_tx_burst =-1 ; host->dma_rx_burst =-1 ; -if (mmc_omap2 ()) - sig = host->id ==0 ?OMAP24XX_DMA_MMC1_TX :OMAP24XX_DMA_MMC2_TX ; -else - sig = host->id ==0 ?OMAP_DMA_MMC_TX :OMAP_DMA_MMC2_TX ; - host->dma_tx =dma_request_channel (mask, omap_dma_filter_fn, &sig); + res =platform_get_resource_byname (pdev,IORESOURCE_DMA ,"tx" ); +if (res) + host->dma_tx =dma_request_channel (mask, omap_dma_filter_fn, + &res->start);if (!host->dma_tx) -dev_warn (host->dev,"unable to obtain TX DMA engine channel %u\n" , - sig); -if (mmc_omap2 ()) - sig = host->id ==0 ?OMAP24XX_DMA_MMC1_RX :OMAP24XX_DMA_MMC2_RX ; -else - sig = host->id ==0 ?OMAP_DMA_MMC_RX :OMAP_DMA_MMC2_RX ; - host->dma_rx =dma_request_channel (mask, omap_dma_filter_fn, &sig); +dev_warn (host->dev, +"unable to obtain TX DMA. Falling back to PIO\n" ); + + res =platform_get_resource_byname (pdev,IORESOURCE_DMA ,"rx" ); +if (res) + host->dma_rx =dma_request_channel (mask, omap_dma_filter_fn, + &res->start);if (!host->dma_rx) -dev_warn (host->dev,"unable to obtain RX DMA engine channel %u\n" , - sig); +dev_warn (host->dev, +"unable to obtain RX DMA. Falling back to PIO\n" ); ret =request_irq (host->irq, mmc_omap_irq,0 ,DRIVER_NAME , host);if (ret)
Signature · 1 line
1.8.4.rc3
PATCH 1/1 mmc: omap: Add erase capability
In reply to Jarkko NikulaThis 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.
---
This goes on top of my previous omap mmc patches:
http://article.gmane.org/gmane.linux.kernel.mmc/22893
--- drivers/mmc/host/omap.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
drivers/mmc/host/omap.c +11 -7
@@ -25,6 +25,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 ;
Signature · 1 line
1.8.4.rc3
PATCH RESEND 1/8 mmc: omap: Fix NULL pointer dereference due uninitialized cover_tasklet
In reply to Jarkko NikulaOmap 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.
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.
--- drivers/mmc/host/omap.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/mmc/host/omap.c +7 -5
@@ -1272,6 +1272,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;
@@ -1288,11 +1295,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); }
Signature · 1 line
1.8.4.2
PATCH RESEND 2/8 mmc: omap: Convert to devm_kzalloc
--- drivers/mmc/host/omap.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/mmc/host/omap.c +2 -4
@@ -1355,7 +1355,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;
@@ -1474,7 +1475,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;
@@ -1509,8 +1509,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 ; }
Signature · 1 line
1.8.4.2
PATCH RESEND 3/8 mmc: omap: Remove duplicate host->irq assignment
In reply to Jarkko Nikulahost-irq is set twice so remove needless one.
--- drivers/mmc/host/omap.c | 1 - 1 file changed, 1 deletion(-)
drivers/mmc/host/omap.c +0 -1
@@ -1385,7 +1385,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)
Signature · 1 line
1.8.4.2
PATCH RESEND 4/8 mmc: omap: Remove mem_res field from struct mmc_omap_host
In reply to Jarkko NikulaField 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.
--- drivers/mmc/host/omap.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/mmc/host/omap.c +1 -3
@@ -140,7 +140,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;
@@ -1382,10 +1381,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;
Signature · 1 line
1.8.4.2
PATCH RESEND 5/8 mmc: omap: Convert to devm_ioremap_resource
In reply to Jarkko NikulaSimplify 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.
--- drivers/mmc/host/omap.c | 41 ++++++++++++----------------------------- 1 file changed, 12 insertions(+), 29 deletions(-)
drivers/mmc/host/omap.c +12 -29
@@ -1344,22 +1344,19 @@ static int mmc_omap_probe(struct platform_device *pdev)return -ENXIO ; } - 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);
@@ -1384,15 +1381,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" );
@@ -1469,11 +1460,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; }
@@ -1501,9 +1487,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 ;
Signature · 1 line
1.8.4.2
PATCH RESEND 6/8 mmc: omap: Remove always set use_dma flag from struct mmc_omap_host
In reply to Jarkko NikulaBecause 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.
--- drivers/mmc/host/omap.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
drivers/mmc/host/omap.c +5 -10
@@ -162,7 +162,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;
@@ -954,7 +953,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;
@@ -979,13 +978,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 ; } }
@@ -1379,7 +1375,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))
Signature · 1 line
1.8.4.2
PATCH RESEND 7/8 mmc: omap: Get DMA request numbers via platform resource
In reply to Jarkko NikulaThere is no need to define MMC DMA TX and RX request numbers locally for OMAP1xxx and OMAP24xx and assign them non-portable way since they already come via platform resources. See commits
6c432f7 ("ARM: OMAP1: Pass dma request lines in platform data to MMC driver") b955eef ("ARM: OMAP2: Use hwmod to initialize mmc for 2420")
Note that mmc_omap_probe doesn't change failure mechanism in case if it fails get DMA request number or DMA channel. In that case it just falls back to PIO transfer for TX and/or RX.
--- drivers/mmc/host/omap.c | 39 +++++++++++++-------------------------- 1 file changed, 13 insertions(+), 26 deletions(-)
drivers/mmc/host/omap.c +13 -26
@@ -90,17 +90,6 @@#define OMAP_MMC_CMDTYPE_AC 2#define OMAP_MMC_CMDTYPE_ADTC 3 -#define OMAP_DMA_MMC_TX 21 -#define OMAP_DMA_MMC_RX 22 -#define OMAP_DMA_MMC2_TX 54 -#define OMAP_DMA_MMC2_RX 55 - -#define OMAP24XX_DMA_MMC2_TX 47 -#define OMAP24XX_DMA_MMC2_RX 48 -#define OMAP24XX_DMA_MMC1_TX 61 -#define OMAP24XX_DMA_MMC1_RX 62 - -#define DRIVER_NAME "mmci-omap"/* Specifies how often in millisecs to poll for card status changes
@@ -1327,7 +1316,6 @@ static int mmc_omap_probe(struct platform_device *pdev)struct mmc_omap_host *host =NULL ;struct resource *res;dma_cap_mask_t mask; -unsigned sig;int i, ret =0 ;int irq;
@@ -1393,22 +1381,21 @@ static int mmc_omap_probe(struct platform_device *pdev) host->dma_tx_burst =-1 ; host->dma_rx_burst =-1 ; -if (mmc_omap2 ()) - sig = host->id ==0 ?OMAP24XX_DMA_MMC1_TX :OMAP24XX_DMA_MMC2_TX ; -else - sig = host->id ==0 ?OMAP_DMA_MMC_TX :OMAP_DMA_MMC2_TX ; - host->dma_tx =dma_request_channel (mask, omap_dma_filter_fn, &sig); + res =platform_get_resource_byname (pdev,IORESOURCE_DMA ,"tx" ); +if (res) + host->dma_tx =dma_request_channel (mask, omap_dma_filter_fn, + &res->start);if (!host->dma_tx) -dev_warn (host->dev,"unable to obtain TX DMA engine channel %u\n" , - sig); -if (mmc_omap2 ()) - sig = host->id ==0 ?OMAP24XX_DMA_MMC1_RX :OMAP24XX_DMA_MMC2_RX ; -else - sig = host->id ==0 ?OMAP_DMA_MMC_RX :OMAP_DMA_MMC2_RX ; - host->dma_rx =dma_request_channel (mask, omap_dma_filter_fn, &sig); +dev_warn (host->dev, +"unable to obtain TX DMA. Falling back to PIO\n" ); + + res =platform_get_resource_byname (pdev,IORESOURCE_DMA ,"rx" ); +if (res) + host->dma_rx =dma_request_channel (mask, omap_dma_filter_fn, + &res->start);if (!host->dma_rx) -dev_warn (host->dev,"unable to obtain RX DMA engine channel %u\n" , - sig); +dev_warn (host->dev, +"unable to obtain RX DMA. Falling back to PIO\n" ); ret =request_irq (host->irq, mmc_omap_irq,0 ,DRIVER_NAME , host);if (ret)
Signature · 1 line
1.8.4.2
PATCH RESEND 8/8 mmc: omap: Add erase capability
In reply to Jarkko NikulaThis 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.
--- drivers/mmc/host/omap.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
drivers/mmc/host/omap.c +11 -7
@@ -25,6 +25,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>
@@ -335,6 +336,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;
@@ -387,12 +389,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); }
@@ -1233,7 +1237,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 ;
Signature · 1 line
1.8.4.2