On Wed, Jul 01, 2026 at 11:19:14AM +0530, Aneesh Kumar K.V (Arm) wrote: > Propagate force_dma_unencrypted() into __DMA_ATTR_ALLOC_CC_SHARED in the > dma-direct allocation path and use the attribute to drive the related > decisions. > > This updates dma_direct_alloc(), dma_direct_free(), and > dma_direct_alloc_pages() to fold the forced unencrypted case into attrs. > > Tested-by: Jiri Pirko <[email protected]> > Tested-by: Michael Kelley <[email protected]> > Tested-by: Mostafa Saleh <[email protected]> > Reviewed-by: Petr Tesarik <[email protected]> > Signed-off-by: Aneesh Kumar K.V (Arm) <[email protected]> > --- > kernel/dma/direct.c | 42 +++++++++++++++++++++++++++++++++--------- > kernel/dma/mapping.c | 9 +++++++++ > 2 files changed, 42 insertions(+), 9 deletions(-) > > diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c > index 0cbf2b0835c4..98e47e0b332d 100644 > --- a/kernel/dma/direct.c > +++ b/kernel/dma/direct.c > @@ -192,16 +192,22 @@ void *dma_direct_alloc(struct device *dev, size_t size, > dma_addr_t *dma_handle, gfp_t gfp, unsigned long attrs) > { > bool remap = false, set_uncached = false; > - bool mark_mem_decrypt = true; > + bool mark_mem_decrypt = false; > struct page *page; > void *ret; > > + if (force_dma_unencrypted(dev)) > + attrs |= __DMA_ATTR_ALLOC_CC_SHARED;
After going through what was left of force_dma_unencrypted() once the series was fully applied you might consider something like dma_update_attrs(dev, &attrs); To remove the frequently duplicated code It is fine like this too Reviewed-by: Jason Gunthorpe <[email protected]> Jason
