Skip to contentSkip to conversation

mmc: usdhi6rol0: handle probe deferral for regulator

PATCH Applied Rabin Vincent 2 participants 6 messages Aug 19, 2015 – Aug 25, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 mmc: usdhi6rol0: handle probe deferral for regulator

We ignore errors from mmc_regulator_get_supply() because the usage of the regulators is optional for the driver, but we still need to check for and handle EPROBE_DEFER, like it's done in for example dw_mmc. Otherwise we might end up not using the specified regulators just because of probe order.

---
 drivers/mmc/host/usdhi6rol0.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/mmc/host/usdhi6rol0.c +4 -2
index 54b082b..63d5d72 100644
@@ -1715,12 +1715,14 @@ static int usdhi6_probe(struct platform_device *pdev)
 	if (!mmc)
 		return -ENOMEM;
 
+	ret = mmc_regulator_get_supply(mmc);
+	if (ret == -EPROBE_DEFER)
+		goto e_free_mmc;
+
 	ret = mmc_of_parse(mmc);
 	if (ret < 0)
 		goto e_free_mmc;
 
-	mmc_regulator_get_supply(mmc);
-
 	host		= mmc_priv(mmc);
 	host->mmc	= mmc;
 	host->wait	= USDHI6_WAIT_FOR_REQUEST;
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 2/3 mmc: usdhi6rol0: fix NULL pointer deref in debug print

host->sg is only set when we're transferring multiple blocks. Check for its availibility before dereferencing it in the timeout work debug print.

---
 drivers/mmc/host/usdhi6rol0.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mmc/host/usdhi6rol0.c +2 -1
index 63d5d72..4188e84e 100644
@@ -1634,6 +1634,7 @@ static void usdhi6_timeout_work(struct work_struct *work)
 	struct usdhi6_host *host = container_of(d, struct usdhi6_host, timeout_work);
 	struct mmc_request *mrq = host->mrq;
 	struct mmc_data *data = mrq ? mrq->data : NULL;
+	struct scatterlist *sg = host->sg ?: data->sg;
 
 	dev_warn(mmc_dev(host->mmc),
 		 "%s timeout wait %u CMD%d: IRQ 0x%08x:0x%08x, last IRQ 0x%08x\n",
@@ -1669,7 +1670,7 @@ static void usdhi6_timeout_work(struct work_struct *work)
 			"%c: page #%u @ +0x%zx %ux%u in SG%u. Current SG %u bytes @ %u\n",
 			data->flags & MMC_DATA_READ ? 'R' : 'W', host->page_idx,
 			host->offset, data->blocks, data->blksz, data->sg_len,
-			sg_dma_len(host->sg), host->sg->offset);
+			sg_dma_len(sg), sg->offset);
 		usdhi6_sg_unmap(host, true);
 		/*
 		 * If USDHI6_WAIT_FOR_DATA_END times out, we have already unmapped
Signature · 1 line
1.7.10.4
#3 lore raw

PATCH 3/3 mmc: usdhi6rol0: fix ack register write

In reply to Rabin Vincent

The intent appears to be to clear only the bits which are set in status (by setting them to zero in the ack write), like in the other interrupt handlers, and not to always clear everything (by always writing zero). Use the correct not operator.

---
 drivers/mmc/host/usdhi6rol0.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/usdhi6rol0.c +1 -1
index 4188e84e..b505cbc2 100644
@@ -1611,7 +1611,7 @@ static irqreturn_t usdhi6_cd(int irq, void *dev_id)
 		return IRQ_NONE;
 
 	/* Ack */
