* [PATCH v2] mmc: sdhci-esdhc-mcf: Flag the sg_miter as atomic
@ 2024-02-28 9:07 Linus Walleij
2024-02-28 9:41 ` Adrian Hunter
2024-02-28 13:03 ` Ulf Hansson
0 siblings, 2 replies; 3+ messages in thread
From: Linus Walleij @ 2024-02-28 9:07 UTC (permalink / raw)
To: Adrian Hunter, Angelo Dureghello, Ulf Hansson, Orson Zhai,
Baolin Wang, Chunyan Zhang
Cc: linux-mmc, Linus Walleij
The sg_miter used to loop over the returned sglist from a
transfer in the esdhc subdriver for SDHCI can be called
from atomic context so the miter needs to be atomic.
sdhci_request_done() is always called from process context,
either as a work or as part of the threaded interrupt handler,
but the one case when we are actually calling .request_done()
from an atomic context is in sdhci_irq().
Fix this by flaggig the miter atomic so we always use
kmap_atomic().
Fixes: e8a167b84886 ("mmc: sdhci-esdhc-mcf: Use sg_miter for swapping")
Reported-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
Changes in v2:
- Do the simpler fix and just use an atomic iterator, it
will work fine since esdhc_mcf_buffer_swap32() doesn't sleep.
- Link to v1: https://lore.kernel.org/r/20240222-fix-sdhci-esdhc-mcf-v1-1-fb87e04ca575@linaro.org
---
drivers/mmc/host/sdhci-esdhc-mcf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mmc/host/sdhci-esdhc-mcf.c b/drivers/mmc/host/sdhci-esdhc-mcf.c
index 1909a11fd065..c97363e2d86c 100644
--- a/drivers/mmc/host/sdhci-esdhc-mcf.c
+++ b/drivers/mmc/host/sdhci-esdhc-mcf.c
@@ -313,7 +313,7 @@ static void esdhc_mcf_request_done(struct sdhci_host *host,
* transfer endiannes. A swap after the transfer is needed.
*/
sg_miter_start(&sgm, mrq->data->sg, mrq->data->sg_len,
- SG_MITER_TO_SG | SG_MITER_FROM_SG);
+ SG_MITER_ATOMIC | SG_MITER_TO_SG | SG_MITER_FROM_SG);
while (sg_miter_next(&sgm)) {
buffer = sgm.addr;
esdhc_mcf_buffer_swap32(buffer, sgm.length);
---
base-commit: 20af1ca418d2c0b11bc2a1fe8c0c88f67bcc2a7e
change-id: 20240228-fix-sdhci-esdhc-mcf-2-539cf338c3a3
Best regards,
--
Linus Walleij <linus.walleij@linaro.org>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] mmc: sdhci-esdhc-mcf: Flag the sg_miter as atomic
2024-02-28 9:07 [PATCH v2] mmc: sdhci-esdhc-mcf: Flag the sg_miter as atomic Linus Walleij
@ 2024-02-28 9:41 ` Adrian Hunter
2024-02-28 13:03 ` Ulf Hansson
1 sibling, 0 replies; 3+ messages in thread
From: Adrian Hunter @ 2024-02-28 9:41 UTC (permalink / raw)
To: Linus Walleij, Angelo Dureghello, Ulf Hansson, Orson Zhai,
Baolin Wang, Chunyan Zhang
Cc: linux-mmc
On 28/02/24 11:07, Linus Walleij wrote:
> The sg_miter used to loop over the returned sglist from a
> transfer in the esdhc subdriver for SDHCI can be called
> from atomic context so the miter needs to be atomic.
>
> sdhci_request_done() is always called from process context,
> either as a work or as part of the threaded interrupt handler,
> but the one case when we are actually calling .request_done()
> from an atomic context is in sdhci_irq().
>
> Fix this by flaggig the miter atomic so we always use
flaggig -> flagging
> kmap_atomic().
>
> Fixes: e8a167b84886 ("mmc: sdhci-esdhc-mcf: Use sg_miter for swapping")
> Reported-by: Adrian Hunter <adrian.hunter@intel.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
> ---
> Changes in v2:
> - Do the simpler fix and just use an atomic iterator, it
> will work fine since esdhc_mcf_buffer_swap32() doesn't sleep.
> - Link to v1: https://lore.kernel.org/r/20240222-fix-sdhci-esdhc-mcf-v1-1-fb87e04ca575@linaro.org
> ---
> drivers/mmc/host/sdhci-esdhc-mcf.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/host/sdhci-esdhc-mcf.c b/drivers/mmc/host/sdhci-esdhc-mcf.c
> index 1909a11fd065..c97363e2d86c 100644
> --- a/drivers/mmc/host/sdhci-esdhc-mcf.c
> +++ b/drivers/mmc/host/sdhci-esdhc-mcf.c
> @@ -313,7 +313,7 @@ static void esdhc_mcf_request_done(struct sdhci_host *host,
> * transfer endiannes. A swap after the transfer is needed.
> */
> sg_miter_start(&sgm, mrq->data->sg, mrq->data->sg_len,
> - SG_MITER_TO_SG | SG_MITER_FROM_SG);
> + SG_MITER_ATOMIC | SG_MITER_TO_SG | SG_MITER_FROM_SG);
> while (sg_miter_next(&sgm)) {
> buffer = sgm.addr;
> esdhc_mcf_buffer_swap32(buffer, sgm.length);
>
> ---
> base-commit: 20af1ca418d2c0b11bc2a1fe8c0c88f67bcc2a7e
> change-id: 20240228-fix-sdhci-esdhc-mcf-2-539cf338c3a3
>
> Best regards,
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] mmc: sdhci-esdhc-mcf: Flag the sg_miter as atomic
2024-02-28 9:07 [PATCH v2] mmc: sdhci-esdhc-mcf: Flag the sg_miter as atomic Linus Walleij
2024-02-28 9:41 ` Adrian Hunter
@ 2024-02-28 13:03 ` Ulf Hansson
1 sibling, 0 replies; 3+ messages in thread
From: Ulf Hansson @ 2024-02-28 13:03 UTC (permalink / raw)
To: Linus Walleij
Cc: Adrian Hunter, Angelo Dureghello, Orson Zhai, Baolin Wang,
Chunyan Zhang, linux-mmc
On Wed, 28 Feb 2024 at 10:07, Linus Walleij <linus.walleij@linaro.org> wrote:
>
> The sg_miter used to loop over the returned sglist from a
> transfer in the esdhc subdriver for SDHCI can be called
> from atomic context so the miter needs to be atomic.
>
> sdhci_request_done() is always called from process context,
> either as a work or as part of the threaded interrupt handler,
> but the one case when we are actually calling .request_done()
> from an atomic context is in sdhci_irq().
>
> Fix this by flaggig the miter atomic so we always use
> kmap_atomic().
>
> Fixes: e8a167b84886 ("mmc: sdhci-esdhc-mcf: Use sg_miter for swapping")
> Reported-by: Adrian Hunter <adrian.hunter@intel.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Applied for next and by fixing the spelling mistake in the commit
message, that was pointed out by Adrian, thanks!
Kind regards
Uffe
> ---
> Changes in v2:
> - Do the simpler fix and just use an atomic iterator, it
> will work fine since esdhc_mcf_buffer_swap32() doesn't sleep.
> - Link to v1: https://lore.kernel.org/r/20240222-fix-sdhci-esdhc-mcf-v1-1-fb87e04ca575@linaro.org
> ---
> drivers/mmc/host/sdhci-esdhc-mcf.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/host/sdhci-esdhc-mcf.c b/drivers/mmc/host/sdhci-esdhc-mcf.c
> index 1909a11fd065..c97363e2d86c 100644
> --- a/drivers/mmc/host/sdhci-esdhc-mcf.c
> +++ b/drivers/mmc/host/sdhci-esdhc-mcf.c
> @@ -313,7 +313,7 @@ static void esdhc_mcf_request_done(struct sdhci_host *host,
> * transfer endiannes. A swap after the transfer is needed.
> */
> sg_miter_start(&sgm, mrq->data->sg, mrq->data->sg_len,
> - SG_MITER_TO_SG | SG_MITER_FROM_SG);
> + SG_MITER_ATOMIC | SG_MITER_TO_SG | SG_MITER_FROM_SG);
> while (sg_miter_next(&sgm)) {
> buffer = sgm.addr;
> esdhc_mcf_buffer_swap32(buffer, sgm.length);
>
> ---
> base-commit: 20af1ca418d2c0b11bc2a1fe8c0c88f67bcc2a7e
> change-id: 20240228-fix-sdhci-esdhc-mcf-2-539cf338c3a3
>
> Best regards,
> --
> Linus Walleij <linus.walleij@linaro.org>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-02-28 13:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-28 9:07 [PATCH v2] mmc: sdhci-esdhc-mcf: Flag the sg_miter as atomic Linus Walleij
2024-02-28 9:41 ` Adrian Hunter
2024-02-28 13:03 ` Ulf Hansson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox