From: Linus Walleij <linus.walleij@linaro.org>
To: Adrian Hunter <adrian.hunter@intel.com>,
Angelo Dureghello <angelo.dureghello@timesys.com>,
Ulf Hansson <ulf.hansson@linaro.org>,
Orson Zhai <orsonzhai@gmail.com>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
Chunyan Zhang <zhang.lyra@gmail.com>
Cc: linux-mmc@vger.kernel.org, Linus Walleij <linus.walleij@linaro.org>
Subject: [PATCH] mmc: sdhci-esdhc-mcf: Flag if the sg_miter is atomic
Date: Thu, 22 Feb 2024 01:00:54 +0100 [thread overview]
Message-ID: <20240222-fix-sdhci-esdhc-mcf-v1-1-fb87e04ca575@linaro.org> (raw)
The sg_miter used to loop over the returned sglist from a
transfer in the esdhc subdriver for SDHCI needs to know if
it is being used in process or atomic context.
This creates a problem because we cannot unconditionally
add SG_MITER_ATOMIC to the miter, as that can create
scheduling while atomic dmesg splats.
Bit the bullet and make the .request_done() callback in
struct sdhci_ops aware of whether it is called from atomic
context or not, and only add the flag when actually called
from atomic context.
sdhci_request_done() is always called from process context,
either as a work or as part of the threaded interrupt handler,
so this will pass false for is_atomic, and the one case when
we are actually calling .request_done() from an atomic context
is in sdhci_irq().
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>
---
drivers/mmc/host/sdhci-esdhc-mcf.c | 8 ++++++--
drivers/mmc/host/sdhci-pxav2.c | 2 +-
drivers/mmc/host/sdhci-sprd.c | 3 ++-
drivers/mmc/host/sdhci.c | 4 ++--
drivers/mmc/host/sdhci.h | 3 ++-
5 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/drivers/mmc/host/sdhci-esdhc-mcf.c b/drivers/mmc/host/sdhci-esdhc-mcf.c
index 1909a11fd065..7b0686701c6e 100644
--- a/drivers/mmc/host/sdhci-esdhc-mcf.c
+++ b/drivers/mmc/host/sdhci-esdhc-mcf.c
@@ -297,8 +297,10 @@ static void esdhc_mcf_pltfm_set_bus_width(struct sdhci_host *host, int width)
}
static void esdhc_mcf_request_done(struct sdhci_host *host,
- struct mmc_request *mrq)
+ struct mmc_request *mrq,
+ bool is_atomic)
{
+ unsigned int miter_flags = SG_MITER_TO_SG | SG_MITER_FROM_SG;
struct sg_mapping_iter sgm;
u32 *buffer;
@@ -312,8 +314,10 @@ static void esdhc_mcf_request_done(struct sdhci_host *host,
* On mcf5441x there is no hw sdma option/flag to select the dma
* transfer endiannes. A swap after the transfer is needed.
*/
+ if (is_atomic)
+ miter_flags |= SG_MITER_ATOMIC;
sg_miter_start(&sgm, mrq->data->sg, mrq->data->sg_len,
- SG_MITER_TO_SG | SG_MITER_FROM_SG);
+ miter_flags);
while (sg_miter_next(&sgm)) {
buffer = sgm.addr;
esdhc_mcf_buffer_swap32(buffer, sgm.length);
diff --git a/drivers/mmc/host/sdhci-pxav2.c b/drivers/mmc/host/sdhci-pxav2.c
index b75cbea88b40..c1b49c2feea8 100644
--- a/drivers/mmc/host/sdhci-pxav2.c
+++ b/drivers/mmc/host/sdhci-pxav2.c
@@ -120,7 +120,7 @@ static u32 pxav1_irq(struct sdhci_host *host, u32 intmask)
return intmask;
}
-static void pxav1_request_done(struct sdhci_host *host, struct mmc_request *mrq)
+static void pxav1_request_done(struct sdhci_host *host, struct mmc_request *mrq, bool is_atomic)
{
u16 tmp;
struct sdhci_pxav2_host *pxav2_host;
diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c
index bed57a1c64b5..a2b244e13451 100644
--- a/drivers/mmc/host/sdhci-sprd.c
+++ b/drivers/mmc/host/sdhci-sprd.c
@@ -411,7 +411,8 @@ static unsigned int sdhci_sprd_get_ro(struct sdhci_host *host)
}
static void sdhci_sprd_request_done(struct sdhci_host *host,
- struct mmc_request *mrq)
+ struct mmc_request *mrq,
+ bool is_atomic)
{
/* Validate if the request was from software queue firstly. */
if (mmc_hsq_finalize_request(host->mmc, mrq))
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index c79f73459915..3c6a9ba573cc 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -3184,7 +3184,7 @@ static bool sdhci_request_done(struct sdhci_host *host)
spin_unlock_irqrestore(&host->lock, flags);
if (host->ops->request_done)
- host->ops->request_done(host, mrq);
+ host->ops->request_done(host, mrq, false);
else
mmc_request_done(host->mmc, mrq);
@@ -3639,7 +3639,7 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id)
continue;
if (host->ops->request_done)
- host->ops->request_done(host, mrqs_done[i]);
+ host->ops->request_done(host, mrqs_done[i], true);
else
mmc_request_done(host->mmc, mrqs_done[i]);
}
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index a20864fc0641..c2ff327e2c96 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -666,7 +666,8 @@ struct sdhci_ops {
struct mmc_data *data,
unsigned int length);
void (*request_done)(struct sdhci_host *host,
- struct mmc_request *mrq);
+ struct mmc_request *mrq,
+ bool is_atomic);
void (*dump_vendor_regs)(struct sdhci_host *host);
};
---
base-commit: 2d5c7b7eb345249cb34d42cbc2b97b4c57ea944e
change-id: 20240222-fix-sdhci-esdhc-mcf-aa062c072800
Best regards,
--
Linus Walleij <linus.walleij@linaro.org>
next reply other threads:[~2024-02-22 0:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-22 0:00 Linus Walleij [this message]
2024-02-22 6:22 ` [PATCH] mmc: sdhci-esdhc-mcf: Flag if the sg_miter is atomic Adrian Hunter
2024-02-22 8:40 ` Linus Walleij
2024-02-28 8:36 ` Adrian Hunter
2024-02-28 8:59 ` Linus Walleij
2024-02-28 13:22 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240222-fix-sdhci-esdhc-mcf-v1-1-fb87e04ca575@linaro.org \
--to=linus.walleij@linaro.org \
--cc=adrian.hunter@intel.com \
--cc=angelo.dureghello@timesys.com \
--cc=baolin.wang@linux.alibaba.com \
--cc=linux-mmc@vger.kernel.org \
--cc=orsonzhai@gmail.com \
--cc=ulf.hansson@linaro.org \
--cc=zhang.lyra@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).