Re: DPAA2 triggers, [PATCH] dma debug: report -EEXIST errors in add_dma_entry

2021-10-11 Thread Christoph Hellwig
On Thu, Oct 07, 2021 at 12:59:32PM +0200, Karsten Graul wrote: > In our case its really that a buffer is mapped twice for 2 different devices > which we use in SMC to provide failover capabilities. We see that -EEXIST is > returned when a buffer is mapped for the second device. Since there is a

Re: [PATCH] dma-debug: fix sg checks in debug_dma_map_sg()

2021-10-11 Thread Christoph Hellwig
Thanks, applied. ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH] dma-mapping: fix the kerneldoc for dma_map_sgtable()

2021-10-11 Thread Christoph Hellwig
Thanks, applied. ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: DPAA2 triggers, [PATCH] dma debug: report -EEXIST errors in add_dma_entry

2021-09-30 Thread Christoph Hellwig
On Tue, Sep 14, 2021 at 03:45:06PM +, Ioana Ciornei wrote: > [ 245.927020] fsl_dpaa2_eth dpni.3: scather-gather idx 0 P=20a732 > N=20a7320 D=20a732 L=30 DMA_BIDIRECTIONAL dma map error check not > applicable· > [ 245.927048] fsl_dpaa2_eth dpni.3: scather-gather idx 1 P=20a7320030

Re: [PATCH V5 12/12] net: netvsc: Add Isolation VM support for netvsc driver

2021-09-29 Thread Christoph Hellwig
On Tue, Sep 28, 2021 at 05:23:31PM +0800, Tianyu Lan wrote: >> >> - the bare memremap usage in swiotlb looks strange and I'd >> definitively expect a well documented wrapper. > > OK. Should the wrapper in the DMA code? How about dma_map_decrypted() > introduced in the V4? A mentioned then

Re: [PATCH 1/2] dma-mapping: remove bogus test for pfn_valid from dma_map_resource

2021-09-29 Thread Christoph Hellwig
e'll lose a bit of a sanity check with this, but given the problems it caused: Reviewed-by: Christoph Hellwig ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH kernel] powerpc/iommu: Report the correct most efficient DMA mask for PCI devices

2021-09-29 Thread Christoph Hellwig
65c24b596 ("powerpc: use the generic dma_ops_bypass mode") > Signed-off-by: Alexey Kardashevskiy Looks good: Reviewed-by: Christoph Hellwig ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH V5 12/12] net: netvsc: Add Isolation VM support for netvsc driver

2021-09-27 Thread Christoph Hellwig
On Mon, Sep 27, 2021 at 10:26:43PM +0800, Tianyu Lan wrote: > Hi Christoph: > Gentile ping. The swiotlb and shared memory mapping changes in this > patchset needs your reivew. Could you have a look? I'm a little too busy for a review of such a huge patchset right now. That being said here are

Re: [PATCH v2 9/9] iommu/vt-d: Use pci core's DVSEC functionality

2021-09-24 Thread Christoph Hellwig
On Thu, Sep 23, 2021 at 10:26:47AM -0700, Ben Widawsky wrote: > */ > static int siov_find_pci_dvsec(struct pci_dev *pdev) > { > + return pci_find_dvsec_capability(pdev, PCI_VENDOR_ID_INTEL, 5); > } I hink the siov_find_pci_dvsec helper is pretty pointless now and can be folded into its

Re: [RFC 04/20] iommu: Add iommu_device_get_info interface

2021-09-21 Thread Christoph Hellwig
On Wed, Sep 22, 2021 at 10:31:47AM +0800, Lu Baolu wrote: > Hi Jason, > > On 9/22/21 12:19 AM, Jason Gunthorpe wrote: >> On Sun, Sep 19, 2021 at 02:38:32PM +0800, Liu Yi L wrote: >>> From: Lu Baolu >>> >>> This provides an interface for upper layers to get the per-device iommu >>> attributes. >>>

[GIT PULL] dma-mapping fixes for Linux 5.15 (2nd attempt)

2021-09-17 Thread Christoph Hellwig
a new dma-debug message (Hamza Mahfooz) - fix the kerneldoc for dma_map_sg_attrs (me) Andreas Larsson (1): sparc32: page align size in arch_dma_alloc Christoph Hellwig (1): dma-mapping: fix the kerneldoc

[GIT PULL] dma-mapping fixes for Linux 5.15

2021-09-17 Thread Christoph Hellwig
The following changes since commit 67f3b2f822b7e71cfc9b42dbd9f3144fa2933e0b: blk-mq: avoid to iterate over stale request (2021-09-12 19:32:43 -0600) are available in the Git repository at: git://git.infradead.org/nvme.git tags/nvme-5.15-2021-09-15 for you to fetch changes up to

Re: [PATCH v3 4/8] powerpc/pseries/svm: Add a powerpc version of cc_platform_has()

2021-09-16 Thread Christoph Hellwig
On Wed, Sep 15, 2021 at 07:18:34PM +0200, Christophe Leroy wrote: > Could you please provide more explicit explanation why inlining such an > helper is considered as bad practice and messy ? Because now we get architectures to all subly differ. Look at the mess for ioremap and the ioremap*

Re: [PATCH] swiotlb: set IO TLB segment size via cmdline

2021-09-15 Thread Christoph Hellwig
On Wed, Sep 15, 2021 at 03:49:52PM +0200, Jan Beulich wrote: > But the question remains: Why does the framebuffer need to be mapped > in a single giant chunk? More importantly: if you use dynamic dma mappings for your framebuffer you're doing something wrong.

Re: [PATCH] swiotlb: set IO TLB segment size via cmdline

2021-09-14 Thread Christoph Hellwig
On Tue, Sep 14, 2021 at 05:29:07PM +0200, Jan Beulich wrote: > I'm not convinced the swiotlb use describe there falls under "intended > use" - mapping a 1280x720 framebuffer in a single chunk? (As an aside, > the bottom of this page is also confusing, as following "Then we can > confirm the

Re: [PATCH v2] dma-debug: prevent an error message from causing runtime problems

2021-09-13 Thread Christoph Hellwig
Thanks a lot. I've applied this with a little change to avoid breaking up the printed string into two lines. ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: DPAA2 triggers, [PATCH] dma debug: report -EEXIST errors in add_dma_entry

2021-09-10 Thread Christoph Hellwig
On Wed, Sep 08, 2021 at 10:33:26PM -0500, Jeremy Linton wrote: > PS, it might not hurt to rate limit/_once this somehow to avoid a runtime > problem if it starts to trigger. Yes, that might be a good idea. Care to prepare a patch? ___ iommu mailing

Re: [PATCH V4 00/13] x86/Hyper-V: Add Hyper-V Isolation VM support

2021-09-02 Thread Christoph Hellwig
On Tue, Aug 31, 2021 at 05:16:19PM +, Michael Kelley wrote: > As a quick overview, I think there are four places where the > shared_gpa_boundary must be applied to adjust the guest physical > address that is used. Each requires mapping a corresponding > virtual address range. Here are the

Re: [PATCH V4 00/13] x86/Hyper-V: Add Hyper-V Isolation VM support

2021-09-02 Thread Christoph Hellwig
On Tue, Aug 31, 2021 at 11:20:06PM +0800, Tianyu Lan wrote: >> If so I suspect the best way to allocate them is by not using vmalloc >> but just discontiguous pages, and then use kmap_local_pfn where the >> PFN includes the share_gpa offset when actually copying from/to the >> skbs. >> > When

[GIT PULL] dma-mapping updates for Linux 5.15

2021-09-01 Thread Christoph Hellwig
_sg return value into an unsigned int (me) - provide a common global coherent pool —Ėmplementation (me) Anthony Iliopoulos (1): dma-debug: fix debugfs initialization order Christoph Hellwig (8): dma-mapping: return an unsig

Re: [PATCH V4 00/13] x86/Hyper-V: Add Hyper-V Isolation VM support

2021-08-30 Thread Christoph Hellwig
Sorry for the delayed answer, but I look at the vmap_pfn usage in the previous version and tried to come up with a better version. This mostly untested branch: http://git.infradead.org/users/hch/misc.git/shortlog/refs/heads/hyperv-vmap get us there for swiotlb and the channel infrastructure

Re: [PATCH V3 05/13] HV: Add Write/Read MSR registers via ghcb page

2021-08-24 Thread Christoph Hellwig
This patch fails to compile when CONFIG_AMD_MEM_ENCRYPT is not enabled, in which case there is sev_es_ghcb_hv_call_simple is not defined. ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH v2 03/12] x86/sev: Add an x86 version of prot_guest_has()

2021-08-24 Thread Christoph Hellwig
On Thu, Aug 19, 2021 at 01:33:09PM -0500, Tom Lendacky wrote: > I did it as inline originally because the presence of the function will be > decided based on the ARCH_HAS_PROTECTED_GUEST config. For now, that is > only selected by the AMD memory encryption support, so if I went out of > line I

Re: [PATCH V3 10/13] x86/Swiotlb: Add Swiotlb bounce buffer remap function for HV IVM

2021-08-19 Thread Christoph Hellwig
On Thu, Aug 19, 2021 at 05:59:02PM +0800, Tianyu Lan wrote: > > > On 8/19/2021 4:49 PM, Christoph Hellwig wrote: >> On Mon, Aug 16, 2021 at 10:50:26PM +0800, Tianyu Lan wrote: >>> Hi Christoph: >>>Sorry to bother you.Please double check with these two p

Re: [PATCH v2 04/12] powerpc/pseries/svm: Add a powerpc version of prot_guest_has()

2021-08-19 Thread Christoph Hellwig
On Fri, Aug 13, 2021 at 11:59:23AM -0500, Tom Lendacky wrote: > +static inline bool prot_guest_has(unsigned int attr) No reall need to have this inline. In fact I'd suggest we havea the prototype in a common header so that everyone must implement it out of line.

Re: [PATCH v2 03/12] x86/sev: Add an x86 version of prot_guest_has()

2021-08-19 Thread Christoph Hellwig
On Fri, Aug 13, 2021 at 11:59:22AM -0500, Tom Lendacky wrote: > While the name suggests this is intended mainly for guests, it will > also be used for host memory encryption checks in place of sme_active(). Which suggest that the name is not good to start with. Maybe protected hardware, system

Re: [PATCH v2 02/12] mm: Introduce a function to check for virtualization protection features

2021-08-19 Thread Christoph Hellwig
On Fri, Aug 13, 2021 at 11:59:21AM -0500, Tom Lendacky wrote: > +#define PATTR_MEM_ENCRYPT0 /* Encrypted memory */ > +#define PATTR_HOST_MEM_ENCRYPT 1 /* Host encrypted > memory */ > +#define PATTR_GUEST_MEM_ENCRYPT 2 /* Guest encrypted >

Re: [PATCH V3 10/13] x86/Swiotlb: Add Swiotlb bounce buffer remap function for HV IVM

2021-08-19 Thread Christoph Hellwig
On Mon, Aug 16, 2021 at 10:50:26PM +0800, Tianyu Lan wrote: > Hi Christoph: > Sorry to bother you.Please double check with these two patches > " [PATCH V3 10/13] x86/Swiotlb: Add Swiotlb bounce buffer remap function > for HV IVM" and "[PATCH V3 09/13] DMA: Add dma_map_decrypted/dma_ >

Re: [PATCH 7/7] hexagon: use the generic global coherent pool

2021-08-18 Thread 'Christoph Hellwig'
Thanks, I've pulled the whole series into the dma-mapping for-next tree. ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH v5 5/7] dma-iommu: Check CONFIG_SWIOTLB more broadly

2021-08-16 Thread Christoph Hellwig
> - if (IS_ENABLED(CONFIG_SWIOTLB) && dev_is_untrusted(dev) && > + if (IS_ENABLED(CONFIG_SWIOTLB) && dev_use_swiotlb(dev) && > iova_offset(iovad, phys | size)) { This can drop the explicit CONFIG_SWIOTLB check now (and make the remaining conditional fit onto a single line).

Re: [PATCH v5 4/7] dma-iommu: fold _swiotlb helpers into callers

2021-08-16 Thread Christoph Hellwig
> + if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC) && > + (dir == DMA_TO_DEVICE || > + dir == DMA_BIDIRECTIONAL)) { Nit: the two dire checks easily fit onto a single line and are easier to follow that way. Otherwise looks good: Reviewed-

Re: [PATCH v5 3/7] dma-iommu: skip extra sync during unmap w/swiotlb

2021-08-16 Thread Christoph Hellwig
Looks good, Reviewed-by: Christoph Hellwig ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH v5 2/7] dma-iommu: fix arch_sync_dma for map

2021-08-16 Thread Christoph Hellwig
Looks good, Reviewed-by: Christoph Hellwig ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: add support for the global coherent pool to the dma core

2021-08-14 Thread Christoph Hellwig
Any more comments? Otherwise I'm going to pull this into the dma-mapping tree next week. ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH v4 5/6] swiotlb: support aligned swiotlb buffers

2021-08-13 Thread Christoph Hellwig
Looks good, Reviewed-by: Christoph Hellwig ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH v4 4/6] dma-iommu: Check CONFIG_SWIOTLB more broadly

2021-08-13 Thread Christoph Hellwig
Looks good, Reviewed-by: Christoph Hellwig ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH v4 3/6] dma-iommu: skip extra sync during unmap w/swiotlb

2021-08-13 Thread Christoph Hellwig
Same comment as for the previous one - please split the actual bug fix from the code movement. ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH v4 2/6] dma-iommu: fix arch_sync_dma for map

2021-08-13 Thread Christoph Hellwig
I have a really hard time reading following the patch. Can you split folding__iommu_dma_map_swiotlb into iommu_dma_map_page into a second cleanup patch? ___ iommu mailing list iommu@lists.linux-foundation.org

Re: [PATCH v4 1/6] dma-iommu: fix sync_sg with swiotlb

2021-08-13 Thread Christoph Hellwig
Looks good, Reviewed-by: Christoph Hellwig ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: add support for the global coherent pool to the dma core

2021-08-12 Thread 'Christoph Hellwig'
On Wed, Jul 28, 2021 at 10:20:34AM -0500, Brian Cain wrote: > > this series adds support for using the global coherent (aka uncached) > > pool to the generic dma-direct code and then switches arm-nommu and > > hexagon over to it, together with a bunch of cleanups. > > Christoph, > > Thanks for

