From: sashiko-bot@kernel.org
To: "Karl Mehltretter" <kmehltretter@gmail.com>
Cc: dri-devel@lists.freedesktop.org, media-ci@linuxtv.org
Subject: Re: [RFC PATCH 2/2] drm/rockchip: Map imported buffers from DMA addresses
Date: Fri, 09 Oct 2026 00:31:35 +0000 [thread overview]
Message-ID: <sashiko-outbox-164673@kernel.org> (raw)
In-Reply-To: <20261009002114.67851-3-kmehltretter@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] drm/rockchip: DMABUF_DEBUG crash on fallback iommu_map_sgtable import
--
commit 59e8ac2bc0441a5d0b8e3d0e4089c7508adc71d5
Author: Karl Mehltretter <kmehltretter@gmail.com>
drm/rockchip: Map imported buffers from DMA addresses
This commit updates rockchip_gem_iommu_map() to use iommu_map_sgtable_dma()
for imported buffers to avoid CONFIG_DMABUF_DEBUG import failures. If the
DMA mapping is not supported, it falls back to the old page-based path using
iommu_map_sgtable().
Link: https://lore.kernel.org/r/DLR74W1U9YPC.375IK0HOYHDIG@cknow-tech.com/
Link: https://lore.kernel.org/r/DLYLA3WQNN3X.3FB9MO8ZWBQ5@cknow-tech.com/
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> index 9a1dc9f120729..501c94cb921ad 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
[ ... ]
> @@ -40,8 +41,16 @@ static int rockchip_gem_iommu_map(struct rockchip_gem_object *rk_obj)
>
> rk_obj->dma_addr = rk_obj->mm.start;
>
> - ret = iommu_map_sgtable(private->domain, rk_obj->dma_addr, rk_obj->sgt,
> - prot);
> + if (dma_dev) {
> + ret = iommu_map_sgtable_dma(private->domain, rk_obj->dma_addr,
> + dma_dev, rk_obj->sgt, prot);
> + if (ret == -EOPNOTSUPP)
> + ret = iommu_map_sgtable(private->domain, rk_obj->dma_addr,
> + rk_obj->sgt, prot);
[Severity: Medium]
Will this fallback path crash if CONFIG_DMABUF_DEBUG is enabled?
The commit message mentions that unsupported imports still use the old
page-based path and remain unfixed. When iommu_map_sgtable_dma() returns
-EOPNOTSUPP, this code falls back to iommu_map_sgtable() which reads CPU-side
pages. Since the dma-buf core explicitly clears these CPU-side page pointers
when CONFIG_DMABUF_DEBUG is enabled, won't this fallback lead to an invalid
memory access or kernel panic?
Should the code return an error instead of falling back to a function that
is known to crash under these conditions?
> + } else {
> + ret = iommu_map_sgtable(private->domain, rk_obj->dma_addr,
> + rk_obj->sgt, prot);
> + }
> if (ret < (ssize_t)rk_obj->base.size) {
> DRM_ERROR("failed to map buffer: size=%zd request_size=%zd\n",
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261009002114.67851-1-kmehltretter@gmail.com?part=2
next prev parent reply other threads:[~2026-10-09 0:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 0:21 [RFC PATCH 0/2] iommu, drm/rockchip: Map private-domain imports from DMA addresses Karl Mehltretter
2026-10-09 0:21 ` [RFC PATCH 1/2] iommu: Add iommu_map_sgtable_dma() Karl Mehltretter
2026-10-09 0:31 ` sashiko-bot
2026-10-09 14:43 ` Jason Gunthorpe
2026-10-09 0:21 ` [RFC PATCH 2/2] drm/rockchip: Map imported buffers from DMA addresses Karl Mehltretter
2026-10-09 0:31 ` sashiko-bot [this message]
2026-10-09 13:45 ` [RFC PATCH 0/2] iommu, drm/rockchip: Map private-domain imports " Robin Murphy
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=sashiko-outbox-164673@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=kmehltretter@gmail.com \
--cc=media-ci@linuxtv.org \
--cc=sashiko-reviews@lists.linux.dev \
/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