From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Cc: Joerg Roedel <joro@8bytes.org>, Jens Axboe <axboe@kernel.dk>,
Ulf Hansson <ulf.hansson@linaro.org>,
Wolfram Sang <wsa+renesas@sang-engineering.com>,
Christoph Hellwig <hch@lst.de>,
Linux IOMMU <iommu@lists.linux-foundation.org>,
linux-block@vger.kernel.org,
Linux MMC List <linux-mmc@vger.kernel.org>,
Linux-Renesas <linux-renesas-soc@vger.kernel.org>
Subject: Re: [RFC PATCH v6 4/5] mmc: tmio: Use dma_max_mapping_size() instead of a workaround
Date: Thu, 13 Jun 2019 22:35:44 +0200 [thread overview]
Message-ID: <CAMuHMdXYqgPRX1WfUTRsKHhnSok5vfnr4AY36=vXoUvAxcNyWQ@mail.gmail.com> (raw)
In-Reply-To: <1560421215-10750-5-git-send-email-yoshihiro.shimoda.uh@renesas.com>
Hi Shimoda-san,
On Thu, Jun 13, 2019 at 5:37 PM Yoshihiro Shimoda
<yoshihiro.shimoda.uh@renesas.com> wrote:
> Since the commit 133d624b1cee ("dma: Introduce dma_max_mapping_size()")
> provides a helper function to get the max mapping size, we can use
> the function instead of the workaround code for swiotlb.
>
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Thanks for your patch!
> --- a/drivers/mmc/host/tmio_mmc_core.c
> +++ b/drivers/mmc/host/tmio_mmc_core.c
> @@ -1189,19 +1190,9 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host)
> mmc->max_blk_size = TMIO_MAX_BLK_SIZE;
> mmc->max_blk_count = pdata->max_blk_count ? :
> (PAGE_SIZE / mmc->max_blk_size) * mmc->max_segs;
> - mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count;
> - /*
> - * Since swiotlb has memory size limitation, this will calculate
> - * the maximum size locally (because we don't have any APIs for it now)
> - * and check the current max_req_size. And then, this will update
> - * the max_req_size if needed as a workaround.
> - */
> - if (swiotlb_max_segment()) {
> - unsigned int max_size = (1 << IO_TLB_SHIFT) * IO_TLB_SEGSIZE;
> -
> - if (mmc->max_req_size > max_size)
> - mmc->max_req_size = max_size;
> - }
> + mmc->max_req_size = min_t(unsigned int,
> + mmc->max_blk_size * mmc->max_blk_count,
> + dma_max_mapping_size(&pdev->dev));
> mmc->max_seg_size = mmc->max_req_size;
I'm always triggered by the use of min_t() and other casts:
mmc->max_blk_size and mmc->max_blk_count are both unsigned int.
dma_max_mapping_size() returns size_t, which can be 64-bit.
1) Can the multiplication overflow?
Probably not, as per commit 2a55c1eac7882232 ("mmc: renesas_sdhi:
prevent overflow for max_req_size"), but I thought I'd better ask.
2) In theory, dma_max_mapping_size() can return a number that doesn't
fit in 32-bit, and will be truncated (to e.g. 0), leading to max_req_size
is zero?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
next prev parent reply other threads:[~2019-06-13 20:36 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-13 10:20 [RFC PATCH v6 0/5] treewide: improve R-Car SDHI performance Yoshihiro Shimoda
2019-06-13 10:20 ` [RFC PATCH v6 1/5] iommu: add an exported function to get minimum page size for a domain Yoshihiro Shimoda
2019-06-13 19:37 ` Wolfram Sang
2019-06-14 7:16 ` Christoph Hellwig
2019-06-17 5:08 ` Yoshihiro Shimoda
2019-06-14 9:41 ` Robin Murphy
2019-06-17 5:23 ` Yoshihiro Shimoda
2019-06-13 10:20 ` [RFC PATCH v6 2/5] block: sort headers on blk-setting.c Yoshihiro Shimoda
2019-06-13 19:40 ` Wolfram Sang
2019-06-13 10:20 ` [RFC PATCH v6 3/5] block: add a helper function to merge the segments by an IOMMU Yoshihiro Shimoda
2019-06-14 7:22 ` Christoph Hellwig
2019-06-14 9:54 ` Robin Murphy
2019-06-17 6:29 ` Yoshihiro Shimoda
2019-06-13 10:20 ` [RFC PATCH v6 4/5] mmc: tmio: Use dma_max_mapping_size() instead of a workaround Yoshihiro Shimoda
2019-06-13 19:45 ` Wolfram Sang
2019-06-17 4:25 ` Yoshihiro Shimoda
2019-06-13 20:35 ` Geert Uytterhoeven [this message]
2019-06-14 7:18 ` Christoph Hellwig
2019-06-14 7:27 ` Geert Uytterhoeven
2019-06-17 4:54 ` Yoshihiro Shimoda
2019-06-17 6:23 ` Geert Uytterhoeven
2019-06-17 6:54 ` Yoshihiro Shimoda
2019-06-13 10:20 ` [RFC PATCH v6 5/5] mmc: queue: Use bigger segments if IOMMU can merge the segments Yoshihiro Shimoda
2019-06-13 19:58 ` Wolfram Sang
2019-06-17 6:38 ` Yoshihiro Shimoda
2019-06-14 7:24 ` Christoph Hellwig
2019-06-14 10:42 ` Wolfram Sang
2019-06-17 6:46 ` Yoshihiro Shimoda
2019-06-17 6:53 ` Christoph Hellwig
2019-06-17 7:02 ` Yoshihiro Shimoda
2019-06-13 19:36 ` [RFC PATCH v6 0/5] treewide: improve R-Car SDHI performance Wolfram Sang
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='CAMuHMdXYqgPRX1WfUTRsKHhnSok5vfnr4AY36=vXoUvAxcNyWQ@mail.gmail.com' \
--to=geert@linux-m68k.org \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=iommu@lists.linux-foundation.org \
--cc=joro@8bytes.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=ulf.hansson@linaro.org \
--cc=wsa+renesas@sang-engineering.com \
--cc=yoshihiro.shimoda.uh@renesas.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 NNTP newsgroup(s).