-	usdhi6_write(host, USDHI6_SD_INFO1, !status);
+	usdhi6_write(host, USDHI6_SD_INFO1, ~status);
 
 	if (!work_pending(&mmc->detect.work) &&
 	    (((status & USDHI6_SD_INFO1_CARD_INSERT) &&
Signature · 1 line
1.7.10.4
Applied
#5 lore raw
In reply to Rabin Vincent
Quoted 7 lines · Rabin Vincent

We ignore errors from mmc_regulator_get_supply() because the usage of the regulators is optional for the driver, but we still need to check for and handle EPROBE_DEFER, like it's done in for example dw_mmc. Otherwise we might end up not using the specified regulators just because of probe order.

Thanks, applied for next!

Kind regards
Uffe

Quoted 28 lines
---
 drivers/mmc/host/usdhi6rol0.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/mmc/host/usdhi6rol0.c +4 -3
index 54b082b..63d5d72 100644
@@ -1715,12 +1715,14 @@ static int usdhi6_probe(struct platform_device *pdev)
        if (!mmc)
                return -ENOMEM;
 
+       ret = mmc_regulator_get_supply(mmc);
+       if (ret == -EPROBE_DEFER)
+               goto e_free_mmc;
+
        ret = mmc_of_parse(mmc);
        if (ret < 0)
                goto e_free_mmc;
 
-       mmc_regulator_get_supply(mmc);
-
        host            = mmc_priv(mmc);
        host->mmc       = mmc;
        host->wait      = USDHI6_WAIT_FOR_REQUEST;
--

1.7.10.4

Applied
#4 lore raw

Re: [PATCH 3/3] mmc: usdhi6rol0: fix ack register write

In reply to Rabin Vincent
Quoted 6 lines · Rabin Vincent

The intent appears to be to clear only the bits which are set in status (by setting them to zero in the ack write), like in the other interrupt handlers, and not to always clear everything (by always writing zero). Use the correct not operator.

Thanks, applied for next!

Kind regards
Uffe

Quoted 20 lines
---
 drivers/mmc/host/usdhi6rol0.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/usdhi6rol0.c +1 -2
index 4188e84e..b505cbc2 100644
@@ -1611,7 +1611,7 @@ static irqreturn_t usdhi6_cd(int irq, void *dev_id)
                return IRQ_NONE;
 
        /* Ack */
-       usdhi6_write(host, USDHI6_SD_INFO1, !status);
+       usdhi6_write(host, USDHI6_SD_INFO1, ~status);
 
        if (!work_pending(&mmc->detect.work) &&
            (((status & USDHI6_SD_INFO1_CARD_INSERT) &&
--

1.7.10.4

Applied
#2 lore raw

Re: [PATCH 2/3] mmc: usdhi6rol0: fix NULL pointer deref in debug print

In reply to Rabin Vincent
Quoted 5 lines · Rabin Vincent

host->sg is only set when we're transferring multiple blocks. Check for its availibility before dereferencing it in the timeout work debug print.

Thanks, applied for next!

Kind regards
Uffe

Quoted 28 lines
---
 drivers/mmc/host/usdhi6rol0.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mmc/host/usdhi6rol0.c +2 -2
index 63d5d72..4188e84e 100644
@@ -1634,6 +1634,7 @@ static void usdhi6_timeout_work(struct work_struct *work)
        struct usdhi6_host *host = container_of(d, struct usdhi6_host, timeout_work);
        struct mmc_request *mrq = host->mrq;
        struct mmc_data *data = mrq ? mrq->data : NULL;
+       struct scatterlist *sg = host->sg ?: data->sg;
 
        dev_warn(mmc_dev(host->mmc),
                 "%s timeout wait %u CMD%d: IRQ 0x%08x:0x%08x, last IRQ 0x%08x\n",
@@ -1669,7 +1670,7 @@ static void usdhi6_timeout_work(struct work_struct *work)
                        "%c: page #%u @ +0x%zx %ux%u in SG%u. Current SG %u bytes @ %u\n",
                        data->flags & MMC_DATA_READ ? 'R' : 'W', host->page_idx,
                        host->offset, data->blocks, data->blksz, data->sg_len,
-                       sg_dma_len(host->sg), host->sg->offset);
+                       sg_dma_len(sg), sg->offset);
                usdhi6_sg_unmap(host, true);
                /*
                 * If USDHI6_WAIT_FOR_DATA_END times out, we have already unmapped
--

1.7.10.4