[PATCH] dma-mapping: return an unsigned int from dma_map_sg{,_attrs}

2021-08-12 Thread Christoph Hellwig
These can only return 0 for failure or the number of entries, so turn the return value into an unsigned int. Signed-off-by: Christoph Hellwig --- include/linux/dma-mapping.h | 9 + kernel/dma/mapping.c| 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include

Re: [PATCH V3 10/13] x86/Swiotlb: Add Swiotlb bounce buffer remap function for HV IVM

2021-08-12 Thread Christoph Hellwig
This is still broken. You need to make sure the actual DMA allocations do have struct page backing. ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH V3 09/13] DMA: Add dma_map_decrypted/dma_unmap_encrypted() function

2021-08-12 Thread Christoph Hellwig
On Mon, Aug 09, 2021 at 01:56:13PM -0400, Tianyu Lan wrote: > From: Tianyu Lan > > In Hyper-V Isolation VM with AMD SEV, swiotlb boucne buffer > needs to be mapped into address space above vTOM and so > introduce dma_map_decrypted/dma_unmap_encrypted() to map/unmap > bounce buffer memory. The

Re: [PATCH v3 3/5] dma-iommu: add SKIP_CPU_SYNC after syncing

2021-08-11 Thread Christoph Hellwig
> diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c > index 4f0cc4a0a61f..be0214b1455c 100644 > --- a/drivers/iommu/dma-iommu.c > +++ b/drivers/iommu/dma-iommu.c > @@ -859,8 +859,11 @@ static dma_addr_t iommu_dma_map_page(struct device *dev, > struct page *page, > static void

Re: [PATCH v3 2/5] dma-iommu: fix arch_sync_dma for map

2021-08-11 Thread Christoph Hellwig
Looks good, Reviewed-by: Christoph Hellwig ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH v3 1/5] dma-iommu: fix sync_sg with swiotlb

2021-08-10 Thread Christoph Hellwig
On Wed, Aug 11, 2021 at 11:42:43AM +0900, David Stevens wrote: > From: David Stevens > > The is_swiotlb_buffer function takes the physical address of the swiotlb > buffer, not the physical address of the original buffer. The sglist > contains the physical addresses of the original buffer, so for

Re: [PATCH RFC 0/2] dma-pool: allow user to disable atomic pool

2021-08-10 Thread Christoph Hellwig
On Tue, Aug 10, 2021 at 03:52:25PM -0500, Tom Lendacky via iommu wrote: > I think the atomic pool is used by the NVMe driver. My understanding is > that driver will do a dma_alloc_coherent() from interrupt context, so it > needs to use GFP_ATOMIC. The pool was created because dma_alloc_coherent()

Re: [PATCH v3 00/21] .map_sg() error cleanup

2021-08-09 Thread Christoph Hellwig
Thanks, I've applied this to the dma-mapping tree with a few minor cosmetic tweaks. ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH resend] dma-debug: Use memory_intersects() directly

2021-08-09 Thread Christoph Hellwig
Thanks, applied. ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH] dma-debug: fix debugfs initialization order

2021-08-09 Thread Christoph Hellwig
Thanks, applied. ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH 02/11] x86/sev: Add an x86 version of prot_guest_has()

2021-07-28 Thread Christoph Hellwig
On Tue, Jul 27, 2021 at 05:26:05PM -0500, Tom Lendacky via iommu wrote: > Introduce an x86 version of the prot_guest_has() function. This will be > used in the more generic x86 code to replace vendor specific calls like > sev_active(), etc. > > While the name suggests this is intended mainly for

Re: [PATCH 01/11] mm: Introduce a function to check for virtualization protection features

2021-07-28 Thread Christoph Hellwig
On Tue, Jul 27, 2021 at 05:26:04PM -0500, Tom Lendacky via iommu wrote: > In prep for other protected virtualization technologies, introduce a > generic helper function, prot_guest_has(), that can be used to check > for specific protection attributes, like memory encryption. This is > intended to

Re: [RFC 3/5] dma-mapping: Enable global non-coherent pool support for RISC-V

2021-07-27 Thread Christoph Hellwig
On Mon, Jul 26, 2021 at 03:47:54PM -0700, Atish Patra wrote: > arch_dma_set_uncached works as well in this case. However, mips, > niops2 & xtensa uses a > fixed (via config) value for the offset. Similar approach can't be > used here because the platform specific > offset value has to be

Re: [RFC 4/5] dma-direct: Allocate dma pages directly if global pool allocation fails

2021-07-26 Thread Christoph Hellwig
On Fri, Jul 23, 2021 at 02:40:30PM -0700, Atish Patra wrote: > DMA_GLOBAL_POOL config may be enabled for platforms where global pool is > not supported because a generic defconfig is expected to boot on different > platforms. Specifically, some RISC-V platforms may use global pool for >

