[GIT PULL] dma-mapping fix for 5.10

2020-10-31 Thread Christoph Hellwig
The following changes since commit ed8780e3f2ecc82645342d070c6b4e530532e680: Merge tag 'x86-urgent-2020-10-27' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip (2020-10-27 14:39:29 -0700) are available in the Git repository at: git://git.infradead.org/users/hch/dma-mapping.git

Re: [PATCH v1] dma-mapping: normal memory for mmap() on coherent architectures

2020-10-28 Thread Christoph Hellwig
On Wed, Oct 28, 2020 at 07:38:04PM +0200, Oded Gabbay wrote: > > > https://lkml.org/lkml/2020/8/29/252) > > > Since then, we are plagued by the kernel log message that gavin has > > > mentioned, as we are mostly running in our C/I environment with 5.4. > > > I wondered if you know if there was any

Re: [PATCH v1] dma-mapping: normal memory for mmap() on coherent architectures

2020-10-28 Thread Christoph Hellwig
On Wed, Oct 28, 2020 at 01:39:17PM +0200, Oded Gabbay wrote: > On Sat, Aug 3, 2019 at 9:26 AM Christoph Hellwig wrote: > > > > See the discussion at: > > > > https://lists.linuxfoundation.org/pipermail/iommu/2019-August/037716.html > > > > Just cu

Re: [PATCH kernel v2 1/2] dma: Allow mixing bypass and normal IOMMU operation

2020-10-28 Thread Christoph Hellwig
On Wed, Oct 28, 2020 at 05:55:23PM +1100, Alexey Kardashevskiy wrote: > > It is passing an address of the end of the mapped area so passing a page > struct means passing page and offset which is an extra parameter and we do > not want to do anything with the page in those hooks anyway so I'd

Re: [PATCH kernel v3 1/2] dma: Allow mixing bypass and mapped DMA operation

2020-10-28 Thread Christoph Hellwig
On Wed, Oct 28, 2020 at 06:00:29PM +1100, Alexey Kardashevskiy wrote: > At the moment we allow bypassing DMA ops only when we can do this for > the entire RAM. However there are configs with mixed type memory > where we could still allow bypassing IOMMU in most cases; > POWERPC with persistent

Re: [PATCH kernel v2 1/2] dma: Allow mixing bypass and normal IOMMU operation

2020-10-27 Thread Christoph Hellwig
> +static inline bool dma_handle_direct(struct device *dev, dma_addr_t > dma_handle) > +{ > + return dma_handle >= dev->archdata.dma_offset; > +} This won't compile except for powerpc, and directly accesing arch members in common code is a bad idea. Maybe both your helpers need to be

Re: [PATCH] fix swiotlb panic on Xen

2020-10-27 Thread Christoph Hellwig
Looks good for now: Reviewed-by: Christoph Hellwig But we really need to clean up the mess with all these magic variables eventually. ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

[GIT PULL] dma-mapping fixes for 5.10

2020-10-24 Thread Christoph Hellwig
document dma_{alloc,free}_pages API - two fixups for the dma-mapping.h split Christoph Hellwig (3): ARM/sa: add a missing include of dma-map-ops.h dma-mapping: move more functions to dma-map-ops.h dma-mapping: document

Re: [PATCH v4 7/7] mm: Remove examples from enum zone_type comment

2020-10-23 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 2/3] drm/msm: add DRM_MSM_GEM_SYNC_CACHE for non-coherent cache maintenance

2020-10-23 Thread Christoph Hellwig
On Thu, Oct 15, 2020 at 04:43:01PM +0100, Christoph Hellwig wrote: > > Somewhat related, but is there a way to tell the dma-api to fail instead > > of falling back to swiotlb? In many case for gpu drivers it's much better > > if we fall back to dma_alloc_coherent and manage the

[PATCH] dma-mapping: document dma_{alloc,free}_pages

2020-10-23 Thread Christoph Hellwig
Document the new dma_alloc_pages and dma_free_pages APIs, and fix up the documentation for dma_alloc_noncoherent and dma_free_noncoherent. Reported-by: Robin Murphy Signed-off-by: Christoph Hellwig --- Documentation/core-api/dma-api.rst | 49 ++ 1 file changed, 43

[PATCH for-5.10] swiotlb: remove the tbl_dma_addr argument to swiotlb_tbl_map_single

2020-10-23 Thread Christoph Hellwig
for io_tlb_start instead. Fixes: 91ffe4ad534a ("swiotlb-xen: introduce phys_to_dma/dma_to_phys translations") Signed-off-by: Christoph Hellwig Reviewed-by: Stefano Stabellini --- drivers/iommu/intel/iommu.c | 5 ++--- drivers/xen/swiotlb-xen.c | 3 +-- include/linux/swiotlb.

Re: WARNING in dma_map_page_attrs

2020-10-22 Thread Christoph Hellwig
I don't think the merge commit makes sense here. But what we see here is that dma_map_page is called on the rxe device, without that device having a DMA mask. For now this needs a workaround in rxe, but for 5.11 I'll send a patch to remove dma-virt and just handle this case inside of the rdma

