From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (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 105F51A9F82 for ; Wed, 31 Dec 2025 13:12:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767186756; cv=none; b=Iu96Bwr+JAUULJP/eP8gBJgv2Fu2+m1AqS/jyHX0jUbxc409U+Za1OfD4FNCmT3/apjR2i+FHSPnkagK7Lnyw1ljblpRKEjwqN6RXen6/j5tP3p8ja0GuzBXG/Cvp8g/QoQbE6tYtHRQwkuaELg1HHq4zyscqWKkpjaQ4zIebl0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767186756; c=relaxed/simple; bh=+Rj9uS/xKO+b+rZgqDTkOPQ7AM9H+O0zY3sW6JnGIaQ=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HUJ657lZ7AV2UjjbdmZDQjqTMvMelCaVEq4yGJd/rWNDb5seuYq1v7xhmmVzeXYJP2QRJxqEwUfefUK7rp++q0rvgg88DH01sw0dZ2ghafZR5bXw3O3emtcO3VxXWIa3sIys070E7yT0ebSw/i7NePEIPZmY42TgBnRmkl8mEDg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=SiNOf5hC; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="SiNOf5hC" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-47d538fafdfso3024535e9.1 for ; Wed, 31 Dec 2025 05:12:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1767186751; x=1767791551; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=Fke3G5rSH2WPZ2DuQdyfqEfEpoI6l76uJNtI0EpEhAo=; b=SiNOf5hCQAQ9lih0xDGV7gjR7CfpmOO8AB3s9IeITfpaC328pdo654nC3FNIfPPnYB fkd5qD9q+HvWSq536C6BhTSPieAbHLipRfLKE21iDDYtDmghplktpIhdpDtdORPciAcZ LQpQ8PKMM8Q6/YUI7t1QvsKoPzRYURS1J27f9/F31nTEFyFQlVX8XQzAr1xtRLQ39GkB REQ15nkajDKe1xg9zkDXa/UH9tt1LtbNShtNDDvRc1UpIXkWn8dwnUZCTvot/hexmBta XggYEqQC1GM23pJ7GQgNCAuwh+5a70MQJiobGXUg7XwbkgAb1lDG3040If49qmyX801q 2gDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767186751; x=1767791551; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Fke3G5rSH2WPZ2DuQdyfqEfEpoI6l76uJNtI0EpEhAo=; b=FzIWzeacIvfjv/dbcWVYt/FYGm5O/1VZqbFE8FtKlVSCm9O+PatMExc2yVA6UKTX8A 0hGJzHhqj4MioELJwMLkdn4YUqqYkTpHDxLEJ57o5HTAo0bJXrAHEREJC2oqQqoPsLIm gXaGhZu3KvrwU6gis1jMqfpDHZ4oNHPn3n4lC/X432wzsVIs2cAGje/EowAuzleHFL0u k17KjtdaEhgr5Hr9HLWKnTzfFZaN0eaepailsNvdn9YP2krtQ5Lfi7U2aIRJQFXcFB8Q S3BODmf3m3L0VOCoR4krY/Dv2PC34kzeVNtE612VJFr5DgxUghSA66elT9s72q8iLSif AnXw== X-Forwarded-Encrypted: i=1; AJvYcCUtvNDRlQONufltr2NFr4SPap8ztpFUEoTJ/uTEacd0S+WLE8MT5UpjUxy3V3aC7GT1NLtjvSKEhOo=@vger.kernel.org X-Gm-Message-State: AOJu0YzLjG2NGPpa+o549kY+GravNO12Kwt6lHzt88aC1Xu6a2dYcZdO 4GPKd2l+3nh+AauunzHJFHTvNgxpEBYgmUoVFu5J4LwV4xIdKurIUprSOLxzM+5I5+8= X-Gm-Gg: AY/fxX6/pimPmR40NLBrzbTP3rl/2NKNB4sMH/x0G3RQ7W3FMc7nnrlGsN0bQGPnj36 eehkatDTyzOH/6n3jiyTzMVKLJlgM9ro4g2jRHOtSIu284rrR4xf69udA/j8Pna6A3CeZHZ8SA+ aztXfBSeu03fQQVZ1FVKKTvDRn1c0WvSEKD80mgtto7baorGZqqEGMTqfOAXAkoHETEJQw8eIdW NuYtFJ7mGa+oBo5zRNFv6igSTJd+xj79RJ8V3N7nOrSBPOUKIjsDmeZu2s9bo0ApoonQsIhqUEW 6QoCVL41kqi5yiTu+F3L/gpJRN0eTjQLks1H6wczyL622ExUzkkMY//jfFNE4Abc1FeYZHvbSSK NoN/ljqjUIPlkqzkNGJSNSsjpeAhP7hUoetGVGV0qHkXVNX3sHXFX0+uBeylmh4JmJSYniyk+0+ +al8LgmLV+qVMouZj+Kp6wyWKAvsEHC6OujgkV8b/j1mTlFN7z8vGEkGCR7pR6L4PfSPv/tmXwY IhT X-Google-Smtp-Source: AGHT+IF4mp6GOV5G6x95wPZOhGbqasawR+ZO3M57T/TzQMfUeMdF8kArZ+ePMOUwA5I3JuKmTuDssg== X-Received: by 2002:a05:600c:3e0b:b0:477:9c73:268a with SMTP id 5b1f17b1804b1-47d195b3d55mr287631655e9.6.1767186751342; Wed, 31 Dec 2025 05:12:31 -0800 (PST) Received: from mordecai (dynamic-2a00-1028-83b8-1e7a-3010-3bd6-8521-caf1.ipv6.o2.cz. [2a00:1028:83b8:1e7a:3010:3bd6:8521:caf1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47be3a20af0sm269524875e9.4.2025.12.31.05.12.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Dec 2025 05:12:30 -0800 (PST) Date: Wed, 31 Dec 2025 14:12:24 +0100 From: Petr Tesarik To: "Michael S. Tsirkin" Cc: linux-kernel@vger.kernel.org, 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 , Leon Romanovsky , Jason Gunthorpe , 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: Re: [PATCH RFC 00/13] fix DMA aligment issues around virtio Message-ID: <20251231141224.56d4ce56@mordecai> In-Reply-To: References: X-Mailer: Claws Mail 4.3.1 (GTK 3.24.51; x86_64-suse-linux-gnu) Precedence: bulk X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Tue, 30 Dec 2025 05:15:42 -0500 "Michael S. Tsirkin" wrote: > Cong Wang reported dma debug warnings with virtio-vsock > and proposed a patch, see: > > https://lore.kernel.org/all/20251228015451.1253271-1-xiyou.wangcong@gmail.com/ > > however, the issue is more widespread. > This is an attempt to fix it systematically. > Note: i2c and gio might also be affected, I am still looking > into it. Help from maintainers welcome. > > Early RFC, compile tested only. Sending for early feedback/flames. > Cursor/claude used liberally mostly for refactoring, and english. > > DMA maintainers, could you please confirm the DMA core changes > are ok with you? Before anyone else runs into the same issue as I did: This patch series does not apply cleanly unless you first apply commit b148e85c918a ("virtio_ring: switch to use vring_virtqueue for virtqueue_add variants") from the mst/vhost/vhost branch. But if you go to the trouble of adding the mst/vhost remote, then the above-mentioned branch also contains this patch series, and it's probably the best place to find the patched code... Now, let me set out for review. Petr T > Thanks! > > > Michael S. Tsirkin (13): > dma-mapping: add __dma_from_device_align_begin/end > docs: dma-api: document __dma_align_begin/end > dma-mapping: add DMA_ATTR_CPU_CACHE_CLEAN > docs: dma-api: document DMA_ATTR_CPU_CACHE_CLEAN > dma-debug: track cache clean flag in entries > virtio: add virtqueue_add_inbuf_cache_clean API > vsock/virtio: fix DMA alignment for event_list > vsock/virtio: use virtqueue_add_inbuf_cache_clean for events > virtio_input: fix DMA alignment for evts > virtio_scsi: fix DMA cacheline issues for events > virtio-rng: fix DMA alignment for data buffer > virtio_input: use virtqueue_add_inbuf_cache_clean for events > vsock/virtio: reorder fields to reduce struct padding > > Documentation/core-api/dma-api-howto.rst | 42 +++++++++++++ > Documentation/core-api/dma-attributes.rst | 9 +++ > drivers/char/hw_random/virtio-rng.c | 2 + > drivers/scsi/virtio_scsi.c | 18 ++++-- > drivers/virtio/virtio_input.c | 5 +- > drivers/virtio/virtio_ring.c | 72 +++++++++++++++++------ > include/linux/dma-mapping.h | 17 ++++++ > include/linux/virtio.h | 5 ++ > kernel/dma/debug.c | 26 ++++++-- > net/vmw_vsock/virtio_transport.c | 8 ++- > 10 files changed, 172 insertions(+), 32 deletions(-) >