From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (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 55C1344DB95 for ; Tue, 28 Jul 2026 14:41:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785249701; cv=none; b=ouCNdRgKkDGuadSx5FJrC46G6/lwchrZiJLVox9g2nA6naiMrWBm+C3E69L9omQdIYT5JFyPZvj0QbExs4z6h/IlAYw4y4jSfVgMltSQUruOkO2/PPgnOBW36zflconZpXzN1nV8LavPUFmedxt3hfMDD8sbosslSZt50JozIzo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785249701; c=relaxed/simple; bh=HyNNoVnivWfWMKFmKPjajYoM7OeYhzbKX854ccuv5SE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=riM5GOCmOT82DVdFDQF/6NzM2Kb9suFoXMUnZDmZi8sXC76cpBQzNJie6cgPZKt17IUo6bctUd7mPs6ioGNlLivQCJzlhWfHAtfDmawJILQj5/kdvYmxcck9lnwYkQgBjWqVfOlVntlfPrZSU0njrVQ7EKPzLTpXnVxrRqfe6IM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Sl0noly5; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Sl0noly5" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-495509b08ebso51215e9.1 for ; Tue, 28 Jul 2026 07:41:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1785249697; x=1785854497; 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=JCZrUOE9kwIF4hUfSxEIdPGLi7SYMbxXEbVOya3wkPE=; b=Sl0noly5wl441RypznmnRrHK3FIE1Q8e11xbEzxHxrj2tKAg8KZKnpIAFMXnpnXZB9 DWS2N79cXUZT8/uGzmd3e4ricxsn2G30yPjPTuoLYp+uk5g+ILhSyVx4Ld1b7caUoBQE ZgPTHj+3SbXBsWTy5gfVCfcZrfJPzeYxm74zd3Swsj0qTEctME5CofSC9dmpT+fx6o3e xUFXUHnpVpojlqvzrt5nPe5xqNC/uCkXNloJJByRH3G46P6GoQWpCSzuHREMny4Mo+5Z WB0ZXDfD3aMp4w/HenWlFXK8J62sk7KBpCONZueXKl9oPYHRZ4Xt/QD11NW2qdUeGMLu nTfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785249697; x=1785854497; 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=JCZrUOE9kwIF4hUfSxEIdPGLi7SYMbxXEbVOya3wkPE=; b=LWMK/C1BW8G02owic0XHlQELBZoy0x9YUf/GvcR/wFAqJ34FUKFHWlbgHXz4VSfB9S DEtOYb59Dncp0KMBfW2qc5HYtPXHr+P184f2ODw//r96Mml1p1a/l1HiPapVzssO3DwB ybx5HJzZiN3NwRqDMQ78vzZ8tE2GBeN48WgrXhdRGF6HbbM37Latc7T17TYOj7lsFQll PfubO+FiE6k50dTCNIynHuGANW7jRg7eUDnT0YFdpg5yZwkUVCNJL81icJaa0qclDl3b hXv4GS1eB8GAH1p9FwtrQo7d7bU368itg/bSv1Z64zMYjHqPjJ1n6U09KWrjkAjU5Rgz zRWw== X-Forwarded-Encrypted: i=1; AHgh+RqZk7dyLNtw9Sq/wcyT+lC8EHAMeZ4uCU4zvKcVb35H72lwpHmEruoqTrNJAA45OaHNI4NOhq9EcJlSIdM=@vger.kernel.org X-Gm-Message-State: AOJu0Yz79FgidQ5UPAFC/f0jPBElz+8+TysL9M8q2ciTE+OpxPx29XxX Ssxu2sYIXE4YMCfhlQZ3431ilcu8D9BdYSWCmnsPUiD2e+CZbS7VYfE1SADwyAcA0Q== X-Gm-Gg: AR+sD10aFx5IYHQHv7IgGeX3nqFF4isCSVE9R0QYBrBotctO3G0FKg8CLCg8e/a8I7m QxtJEES2WyM/8DDodDEKJ9HxF39+FW+eJXrl/gf2PgEkJ5p1yCQspfVGrx4RqW7NfifWDGjQHnT RnvyIRctfz73X8TCQ2LrqnLuVXvwowA6bvh1Y4J7LY4vI2rC7WvGokclMkbydmAVWyGmS5oH2DJ CJj9bF1hOAcJaCDxx7ooLyteX0FZhTxkQELpVk2hOFwZAozfBh+sT/roCovwfbXw4jmwlIsOJxY SPljlIpVMKzlqDjpaNKRKdFalDWIx8X2TME7C97leokxHKcjzA5B9lnAOazlKzXUDfLtA/FE2sk PWTi8MftxuWU55lweDiUr+gJYlIJfmtd7kdIkV4Uulpu6267XEDIQuQPKWitRQq67Gw//WwSlHT r/FVylIXS7ZDslEyojCvAq8tgqzhh3EHlQMNj8ymvpu+w= X-Received: by 2002:a05:600c:528c:b0:490:ab15:b9e8 with SMTP id 5b1f17b1804b1-496b944f535mr5111045e9.2.1785249696887; Tue, 28 Jul 2026 07:41:36 -0700 (PDT) Received: from google.com (250.192.189.35.bc.googleusercontent.com. [35.189.192.250]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-496c45c338fsm83874795e9.8.2026.07.28.07.41.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2026 07:41:36 -0700 (PDT) Date: Tue, 28 Jul 2026 14:41:30 +0000 From: Mostafa Saleh 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 , Jason Gunthorpe , 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, Jason Gunthorpe , Michael Kelley Subject: Re: [PATCH v8 12/23] dma: swiotlb: pass mapping attributes by reference Message-ID: References: <20260717180442.110954-1-aneesh.kumar@kernel.org> <20260717180442.110954-13-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: <20260717180442.110954-13-aneesh.kumar@kernel.org> On Fri, Jul 17, 2026 at 11:34:30PM +0530, Aneesh Kumar K.V (Arm) wrote: > Change swiotlb_tbl_map_single() to take the DMA mapping attributes by > reference and update the direct callers accordingly. > > This is a preparatory change for a follow-up patch which updates the > attributes based on the selected swiotlb pool. Keeping the signature change > separate makes the follow-up patch easier to review. > I do not understand the point of this, why would swiotlb_tbl_map_single() force attrs over the caller which should already know the context (whether DMA is shared or not) which case would this be useful to force from the SWIOTLB code? Thanks, Mostafa > No functional change in this patch. > > Reviewed-by: Jason Gunthorpe > Tested-by: Michael Kelley > Tested-by: Mostafa Saleh > Reviewed-by: Petr Tesarik > Signed-off-by: Aneesh Kumar K.V (Arm) > --- > drivers/iommu/dma-iommu.c | 2 +- > drivers/xen/swiotlb-xen.c | 2 +- > include/linux/swiotlb.h | 2 +- > kernel/dma/swiotlb.c | 6 +++--- > 4 files changed, 6 insertions(+), 6 deletions(-) > > diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c > index 83bf15ae9777..c42e40e60575 100644 > --- a/drivers/iommu/dma-iommu.c > +++ b/drivers/iommu/dma-iommu.c > @@ -1180,7 +1180,7 @@ static phys_addr_t iommu_dma_map_swiotlb(struct device *dev, phys_addr_t phys, > trace_swiotlb_bounced(dev, phys, size); > > phys = swiotlb_tbl_map_single(dev, phys, size, iova_mask(iovad), dir, > - attrs); > + &attrs); > > /* > * Untrusted devices should not see padding areas with random leftover > diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c > index 2cbf2b588f5b..8c4abe65cd49 100644 > --- a/drivers/xen/swiotlb-xen.c > +++ b/drivers/xen/swiotlb-xen.c > @@ -243,7 +243,7 @@ static dma_addr_t xen_swiotlb_map_phys(struct device *dev, phys_addr_t phys, > */ > trace_swiotlb_bounced(dev, dev_addr, size); > > - map = swiotlb_tbl_map_single(dev, phys, size, 0, dir, attrs); > + map = swiotlb_tbl_map_single(dev, phys, size, 0, dir, &attrs); > if (map == (phys_addr_t)DMA_MAPPING_ERROR) > return DMA_MAPPING_ERROR; > > diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h > index c92ff6791595..ea4c0a292dea 100644 > --- a/include/linux/swiotlb.h > +++ b/include/linux/swiotlb.h > @@ -238,7 +238,7 @@ static inline phys_addr_t default_swiotlb_limit(void) > > phys_addr_t swiotlb_tbl_map_single(struct device *hwdev, phys_addr_t phys, > size_t mapping_size, unsigned int alloc_aligned_mask, > - enum dma_data_direction dir, unsigned long attrs); > + enum dma_data_direction dir, unsigned long *attrs); > dma_addr_t swiotlb_map(struct device *dev, phys_addr_t phys, > size_t size, enum dma_data_direction dir, unsigned long attrs); > > diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c > index 908de28aceb2..046ae92c4832 100644 > --- a/kernel/dma/swiotlb.c > +++ b/kernel/dma/swiotlb.c > @@ -1396,7 +1396,7 @@ static unsigned long mem_used(struct io_tlb_mem *mem) > */ > phys_addr_t swiotlb_tbl_map_single(struct device *dev, phys_addr_t orig_addr, > size_t mapping_size, unsigned int alloc_align_mask, > - enum dma_data_direction dir, unsigned long attrs) > + enum dma_data_direction dir, unsigned long *attrs) > { > struct io_tlb_mem *mem = dev->dma_io_tlb_mem; > unsigned int offset; > @@ -1430,7 +1430,7 @@ phys_addr_t swiotlb_tbl_map_single(struct device *dev, phys_addr_t orig_addr, > size = ALIGN(mapping_size + offset, alloc_align_mask + 1); > index = swiotlb_find_slots(dev, orig_addr, size, alloc_align_mask, &pool); > if (index == -1) { > - if (!(attrs & DMA_ATTR_NO_WARN)) > + if (!(*attrs & DMA_ATTR_NO_WARN)) > dev_warn_ratelimited(dev, > "swiotlb buffer is full (sz: %zd bytes), total %lu (slots), used %lu (slots)\n", > size, mem->nslabs, mem_used(mem)); > @@ -1609,7 +1609,7 @@ dma_addr_t swiotlb_map(struct device *dev, phys_addr_t paddr, size_t size, > > trace_swiotlb_bounced(dev, phys_to_dma(dev, paddr), size); > > - swiotlb_addr = swiotlb_tbl_map_single(dev, paddr, size, 0, dir, attrs); > + swiotlb_addr = swiotlb_tbl_map_single(dev, paddr, size, 0, dir, &attrs); > if (swiotlb_addr == (phys_addr_t)DMA_MAPPING_ERROR) > return DMA_MAPPING_ERROR; > > -- > 2.43.0 >