Re: [PATCH v4 2/3] mm: Add support for kmem caches in DMA32 zone

2018-12-04 Thread Nicolas Boichat
On Wed, Dec 5, 2018 at 3:25 PM Wei Yang wrote: > > On Wed, Dec 05, 2018 at 01:48:27PM +0800, Nicolas Boichat wrote: > >In some cases (e.g. IOMMU ARMv7s page allocator), we need to allocate > >data structures smaller than a page with GFP_DMA32 flag. > > > >This change makes it possible to create a

Re: [PATCH v4 2/3] mm: Add support for kmem caches in DMA32 zone

2018-12-04 Thread Wei Yang
On Wed, Dec 05, 2018 at 01:48:27PM +0800, Nicolas Boichat wrote: >In some cases (e.g. IOMMU ARMv7s page allocator), we need to allocate >data structures smaller than a page with GFP_DMA32 flag. > >This change makes it possible to create a custom cache in DMA32 zone >using kmem_cache_create, then

Re: [PATCH v2 0/3] iommu/io-pgtable-arm-v7s: Use DMA32 zone for page tables

2018-12-04 Thread Nicolas Boichat
On Wed, Dec 5, 2018 at 10:04 AM Nicolas Boichat wrote: > > On Tue, Dec 4, 2018 at 10:35 PM Vlastimil Babka wrote: > > > > On 12/4/18 10:37 AM, Nicolas Boichat wrote: > > > On Sun, Nov 11, 2018 at 5:04 PM Nicolas Boichat > > > wrote: > > >> > > >> This is a follow-up to the discussion in [1],

[PATCH v4 3/3] iommu/io-pgtable-arm-v7s: Request DMA32 memory, and improve debugging

2018-12-04 Thread Nicolas Boichat
IOMMUs using ARMv7 short-descriptor format require page tables (level 1 and 2) to be allocated within the first 4GB of RAM, even on 64-bit systems. For level 1/2 pages, ensure GFP_DMA32 is used if CONFIG_ZONE_DMA32 is defined (e.g. on arm64 platforms). For level 2 pages, allocate a slab cache in

[PATCH v4 1/3] mm: slab/slub: Add check_slab_flags function to check for valid flags

2018-12-04 Thread Nicolas Boichat
Remove duplicated code between slab and slub, and will make it easier to make the test more complicated in the next commits. Fixes: ad67f5a6545f ("arm64: replace ZONE_DMA with ZONE_DMA32") Signed-off-by: Nicolas Boichat --- mm/internal.h | 18 -- mm/slab.c | 8 +---

[PATCH v4 2/3] mm: Add support for kmem caches in DMA32 zone

2018-12-04 Thread Nicolas Boichat
In some cases (e.g. IOMMU ARMv7s page allocator), we need to allocate data structures smaller than a page with GFP_DMA32 flag. This change makes it possible to create a custom cache in DMA32 zone using kmem_cache_create, then allocate memory using kmem_cache_alloc. We do not create a DMA32

[PATCH v4 0/3] iommu/io-pgtable-arm-v7s: Use DMA32 zone for page tables

