From: sashiko-bot@kernel.org
To: Frank.Li@oss.nxp.com
Cc: wsa+renesas@sang-engineering.com, imx@lists.linux.dev,
Frank.Li@kernel.org
Subject: Re: [PATCH 1/1] mmc: use dmaengine_get_dma_device() instead of chan->device->dev
Date: Thu, 17 Sep 2026 20:55:41 +0000 [thread overview]
Message-ID: <20260917205541.C19BB1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260917204240.1284796-1-Frank.Li@oss.nxp.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] mmc: mmci: DMA API violation due to map/unmap device mismatch
--
commit d094ad885249a508b0979254780f5dd030ce3bf9
Author: Frank Li <Frank.Li@nxp.com>
mmc: use dmaengine_get_dma_device() instead of chan->device->dev
This commit replaces direct access to the chan->device->dev field
with dmaengine_get_dma_device(chan) to retrieve the correct DMA device,
especially for engines with per-channel IOMMU mappings. This also prepares
for making the DMA engine provider data structures private.
> diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
> index 416bdb184ed4c..5d81c96ca4f37 100644
> --- a/drivers/mmc/host/mmci.c
> +++ b/drivers/mmc/host/mmci.c
[ ... ]
> @@ -940,7 +940,7 @@ static void mmci_dma_unmap(struct mmci_host *host, struct mmc_data *data)
> else
> chan = dmae->tx_channel;
>
> - dma_unmap_sg(chan->device->dev, data->sg, data->sg_len,
> + dma_unmap_sg(dmaengine_get_dma_device(chan), data->sg, data->sg_len,
> mmc_get_dma_dir(data));
> }
[Severity: High]
Does this introduce a device mismatch with the mapping paths in the same file?
The map path in _mmci_dmae_prep_data() still maps the scatterlist using the
underlying DMA controller device:
drivers/mmc/host/mmci.c:_mmci_dmae_prep_data() {
...
nr_sg = dma_map_sg(device->dev, data->sg, data->sg_len,
mmc_get_dma_dir(data));
...
unmap_exit:
dma_unmap_sg(device->dev, data->sg, data->sg_len,
mmc_get_dma_dir(data));
}
Since dmaengine_get_dma_device(chan) can return a different device structure
than chan->device->dev, does passing mismatched device structures to
dma_map_sg() and dma_unmap_sg() violate the DMA API contract?
[Severity: Medium]
This is a pre-existing issue, but I noticed there are other files in the
MMC subsystem that still directly access chan->device->dev which appear to
have been missed by this patch's search strategy.
For example, in drivers/mmc/host/mxcmmc.c:mxcmci_setup_data():
nents = dma_map_sg(host->dma->device->dev, data->sg,
data->sg_len, host->dma_dir);
And in drivers/mmc/host/omap.c:mmc_omap_dma_cb():
dev = c->device->dev;
Will leaving these in place cause build breakages when the DMA engine provider
structures are finally made private?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260917204240.1284796-1-Frank.Li@oss.nxp.com?part=1
next prev parent reply other threads:[~2026-09-17 20:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 20:42 [PATCH 1/1] mmc: use dmaengine_get_dma_device() instead of chan->device->dev Frank.Li
2026-09-17 20:55 ` sashiko-bot [this message]
2026-09-17 21:42 ` Linus Walleij
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=20260917205541.C19BB1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=Frank.Li@oss.nxp.com \
--cc=imx@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
--cc=wsa+renesas@sang-engineering.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