[PATCH] dma-mapping: do not mapping module memory

2019-11-29 Thread lijiazi
On ARM, x86_64, sparc64 platform, virt_to_page only convert a _valid_ virtual address to struct page *, virt_addr_valid(x) indicates whether a virtual address is valid. If ptr is point to a static variable in module area, virt_to_page will return a invalid value. Signed-off-by: lijiazi --- inclu

[git pull] IOMMU Updates for Linux v5.5

2019-11-29 Thread Joerg Roedel
Hi Linus, The following changes since commit 31f4f5b495a62c9a8b15b1c3581acd5efeb9af8c: Linux 5.4-rc7 (2019-11-10 16:17:15 -0800) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu.git tags/iommu-updates-v5.5 for you to fetch changes up to 9b3a

[PATCH v4 1/2] PCI: Add parameter nr_devfns to pci_add_dma_alias

2019-11-29 Thread James Sewart via iommu
pci_add_dma_alias can now be used to create a dma alias for a range of devfns. Signed-off-by: James Sewart --- drivers/pci/pci.c| 23 ++- drivers/pci/quirks.c | 14 +++--- include/linux/pci.h | 2 +- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git

[PATCH v4 2/2] PCI: Add DMA alias quirk for PLX PEX NTB

2019-11-29 Thread James Sewart via iommu
The PLX PEX NTB forwards DMA transactions using Requester ID's that don't exist as PCI devices. The devfn for a transaction is used as an index into a lookup table storing the origin of a transaction on the other side of the bridge. This patch aliases all possible devfn's to the NTB device so that

Re: [Patch v2 2/3] iommu: optimize iova_magazine_free_pfns()

2019-11-29 Thread John Garry
On 29/11/2019 00:48, Cong Wang wrote: If the maganize is empty, iova_magazine_free_pfns() should magazine be a nop, however it misses the case of mag->size==0. So we should just call iova_magazine_empty(). This should reduce the contention on iovad->iova_rbtree_lock a little bit. Cc: Joerg

Re: [Patch v2 3/3] iommu: avoid taking iova_rbtree_lock twice

2019-11-29 Thread John Garry
On 29/11/2019 00:48, Cong Wang wrote: Both find_iova() and __free_iova() take iova_rbtree_lock, there is no reason to take and release it twice inside free_iova(). Fold them into the critical section by calling the unlock versions instead. Since generally the iova would be non-NULL, this seems

[PATCH v2] iommu/amd: Disable IOMMU on Stoney Ridge systems

2019-11-29 Thread Kai-Heng Feng
Serious screen flickering when Stoney Ridge outputs to a 4K monitor. According to Alex Deucher, IOMMU isn't enabled on Windows, so let's do the same here to avoid screen flickering on 4K monitor. Cc: Alex Deucher Bug: https://gitlab.freedesktop.org/drm/amd/issues/961 Signed-off-by: Kai-Heng Feng

Re: [Patch v2 1/3] iommu: match the original algorithm

2019-11-29 Thread John Garry
On 29/11/2019 00:48, Cong Wang wrote: The IOVA cache algorithm implemented in IOMMU code does not exactly match the original algorithm described in the paper. which paper? Particularly, it doesn't need to free the loaded empty magazine when trying to put it back to global depot. To make it w

Re: [PATCH v4 1/2] PCI: Add parameter nr_devfns to pci_add_dma_alias

2019-11-29 Thread Logan Gunthorpe
On 2019-11-29 5:49 a.m., James Sewart wrote: > pci_add_dma_alias can now be used to create a dma alias for a range of > devfns. > > Signed-off-by: James Sewart > --- > drivers/pci/pci.c| 23 ++- > drivers/pci/quirks.c | 14 +++--- > include/linux/pci.h | 2 +-

Re: [PATCH v4 1/2] PCI: Add parameter nr_devfns to pci_add_dma_alias

2019-11-29 Thread James Sewart via iommu
> On 29 Nov 2019, at 16:50, Logan Gunthorpe wrote: > > > > On 2019-11-29 5:49 a.m., James Sewart wrote: >> pci_add_dma_alias can now be used to create a dma alias for a range of >> devfns. >> >> Signed-off-by: James Sewart >> --- >> drivers/pci/pci.c| 23 ++- >> drive