[PATCH] dma-mapping: move more functions to dma-map-ops.h

2020-10-20 Thread Christoph Hellwig
Due to a mismerge a bunch of prototypes that should have moved to dma-map-ops.h are still in dma-mapping.h, fix that up. Signed-off-by: Christoph Hellwig --- include/linux/dma-map-ops.h | 23 +++ include/linux/dma-mapping.h | 24 kernel/dma/remap.c

Re: [RFC PATCH 2/2] iommu: Add IOMMU_UNBIND_FAULT_PENDING flag

2020-10-16 Thread Christoph Hellwig
On Thu, Oct 15, 2020 at 11:00:29AM +0200, Jean-Philippe Brucker wrote: > IOMMU drivers only need to flush their PRI queue when faults might be > pending. According to the PCIe spec (quoted below) this only happens > when using the "Stop Marker" method. Otherwise the function waits for > pending

[GIT PULL] dma-mapping updates for 5.10

2020-10-15 Thread Christoph Hellwig
Barry Song (3): dma-contiguous: provide the ability to reserve per-numa CMA arm64: mm: reserve per-numa CMA to localize coherent dma buffers mm: cma: use CMA_MAX_NAME to define the length of cma name array Christoph Hellwig (54): dma-mapping: remove the dma_dummy_ops

Re: [PATCH 2/3] drm/msm: add DRM_MSM_GEM_SYNC_CACHE for non-coherent cache maintenance

2020-10-15 Thread Christoph Hellwig
On Thu, Oct 15, 2020 at 05:33:34PM +0200, Daniel Vetter wrote: > On Thu, Oct 15, 2020 at 07:55:32AM +0100, Christoph Hellwig wrote: > > On Tue, Oct 13, 2020 at 02:42:38PM +0100, Robin Murphy wrote: > > > I still think this situation would be best handled with a variant of &g

Re: [PATCH 2/3] drm/msm: add DRM_MSM_GEM_SYNC_CACHE for non-coherent cache maintenance

2020-10-15 Thread Christoph Hellwig
On Tue, Oct 13, 2020 at 02:42:38PM +0100, Robin Murphy wrote: > I still think this situation would be best handled with a variant of > dma_ops_bypass that also guarantees to bypass SWIOTLB, and can be set > automatically when attaching to an unmanaged IOMMU domain. dma_ops_bypass should mostly do

Re: [PATCH v3 3/8] of/address: Introduce of_dma_get_max_cpu_address()

2020-10-14 Thread Christoph Hellwig
> +phys_addr_t __init of_dma_get_max_cpu_address(struct device_node *np) > +{ > + phys_addr_t max_cpu_addr = PHYS_ADDR_MAX; > + struct of_range_parser parser; > + phys_addr_t subtree_max_addr; > + struct device_node *child; > + phys_addr_t cpu_end = 0; > + struct of_range

Re: [PATCH v3 8/8] mm: Update DMA zones description

2020-10-14 Thread Christoph Hellwig
On Wed, Oct 14, 2020 at 09:12:10PM +0200, Nicolas Saenz Julienne wrote: > The default behavior for arm64 changed, so reflect that. > > Signed-off-by: Nicolas Saenz Julienne > Acked-by: Catalin Marinas > --- > include/linux/mmzone.h | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) >

Re: [PATCH v3 6/8] arm64: mm: Set ZONE_DMA size based on devicetree's dma-ranges

2020-10-14 Thread Christoph Hellwig
On Wed, Oct 14, 2020 at 09:12:08PM +0200, Nicolas Saenz Julienne wrote: > + zone_dma_bits = min(zone_dma_bits, > + (unsigned > int)ilog2(of_dma_get_max_cpu_address(NULL))); Plase avoid pointlessly long lines. Especially if it is completely trivial by using either

Re: [PATCH v3 5/8] dma-direct: Turn zone_dma_bits default value into a define

2020-10-14 Thread Christoph Hellwig
On Wed, Oct 14, 2020 at 09:12:07PM +0200, Nicolas Saenz Julienne wrote: > Set zone_dma_bits default value through a define so as for architectures > to be able to override it with their default value. Architectures can do that already by assigning a value to zone_dma_bits at runtime. I really do

Re: [PATCH 1/9] dma-mapping: split

2020-10-13 Thread Christoph Hellwig
Thanks for the report, I've commited the obvious fix. ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH 1/4] of/fdt: Update zone_dma_bits when running in bcm2711

2020-10-12 Thread Christoph Hellwig
On Fri, Oct 09, 2020 at 06:10:52PM +0100, Catalin Marinas wrote: > kdump wants DMA-able memory and, DMAable by whom? The only way to guranteed DMAable memory is to use the DMA memory allocator(s) and pass a specific device to them. Everyting else is just fundamentally broken. Note that even

Re: [PATCH 1/4] of/fdt: Update zone_dma_bits when running in bcm2711