Re: [RFC 3/5] dma-mapping: Enable global non-coherent pool support for RISC-V

2021-07-26 Thread Christoph Hellwig
On Fri, Jul 23, 2021 at 02:40:29PM -0700, Atish Patra wrote: > Currently, linux,dma-default is used to reserve a global non-coherent pool > to allocate memory for dma operations. This can be useful for RISC-V as > well as the ISA specification doesn't specify a method to modify PMA > attributes or

Re: [RFC 1/5] RISC-V: Implement arch_sync_dma* functions

2021-07-26 Thread Christoph Hellwig
> +#ifdef CONFIG_RISCV_DMA_NONCOHERENT > +struct riscv_dma_cache_sync { > + void (*cache_invalidate)(phys_addr_t paddr, size_t size); > + void (*cache_clean)(phys_addr_t paddr, size_t size); > + void (*cache_flush)(phys_addr_t paddr, size_t size); > +}; > + > +void

Re: [GIT PULL] dma-mapping fix for Linux 5.14

2021-07-25 Thread Christoph Hellwig
On Sun, Jul 25, 2021 at 09:50:29AM -0700, Linus Torvalds wrote: > On Sat, Jul 24, 2021 at 11:03 PM Christoph Hellwig wrote: > > > > dma-mapping fix for Lonux 5.14 > > We're calling it "Lonux" now? Only on weekends :) > > - handle vmalloc addr

Re: [PATCH v2 01/21] dma-mapping: Allow map_sg() ops to return negative error codes

