From: "Christian König" <christian.koenig@amd.com>
To: Ekansh Gupta <ekansh.gupta@oss.qualcomm.com>,
Oded Gabbay <ogabbay@kernel.org>,
Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>,
Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
Robin Murphy <robin.murphy@arm.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
Sumit Semwal <sumit.semwal@linaro.org>
Cc: Bharath Kumar <quic_bkumar@quicinc.com>,
Chenna Kesava Raju <quic_chennak@quicinc.com>,
srini@kernel.org, dmitry.baryshkov@oss.qualcomm.com,
andersson@kernel.org, konradybcio@kernel.org,
robin.clark@oss.qualcomm.com, linux-kernel@vger.kernel.org,
dri-devel@lists.freedesktop.org, linux-doc@vger.kernel.org,
linux-arm-msm@vger.kernel.org, iommu@lists.linux.dev,
linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org
Subject: Re: [PATCH 11/15] accel/qda: Add PRIME DMA-BUF import support
Date: Wed, 3 Jun 2026 15:40:10 +0200 [thread overview]
Message-ID: <0feaad40-8bde-46c4-a251-07a1bd6ac79d@amd.com> (raw)
In-Reply-To: <e465ed15-1568-467b-ac6b-94f903b46776@oss.qualcomm.com>
On 6/3/26 08:11, Ekansh Gupta wrote:
> On 19-05-2026 12:25, Christian König wrote:
>> On 5/19/26 08:16, Ekansh Gupta via B4 Relay wrote:
>>> From: Ekansh Gupta <ekansh.gupta@oss.qualcomm.com>
...
>>> +static int qda_memory_manager_map_imported(struct qda_memory_manager *mem_mgr,
>>> + struct qda_gem_obj *gem_obj,
>>> + struct qda_iommu_device *iommu_dev)
>>> +{
>>> + struct scatterlist *sg;
>>> + dma_addr_t dma_addr;
>>> +
>>> + if (!gem_obj->is_imported || !gem_obj->sgt || !iommu_dev) {
>>> + drm_err(gem_obj->base.dev, "Invalid parameters for imported buffer mapping\n");
>>> + return -EINVAL;
>>> + }
>>> +
>>> + sg = gem_obj->sgt->sgl;
>>> + if (!sg) {
>>> + drm_err(gem_obj->base.dev, "Invalid scatter-gather list for imported buffer\n");
>>> + return -EINVAL;
>>> + }
>>> +
>>> + gem_obj->iommu_dev = iommu_dev;
>>> +
>>> + /*
>>> + * After dma_buf_map_attachment_unlocked(), sg_dma_address() returns the
>>> + * IOMMU virtual address, not the physical address. The IOMMU maps the
>>> + * entire buffer as a contiguous range in the IOMMU address space even if
>>> + * the underlying physical memory is non-contiguous. Therefore the first
>>> + * sg entry's DMA address is the start of the complete contiguous
>>> + * IOMMU-mapped range and is sufficient to describe the buffer to the DSP.
>>> + */
>>> + dma_addr = sg_dma_address(sg);
>>> + dma_addr += ((u64)iommu_dev->sid << 32);
>>> + gem_obj->dma_addr = dma_addr;
>>
>> That handling here is completely broken since it assumes that the exporter maps the buffer as contigious range.
>>
>> But that's in no way guaranteed.
> I'll collect more details and will try to implement this in the right
> way, maybe by iterating the full sg_table.>
You could also document explicitly that you can only import contiguous buffers (e.g. DMA-buf heap CMA etc....) and then cleanly reject non contiguous buffers here.
We have quite a number of drivers/HW with that limitation, so only accepting contiguous buffers is perfectly ok.
You just can't silently assume that IOMMU would always map the entire buffer as one contiguous range, cause that is certainly not true.
Regards,
Christian.
>> Regards,
>> Christian.
next prev parent reply other threads:[~2026-06-03 13:40 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-19 6:15 [PATCH 00/15] accel/qda: Qualcomm DSP Accelerator driver Ekansh Gupta via B4 Relay
2026-05-19 6:15 ` [PATCH 01/15] MAINTAINERS: Add entry for Qualcomm DSP Accelerator (QDA) driver Ekansh Gupta via B4 Relay
2026-05-19 6:15 ` [PATCH 02/15] accel/qda: Add QDA driver documentation Ekansh Gupta via B4 Relay
2026-05-20 14:12 ` Dmitry Baryshkov
2026-05-20 15:47 ` Tomeu Vizoso
2026-06-03 5:22 ` Ekansh Gupta
2026-06-03 8:54 ` Tomeu Vizoso
2026-06-03 5:19 ` Ekansh Gupta
2026-05-19 6:15 ` [PATCH 03/15] accel/qda: Add initial QDA DRM accelerator driver Ekansh Gupta via B4 Relay
2026-05-20 14:18 ` Dmitry Baryshkov
2026-06-03 5:26 ` Ekansh Gupta
2026-05-19 6:15 ` [PATCH 04/15] accel/qda: Add compute bus for QDA context banks Ekansh Gupta via B4 Relay
2026-05-20 14:19 ` Dmitry Baryshkov
2026-06-03 5:28 ` Ekansh Gupta
2026-06-03 13:25 ` Dmitry Baryshkov
2026-05-19 6:15 ` [PATCH 05/15] iommu: Add QDA compute context bank bus to iommu_buses Ekansh Gupta via B4 Relay
2026-05-20 14:19 ` Dmitry Baryshkov
2026-05-19 6:15 ` [PATCH 06/15] accel/qda: Create compute context bank devices on QDA compute bus Ekansh Gupta via B4 Relay
2026-05-20 14:23 ` Dmitry Baryshkov
2026-06-03 5:39 ` Ekansh Gupta
2026-06-03 13:26 ` Dmitry Baryshkov
2026-05-19 6:15 ` [PATCH 07/15] accel/qda: Add memory manager for CB devices Ekansh Gupta via B4 Relay
2026-05-20 14:26 ` Dmitry Baryshkov
2026-06-03 5:44 ` Ekansh Gupta
2026-05-20 14:27 ` Dmitry Baryshkov
2026-06-03 5:46 ` Ekansh Gupta
2026-05-19 6:15 ` [PATCH 08/15] accel/qda: Add QUERY IOCTL and QDA UAPI header Ekansh Gupta via B4 Relay
2026-05-20 14:29 ` Dmitry Baryshkov
2026-06-03 5:51 ` Ekansh Gupta
2026-06-03 13:43 ` Dmitry Baryshkov
2026-05-19 6:15 ` [PATCH 09/15] accel/qda: Add DMA-backed GEM objects and memory manager integration Ekansh Gupta via B4 Relay
2026-05-19 12:14 ` Markus Elfring
2026-05-19 12:28 ` Matthew Wilcox
2026-05-19 12:32 ` Markus Elfring
2026-05-19 6:16 ` [PATCH 10/15] accel/qda: Add GEM_CREATE and GEM_MMAP_OFFSET IOCTLs Ekansh Gupta via B4 Relay
2026-05-19 6:16 ` [PATCH 11/15] accel/qda: Add PRIME DMA-BUF import support Ekansh Gupta via B4 Relay
2026-05-19 6:55 ` Christian König
2026-06-03 6:11 ` Ekansh Gupta
2026-06-03 13:40 ` Christian König [this message]
2026-06-08 5:14 ` Ekansh Gupta
2026-05-19 6:16 ` [PATCH 12/15] accel/qda: Add FastRPC invocation support Ekansh Gupta via B4 Relay
2026-05-20 13:56 ` Dmitry Baryshkov
2026-06-04 5:09 ` Ekansh Gupta
2026-06-07 21:14 ` Dmitry Baryshkov
2026-06-10 9:38 ` Ekansh Gupta
2026-06-12 8:21 ` Dmitry Baryshkov
2026-05-19 6:16 ` [PATCH 13/15] accel/qda: Add DSP process creation and release Ekansh Gupta via B4 Relay
2026-05-20 14:00 ` Dmitry Baryshkov
2026-06-04 5:17 ` Ekansh Gupta
2026-06-07 21:16 ` Dmitry Baryshkov
2026-05-19 6:16 ` [PATCH 14/15] accel/qda: Add remote memory mapping to DSP address space Ekansh Gupta via B4 Relay
2026-05-19 6:16 ` [PATCH 15/15] accel/qda: Add remote memory unmap from " Ekansh Gupta via B4 Relay
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=0feaad40-8bde-46c4-a251-07a1bd6ac79d@amd.com \
--to=christian.koenig@amd.com \
--cc=airlied@gmail.com \
--cc=andersson@kernel.org \
--cc=corbet@lwn.net \
--cc=dmitry.baryshkov@oss.qualcomm.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=ekansh.gupta@oss.qualcomm.com \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=konradybcio@kernel.org \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=ogabbay@kernel.org \
--cc=quic_bkumar@quicinc.com \
--cc=quic_chennak@quicinc.com \
--cc=robin.clark@oss.qualcomm.com \
--cc=robin.murphy@arm.com \
--cc=simona@ffwll.ch \
--cc=skhan@linuxfoundation.org \
--cc=srini@kernel.org \
--cc=sumit.semwal@linaro.org \
--cc=tzimmermann@suse.de \
--cc=will@kernel.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