2020-10-09 Thread Christoph Hellwig
On Thu, Oct 08, 2020 at 12:05:25PM +0200, Nicolas Saenz Julienne wrote: > Sadly I just realised that the series is incomplete, we have RPi4 users that > want to boot unsing ACPI, and this series would break things for them. I'll > have a word with them to see what we can do for their use-case.

Re: [PATCH 8/8] WIP: add a dma_alloc_contiguous API

2020-10-07 Thread Christoph Hellwig
On Wed, Oct 07, 2020 at 02:21:43PM +0200, Tomasz Figa wrote: > My initial feeling is that it should work, but we'll give you a > definitive answer once we prototype it. :) > > We might actually give it a try in the USB HCD subsystem as well, to > implement usb_alloc_noncoherent(), as an

Re: [PATCH 2/3] drm/msm: add DRM_MSM_GEM_SYNC_CACHE for non-coherent cache maintenance

2020-10-07 Thread Christoph Hellwig
On Tue, Oct 06, 2020 at 09:19:32AM -0400, Jonathan Marek wrote: > One example why drm/msm can't use DMA API is multiple page table support > (that is landing in 5.10), which is something that definitely couldn't work > with DMA API. > > Another one is being able to choose the address for

Re: [PATCH 8/8] WIP: add a dma_alloc_contiguous API

2020-10-07 Thread Christoph Hellwig
On Tue, Oct 06, 2020 at 10:56:04PM +0200, Tomasz Figa wrote: > > Yes. And make sure the API isn't implemented when VIVT caches are > > used, but that isn't really different from the current interface. > > Okay, thanks. Let's see if we can make necessary changes to the videobuf2. > > +Sergey

Re: xen-swiotlb vs phys_to_dma

2020-10-07 Thread Christoph Hellwig
On Tue, Oct 06, 2020 at 01:46:12PM -0700, Stefano Stabellini wrote: > OK, this makes a lot of sense, and I like the patch because it makes the > swiotlb interface clearer. > > Just one comment below. > > > +phys_addr_t swiotlb_tbl_map_single(struct device *hwdev, phys_addr_t > > orig_addr, > >

Re: xen-swiotlb vs phys_to_dma

2020-10-06 Thread Christoph Hellwig
On Fri, Oct 02, 2020 at 01:21:25PM -0700, Stefano Stabellini wrote: > On Fri, 2 Oct 2020, Christoph Hellwig wrote: > > Hi Stefano, > > > > I've looked over xen-swiotlb in linux-next, that is with your recent > > changes to take dma offsets into account.

Re: [PATCH 2/3] drm/msm: add DRM_MSM_GEM_SYNC_CACHE for non-coherent cache maintenance

2020-10-06 Thread Christoph Hellwig
On Mon, Oct 05, 2020 at 10:35:43AM -0400, Jonathan Marek wrote: > The cache synchronization doesn't have anything to do with IOMMU (for > example: cache synchronization would be useful in cases where drm/msm > doesn't use IOMMU). It has to do with doing DMA. And we have two frameworks for doing

Re: clean up the DMA mapping headers

2020-10-05 Thread Christoph Hellwig
I've pulled this into the dma-mapping for-next tree now. ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [RFC 0/3] iommu: Reserved regions for IOVAs beyond dma_mask and iommu aperture

2020-10-05 Thread Christoph Hellwig
On Mon, Oct 05, 2020 at 11:44:10AM +0100, Lorenzo Pieralisi wrote: > > I see that there are both OF and ACPI hooks in pci_dma_configure() and > > both modify dev->dma_mask, which is what pci-sysfs is exposing here, > > but I'm not convinced this even does what it's intended to do. The > > driver

Re: [PATCH] cma: decrease CMA_ALIGNMENT lower limit to 2

2020-10-05 Thread Christoph Hellwig
Thanks, applied to dma-mapping for-next. ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH 8/8] WIP: add a dma_alloc_contiguous API

2020-10-05 Thread Christoph Hellwig
On Fri, Oct 02, 2020 at 05:50:40PM +, Tomasz Figa wrote: > Hi Christoph, > > On Wed, Sep 30, 2020 at 06:09:17PM +0200, Christoph Hellwig wrote: > > Add a new API that returns a virtually non-contigous array of pages > > and dma address. This API is only impl

xen-swiotlb vs phys_to_dma

2020-10-02 Thread Christoph Hellwig
Hi Stefano, I've looked over xen-swiotlb in linux-next, that is with your recent changes to take dma offsets into account. One thing that puzzles me is that xen_swiotlb_map_page passes virt_to_phys(xen_io_tlb_start) as the tbl_dma_addr argument to swiotlb_tbl_map_single, despite the fact that

[PATCH 1/8] dma-mapping: remove the {alloc,free}_noncoherent methods

2020-09-30 Thread Christoph Hellwig
later. Signed-off-by: Christoph Hellwig --- drivers/iommu/dma-iommu.c | 30 -- include/linux/dma-mapping.h | 5 - kernel/dma/mapping.c| 33 ++--- 3 files changed, 6 insertions(+), 62 deletions(-) diff --git a/drivers/iommu/dma

[PATCH 6/8] dma-direct: simplify the DMA_ATTR_NO_KERNEL_MAPPING handling