2021-07-25 Thread Christoph Hellwig
> +int dma_map_sgtable(struct device *dev, struct sg_table *sgt, > + enum dma_data_direction dir, unsigned long attrs) > +{ > + int nents; > + > + nents = __dma_map_sg_attrs(dev, sgt->sgl, sgt->orig_nents, dir, attrs); > + if (nents == 0) > + return -EIO; >

[GIT PULL] dma-mapping fix for Linux 5.14

2021-07-25 Thread Christoph Hellwig
The following changes since commit d936eb23874433caa3e3d841cfa16f5434b85dcf: Revert "Makefile: Enable -Wimplicit-fallthrough for Clang" (2021-07-15 18:05:31 -0700) are available in the Git repository at: git://git.infradead.org/users/hch/dma-mapping.git tags/dma-mapping-5.14-1 for you to

Re: [PATCH 3/6] vfio: remove the unused mdev iommu hook

2021-07-22 Thread Christoph Hellwig
On Fri, Jul 23, 2021 at 05:36:17AM +, Tian, Kevin wrote: > > > And a new set of IOMMU-API: > > > > > > - iommu_{un}bind_pgtable(domain, dev, addr); > > > - iommu_{un}bind_pgtable_pasid(domain, dev, addr, pasid); > > > - iommu_cache_invalidate(domain, dev, invalid_info); > > > >

Re: [PATCH] iommu/dma: Fix leak in non-contiguous API

2021-07-22 Thread Christoph Hellwig
Looks good, Reviewed-by: Christoph Hellwig > As a side note, it appears the struct dma_sgt_handle type is exposed > to users of the DMA-API by linux/dma-map-ops.h, but is has no users > or functions returning the type explicitly. > > This may indicate it's a good idea to

Re: [PATCH 3/6] vfio: remove the unused mdev iommu hook

2021-07-22 Thread Christoph Hellwig
On Wed, Jun 30, 2021 at 09:08:19AM +, Tian, Kevin wrote: > The iommu layer should maintain above attaching status per device and per > iommu domain. There is no mdev/subdev concept in the iommu layer. It's > just about RID or PASID. Yes, I think that makes sense. > And a new set of

Re: [Resend RFC PATCH V4 09/13] x86/Swiotlb/HV: Add Swiotlb bounce buffer remap function for HV IVM

2021-07-21 Thread Christoph Hellwig
On Wed, Jul 21, 2021 at 06:28:48PM +0800, Tianyu Lan wrote: > dma_mmap_attrs() and dma_get_sgtable_attrs() get input virtual address > belonging to backing memory with struct page and returns bounce buffer > dma physical address which is below shared_gpa_boundary(vTOM) and passed > to Hyper-V via

Re: [Resend RFC PATCH V4 09/13] x86/Swiotlb/HV: Add Swiotlb bounce buffer remap function for HV IVM

2021-07-20 Thread Christoph Hellwig
Please split the swiotlb changes into a separate patch from the consumer. > } > + > +/* > + * hv_map_memory - map memory to extra space in the AMD SEV-SNP Isolation VM. > + */ > +unsigned long hv_map_memory(unsigned long addr, unsigned long size) > +{ > + unsigned long *pfns = kcalloc(size

Re: [PATCH 0/5] Fix restricted DMA vs swiotlb_exit()

2021-07-20 Thread Christoph Hellwig
Looks fine except for the patch split nitpick mentioned: Reviewed-by: Christoph Hellwig ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH 2/5] swiotlb: Point io_default_tlb_mem at static allocation

2021-07-20 Thread Christoph Hellwig
I'd prefer if the next patch is merged into this one, to avoid the confusing state inbetween entirely. ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH v2] dma-mapping: use vmalloc_to_page for vmalloc addresses

2021-07-19 Thread Christoph Hellwig
On Sat, Jul 17, 2021 at 11:39:21AM +0300, Roman Skakun wrote: > > We can merge this patch and create a new one for > > xen_swiotlb_free_coherent() later. > > Yeah, no worries, I didn't know that exposing dma_common_vaddr_to_page > > was problematic. > > > > This patch is fine by me. > > Good. I'm

Re: [PATCH v2] dma-mapping: use vmalloc_to_page for vmalloc addresses

2021-07-16 Thread Christoph Hellwig
ers. Properly handle them to unbreak Xen on ARM platforms. Fixes: 1b65c4e5a9af ("swiotlb-xen: use xen_alloc/free_coherent_pages") Signed-off-by: Roman Skakun Reviewed-by: Andrii Anisov [hch: split the patch, renamed the helpers] Signed-off-by: Christoph Hellwig --- kernel/dma/ops_h

Re: [PATCH v1 16/16] dma-mapping: Disallow .map_sg operations from returning zero on error

2021-07-16 Thread Christoph Hellwig
On Thu, Jul 15, 2021 at 10:45:44AM -0600, Logan Gunthorpe wrote: > @@ -194,6 +194,8 @@ static int __dma_map_sg_attrs(struct device *dev, struct > scatterlist *sg, > else > ents = ops->map_sg(dev, sg, nents, dir, attrs); > > + WARN_ON_ONCE(ents == 0); Turns this into a

Re: [PATCH v1 14/16] x86/amd_gart: return error code from gart_map_sg()

2021-07-16 Thread Christoph Hellwig
On Thu, Jul 15, 2021 at 10:45:42AM -0600, Logan Gunthorpe wrote: > @@ -458,7 +460,7 @@ static int gart_map_sg(struct device *dev, struct > scatterlist *sg, int nents, > iommu_full(dev, pages << PAGE_SHIFT, dir); > for_each_sg(sg, s, nents, i) > s->dma_address =

Re: [PATCH v1 04/16] dma-iommu: Return error code from iommu_dma_map_sg()

2021-07-16 Thread Christoph Hellwig
Careful here. What do all these errors from the low-level code mean here? I think we need to clearly standardize on what we actually return from ->map_sg and possibly document what the callers expect and can do, and enforce that only those error are reported.

Re: [PATCH v1 01/16] dma-mapping: Allow map_sg() ops to return negative error codes

2021-07-16 Thread Christoph Hellwig
On Thu, Jul 15, 2021 at 10:45:29AM -0600, Logan Gunthorpe wrote: > + * dma_map_sgtable() will return the error code returned and convert > + * a zero return (for legacy implementations) into -EINVAL. > + * > + * dma_map_sg() will always return zero on any negative or zero > +

Re: [PATCH v4 0/3] Apple M1 DART IOMMU driver

2021-07-16 Thread Christoph Hellwig
On Wed, Jul 14, 2021 at 07:19:50PM +0100, Robin Murphy wrote: > Even at the DMA API level you could hide *some* of it (at the cost of > effectively only having 1/4 of the usable address space), but there are > still cases like where v4l2 has a hard requirement that a page-aligned > scatterlist can

Re: [PATCH v2] iommu: Streamline iommu_iova_to_phys()

2021-07-16 Thread Christoph Hellwig
On Thu, Jul 15, 2021 at 03:16:08PM +0100, Robin Murphy wrote: > On 2021-07-15 15:07, Christoph Hellwig wrote: > > On Thu, Jul 15, 2021 at 02:04:24PM +0100, Robin Murphy wrote: > > > If people are going to insist on calling iommu_iova_to_phys() > > > pointless

Re: [PATCH v2] dma-mapping: use vmalloc_to_page for vmalloc addresses

2021-07-15 Thread Christoph Hellwig
On Thu, Jul 15, 2021 at 12:58:53PM -0400, Boris Ostrovsky wrote: > > On 7/15/21 3:39 AM, Roman Skakun wrote: > >> This looks like it wasn't picked up? Should it go in rc1? > > Hi, Konrad! > > > > This looks like an unambiguous bug, and should be in rc1. > > > Looks like you didn't copy

Re: [PATCH v2] iommu: Streamline iommu_iova_to_phys()

2021-07-15 Thread Christoph Hellwig
On Thu, Jul 15, 2021 at 02:04:24PM +0100, Robin Murphy wrote: > If people are going to insist on calling iommu_iova_to_phys() > pointlessly and expecting it to work, Maybe we need to fix that? ___ iommu mailing list iommu@lists.linux-foundation.org

[PATCH 7/7] hexagon: use the generic global coherent pool

2021-07-12 Thread Christoph Hellwig
Switch hexagon to use the generic code for dma_alloc_coherent from a global pre-filled pool. Signed-off-by: Christoph Hellwig --- arch/hexagon/Kconfig | 1 + arch/hexagon/kernel/dma.c | 57 --- 2 files changed, 12 insertions(+), 46 deletions(-) diff

[PATCH 6/7] dma-mapping: make the global coherent pool conditional

2021-07-12 Thread Christoph Hellwig
Only build the code to support the global coherent pool if support for it is enabled. Signed-off-by: Christoph Hellwig Tested-by: Dillon Min --- include/linux/dma-map-ops.h | 18 +++--- kernel/dma/coherent.c | 47 - 2 files changed, 35

[PATCH 5/7] dma-mapping: add a dma_init_global_coherent helper

2021-07-12 Thread Christoph Hellwig
Add a new helper to initialize the global coherent pool. This both cleans up the existing initialization which indirects through the reserved_mem_ops that are normally only used for struct device, and also allows using the global pool for non-devicetree architectures. Signed-off-by: Christoph

[PATCH 4/7] dma-mapping: simplify dma_init_coherent_memory

2021-07-12 Thread Christoph Hellwig
Return the allocated dma_coherent_mem structure, set the use_dma_pfn_offset and print the failure warning inside of dma_init_coherent_memory instead of leaving that to the callers. Signed-off-by: Christoph Hellwig Tested-by: Dillon Min --- kernel/dma/coherent.c | 78

[PATCH 3/7] dma-mapping: allow using the global coherent pool for !ARM

2021-07-12 Thread Christoph Hellwig
Switch an ifdef so that the global coherent pool is initialized for any architecture that selects the DMA_GLOBAL_POOL symbol insted of hardcoding ARM. Signed-off-by: Christoph Hellwig Tested-by: Dillon Min --- kernel/dma/coherent.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel

[PATCH 2/7] ARM/nommu: use the generic dma-direct code for non-coherent devices

2021-07-12 Thread Christoph Hellwig
Select the right options to just use the generic dma-direct code instead of reimplementing it. Signed-off-by: Christoph Hellwig Tested-by: Dillon Min --- arch/arm/Kconfig| 5 +- arch/arm/mm/dma-mapping-nommu.c | 173 ++-- 2 files changed, 9

[PATCH 1/7] dma-direct: add support for dma_coherent_default_memory

2021-07-12 Thread Christoph Hellwig
the one that platforms that can remap at runtime use for GFP_ATOMIC allocations for now, although there might be opportunities to eventually end up with a common codebase for the two use cases. Signed-off-by: Christoph Hellwig Tested-by: Dillon Min --- kernel/dma/Kconfig | 4 kernel/dma

add support for the global coherent pool to the dma core

2021-07-12 Thread Christoph Hellwig
Hi all, this series adds support for using the global coherent (aka uncached) pool to the generic dma-direct code and then switches arm-nommu and hexagon over to it, together with a bunch of cleanups. Diffstat: arch/arm/Kconfig|5 - arch/arm/mm/dma-mapping-nommu.c | 173

Re: [PATCH v15 06/12] swiotlb: Use is_swiotlb_force_bounce for swiotlb data bouncing

2021-07-06 Thread Christoph Hellwig
On Tue, Jul 06, 2021 at 03:01:04PM +0100, Robin Murphy wrote: > FWIW I was pondering the question of whether to do something along those > lines or just scrap the default assignment entirely, so since I hadn't got > round to saying that I've gone ahead and hacked up the alternative > (similarly

Re: [PATCH v15 06/12] swiotlb: Use is_swiotlb_force_bounce for swiotlb data bouncing

2021-07-05 Thread Christoph Hellwig
On Mon, Jul 05, 2021 at 08:03:52PM +0100, Will Deacon wrote: > So at this point, the AMD IOMMU driver does: > > swiotlb= (iommu_default_passthrough() || sme_me_mask) ? 1 : 0; > > where 'swiotlb' is a global variable indicating whether or not swiotlb > is in use. It's picked up a

[GIT PULL] dma-mapping updates for Linux 5.14

2021-07-02 Thread Christoph Hellwig
The following changes since commit a7f3d3d3600c8ed119eb0d2483de0062ce2e3707: dma-mapping: add unlikely hint to error path in dma_mapping_error (2021-04-02 16:41:08 +0200) are available in the Git repository at: git://git.infradead.org/users/hch/dma-mapping.git tags/dma-mapping-5.14 for

Re: [RFC] /dev/ioasid uAPI proposal

2021-06-30 Thread Christoph Hellwig
On Mon, Jun 07, 2021 at 11:14:24AM -0300, Jason Gunthorpe wrote: > "non-coherent DMA" is some general euphemism that evokes images of > embedded platforms that don't have coherent DMA at all and have low > cost ways to regain coherence. This is not at all what we are talking > about here at all.

Re: [RFC] /dev/ioasid uAPI proposal

2021-06-30 Thread Christoph Hellwig
On Fri, Jun 04, 2021 at 08:58:05AM -0300, Jason Gunthorpe wrote: > On Fri, Jun 04, 2021 at 09:11:03AM +0800, Jason Wang wrote: > > > nor do any virtio drivers implement the required platform specific > > > cache flushing to make no-snoop TLPs work. > > > > I don't get why virtio drivers needs to

Re: [RFC] /dev/ioasid uAPI proposal

2021-06-30 Thread Christoph Hellwig
On Wed, Jun 09, 2021 at 09:47:42AM -0300, Jason Gunthorpe wrote: > I can vaugely understand this rational for vfio, but not at all for > the platform's iommu driver, sorry. Agreed. More importantly the dependency is not for the platform iommu driver but just for the core iommu code, which is

Re: [RFC] /dev/ioasid uAPI proposal

2021-06-30 Thread Christoph Hellwig
On Mon, Jun 07, 2021 at 03:25:32AM +, Tian, Kevin wrote: > > Possibly just a naming thing, but I feel it's better to just talk about > no-snoop or non-coherent in the uAPI. Per Intel SDM wbinvd is a > privileged instruction. A process on the host has no privilege to > execute it. Only when

Re: [RFC] /dev/ioasid uAPI proposal

2021-06-30 Thread Christoph Hellwig
On Tue, Jun 08, 2021 at 09:20:29AM +0800, Jason Wang wrote: > " > > 6.2.17 _CCA (Cache Coherency Attribute) The _CCA object returns whether or > not a bus-master device supports hardware managed cache coherency. Expected > values are 0 to indicate it is not supported, and 1 to indicate that it is

Re: [RFC] /dev/ioasid uAPI proposal

2021-06-30 Thread Christoph Hellwig
On Mon, Jun 07, 2021 at 04:08:02PM -0300, Jason Gunthorpe wrote: > Compatibility is important, but when I look in the kernel code I see > very few places that call wbinvd(). Basically all DRM for something > relavent to qemu. > > That tells me that the vast majority of PCI devices do not generate

Re: [PATCH 9/9] dma-debug: Use memory_intersects() directly

2021-06-28 Thread Christoph Hellwig
You've sent me a patch 9 out of 9 without the previous 8 patches. There is no way I can sensibly review this series. ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH RFC 0/2] dma-pool: allow user to disable atomic pool

2021-06-24 Thread Christoph Hellwig
On Thu, Jun 24, 2021 at 11:47:31AM +0100, Robin Murphy wrote: > Hmm, I think the Kconfig reshuffle has actually left a slight wrinkle here. > For DMA_DIRECT_REMAP=y we can assume an atomic pool is always needed, since > that was the original behaviour anyway. However the implications of >

Re: [PATCH v14 06/12] swiotlb: Use is_swiotlb_force_bounce for swiotlb data bouncing

2021-06-23 Thread Christoph Hellwig
On Wed, Jun 23, 2021 at 02:44:34PM -0400, Qian Cai wrote: > is_swiotlb_force_bounce at /usr/src/linux-next/./include/linux/swiotlb.h:119 > > is_swiotlb_force_bounce() was the new function introduced in this patch here. > > +static inline bool is_swiotlb_force_bounce(struct device *dev) > +{ > +

Re: [PATCH 1/1] dma-mapping: remove trailing spaces and tabs

2021-06-22 Thread Christoph Hellwig
Thanks, applied to the dma-mapping tree. ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH] dma debug: report -EEXIST errors in add_dma_entry

2021-06-22 Thread Christoph Hellwig
Thanks, applied to the dma-mapping tree. ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH v13 01/12] swiotlb: Refactor swiotlb init functions

2021-06-21 Thread Christoph Hellwig
On Mon, Jun 21, 2021 at 10:59:20AM -0700, Stefano Stabellini wrote: > Just as a clarification: I was referring to the zeroing of "mem" in > swiotlb_late_init_with_tbl and swiotlb_init_with_tbl. While it looks > like Tom and Christoph are talking about the zeroing of "tlb". Indeed. > > The

Re: [PATCH v13 01/12] swiotlb: Refactor swiotlb init functions

2021-06-18 Thread Christoph Hellwig
On Fri, Jun 18, 2021 at 09:09:17AM -0500, Tom Lendacky wrote: > > swiotlb_init_with_tbl uses memblock_alloc to allocate the io_tlb_mem > > and memblock_alloc[1] will do memset in memblock_alloc_try_nid[2], so > > swiotlb_init_with_tbl is also good. > > I'm happy to add the memset in

  1   2   3   4   5   6   7   8   9   10   >