[PATCH 14/14] swiotlb: remove swiotlb_nr_tbl

2021-02-28 Thread Christoph Hellwig
All callers just use it to check if swiotlb is active at all, for which they can just use is_swiotlb_active. In the longer run drivers need to stop using is_swiotlb_active as well, but let's do the simple step first. Signed-off-by: Christoph Hellwig --- drivers/gpu/drm/i915/gem/i915_gem_interna

[PATCH 13/14] swiotlb: dynamically allocate io_tlb_default_mem

2021-02-28 Thread Christoph Hellwig
Instead of allocating ->list and ->orig_addr separately just do one dynamic allocation for the actual io_tlb_mem structure. This simplifies a lot of the initialization code, and also allows to just check io_tlb_default_mem to see if swiotlb is in use. Signed-off-by: Christoph Hellwig --- driver

[PATCH 12/14] swiotlb: move global variables into a new io_tlb_mem structure

2021-02-28 Thread Christoph Hellwig
From: Claire Chang Added a new struct, io_tlb_mem, as the IO TLB memory pool descriptor and moved relevant global variables into that struct. This will be useful later to allow for restricted DMA pool. Signed-off-by: Claire Chang [hch: rebased] Signed-off-by: Christoph Hellwig --- drivers/xen

[PATCH 11/14] xen-swiotlb: remove the unused size argument from xen_swiotlb_fixup

2021-02-28 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig --- drivers/xen/swiotlb-xen.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c index 00adeb95ebb9df..4ecfce2c6f7263 100644 --- a/drivers/xen/swiotlb-xen.c +++ b/drivers/xen/swiotlb-xen

[PATCH 08/14] xen-swiotlb: remove xen_io_tlb_start and xen_io_tlb_nslabs

2021-02-28 Thread Christoph Hellwig
The xen_io_tlb_start and xen_io_tlb_nslabs variables ar now only used in xen_swiotlb_init, so replace them with local variables. Signed-off-by: Christoph Hellwig --- drivers/xen/swiotlb-xen.c | 57 +-- 1 file changed, 25 insertions(+), 32 deletions(-) diff --

[PATCH 10/14] xen-swiotlb: split xen_swiotlb_init

2021-02-28 Thread Christoph Hellwig
Split xen_swiotlb_init into a normal an an early case. That makes both much simpler and more readable, and also allows marking the early code as __init and x86-only. Signed-off-by: Christoph Hellwig --- arch/arm/xen/mm.c | 2 +- arch/x86/xen/pci-swiotlb-xen.c | 4 +- drivers/xe

[PATCH 09/14] swiotlb: lift the double initialization protection from xen-swiotlb

2021-02-28 Thread Christoph Hellwig
Lift the double initialization protection from xen-swiotlb to the core code to avoid exposing too many swiotlb internals. Also upgrade the check to a warning as it should not happen. Signed-off-by: Christoph Hellwig --- drivers/xen/swiotlb-xen.c | 7 --- kernel/dma/swiotlb.c | 8 ++

[PATCH 07/14] xen-swiotlb: remove xen_set_nslabs

2021-02-28 Thread Christoph Hellwig
The xen_set_nslabs function is a little weird, as it has just one caller, that caller passes a global variable as the argument, which is then overriden in the function and a derivative of it returned. Just add a cpp symbol for the default size using a readable constant and open code the remaining

[PATCH 06/14] xen-swiotlb: use io_tlb_end in xen_swiotlb_dma_supported

2021-02-28 Thread Christoph Hellwig
Use the existing variable that holds the physical address for xen_io_tlb_end to simplify xen_swiotlb_dma_supported a bit, and remove the otherwise unused xen_io_tlb_end variable and the xen_virt_to_bus helper. Signed-off-by: Christoph Hellwig Reviewed-by: Konrad Rzeszutek Wilk --- drivers/xen/s

[PATCH 05/14] xen-swiotlb: use is_swiotlb_buffer in is_xen_swiotlb_buffer

