From: "Arnd Bergmann" <arnd@arndb.de>
To: "Linus Walleij" <linus.walleij@linaro.org>,
"Christoph Hellwig" <hch@lst.de>, "Jens Axboe" <axboe@kernel.dk>,
"Ming Lei" <ming.lei@redhat.com>,
"Ulf Hansson" <ulf.hansson@linaro.org>,
"Nicolas Pitre" <nico@fluxnic.net>,
"Aaro Koskinen" <aaro.koskinen@iki.fi>,
"Adrian Hunter" <adrian.hunter@intel.com>,
"Angelo Dureghello" <angelo.dureghello@timesys.com>
Cc: "linux-mmc @ vger . kernel . org" <linux-mmc@vger.kernel.org>,
linux-block@vger.kernel.org,
Linux-OMAP <linux-omap@vger.kernel.org>
Subject: Re: [PATCH 1/7] mmc: davinci_mmc: Map the virtual page for PIO
Date: Thu, 25 Jan 2024 17:37:21 +0100 [thread overview]
Message-ID: <7ca13324-ac47-4648-9b3c-c616de515625@app.fastmail.com> (raw)
In-Reply-To: <20240125-mmc-proper-kmap-v1-1-ba953c1ac3f9@linaro.org>
On Thu, Jan 25, 2024, at 15:37, Linus Walleij wrote:
> Use kmap_local_page() instead of sg_virt() to obtain a page
> from the scatterlist: sg_virt() will not perform bounce
> buffering if the page happens to be located in high memory,
> which the driver may or may not be using.
>
> Suggested-by: Christoph Hellwig <hch@lst.de>
> Link: https://lore.kernel.org/linux-mmc/20240122073423.GA25859@lst.de/
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> drivers/mmc/host/davinci_mmc.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/host/davinci_mmc.c
> b/drivers/mmc/host/davinci_mmc.c
> index ee3b1a4e0848..4e9f96b1caf3 100644
> --- a/drivers/mmc/host/davinci_mmc.c
> +++ b/drivers/mmc/host/davinci_mmc.c
> @@ -216,7 +216,7 @@ static irqreturn_t mmc_davinci_irq(int irq, void
> *dev_id);
> static void mmc_davinci_sg_to_buf(struct mmc_davinci_host *host)
> {
> host->buffer_bytes_left = sg_dma_len(host->sg);
> - host->buffer = sg_virt(host->sg);
> + host->buffer = kmap_local_page(sg_page(host->sg));
> if (host->buffer_bytes_left > host->bytes_left)
> host->buffer_bytes_left = host->bytes_left;
> }
I see multiple problems here:
- you are missing the offset within the page, which you
get by adding sg->offset
- kmap_local_page() only maps one page at a time, so
this will fail if the scatterlist entry spans one or
more pages.
- the first call to mmc_davinci_sg_to_buf() may happen
in mmc_davinci_prepare_data(), while the rest is done
in the interrupt handler, and you can't hold the
kmap reference across multiple contexts
- It looks like you are missing the unmap inside of
loop when moving to the next sg element.
I think to do this properly, the driver would have to
use struct sg_mapping_iter like the cb710 driver does,
but the conversion is not as simple as your patch here.
Arnd
next prev parent reply other threads:[~2024-01-25 16:37 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-25 14:37 [PATCH 0/7] mmc: Try to do proper kmap_local() for scatterlists Linus Walleij
2024-01-25 14:37 ` [PATCH 1/7] mmc: davinci_mmc: Map the virtual page for PIO Linus Walleij
2024-01-25 16:37 ` Arnd Bergmann [this message]
2024-01-25 23:18 ` Linus Walleij
2024-01-25 14:37 ` [PATCH 2/7] mmc: moxart-mmc: " Linus Walleij
2024-01-25 14:37 ` [PATCH 3/7] mmc: mvsdio: " Linus Walleij
2024-01-25 14:37 ` [PATCH 4/7] mmc: mxcmmc: " Linus Walleij
2024-01-25 14:37 ` [PATCH 5/7] mmc: omap: " Linus Walleij
2024-01-25 14:37 ` [PATCH 6/7] mmc: sdhci-esdhc-mcf: Map the virtual page for swapping Linus Walleij
2024-01-25 14:37 ` [PATCH 7/7] mmc: sh_mmcif: Map the virtual page for PIO Linus Walleij
2024-02-13 16:45 ` [PATCH 0/7] mmc: Try to do proper kmap_local() for scatterlists Ulf Hansson
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=7ca13324-ac47-4648-9b3c-c616de515625@app.fastmail.com \
--to=arnd@arndb.de \
--cc=aaro.koskinen@iki.fi \
--cc=adrian.hunter@intel.com \
--cc=angelo.dureghello@timesys.com \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=linus.walleij@linaro.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=ming.lei@redhat.com \
--cc=nico@fluxnic.net \
--cc=ulf.hansson@linaro.org \
/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).