LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] mmc: dw_mmc: Only inject fault before done/error
@ 2021-08-25 11:42 ` Vincent Whitchurch
2021-08-25 22:51 ` Jaehoon Chung
2021-09-06 17:09 ` Ulf Hansson
0 siblings, 2 replies; 3+ messages in thread
From: Vincent Whitchurch @ 2021-08-25 11:42 UTC (permalink / raw)
To: Jaehoon Chung, Ulf Hansson
Cc: kernel, Vincent Whitchurch, linux-mmc, linux-kernel
The fault injection function can set EVENT_DATA_ERROR but skip the
setting of ->data_status to an error status if it hits just after a data
over interrupt. This confuses the tasklet which can later end up
triggering the WARN_ON(host->cmd || ..) in dw_mci_request_end() since
dw_mci_data_complete() would return success.
Prevent the fault injection function from doing this since this is not a
real case, and ensure that the fault injection doesn't race with a real
error either.
Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
---
drivers/mmc/host/dw_mmc.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index 6578cc64ae9e..380f9aa56eb2 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -1802,10 +1802,15 @@ static enum hrtimer_restart dw_mci_fault_timer(struct hrtimer *t)
spin_lock_irqsave(&host->irq_lock, flags);
- if (!host->data_status)
+ /*
+ * Only inject an error if we haven't already got an error or data over
+ * interrupt.
+ */
+ if (!host->data_status) {
host->data_status = SDMMC_INT_DCRC;
- set_bit(EVENT_DATA_ERROR, &host->pending_events);
- tasklet_schedule(&host->tasklet);
+ set_bit(EVENT_DATA_ERROR, &host->pending_events);
+ tasklet_schedule(&host->tasklet);
+ }
spin_unlock_irqrestore(&host->irq_lock, flags);
@@ -2721,12 +2726,16 @@ static irqreturn_t dw_mci_interrupt(int irq, void *dev_id)
}
if (pending & DW_MCI_DATA_ERROR_FLAGS) {
+ spin_lock(&host->irq_lock);
+
/* if there is an error report DATA_ERROR */
mci_writel(host, RINTSTS, DW_MCI_DATA_ERROR_FLAGS);
host->data_status = pending;
smp_wmb(); /* drain writebuffer */
set_bit(EVENT_DATA_ERROR, &host->pending_events);
tasklet_schedule(&host->tasklet);
+
+ spin_unlock(&host->irq_lock);
}
if (pending & SDMMC_INT_DATA_OVER) {
--
2.28.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mmc: dw_mmc: Only inject fault before done/error
2021-08-25 11:42 ` [PATCH] mmc: dw_mmc: Only inject fault before done/error Vincent Whitchurch
@ 2021-08-25 22:51 ` Jaehoon Chung
2021-09-06 17:09 ` Ulf Hansson
1 sibling, 0 replies; 3+ messages in thread
From: Jaehoon Chung @ 2021-08-25 22:51 UTC (permalink / raw)
To: Vincent Whitchurch, Ulf Hansson; +Cc: kernel, linux-mmc, linux-kernel
On 8/25/21 8:42 PM, Vincent Whitchurch wrote:
> The fault injection function can set EVENT_DATA_ERROR but skip the
> setting of ->data_status to an error status if it hits just after a data
> over interrupt. This confuses the tasklet which can later end up
> triggering the WARN_ON(host->cmd || ..) in dw_mci_request_end() since
> dw_mci_data_complete() would return success.
>
> Prevent the fault injection function from doing this since this is not a
> real case, and ensure that the fault injection doesn't race with a real
> error either.
>
> Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
Best Regards,
Jaehoon Chung
> ---
> drivers/mmc/host/dw_mmc.c | 15 ++++++++++++---
> 1 file changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
> index 6578cc64ae9e..380f9aa56eb2 100644
> --- a/drivers/mmc/host/dw_mmc.c
> +++ b/drivers/mmc/host/dw_mmc.c
> @@ -1802,10 +1802,15 @@ static enum hrtimer_restart dw_mci_fault_timer(struct hrtimer *t)
>
> spin_lock_irqsave(&host->irq_lock, flags);
>
> - if (!host->data_status)
> + /*
> + * Only inject an error if we haven't already got an error or data over
> + * interrupt.
> + */
> + if (!host->data_status) {
> host->data_status = SDMMC_INT_DCRC;
> - set_bit(EVENT_DATA_ERROR, &host->pending_events);
> - tasklet_schedule(&host->tasklet);
> + set_bit(EVENT_DATA_ERROR, &host->pending_events);
> + tasklet_schedule(&host->tasklet);
> + }
>
> spin_unlock_irqrestore(&host->irq_lock, flags);
>
> @@ -2721,12 +2726,16 @@ static irqreturn_t dw_mci_interrupt(int irq, void *dev_id)
> }
>
> if (pending & DW_MCI_DATA_ERROR_FLAGS) {
> + spin_lock(&host->irq_lock);
> +
> /* if there is an error report DATA_ERROR */
> mci_writel(host, RINTSTS, DW_MCI_DATA_ERROR_FLAGS);
> host->data_status = pending;
> smp_wmb(); /* drain writebuffer */
> set_bit(EVENT_DATA_ERROR, &host->pending_events);
> tasklet_schedule(&host->tasklet);
> +
> + spin_unlock(&host->irq_lock);
> }
>
> if (pending & SDMMC_INT_DATA_OVER) {
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mmc: dw_mmc: Only inject fault before done/error
2021-08-25 11:42 ` [PATCH] mmc: dw_mmc: Only inject fault before done/error Vincent Whitchurch
2021-08-25 22:51 ` Jaehoon Chung
@ 2021-09-06 17:09 ` Ulf Hansson
1 sibling, 0 replies; 3+ messages in thread
From: Ulf Hansson @ 2021-09-06 17:09 UTC (permalink / raw)
To: Vincent Whitchurch
Cc: Jaehoon Chung, kernel, linux-mmc, Linux Kernel Mailing List
On Wed, 25 Aug 2021 at 13:42, Vincent Whitchurch
<vincent.whitchurch@axis.com> wrote:
>
> The fault injection function can set EVENT_DATA_ERROR but skip the
> setting of ->data_status to an error status if it hits just after a data
> over interrupt. This confuses the tasklet which can later end up
> triggering the WARN_ON(host->cmd || ..) in dw_mci_request_end() since
> dw_mci_data_complete() would return success.
>
> Prevent the fault injection function from doing this since this is not a
> real case, and ensure that the fault injection doesn't race with a real
> error either.
>
> Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
Applied for fixes and by adding a fixes tag, thanks!
Kind regards
Uffe
> ---
> drivers/mmc/host/dw_mmc.c | 15 ++++++++++++---
> 1 file changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
> index 6578cc64ae9e..380f9aa56eb2 100644
> --- a/drivers/mmc/host/dw_mmc.c
> +++ b/drivers/mmc/host/dw_mmc.c
> @@ -1802,10 +1802,15 @@ static enum hrtimer_restart dw_mci_fault_timer(struct hrtimer *t)
>
> spin_lock_irqsave(&host->irq_lock, flags);
>
> - if (!host->data_status)
> + /*
> + * Only inject an error if we haven't already got an error or data over
> + * interrupt.
> + */
> + if (!host->data_status) {
> host->data_status = SDMMC_INT_DCRC;
> - set_bit(EVENT_DATA_ERROR, &host->pending_events);
> - tasklet_schedule(&host->tasklet);
> + set_bit(EVENT_DATA_ERROR, &host->pending_events);
> + tasklet_schedule(&host->tasklet);
> + }
>
> spin_unlock_irqrestore(&host->irq_lock, flags);
>
> @@ -2721,12 +2726,16 @@ static irqreturn_t dw_mci_interrupt(int irq, void *dev_id)
> }
>
> if (pending & DW_MCI_DATA_ERROR_FLAGS) {
> + spin_lock(&host->irq_lock);
> +
> /* if there is an error report DATA_ERROR */
> mci_writel(host, RINTSTS, DW_MCI_DATA_ERROR_FLAGS);
> host->data_status = pending;
> smp_wmb(); /* drain writebuffer */
> set_bit(EVENT_DATA_ERROR, &host->pending_events);
> tasklet_schedule(&host->tasklet);
> +
> + spin_unlock(&host->irq_lock);
> }
>
> if (pending & SDMMC_INT_DATA_OVER) {
> --
> 2.28.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-09-06 17:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CGME20210825114239epcas1p30b69652c975c001082e729fc27ef04c1@epcas1p3.samsung.com>
2021-08-25 11:42 ` [PATCH] mmc: dw_mmc: Only inject fault before done/error Vincent Whitchurch
2021-08-25 22:51 ` Jaehoon Chung
2021-09-06 17:09 ` Ulf Hansson
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).