2018-12-04 Thread Nicolas Boichat
This is a follow-up to the discussion in [1], [2]. IOMMUs using ARMv7 short-descriptor format require page tables (level 1 and 2) to be allocated within the first 4GB of RAM, even on 64-bit systems. For L1 tables that are bigger than a page, we can just use __get_free_pages with GFP_DMA32 (on

Re: [PATCH 1/4] dma-debug: Use pr_fmt()

2018-12-04 Thread Joe Perches
On Mon, 2018-12-03 at 17:28 +, Robin Murphy wrote: > Use pr_fmt() to generate the "DMA-API: " prefix consistently. This > results in it being added to a couple of pr_*() messages which were > missing it before, and for the err_printk() calls moves it to the actual > start of the message

Re: [PATCH v2 0/3] iommu/io-pgtable-arm-v7s: Use DMA32 zone for page tables

2018-12-04 Thread Nicolas Boichat
On Tue, Dec 4, 2018 at 10:35 PM Vlastimil Babka wrote: > > On 12/4/18 10:37 AM, Nicolas Boichat wrote: > > On Sun, Nov 11, 2018 at 5:04 PM Nicolas Boichat > > wrote: > >> > >> This is a follow-up to the discussion in [1], to make sure that the page > >> tables allocated by

[PATCH] iommu: fix amd_iommu=force_isolation

2018-12-04 Thread Yu Zhao via iommu
The parameter is still there but it's ignored. We need to check its value before deciding to go into passthrough mode for AMD IOMMU. Fixes: aafd8ba0ca74 ("iommu/amd: Implement add_device and remove_device") Signed-off-by: Yu Zhao --- drivers/iommu/amd_iommu.c | 3 ++- 1 file changed, 2

Re: [PATCH 01/23] dma-mapping: provide a generic DMA_MAPPING_ERROR

2018-12-04 Thread Christoph Hellwig
On Tue, Dec 04, 2018 at 04:41:34PM +, Robin Murphy wrote: > I'd have been inclined to put the default check here, i.e. > > - return 0 > + return dma_addr == DMA_MAPPING_ERROR > > such that the callback retains full precedence and we don't have to deal > with the non-trivial removals

Re: [PATCH] of/device: add blacklist for iommu dma_ops

2018-12-04 Thread Rob Herring
On Sat, Dec 1, 2018 at 10:54 AM Rob Clark wrote: > > This solves a problem we see with drm/msm, caused by getting > iommu_dma_ops while we attach our own domain and manage it directly at > the iommu API level: > > [0038] user address but active_mm is swapper > Internal error:

Re: [PATCH v4 9/9] dmapool: debug: prevent endless loop in case of corruption

2018-12-04 Thread Andy Shevchenko
On Tue, Dec 4, 2018 at 11:26 PM Tony Battersby wrote: > > On 12/4/18 3:30 PM, Andy Shevchenko wrote: > > On Tue, Dec 4, 2018 at 10:18 PM Matthew Wilcox wrote: > >> On Tue, Dec 04, 2018 at 12:14:43PM -0800, Andrew Morton wrote: > >>> Also, Andy had issues with the v2 series so it would be good to

Re: [PATCH V2] mm: Replace all open encodings for NUMA_NO_NODE

2018-12-04 Thread Lubomir Rintel
On Mon, 2018-11-26 at 17:56 +0530, Anshuman Khandual wrote: > At present there are multiple places where invalid node number is encoded > as -1. Even though implicitly understood it is always better to have macros > in there. Replace these open encodings for an invalid node number with the >

Re: [PATCH v4 9/9] dmapool: debug: prevent endless loop in case of corruption

2018-12-04 Thread Tony Battersby
On 12/4/18 3:30 PM, Andy Shevchenko wrote: > On Tue, Dec 4, 2018 at 10:18 PM Matthew Wilcox wrote: >> On Tue, Dec 04, 2018 at 12:14:43PM -0800, Andrew Morton wrote: >>> Also, Andy had issues with the v2 series so it would be good to hear an >>> update from him? >> Certainly. > Hmm... I certainly

Re: [PATCH v4 9/9] dmapool: debug: prevent endless loop in case of corruption

2018-12-04 Thread Matthew Wilcox
On Tue, Dec 04, 2018 at 12:28:54PM -0800, Andrew Morton wrote: > On Tue, 4 Dec 2018 12:18:01 -0800 Matthew Wilcox wrote: > > I only had a review comment on 8/9, which I then withdrew during my review > > of patch 9/9. Unless I missed something during my re-review of my > > responses? > > And

Re: [PATCH v4 9/9] dmapool: debug: prevent endless loop in case of corruption

2018-12-04 Thread Andy Shevchenko
On Tue, Dec 4, 2018 at 10:18 PM Matthew Wilcox wrote: > On Tue, Dec 04, 2018 at 12:14:43PM -0800, Andrew Morton wrote: > > Also, Andy had issues with the v2 series so it would be good to hear an > > update from him? > > Certainly. Hmm... I certainly forgot what was long time ago. If I _was_ in

Re: [PATCH v4 9/9] dmapool: debug: prevent endless loop in case of corruption

2018-12-04 Thread Andrew Morton
On Tue, 4 Dec 2018 12:18:01 -0800 Matthew Wilcox wrote: > On Tue, Dec 04, 2018 at 12:14:43PM -0800, Andrew Morton wrote: > > On Tue, 4 Dec 2018 11:22:34 -0500 Tony Battersby > > wrote: > > > > > On 11/13/18 1:36 AM, Matthew Wilcox wrote: > > > > On Mon, Nov 12, 2018 at 10:46:35AM -0500, Tony

Re: [PATCH v4 9/9] dmapool: debug: prevent endless loop in case of corruption

2018-12-04 Thread Matthew Wilcox
On Tue, Dec 04, 2018 at 12:14:43PM -0800, Andrew Morton wrote: > On Tue, 4 Dec 2018 11:22:34 -0500 Tony Battersby > wrote: > > > On 11/13/18 1:36 AM, Matthew Wilcox wrote: > > > On Mon, Nov 12, 2018 at 10:46:35AM -0500, Tony Battersby wrote: > > >> Prevent a possible endless loop with

Re: [PATCH v4 9/9] dmapool: debug: prevent endless loop in case of corruption

2018-12-04 Thread Andrew Morton
On Tue, 4 Dec 2018 11:22:34 -0500 Tony Battersby wrote: > On 11/13/18 1:36 AM, Matthew Wilcox wrote: > > On Mon, Nov 12, 2018 at 10:46:35AM -0500, Tony Battersby wrote: > >> Prevent a possible endless loop with DMAPOOL_DEBUG enabled if a buggy > >> driver corrupts DMA pool memory. > >> > >>

[PATCH] Fix typo. Change tlb_range_add to iotlb_range_add and tlb_sync to iotlb_sync

2018-12-04 Thread Tom Murphy
From: tom Someone forgot to update this comment. Signed-off-by: Tom Murphy --- include/linux/iommu.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index a1d28f42cb77..11db18b9ffe8 100644 --- a/include/linux/iommu.h +++

Re: [PATCH 3/4] dma-debug: Dynamically expand the dma_debug_entry pool

2018-12-04 Thread John Garry
In fact, having got this far in, what I'd quite like to do is to get rid of dma_debug_resize_entries() such that we never need to free things at all, since then we could allocate whole pages as blocks of entries to save on masses of individual slab allocations. On a related topic, is it

[PATCH 5/5] xhci: Use device_iommu_mapped()

2018-12-04 Thread Joerg Roedel
From: Joerg Roedel Replace the dev->iommu_group check with a proper function call that better reprensents its purpose. Cc: Mathias Nyman Signed-off-by: Joerg Roedel --- drivers/usb/host/xhci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci.c

[PATCH 4/5] powerpc/iommu: Use device_iommu_mapped()

2018-12-04 Thread Joerg Roedel
From: Joerg Roedel Use the new function to replace the open-coded iommu check. Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Russell Currey Cc: Sam Bobroff Signed-off-by: Joerg Roedel --- arch/powerpc/kernel/eeh.c | 2 +- arch/powerpc/kernel/iommu.c | 6 +++--- 2 files changed, 4

[PATCH 2/5] iommu/of: Use device_iommu_mapped()

2018-12-04 Thread Joerg Roedel
From: Joerg Roedel Use Use device_iommu_mapped() to check if the device is already mapped by an IOMMU. Signed-off-by: Joerg Roedel --- drivers/iommu/of_iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c index

[PATCH 3/5] ACPI/IORT: Use device_iommu_mapped()

2018-12-04 Thread Joerg Roedel
From: Joerg Roedel Replace the iommu-check with a proper and readable function call. Cc: Lorenzo Pieralisi Signed-off-by: Joerg Roedel --- drivers/acpi/arm64/iort.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c index

[PATCH 1/5] driver core: Introduce device_iommu_mapped() function

2018-12-04 Thread Joerg Roedel
From: Joerg Roedel Some places in the kernel check the iommu_group pointer in 'struct device' in order to find ot whether a device is mapped by an IOMMU. This is not good way to make this check, as the pointer will be moved to 'struct dev_iommu_data'. This way to make the check is also not very

[PATCH 0/5] Introduce device_iommu_maped() function

2018-12-04 Thread Joerg Roedel
Hi, here is a patch-set to replace the dev->iommu_group checks in the source tree by a proper function call. The pointer checks mostly happen to check whether a device is managed my an IOMMU. For that purpose a pointer check is not very descriptable, so replace it by a function call that make its

Re: [PATCH 3/4] dma-debug: Dynamically expand the dma_debug_entry pool

2018-12-04 Thread Robin Murphy
On 04/12/2018 16:30, John Garry wrote: On 04/12/2018 13:11, Robin Murphy wrote: Hi John, On 03/12/2018 18:23, John Garry wrote: On 03/12/2018 17:28, Robin Murphy wrote: Certain drivers such as large multi-queue network adapters can use pools of mapped DMA buffers larger than the default

Re: [PATCH 01/23] dma-mapping: provide a generic DMA_MAPPING_ERROR

2018-12-04 Thread Robin Murphy
On 30/11/2018 13:22, Christoph Hellwig wrote: Error handling of the dma_map_single and dma_map_page APIs is a little problematic at the moment, in that we use different encodings in the returned dma_addr_t to indicate an error. That means we require an additional indirect call to figure out if

Re: [PATCH v3, RFC] iommu/io-pgtable-arm-v7s: Use page_frag to request DMA32 memory

2018-12-04 Thread Will Deacon
On Tue, Dec 04, 2018 at 04:23:00PM +0800, Nicolas Boichat wrote: > IOMMUs using ARMv7 short-descriptor format require page tables > (level 1 and 2) to be allocated within the first 4GB of RAM, even > on 64-bit systems. > > For level 1/2 tables, ensure GFP_DMA32 is used if CONFIG_ZONE_DMA32 > is

Re: [PATCH 3/4] dma-debug: Dynamically expand the dma_debug_entry pool

2018-12-04 Thread Robin Murphy
On 04/12/2018 14:29, Christoph Hellwig wrote: + for (retry_count = 0; ; retry_count++) { + spin_lock_irqsave(_entries_lock, flags); + + if (num_free_entries > 0) + break; spin_unlock_irqrestore(_entries_lock, flags); Taking a

Re: [PATCH 3/4] dma-debug: Dynamically expand the dma_debug_entry pool

2018-12-04 Thread John Garry
On 04/12/2018 13:11, Robin Murphy wrote: Hi John, On 03/12/2018 18:23, John Garry wrote: On 03/12/2018 17:28, Robin Murphy wrote: Certain drivers such as large multi-queue network adapters can use pools of mapped DMA buffers larger than the default dma_debug_entry pool of 65536 entries, with

[PATCH 9/9] iommu/tegra: Use helper functions to access dev->iommu_fwspec

2018-12-04 Thread Joerg Roedel
From: Joerg Roedel Use the new helpers dev_iommu_fwspec_get()/set() to access the dev->iommu_fwspec pointer. This makes it easier to move that pointer later into another struct. Cc: Thierry Reding Signed-off-by: Joerg Roedel --- drivers/iommu/tegra-smmu.c | 2 +- 1 file changed, 1

[PATCH 7/9] iommu/of: Use helper functions to access dev->iommu_fwspec

2018-12-04 Thread Joerg Roedel
From: Joerg Roedel Use the new helpers dev_iommu_fwspec_get()/set() to access the dev->iommu_fwspec pointer. This makes it easier to move that pointer later into another struct. Signed-off-by: Joerg Roedel --- drivers/iommu/of_iommu.c | 7 +-- 1 file changed, 5 insertions(+), 2

[PATCH 2/9] ACPI/IORT: Use helper functions to access dev->iommu_fwspec

2018-12-04 Thread Joerg Roedel
From: Joerg Roedel Use the new helpers dev_iommu_fwspec_get()/set() to access the dev->iommu_fwspec pointer. This makes it easier to move that pointer later into another struct. Cc: Lorenzo Pieralisi Signed-off-by: Joerg Roedel --- drivers/acpi/arm64/iort.c | 12 +++- 1 file changed,

[PATCH 8/9] iommu/qcom: Use helper functions to access dev->iommu_fwspec

2018-12-04 Thread Joerg Roedel
From: Joerg Roedel Use the new helpers dev_iommu_fwspec_get()/set() to access the dev->iommu_fwspec pointer. This makes it easier to move that pointer later into another struct. Cc: Rob Clark Signed-off-by: Joerg Roedel --- drivers/iommu/qcom_iommu.c | 18 ++ 1 file changed,

[PATCH 0/9] Access dev->iommu_fwspec through functions

2018-12-04 Thread Joerg Roedel
Hi, here is a patch-set to wrap accesses to dev->iommu_fwspec into functions. This will make it easier to move the pointer into a separate struct and consolitdate the iommu-related pointers in 'struct device'. Regards, Joerg Joerg Roedel (9): iommu: Introduce wrappers around

[PATCH 5/9] iommu/ipmmu-vmsa: Use helper functions to access dev->iommu_fwspec

2018-12-04 Thread Joerg Roedel
From: Joerg Roedel Use the new helpers dev_iommu_fwspec_get()/set() to access the dev->iommu_fwspec pointer. This makes it easier to move that pointer later into another struct. Signed-off-by: Joerg Roedel --- drivers/iommu/ipmmu-vmsa.c | 12 1 file changed, 8 insertions(+), 4

[PATCH 6/9] iommu/mediatek: Use helper functions to access dev->iommu_fwspec

2018-12-04 Thread Joerg Roedel
From: Joerg Roedel Use the new helpers dev_iommu_fwspec_get()/set() to access the dev->iommu_fwspec pointer. This makes it easier to move that pointer later into another struct. Cc: Matthias Brugger Signed-off-by: Joerg Roedel --- drivers/iommu/mtk_iommu.c| 21 -

[PATCH 3/9] iommu/arm-smmu: Use helper functions to access dev->iommu_fwspec

2018-12-04 Thread Joerg Roedel
From: Joerg Roedel Use the new helpers dev_iommu_fwspec_get()/set() to access the dev->iommu_fwspec pointer. This makes it easier to move that pointer later into another struct. Cc: Will Deacon Cc: Robin Murphy Signed-off-by: Joerg Roedel --- drivers/iommu/arm-smmu-v3.c | 16

[PATCH 4/9] iommu/dma: Use helper functions to access dev->iommu_fwspec

2018-12-04 Thread Joerg Roedel
From: Joerg Roedel Use the new helpers dev_iommu_fwspec_get()/set() to access the dev->iommu_fwspec pointer. This makes it easier to move that pointer later into another struct. Signed-off-by: Joerg Roedel --- drivers/iommu/dma-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)

[PATCH 1/9] iommu: Introduce wrappers around dev->iommu_fwspec

2018-12-04 Thread Joerg Roedel
From: Joerg Roedel These wrappers will be used to easily change the location of the field later when all users are converted. Signed-off-by: Joerg Roedel --- drivers/iommu/iommu.c | 14 +++--- include/linux/iommu.h | 11 +++ 2 files changed, 18 insertions(+), 7 deletions(-)

Re: [PATCH v2 0/3] iommu/io-pgtable-arm-v7s: Use DMA32 zone for page tables

2018-12-04 Thread Will Deacon
On Tue, Dec 04, 2018 at 05:37:13PM +0800, Nicolas Boichat wrote: > On Sun, Nov 11, 2018 at 5:04 PM Nicolas Boichat wrote: > > > > This is a follow-up to the discussion in [1], to make sure that the page > > tables allocated by iommu/io-pgtable-arm-v7s are contained within 32-bit > > physical

Re: [PATCH v4 9/9] dmapool: debug: prevent endless loop in case of corruption

2018-12-04 Thread Tony Battersby
On 11/13/18 1:36 AM, Matthew Wilcox wrote: > On Mon, Nov 12, 2018 at 10:46:35AM -0500, Tony Battersby wrote: >> Prevent a possible endless loop with DMAPOOL_DEBUG enabled if a buggy >> driver corrupts DMA pool memory. >> >> Signed-off-by: Tony Battersby > I like it! Also, here you're using

merge swiotlb support into dma_direct_ops

2018-12-04 Thread Christoph Hellwig
Hi Konrad and others, can you review this series? It merges the swiotlb support into the DMA direct ops so that we don't have to duplicate the dma mapping logic in multiple places. Note that this is based on the dma_mapping_error series for which I'd still like to collect a few more reviews, so

[PATCH 1/5] swiotlb: remove SWIOTLB_MAP_ERROR

2018-12-04 Thread Christoph Hellwig
We can use DMA_MAPPING_ERROR instead, which already maps to the same value. Signed-off-by: Christoph Hellwig --- drivers/xen/swiotlb-xen.c | 4 ++-- include/linux/swiotlb.h | 3 --- kernel/dma/swiotlb.c | 4 ++-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git

[PATCH 5/5] dma-direct: merge swiotlb_dma_ops into the dma_direct code

2018-12-04 Thread Christoph Hellwig
While the dma-direct code is (relatively) clean and simple we actually have to use the swiotlb ops for the mapping on many architectures due to devices with addressing limits. Instead of keeping two implementations around this commit allows the dma-direct implementation to call the swiotlb bounce

[PATCH 4/5] dma-direct: use dma_direct_map_page to implement dma_direct_map_sg

2018-12-04 Thread Christoph Hellwig
No need to duplicate the mapping logic. Signed-off-by: Christoph Hellwig --- kernel/dma/direct.c | 14 +- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c index edb24f94ea1e..d45306473c90 100644 --- a/kernel/dma/direct.c +++

[PATCH 3/5] dma-direct: improve addressability error reporting

2018-12-04 Thread Christoph Hellwig
Only report report a DMA addressability report once to avoid spewing the kernel log with repeated message. Also provide a stack trace to make it easy to find the actual caller that caused the problem. Last but not least move the actual check into the fast path and only leave the error reporting

[PATCH 2/5] swiotlb: remove dma_mark_clean

2018-12-04 Thread Christoph Hellwig
Instead of providing a special dma_mark_clean hook just for ia64, switch ia64 to use the normal arch_sync_dma_for_cpu hooks instead. This means that we now also set the PG_arch_1 bit for pages in the swiotlb buffer, which isn't stricly needed as we will never execute code out of the swiotlb

Re: [PATCH 2/4] dma-debug: Refactor dma_debug_entry allocation

2018-12-04 Thread Robin Murphy
On 04/12/2018 14:27, Christoph Hellwig wrote: On Mon, Dec 03, 2018 at 05:28:07PM +, Robin Murphy wrote: Make prealloc_memory() a little more general and robust so that it serves for runtime reallocations too. The first thing we can do with that is clean up dma_debug_resize_entries() quite a

Re: [PATCH 3/4] dma-debug: Dynamically expand the dma_debug_entry pool

2018-12-04 Thread Robin Murphy
On 04/12/2018 14:17, Christoph Hellwig wrote: On Tue, Dec 04, 2018 at 01:11:37PM +, Robin Murphy wrote: In fact, having got this far in, what I'd quite like to do is to get rid of dma_debug_resize_entries() such that we never need to free things at all, since then we could allocate whole

[PATCH] dma-mapping: remove a pointless memset in dma_atomic_pool_init

2018-12-04 Thread Christoph Hellwig
We already zero the memory after allocating it from the pool that this function fills, and having the memset here in this form means we can't support CMA highmem allocations. Signed-off-by: Christoph Hellwig Reported-by: Russell King - ARM Linux --- kernel/dma/remap.c | 1 - 1 file changed, 1

[PATCH] dma-mapping: simplify the dma_sync_single_range_for_{cpu, device} implementation

2018-12-04 Thread Christoph Hellwig
We can just call the regular calls after adding offset the the address instead of reimplementing them. Signed-off-by: Christoph Hellwig --- include/linux/dma-debug.h | 27 include/linux/dma-mapping.h | 34 +- kernel/dma/debug.c |

Re: [PATCH 1/1] iommu/arm-smmu: Add support to use Last level cache

2018-12-04 Thread Robin Murphy
On 04/12/2018 11:01, Vivek Gautam wrote: Qualcomm SoCs have an additional level of cache called as System cache, aka. Last level cache (LLC). This cache sits right before the DDR, and is tightly coupled with the memory controller. The cache is available to all the clients present in the SoC

Re: [PATCH v2 0/3] iommu/io-pgtable-arm-v7s: Use DMA32 zone for page tables

2018-12-04 Thread Vlastimil Babka
On 12/4/18 10:37 AM, Nicolas Boichat wrote: > On Sun, Nov 11, 2018 at 5:04 PM Nicolas Boichat wrote: >> >> This is a follow-up to the discussion in [1], to make sure that the page >> tables allocated by iommu/io-pgtable-arm-v7s are contained within 32-bit >> physical address space. >> >> [1] >>

Re: [RFC 4/4] dma-debug: Make leak-like behaviour apparent

2018-12-04 Thread Christoph Hellwig
On Mon, Dec 03, 2018 at 05:28:09PM +, Robin Murphy wrote: > Now that we can dynamically allocate DMA debug entries to cope with > drivers maintaining excessively large numbers of live mappings, a driver > which *does* actually have a bug leaking mappings (and is not unloaded) > will no longer

Re: [PATCH 3/4] dma-debug: Dynamically expand the dma_debug_entry pool

2018-12-04 Thread Christoph Hellwig
> + for (retry_count = 0; ; retry_count++) { > + spin_lock_irqsave(_entries_lock, flags); > + > + if (num_free_entries > 0) > + break; > > spin_unlock_irqrestore(_entries_lock, flags); Taking a spinlock just to read a single integer

Re: [PATCH 2/4] dma-debug: Refactor dma_debug_entry allocation

2018-12-04 Thread Christoph Hellwig
On Mon, Dec 03, 2018 at 05:28:07PM +, Robin Murphy wrote: > Make prealloc_memory() a little more general and robust so that it > serves for runtime reallocations too. The first thing we can do with > that is clean up dma_debug_resize_entries() quite a bit. Maybe also renamed it to

Re: [PATCH 1/4] dma-debug: Use pr_fmt()

2018-12-04 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, RFC] iommu/io-pgtable-arm-v7s: Use page_frag to request DMA32 memory

2018-12-04 Thread Christoph Hellwig
On Tue, Dec 04, 2018 at 04:23:00PM +0800, Nicolas Boichat wrote: > IOMMUs using ARMv7 short-descriptor format require page tables > (level 1 and 2) to be allocated within the first 4GB of RAM, even > on 64-bit systems. > > For level 1/2 tables, ensure GFP_DMA32 is used if CONFIG_ZONE_DMA32 > is

Re: use generic DMA mapping code in powerpc V4

2018-12-04 Thread Christoph Hellwig
On Tue, Dec 04, 2018 at 10:53:39AM +0100, Christian Zigotzky wrote: > I don't know why this kernel doesn't recognize the hard disks connected to > my physical P5020 board and why the onboard ethernet on my PASEMI board > doesn't work. (dma_direct_map_page: overflow) Do you know if this actually

Re: [PATCH 5/9] dma-mapping: support highmem in the generic remap allocator

2018-12-04 Thread Christoph Hellwig
On Tue, Dec 04, 2018 at 09:38:02AM +0100, Marek Szyprowski wrote: > Hi All, > > On 2018-11-30 20:05, Robin Murphy wrote: > > On 05/11/2018 12:19, Christoph Hellwig wrote: > >> By using __dma_direct_alloc_pages we can deal entirely with struct page > >> instead of having to derive a kernel virtual

Re: [PATCH 4/9] dma-mapping: move the arm64 ncoherent alloc/free support to common code

2018-12-04 Thread Christoph Hellwig
> > +int __init dma_atomic_pool_init(gfp_t gfp, pgprot_t prot) > > +{ > > + unsigned int pool_size_order = get_order(atomic_pool_size); > > + unsigned long nr_pages = atomic_pool_size >> PAGE_SHIFT; > > + struct page *page; > > + void *addr; > > + int ret; > > + > > + if

Re: [PATCH 3/4] dma-debug: Dynamically expand the dma_debug_entry pool

2018-12-04 Thread Christoph Hellwig
On Tue, Dec 04, 2018 at 01:11:37PM +, Robin Murphy wrote: > In fact, having got this far in, what I'd quite like to do is to get rid of > dma_debug_resize_entries() such that we never need to free things at all, > since then we could allocate whole pages as blocks of entries to save on >

RE: [PATCH v2] dma-debug: Kconfig for PREALLOC_DMA_DEBUG_ENTRIES

2018-12-04 Thread David Laight
From: Qian Cai > Sent: 30 November 2018 21:48 > To: h...@lst.de; m.szyprow...@samsung.com; robin.mur...@arm.com > Cc: yisen.zhu...@huawei.com; salil.me...@huawei.com; john.ga...@huawei.com; > linux...@huawei.com; > iommu@lists.linux-foundation.org; net...@vger.kernel.org; >

Re: [PATCH 3/4] dma-debug: Dynamically expand the dma_debug_entry pool

2018-12-04 Thread Robin Murphy
Hi John, On 03/12/2018 18:23, John Garry wrote: On 03/12/2018 17:28, Robin Murphy wrote: Certain drivers such as large multi-queue network adapters can use pools of mapped DMA buffers larger than the default dma_debug_entry pool of 65536 entries, with the result that merely probing such a

[PATCH 1/1] iommu/arm-smmu: Add support to use Last level cache

2018-12-04 Thread Vivek Gautam
Qualcomm SoCs have an additional level of cache called as System cache, aka. Last level cache (LLC). This cache sits right before the DDR, and is tightly coupled with the memory controller. The cache is available to all the clients present in the SoC system. The clients request their slices from

Re: [PATCH 4/9] dma-mapping: move the arm64 ncoherent alloc/free support to common code

2018-12-04 Thread Russell King - ARM Linux
On Mon, Nov 05, 2018 at 01:19:26PM +0100, Christoph Hellwig wrote: > The arm64 codebase to implement coherent dma allocation for architectures > with non-coherent DMA is a good start for a generic implementation, given > that is uses the generic remap helpers, provides the atomic pool for >

Re: use generic DMA mapping code in powerpc V4

2018-12-04 Thread Christian Zigotzky
On 04 December 2018 at 08:31AM, Christian Zigotzky wrote: Hi All, Could you please test Christoph's kernel on your PASEMI and NXP boards? Download: 'git clone git://git.infradead.org/users/hch/misc.git -b powerpc-dma.5 a' Thanks, Christian I successfully tested this kernel on a virtual

Re: [PATCH v2 0/3] iommu/io-pgtable-arm-v7s: Use DMA32 zone for page tables

2018-12-04 Thread Nicolas Boichat
On Sun, Nov 11, 2018 at 5:04 PM Nicolas Boichat wrote: > > This is a follow-up to the discussion in [1], to make sure that the page > tables allocated by iommu/io-pgtable-arm-v7s are contained within 32-bit > physical address space. > > [1] >

Re: [PATCH v3 1/4] PCI / ACPI: Identify untrusted PCI devices

2018-12-04 Thread Mika Westerberg
On Mon, Dec 03, 2018 at 06:28:00PM -0600, Bjorn Helgaas wrote: > On Thu, Nov 29, 2018 at 06:51:50PM +0300, Mika Westerberg wrote: > > A malicious PCI device may use DMA to attack the system. An external > > Thunderbolt port is a convenient point to attach such a device. The OS > > may use IOMMU to

Re: [PATCH 5/9] dma-mapping: support highmem in the generic remap allocator

2018-12-04 Thread Marek Szyprowski
Hi All, On 2018-11-30 20:05, Robin Murphy wrote: > On 05/11/2018 12:19, Christoph Hellwig wrote: >> By using __dma_direct_alloc_pages we can deal entirely with struct page >> instead of having to derive a kernel virtual address. > > Simple enough :) > > Reviewed-by: Robin Murphy This patch has

[PATCH v3, RFC] iommu/io-pgtable-arm-v7s: Use page_frag to request DMA32 memory

2018-12-04 Thread Nicolas Boichat
IOMMUs using ARMv7 short-descriptor format require page tables (level 1 and 2) to be allocated within the first 4GB of RAM, even on 64-bit systems. For level 1/2 tables, ensure GFP_DMA32 is used if CONFIG_ZONE_DMA32 is defined (e.g. on arm64 platforms). For level 2 tables (1 KB), we use