* [PATCH V2] mmc: mmci: add threaded irq to abort DPSM of non-functional state
@ 2019-12-11 13:39 ` Ludovic Barre
0 siblings, 0 replies; 6+ messages in thread
From: Ludovic Barre @ 2019-12-11 13:39 UTC (permalink / raw)
To: Ulf Hansson, Rob Herring
Cc: srinivas.kandagatla, Maxime Coquelin, Alexandre Torgue,
linux-arm-kernel, linux-kernel, devicetree, linux-mmc,
linux-stm32, Ludovic Barre
From: Ludovic Barre <ludovic.barre@st.com>
If datatimeout occurs on R1B request, the Data Path State Machine stays
in busy and is non-functional. Only a reset aborts the DPSM.
Like a reset must be outside of critical section, this patch adds
threaded irq function to release state machine. In this case,
the mmc_request_done is called at the end of threaded irq and
skipped into irq handler.
Signed-off-by: Ludovic Barre <ludovic.barre@st.com>
---
change V2:
-check IRQ_WAKE_THREAD only in mmci_cmd_irq error part,
to avoid this test in mmci_request_end.
---
drivers/mmc/host/mmci.c | 46 +++++++++++++++++++++++++++++++++++------
drivers/mmc/host/mmci.h | 1 +
2 files changed, 41 insertions(+), 6 deletions(-)
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 40e72c30ea84..2b91757e3e84 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -1321,6 +1321,7 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd,
} else if (host->variant->busy_timeout && busy_resp &&
status & MCI_DATATIMEOUT) {
cmd->error = -ETIMEDOUT;
+ host->irq_action = IRQ_WAKE_THREAD;
} else {
cmd->resp[0] = readl(base + MMCIRESPONSE0);
cmd->resp[1] = readl(base + MMCIRESPONSE1);
@@ -1339,7 +1340,10 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd,
return;
}
}
- mmci_request_end(host, host->mrq);
+
+ if (host->irq_action != IRQ_WAKE_THREAD)
+ mmci_request_end(host, host->mrq);
+
} else if (sbc) {
mmci_start_command(host, host->mrq->cmd, 0);
} else if (!host->variant->datactrl_first &&
@@ -1532,9 +1536,9 @@ static irqreturn_t mmci_irq(int irq, void *dev_id)
{
struct mmci_host *host = dev_id;
u32 status;
- int ret = 0;
spin_lock(&host->lock);
+ host->irq_action = IRQ_HANDLED;
do {
status = readl(host->base + MMCISTATUS);
@@ -1574,12 +1578,41 @@ static irqreturn_t mmci_irq(int irq, void *dev_id)
if (host->variant->busy_detect_flag)
status &= ~host->variant->busy_detect_flag;
- ret = 1;
} while (status);
spin_unlock(&host->lock);
- return IRQ_RETVAL(ret);
+ return host->irq_action;
+}
+
+/*
+ * mmci_irq_threaded is call if the mmci host need to release state machines
+ * before to terminate the request.
+ * If datatimeout occurs on R1B request, the Data Path State Machine stays
+ * in busy and is non-functional. Only a reset can to abort the DPSM.
+ */
+static irqreturn_t mmci_irq_threaded(int irq, void *dev_id)
+{
+ struct mmci_host *host = dev_id;
+ unsigned long flags;
+
+ if (host->rst) {
+ reset_control_assert(host->rst);
+ udelay(2);
+ reset_control_deassert(host->rst);
+ }
+
+ spin_lock_irqsave(&host->lock, flags);
+ writel(host->clk_reg, host->base + MMCICLOCK);
+ writel(host->pwr_reg, host->base + MMCIPOWER);
+ writel(MCI_IRQENABLE | host->variant->start_err,
+ host->base + MMCIMASK0);
+
+ host->irq_action = IRQ_HANDLED;
+ mmci_request_end(host, host->mrq);
+ spin_unlock_irqrestore(&host->lock, flags);
+
+ return host->irq_action;
}
static void mmci_request(struct mmc_host *mmc, struct mmc_request *mrq)
@@ -2071,8 +2104,9 @@ static int mmci_probe(struct amba_device *dev,
goto clk_disable;
}
- ret = devm_request_irq(&dev->dev, dev->irq[0], mmci_irq, IRQF_SHARED,
- DRIVER_NAME " (cmd)", host);
+ ret = devm_request_threaded_irq(&dev->dev, dev->irq[0], mmci_irq,
+ mmci_irq_threaded, IRQF_SHARED,
+ DRIVER_NAME " (cmd)", host);
if (ret)
goto clk_disable;
diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h
index 158e1231aa23..5e63c0596364 100644
--- a/drivers/mmc/host/mmci.h
+++ b/drivers/mmc/host/mmci.h
@@ -412,6 +412,7 @@ struct mmci_host {
struct timer_list timer;
unsigned int oldstat;
+ u32 irq_action;
/* pio stuff */
struct sg_mapping_iter sg_miter;
--
2.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH V2] mmc: mmci: add threaded irq to abort DPSM of non-functional state
@ 2019-12-11 13:39 ` Ludovic Barre
0 siblings, 0 replies; 6+ messages in thread
From: Ludovic Barre @ 2019-12-11 13:39 UTC (permalink / raw)
To: Ulf Hansson, Rob Herring
Cc: devicetree, Alexandre Torgue, linux-mmc, linux-kernel,
srinivas.kandagatla, Ludovic Barre, Maxime Coquelin, linux-stm32,
linux-arm-kernel
From: Ludovic Barre <ludovic.barre@st.com>
If datatimeout occurs on R1B request, the Data Path State Machine stays
in busy and is non-functional. Only a reset aborts the DPSM.
Like a reset must be outside of critical section, this patch adds
threaded irq function to release state machine. In this case,
the mmc_request_done is called at the end of threaded irq and
skipped into irq handler.
Signed-off-by: Ludovic Barre <ludovic.barre@st.com>
---
change V2:
-check IRQ_WAKE_THREAD only in mmci_cmd_irq error part,
to avoid this test in mmci_request_end.
---
drivers/mmc/host/mmci.c | 46 +++++++++++++++++++++++++++++++++++------
drivers/mmc/host/mmci.h | 1 +
2 files changed, 41 insertions(+), 6 deletions(-)
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 40e72c30ea84..2b91757e3e84 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -1321,6 +1321,7 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd,
} else if (host->variant->busy_timeout && busy_resp &&
status & MCI_DATATIMEOUT) {
cmd->error = -ETIMEDOUT;
+ host->irq_action = IRQ_WAKE_THREAD;
} else {
cmd->resp[0] = readl(base + MMCIRESPONSE0);
cmd->resp[1] = readl(base + MMCIRESPONSE1);
@@ -1339,7 +1340,10 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd,
return;
}
}
- mmci_request_end(host, host->mrq);
+
+ if (host->irq_action != IRQ_WAKE_THREAD)
+ mmci_request_end(host, host->mrq);
+
} else if (sbc) {
mmci_start_command(host, host->mrq->cmd, 0);
} else if (!host->variant->datactrl_first &&
@@ -1532,9 +1536,9 @@ static irqreturn_t mmci_irq(int irq, void *dev_id)
{
struct mmci_host *host = dev_id;
u32 status;
- int ret = 0;
spin_lock(&host->lock);
+ host->irq_action = IRQ_HANDLED;
do {
status = readl(host->base + MMCISTATUS);
@@ -1574,12 +1578,41 @@ static irqreturn_t mmci_irq(int irq, void *dev_id)
if (host->variant->busy_detect_flag)
status &= ~host->variant->busy_detect_flag;
- ret = 1;
} while (status);
spin_unlock(&host->lock);
- return IRQ_RETVAL(ret);
+ return host->irq_action;
+}
+
+/*
+ * mmci_irq_threaded is call if the mmci host need to release state machines
+ * before to terminate the request.
+ * If datatimeout occurs on R1B request, the Data Path State Machine stays
+ * in busy and is non-functional. Only a reset can to abort the DPSM.
+ */
+static irqreturn_t mmci_irq_threaded(int irq, void *dev_id)
+{
+ struct mmci_host *host = dev_id;
+ unsigned long flags;
+
+ if (host->rst) {
+ reset_control_assert(host->rst);
+ udelay(2);
+ reset_control_deassert(host->rst);
+ }
+
+ spin_lock_irqsave(&host->lock, flags);
+ writel(host->clk_reg, host->base + MMCICLOCK);
+ writel(host->pwr_reg, host->base + MMCIPOWER);
+ writel(MCI_IRQENABLE | host->variant->start_err,
+ host->base + MMCIMASK0);
+
+ host->irq_action = IRQ_HANDLED;
+ mmci_request_end(host, host->mrq);
+ spin_unlock_irqrestore(&host->lock, flags);
+
+ return host->irq_action;
}
static void mmci_request(struct mmc_host *mmc, struct mmc_request *mrq)
@@ -2071,8 +2104,9 @@ static int mmci_probe(struct amba_device *dev,
goto clk_disable;
}
- ret = devm_request_irq(&dev->dev, dev->irq[0], mmci_irq, IRQF_SHARED,
- DRIVER_NAME " (cmd)", host);
+ ret = devm_request_threaded_irq(&dev->dev, dev->irq[0], mmci_irq,
+ mmci_irq_threaded, IRQF_SHARED,
+ DRIVER_NAME " (cmd)", host);
if (ret)
goto clk_disable;
diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h
index 158e1231aa23..5e63c0596364 100644
--- a/drivers/mmc/host/mmci.h
+++ b/drivers/mmc/host/mmci.h
@@ -412,6 +412,7 @@ struct mmci_host {
struct timer_list timer;
unsigned int oldstat;
+ u32 irq_action;
/* pio stuff */
struct sg_mapping_iter sg_miter;
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH V2] mmc: mmci: add threaded irq to abort DPSM of non-functional state
2019-12-11 13:39 ` Ludovic Barre
@ 2019-12-18 14:01 ` Ulf Hansson
-1 siblings, 0 replies; 6+ messages in thread
From: Ulf Hansson @ 2019-12-18 14:01 UTC (permalink / raw)
To: Ludovic Barre
Cc: Rob Herring, Srinivas Kandagatla, Maxime Coquelin,
Alexandre Torgue, Linux ARM, Linux Kernel Mailing List, DTML,
linux-mmc, linux-stm32
On Wed, 11 Dec 2019 at 14:40, Ludovic Barre <ludovic.Barre@st.com> wrote:
>
> From: Ludovic Barre <ludovic.barre@st.com>
>
> If datatimeout occurs on R1B request, the Data Path State Machine stays
> in busy and is non-functional. Only a reset aborts the DPSM.
>
> Like a reset must be outside of critical section, this patch adds
> threaded irq function to release state machine. In this case,
> the mmc_request_done is called at the end of threaded irq and
> skipped into irq handler.
>
> Signed-off-by: Ludovic Barre <ludovic.barre@st.com>
Applied for next, thanks!
I took the liberty of doing some minor updates (changelog/comment),
please have a look and let me know if there is something you want me
to change.
And again, apologize for the delays!
Kind regards
Uffe
> ---
> change V2:
> -check IRQ_WAKE_THREAD only in mmci_cmd_irq error part,
> to avoid this test in mmci_request_end.
>
> ---
> drivers/mmc/host/mmci.c | 46 +++++++++++++++++++++++++++++++++++------
> drivers/mmc/host/mmci.h | 1 +
> 2 files changed, 41 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
> index 40e72c30ea84..2b91757e3e84 100644
> --- a/drivers/mmc/host/mmci.c
> +++ b/drivers/mmc/host/mmci.c
> @@ -1321,6 +1321,7 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd,
> } else if (host->variant->busy_timeout && busy_resp &&
> status & MCI_DATATIMEOUT) {
> cmd->error = -ETIMEDOUT;
> + host->irq_action = IRQ_WAKE_THREAD;
> } else {
> cmd->resp[0] = readl(base + MMCIRESPONSE0);
> cmd->resp[1] = readl(base + MMCIRESPONSE1);
> @@ -1339,7 +1340,10 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd,
> return;
> }
> }
> - mmci_request_end(host, host->mrq);
> +
> + if (host->irq_action != IRQ_WAKE_THREAD)
> + mmci_request_end(host, host->mrq);
> +
> } else if (sbc) {
> mmci_start_command(host, host->mrq->cmd, 0);
> } else if (!host->variant->datactrl_first &&
> @@ -1532,9 +1536,9 @@ static irqreturn_t mmci_irq(int irq, void *dev_id)
> {
> struct mmci_host *host = dev_id;
> u32 status;
> - int ret = 0;
>
> spin_lock(&host->lock);
> + host->irq_action = IRQ_HANDLED;
>
> do {
> status = readl(host->base + MMCISTATUS);
> @@ -1574,12 +1578,41 @@ static irqreturn_t mmci_irq(int irq, void *dev_id)
> if (host->variant->busy_detect_flag)
> status &= ~host->variant->busy_detect_flag;
>
> - ret = 1;
> } while (status);
>
> spin_unlock(&host->lock);
>
> - return IRQ_RETVAL(ret);
> + return host->irq_action;
> +}
> +
> +/*
> + * mmci_irq_threaded is call if the mmci host need to release state machines
> + * before to terminate the request.
> + * If datatimeout occurs on R1B request, the Data Path State Machine stays
> + * in busy and is non-functional. Only a reset can to abort the DPSM.
> + */
> +static irqreturn_t mmci_irq_threaded(int irq, void *dev_id)
> +{
> + struct mmci_host *host = dev_id;
> + unsigned long flags;
> +
> + if (host->rst) {
> + reset_control_assert(host->rst);
> + udelay(2);
> + reset_control_deassert(host->rst);
> + }
> +
> + spin_lock_irqsave(&host->lock, flags);
> + writel(host->clk_reg, host->base + MMCICLOCK);
> + writel(host->pwr_reg, host->base + MMCIPOWER);
> + writel(MCI_IRQENABLE | host->variant->start_err,
> + host->base + MMCIMASK0);
> +
> + host->irq_action = IRQ_HANDLED;
> + mmci_request_end(host, host->mrq);
> + spin_unlock_irqrestore(&host->lock, flags);
> +
> + return host->irq_action;
> }
>
> static void mmci_request(struct mmc_host *mmc, struct mmc_request *mrq)
> @@ -2071,8 +2104,9 @@ static int mmci_probe(struct amba_device *dev,
> goto clk_disable;
> }
>
> - ret = devm_request_irq(&dev->dev, dev->irq[0], mmci_irq, IRQF_SHARED,
> - DRIVER_NAME " (cmd)", host);
> + ret = devm_request_threaded_irq(&dev->dev, dev->irq[0], mmci_irq,
> + mmci_irq_threaded, IRQF_SHARED,
> + DRIVER_NAME " (cmd)", host);
> if (ret)
> goto clk_disable;
>
> diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h
> index 158e1231aa23..5e63c0596364 100644
> --- a/drivers/mmc/host/mmci.h
> +++ b/drivers/mmc/host/mmci.h
> @@ -412,6 +412,7 @@ struct mmci_host {
>
> struct timer_list timer;
> unsigned int oldstat;
> + u32 irq_action;
>
> /* pio stuff */
> struct sg_mapping_iter sg_miter;
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH V2] mmc: mmci: add threaded irq to abort DPSM of non-functional state
@ 2019-12-18 14:01 ` Ulf Hansson
0 siblings, 0 replies; 6+ messages in thread
From: Ulf Hansson @ 2019-12-18 14:01 UTC (permalink / raw)
To: Ludovic Barre
Cc: DTML, Alexandre Torgue, linux-mmc, Linux Kernel Mailing List,
Rob Herring, Srinivas Kandagatla, Maxime Coquelin, linux-stm32,
Linux ARM
On Wed, 11 Dec 2019 at 14:40, Ludovic Barre <ludovic.Barre@st.com> wrote:
>
> From: Ludovic Barre <ludovic.barre@st.com>
>
> If datatimeout occurs on R1B request, the Data Path State Machine stays
> in busy and is non-functional. Only a reset aborts the DPSM.
>
> Like a reset must be outside of critical section, this patch adds
> threaded irq function to release state machine. In this case,
> the mmc_request_done is called at the end of threaded irq and
> skipped into irq handler.
>
> Signed-off-by: Ludovic Barre <ludovic.barre@st.com>
Applied for next, thanks!
I took the liberty of doing some minor updates (changelog/comment),
please have a look and let me know if there is something you want me
to change.
And again, apologize for the delays!
Kind regards
Uffe
> ---
> change V2:
> -check IRQ_WAKE_THREAD only in mmci_cmd_irq error part,
> to avoid this test in mmci_request_end.
>
> ---
> drivers/mmc/host/mmci.c | 46 +++++++++++++++++++++++++++++++++++------
> drivers/mmc/host/mmci.h | 1 +
> 2 files changed, 41 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
> index 40e72c30ea84..2b91757e3e84 100644
> --- a/drivers/mmc/host/mmci.c
> +++ b/drivers/mmc/host/mmci.c
> @@ -1321,6 +1321,7 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd,
> } else if (host->variant->busy_timeout && busy_resp &&
> status & MCI_DATATIMEOUT) {
> cmd->error = -ETIMEDOUT;
> + host->irq_action = IRQ_WAKE_THREAD;
> } else {
> cmd->resp[0] = readl(base + MMCIRESPONSE0);
> cmd->resp[1] = readl(base + MMCIRESPONSE1);
> @@ -1339,7 +1340,10 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd,
> return;
> }
> }
> - mmci_request_end(host, host->mrq);
> +
> + if (host->irq_action != IRQ_WAKE_THREAD)
> + mmci_request_end(host, host->mrq);
> +
> } else if (sbc) {
> mmci_start_command(host, host->mrq->cmd, 0);
> } else if (!host->variant->datactrl_first &&
> @@ -1532,9 +1536,9 @@ static irqreturn_t mmci_irq(int irq, void *dev_id)
> {
> struct mmci_host *host = dev_id;
> u32 status;
> - int ret = 0;
>
> spin_lock(&host->lock);
> + host->irq_action = IRQ_HANDLED;
>
> do {
> status = readl(host->base + MMCISTATUS);
> @@ -1574,12 +1578,41 @@ static irqreturn_t mmci_irq(int irq, void *dev_id)
> if (host->variant->busy_detect_flag)
> status &= ~host->variant->busy_detect_flag;
>
> - ret = 1;
> } while (status);
>
> spin_unlock(&host->lock);
>
> - return IRQ_RETVAL(ret);
> + return host->irq_action;
> +}
> +
> +/*
> + * mmci_irq_threaded is call if the mmci host need to release state machines
> + * before to terminate the request.
> + * If datatimeout occurs on R1B request, the Data Path State Machine stays
> + * in busy and is non-functional. Only a reset can to abort the DPSM.
> + */
> +static irqreturn_t mmci_irq_threaded(int irq, void *dev_id)
> +{
> + struct mmci_host *host = dev_id;
> + unsigned long flags;
> +
> + if (host->rst) {
> + reset_control_assert(host->rst);
> + udelay(2);
> + reset_control_deassert(host->rst);
> + }
> +
> + spin_lock_irqsave(&host->lock, flags);
> + writel(host->clk_reg, host->base + MMCICLOCK);
> + writel(host->pwr_reg, host->base + MMCIPOWER);
> + writel(MCI_IRQENABLE | host->variant->start_err,
> + host->base + MMCIMASK0);
> +
> + host->irq_action = IRQ_HANDLED;
> + mmci_request_end(host, host->mrq);
> + spin_unlock_irqrestore(&host->lock, flags);
> +
> + return host->irq_action;
> }
>
> static void mmci_request(struct mmc_host *mmc, struct mmc_request *mrq)
> @@ -2071,8 +2104,9 @@ static int mmci_probe(struct amba_device *dev,
> goto clk_disable;
> }
>
> - ret = devm_request_irq(&dev->dev, dev->irq[0], mmci_irq, IRQF_SHARED,
> - DRIVER_NAME " (cmd)", host);
> + ret = devm_request_threaded_irq(&dev->dev, dev->irq[0], mmci_irq,
> + mmci_irq_threaded, IRQF_SHARED,
> + DRIVER_NAME " (cmd)", host);
> if (ret)
> goto clk_disable;
>
> diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h
> index 158e1231aa23..5e63c0596364 100644
> --- a/drivers/mmc/host/mmci.h
> +++ b/drivers/mmc/host/mmci.h
> @@ -412,6 +412,7 @@ struct mmci_host {
>
> struct timer_list timer;
> unsigned int oldstat;
> + u32 irq_action;
>
> /* pio stuff */
> struct sg_mapping_iter sg_miter;
> --
> 2.17.1
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH V2] mmc: mmci: add threaded irq to abort DPSM of non-functional state
2019-12-18 14:01 ` Ulf Hansson
@ 2019-12-18 15:19 ` Ludovic BARRE
-1 siblings, 0 replies; 6+ messages in thread
From: Ludovic BARRE @ 2019-12-18 15:19 UTC (permalink / raw)
To: Ulf Hansson
Cc: Rob Herring, Srinivas Kandagatla, Maxime Coquelin,
Alexandre Torgue, Linux ARM, Linux Kernel Mailing List, DTML,
linux-mmc, linux-stm32
hi ulf
Le 12/18/19 à 3:01 PM, Ulf Hansson a écrit :
> On Wed, 11 Dec 2019 at 14:40, Ludovic Barre <ludovic.Barre@st.com> wrote:
>>
>> From: Ludovic Barre <ludovic.barre@st.com>
>>
>> If datatimeout occurs on R1B request, the Data Path State Machine stays
>> in busy and is non-functional. Only a reset aborts the DPSM.
>>
>> Like a reset must be outside of critical section, this patch adds
>> threaded irq function to release state machine. In this case,
>> the mmc_request_done is called at the end of threaded irq and
>> skipped into irq handler.
>>
>> Signed-off-by: Ludovic Barre <ludovic.barre@st.com>
>
> Applied for next, thanks!
>
> I took the liberty of doing some minor updates (changelog/comment),
> please have a look and let me know if there is something you want me
> to change.
>
I read the modifications (changelog and comment function),
and it's ok for me.
thanks
Ludo
> And again, apologize for the delays!
>
> Kind regards
> Uffe
>
>
>> ---
>> change V2:
>> -check IRQ_WAKE_THREAD only in mmci_cmd_irq error part,
>> to avoid this test in mmci_request_end.
>>
>> ---
>> drivers/mmc/host/mmci.c | 46 +++++++++++++++++++++++++++++++++++------
>> drivers/mmc/host/mmci.h | 1 +
>> 2 files changed, 41 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
>> index 40e72c30ea84..2b91757e3e84 100644
>> --- a/drivers/mmc/host/mmci.c
>> +++ b/drivers/mmc/host/mmci.c
>> @@ -1321,6 +1321,7 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd,
>> } else if (host->variant->busy_timeout && busy_resp &&
>> status & MCI_DATATIMEOUT) {
>> cmd->error = -ETIMEDOUT;
>> + host->irq_action = IRQ_WAKE_THREAD;
>> } else {
>> cmd->resp[0] = readl(base + MMCIRESPONSE0);
>> cmd->resp[1] = readl(base + MMCIRESPONSE1);
>> @@ -1339,7 +1340,10 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd,
>> return;
>> }
>> }
>> - mmci_request_end(host, host->mrq);
>> +
>> + if (host->irq_action != IRQ_WAKE_THREAD)
>> + mmci_request_end(host, host->mrq);
>> +
>> } else if (sbc) {
>> mmci_start_command(host, host->mrq->cmd, 0);
>> } else if (!host->variant->datactrl_first &&
>> @@ -1532,9 +1536,9 @@ static irqreturn_t mmci_irq(int irq, void *dev_id)
>> {
>> struct mmci_host *host = dev_id;
>> u32 status;
>> - int ret = 0;
>>
>> spin_lock(&host->lock);
>> + host->irq_action = IRQ_HANDLED;
>>
>> do {
>> status = readl(host->base + MMCISTATUS);
>> @@ -1574,12 +1578,41 @@ static irqreturn_t mmci_irq(int irq, void *dev_id)
>> if (host->variant->busy_detect_flag)
>> status &= ~host->variant->busy_detect_flag;
>>
>> - ret = 1;
>> } while (status);
>>
>> spin_unlock(&host->lock);
>>
>> - return IRQ_RETVAL(ret);
>> + return host->irq_action;
>> +}
>> +
>> +/*
>> + * mmci_irq_threaded is call if the mmci host need to release state machines
>> + * before to terminate the request.
>> + * If datatimeout occurs on R1B request, the Data Path State Machine stays
>> + * in busy and is non-functional. Only a reset can to abort the DPSM.
>> + */
>> +static irqreturn_t mmci_irq_threaded(int irq, void *dev_id)
>> +{
>> + struct mmci_host *host = dev_id;
>> + unsigned long flags;
>> +
>> + if (host->rst) {
>> + reset_control_assert(host->rst);
>> + udelay(2);
>> + reset_control_deassert(host->rst);
>> + }
>> +
>> + spin_lock_irqsave(&host->lock, flags);
>> + writel(host->clk_reg, host->base + MMCICLOCK);
>> + writel(host->pwr_reg, host->base + MMCIPOWER);
>> + writel(MCI_IRQENABLE | host->variant->start_err,
>> + host->base + MMCIMASK0);
>> +
>> + host->irq_action = IRQ_HANDLED;
>> + mmci_request_end(host, host->mrq);
>> + spin_unlock_irqrestore(&host->lock, flags);
>> +
>> + return host->irq_action;
>> }
>>
>> static void mmci_request(struct mmc_host *mmc, struct mmc_request *mrq)
>> @@ -2071,8 +2104,9 @@ static int mmci_probe(struct amba_device *dev,
>> goto clk_disable;
>> }
>>
>> - ret = devm_request_irq(&dev->dev, dev->irq[0], mmci_irq, IRQF_SHARED,
>> - DRIVER_NAME " (cmd)", host);
>> + ret = devm_request_threaded_irq(&dev->dev, dev->irq[0], mmci_irq,
>> + mmci_irq_threaded, IRQF_SHARED,
>> + DRIVER_NAME " (cmd)", host);
>> if (ret)
>> goto clk_disable;
>>
>> diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h
>> index 158e1231aa23..5e63c0596364 100644
>> --- a/drivers/mmc/host/mmci.h
>> +++ b/drivers/mmc/host/mmci.h
>> @@ -412,6 +412,7 @@ struct mmci_host {
>>
>> struct timer_list timer;
>> unsigned int oldstat;
>> + u32 irq_action;
>>
>> /* pio stuff */
>> struct sg_mapping_iter sg_miter;
>> --
>> 2.17.1
>>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH V2] mmc: mmci: add threaded irq to abort DPSM of non-functional state
@ 2019-12-18 15:19 ` Ludovic BARRE
0 siblings, 0 replies; 6+ messages in thread
From: Ludovic BARRE @ 2019-12-18 15:19 UTC (permalink / raw)
To: Ulf Hansson
Cc: DTML, Alexandre Torgue, linux-mmc, Linux Kernel Mailing List,
Rob Herring, Srinivas Kandagatla, Maxime Coquelin, linux-stm32,
Linux ARM
hi ulf
Le 12/18/19 à 3:01 PM, Ulf Hansson a écrit :
> On Wed, 11 Dec 2019 at 14:40, Ludovic Barre <ludovic.Barre@st.com> wrote:
>>
>> From: Ludovic Barre <ludovic.barre@st.com>
>>
>> If datatimeout occurs on R1B request, the Data Path State Machine stays
>> in busy and is non-functional. Only a reset aborts the DPSM.
>>
>> Like a reset must be outside of critical section, this patch adds
>> threaded irq function to release state machine. In this case,
>> the mmc_request_done is called at the end of threaded irq and
>> skipped into irq handler.
>>
>> Signed-off-by: Ludovic Barre <ludovic.barre@st.com>
>
> Applied for next, thanks!
>
> I took the liberty of doing some minor updates (changelog/comment),
> please have a look and let me know if there is something you want me
> to change.
>
I read the modifications (changelog and comment function),
and it's ok for me.
thanks
Ludo
> And again, apologize for the delays!
>
> Kind regards
> Uffe
>
>
>> ---
>> change V2:
>> -check IRQ_WAKE_THREAD only in mmci_cmd_irq error part,
>> to avoid this test in mmci_request_end.
>>
>> ---
>> drivers/mmc/host/mmci.c | 46 +++++++++++++++++++++++++++++++++++------
>> drivers/mmc/host/mmci.h | 1 +
>> 2 files changed, 41 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
>> index 40e72c30ea84..2b91757e3e84 100644
>> --- a/drivers/mmc/host/mmci.c
>> +++ b/drivers/mmc/host/mmci.c
>> @@ -1321,6 +1321,7 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd,
>> } else if (host->variant->busy_timeout && busy_resp &&
>> status & MCI_DATATIMEOUT) {
>> cmd->error = -ETIMEDOUT;
>> + host->irq_action = IRQ_WAKE_THREAD;
>> } else {
>> cmd->resp[0] = readl(base + MMCIRESPONSE0);
>> cmd->resp[1] = readl(base + MMCIRESPONSE1);
>> @@ -1339,7 +1340,10 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd,
>> return;
>> }
>> }
>> - mmci_request_end(host, host->mrq);
>> +
>> + if (host->irq_action != IRQ_WAKE_THREAD)
>> + mmci_request_end(host, host->mrq);
>> +
>> } else if (sbc) {
>> mmci_start_command(host, host->mrq->cmd, 0);
>> } else if (!host->variant->datactrl_first &&
>> @@ -1532,9 +1536,9 @@ static irqreturn_t mmci_irq(int irq, void *dev_id)
>> {
>> struct mmci_host *host = dev_id;
>> u32 status;
>> - int ret = 0;
>>
>> spin_lock(&host->lock);
>> + host->irq_action = IRQ_HANDLED;
>>
>> do {
>> status = readl(host->base + MMCISTATUS);
>> @@ -1574,12 +1578,41 @@ static irqreturn_t mmci_irq(int irq, void *dev_id)
>> if (host->variant->busy_detect_flag)
>> status &= ~host->variant->busy_detect_flag;
>>
>> - ret = 1;
>> } while (status);
>>
>> spin_unlock(&host->lock);
>>
>> - return IRQ_RETVAL(ret);
>> + return host->irq_action;
>> +}
>> +
>> +/*
>> + * mmci_irq_threaded is call if the mmci host need to release state machines
>> + * before to terminate the request.
>> + * If datatimeout occurs on R1B request, the Data Path State Machine stays
>> + * in busy and is non-functional. Only a reset can to abort the DPSM.
>> + */
>> +static irqreturn_t mmci_irq_threaded(int irq, void *dev_id)
>> +{
>> + struct mmci_host *host = dev_id;
>> + unsigned long flags;
>> +
>> + if (host->rst) {
>> + reset_control_assert(host->rst);
>> + udelay(2);
>> + reset_control_deassert(host->rst);
>> + }
>> +
>> + spin_lock_irqsave(&host->lock, flags);
>> + writel(host->clk_reg, host->base + MMCICLOCK);
>> + writel(host->pwr_reg, host->base + MMCIPOWER);
>> + writel(MCI_IRQENABLE | host->variant->start_err,
>> + host->base + MMCIMASK0);
>> +
>> + host->irq_action = IRQ_HANDLED;
>> + mmci_request_end(host, host->mrq);
>> + spin_unlock_irqrestore(&host->lock, flags);
>> +
>> + return host->irq_action;
>> }
>>
>> static void mmci_request(struct mmc_host *mmc, struct mmc_request *mrq)
>> @@ -2071,8 +2104,9 @@ static int mmci_probe(struct amba_device *dev,
>> goto clk_disable;
>> }
>>
>> - ret = devm_request_irq(&dev->dev, dev->irq[0], mmci_irq, IRQF_SHARED,
>> - DRIVER_NAME " (cmd)", host);
>> + ret = devm_request_threaded_irq(&dev->dev, dev->irq[0], mmci_irq,
>> + mmci_irq_threaded, IRQF_SHARED,
>> + DRIVER_NAME " (cmd)", host);
>> if (ret)
>> goto clk_disable;
>>
>> diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h
>> index 158e1231aa23..5e63c0596364 100644
>> --- a/drivers/mmc/host/mmci.h
>> +++ b/drivers/mmc/host/mmci.h
>> @@ -412,6 +412,7 @@ struct mmci_host {
>>
>> struct timer_list timer;
>> unsigned int oldstat;
>> + u32 irq_action;
>>
>> /* pio stuff */
>> struct sg_mapping_iter sg_miter;
>> --
>> 2.17.1
>>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-12-18 15:20 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-11 13:39 [PATCH V2] mmc: mmci: add threaded irq to abort DPSM of non-functional state Ludovic Barre
2019-12-11 13:39 ` Ludovic Barre
2019-12-18 14:01 ` Ulf Hansson
2019-12-18 14:01 ` Ulf Hansson
2019-12-18 15:19 ` Ludovic BARRE
2019-12-18 15:19 ` Ludovic BARRE
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.