Re: [PATCH] mmc: sh_mmcif: rework sg_miter handling

From: Linus Walleij

Date: Wed Nov 18 2026 - 12:48:13 EST


Hi Arnd,

On Wed, Nov 18, 2026 at 2:45 PM Arnd Bergmann <arnd@xxxxxxxxxx> wrote:

> From: Arnd Bergmann <arnd@xxxxxxxx>
>
> This driver is the only one that uses sg_miter_next() to get a persistent
> mapping across interrupts, which prevents us from converting the internal
> kmap() to a local mapping using SG_MITER_LOCAL flag.
>
> Linus previously attempted to use atomic mappings here, which failed
> for the same reason. I gave it another try, with a mapping that is only
> active during a single sh_mmcif_mread_block()/sh_mmcif_mwrite_block() call.
>
> This is mainly a revert of the patch that fixed the command 18 timeout,
> but tries to solve the problem by updating and checking data->bytes_xfered
> to keep track of when the transfer is finished.
>
> Instead of calling sg_miter_stop() on error or completion, this now
> always stops the iterator after the data transfer and restarts it during
> the following interrupt.
>
> Cc: Linus Walleij <linusw@xxxxxxxxxx>
> Cc: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>
> Cc: Wolfram Sang <wsa+renesas@xxxxxxxxxxxxxxxxxxxx>
> Fixes: 4d4a2c71b862 ("mmc: sh_mmcif: Advance sg_miter before reading blocks")
> Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>

FWIW:
Acked-by: Linus Walleij <linusw@xxxxxxxxxx>

> Hi Wolfram and Linus,
>
> Could you have a look at this? I'm not familiar with this driver,
> so there is a chance I got this completely wrong. If the change
> does make sense, maybe you can try testing it on one of the
> highmem-enabled boards.

I don't have this hardware, but Geert does (he helped me with the
previous patches to this driver), so it'd be great if he
could give it a spin!

Yours,
Linus Walleij