On Sun, 29 Nov 2026 17:25:07 +0200, Edward Srouji wrote:
> Today mlx5 imports every dma-buf as movable. The mkey is sized for the
> worst case, one entry per PAGE_SIZE of the dma-buf, and an invalidation
> zaps the mkey and relies on ODP page faults to map it again. This makes
> dma-buf MRs depend on CONFIG_INFINIBAND_ON_DEMAND_PAGING, and wastes
> translation entries for exporters that never move their memory, such as
> when GPU or device memory is registered for peer-to-peer DMA.
>
> [...]
Applied, thanks!
[1/3] RDMA/uverbs: Permit dma-buf export to work with pinned importers
https://git.kernel.org/rdma/rdma/c/fd94c97b8495c7
[2/3] RDMA/mlx5: Move dma-buf MR init out of ODP-only compilation
https://git.kernel.org/rdma/rdma/c/a460c35a999e00
[3/3] RDMA/mlx5: Try pinned revocable dmabuf import by default
https://git.kernel.org/rdma/rdma/c/bd3cf336bedb1f
Best regards,
--
Leon Romanovsky <leon(a)kernel.org>
On 12/1/26 17:52, Boris Brezillon wrote:
> On Tue, 01 Dec 2026 17:35:28 +0100
> Boris Brezillon <boris.brezillon(a)collabora.com> wrote:
>
>> If a job is passed a dependency that's coming from the same queue the
>> job is targeting, we can get rid of the dependency because of the
>> implicit serialization provided by the queue. This will allow us
>> benefit from the pipelining provided by the ring buffer (no extra
>> MCU <-> CPU round-trip to have the job pushed to the ring buffer).
>>
>> drm_sched_entity_add_dependency_cb() already has this optimization in
>> place, all we need to do is explode the chain/array containers with a
>> dma_fence_unwrap_for_each() when we add job dependencies.
>>
>> Signed-off-by: Boris Brezillon <boris.brezillon(a)collabora.com>
>> Cc: Xianzhong Li <xianzhong.li(a)nxp.com>
>> ---
>> Some recent effort to improve job pipelining [1] showed that the
>> MCU <-> CPU round-trip that lets us signal job fences adds a
>> non-negligible overhead, and this problem seems to be easier and
>> more systematically fixed if it's addressed at the KMD side, so
>> here's a patch doing exactly that.
>>
>> [1]https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/46172
>> ---
>> Changes in v2:
>> - Explode container fences with dma_fence_unwrap_for_each() instead of
>> and rely on drm_sched_entity_add_dependency_cb() elimination instead
>> of open-coding it
>> ---
>> drivers/gpu/drm/panthor/panthor_drv.c | 17 +++++++++++++----
>> 1 file changed, 13 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c
>> index dc8d0191aef4..a527ce86a113 100644
>> --- a/drivers/gpu/drm/panthor/panthor_drv.c
>> +++ b/drivers/gpu/drm/panthor/panthor_drv.c
>> @@ -7,6 +7,7 @@
>> #include <asm/arch_timer.h>
>> #endif
>>
>> +#include <linux/dma-fence-unwrap.h>
>> #include <linux/list.h>
>> #include <linux/module.h>
>> #include <linux/of_platform.h>
>> @@ -612,8 +613,9 @@ panthor_submit_ctx_add_sync_deps_to_job(struct panthor_submit_ctx *ctx,
>> int ret = 0;
>>
>> for (u32 i = 0; i < sync_op_count; i++) {
>> + struct dma_fence *fence, *inner_fence;
>> struct panthor_sync_signal *sig_sync;
>> - struct dma_fence *fence;
>> + struct dma_fence_unwrap iter;
>>
>> if (!sync_op_is_wait(&sync_ops[i]))
>> continue;
>> @@ -637,9 +639,16 @@ panthor_submit_ctx_add_sync_deps_to_job(struct panthor_submit_ctx *ctx,
>> return ret;
>> }
>>
>> - ret = drm_sched_job_add_dependency(job, fence);
>> - if (ret)
>> - return ret;
>> + /* Explode containers so that drm_sched_entity_add_dependency_cb() can
>> + * eliminate fences that are coming from the same queue.
>> + */
>> + dma_fence_unwrap_for_each(inner_fence, &iter, fence) {
>> + ret = drm_sched_job_add_dependency(job, inner_fence);
>
> Missing dma_fence_get(inner_fence) here, as reported by Sashiko.
Yeah drm_sched_job_add_dependency() consumed the fence reference.
>
>> + if (ret) {
>> + dma_fence_put(iter.chain);
I had it on my TODO list for a very long time to clean that up.
Just send you the patch which makes dma_fence_unwrap_for_each() drop the reference with a scoped guard.
Apart from the reference count your patch looks reasonable to me.
Regards,
Christian.
>> + return ret;
>> + }
>> + }
>> }
>>
>> return 0;
>>
>> ---
>> base-commit: 28f286b0dfa9610d4ee2447415e964e8bc603056
>> change-id: 20261201-panhtor-dep-skip-9c6a3e2f7cc7
>>
>> Best regards,
>
Dave Hansen <dave.hansen(a)intel.com> writes:
> On 11/16/26 01:11, Aneesh Kumar K.V (Arm) wrote:
>> if (cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT)) {
>> - r = set_memory_decrypted((unsigned long) hvclock_mem,
>> + r = set_memory_decrypted((unsigned long)hvclock_mem,
>> 1UL << order);
>
> NAK on this specific patch.
>
> Good idea, but this needs to be broken out to do fewer things at once.
>
Are you suggesting that this be split into per-architecture patches?
> The vga changes, for instance, are not explained anywhere.
modified arch/x86/include/asm/vga.h
@@ -14,7 +14,7 @@
* On the PC, we can just recalculate addresses and then
* access the videoram directly without any black magic.
* To support memory encryption however, we need to access
- * the videoram as decrypted memory.
+ * the videoram as decrypted memory without clearing its contents.
*/
#define VGA_MAP_MEM(x, s) \
@@ -22,7 +22,7 @@
unsigned long start = (unsigned long)phys_to_virt(x); \
\
if (IS_ENABLED(CONFIG_AMD_MEM_ENCRYPT)) \
- set_memory_decrypted(start, (s) >> PAGE_SHIFT); \
+ set_memory_decrypted_nozero(start, (s) >> PAGE_SHIFT); \
\
start; \
})
The VGA change is an API substitution intended to preserve the existing
behavior: set_memory_decrypted_nozero() avoids the newly added memset().
I have not audited the VGA-specific memory encryption handling in detail.
I had intended the updated comment to explain this, but I can also split
the patch and add that explanation.
-aneesh
On 12/1/26 10:33, Alistair Popple wrote:
> On 2026-12-01 at 19:11 +1100, Christian König <christian.koenig(a)amd.com> wrote...
>> On 12/1/26 08:13, Alistair Popple wrote:
>>> On 2026-12-01 at 15:05 +1100, Dave Airlie <airlied(a)gmail.com> wrote...
>>>>> The problem is I can't figure out how to build that low level API.
>>
>> Seconded.
>>
>> I can give you quite a bunch of requirements based on what the high level DMA-buf API and uAPI has on functionality and based on what I have seen on use cases in the wild.
>
> I think a bunch of requirements would be helpful, because they've kind of been
> scattered across threads at this point and I concluded it was kind of impossible
> to build given the constraints.
>
> In particular the one thing that PCIe P2P, IOMMUFD, KVM, etc. all need is the
> physical address. That is the vendor agnostic thing below but providing that has
> been consistently NACKed and I can't see how you can make any low level API work
> without having the physical address.
Yeah good point, let's start with that one. There are multiple problems with using physical addresses.
First of all a physical address is only what the CPU can see, but there are a lot of use cases where you need to access resources the CPU can't reach. For example hidden device memory or even system memory where the CPU intentionally has no address for because of digital rights management reasons etc... Taking a look at all the use cases I have seen I would say that DMA-buf actually contains more non CPU accessible resources than CPU accessible ones.
Then especially for PCI a physical address is only halve the information you need. The importer can also need additional info to stitch together the TLP, like SH, snooping bit, atomic access ops etc....
Then there is the reason that we have seen a tremendous amount of cases where importers abused the physical address and/or struct page pointer which was unfortunately accessible through the SGT. To be honest I can't count the number of CVE entries given to such bugs.
There are some use cases for KVM for example which need physical addresses, but to be honest they look like corner cases.
Ideally even the exporter shouldn't work with physically addresses I think. For example even when you have a PCI P2P API which fills in your mapping it should work with PCI BAR, offset and length and and not a physical address into the BAR.
> I know in the past you've suggested passing all the importer context through to
> the exporter, but that is also a complete non-starter. It lets arbitrary drivers
> implement the mapping wrong and likely get all the life-times, which belong to
> the importer, wrong. So until we can solve that I'm not really seeing much of
> way forward here.
WOW, wait a second. With the exception of the old interface which pins things down the lifetime of the mapping belongs to the exporter and not the importer!
That's one of the reasons why the exporter needs the IOMMU context of the importer for example, otherwise you can't forcefully remove IOMMU mappings without relying on the importer doing that for you.
>> But I can't say either what the low level API needs to look like and one of the major reasons I want DMA-buf separated from that low level API is that it seems like this needs a different field of expertise and responsibilities.
>
> I get it, and I do appreciate the expertise provided here. However if DMA-buf
> is supposed to be some separate mechanism just for passing pointer types between
> exporter/importer with some lifetime and location negotiation rules it shouldn't
> also be seeking to impose constraints on what information those types actually
> contain. That is none of it's business and is up to what the low level API
> needs.
I have to admit that's a pretty good argument, but I would say the restriction is on the exporter, importer and which role is using what and not the low level API itself.
> If the low level API needs importer context and physical addresses to do
> anything useful then so be it.
As long as the low level API is only called by the exporter I have no problem with it taking physical addresses when it is sufficient for the use case.
I just think that we have use cases where the exporter needs to give additional information to the physical address to the IOMMU driver for example.
I need to attend some customer stuff now and will try to answer the rest of the mail later today.
Regards,
Christian.
>>>>>
>>>>> The current low level DMA API can't correctly handle PCIe P2P, or IOMMUFD, or
>>>>> the KVM/confidential compute use-cases (I'm less familiar with those). It can
>>>>> only handle creating a DMA mapping for system memory for a specific importing
>>>>> device.
>>>>>
>>>>> So I assume you are talking about some new API. Following Dave's lead lets call
>>>>> that shared_buf_map(). That would need to take some importing device context
>>>>> so that it could dispatch to the correct mapping code and a list of physical
>>>>> locations the exporter needs mapped.
>>>>>
>>>>> At a high level something like:
>>>>>
>>>>> struct dma_addr_list *shared_buf_map(import_context, location_list);
>>>>>
>>>>> Where the import_context is some importer specific struct opaque to the exporter
>>>>> and the location list is a list of either PCIe MMIO or system RAM physical
>>>>> addresses.
>>>>>
>>>>> Every exporter ->map_dma_buf() should call shared_buf_map() instead of
>>>>> open-coding their own mapping code, as I think we all agree we don't want that
>>>>> open-coded.
>>>>>
>>>>> Placement selection can be dealt with as a separate topic, so setting that
>>>>> aside means passing in the same location list regardless of importing device.
>>>>> shared_buf_map() then has to dispatch to the correct mapping generation code -
>>>>> either DMA API, PCIe peer-to-peer API, IOMMUFD API, KVM API or maybe some other
>>>>> importing device/driver specific API.
>>
>> That sounds totally sane to me, yes.
>
> Ok. The problem is how this shared_buf_map() gets the importer context.
>
> It would be easy enough to make work if an impoter could call eg.
> shared_buf_map(import_type, attachment) or something like that, but I got the
> impression from the middle-layer discussion that that would be undesirable and
> get NACKed because only exporter should call that. So not sure how to actually
> make that work, unless my impression there is wrong.
>
>>>>>
>>>>> I could see how that could be made to work, but it seems more complex than
>>>>> a dma_buf exporter op that returns a list of physical locations and a helper
>>>>> library that importers call to do the mapping into whatever importer specific
>>>>> context is needed. Instead you would have to add importer specific callbacks
>>>>> that the shared_buf_map code could call along with plumbing the importer context
>>>>> through.
>>
>> I've thought about that as well for a while but came to the conclusion that we most likely want some more differentiation here.
>>
>> On the one hand we have the vendor agnostic things like PCI P2P, IOMMU, IOVAs, bus addresses, CPU physical addresses etc... which a vendor agnostic API should be dealing with.
>
> Right - I'd like to tackle the vendor agnostic things, as they provide the most
> value. Vendor specific things have already been hacked up to work in all sorts
> of horrible ways, which is why I want to fix this so I can at least remove some
> of the horrid hacks from our code.
>
>> On the other hand we have vendor specific things like XGMI, GDS/GWS/OA, I2C, I2S, doorbells, <just name the strange thing people stuffed into a DMA-buf> which only specific drivers understand.
>>
>> The problem is now that those things at least partially overlap, for example a doorbell which is ringed by a PCI P2P write.
>
> I'd argue that a doorbell rung by a PCI P2P write isn't any different than any
> other PCI P2P access. The data in these buffers doesn't change the type from a
> buffer sharing perspective, the type of data in these buffers is always up to
> some other layer (eg. userspace), so I don't see the overlap.
>
>>>>
>>>> This is where I got to thinking it might end up, not that we have an
>>>> export function that actually exports anything, but merely advertises
>>>> this provider has an object with this fd and it can export it in these
>>>> ways.
>>>>
>>>> Then on import we'd have to go into the exporter and setup the object
>>>> that gets shared between that specific importer/exporter combination
>>>> and not always have a singular export, but one per import, that I
>>>> suppose could be refcounted per export if lots of importers wanted the
>>>> same thing.
>>
>> Yes that is a requirement of ROCm as well and we have hacked around such things massively with the KFD and all the rat tail of consequences seen by it.
>
> I should introduce you to RM :-)
>
> Thanks.
>
> - Alistair
>
>>> That sounds reasonably complex. Do you have a vague plan, ideally in the form
>>> of data-structures/API definitions, that would help explain what it would look
>>> like?
>>>
>>> For now I have sent a simplified RFC series -
>>> https://lore.kernel.org/dri-devel/20261201-dmabuf_shared_buf_v1_xe_rc5-v1-0… - that drops the placement
>>> bits and implements the rough plan I outlined in
>>> https://lore.kernel.org/dri-devel/awZ_Os1pXelOGaFP@nvdebian.thelocal/ . I'm not
>>> sure it addresses everything, but I'd be interested in getting feedback on what
>>> it gets right and what specifically needs fixing/changing, and how, to satisfy
>>> the design constraints.
>>>
>>> Thanks.
>>>
>>> - Alistair
>>>
>>>> Now maybe we can't call this dma-buf, but I think dma-buf is a subset of this.
>>
>> I would say that DMA-buf is the high level API which allows importers and exporters to exchange the data structures of the low level API.
>>
>> Christian.
>>
>>>>
>>>> Dave.
>>
This series tightens the alignment requirements for buffers that are shared
between confidential-computing guests and the host, and adds a common
allocator for host-shared memory.
When a guest runs with private memory, buffers shared with the hypervisor
are not only accessed by the guest. They are also accessed by the host
kernel, and the host may manage the corresponding shared/private state at a
granularity larger than the guest page size.
Architectures such as Arm can detect incorrect accesses to Realm physical
address space PFNs through GPC faults. However, relying on that as the only
line of defence is fragile and can still lead to kernel crashes. The risk
is especially visible for shared buffers that are later mmapped into
userspace, such as guest_memfd or dma-buf backed allocations. Once
userspace can access the mapping, the kernel cannot guarantee that
applications will only touch the intended 4K region rather than the whole
host page mapped into their address space. Those userspace addresses may
also be passed back into the kernel and accessed through the linear map,
resulting in a GPC fault.
To avoid this, host-shared buffers must satisfy two constraints:
- the address must be aligned to the CoCo shared-granule size
- the size must be a multiple of that granule size
The series adds a common CoCo shared-memory layer for enforcing these
constraints. It provides shared-granule geometry and range-validation
helpers, byte-oriented private/shared transition helpers, and
alloc_cc_shared_pages(). The allocator rounds a request to the architecture
shared granule, allocates suitably aligned contiguous pages, transitions
the complete allocation to shared state, and returns the transitioned size
alongside the page.
The corresponding free helper restores the complete allocation to private
state before returning it to the buddy allocator. If private state cannot
be restored safely, the allocation is deliberately leaked rather than
returning potentially shared memory for unrelated use.
The series also makes zeroing part of private-to-shared transitions, with
each architecture clearing memory at the appropriate point. Callers must
therefore initialize shared buffers after the transition; existing contents
are not preserved.
The shared-granule size defaults to PAGE_SIZE and can be overridden by an
architecture. The arm64 CCA changes to discover the host's IPA state change
alignment are not included in this series.
GIC ITS command queues and tables and the dma-buf system_cc_shared heap
use the common allocator. DMA direct, atomic DMA pools and SWIOTLB retain
their allocation paths and use the common layout or transition helpers.
Restricted DMA pools are checked for shared-granule alignment.
Hyper-V users of set_memory_encrypted() and set_memory_decrypted() are not
changed to use cc_make_shared() by this series. Those paths are not
currently used by the arm64 CCA code path, and therefore are not part of
the arm64 CCA IPA state change alignment problem addressed here.
Notes:
* Codex assisted with implementation, review and series organization.
Changes from v9:
https://lore.kernel.org/all/20261104164555.3555725-1-aneesh.kumar@kernel.org
* Leak allocations after failed sharing in the common allocator and SWIOTLB.
* Move x86 zeroing from the AMD, TDX and Hyper-V vTOM callbacks to
set_memory_decrypted(), after a successful transition
* Add set_memory_decrypted_nozero() for VGA mappings, which must change
memory attributes without clearing device memory.
* Zero memory even when encryption is inactive in the generic, arm64 and
pSeries implementations of set_memory_decrypted().
* Move pSeries zeroing after sharing. Document why pKVM and s390 must clear
private contents before sharing
* Drop the GIC ITS VPE L1 preallocation patch from this series.
This issue predates the series and will be addressed separately.
* Add mm/cc_shared.c and include/linux/cc_shared.h to the TSM MAINTAINERS
entry.
Changes from v8:
https://lore.kernel.org/all/20260924100529.1398790-1-aneesh.kumar@kernel.org
* Rebase onto the 7.4-rc1
* Move TDX and AMD (including SEV-SNP) zeroing to their finish callbacks
so private-to-shared transitions clear the final shared mapping.
* Clear __GFP_MOVABLE for shared allocations, which cannot be migrated.
* Resolve NUMA_NO_NODE in the common ITS allocation helper to preserve
placement for all ITS callers.
* Stop SWIOTLB allocation retries when the reduced pool would fall below
the shared granule size, avoiding an allocation retry loop.
Changes from v7:
https://lore.kernel.org/all/20260921144847.501151-1-aneesh.kumar@kernel.org
* Add the following new patches:
* "irqchip/gic-v3-its: Preallocate VPE L1 tables"
* "mm: Assert CoCo shared allocations may sleep"
* "mm: Zero memory during shared memory transitions"
* Drop the arm64 RHI and shared granule size patches so that the series can
be rebased on top of upstream to enable Shashiko review.
Changes from v6:
https://lore.kernel.org/all/20260904103452.1197239-1-aneesh.kumar@kernel.org
* Add a common allocator and geometry/transition helpers for CoCo host-shared
memory.
* Convert GIC ITS, dma-direct, atomic DMA pools, and the dma-buf
system_cc_shared heap to the common allocator.
* Limit dma-buf scatterlist entries to the requested buffer size so rounded
backing is not exposed to importers.
Changes from v5:
https://lore.kernel.org/all/20260706060432.1375570-1-aneesh.kumar@kernel.org
* Rebased to latest kernel
* Drop patch arm64: realm: Move Realm memory encryption ops to RSI code
Changes from v4:
https://lore.kernel.org/all/20260427063108.909019-1-aneesh.kumar@kernel.org
* Rename the helpers to use CoCo terminology
(mem_cc_shared_granule_size() / mem_cc_align_to_shared_granule() instead of
mem_decrypt_granule_size() / mem_decrypt_align()).
* Use __DMA_ATTR_ALLOC_CC_SHARED to pass CoCo shared allocation requirements
down to CMA-based allocation helpers.
* Add validation for restricted DMA pools to reject pools that are not aligned
to the shared granule size.
* Add dma-buf system heap handling for cc-shared buffers.
* Split the previous combined DMA/SWIOTLB/ITS change into smaller subsystem
patches covering ITS, DMA direct, SWIOTLB, restricted DMA pools, dma-buf
system heap, and arm64 Realm support.
* Rework arm64 Realm support by moving Realm memory encryption ops into RSI
code and exposing the CCA shared granule size through arm64_mem_crypt_ops.
Changes from v3:
https://lore.kernel.org/all/20260309102625.2315725-1-aneesh.kumar@kernel.org
* Fix build error reported by kernel test robot <lkp(a)intel.com>
Changes from v2:
https://lore.kernel.org/all/20251221160920.297689-1-aneesh.kumar@kernel.org
* Rebase to latest kernel
* Consider swiotlb always decrypted and don't align when allocating from swiotlb.
Changes from v1:
* Rename the helper to mem_encrypt_align
* Improve the commit message
* Handle DMA allocations from contiguous memory
* Handle DMA allocations from the pool
* swiotlb is still considered unencrypted. Support for an encrypted swiotlb pool
is left as TODO and is independent of this series.
Cc: Andrew Morton <akpm(a)linux-foundation.org>
Cc: Baoquan He <baoquan.he(a)linux.dev>
Cc: Mike Rapoport <rppt(a)kernel.org>
Cc: Pasha Tatashin <pasha.tatashin(a)soleen.com>
Cc: Pratyush Yadav <pratyush(a)kernel.org>
Cc: Catalin Marinas <catalin.marinas(a)arm.com>
Cc: "Christian König" <christian.koenig(a)amd.com>
Cc: Jason Gunthorpe <jgg(a)ziepe.ca>
Cc: Joerg Roedel (AMD) <joro(a)8bytes.org>
Cc: Marc Zyngier <maz(a)kernel.org>
Cc: Marek Szyprowski <m.szyprowski(a)samsung.com>
Cc: Robin Murphy <robin.murphy(a)arm.com>
Cc: Steven Price <steven.price(a)arm.com>
Cc: Sumit Semwal <sumit.semwal(a)linaro.org>
Cc: Suzuki K Poulose <suzuki.poulose(a)arm.com>
Cc: Thomas Gleixner <tglx(a)kernel.org>
Cc: Will Deacon <will(a)kernel.org>
Cc: Russell King <linux(a)armlinux.org.uk>
Cc: Benjamin Gaignard <benjamin.gaignard(a)collabora.com>
Cc: Brian Starkey <Brian.Starkey(a)arm.com>
Cc: John Stultz <jstultz(a)google.com>
Cc: Mark Rutland <mark.rutland(a)arm.com>
Cc: Radu Rendec <radu(a)rendec.net>
Cc: "T.J. Mercier" <tjmercier(a)google.com>
Cc: Madhavan Srinivasan <maddy(a)linux.ibm.com>
Cc: Michael Ellerman <mpe(a)ellerman.id.au>
Cc: Nicholas Piggin <npiggin(a)gmail.com>
Cc: Christophe Leroy (CS GROUP) <chleroy(a)kernel.org>
Cc: Ritesh Harjani (IBM) <ritesh.list(a)gmail.com>
Cc: Shrikanth Hegde <sshegde(a)linux.ibm.com>
Cc: Alexander Gordeev <agordeev(a)linux.ibm.com>
Cc: Gerald Schaefer <gerald.schaefer(a)linux.ibm.com>
Cc: Heiko Carstens <hca(a)linux.ibm.com>
Cc: Vasily Gorbik <gor(a)linux.ibm.com>
Cc: Christian Borntraeger <borntraeger(a)linux.ibm.com>
Cc: Sven Schnelle <svens(a)linux.ibm.com>
Cc: Ingo Molnar <mingo(a)redhat.com>
Cc: Borislav Petkov <bp(a)alien8.de>
Cc: Dave Hansen <dave.hansen(a)linux.intel.com>
Cc: x86(a)kernel.org
Cc: H. Peter Anvin <hpa(a)zytor.com>
Cc: Kiryl Shutsemau <kas(a)kernel.org>
Cc: Rick Edgecombe <rick.p.edgecombe(a)intel.com>
Cc: K. Y. Srinivasan <kys(a)microsoft.com>
Cc: Haiyang Zhang <haiyangz(a)microsoft.com>
Cc: Wei Liu <wei.liu(a)kernel.org>
Cc: Dexuan Cui <decui(a)microsoft.com>
Cc: Long Li <longli(a)microsoft.com>
Cc: Paolo Bonzini <pbonzini(a)redhat.com>
Cc: Vitaly Kuznetsov <vkuznets(a)redhat.com>
Cc: Andy Lutomirski <luto(a)kernel.org>
Cc: Peter Zijlstra <peterz(a)infradead.org>
Cc: dri-devel(a)lists.freedesktop.org
Cc: iommu(a)lists.linux.dev
Cc: linaro-mm-sig(a)lists.linaro.org
Cc: linux-arm-kernel(a)lists.infradead.org
Cc: linux-media(a)vger.kernel.org
Cc: linux-mm(a)kvack.org
Cc: kvmarm(a)lists.linux.dev
Cc: patches(a)lists.linux.dev
Aneesh Kumar K.V (Arm) (13):
mm: Add an allocator for CoCo shared memory
mm: Zero memory during shared memory transitions
irqchip/gic-v3-its: Resolve the default NUMA node explicitly
irqchip/gic-v3-its: Allocate shared tables using CoCo shared memory
allocator
dma-contiguous: Derive shared alignment from DMA attributes
dma-pool: Allocate CoCo atomic pools using CoCo shared memory
allocator
dma-direct: Align CoCo shared DMA allocations to the shared granule
size
swiotlb: Align shared IO TLB pools to the shared granule size
swiotlb: Reject misaligned restricted DMA pools for CoCo guests
dma-buf: system_heap: Limit scatterlist entries to the buffer size
dma-buf: system_heap: Allocate shared buffers using CoCo shared memory
allocator
swiotlb: Make rounded shared pool capacity allocatable
mm: Assert CoCo shared allocations may sleep
MAINTAINERS | 2 +
arch/arm/mm/dma-mapping.c | 5 +-
arch/arm64/mm/mem_encrypt.c | 8 +-
arch/powerpc/platforms/pseries/svm.c | 13 +-
arch/s390/mm/init.c | 7 +
arch/x86/hyperv/hv_init.c | 6 +-
arch/x86/include/asm/set_memory.h | 1 +
arch/x86/include/asm/vga.h | 4 +-
arch/x86/kernel/kvmclock.c | 6 +-
arch/x86/mm/mem_encrypt_amd.c | 1 +
arch/x86/mm/pat/set_memory.c | 19 +-
drivers/dma-buf/heaps/system_heap.c | 128 +++++-----
drivers/firmware/arm_rmm/rsi.c | 9 +
drivers/hv/connection.c | 41 ++-
drivers/hv/hv.c | 11 +-
drivers/hv/hv_common.c | 2 -
drivers/iommu/dma-iommu.c | 2 +-
drivers/irqchip/irq-gic-v3-its.c | 42 ++--
drivers/virt/coco/pkvm-guest/arm-pkvm-guest.c | 4 +
include/linux/cc_shared.h | 39 +++
include/linux/dma-map-ops.h | 9 +-
include/linux/set_memory.h | 8 +-
kernel/dma/contiguous.c | 41 ++-
kernel/dma/direct.c | 73 ++++--
kernel/dma/ops_helpers.c | 2 +-
kernel/dma/pool.c | 27 +-
kernel/dma/swiotlb.c | 94 ++++---
kernel/kexec_file.c | 3 +-
mm/Makefile | 1 +
mm/cc_shared.c | 238 ++++++++++++++++++
30 files changed, 635 insertions(+), 211 deletions(-)
create mode 100644 include/linux/cc_shared.h
create mode 100644 mm/cc_shared.c
base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
prerequisite-patch-id: 121492d71cc22b2adbfdedd668868c5a449ad764
prerequisite-patch-id: ed31fd728f0adba3d60dcd6f3bae8da1a2193bcc
--
2.43.0
On 12/1/26 14:58, Boris Brezillon wrote:
> If a job is passed a dependency that's coming from the same queue the
> job is targeting, we can get rid of the dependency because of the
> implicit serialization provided by the queue. This will allow us to take
> benefit of the pipelining provided by the ring buffer (no extra
> MCU <-> CPU round-trip to have the job pushed to the ring buffer).
>
> Signed-off-by: Boris Brezillon <boris.brezillon(a)collabora.com>
> Cc: Xianzhong Li <xianzhong.li(a)nxp.com>
> ---
> Some recent effort to improve job pipelining [1] showed that the
> MCU <-> CPU round-trip that lets us signal job fences adds a
> non-negligible overhead, and this problem seems to be easier and
> more systematically fixed if it's addressed at the KMD side, so
> here's a patch doing exactly that.
>
> [1]https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/46172
> ---
> drivers/gpu/drm/panthor/panthor_drv.c | 41 +++++++++++++++++++++++++++++++++++
> 1 file changed, 41 insertions(+)
>
> diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c
> index dc8d0191aef4..cfffb9e2dec8 100644
> --- a/drivers/gpu/drm/panthor/panthor_drv.c
> +++ b/drivers/gpu/drm/panthor/panthor_drv.c
> @@ -7,6 +7,8 @@
> #include <asm/arch_timer.h>
> #endif
>
> +#include <linux/dma-fence-array.h>
> +#include <linux/dma-fence-chain.h>
> #include <linux/list.h>
> #include <linux/module.h>
> #include <linux/of_platform.h>
> @@ -591,6 +593,40 @@ panthor_submit_ctx_push_fences(struct panthor_submit_ctx *ctx)
> }
> }
>
> +static bool can_skip_dep(const struct drm_sched_job *job, struct dma_fence *fence)
> +{
> + if (!fence)
> + return true;
> +
> + /* This fence comes from our queue, and the serialization happening at
> + * the queue level makes it so we can skip the CPU wait.
> + */
> + if (fence->context == job->entity->fence_context ||
> + fence->context == job->entity->fence_context + 1)
> + return true;
> +
> + if (dma_fence_is_chain(fence)) {
> + dma_fence_chain_for_each(fence, fence) {
> + if (!can_skip_dep(job, dma_fence_chain_contained(fence)))
Recursion is usually not allowed inside the Linux kernel even when like in this case it is limited.
But you can use the dma_fence_unwrap_for_each() helper for this which should make the code much easier to write and understand.
But let me send you the cleanup patch for the dma_fence_unwrap_for_each() helper as well.
Regards,
Christian.
> + return false;
> + }
> +
> + return true;
> + } else if (dma_fence_is_array(fence)) {
> + struct dma_fence *sub_fence;
> + u32 index;
> +
> + dma_fence_array_for_each(sub_fence, index, fence) {
> + if (!can_skip_dep(job, sub_fence))
> + return false;
> + }
> +
> + return true;
> + }
> +
> + return false;
> +}
> +
> /**
> * panthor_submit_ctx_add_sync_deps_to_job() - Add sync wait operations as
> * job dependencies.
> @@ -637,6 +673,11 @@ panthor_submit_ctx_add_sync_deps_to_job(struct panthor_submit_ctx *ctx,
> return ret;
> }
>
> + if (can_skip_dep(job, fence)) {
> + dma_fence_put(fence);
> + continue;
> + }
> +
> ret = drm_sched_job_add_dependency(job, fence);
> if (ret)
> return ret;
>
> ---
> base-commit: 28f286b0dfa9610d4ee2447415e964e8bc603056
> change-id: 20261201-panhtor-dep-skip-9c6a3e2f7cc7
>
> Best regards,
On Sun, Nov 29, 2026 at 12:35:35PM +0100, Tomeu Vizoso wrote:
> Allow specifying a second sub-mailbox that could be used by the firmware
> in addition to the first one, which is taken by remoteproc.
>
> This is required by firmware that doesn't use rpmsg for their
> communication with the Linux kernel.
>
> Signed-off-by: Tomeu Vizoso <tomeu(a)tomeuvizoso.net>
>
> ---
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski(a)oss.qualcomm.com>
Best regards,
Krzysztof
On Sun, Nov 29, 2026 at 12:35:34PM +0100, Tomeu Vizoso wrote:
> Besides the existing L2 SRAM region, at least some C7x DSPs in K3 SoCs
> have an additional region called in the documentation "AUX L2 SRAM".
> This is just some more SRAM that is accessed separately.
>
> Also add the memory region for the control registers of the DRU (Data
> Routing Unit), which allow starting DMA transactions and polling for
> their completion.
>
> The two entries are optional, so existing device trees still validate,
> and are allowed only for the ti,am62a-c7xv-dsp compatible, the C7x
> generation that has them.
>
> Signed-off-by: Tomeu Vizoso <tomeu(a)tomeuvizoso.net>
>
> ---
>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski(a)oss.qualcomm.com>
Best regards,
Krzysztof
Hi guys,
On 12/1/26 08:13, Alistair Popple wrote:
> On 2026-12-01 at 15:05 +1100, Dave Airlie <airlied(a)gmail.com> wrote...
>>> The problem is I can't figure out how to build that low level API.
Seconded.
I can give you quite a bunch of requirements based on what the high level DMA-buf API and uAPI has on functionality and based on what I have seen on use cases in the wild.
But I can't say either what the low level API needs to look like and one of the major reasons I want DMA-buf separated from that low level API is that it seems like this needs a different field of expertise and responsibilities.
>>>
>>> The current low level DMA API can't correctly handle PCIe P2P, or IOMMUFD, or
>>> the KVM/confidential compute use-cases (I'm less familiar with those). It can
>>> only handle creating a DMA mapping for system memory for a specific importing
>>> device.
>>>
>>> So I assume you are talking about some new API. Following Dave's lead lets call
>>> that shared_buf_map(). That would need to take some importing device context
>>> so that it could dispatch to the correct mapping code and a list of physical
>>> locations the exporter needs mapped.
>>>
>>> At a high level something like:
>>>
>>> struct dma_addr_list *shared_buf_map(import_context, location_list);
>>>
>>> Where the import_context is some importer specific struct opaque to the exporter
>>> and the location list is a list of either PCIe MMIO or system RAM physical
>>> addresses.
>>>
>>> Every exporter ->map_dma_buf() should call shared_buf_map() instead of
>>> open-coding their own mapping code, as I think we all agree we don't want that
>>> open-coded.
>>>
>>> Placement selection can be dealt with as a separate topic, so setting that
>>> aside means passing in the same location list regardless of importing device.
>>> shared_buf_map() then has to dispatch to the correct mapping generation code -
>>> either DMA API, PCIe peer-to-peer API, IOMMUFD API, KVM API or maybe some other
>>> importing device/driver specific API.
That sounds totally sane to me, yes.
>>>
>>> I could see how that could be made to work, but it seems more complex than
>>> a dma_buf exporter op that returns a list of physical locations and a helper
>>> library that importers call to do the mapping into whatever importer specific
>>> context is needed. Instead you would have to add importer specific callbacks
>>> that the shared_buf_map code could call along with plumbing the importer context
>>> through.
I've thought about that as well for a while but came to the conclusion that we most likely want some more differentiation here.
On the one hand we have the vendor agnostic things like PCI P2P, IOMMU, IOVAs, bus addresses, CPU physical addresses etc... which a vendor agnostic API should be dealing with.
On the other hand we have vendor specific things like XGMI, GDS/GWS/OA, I2C, I2S, doorbells, <just name the strange thing people stuffed into a DMA-buf> which only specific drivers understand.
The problem is now that those things at least partially overlap, for example a doorbell which is ringed by a PCI P2P write.
>>
>> This is where I got to thinking it might end up, not that we have an
>> export function that actually exports anything, but merely advertises
>> this provider has an object with this fd and it can export it in these
>> ways.
>>
>> Then on import we'd have to go into the exporter and setup the object
>> that gets shared between that specific importer/exporter combination
>> and not always have a singular export, but one per import, that I
>> suppose could be refcounted per export if lots of importers wanted the
>> same thing.
Yes that is a requirement of ROCm as well and we have hacked around such things massively with the KFD and all the rat tail of consequences seen by it.
> That sounds reasonably complex. Do you have a vague plan, ideally in the form
> of data-structures/API definitions, that would help explain what it would look
> like?
>
> For now I have sent a simplified RFC series -
> https://lore.kernel.org/dri-devel/20261201-dmabuf_shared_buf_v1_xe_rc5-v1-0… - that drops the placement
> bits and implements the rough plan I outlined in
> https://lore.kernel.org/dri-devel/awZ_Os1pXelOGaFP@nvdebian.thelocal/ . I'm not
> sure it addresses everything, but I'd be interested in getting feedback on what
> it gets right and what specifically needs fixing/changing, and how, to satisfy
> the design constraints.
>
> Thanks.
>
> - Alistair
>
>> Now maybe we can't call this dma-buf, but I think dma-buf is a subset of this.
I would say that DMA-buf is the high level API which allows importers and exporters to exchange the data structures of the low level API.
Christian.
>>
>> Dave.
On Thu, 26 Nov 2026 11:59:09 +0530, Jayant Shekhar wrote:
> Add a binding for the Qualcomm DCP VirtIO display function.
> Document the framebuffer IOMMU context, DCP INTF output graph, DSI host
> indices, and connections to the external display chain. Firmware-owned
> display resources and internal paths are discovered at runtime.
>
> Assisted-by: LLM
> Signed-off-by: Jayant Shekhar <jayant.shekhar(a)oss.qualcomm.com>
> ---
> .../devicetree/bindings/display/msm/qcom,dcp.yaml | 159 +++++++++++++++++++++
> 1 file changed, 159 insertions(+)
>
My bot found errors running 'make dt_binding_check' on your patch:
yamllint warnings/errors:
dtschema/dtc warnings/errors:
Documentation/devicetree/bindings/virtio/qcom,dcp-virtio.example.dtb: virtio@9be8000 (qcom,dcp-virtio): iommu-ranges: [[0,2214592512,0,67108864]] has less than 4 items
from schema $id: http://devicetree.org/schemas/virtio/qcom,dcp-virtio.yaml
Documentation/devicetree/bindings/virtio/qcom,dcp-virtio.example.dtb: virtio@9be8000 (qcom,dcp-virtio): iommu-ranges:0: [0,2214592512,0,67108864] is not of type "integer"
from schema $id: http://devicetree.org/schemas/virtio/qcom,dcp-virtio.yaml
Documentation/devicetree/bindings/virtio/qcom,dcp-virtio.example.dtb: virtio@9be8000 (qcom,dcp-virtio): iommu-ranges:0: [0,2214592512,0,67108864] is not of type "integer"
from schema $id: http://devicetree.org/schemas/virtio/qcom,dcp-virtio.yaml
doc reference errors (make refcheckdocs):
See https://patchwork.kernel.org/project/devicetree/patch/20261126-jshekhar-v3-…
The base for the series is generally the latest rc1. A different dependency
should be noted in *this* patch.
If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:
pip3 install dtschema --upgrade
Please check and re-submit after running the above command yourself. Note
that DT_SCHEMA_FILES can be set to your schema file to speed up checking
your schema. However, it must be unset to test all examples with your schema.