mmc: mmci: add busy detect for stm32 sdmmc variant
Subsystems (2)
v3 cover mmc: mmci: add busy detect for stm32 sdmmc variant
From: Ludovic Barre <[email protected]>
This patch series adds busy detect for stm32 sdmmc variant. Some adaptations are required:
-Clear busy status bit if busy_detect_flag and busy_detect_mask are
different.
-Add hardware busy timeout with MMCIDATATIMER register.
V3:
-rebase on latest mmc next
-replace re-read by status parameter.
V2:
-mmci_cmd_irq cleanup in separate patch.
-simplify the busy_detect_flag exclude
-replace sdmmc specific comment in
"mmc: mmci: avoid fake busy polling in mmci_irq"
to focus on common behavior
Ludovic Barre (3):
mmc: mmci: fix read status for busy detect
mmc: mmci: add hardware busy timeout feature
mmc: mmci: add busy detect for stm32 sdmmc variant
drivers/mmc/host/mmci.c | 49 +++++++++++++++++++++++++++++++++++++++++-------- drivers/mmc/host/mmci.h | 3 +++ 2 files changed, 44 insertions(+), 8 deletions(-)
Signature · 1 line
2.7.4
PATCH v3 1/3 mmc: mmci: fix read status for busy detect
From: Ludovic Barre <[email protected]>
"busy_detect_flag" is used to read & clear busy value of mmci status. "busy_detect_mask" is used to manage busy irq of mmci mask. So to read mmci status the busy_detect_flag must be take account. if the variant does not support busy detect feature the flag is null and there is no impact.
Not need to re-read the status register in mmci_cmd_irq, the status parameter can be used.
--- drivers/mmc/host/mmci.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/mmc/host/mmci.c +3 -2
@@ -1240,7 +1240,7 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd,*/ if (!host->busy_status && !(status & (MCI_CMDCRCFAIL |MCI_CMDTIMEOUT )) && - (readl (base +MMCISTATUS ) & host->variant->busy_detect_flag)) { + (status & host->variant->busy_detect_flag)) {/* Clear the busy start IRQ */ writel(host->variant->busy_detect_mask,
@@ -1517,7 +1517,8 @@ static irqreturn_t mmci_irq(int irq, void *dev_id)* to make sure that both start and end interrupts are always * cleared one after the other. */ - status &=readl (host->base +MMCIMASK0 ); + status &=readl (host->base +MMCIMASK0 ) | + host->variant->busy_detect_flag;if (host->variant->busy_detect)writel (status & ~host->variant->busy_detect_mask, host->base +MMCICLEAR );
Signature · 1 line
2.7.4
Re: [PATCH V3 1/3] mmc: mmci: fix read status for busy detect
Quoted 8 lines · Ludovic Barre
From: Ludovic Barre <[email protected]>
"
busy_detect_flag" is used to read & clear busy value of mmci status. "busy_detect_mask" is used to manage busy irq of mmci mask. So to read mmci status thebusy_detect_flagmust be take account. if the variant does not support busy detect feature the flag is null and there is no impact.
By reading the changelog, it doesn't tell me the purpose of this change. When going forward, please work harder on your changelogs.
Make sure to answer the questions, *why* is this change needed, *what/how* does the change do.
Quoted 14 lines
Not need to re-read the status register in
mmci_cmd_irq, the status parameter can be used.Signed-off-by Ludovic Barre <[email protected]>--- drivers/mmc/host/mmci.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/mmc/host/mmci.c +0
-0
drivers/mmc/host/mmci.c mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd, · line 1243
Quoted 5 lines
drivers/mmc/host/mmci.c +1
-1@@ -1240,7 +1240,7 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd,*/ if (!host->busy_status && !(status & (MCI_CMDCRCFAIL |MCI_CMDTIMEOUT )) && - (readl (base +MMCISTATUS ) & host->variant->busy_detect_flag)) { + (status & host->variant->busy_detect_flag)) {
I suggested you to do this change through some of my earlier comments, however I think it should be made as a stand alone change.
Anyway, when looking at the details in your series, I decided to try to help out a bit, so I have prepared a couple of related patches for cleaning up and clarifying the busy detection code/comments in mmci. I have incorporated the above change, so let me post them asap.
drivers/mmc/host/mmci.c static irqreturn_t mmci_irq(int irq, void *dev_id) · line 1521
Quoted 10 lines
drivers/mmc/host/mmci.c +2
-1/* Clear the busy start IRQ */ writel(host->variant->busy_detect_mask,@@ -1517,7 +1517,8 @@ static irqreturn_t mmci_irq(int irq, void *dev_id)* to make sure that both start and end interrupts are always * cleared one after the other. */ - status &=readl (host->base +MMCIMASK0 ); + status &=readl (host->base +MMCIMASK0 ) | + host->variant->busy_detect_flag;
As I told earlier in the review, this looks wrong to me.
It means that you will add the bit for the ->busy_detect_flag to the status field we have just read from the MMCISTATUS register. That means the busy status may be set when it shouldn't.
Quoted 6 lines
drivers/mmc/host/mmci.c +0
-1if (host->variant->busy_detect)writel (status & ~host->variant->busy_detect_mask, host->base +MMCICLEAR ); --2.7.4
By looking at the other changes in the series, I assume @subject patch is intended to prepare for the other changes on top. But it's not really clear.
Anyway, in that regards, the below is my observations of what seems to be important part, when supporting busy detection for the stm32 sdmmc variant (except the timeout things in patch2, which I intend to comment separately on).
I figured, these are the involved register bits/masks:
MMCISTATUS:MCI_STM32_BUSYD0 BIT(20)MCI_STM32_BUSYD0END BIT(21)
MMCIMASK0:MCI_STM32_BUSYD0ENDMASK BIT(21)
For the legacy ST variant, there is only one register bit in MMCISTATUS that is used for indicating busy (MCI_ST_CARDBUSY BIT(24)). There is no dedicated busy-end bit for the busy-end IRQ, which I believe is the reason to why the current code also is bit messy.
It seems like the stm32 sdmmc variant have a separate status bit for the busy-end IRQ, correct?
If I understand correctly by looking at patch3, you don't use the dedicated busy-end status bit (MCI_STM32_BUSYD0END), right? Then why not?
Thoughts?
Kind regards
Uffe
Re: [PATCH V3 1/3] mmc: mmci: fix read status for busy detect
hi Ulf
Thanks to your "Clarify comments ..." commit, like is closes I resumed upstream of this series.
Quoted 10 lines · Ulf Hansson
Quoted 8 lines · Ludovic Barre
From: Ludovic Barre <[email protected]>
"
busy_detect_flag" is used to read & clear busy value of mmci status. "busy_detect_mask" is used to manage busy irq of mmci mask. So to read mmci status thebusy_detect_flagmust be take account. if the variant does not support busy detect feature the flag is null and there is no impact.
Quoted 5 lines
By reading the changelog, it doesn't tell me the purpose of this change. When going forward, please work harder on your changelogs.
Make sure to answer the questions, *why* is this change needed, *what/how* does the change do.
Ok, I will explain the differences with the legacy and the needs of sdmmc variant about busy detection.
Quoted 62 lines
Quoted 15 lines
Not need to re-read the status register in
mmci_cmd_irq, the status parameter can be used.Signed-off-by Ludovic Barre <[email protected]>--- drivers/mmc/host/mmci.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/mmc/host/mmci.c +0
-0drivers/mmc/host/mmci.c mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd, · line 1243
Quoted 5 lines
drivers/mmc/host/mmci.c +1
-1@@ -1240,7 +1240,7 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd,*/ if (!host->busy_status && !(status & (MCI_CMDCRCFAIL |MCI_CMDTIMEOUT )) && - (readl (base +MMCISTATUS ) & host->variant->busy_detect_flag)) { + (status & host->variant->busy_detect_flag)) {I suggested you to do this change through some of my earlier comments, however I think it should be made as a stand alone change.
Anyway, when looking at the details in your series, I decided to try to help out a bit, so I have prepared a couple of related patches for cleaning up and clarifying the busy detection code/comments in mmci. I have incorporated the above change, so let me post them asap.
drivers/mmc/host/mmci.c static irqreturn_t mmci_irq(int irq, void *dev_id) · line 1521
Quoted 10 lines
drivers/mmc/host/mmci.c +2
-1/* Clear the busy start IRQ */ writel(host->variant->busy_detect_mask,@@ -1517,7 +1517,8 @@ static irqreturn_t mmci_irq(int irq, void *dev_id)* to make sure that both start and end interrupts are always * cleared one after the other. */ - status &=readl (host->base +MMCIMASK0 ); + status &=readl (host->base +MMCIMASK0 ) | + host->variant->busy_detect_flag;As I told earlier in the review, this looks wrong to me.
It means that you will add the bit for the ->busy_detect_flag to the status field we have just read from the MMCISTATUS register. That means the busy status may be set when it shouldn't.
Quoted 6 lines
drivers/mmc/host/mmci.c +0
-1if (host->variant->busy_detect)writel (status & ~host->variant->busy_detect_mask, host->base +MMCICLEAR ); --2.7.4
By looking at the other changes in the series, I assume @subject patch is intended to prepare for the other changes on top. But it's not really clear.
Anyway, in that regards, the below is my observations of what seems to be important part, when supporting busy detection for the stm32 sdmmc variant (except the timeout things in patch2, which I intend to comment separately on).
Quoted 8 lines
I figured, these are the involved register bits/masks:
MMCISTATUS:
MCI_STM32_BUSYD0BIT(20)MCI_STM32_BUSYD0ENDBIT(21)MMCIMASK0:
MCI_STM32_BUSYD0ENDMASKBIT(21)
it's exact:MCI_STM32_BUSYD0 BIT(20): This is a hardware status flag only (inverted value of d0 line), it does not generate an interrupt, and so no mask bit.
MCI_STM32_BUSYD0ENDMASK BIT(21): This indicates only end of busy following a CMD response. On busy to Not busy changes, an interrupt is generated (if unmask) and BUSYD0END status flag is set.
status flag is cleared by writing corresponding interrupt clear bit in MMCICLEAR.
Quoted 5 lines
For the legacy ST variant, there is only one register bit in MMCISTATUS that is used for indicating busy (
MCI_ST_CARDBUSYBIT(24)). There is no dedicated busy-end bit for the busy-end IRQ, which I believe is the reason to why the current code also is bit messy.
yes
Quoted 3 lines
It seems like the stm32 sdmmc variant have a separate status bit for the busy-end IRQ, correct?
yes
Quoted 4 lines
If I understand correctly by looking at patch3, you don't use the dedicated busy-end status bit (
MCI_STM32_BUSYD0END), right? Then why not?
like your are clarify in previous series, the busy detection is done in 3 steps.
if I use:
.busy_detect_flag = MCI_STM32_BUSYD0ENDMASK,
.busy_detect_mask = MCI_STM32_BUSYD0ENDMASK,
the sdmmc request will be not correctly completed, because the third step can't be happen.
chronologies:
step1: when busyd0end change to 1
=> busyd0end interrupt is unmasked
=> busy_status = cmd_sent | respend
=> return to mmci_irq
step2: busyd0end is yet to 1
=> clear the busyd0end interrupt
=> the hardware clear busyd0end status flag on interrupt clear
=> return to mmci_irq
like MCI_STM32_BUSYD0END interrupt is generated only on change busy to not busy, when the interrupt is cleared (status is 0) the step 3 can't happen (no irq pending to re-enter in mmci_cmd_irq). sdmmc can't complete the request.
If I use:
.busy_detect_flag = MCI_STM32_BUSYD0,
.busy_detect_mask = MCI_STM32_BUSYD0ENDMASK,
Like there is no MCI_STM32_BUSYD0 irq mask, the status read in mmci_irq
"status &= readl(host->base + MMCIMASK0)" can't take account the busy_detect_flag (for sdmmc). So the step 2 can't be passed. However we could share re-read between step 1 and step 2.
proposal:
+
+ u32 busy_val = readl(base + MMCISTATUS) &
+ host->variant->busy_detect_flag;
+
if (!host->busy_status &&
- !(status & (MCI_CMDCRCFAIL|MCI_CMDTIMEOUT)) &&
- (readl(base + MMCISTATUS) & host->variant->busy_detect_flag)) {
+ !(status & (MCI_CMDCRCFAIL|MCI_CMDTIMEOUT)) && busy_val) { writel(readl(base + MMCIMASK0) |
host->variant->busy_detect_mask,
@@ -1262,8 +1265,7 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd,
* both the start and the end interrupts needs to be cleared,
* one after the other. So, clear the busy start IRQ here. */
- if (host->busy_status &&
- (status & host->variant->busy_detect_flag)) {
+ if (host->busy_status && busy_val) {
what do you think about it ?
Quoted 6 lines
Thoughts?
Kind regards
Uffe
Regards
Ludo
Re: [Linux-stm32] [PATCH V3 1/3] mmc: mmci: fix read status for busy detect
hi Ulf
Quoted 181 lines · Ludovic BARRE
hi Ulf
Thanks to your "Clarify comments ..." commit, like is closes I resumed upstream of this series.
Quoted 10 lines · Ulf Hansson
Quoted 8 lines · Ludovic Barre
From: Ludovic Barre <[email protected]>
"
busy_detect_flag" is used to read & clear busy value of mmci status. "busy_detect_mask" is used to manage busy irq of mmci mask. So to read mmci status thebusy_detect_flagmust be take account. if the variant does not support busy detect feature the flag is null and there is no impact.Quoted 5 lines
By reading the changelog, it doesn't tell me the purpose of this change. When going forward, please work harder on your changelogs.
Make sure to answer the questions, *why* is this change needed, *what/how* does the change do.
Ok, I will explain the differences with the legacy and the needs of sdmmc variant about busy detection.
Quoted 64 lines
Quoted 17 lines
Not need to re-read the status register in
mmci_cmd_irq, the status parameter can be used.Signed-off-by Ludovic Barre <[email protected]>---
drivers/mmc/host/mmci.c| 5 +++--1 file changed, 3 insertions(+), 2 deletions(-)drivers/mmc/host/mmci.c +0
-0@@ -1240,7 +1240,7 @@ mmci_cmd_irq(struct mmci_host *host, structmmc_command *cmd, */ Quoted 5 lines
if (!host->busy_status &&
!(status & (MCI_CMDCRCFAIL|MCI_CMDTIMEOUT)) && - (readl(base + MMCISTATUS) &host->variant->busy_detect_flag)) {
+ (status &host->variant->busy_detect_flag)) {I suggested you to do this change through some of my earlier comments, however I think it should be made as a stand alone change.
Anyway, when looking at the details in your series, I decided to try to help out a bit, so I have prepared a couple of related patches for cleaning up and clarifying the busy detection code/comments in mmci. I have incorporated the above change, so let me post them asap.
drivers/mmc/host/mmci.c static irqreturn_t mmci_irq(int irq, void *dev_id) · line 1521
Quoted 10 lines
/* Clear the busy start IRQ */ writel(host->variant->busy_detect_mask,
drivers/mmc/host/mmci.c +2
-1@@ -1517,7 +1517,8 @@ static irqreturn_t mmci_irq(int irq, void *dev_id)* to make sure that both start and end interrupts are always * cleared one after the other. */ - status &= readl(host->base + MMCIMASK0); + status &= readl(host->base + MMCIMASK0) | + host->variant->busy_detect_flag;As I told earlier in the review, this looks wrong to me.
It means that you will add the bit for the ->busy_detect_flag to the status field we have just read from the MMCISTATUS register. That means the busy status may be set when it shouldn't.
Quoted 6 lines
drivers/mmc/host/mmci.c +0
-0if (host->variant->busy_detect) writel(status & ~host->variant->busy_detect_mask, host->base + MMCICLEAR);Signature · 1 line
2.7.4By looking at the other changes in the series, I assume @subject patch is intended to prepare for the other changes on top. But it's not really clear.
Anyway, in that regards, the below is my observations of what seems to be important part, when supporting busy detection for the stm32 sdmmc variant (except the timeout things in patch2, which I intend to comment separately on).
Quoted 8 lines
I figured, these are the involved register bits/masks:
MMCISTATUS:
MCI_STM32_BUSYD0BIT(20)MCI_STM32_BUSYD0ENDBIT(21)MMCIMASK0:
MCI_STM32_BUSYD0ENDMASKBIT(21)it's exact:
MCI_STM32_BUSYD0BIT(20): This is a hardware status flag only (inverted value of d0 line), it does not generate an interrupt, and so no mask bit.
MCI_STM32_BUSYD0ENDMASKBIT(21): This indicates only end of busy following a CMD response. On busy to Not busy changes, an interrupt is generated (if unmask) and BUSYD0END status flag is set.
status flag is cleared by writing corresponding interrupt clear bit in MMCICLEAR.Quoted 5 lines
For the legacy ST variant, there is only one register bit in MMCISTATUS that is used for indicating busy (
MCI_ST_CARDBUSYBIT(24)). There is no dedicated busy-end bit for the busy-end IRQ, which I believe is the reason to why the current code also is bit messy.yes
Quoted 3 lines
It seems like the stm32 sdmmc variant have a separate status bit for the busy-end IRQ, correct?
yes
Quoted 4 lines
If I understand correctly by looking at patch3, you don't use the dedicated busy-end status bit (
MCI_STM32_BUSYD0END), right? Then why not?like your are clarify in previous series, the busy detection is done in 3 steps.
if I use:
.busy_detect_flag =MCI_STM32_BUSYD0ENDMASK,
.busy_detect_mask =MCI_STM32_BUSYD0ENDMASK,the sdmmc request will be not correctly completed, because the third step can't be happen.
chronologies:
step1: when busyd0end change to 1
=> busyd0end interrupt is unmasked
=>busy_status=cmd_sent| respend
=> return tommci_irq
step2: busyd0end is yet to 1
=> clear the busyd0end interrupt
=> the hardware clear busyd0end status flag on interrupt clear => return tommci_irqlike
MCI_STM32_BUSYD0ENDinterrupt is generated only on change busy to not busy, when the interrupt is cleared (status is 0) the step 3 can't happen (no irq pending to re-enter inmmci_cmd_irq). sdmmc can't complete the request.If I use:
.busy_detect_flag =MCI_STM32_BUSYD0,
.busy_detect_mask =MCI_STM32_BUSYD0ENDMASK,Like there is no
MCI_STM32_BUSYD0irq mask, the status read inmmci_irq
"status &=readl(host->base + MMCIMASK0)" can't take account thebusy_detect_flag(for sdmmc). So the step 2 can't be passed. However we could share re-read between step 1 and step 2.proposal:
(quoted diff) +4
-2+ + u32 busy_val = readl(base + MMCISTATUS) & + host->variant->busy_detect_flag; + if (!host->busy_status && - !(status & (MCI_CMDCRCFAIL|MCI_CMDTIMEOUT)) && - (readl(base + MMCISTATUS) &
host->variant->busy_detect_flag)) {
+ !(status & (MCI_CMDCRCFAIL|MCI_CMDTIMEOUT)) &&busy_val) {writel(readl(base + MMCIMASK0) |
host->variant->busy_detect_mask,(quoted diff) +1
-2@@ -1262,8 +1265,7 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd, * both the start and the end interrupts needs to be cleared, * one after the other. So, clear the busy start IRQ here. */ - if (host->busy_status && - (status & host->variant->busy_detect_flag)) { + if (host->busy_status && busy_val) {
Quoted 2 lines
what do you think about it ?
I give up this proposal for a new version based on mmci_host_ops callback to done the busy completion.
Quoted 7 lines
Quoted 6 lines
Thoughts?
Kind regards
Uffe
Quoted 6 lines
Regards
Ludo
_______________________________________________
Linux-stm32 mailing list
[email protected]
https://st-md-mailman.stormreply.com/mailman/listinfo/linux-stm32
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v3 2/3 mmc: mmci: add hardware busy timeout feature
In reply to Ludovic BarreFrom: Ludovic Barre <[email protected]>
In some variants, the data timer is enabled when the DPSM is in busy state (while data transfer or MMC_RSP_BUSY), and could generate a data timeout error if the counter reach 0.
-Define max_busy_timeout (in ms) according to clock. -Set data timer register if the command has rsp_busy flag.
If busy_timeout is not defined by framework, the busy length after Data Burst is defined as 1 second (refer: 4.6.2.2 Write of sd specification part1 v6-0).
-Add MCI_DATATIMEOUT error management in mmci_cmd_irq.
--- drivers/mmc/host/mmci.c | 40 ++++++++++++++++++++++++++++++++++------ drivers/mmc/host/mmci.h | 2 ++ 2 files changed, 36 insertions(+), 6 deletions(-)
drivers/mmc/host/mmci.c +34 -6
@@ -1078,6 +1078,7 @@ static void mmci_start_command(struct mmci_host *host, struct mmc_command *cmd, u32 c) { void __iomem *base = host->base; +unsigned long long clks =0 ;dev_dbg (mmc_dev (host->mmc),"op %02x arg %08x flags %08x\n" , cmd->opcode, cmd->arg, cmd->flags);
@@ -1100,6 +1101,19 @@ mmci_start_command(struct mmci_host *host, struct mmc_command *cmd, u32 c)else c |= host->variant->cmdreg_srsp; } + +if (host->variant->busy_timeout && !cmd->data) { +if (cmd->flags &MMC_RSP_BUSY ) { +if (!cmd->busy_timeout) + cmd->busy_timeout =1000 ; + + clks = (unsigned long long )cmd->busy_timeout; + clks *= host->cclk; +do_div (clks,MSEC_PER_SEC ); + } +writel_relaxed (clks, host->base +MMCIDATATIMER ); + } +if (/*interrupt*/ 0 ) c |=MCI_CPSM_INTERRUPT ;
@@ -1206,6 +1220,7 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd, {void __iomem *base = host->base;bool sbc, busy_resp; +u32 err_msk;if (!cmd)return ;
@@ -1218,8 +1233,12 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd,* handling. Note that we tag on any latent IRQs postponed * due to waiting for busy status. */ -if (!((status|host->busy_status) & - (MCI_CMDCRCFAIL |MCI_CMDTIMEOUT |MCI_CMDSENT |MCI_CMDRESPEND ))) + err_msk =MCI_CMDCRCFAIL |MCI_CMDTIMEOUT ; +if (host->variant->busy_timeout && busy_resp) + err_msk |=MCI_DATATIMEOUT ; + +if (!((status | host->busy_status) & + (err_msk |MCI_CMDSENT |MCI_CMDRESPEND )))return ;/*
@@ -1228,7 +1247,7 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd,if (busy_resp && host->variant->busy_detect) {/* We are busy with a command, return */ -if (host->busy_status && +if (host->busy_status && !(status & (err_msk)) && (status & host->variant->busy_detect_flag))return ;
@@ -1238,8 +1257,7 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd,* that the special busy status bit is still set before * proceeding. */ -if (!host->busy_status && - !(status & (MCI_CMDCRCFAIL |MCI_CMDTIMEOUT )) && +if (!host->busy_status && !(status & (err_msk)) && (status & host->variant->busy_detect_flag)) {/* Clear the busy start IRQ */
@@ -1282,6 +1300,9 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd, cmd->error = -ETIMEDOUT ; }else if (status &MCI_CMDCRCFAIL && cmd->flags &MMC_RSP_CRC ) { cmd->error = -EILSEQ ; + }else if (host->variant->busy_timeout && busy_resp && + status &MCI_DATATIMEOUT ) { + cmd->error = -ETIMEDOUT ; }else { cmd->resp[0 ] =readl (base +MMCIRESPONSE0 ); cmd->resp[1 ] =readl (base +MMCIRESPONSE1 );
@@ -1543,6 +1564,7 @@ static irqreturn_t mmci_irq(int irq, void *dev_id) status &= ~host->variant->busy_detect_flag; ret =1 ; + }while (status);spin_unlock (&host->lock);
@@ -1947,6 +1969,8 @@ static int mmci_probe(struct amba_device *dev,* Enable busy detection. */ if (variant->busy_detect) { +u32 max_busy_timeout =0 ; + mmci_ops.card_busy = mmci_card_busy;/* * Not all variants have a flag to enable busy detection
@@ -1956,7 +1980,11 @@ static int mmci_probe(struct amba_device *dev,mmci_write_datactrlreg (host, host->variant->busy_dpsm_flag); mmc->caps |=MMC_CAP_WAIT_WHILE_BUSY ; - mmc->max_busy_timeout =0 ; + +if (variant->busy_timeout) + max_busy_timeout = ~0UL / (mmc->f_max /MSEC_PER_SEC ); + + mmc->max_busy_timeout = max_busy_timeout; }/* Prepare a CMD12 - needed to clear the DPSM on some variants. */
drivers/mmc/host/mmci.h +2 -0
@@ -290,6 +290,7 @@ struct mmci_host;* @signal_direction: input/out direction of bus signals can be indicated * @pwrreg_clkgate: MMCIPOWER register must be used to gate the clock * @busy_detect: true if the variant supports busy detection on DAT0. +* @busy_timeout: true if the variant supports hardware busy timeout on R1B. * @busy_dpsm_flag: bitmask enabling busy detection in the DPSM * @busy_detect_flag: bitmask identifying the bit in the MMCISTATUS register * indicating that the card is busy
@@ -336,6 +337,7 @@ struct variant_data { u8 signal_direction:1; u8 pwrreg_clkgate:1; u8 busy_detect:1; + u8 busy_timeout:1;u32 busy_dpsm_flag;u32 busy_detect_flag;u32 busy_detect_mask;
Signature · 1 line
2.7.4
PATCH v3 3/3 mmc: mmci: add busy detect for stm32 sdmmc variant
In reply to Ludovic BarreFrom: Ludovic Barre <[email protected]>
This patch enables busy detection for stm32 sdmmc which requires to set data timer to define the busy timeout.
sdmmc has 2 flags:
-busyd0: inverted value of d0 line.
-busyd0end which indicates only end of busy following a cmd response. Only one interrupt on busyd0end.
--- drivers/mmc/host/mmci.c | 4 ++++ drivers/mmc/host/mmci.h | 1 + 2 files changed, 5 insertions(+)
drivers/mmc/host/mmci.c +4 -0
@@ -264,6 +264,10 @@ static struct variant_data variant_stm32_sdmmc = { .datalength_bits = 25, .datactrl_blocksz = 14, .stm32_idmabsize_mask = GENMASK(12, 5), + .busy_detect = true, + .busy_timeout = true, + .busy_detect_flag = MCI_STM32_BUSYD0, + .busy_detect_mask = MCI_STM32_BUSYD0ENDMASK, .init = sdmmc_variant_init, };
drivers/mmc/host/mmci.h +1 -0
@@ -167,6 +167,7 @@#define MCI_ST_CARDBUSY (1 << 24)/* Extended status bits for the STM32 variants */ #define MCI_STM32_BUSYD0 BIT(20) +#define MCI_STM32_BUSYD0END BIT(21)#define MMCICLEAR 0x038#define MCI_CMDCRCFAILCLR (1 << 0)
Signature · 1 line
2.7.4
hi Ulf
Just a "gentleman ping" about this series.
I know you are busy, it's just to be sure you do not forget me :-)
Regards
Ludo
Quoted 28 lines · Ludovic Barre
From: Ludovic Barre <[email protected]>
This patch series adds busy detect for stm32 sdmmc variant. Some adaptations are required:
(quoted diff) +0
-2-Clear busy status bit if busy_detect_flag and busy_detect_mask are different. -Add hardware busy timeout with MMCIDATATIMER register.V3:
(quoted diff) +0
-2-rebase on latest mmc next -replace re-read by status parameter.V2:
(quoted diff) +0
-3-mmci_cmd_irq cleanup in separate patch. -simplify the busy_detect_flag exclude -replace sdmmc specific comment in"mmc: mmci: avoid fake busy polling in
mmci_irq"
to focus on common behaviorLudovic Barre (3):
mmc: mmci: fix read status for busy detect
mmc: mmci: add hardware busy timeout feature
mmc: mmci: add busy detect for stm32 sdmmc variantdrivers/mmc/host/mmci.c | 49 +++++++++++++++++++++++++++++++++++++++++-------- drivers/mmc/host/mmci.h | 3 +++ 2 files changed, 44 insertions(+), 8 deletions(-)
Quoted 5 lines · Ludovic BARRE
hi Ulf
Just a "gentleman ping" about this series.
I know you are busy, it's just to be sure you do not forget me :-)
Thanks! I started briefly to review, but got distracted again. I will come to it, but it just seems to take more time than it should, my apologies.
Br
Uffe
Quoted 33 lines
Regards
LudoQuoted 28 lines · Ludovic Barre
From: Ludovic Barre <[email protected]>
This patch series adds busy detect for stm32 sdmmc variant. Some adaptations are required:
(quoted diff) +0
-2-Clear busy status bit if busy_detect_flag and busy_detect_mask are different. -Add hardware busy timeout with MMCIDATATIMER register.V3:
(quoted diff) +0
-2-rebase on latest mmc next -replace re-read by status parameter.V2:
(quoted diff) +0
-3-mmci_cmd_irq cleanup in separate patch. -simplify the busy_detect_flag exclude -replace sdmmc specific comment in"mmc: mmci: avoid fake busy polling in
mmci_irq"
to focus on common behaviorLudovic Barre (3):
mmc: mmci: fix read status for busy detect
mmc: mmci: add hardware busy timeout feature
mmc: mmci: add busy detect for stm32 sdmmc variantdrivers/mmc/host/mmci.c | 49 +++++++++++++++++++++++++++++++++++++++++-------- drivers/mmc/host/mmci.h | 3 +++ 2 files changed, 44 insertions(+), 8 deletions(-)
Hi Ludovic,
Quoted 11 lines · Ulf Hansson
Quoted 5 lines · Ludovic BARRE
hi Ulf
Just a "gentleman ping" about this series.
I know you are busy, it's just to be sure you do not forget me :-)Thanks! I started briefly to review, but got distracted again. I will come to it, but it just seems to take more time than it should, my apologies.
Alright, so I planned to review this this week - but failed. I have been overwhelmed with work lately (as usual when vacation is getting closer).
I need to gently request to come back to this as of week 28, when I will give this the highest prio. Again apologize for the delays!
Kind regards
Uffe
Quoted 37 lines
Br
UffeQuoted 33 lines
Regards
LudoQuoted 28 lines · Ludovic Barre
From: Ludovic Barre <[email protected]>
This patch series adds busy detect for stm32 sdmmc variant. Some adaptations are required:
(quoted diff) +0
-2-Clear busy status bit if busy_detect_flag and busy_detect_mask are different. -Add hardware busy timeout with MMCIDATATIMER register.V3:
(quoted diff) +0
-2-rebase on latest mmc next -replace re-read by status parameter.V2:
(quoted diff) +0
-3-mmci_cmd_irq cleanup in separate patch. -simplify the busy_detect_flag exclude -replace sdmmc specific comment in"mmc: mmci: avoid fake busy polling in
mmci_irq"
to focus on common behaviorLudovic Barre (3):
mmc: mmci: fix read status for busy detect
mmc: mmci: add hardware busy timeout feature
mmc: mmci: add busy detect for stm32 sdmmc variantdrivers/mmc/host/mmci.c | 49 +++++++++++++++++++++++++++++++++++++++++-------- drivers/mmc/host/mmci.h | 3 +++ 2 files changed, 44 insertions(+), 8 deletions(-)
Hi Ulf
like scheduled, I send you a "gentleman ping" about this series.
Regards,
Ludo
________________________________________
De : Ulf Hansson <[email protected]>
Envoyé : jeudi 20 juin 2019 15:50
À : Ludovic BARRE
Cc : Rob Herring; Srinivas Kandagatla; Maxime Coquelin; Alexandre TORGUE; Linux ARM; Linux Kernel Mailing List; DTML; [email protected]; [email protected] Objet : Re: [PATCH V3 0/3] mmc: mmci: add busy detect for stm32 sdmmc variant
Hi Ludovic,
Quoted 11 lines · Ulf Hansson
Quoted 5 lines · Ludovic BARRE
hi Ulf
Just a "gentleman ping" about this series.
I know you are busy, it's just to be sure you do not forget me :-)Thanks! I started briefly to review, but got distracted again. I will come to it, but it just seems to take more time than it should, my apologies.
Alright, so I planned to review this this week - but failed. I have been overwhelmed with work lately (as usual when vacation is getting closer).
I need to gently request to come back to this as of week 28, when I will give this the highest prio. Again apologize for the delays!
Kind regards
Uffe
Quoted 37 lines
Br
UffeQuoted 33 lines
Regards
LudoQuoted 28 lines · Ludovic Barre
From: Ludovic Barre <[email protected]>
This patch series adds busy detect for stm32 sdmmc variant. Some adaptations are required:
(quoted diff) +0
-2-Clear busy status bit if busy_detect_flag and busy_detect_mask are different. -Add hardware busy timeout with MMCIDATATIMER register.V3:
(quoted diff) +0
-2-rebase on latest mmc next -replace re-read by status parameter.V2:
(quoted diff) +0
-3-mmci_cmd_irq cleanup in separate patch. -simplify the busy_detect_flag exclude -replace sdmmc specific comment in"mmc: mmci: avoid fake busy polling in
mmci_irq"
to focus on common behaviorLudovic Barre (3):
mmc: mmci: fix read status for busy detect
mmc: mmci: add hardware busy timeout feature
mmc: mmci: add busy detect for stm32 sdmmc variantdrivers/mmc/host/mmci.c | 49 +++++++++++++++++++++++++++++++++++++++++-------- drivers/mmc/host/mmci.h | 3 +++ 2 files changed, 44 insertions(+), 8 deletions(-)
Quoted 4 lines · Ludovic BARRE
Hi Ulf
like scheduled, I send you a "gentleman ping" about this series.
Thanks, I am just looking at it, again.
Kind regards
Uffe
Quoted 72 lines
Regards,
Ludo
________________________________________
De : Ulf Hansson <[email protected]>
Envoyé : jeudi 20 juin 2019 15:50
À : Ludovic BARRE
Cc : Rob Herring; Srinivas Kandagatla; Maxime Coquelin; Alexandre TORGUE; Linux ARM; Linux Kernel Mailing List; DTML; [email protected]; [email protected] Objet : Re: [PATCH V3 0/3] mmc: mmci: add busy detect for stm32 sdmmc variantHi Ludovic,
Quoted 11 lines · Ulf Hansson
Quoted 5 lines · Ludovic BARRE
hi Ulf
Just a "gentleman ping" about this series.
I know you are busy, it's just to be sure you do not forget me :-)Thanks! I started briefly to review, but got distracted again. I will come to it, but it just seems to take more time than it should, my apologies.
Alright, so I planned to review this this week - but failed. I have been overwhelmed with work lately (as usual when vacation is getting closer).
I need to gently request to come back to this as of week 28, when I will give this the highest prio. Again apologize for the delays!
Kind regards
UffeQuoted 37 lines
Br
UffeQuoted 33 lines
Regards
LudoQuoted 28 lines · Ludovic Barre
From: Ludovic Barre <[email protected]>
This patch series adds busy detect for stm32 sdmmc variant. Some adaptations are required:
(quoted diff) +0
-2-Clear busy status bit if busy_detect_flag and busy_detect_mask are different. -Add hardware busy timeout with MMCIDATATIMER register.V3:
(quoted diff) +0
-2-rebase on latest mmc next -replace re-read by status parameter.V2:
(quoted diff) +0
-3-mmci_cmd_irq cleanup in separate patch. -simplify the busy_detect_flag exclude -replace sdmmc specific comment in"mmc: mmci: avoid fake busy polling in
mmci_irq"
to focus on common behaviorLudovic Barre (3):
mmc: mmci: fix read status for busy detect
mmc: mmci: add hardware busy timeout feature
mmc: mmci: add busy detect for stm32 sdmmc variantdrivers/mmc/host/mmci.c | 49 +++++++++++++++++++++++++++++++++++++++++-------- drivers/mmc/host/mmci.h | 3 +++ 2 files changed, 44 insertions(+), 8 deletions(-)