From: Robin Murphy <robin.murphy@arm.com>
To: Neil Armstrong <narmstrong@baylibre.com>,
jgg@ziepe.ca, leon@kernel.org, m.szyprowski@samsung.com,
ulf.hansson@linaro.org
Cc: torvalds@linux-foundation.org, khilman@baylibre.com,
jbrunet@baylibre.com, linux-mmc@vger.kernel.org,
linux-amlogic@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH RFC 2/2] mmc: meson-gx: use sg_copy_to/from_io instead of local version
Date: Mon, 28 Jun 2021 14:44:20 +0100 [thread overview]
Message-ID: <cfd6c96a-b5eb-bc0b-1861-c409f0a7e4f0@arm.com> (raw)
In-Reply-To: <20210628123411.119778-3-narmstrong@baylibre.com>
On 2021-06-28 13:34, Neil Armstrong wrote:
> Use the proper sg_copy_to_io & sg_copy_from_io instead of having a local
> sg_copy_buffer variant to handle the I/O mapped buffer case.
>
> Cc: Robin Murphy <robin.murphy@arm.com>
> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
> ---
> drivers/mmc/host/meson-gx-mmc.c | 53 +++++++--------------------------
> 1 file changed, 10 insertions(+), 43 deletions(-)
>
> diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c
> index 3f28eb4d17fe..c13436efb414 100644
> --- a/drivers/mmc/host/meson-gx-mmc.c
> +++ b/drivers/mmc/host/meson-gx-mmc.c
> @@ -746,47 +746,6 @@ static void meson_mmc_desc_chain_transfer(struct mmc_host *mmc, u32 cmd_cfg)
> writel(start, host->regs + SD_EMMC_START);
> }
>
> -/* local sg copy to buffer version with _to/fromio usage for dram_access_quirk */
> -static void meson_mmc_copy_buffer(struct meson_host *host, struct mmc_data *data,
> - size_t buflen, bool to_buffer)
> -{
> - unsigned int sg_flags = SG_MITER_ATOMIC;
> - struct scatterlist *sgl = data->sg;
> - unsigned int nents = data->sg_len;
> - struct sg_mapping_iter miter;
> - unsigned int offset = 0;
> -
> - if (to_buffer)
> - sg_flags |= SG_MITER_FROM_SG;
> - else
> - sg_flags |= SG_MITER_TO_SG;
> -
> - sg_miter_start(&miter, sgl, nents, sg_flags);
> -
> - while ((offset < buflen) && sg_miter_next(&miter)) {
> - unsigned int len;
> -
> - len = min(miter.length, buflen - offset);
> -
> - /* When dram_access_quirk, the bounce buffer is a iomem mapping */
> - if (host->dram_access_quirk) {
> - if (to_buffer)
> - memcpy_toio(host->bounce_iomem_buf + offset, miter.addr, len);
> - else
> - memcpy_fromio(miter.addr, host->bounce_iomem_buf + offset, len);
> - } else {
> - if (to_buffer)
> - memcpy(host->bounce_buf + offset, miter.addr, len);
> - else
> - memcpy(miter.addr, host->bounce_buf + offset, len);
> - }
> -
> - offset += len;
> - }
> -
> - sg_miter_stop(&miter);
> -}
> -
> static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd)
> {
> struct meson_host *host = mmc_priv(mmc);
> @@ -830,7 +789,12 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd)
> if (data->flags & MMC_DATA_WRITE) {
> cmd_cfg |= CMD_CFG_DATA_WR;
> WARN_ON(xfer_bytes > host->bounce_buf_size);
> - meson_mmc_copy_buffer(host, data, xfer_bytes, true);
> + if (host->dram_access_quirk)
> + sg_copy_to_io(data->sg, data->sg_len,
> + host->bounce_iomem_buf, xfer_bytes);
Maybe you could just use host->regs + SD_EMMC_SRAM_DATA_BUF_OFF directly
here (and below) and save carrying host->bounce_iomem_buf around?
Robin.
> + else
> + sg_copy_to_buffer(data->sg, data->sg_len,
> + host->bounce_buf, xfer_bytes);
> dma_wmb();
> }
>
> @@ -999,7 +963,10 @@ static irqreturn_t meson_mmc_irq_thread(int irq, void *dev_id)
> if (meson_mmc_bounce_buf_read(data)) {
> xfer_bytes = data->blksz * data->blocks;
> WARN_ON(xfer_bytes > host->bounce_buf_size);
> - meson_mmc_copy_buffer(host, data, xfer_bytes, false);
> + if (host->dram_access_quirk)
> + sg_copy_from_io(data->sg, data->sg_len, host->bounce_iomem_buf, xfer_bytes);
> + else
> + sg_copy_from_buffer(data->sg, data->sg_len, host->bounce_buf, xfer_bytes);
> }
>
> next_cmd = meson_mmc_get_next_command(cmd);
>
prev parent reply other threads:[~2021-06-28 13:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-28 12:34 [PATCH RFC 0/2] scatterlist: add I/O variant of sg_pcopy & sg_copy and use them Neil Armstrong
2021-06-28 12:34 ` [PATCH RFC 1/2] scatterlist: add I/O variant of sg_pcopy & sg_copy Neil Armstrong
2021-06-28 13:40 ` Robin Murphy
2021-06-28 12:34 ` [PATCH RFC 2/2] mmc: meson-gx: use sg_copy_to/from_io instead of local version Neil Armstrong
2021-06-28 13:44 ` Robin Murphy [this message]
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=cfd6c96a-b5eb-bc0b-1861-c409f0a7e4f0@arm.com \
--to=robin.murphy@arm.com \
--cc=jbrunet@baylibre.com \
--cc=jgg@ziepe.ca \
--cc=khilman@baylibre.com \
--cc=leon@kernel.org \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=narmstrong@baylibre.com \
--cc=torvalds@linux-foundation.org \
--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