Re: [PATCH v4 1/2] PCI: Add parameter nr_devfns to pci_add_dma_alias

2019-11-29 Thread Logan Gunthorpe
On 2019-11-29 10:19 a.m., James Sewart wrote: > > >> On 29 Nov 2019, at 16:50, Logan Gunthorpe wrote: >> >> >> >> On 2019-11-29 5:49 a.m., James Sewart wrote: >>> pci_add_dma_alias can now be used to create a dma alias for a range of >>> devfns. >>> >>> Signed-off-by: James Sewart >>> --- >>>

[PATCH v5 3/3] PCI: Add DMA alias quirk for PLX PEX NTB

2019-11-29 Thread James Sewart via iommu
The PLX PEX NTB forwards DMA transactions using Requester ID's that don't exist as PCI devices. The devfn for a transaction is used as an index into a lookup table storing the origin of a transaction on the other side of the bridge. This patch aliases all possible devfn's to the NTB device so that

Re: [PATCH v5 1/3] PCI: Fix off by one in dma_alias_mask allocation size

2019-11-29 Thread Logan Gunthorpe
On 2019-11-29 10:56 a.m., James Sewart wrote: > The number of possible devfns is 256 so the size of the bitmap for > allocations should be U8_MAX+1. > > Signed-off-by: James Sewart Looks good to me. Thanks! For the whole series: Reviewed-by: Logan Gunthorpe > --- > drivers/pci/pci.c|

[PATCH v5 1/3] PCI: Fix off by one in dma_alias_mask allocation size

2019-11-29 Thread James Sewart via iommu
The number of possible devfns is 256 so the size of the bitmap for allocations should be U8_MAX+1. Signed-off-by: James Sewart --- drivers/pci/pci.c| 2 +- drivers/pci/search.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index

[PATCH v5 2/3] PCI: Add parameter nr_devfns to pci_add_dma_alias

2019-11-29 Thread James Sewart via iommu
pci_add_dma_alias can now be used to create a dma alias for a range of devfns. Signed-off-by: James Sewart --- drivers/pci/pci.c| 23 ++- drivers/pci/quirks.c | 14 +++--- include/linux/pci.h | 2 +- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git

dma-mapping: use bit macros

2019-11-29 Thread Heiner Kallweit
Not necessarily a big leap for mankind, but using bit macros makes the code better readable, especially the definition of DMA_BIT_MASK is more intuitive. Signed-off-by: Heiner Kallweit --- include/linux/dma-mapping.h | 21 +++-- 1 file changed, 11 insertions(+), 10 deletions(-)

Re: [Patch v2 1/3] iommu: match the original algorithm

2019-11-29 Thread Cong Wang
On Fri, Nov 29, 2019 at 6:43 AM John Garry wrote: > > On 29/11/2019 00:48, Cong Wang wrote: > > The IOVA cache algorithm implemented in IOMMU code does not > > exactly match the original algorithm described in the paper. > > > > which paper? It's in drivers/iommu/iova.c, from line 769: 769 /*

Re: [Patch v2 2/3] iommu: optimize iova_magazine_free_pfns()

2019-11-29 Thread Cong Wang
On Fri, Nov 29, 2019 at 5:24 AM John Garry wrote: > > On 29/11/2019 00:48, Cong Wang wrote: > > If the maganize is empty, iova_magazine_free_pfns() should > > magazine Good catch! > > > be a nop, however it misses the case of mag->size==0. So we > > should just call iova_magazine_empty(). > > >

Re: [Patch v2 3/3] iommu: avoid taking iova_rbtree_lock twice

2019-11-29 Thread Cong Wang
On Fri, Nov 29, 2019 at 5:34 AM John Garry wrote: > > On 29/11/2019 00:48, Cong Wang wrote: > > Both find_iova() and __free_iova() take iova_rbtree_lock, > > there is no reason to take and release it twice inside > > free_iova(). > > > > Fold them into the critical section by calling the unlock >