From: Dongli Zhang <dongli.zhang@oracle.com>
To: iommu@lists.linux-foundation.org, xen-devel@lists.xenproject.org,
x86@kernel.org, linuxppc-dev@lists.ozlabs.org,
virtualization@lists.linux-foundation.org
Cc: jgross@suse.com, sstabellini@kernel.org, mst@redhat.com,
konrad.wilk@oracle.com, mpe@ellerman.id.au,
dave.hansen@linux.intel.com, joe.jin@oracle.com,
linux-kernel@vger.kernel.org, hch@infradead.org,
mingo@redhat.com, bp@alien8.de, tglx@linutronix.de,
m.szyprowski@samsung.com
Subject: [PATCH RFC v1 0/7] swiotlb: extra 64-bit buffer for dev->dma_io_tlb_mem
Date: Wed, 8 Jun 2022 17:55:46 -0700 [thread overview]
Message-ID: <20220609005553.30954-1-dongli.zhang@oracle.com> (raw)
Hello,
I used to send out a patchset on 64-bit buffer and people thought it was
the same as Restricted DMA. However, the 64-bit buffer is still not supported.
https://lore.kernel.org/all/20210203233709.19819-1-dongli.zhang@oracle.com/
This RFC is to introduce the extra swiotlb buffer with SWIOTLB_ANY flag,
to support 64-bit swiotlb.
The core ideas are:
1. Create an extra io_tlb_mem with SWIOTLB_ANY flags.
2. The dev->dma_io_tlb_mem is set to either default or the extra io_tlb_mem,
depending on dma mask.
Would you please help suggest for below questions in the RFC?
- Is it fine to create the extra io_tlb_mem?
- Which one is better: to create a separate variable for the extra
io_tlb_mem, or make it an array of two io_tlb_mem?
- Should I set dev->dma_io_tlb_mem in each driver (e.g., virtio driver as
in this patchset)based on the value of
min_not_zero(*dev->dma_mask, dev->bus_dma_limit), or at higher level
(e.g., post pci driver)?
This patchset is to demonstrate that the idea works. Since this is just a
RFC, I have only tested virtio-blk on qemu-7.0 by enforcing swiotlb. It is
not tested on AMD SEV environment.
qemu-system-x86_64 -cpu host -name debug-threads=on \
-smp 8 -m 16G -machine q35,accel=kvm -vnc :5 -hda boot.img \
-kernel mainline-linux/arch/x86_64/boot/bzImage \
-append "root=/dev/sda1 init=/sbin/init text console=ttyS0 loglevel=7 swiotlb=327680,3145728,force" \
-device virtio-blk-pci,id=vblk0,num-queues=8,drive=drive0,disable-legacy=on,iommu_platform=true \
-drive file=test.raw,if=none,id=drive0,cache=none \
-net nic -net user,hostfwd=tcp::5025-:22 -serial stdio
The kernel command line "swiotlb=327680,3145728,force" is to allocate 6GB for
the extra swiotlb.
[ 2.826676] PCI-DMA: Using software bounce buffering for IO (SWIOTLB)
[ 2.826693] software IO TLB: default mapped [mem 0x0000000037000000-0x000000005f000000] (640MB)
[ 2.826697] software IO TLB: high mapped [mem 0x00000002edc80000-0x000000046dc80000] (6144MB)
The highmem swiotlb is being used by virtio-blk.
$ cat /sys/kernel/debug/swiotlb/swiotlb-hi/io_tlb_nslabs
3145728
$ cat /sys/kernel/debug/swiotlb/swiotlb-hi/io_tlb_used
8960
Dongli Zhang (7):
swiotlb: introduce the highmem swiotlb buffer
swiotlb: change the signature of remap function
swiotlb-xen: support highmem for xen specific code
swiotlb: to implement io_tlb_high_mem
swiotlb: add interface to set dev->dma_io_tlb_mem
virtio: use io_tlb_high_mem if it is active
swiotlb: fix the slot_addr() overflow
arch/powerpc/kernel/dma-swiotlb.c | 8 +-
arch/x86/include/asm/xen/swiotlb-xen.h | 2 +-
arch/x86/kernel/pci-dma.c | 5 +-
drivers/virtio/virtio.c | 8 ++
drivers/xen/swiotlb-xen.c | 16 +++-
include/linux/swiotlb.h | 14 ++-
kernel/dma/swiotlb.c | 136 +++++++++++++++++++++-------
7 files changed, 145 insertions(+), 44 deletions(-)
Thank you very much for feedback and suggestion!
Dongli Zhang
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
next reply other threads:[~2022-06-09 1:00 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-09 0:55 Dongli Zhang [this message]
2022-06-09 0:55 ` [PATCH RFC v1 1/7] swiotlb: introduce the highmem swiotlb buffer Dongli Zhang
2022-06-09 5:04 ` Christoph Hellwig
2022-06-09 0:55 ` [PATCH RFC v1 2/7] swiotlb: change the signature of remap function Dongli Zhang
2022-06-09 0:55 ` [PATCH RFC v1 3/7] swiotlb-xen: support highmem for xen specific code Dongli Zhang
2022-06-09 5:08 ` Christoph Hellwig
2022-06-09 0:55 ` [PATCH RFC v1 4/7] swiotlb: to implement io_tlb_high_mem Dongli Zhang
2022-06-09 5:05 ` Christoph Hellwig
2022-06-10 21:56 ` Dongli Zhang
2022-06-13 6:04 ` Christoph Hellwig
2022-06-09 0:55 ` [PATCH RFC v1 5/7] swiotlb: add interface to set dev->dma_io_tlb_mem Dongli Zhang
2022-06-09 5:06 ` Christoph Hellwig
2022-06-09 0:55 ` [PATCH RFC v1 6/7] virtio: use io_tlb_high_mem if it is active Dongli Zhang
2022-06-09 5:07 ` Christoph Hellwig
2022-06-09 0:55 ` [PATCH RFC v1 7/7] swiotlb: fix the slot_addr() overflow Dongli Zhang
2022-06-09 5:07 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220609005553.30954-1-dongli.zhang@oracle.com \
--to=dongli.zhang@oracle.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hch@infradead.org \
--cc=iommu@lists.linux-foundation.org \
--cc=jgross@suse.com \
--cc=joe.jin@oracle.com \
--cc=konrad.wilk@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=m.szyprowski@samsung.com \
--cc=mingo@redhat.com \
--cc=mpe@ellerman.id.au \
--cc=mst@redhat.com \
--cc=sstabellini@kernel.org \
--cc=tglx@linutronix.de \
--cc=virtualization@lists.linux-foundation.org \
--cc=x86@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).