* [PATCH 1/2] mmc: sh_mmcif: fix error handling
@ 2026-12-02 15:23 Arnd Bergmann
2026-12-02 15:23 ` [PATCH 2/2] mmc: convert sg_miter user to SG_MITER_LOCAL Arnd Bergmann
0 siblings, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2026-12-02 15:23 UTC (permalink / raw)
To: Ulf Hansson, Linus Walleij, Arnd Bergmann
Cc: Geert Uytterhoeven, Wolfram Sang, Frank Li, Runyu Xiao,
Matthew Wilcox (Oracle), Samarth Narang, Pan Chuang, linux-mmc
From: Arnd Bergmann <arnd@arndb.de>
My earlier patch introduced a bug in the error handling code,
as Sashiko-bot reported.
Fix this by only resetting the number of bytes transferred
if a request has a 'data' member.
Cc: Linus Walleij <linusw@kernel.org>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
Fixes: d372d206e6e0 ("mmc: sh_mmcif: rework sg_miter handling")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
If possible, please fold this into the earlier patch, otherwise
this can go on top.
---
drivers/mmc/host/sh_mmcif.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c
index c6033c6596e0..9850d2ae6f16 100644
--- a/drivers/mmc/host/sh_mmcif.c
+++ b/drivers/mmc/host/sh_mmcif.c
@@ -1388,7 +1388,8 @@ static void sh_mmcif_timeout_work(struct work_struct *work)
BUG();
}
- mrq->data->bytes_xfered = 0;
+ if (mrq->data)
+ mrq->data->bytes_xfered = 0;
host->state = STATE_IDLE;
host->wait_for = MMCIF_WAIT_FOR_REQUEST;
host->mrq = NULL;
--
2.53.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 2/2] mmc: convert sg_miter user to SG_MITER_LOCAL 2026-12-02 15:23 [PATCH 1/2] mmc: sh_mmcif: fix error handling Arnd Bergmann @ 2026-12-02 15:23 ` Arnd Bergmann 2026-12-02 15:30 ` sashiko-bot 0 siblings, 1 reply; 4+ messages in thread From: Arnd Bergmann @ 2026-12-02 15:23 UTC (permalink / raw) To: Robert Richter, Ulf Hansson, Michał Mirosław, Paul Cercueil, Frank Li, Sascha Hauer, Tony Huang, Li-hao Kuo Cc: Arnd Bergmann, Pengutronix Kernel Team, Fabio Estevam, Thorsten Blum, Vinod Koul, Olivier Louvignes, Wolfram Sang, Linus Walleij, Fan Wu, Andrew Gaylard, linux-mmc, linux-mips, imx, linux-arm-kernel From: Arnd Bergmann <arnd@arndb.de> These mmc drivers all use the sg_miter infrastructure with the default iterator using kmap(), but they are safe to use kmap_local() instead, so use that to get us one step closer to removing kmap(). Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- drivers/mmc/host/cavium.c | 3 ++- drivers/mmc/host/cb710-mmc.c | 4 ++-- drivers/mmc/host/jz4740_mmc.c | 2 +- drivers/mmc/host/mxcmmc.c | 4 ++-- drivers/mmc/host/sunplus-mmc.c | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/mmc/host/cavium.c b/drivers/mmc/host/cavium.c index 37a88f2a0c86..95a45062a674 100644 --- a/drivers/mmc/host/cavium.c +++ b/drivers/mmc/host/cavium.c @@ -719,7 +719,8 @@ static void do_write_request(struct cvm_mmc_host *host, struct mmc_request *mrq) u64 dat = 0; /* Copy data to the xmit buffer before issuing the command. */ - sg_miter_start(smi, mrq->data->sg, mrq->data->sg_len, SG_MITER_FROM_SG); + sg_miter_start(smi, mrq->data->sg, mrq->data->sg_len, + SG_MITER_LOCAL | SG_MITER_FROM_SG); /* Auto inc from offset zero, dbuf zero */ writeq(0x10000ull, host->base + MIO_EMM_BUF_IDX(host)); diff --git a/drivers/mmc/host/cb710-mmc.c b/drivers/mmc/host/cb710-mmc.c index 31daec787495..1e6d567c1edd 100644 --- a/drivers/mmc/host/cb710-mmc.c +++ b/drivers/mmc/host/cb710-mmc.c @@ -274,7 +274,7 @@ static int cb710_mmc_receive(struct cb710_slot *slot, struct mmc_data *data) if (unlikely(data->blksz & 15 && (data->blocks != 1 || data->blksz != 8))) return -EINVAL; - sg_miter_start(&miter, data->sg, data->sg_len, SG_MITER_TO_SG); + sg_miter_start(&miter, data->sg, data->sg_len, SG_MITER_LOCAL | SG_MITER_TO_SG); cb710_modify_port_8(slot, CB710_MMC_CONFIG2_PORT, 15, CB710_MMC_C2_READ_PIO_SIZE_MASK); @@ -318,7 +318,7 @@ static int cb710_mmc_send(struct cb710_slot *slot, struct mmc_data *data) if (unlikely(data->blocks > 1 && data->blksz & 15)) return -EINVAL; - sg_miter_start(&miter, data->sg, data->sg_len, SG_MITER_FROM_SG); + sg_miter_start(&miter, data->sg, data->sg_len, SG_MITER_LOCAL | SG_MITER_FROM_SG); cb710_modify_port_8(slot, CB710_MMC_CONFIG2_PORT, 0, CB710_MMC_C2_READ_PIO_SIZE_MASK); diff --git a/drivers/mmc/host/jz4740_mmc.c b/drivers/mmc/host/jz4740_mmc.c index 49bc72f82708..b2eaefaf5c79 100644 --- a/drivers/mmc/host/jz4740_mmc.c +++ b/drivers/mmc/host/jz4740_mmc.c @@ -750,7 +750,7 @@ static void jz_mmc_prepare_data_transfer(struct jz4740_mmc_host *host) else direction = SG_MITER_FROM_SG; - sg_miter_start(&host->miter, data->sg, data->sg_len, direction); + sg_miter_start(&host->miter, data->sg, data->sg_len, SG_MITER_LOCAL | direction); } diff --git a/drivers/mmc/host/mxcmmc.c b/drivers/mmc/host/mxcmmc.c index 16d3b91fd472..4487e3a8e9cc 100644 --- a/drivers/mmc/host/mxcmmc.c +++ b/drivers/mmc/host/mxcmmc.c @@ -270,7 +270,7 @@ static void mxcmci_swap_buffers(struct mmc_data *data) u32 *buf; sg_miter_start(&sgm, data->sg, data->sg_len, - SG_MITER_TO_SG | SG_MITER_FROM_SG); + SG_MITER_LOCAL | SG_MITER_TO_SG | SG_MITER_FROM_SG); while (sg_miter_next(&sgm)) { buf = sgm.addr; @@ -597,7 +597,7 @@ static int mxcmci_transfer_data(struct mxcmci_host *host) host->data = data; host->datasize = 0; - sg_miter_start(&sgm, data->sg, data->sg_len, + sg_miter_start(&sgm, data->sg, data->sg_len, SG_MITER_LOCAL | (data->flags & MMC_DATA_READ) ? SG_MITER_TO_SG : SG_MITER_FROM_SG); if (data->flags & MMC_DATA_READ) { diff --git a/drivers/mmc/host/sunplus-mmc.c b/drivers/mmc/host/sunplus-mmc.c index e947c84eef94..088e4294a53e 100644 --- a/drivers/mmc/host/sunplus-mmc.c +++ b/drivers/mmc/host/sunplus-mmc.c @@ -639,7 +639,7 @@ static void spmmc_xfer_data_pio(struct spmmc_host *host, struct mmc_data *data) flags |= SG_MITER_FROM_SG; else flags |= SG_MITER_TO_SG; - sg_miter_start(&sg_miter, data->sg, data->sg_len, flags); + sg_miter_start(&sg_miter, data->sg, data->sg_len, SG_MITER_LOCAL | flags); while (data_left > 0) { consumed = 0; if (!sg_miter_next(&sg_miter)) -- 2.53.0 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] mmc: convert sg_miter user to SG_MITER_LOCAL 2026-12-02 15:23 ` [PATCH 2/2] mmc: convert sg_miter user to SG_MITER_LOCAL Arnd Bergmann @ 2026-12-02 15:30 ` sashiko-bot 2026-12-02 15:46 ` Arnd Bergmann 0 siblings, 1 reply; 4+ messages in thread From: sashiko-bot @ 2026-12-02 15:30 UTC (permalink / raw) To: Arnd Bergmann; +Cc: imx, Frank.Li Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] mmc: mxcmmc: operator precedence bug in mxcmci_transfer_data() flags -- commit a258d24bc3cd5f55b4dfadc025c7f77a315cd363 Author: Arnd Bergmann <arnd@arndb.de> mmc: convert sg_miter user to SG_MITER_LOCAL This commit converts several MMC host drivers to pass SG_MITER_LOCAL to sg_miter_start() so they use kmap_local_page() instead of kmap(). > diff --git a/drivers/mmc/host/mxcmmc.c b/drivers/mmc/host/mxcmmc.c > index 16d3b91fd4725..4487e3a8e9ccc 100644 > --- a/drivers/mmc/host/mxcmmc.c > +++ b/drivers/mmc/host/mxcmmc.c [ ... ] > @@ -597,7 +597,7 @@ static int mxcmci_transfer_data(struct mxcmci_host *host) > > host->data = data; > host->datasize = 0; > - sg_miter_start(&sgm, data->sg, data->sg_len, > + sg_miter_start(&sgm, data->sg, data->sg_len, SG_MITER_LOCAL | > (data->flags & MMC_DATA_READ) ? SG_MITER_TO_SG : SG_MITER_FROM_SG); > > if (data->flags & MMC_DATA_READ) { [Severity: Medium] Does the flags expression here need parentheses around the ternary operator? Because '|' has higher precedence than '?:', the condition is evaluated as (SG_MITER_LOCAL | (data->flags & MMC_DATA_READ)), which is always true and passes only SG_MITER_TO_SG to sg_miter_start() (dropping SG_MITER_LOCAL and using SG_MITER_TO_SG even on PIO writes). -- Sashiko AI review · https://sashiko.dev/#/patchset/20261202152437.664948-1-arnd@kernel.org?part=2 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] mmc: convert sg_miter user to SG_MITER_LOCAL 2026-12-02 15:30 ` sashiko-bot @ 2026-12-02 15:46 ` Arnd Bergmann 0 siblings, 0 replies; 4+ messages in thread From: Arnd Bergmann @ 2026-12-02 15:46 UTC (permalink / raw) To: sashiko-reviews; +Cc: imx, Frank Li, Ulf Hansson On Wed, Dec 2, 2026, at 16:30, sashiko-bot@kernel.org wrote: > Thank you for your contribution! Sashiko AI review found 1 potential > issue to consider: > - [Medium] mmc: mxcmmc: operator precedence bug in > mxcmci_transfer_data() flags > -- > > > [Severity: Medium] > Does the flags expression here need parentheses around the ternary > operator? Because '|' has higher precedence than '?:', the condition is > evaluated as (SG_MITER_LOCAL | (data->flags & MMC_DATA_READ)), which is > always true and passes only SG_MITER_TO_SG to sg_miter_start() (dropping > SG_MITER_LOCAL and using SG_MITER_TO_SG even on PIO writes). Hi Ulf, I've fixed it up locally. Will send a fixed v2 after you've had a chance to look at v1. Feel free to apply patch 1/2, which addressed another bug found by Sashiko in the earlier patch. Arnd ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-12-02 15:47 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-12-02 15:23 [PATCH 1/2] mmc: sh_mmcif: fix error handling Arnd Bergmann 2026-12-02 15:23 ` [PATCH 2/2] mmc: convert sg_miter user to SG_MITER_LOCAL Arnd Bergmann 2026-12-02 15:30 ` sashiko-bot 2026-12-02 15:46 ` Arnd Bergmann
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.