From nobody Sun Feb 8 00:11:39 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 DA8CD285C91 for ; Mon, 5 Jan 2026 08:23:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767601392; cv=none; b=IFahVrp3eZEsVXTH471HHu9PLtljAELv9auVy6UTnh8B3HLPBeh7dsm1Vms16ybO1d+Noq7pr3xdZpSGSLc6AJCPCESUrVH2fwrmJNlcyAh1yfb6RoAkmCERQG/ZDJC4ivE1zgE0sU9GeoiZm3+bFVbHKkddOl808tPz7QYjzf4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767601392; c=relaxed/simple; bh=IXDkDZtAt0m+aQ314vUNmBOnLJtrDRmmzuRNBy60P98=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=KOdHtjv0thB/saVc+ai0/TRs8YtmEpjl0rZ5BxjEarcdmDBquLUhuwjL55tjwwJBr2UxB22+Cyzf+Q1ya1uXEhBVuMBjSuJD5VfgR+OiCbjNuwypd6Z+IsigVdxdLF2VrYuJ3uozD8Oi2Il+5Zr2SbrHD5kPRLN0FI1NSoUF+Ak= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=AEBaeALe; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=SVLy5NLa; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="AEBaeALe"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="SVLy5NLa" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1767601388; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=1GET0dQPIEY4INQeC72jj/1xpmrzV3mfvZ6nPpr/HKY=; b=AEBaeALep1zaNbb0x0/0n6NT1Y1yen9lZPR5QYlhYaryR+slD065Hydx5X+LHnUm4eUQ40 VsnNwXHsVoJeAFuMARDPi/7suOmiuEbeUE7BrqGpulBIrlIdhNRbHBmcn+ZpbA+uWUT/GU NDS4V23B7nFdBRCQcv7uCdN8wAaJZOM= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-199-3GpukyDVP6ia7-_ToDfzSw-1; Mon, 05 Jan 2026 03:23:07 -0500 X-MC-Unique: 3GpukyDVP6ia7-_ToDfzSw-1 X-Mimecast-MFC-AGG-ID: 3GpukyDVP6ia7-_ToDfzSw_1767601386 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-47d5c7a2f5dso41768105e9.2 for ; Mon, 05 Jan 2026 00:23:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1767601386; x=1768206186; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=1GET0dQPIEY4INQeC72jj/1xpmrzV3mfvZ6nPpr/HKY=; b=SVLy5NLaTRyVFdHdGzEjHMfGiKbc6I3fmsbr9lm1E8b1CKA/LQPCgjNjlWxIeHOo5k TCyXSslVxjf4VZ9QOe/s6tO2/Kwb4Jh6FbN2yQg8JaYMQ5nfvPhs0YO+1lEDBjqdTmKK nogzUqEH4ucYBZ2zA5lSaWV6mg4RpJBvIS8ASAcegaSwnPt7qTWgY7Miod5DsRDAoOYV UepvtMzbzwR8LaO4yzzJNvOZ4N26154q2EDHSSzoxcZQ6NqYgihrX2umzlfrkKx0+K3x VdkBYb/Grc6tgqNZeOLw5aG2S93fmuUJsNF5Da+4flx0dpVDTijlOJSLPU0HOTBDzlrv QX7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767601386; x=1768206186; h=in-reply-to:content-disposition: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; bh=1GET0dQPIEY4INQeC72jj/1xpmrzV3mfvZ6nPpr/HKY=; b=mESFO/lslFgxnCgK+dxcafUf4mcna8SWC28su84ItOwmjFOKggmFdBFC5TmyfvLJ6Z MKPjn0FeVQYIS2g02zdAiK83efIN7ZyNrGHfWL4qM8aJU4AgE9mZO5Thc7bh0gz10sZH AYNzscxJEFKjZL0tz2A+MBmtXcJO0lx23YE9BHutI5Sr5CthEx+MQ4UBXhzS2mOtlE+d BoVaE3m3U0Gs8EghRreLePVAKhcPypAy53GifkyILdei58mBSYEK6xHmTnhctDQX8J3E E0TheGCPYquGz+JcjZB678JpWn6gSZigWMFlHEKYmTNzTel9pMYbAX5C4VLTzz6FgIrJ jFOQ== X-Gm-Message-State: AOJu0Yx+BouydH4/40Aq6IpK3+CirzawwgTftQMpKADrZQpZaEbw+Ayq OM9tUhzMa/E+L6kzS/5OvDyMydZng4ikf6BAedKSpvG2qQ5kkhYBHGne8epsl+K5xyQiztK+uRf gufYqpyHRx9bqh/DioAaB0G+ibaJTkzJBd94mVpCKVJnRQACTlTZq6EBWH0kpG2jbvErdTRs52J FRGkWEpEWkNQCnztSJ4HZF6CyGfe9K8VOCNWbCKPaMjEY= X-Gm-Gg: AY/fxX7NH946OIOEeBEPpasgxN/KYJB4Mz8jfzJWONoYohhdHbeoo058RAOzL9wxJBN 9KjOEwihoLkkgp9gqUZ5df3uNSQZm+20P1by61Fmr8pVwKWJ2z+NGzA0yYbl10DFe2URLmXzLqD kUgi7vFukEzufJjkmFJJYbE0Ox1OtuoMpN2Jmvi3sLVIY34u6FhcfipqAqObzYFB8K6m/HB8aVT mDZ8QTldmRwYIL9VGVBsaoHN98cJsVjAXnRaDyMkq/7hapCrAt/GrGRWT/ntKt0lbN0RBMVv8a+ pj4t9Fd/7ZzSGzBsQRpdvCnEVCtkZ2+LynFgpmj8TwMaxPzAlbQnnFG0Fj39Pee4GLfIMnG/Qp0 vhsuLBqRovWywKgEl7enttwJd+/V462Bp6A== X-Received: by 2002:a05:600c:8107:b0:477:7f4a:44b0 with SMTP id 5b1f17b1804b1-47d1959441fmr614821645e9.33.1767601385873; Mon, 05 Jan 2026 00:23:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IFFnRSrw61tFPN3ingmu+tnGwj19lkkHlcV8EUdBq7ZpNk54zAQl+NVy05hzMsFUOEhZ22F+w== X-Received: by 2002:a05:600c:8107:b0:477:7f4a:44b0 with SMTP id 5b1f17b1804b1-47d1959441fmr614820945e9.33.1767601385198; Mon, 05 Jan 2026 00:23:05 -0800 (PST) Received: from redhat.com (IGLD-80-230-31-118.inter.net.il. [80.230.31.118]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47d6c0a1d89sm52159655e9.12.2026.01.05.00.23.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jan 2026 00:23:04 -0800 (PST) Date: Mon, 5 Jan 2026 03:23:01 -0500 From: "Michael S. Tsirkin" To: linux-kernel@vger.kernel.org Cc: Cong Wang , Jonathan Corbet , Olivia Mackall , Herbert Xu , Jason Wang , Paolo Bonzini , Stefan Hajnoczi , Eugenio =?utf-8?B?UMOpcmV6?= , "James E.J. Bottomley" , "Martin K. Petersen" , Gerd Hoffmann , Xuan Zhuo , Marek Szyprowski , 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 Subject: [PATCH v2 03/15] dma-mapping: add DMA_ATTR_CPU_CACHE_CLEAN Message-ID: <2d5d091f9d84b68ea96abd545b365dd1d00bbf48.1767601130.git.mst@redhat.com> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Acked-by: Marek Szyprowski Reviewed-by: Petr Tesarik --- 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) =20 +/* + * 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. I= t 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 =3D=3D -ENOMEM) { pr_err_once("cacheline tracking ENOMEM, dma-debug disabled\n"); global_disable =3D true; - } else if (rc =3D=3D -EEXIST && !(attrs & DMA_ATTR_SKIP_CPU_SYNC) && + } else if (rc =3D=3D -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, --=20 MST