2020-09-30 Thread Christoph Hellwig
alloc/free hooks. Signed-off-by: Christoph Hellwig --- include/linux/dma-noncoherent.h | 13 - kernel/dma/direct.c | 100 +--- 2 files changed, 39 insertions(+), 74 deletions(-) diff --git a/include/linux/dma-noncoherent.h b/include/linux/dma

[PATCH 2/8] dma-mapping: document dma_{alloc,free}_pages

2020-09-30 Thread Christoph Hellwig
Document the new dma_alloc_pages and dma_free_pages APIs, and fix up the documentation for dma_alloc_noncoherent and dma_free_noncoherent. Reported-by: Robin Murphy Signed-off-by: Christoph Hellwig --- Documentation/core-api/dma-api.rst | 45 ++ 1 file changed, 40

[PATCH 5/8] dma-direct: factor out a dma_direct_alloc_from_pool helper

2020-09-30 Thread Christoph Hellwig
This ensures dma_direct_alloc_pages will use the right gfp mask, as well as keeping the code for that common. Signed-off-by: Christoph Hellwig --- kernel/dma/direct.c | 41 - 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/kernel/dma

[PATCH 8/8] WIP: add a dma_alloc_contiguous API

2020-09-30 Thread Christoph Hellwig
. map them to userspace. In that sense it is a replacement for some aspects of the recently removed and never fully implemented DMA_ATTR_NON_CONSISTENT Signed-off-by: Christoph Hellwig --- drivers/iommu/dma-iommu.c | 73 + include/linux/dma-mapping.h | 9

[PATCH 7/8] dma-iommu: remove __iommu_dma_mmap

2020-09-30 Thread Christoph Hellwig
The function has a single caller, so open code it there and take advantage of the precalculated page count variable. Signed-off-by: Christoph Hellwig --- drivers/iommu/dma-iommu.c | 17 + 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/drivers/iommu/dma-iommu.c b

[PATCH 4/8] dma-direct: use __GFP_ZERO in dma_direct_alloc_pages

2020-09-30 Thread Christoph Hellwig
Prepare for supporting the DMA_ATTR_NO_KERNEL_MAPPING flag in dma_alloc_pages. Signed-off-by: Christoph Hellwig --- kernel/dma/direct.c | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c index b5f20781d3a96f..b5d56810130b22

[PATCH 3/8] dma-direct check for highmem pages in dma_direct_alloc_pages

2020-09-30 Thread Christoph Hellwig
Check for highmem pages from CMA, just like in the dma_direct_alloc path. Signed-off-by: Christoph Hellwig --- kernel/dma/direct.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c index 121a9c1969dd3a..b5f20781d3a96f 100644 --- a/kernel

dma_alloc_pages / dma_alloc_noncoherent fixups

2020-09-30 Thread Christoph Hellwig
Hi all, this series has a bunch of fixups for the noncoherent DMA allocator rework that recently landed in linux-next. I think the most important part is that the idea of vmap()ing non-contiguous allocations in dma_alloc_noncoherent doesn't work very well after all. It means we can't just rely

[PATCH 1/9] dma-mapping: split

2020-09-30 Thread Christoph Hellwig
or arm versions in a few not overly portable drivers. Signed-off-by: Christoph Hellwig --- MAINTAINERS | 1 + arch/alpha/kernel/pci_iommu.c | 2 +- arch/arc/mm/dma.c | 1 + arch/arm/common/dmabounce.c

[PATCH 4/9] dma-contiguous: remove dma_contiguous_set_default

2020-09-30 Thread Christoph Hellwig
dma_contiguous_set_default contains a trivial assignment, and has a single caller that is compiled if CONFIG_CMA_DMA is enabled. Signed-off-by: Christoph Hellwig --- include/linux/dma-contiguous.h | 7 --- kernel/dma/contiguous.c| 2 +- 2 files changed, 1 insertion(+), 8 deletions

[PATCH 9/9] dma-mapping: merge into

2020-09-30 Thread Christoph Hellwig
Move more nitty gritty DMA implementation details into the common internal header. Signed-off-by: Christoph Hellwig --- MAINTAINERS | 1 - arch/arc/mm/dma.c | 1 - arch/arm/mm/dma-mapping.c | 1 - arch/arm/xen/mm.c | 2

[PATCH 3/9] dma-contiguous: remove dev_set_cma_area

2020-09-30 Thread Christoph Hellwig
dev_set_cma_area contains a trivial assignment. It has just three callers that all have a non-NULL device and depend on CONFIG_DMA_CMA, so remove the wrapper. Signed-off-by: Christoph Hellwig --- arch/arm/mach-davinci/devices-da8xx.c | 2 +- include/linux/dma-contiguous.h| 8

[PATCH 5/9] dma-mapping: merge into

2020-09-30 Thread Christoph Hellwig
Merge dma-contiguous.h into dma-map-ops.h, after removing the comment describing the contiguous allocator into kernel/dma/contigous.c. Signed-off-by: Christoph Hellwig --- .../admin-guide/kernel-parameters.txt | 2 +- arch/arm/mach-davinci/devices-da8xx.c | 2 +- arch/arm