2021-02-28 Thread Christoph Hellwig
Use the is_swiotlb_buffer to check if a physical address is a swiotlb buffer. This works because xen-swiotlb does use the same buffer as the main swiotlb code, and xen_io_tlb_{start,end} are just the addresses for it that went through phys_to_virt. Signed-off-by: Christoph Hellwig Reviewed-by: K

[PATCH 04/14] swiotlb: split swiotlb_tbl_sync_single

2021-02-28 Thread Christoph Hellwig
Split swiotlb_tbl_sync_single into two separate funtions for the to device and to cpu synchronization. Signed-off-by: Christoph Hellwig --- drivers/iommu/dma-iommu.c | 12 ++-- drivers/xen/swiotlb-xen.c | 4 ++-- include/linux/swiotlb.h | 17 - kernel/dma/direct.c

[PATCH 03/14] swiotlb: move orig addr and size validation into swiotlb_bounce

2021-02-28 Thread Christoph Hellwig
Move the code to find and validate the original buffer address and size from the callers into swiotlb_bounce. This means a tiny bit of extra work in the swiotlb_map path, but avoids code duplication and a leads to a better code structure. Signed-off-by: Christoph Hellwig --- kernel/dma/swiotlb.

[PATCH 02/14] swiotlb: remove the alloc_size parameter to swiotlb_tbl_unmap_single

2021-02-28 Thread Christoph Hellwig
Now that swiotlb remembers the allocation size there is no need to pass it back to swiotlb_tbl_unmap_single. Signed-off-by: Christoph Hellwig --- drivers/iommu/dma-iommu.c | 11 +++--- drivers/xen/swiotlb-xen.c | 4 ++-- include/linux/swiotlb.h | 1 - kernel/dma/direct.h | 2 +- k

swiotlb cleanups v2

2021-02-28 Thread Christoph Hellwig
Hi Konrad, this series contains a bunch of swiotlb cleanups, mostly to reduce the amount of internals exposed to code outside of swiotlb.c, which should helper to prepare for supporting multiple different bounce buffer pools. Changes since v1: - rebased to v5.12-rc1 - a few more cleanups - mer

[PATCH 01/14] powerpc/svm: stop using io_tlb_start

2021-02-28 Thread Christoph Hellwig
Use the local variable that is passed to swiotlb_init_with_tbl for freeing the memory in the failure case to isolate the code a little better from swiotlb internals. Signed-off-by: Christoph Hellwig --- arch/powerpc/platforms/pseries/svm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions

Re: [PATCH 6/7] dma-iommu: implement ->alloc_noncontiguous

2021-02-28 Thread Christoph Hellwig
On Mon, Mar 01, 2021 at 04:17:42PM +0900, Sergey Senozhatsky wrote: > > > Do you think we could add the attrs parameter to the > > > dma_alloc_noncontiguous() API? > > > > Yes, we could probably do that. > > I can cook a patch, unless somebody is already looking into it. I plan to resend the who

Re: [PATCH 6/7] dma-iommu: implement ->alloc_noncontiguous

2021-02-28 Thread Sergey Senozhatsky
On (21/02/16 09:49), Christoph Hellwig wrote: > > When working on the videobuf2 integration with Sergey I noticed that > > we always pass 0 as DMA attrs here, which removes the ability for > > drivers to use DMA_ATTR_ALLOC_SINGLE_PAGES. > > > > It's quite important from a system stability point of

Re: [PATCH] iommu/vt-d: Fix status code for Allocate/Free PASID command

2021-02-28 Thread Lu Baolu
On 2/27/21 3:39 PM, Zenghui Yu wrote: As per Intel vt-d spec, Rev 3.0 (section 10.4.45 "Virtual Command Response Register"), the status code of "No PASID available" error in response to the Allocate PASID command is 2, not 1. The same for "Invalid PASID" error in response to the Free PASID comman