From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BDEB140FD9C; Thu, 8 Jan 2026 13:57:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.118.77.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767880678; cv=none; b=l+Nq+mj3q6wiVjio0C70wCgKlvYAcBRsd1ix1ztV4sq8pjZhlarFjSV1nzMskQYOcgMG1izRqm5prg3Cx9xMOSdsXwhB12hj7/oJEND0sxrqNNoNIQFIv/qJR0o4JsUJWlt+9E87hkx5oD6C902+Ps6g5egRaYdPxsgGbWQ2wdI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767880678; c=relaxed/simple; bh=oo49FY2ULfaQzovc7U0e+DMcGIZIxCNslx48Vot+DTc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:From:In-Reply-To: Content-Type:References; b=UY6T4wChp9koqnkMWFImtB9doyHIgRiMN15jxPZdd9DV0igKbGT7i1I5rT8mJCNuCnV4A7VlUYE+TgNAbofJ5S3dF1LfDtyk0jSOr/EXfYDY5nz6eFy7YDGZikawsKzsl1+hs3gVoL/IfzDTIb4XDz7tJ4JWHnRYOb8hxHxEr0s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=N46t9Kk/; arc=none smtp.client-ip=210.118.77.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="N46t9Kk/" Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20260108135752euoutp01739b42acd5b37a2cf575cc6620e75601~Ixhr3Z5IZ0573705737euoutp01M; Thu, 8 Jan 2026 13:57:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20260108135752euoutp01739b42acd5b37a2cf575cc6620e75601~Ixhr3Z5IZ0573705737euoutp01M DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1767880672; bh=yH2rPLThWUM1dKN4UcJR1XVOYszcMfuT+BMdjTT6Aeg=; h=Date:Subject:To:Cc:From:In-Reply-To:References:From; b=N46t9Kk/hKhFT/cK/fnFzzobH1ZHxDEKrH7vDer+rIyqkzq2N3DjZtamOag7s+48z i2stGQ72tRjS8NBhnxaWsqtYROJQY5AGOSLNwsEn/ggNNLJc1AOnGbHRIXur7qHK0Z QXh9oqt5sxoI2nKXY+ibzdMZ6i2j5jvnKS/9Zbog= Received: from eusmtip2.samsung.com (unknown [203.254.199.222]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20260108135752eucas1p13f59f8e3f41236b8ee98e7a0596869e7~Ixhrlgbp73057130571eucas1p1m; Thu, 8 Jan 2026 13:57:52 +0000 (GMT) Received: from [106.210.134.192] (unknown [106.210.134.192]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20260108135749eusmtip2c78af2cbbbecbe57163d255ece269da0~IxholZqkN2020220202eusmtip2V; Thu, 8 Jan 2026 13:57:49 +0000 (GMT) Message-ID: Date: Thu, 8 Jan 2026 14:57:48 +0100 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Betterbird (Windows) Subject: Re: [PATCH v2 03/15] dma-mapping: add DMA_ATTR_CPU_CACHE_CLEAN To: "Michael S. Tsirkin" , linux-kernel@vger.kernel.org Cc: Cong Wang , Jonathan Corbet , Olivia Mackall , Herbert Xu , Jason Wang , Paolo Bonzini , Stefan Hajnoczi , =?UTF-8?Q?Eugenio_P=C3=A9rez?= , "James E.J. Bottomley" , "Martin K. Petersen" , Gerd Hoffmann , Xuan Zhuo , Robin Murphy , Stefano Garzarella , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Petr Tesarik , Leon Romanovsky , Jason Gunthorpe , Bartosz Golaszewski , linux-doc@vger.kernel.org, linux-crypto@vger.kernel.org, virtualization@lists.linux.dev, linux-scsi@vger.kernel.org, iommu@lists.linux.dev, kvm@vger.kernel.org, netdev@vger.kernel.org Content-Language: en-US From: Marek Szyprowski In-Reply-To: <2d5d091f9d84b68ea96abd545b365dd1d00bbf48.1767601130.git.mst@redhat.com> Content-Transfer-Encoding: 8bit X-CMS-MailID: 20260108135752eucas1p13f59f8e3f41236b8ee98e7a0596869e7 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20260105082314eucas1p2dd6ff42b1a8f9c60e9c813dffef7f4fb X-EPHeader: CA X-CMS-RootMailID: 20260105082314eucas1p2dd6ff42b1a8f9c60e9c813dffef7f4fb References: <2d5d091f9d84b68ea96abd545b365dd1d00bbf48.1767601130.git.mst@redhat.com> On 05.01.2026 09:23, Michael S. Tsirkin wrote: > When multiple small DMA_FROM_DEVICE or DMA_BIDIRECTIONAL buffers share a > cacheline, and DMA_API_DEBUG is enabled, we get this warning: > cacheline tracking EEXIST, overlapping mappings aren't supported. > > This is because when one of the mappings is removed, while another one > is active, CPU might write into the buffer. > > Add an attribute for the driver to promise not to do this, making the > overlapping safe, and suppressing the warning. > > Signed-off-by: Michael S. Tsirkin It is somehow similar to DMA_ATTR_SKIP_CPU_SYNC in its concept, so I see no reason not to accept it. Acked-by: Marek Szyprowski > --- > include/linux/dma-mapping.h | 7 +++++++ > kernel/dma/debug.c | 3 ++- > 2 files changed, 9 insertions(+), 1 deletion(-) > > diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h > index 29ad2ce700f0..29973baa0581 100644 > --- a/include/linux/dma-mapping.h > +++ b/include/linux/dma-mapping.h > @@ -79,6 +79,13 @@ > */ > #define DMA_ATTR_MMIO (1UL << 10) > > +/* > + * DMA_ATTR_CPU_CACHE_CLEAN: Indicates the CPU will not dirty any cacheline > + * overlapping this buffer while it is mapped for DMA. All mappings sharing > + * a cacheline must have this attribute for this to be considered safe. > + */ > +#define DMA_ATTR_CPU_CACHE_CLEAN (1UL << 11) > + > /* > * A dma_addr_t can hold any valid DMA or bus address for the platform. It can > * be given to a device to use as a DMA source or target. It is specific to a > diff --git a/kernel/dma/debug.c b/kernel/dma/debug.c > index 138ede653de4..7e66d863d573 100644 > --- a/kernel/dma/debug.c > +++ b/kernel/dma/debug.c > @@ -595,7 +595,8 @@ static void add_dma_entry(struct dma_debug_entry *entry, unsigned long attrs) > if (rc == -ENOMEM) { > pr_err_once("cacheline tracking ENOMEM, dma-debug disabled\n"); > global_disable = true; > - } else if (rc == -EEXIST && !(attrs & DMA_ATTR_SKIP_CPU_SYNC) && > + } else if (rc == -EEXIST && > + !(attrs & (DMA_ATTR_SKIP_CPU_SYNC | DMA_ATTR_CPU_CACHE_CLEAN)) && > !(IS_ENABLED(CONFIG_DMA_BOUNCE_UNALIGNED_KMALLOC) && > is_swiotlb_active(entry->dev))) { > err_printk(entry->dev, entry, Best regards -- Marek Szyprowski, PhD Samsung R&D Institute Poland