[PATCH 6/9] dma-mapping: remove

2020-09-30 Thread Christoph Hellwig
Just provide a weak default definition of dma_contiguous_early_fixup and let arm override it. Signed-off-by: Christoph Hellwig --- arch/arm/include/asm/dma-contiguous.h | 15 --- arch/arm/mm/dma-mapping.c | 1 - include/asm-generic/Kbuild| 1 - include/asm

clean up the DMA mapping headers

2020-09-30 Thread Christoph Hellwig
Hi all, this series cleans up the dma-mapping headers by moving everything not required by normal drivers out of into a new and then folding most other DMA mapping related headers either into the new dma-map-ops.h one, or by moving them to kernel/dma/ and thus out of the global scope. A bunch

[PATCH 8/9] dma-mapping: move large parts of to kernel/dma

2020-09-30 Thread Christoph Hellwig
Most of the dma_direct symbols should only be used by direct.c and mapping.c, so move them to kernel/dma. In fact more of dma-direct.h should eventually move, but that will require more coordination with other subsystems. Signed-off-by: Christoph Hellwig --- include/linux/dma-direct.h | 106

[PATCH 7/9] dma-mapping: move dma-debug.h to kernel/dma/

2020-09-30 Thread Christoph Hellwig
Most of dma-debug.h is not required by anything outside of kernel/dma. Move the four declarations needed by dma-mappin.h or dma-ops providers into dma-mapping.h and dma-map-ops.h, and move the remainder of the file to kernel/dma/debug.h. Signed-off-by: Christoph Hellwig --- arch/arm/include/asm

[PATCH 2/9] dma-contiguous: remove dma_declare_contiguous

2020-09-30 Thread Christoph Hellwig
dma_declare_contiguous is a trivial wrapper around dma_contiguous_reserve_area and just has a single caller. Signed-off-by: Christoph Hellwig --- arch/arm/mach-davinci/devices-da8xx.c | 16 +- include/linux/dma-contiguous.h| 32 --- 2 files changed

Re: [RFC 2/3] iommu: Account for dma_mask and iommu aperture in IOVA reserved regions

2020-09-29 Thread Christoph Hellwig
On Mon, Sep 28, 2020 at 09:50:36PM +0200, Eric Auger wrote: > VFIO currently exposes the usable IOVA regions through the > VFIO_IOMMU_GET_INFO ioctl. However it fails to take into account > the dma_mask of the devices within the container. The top limit > currently is defined by the iommu

Re: [PATCH v3 2/2] iommu/tegra-smmu: Expend mutex protection range

2020-09-29 Thread Christoph Hellwig
On Mon, Sep 28, 2020 at 09:52:47PM -0700, Nicolin Chen wrote: > This is used to protect potential race condition at use_count. > since probes of client drivers, calling attach_dev(), may run > concurrently. Shouldn't this read "expand" instead of "expend"?

Re: [PATCH 17/18] dma-iommu: implement ->alloc_noncoherent

2020-09-26 Thread Christoph Hellwig
On Fri, Sep 25, 2020 at 06:46:22PM +, Tomasz Figa wrote: > > +static void *iommu_dma_alloc_noncoherent(struct device *dev, size_t size, > > + dma_addr_t *handle, enum dma_data_direction dir, gfp_t gfp) > > +{ > > + if (!gfpflags_allow_blocking(gfp)) { > > + struct page

Re: [PATCH 1/8] dma-mapping: add DMA_ATTR_LOW_ADDRESS attribute

2020-09-25 Thread Christoph Hellwig
> #define DMA_ATTR_PRIVILEGED (1UL << 9) > +/* > + * DMA_ATTR_LOW_ADDRESS: used to indicate that the buffer should be allocated > + * at the lowest possible DMA address, usually just at the beginning of the > + * DMA/IOVA address space ('first-fit' allocation algorithm). > + */ >

Re: [PATCH 08/18] dma-mapping: add a new dma_alloc_noncoherent API

2020-09-25 Thread Christoph Hellwig
On Fri, Sep 25, 2020 at 12:15:37PM +0100, Robin Murphy wrote: > On 2020-09-15 16:51, Christoph Hellwig wrote: > [...] >> +These APIs allow to allocate pages in the kernel direct mapping that are >> +guaranteed to be DMA addressable. This means that unlike >> dma_alloc_co

Re: a saner API for allocating DMA addressable pages v3

2020-09-24 Thread Christoph Hellwig
This is in dma-mapping for-next now. ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH 1/4] ARM/omap1: switch to use dma_direct_set_offset for lbus DMA offsets

2020-09-24 Thread Christoph Hellwig
On Mon, Sep 21, 2020 at 09:44:18AM +0300, Tony Lindgren wrote: > > > Looks nice to me :) I still can't test this probably for few more weeks > > > though but hopefully Aaro or Janusz (Added to Cc) can test it. > > > > Works for me on Amstrad Delta (tested with a USB ethernet adapter). > > > >

