From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 516EB299A82 for ; Mon, 13 Jul 2026 19:22:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783970521; cv=none; b=r+H1PqONauW6P3JTWKI0lkviB/i9Ext6mjUKuzWwdN+LNlDr/2JjV6nNYVX/k5JpYc06+rCOu/u6OybwATtOPVzZi/ydWYnrWgsQxMv7UN8i7DnXQegiM8kPrVkB8hIfJMfrlLJ5BGGkO4Ktpr+tWoTrqS1SvPeqJJGcZjbZjtI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783970521; c=relaxed/simple; bh=2S23cLlbDaDZPWx0WS3KxZy0gp3jtCk2pWDFCTO6yTU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=NR13FoCtSxXj5RO39gS1Tx4VLyc8XqYnfek4JwNtBMDNvv4tGDIV1ObP7anGQ4bSauzsHYvWfvBqkYTxYtsd1Q5Z+qxZOEy9BTdYkBL4VuxQs34h4IDmNjV2A94geJmuleVWAHc2WFLut4fIQdkAt1a3/bWVwEBc0LssG0FvgPg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca; spf=pass smtp.mailfrom=ziepe.ca; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b=fV30FvXk; arc=none smtp.client-ip=209.85.222.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="fV30FvXk" Received: by mail-qk1-f178.google.com with SMTP id af79cd13be357-92f03daaa97so152467185a.2 for ; Mon, 13 Jul 2026 12:22:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1783970519; x=1784575319; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=Kt1NNWVp5vzCd+THxZiV4tdGJLfhiT0ZXPz0TueqWMw=; b=fV30FvXk24jAO5EmvQk/hl5IvDE9t1q+ZDmjqaqkdQWftHYoVrSM2Vq4Ogy67+ERLT YP8L6FIiDIR6Qmit0+Lg3pKgPl2W0l2gR2nZCn50v7jRrknyzywvN93X5CowGNC5MtLB P3rHb+bB3cKTRbovRvKpm8I6d8mbIjZs9RKo8cAlfaexi5r+kzYBq4GLdcNUsluaj5v+ iSGUZmD+aG7wm2dcBDJy8PsWPJJN6rhPqQgnn18yaLBGX786TgD8GcifdXKnMQyD7ywy sDOs3pU9SAqm69GSeBK8kA/7DRMuxzhlQlBVa0NrV2udTt8L9rR/+Fjpni4YHugZNrXZ EcZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783970519; x=1784575319; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Kt1NNWVp5vzCd+THxZiV4tdGJLfhiT0ZXPz0TueqWMw=; b=d43bk/y/T2d+CoXF2IZ1qDkVLVtvvdjD0XSn+eo+s0/4DgppT84+2isVdWPSIAuthK 5yUnuHvYdcomVCETxd19fwhwTU2HReZHztjW+hqnYnynMqUcrv0jwkrb94JnfsYJpuQ1 +twN5Em5sv6DKoSaZs3KPFHuJlrv4+hUOfiLyPTZ8rT9WIwtXAmcp2e2vJEjPXSJj2I+ 24AjAPKhSibr8gLdJEdkB12Cm4uD7PDrDNJxX3/uuCn/2231y6isCuP4ahkPsF6IQELf EY2e7W7/9jCc5IwuzXe0h81ASiaDlzmVCUXOz9A6ViBKxsHLH1klRkR6oD1N1KBeOQsD MbCg== X-Forwarded-Encrypted: i=1; AHgh+RpeU7PQ7EUb3OvIplOG/GX3g2IrN/DnlKgLTi/thEfJOFKVIAPlTg8vCV82AvsiZVJskvRPmA+lyG5M2Gw=@vger.kernel.org X-Gm-Message-State: AOJu0YxsyynQ7OgJ2U2ED95Kf/qFg1XmFQIx1Sxbnz1VzSjmreDYzMhV OGpsLBLWDt3rrsu9XeeIWk+vd0TPwmaGlaBcUXQBU0G8WXZOY79isMjQiXOGkLtCGl4= X-Gm-Gg: AfdE7cnTMJ9nMEVnD0HxLF0L9SHRlX9XquKSO1YZ+pp2rQned7T5K4UJBJ5CWyTvGHo m3YRpssd7K2L2AytS2+bvRocPXGLKR/9jeGNkFuuevPm5J22cH9wkTnix2Lpmhe9oySVMtnYPzJ eVNTjHB3kzVc67s2OBd7eGdd45MuGVi2qTLUjs2egxibLs8bnG+DhlGq65jH3MKbqItFAEDhtNa JFoTNrvilCpIWutaS8XIXC6wmjiK1nfsIR4UU+dXdIns+5bPoR5D+AwodZiZO4XTIRp0iBmWYE6 LHuHJvdcAzx1N7hNtyj7HyoMo2cd6Pq2d13NnNf4hdiMovpOKGcalndc+uEMto2vfZH3cD4UZcA yrGj2yFSLpu6zZdPx/1HH0+jdJ5zxXtJbfvzOz4gr9kLycAZLU7a9NTKBniFzZIelr8PmEvE= X-Received: by 2002:a05:620a:44cf:b0:92b:6805:eae0 with SMTP id af79cd13be357-92ef2c0c787mr987778485a.61.1783970519182; Mon, 13 Jul 2026 12:21:59 -0700 (PDT) Received: from ziepe.ca ([159.2.72.92]) by smtp.gmail.com with ESMTPSA id af79cd13be357-92ee5cf7ab2sm1122922585a.30.2026.07.13.12.21.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2026 12:21:58 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1wjME1-0000000E53O-3cBb; Mon, 13 Jul 2026 16:21:57 -0300 Date: Mon, 13 Jul 2026 16:21:57 -0300 From: Jason Gunthorpe To: "Aneesh Kumar K.V (Arm)" Cc: iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-coco@lists.linux.dev, Robin Murphy , Marek Szyprowski , Will Deacon , Marc Zyngier , Steven Price , Suzuki K Poulose , Catalin Marinas , Jiri Pirko , Mostafa Saleh , Petr Tesarik , Alexey Kardashevskiy , Dan Williams , Xu Yilun , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , "Christophe Leroy (CS GROUP)" , Alexander Gordeev , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , x86@kernel.org, Jiri Pirko , Michael Kelley Subject: Re: [PATCH v7 10/22] dma-direct: use __DMA_ATTR_ALLOC_CC_SHARED in alloc/free paths Message-ID: <20260713192157.GQ3133966@ziepe.ca> References: <20260701054926.825925-1-aneesh.kumar@kernel.org> <20260701054926.825925-11-aneesh.kumar@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260701054926.825925-11-aneesh.kumar@kernel.org> 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 > Tested-by: Michael Kelley > Tested-by: Mostafa Saleh > Reviewed-by: Petr Tesarik > Signed-off-by: Aneesh Kumar K.V (Arm) > --- > 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 Jason