Re: [PATCH 3/3] dma-mapping: better document dma_addr_t and DMA_MAPPING_ERROR

2020-09-24 Thread 'Christoph Hellwig'
On Tue, Sep 22, 2020 at 01:56:46PM +, David Laight wrote: > > +/* > > + * A dma_addr_t can hold any valid DMA or bus address for the platform. > > It can > > + * be given to a device to use as a DMA source or target. A CPU cannot > > + * reference a dma_addr_t directly because there may be

Re: IOVA allocation dependency between firmware buffer and remaining buffers

2020-09-23 Thread Christoph Hellwig
On Wed, Sep 23, 2020 at 01:15:33PM +0530, Ajay kumar wrote: > Hello all, > > We pretty much tried to solve the same issue here with a new API in DMA-IOMMU: > https://lore.kernel.org/linux-iommu/20200811054912.ga...@infradead.org/T/ > > Christopher- the user part would be MFC devices on exynos

Re: IOVA allocation dependency between firmware buffer and remaining buffers

2020-09-23 Thread Christoph Hellwig
On Wed, Sep 23, 2020 at 08:48:26AM +0200, Marek Szyprowski wrote: > Hi Shaik, > > I've run into similar problem while adapting S5P-MFC and Exynos4-IS > drivers for generic IOMMU-DMA framework. Here is my first solution: >

[PATCH 1/3] dma-mapping: remove DMA_MASK_NONE

2020-09-22 Thread Christoph Hellwig
This value is only used by a PCMCIA driver and not very useful. Signed-off-by: Christoph Hellwig --- drivers/pcmcia/ds.c | 2 +- include/linux/dma-mapping.h | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index

[PATCH 3/3] dma-mapping: better document dma_addr_t and DMA_MAPPING_ERROR

2020-09-22 Thread Christoph Hellwig
Move the comment documenting dma_addr_t away from the dma_map_ops definition which isn't very related to it, and toward DMA_MAPPING_ERROR, which is somewhat related. Add a little blurb about DMA_MAPPING_ERROR as well. Signed-off-by: Christoph Hellwig --- include/linux/dma-mapping.h | 16

a few trivial dma-mapping header cleanups

2020-09-22 Thread Christoph Hellwig
Hi all, these three patches clean up dma-mapping.h a little bit ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

[PATCH 2/3] dma-mapping: move valid_dma_direction to dma-direction.h

2020-09-22 Thread Christoph Hellwig
Move the valid_dma_direction helper to a more suitable header, and clean it up to use the proper enum as well as removing pointless braces. Signed-off-by: Christoph Hellwig --- include/linux/dma-direction.h | 8 +++- include/linux/dma-mapping.h | 7 --- 2 files changed, 7 insertions

Re: [PATCH] iommu/io-pgtable-arm: Clean up faulty sanity check

2020-09-21 Thread Christoph Hellwig
On Mon, Sep 21, 2020 at 04:08:01PM +0100, Robin Murphy wrote: > Checking for a nonzero dma_pfn_offset was a quick shortcut to validate > whether the DMA == phys assumption could hold at all. Checking for a > non-NULL dma_range_map is not quite equivalent, since a map may be > present to describe a

Re: [PATCH] dma: debug: convert comma to semicolon

2020-09-21 Thread Christoph Hellwig
Thanks, applied to the dma-mapping for-next tree. ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH 1/4] ARM/omap1: switch to use dma_direct_set_offset for lbus DMA offsets

2020-09-21 Thread Christoph Hellwig
On Mon, Sep 21, 2020 at 09:44:18AM +0300, Tony Lindgren wrote: > * Janusz Krzysztofik [200919 22:29]: > > Hi Tony, > > > > On Friday, September 18, 2020 7:49:33 A.M. CEST Tony Lindgren wrote: > > > * Christoph Hellwig [200917 17:37]: > > > > Switc

Re: a saner API for allocating DMA addressable pages v3

2020-09-21 Thread Christoph Hellwig
, and chance you could retest it? On Tue, Sep 15, 2020 at 05:51:04PM +0200, Christoph Hellwig wrote: > Hi all, > > this series replaced the DMA_ATTR_NON_CONSISTENT flag to dma_alloc_attrs > with a separate new dma_alloc_pages API, which is available on all > platforms. In addition

Re: [PATCH 3/4] ARM/dma-mapping: don't handle NULL devices in dma-direct.h

2020-09-17 Thread Christoph Hellwig
On Thu, Sep 17, 2020 at 07:50:10PM +0100, Russell King - ARM Linux admin wrote: > On Thu, Sep 17, 2020 at 07:32:28PM +0200, Christoph Hellwig wrote: > > The DMA API removed support for not passing in a device a long time > > ago, so remove the NULL checks. > > What hap

[PATCH 4/4] ARM/dma-mapping: remove the arm specific phys to dma translation helpers

2020-09-17 Thread Christoph Hellwig
or virt addr based arm ones. Signed-off-by: Christoph Hellwig --- arch/arm/Kconfig | 1 - arch/arm/common/dmabounce.c | 14 +- arch/arm/include/asm/dma-direct.h | 45 --- arch/arm/mm/dma-mapping.c | 20 +++--- 4 files

[PATCH 3/4] ARM/dma-mapping: don't handle NULL devices in dma-direct.h

2020-09-17 Thread Christoph Hellwig
The DMA API removed support for not passing in a device a long time ago, so remove the NULL checks. Signed-off-by: Christoph Hellwig --- arch/arm/include/asm/dma-direct.h | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/arch/arm/include/asm/dma-direct.h b/arch/arm

[PATCH 2/4] ARM/footbridge: switch to use dma_direct_set_offset for lbus DMA offsets

2020-09-17 Thread Christoph Hellwig
Switch the footbridge PCI devices to use dma_direct_set_offset to set the DMA offset instead of using direct hooks into the DMA mapping code and remove the now unused hooks. Signed-off-by: Christoph Hellwig --- arch/arm/include/asm/dma-direct.h | 4 +- arch/arm/include/asm/memory.h

[PATCH 1/4] ARM/omap1: switch to use dma_direct_set_offset for lbus DMA offsets

2020-09-17 Thread Christoph Hellwig
Switch the omap1510 platform ohci device to use dma_direct_set_offset to set the DMA offset instead of using direct hooks into the DMA mapping code and remove the now unused hooks. Signed-off-by: Christoph Hellwig --- arch/arm/include/asm/dma-direct.h | 18 - arch/arm/mach

RFC: remove the need for on ARM

2020-09-17 Thread Christoph Hellwig
Hi Russell, as Robin pointed out there is not much need for the ARM specific routines to translated to and from a dma_addr_t given that we have the dma offset (and now offset range) functionality. This series converts ARM over to the generic helpers. This has only been tested on qemu, and

Re: support range based offsets in dma-direct v3

2020-09-17 Thread Christoph Hellwig
I've pulled this into the dma-mapping for-next tree. Thanks Jim and everyone helping out! ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH V2] dma-direct: Fix potential NULL pointer dereference

2020-09-17 Thread Christoph Hellwig
Thanks, applied to the dma-mapping for-next tree. ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

[PATCH 6/6] dma-mapping: introduce DMA range map, supplanting dma_pfn_offset

2020-09-16 Thread Christoph Hellwig
t_set_offset(dev, cpu_addr, dma_addr, size). Signed-off-by: Jim Quinlan [hch: various interface cleanups] Signed-off-by: Christoph Hellwig Tested-by: Nathan Chancellor --- arch/arm/include/asm/dma-direct.h | 9 +-- arch/arm/mach-keystone/keystone.c | 17 ++--- arch/a

[PATCH 5/6] usb: don't inherity DMA properties for USB devices

2020-09-16 Thread Christoph Hellwig
commit 21e07dba9fb1 ("scsi: reduce use of block bounce buffers") years ago. Signed-off-by: Christoph Hellwig Reviewed-by: Greg Kroah-Hartman --- drivers/usb/core/message.c | 6 -- drivers/usb/core/usb.c | 12 2 files changed, 18 deletions(-) diff --git a/drivers/us

[PATCH 4/6] ARM/keystone: move the DMA offset handling under ifdef CONFIG_ARM_LPAE

2020-09-16 Thread Christoph Hellwig
to not compile the code except for LPAE configs. Signed-off-by: Christoph Hellwig Reviewed-by: Robin Murphy --- arch/arm/mach-keystone/keystone.c | 4 1 file changed, 4 insertions(+) diff --git a/arch/arm/mach-keystone/keystone.c b/arch/arm/mach-keystone/keystone.c index 638808c4e12247

[PATCH 3/6] ARM/dma-mapping: move various helpers from dma-mapping.h to dma-direct.h

2020-09-16 Thread Christoph Hellwig
Move the helpers to translate to and from direct mapping DMA addresses to dma-direct.h. This not only is the most logical place, but the new placement also avoids dependency loops with pending commits. Signed-off-by: Christoph Hellwig Reviewed-by: Robin Murphy --- arch/arm/common/dmabounce.c

[PATCH 2/6] ARM/dma-mapping: remove dma_to_virt

2020-09-16 Thread Christoph Hellwig
dma_to_virt is entirely unused, remove it. Signed-off-by: Christoph Hellwig --- arch/arm/include/asm/dma-mapping.h| 18 +- arch/arm/mach-omap1/include/mach/memory.h | 4 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/arch/arm/include/asm/dma

Re: [PATCH] dma-direct: Fix potential NULL pointer dereference

2020-09-16 Thread Christoph Hellwig
On Tue, Sep 15, 2020 at 04:46:17PM -0400, Thomas Tai wrote: > I tried out the suggested changes, and it successfully warned the null > pointer without panic. I notice that there are some places outside the > dma-direct, which calls dma_capable(). > >

[PATCH 1/6] ARM/dma-mapping: remove a __arch_page_to_dma #error

2020-09-16 Thread Christoph Hellwig
The __arch_page_to_dma hook is long gone. Signed-off-by: Christoph Hellwig --- arch/arm/include/asm/dma-mapping.h | 4 1 file changed, 4 deletions(-) diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h index bdd80ddbca3451..70d95677656044 100644

support range based offsets in dma-direct v3

2020-09-16 Thread Christoph Hellwig
Hi all, this series adds range-based offsets to the dma-direct implementation. The guts of the change are a patch from Jim with some modifications from me, but to do it nicely we need to ARM patches to prepare for it as well. Changes since v2: - fix a mismerge - return (phys_addr_t)-1 from

Re: [PATCH 6/6] dma-mapping: introduce DMA range map, supplanting dma_pfn_offset

2020-09-16 Thread Christoph Hellwig
On Tue, Sep 15, 2020 at 01:55:01PM -0600, Mathieu Poirier wrote: > That did the trick - the stm32 platform driver's probe() function completes > and > the remote processor is operatinal. > > That being said the value returned by function dma_to_pfn() > is 0x137fff in the original code and

[PATCH 18/18] firewire-ohci: use dma_alloc_pages

2020-09-15 Thread Christoph Hellwig
Use dma_alloc_pages to allocate DMAable pages instead of hoping that the architecture either has GFP_DMA32 or not more than 4G of memory. Signed-off-by: Christoph Hellwig --- drivers/firewire/ohci.c | 26 +++--- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git

[PATCH 17/18] dma-iommu: implement ->alloc_noncoherent

2020-09-15 Thread Christoph Hellwig
Implement the alloc_noncoherent method to provide memory that is neither coherent not contiguous. Signed-off-by: Christoph Hellwig --- drivers/iommu/dma-iommu.c | 41 +++ 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/dma-iommu.c

[PATCH 16/18] dma-mapping: add new {alloc, free}_noncoherent dma_map_ops methods

2020-09-15 Thread Christoph Hellwig
This will allow IOMMU drivers to allocate non-contigous memory and return a vmapped virtual address. Signed-off-by: Christoph Hellwig --- include/linux/dma-mapping.h | 5 + kernel/dma/mapping.c| 33 +++-- 2 files changed, 32 insertions(+), 6 deletions

[PATCH 15/18] dma-mapping: add a new dma_alloc_pages API

2020-09-15 Thread Christoph Hellwig
over to use dma_alloc_pages as its backend. Signed-off-by: Christoph Hellwig --- Documentation/core-api/dma-attributes.rst | 8 --- arch/alpha/kernel/pci_iommu.c | 2 + arch/arm/mm/dma-mapping-nommu.c | 2 + arch/arm/mm/dma-mapping.c | 4 ++ arch/ia64/hp

[PATCH 14/18] dma-mapping: remove dma_cache_sync

2020-09-15 Thread Christoph Hellwig
All users are gone now, remove the API. Signed-off-by: Christoph Hellwig --- arch/mips/Kconfig | 1 - arch/mips/jazz/jazzdma.c| 1 - arch/mips/mm/dma-noncoherent.c | 6 -- arch/parisc/Kconfig | 1 - arch/parisc/kernel/pci-dma.c| 6 -- include

[PATCH 13/18] 53c700: convert to dma_alloc_noncoherent

2020-09-15 Thread Christoph Hellwig
Use the new non-coherent DMA API including proper ownership transfers. Signed-off-by: Christoph Hellwig --- drivers/scsi/53c700.c | 20 ++-- 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c index c59226d7e2f6b5

[PATCH 12/18] sgiseeq: convert to dma_alloc_noncoherent

2020-09-15 Thread Christoph Hellwig
Use the new non-coherent DMA API including proper ownership transfers. This includes adding additional calls to dma_sync_desc_dev as the old syncing was rather ad-hoc. Thanks to Thomas Bogendoerfer for debugging the ownership transfer issues. Signed-off-by: Christoph Hellwig --- drivers/net

[PATCH 11/18] lib82596: convert to dma_alloc_noncoherent

2020-09-15 Thread Christoph Hellwig
Use the new non-coherent DMA API including proper ownership transfers. This includes moving the DMA helpers to lib82596 based of an ifdef to avoid include order problems. Signed-off-by: Christoph Hellwig --- drivers/net/ethernet/i825xx/lasi_82596.c | 25 ++--- drivers/net/ethernet/i825xx

[PATCH 10/18] hal2: convert to dma_alloc_noncoherent

2020-09-15 Thread Christoph Hellwig
Use the new non-coherent DMA API including proper ownership transfers. This also means we can allocate the buffer memory with the proper direction instead of bidirectional. Signed-off-by: Christoph Hellwig --- sound/mips/hal2.c | 58 ++- 1 file

[PATCH 09/18] sgiwd93: convert to dma_alloc_noncoherent

2020-09-15 Thread Christoph Hellwig
Use the new non-coherent DMA API including proper ownership transfers. This also means we can allocate the memory as DMA_TO_DEVICE instead of bidirectional. Signed-off-by: Christoph Hellwig --- drivers/scsi/sgiwd93.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff

  1   2   3   4   5   6   7   8   9   10   >