Re: [PATCH v4 0/9] mm: Use vm_map_pages() and vm_map_pages_zero() API

2019-02-20 Thread Souptick Joarder
On Fri, Feb 15, 2019 at 8:06 AM Souptick Joarder wrote: > > Previouly drivers have their own way of mapping range of > kernel pages/memory into user vma and this was done by > invoking vm_insert_page() within a loop. > > As this pattern is common across different drivers, it can > be generalized

Re: [PATCH 7/7] iommu/ipmmu-vmsa: Add suspend/resume support

2019-02-20 Thread Geert Uytterhoeven
Hi Laurent, On Wed, Feb 20, 2019 at 5:11 PM Laurent Pinchart wrote: > On Wed, Feb 20, 2019 at 05:05:49PM +0100, Geert Uytterhoeven wrote: > > On Wed, Feb 20, 2019 at 4:42 PM Laurent Pinchart wrote: > > > On Wed, Feb 20, 2019 at 04:05:31PM +0100, Geert Uytterhoeven wrote: > > >> During PSCI

[PATCH] iommu/dmar: fix buffer overflow during PCI bus notification

2019-02-20 Thread Julia Cartwright
Commit 57384592c433 ("iommu/vt-d: Store bus information in RMRR PCI device path") changed the type of the path data, however, the change in path type was not reflected in size calculations. Update to use the correct type and prevent a buffer overflow. This bug manifests in systems with deep PCI

Re: [PATCH] iommu/dmar: fix buffer overflow during PCI bus notification

2019-02-20 Thread Julia Cartwright
On Wed, Feb 20, 2019 at 10:46:31AM -0600, Julia Cartwright wrote: > Commit 57384592c433 ("iommu/vt-d: Store bus information in RMRR PCI > device path") changed the type of the path data, however, the change in > path type was not reflected in size calculations. Update to use the > correct type

Re: [PATCH 7/7] iommu/ipmmu-vmsa: Add suspend/resume support

2019-02-20 Thread Laurent Pinchart
Hi Geert, On Wed, Feb 20, 2019 at 05:05:49PM +0100, Geert Uytterhoeven wrote: > On Wed, Feb 20, 2019 at 4:42 PM Laurent Pinchart wrote: > > On Wed, Feb 20, 2019 at 04:05:31PM +0100, Geert Uytterhoeven wrote: > >> During PSCI system suspend, R-Car Gen3 SoCs are powered down, and all > >> IPMMU

Re: [PATCH 7/7] iommu/ipmmu-vmsa: Add suspend/resume support

2019-02-20 Thread Geert Uytterhoeven
Hi Laurent, On Wed, Feb 20, 2019 at 4:42 PM Laurent Pinchart wrote: > On Wed, Feb 20, 2019 at 04:05:31PM +0100, Geert Uytterhoeven wrote: > > During PSCI system suspend, R-Car Gen3 SoCs are powered down, and all > > IPMMU state is lost. Hence after s2ram, devices wired behind an IPMMU, > > and

Re: [PATCH 6/7] iommu/ipmmu-vmsa: Extract hardware context initialization

2019-02-20 Thread Geert Uytterhoeven
Hi Laurent, On Wed, Feb 20, 2019 at 4:35 PM Laurent Pinchart wrote: > On Wed, Feb 20, 2019 at 04:05:30PM +0100, Geert Uytterhoeven wrote: > > ipmmu_domain_init_context() takes care of (1) initializing the software > > domain, and (2) initializing the hardware context for the domain. > > > >

Re: [PATCH 5/7] iommu/ipmmu-vmsa: Move num_utlbs to SoC-specific features

2019-02-20 Thread Laurent Pinchart
Hi Geert, Thank you for the patch. On Wed, Feb 20, 2019 at 04:05:29PM +0100, Geert Uytterhoeven wrote: > The maximum number of micro-TLBs per IPMMU instance is not fixed, but > depends on the SoC type. Hence move it from struct ipmmu_vmsa_device to > struct ipmmu_features, and set up the

Re: [PATCH 7/7] iommu/ipmmu-vmsa: Add suspend/resume support

2019-02-20 Thread Laurent Pinchart
Hi Geert, Thank you for the patch. On Wed, Feb 20, 2019 at 04:05:31PM +0100, Geert Uytterhoeven wrote: > During PSCI system suspend, R-Car Gen3 SoCs are powered down, and all > IPMMU state is lost. Hence after s2ram, devices wired behind an IPMMU, > and configured to use it, will see their DMA

Re: [PATCH 3/7] iommu/ipmmu-vmsa: Prepare to handle 40-bit error addresses

2019-02-20 Thread Geert Uytterhoeven
Hi Laurent, On Wed, Feb 20, 2019 at 4:31 PM Laurent Pinchart wrote: > On Wed, Feb 20, 2019 at 04:05:27PM +0100, Geert Uytterhoeven wrote: > > On R-Car Gen3, the faulting virtual address is a 40-bit address, and > > comprised of two registers. Read the upper address part, and combine > > both

Re: [PATCH 6/7] iommu/ipmmu-vmsa: Extract hardware context initialization

2019-02-20 Thread Laurent Pinchart
Hi Geert, Thank you for the patch. On Wed, Feb 20, 2019 at 04:05:30PM +0100, Geert Uytterhoeven wrote: > ipmmu_domain_init_context() takes care of (1) initializing the software > domain, and (2) initializing the hardware context for the domain. > > Extract the code to initialize the hardware

Re: [PATCH 3/7] iommu/ipmmu-vmsa: Prepare to handle 40-bit error addresses

2019-02-20 Thread Laurent Pinchart
Hi Geert, Thank you for the patch. On Wed, Feb 20, 2019 at 04:05:27PM +0100, Geert Uytterhoeven wrote: > On R-Car Gen3, the faulting virtual address is a 40-bit address, and > comprised of two registers. Read the upper address part, and combine > both parts, when running on a 64-bit system. >

Re: [PATCH 4/7] iommu/ipmmu-vmsa: Make IPMMU_CTX_MAX unsigned

2019-02-20 Thread Laurent Pinchart
Hi Geert, Thank you for the patch. On Wed, Feb 20, 2019 at 04:05:28PM +0100, Geert Uytterhoeven wrote: > Make the IPMMU_CTX_MAX constant unsigned, to match the type of > ipmmu_features.number_of_contexts. > > This allows to use plain min() instead of type-casting min_t(). > > Signed-off-by:

Re: [PATCH 2/7] iommu/ipmmu-vmsa: Call ipmmu_ctx_write_root() instead of open coding

2019-02-20 Thread Laurent Pinchart
Hi Geert, Thank you for the patch. On Wed, Feb 20, 2019 at 04:05:26PM +0100, Geert Uytterhoeven wrote: > There is a helper to write to the root IPMMU instance's registers, so > let's use it. > > Signed-off-by: Geert Uytterhoeven > --- > drivers/iommu/ipmmu-vmsa.c | 3 +-- > 1 file changed, 1

Re: [PATCH 1/7] iommu/ipmmu-vmsa: Link IOMMUs and devices in sysfs

2019-02-20 Thread Laurent Pinchart
Hi Geert, Thank you for the patch. On Wed, Feb 20, 2019 at 04:05:25PM +0100, Geert Uytterhoeven wrote: > As of commit 7af9a5fdb9e0ca33 ("iommu/ipmmu-vmsa: Use > iommu_device_sysfs_add()/remove()"), IOMMU devices show up under > /sys/class/iommus/, but their "devices" subdirectories are empty. >

Re: [PATCHv7] x86/kdump: bugfix, make the behavior of crashkernel=X consistent with kaslr

2019-02-20 Thread Pingfan Liu
On Mon, Feb 18, 2019 at 9:48 AM Dave Young wrote: > > On 02/15/19 at 11:24am, Borislav Petkov wrote: > > On Tue, Feb 12, 2019 at 04:48:16AM +0800, Dave Young wrote: > > > Even we make it automatic in kernel, but we have to have some default > > > value for swiotlb in case crashkernel can not find

Re: [PATCHv7] x86/kdump: bugfix, make the behavior of crashkernel=X consistent with kaslr

2019-02-20 Thread Pingfan Liu
On Wed, Feb 20, 2019 at 5:41 PM Dave Young wrote: > > On 02/20/19 at 09:32am, Borislav Petkov wrote: > > On Mon, Feb 18, 2019 at 09:48:20AM +0800, Dave Young wrote: > > > It is ideal if kernel can do it automatically, but I'm not sure if > > > kernel can predict the swiotlb reserved size

[PATCH 1/7] iommu/ipmmu-vmsa: Link IOMMUs and devices in sysfs

2019-02-20 Thread Geert Uytterhoeven
As of commit 7af9a5fdb9e0ca33 ("iommu/ipmmu-vmsa: Use iommu_device_sysfs_add()/remove()"), IOMMU devices show up under /sys/class/iommus/, but their "devices" subdirectories are empty. Likewise, devices tied to an IOMMU do not have an "iommu" backlink. Make sure all links are created, on both

[PATCH 7/7] iommu/ipmmu-vmsa: Add suspend/resume support

2019-02-20 Thread Geert Uytterhoeven
During PSCI system suspend, R-Car Gen3 SoCs are powered down, and all IPMMU state is lost. Hence after s2ram, devices wired behind an IPMMU, and configured to use it, will see their DMA operations hang. To fix this, restore all IPMMU contexts, and re-enable all active micro-TLBs during system

[PATCH 0/7] iommu/ipmmu-vmsa: Suspend/resume support and assorted cleanups

2019-02-20 Thread Geert Uytterhoeven
Hi Jörg, Magnus, On R-Car Gen3 systems with PSCI, PSCI may power down the SoC during system suspend, thus losing all IOMMU state. Hence after s2ram, devices behind an IPMMU (e.g. SATA), and configured to use it, will fail to complete their I/O operations. This patch series adds

[PATCH 2/7] iommu/ipmmu-vmsa: Call ipmmu_ctx_write_root() instead of open coding

2019-02-20 Thread Geert Uytterhoeven
There is a helper to write to the root IPMMU instance's registers, so let's use it. Signed-off-by: Geert Uytterhoeven --- drivers/iommu/ipmmu-vmsa.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c index

[PATCH 5/7] iommu/ipmmu-vmsa: Move num_utlbs to SoC-specific features

2019-02-20 Thread Geert Uytterhoeven
The maximum number of micro-TLBs per IPMMU instance is not fixed, but depends on the SoC type. Hence move it from struct ipmmu_vmsa_device to struct ipmmu_features, and set up the correct value for both R-Car Gen2 and Gen3 SoCs. Note that currently no code uses this value. Signed-off-by: Geert

[PATCH 6/7] iommu/ipmmu-vmsa: Extract hardware context initialization

2019-02-20 Thread Geert Uytterhoeven
ipmmu_domain_init_context() takes care of (1) initializing the software domain, and (2) initializing the hardware context for the domain. Extract the code to initialize the hardware context into a new subroutine ipmmu_context_init(), to prepare for later reuse. Signed-off-by: Geert Uytterhoeven

[PATCH 3/7] iommu/ipmmu-vmsa: Prepare to handle 40-bit error addresses

2019-02-20 Thread Geert Uytterhoeven
On R-Car Gen3, the faulting virtual address is a 40-bit address, and comprised of two registers. Read the upper address part, and combine both parts, when running on a 64-bit system. Signed-off-by: Geert Uytterhoeven --- Apart from this, the driver doesn't support 40-bit IOVA addresses yet. ---

[PATCH 4/7] iommu/ipmmu-vmsa: Make IPMMU_CTX_MAX unsigned

2019-02-20 Thread Geert Uytterhoeven
Make the IPMMU_CTX_MAX constant unsigned, to match the type of ipmmu_features.number_of_contexts. This allows to use plain min() instead of type-casting min_t(). Signed-off-by: Geert Uytterhoeven --- drivers/iommu/ipmmu-vmsa.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff

[PATCH 1/1] iommu: Bind process address spaces to devices

2019-02-20 Thread Jean-Philippe Brucker
Add bind() and unbind() operations to the IOMMU API. Bind() returns a PASID to the device driver (by convention, a 20-bit system-wide ID representing the address space). When programming DMA addresses, device drivers include this PASID in a device-specific manner, to let the device access the

[PATCH 0/1] IOMMU SVA device driver interface

2019-02-20 Thread Jean-Philippe Brucker
This series focuses on the device driver API for SVA, as I'd like to get at least parts of it merged in v5.2 [1]. If we can get consensus on the interface, it will be easier for device drivers to start adding SVA support while we're improving the IOMMU side. Since v3 [2] I changed the interface

Re: [PATCH 2/3] iommu: Document iommu_ops.iotlb_sync_map()

2019-02-20 Thread Dmitry Osipenko
20.02.2019 16:00, Geert Uytterhoeven пишет: > Add missing kerneldoc for iommu_ops.iotlb_sync_map(). > > Fixes: 1d7ae53b152dbc5b ("iommu: Introduce iotlb_sync_map callback") > Signed-off-by: Geert Uytterhoeven > --- > include/linux/iommu.h | 1 + > 1 file changed, 1 insertion(+) > > diff --git

[PATCH 0/3] iommu: Kerneldoc improvements

2019-02-20 Thread Geert Uytterhoeven
Hi Jörg, This series contains a fix for an incorrect kerneldoc parameter, and adds the missing kerneldoc for two recently added IOMMU methods. Thanks! Geert Uytterhoeven (3): iommu: Fix kerneldoc for iommu_ops.flush_iotlb_all() iommu: Document iommu_ops.iotlb_sync_map() iommu:

[PATCH 3/3] iommu: Document iommu_ops.is_attach_deferred()

2019-02-20 Thread Geert Uytterhoeven
Add missing kerneldoc for iommu_ops.is_attach_deferred(). Fixes: e01d1913b0d08171 ("iommu: Add is_attach_deferred call-back to iommu-ops") Signed-off-by: Geert Uytterhoeven --- include/linux/iommu.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/iommu.h

[PATCH 2/3] iommu: Document iommu_ops.iotlb_sync_map()

2019-02-20 Thread Geert Uytterhoeven
Add missing kerneldoc for iommu_ops.iotlb_sync_map(). Fixes: 1d7ae53b152dbc5b ("iommu: Introduce iotlb_sync_map callback") Signed-off-by: Geert Uytterhoeven --- include/linux/iommu.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index

[PATCH 1/3] iommu: Fix kerneldoc for iommu_ops.flush_iotlb_all()

2019-02-20 Thread Geert Uytterhoeven
While the API wrapper is called iommu_flush_tlb_all(), the actual iommu_ops method is called .flush_iotlb_all(), not .flush_tlb_all(). Fixes: add02cfdc9bc2987 ("iommu: Introduce Interface for IOMMU TLB Flushing") Signed-off-by: Geert Uytterhoeven --- include/linux/iommu.h | 2 +- 1 file

[PATCH] iommu: Fix IOMMU debugfs fallout

2019-02-20 Thread Geert Uytterhoeven
A change made in the final version of IOMMU debugfs support replaced the public function iommu_debugfs_new_driver_dir() by the public dentry iommu_debugfs_dir in , but forgot to update both the implementation in iommu-debugfs.c, and the patch description. Fix this by exporting iommu_debugfs_dir,

Re: [PATCHv7] x86/kdump: bugfix, make the behavior of crashkernel=X consistent with kaslr

2019-02-20 Thread Dave Young
On 02/20/19 at 09:32am, Borislav Petkov wrote: > On Mon, Feb 18, 2019 at 09:48:20AM +0800, Dave Young wrote: > > It is ideal if kernel can do it automatically, but I'm not sure if > > kernel can predict the swiotlb reserved size automatically. > > Do you see how even more absurd this gets? > >

Re: [PATCH v6 21/22] iommu/mediatek: Fix iova_to_phys PA start for 4GB mode

2019-02-20 Thread Yong Wu
On Tue, 2019-02-19 at 15:33 -0800, Evan Green wrote: > On Sun, Feb 17, 2019 at 1:09 AM Yong Wu wrote: > > > > In the 4GB mode, the physical address is remapped, > > > > Here is the detailed remap relationship. > > CPU PA ->HW PA > > 0x4000_ 0x1_4000_ (Add bit32) > >

Re: [PATCHv7] x86/kdump: bugfix, make the behavior of crashkernel=X consistent with kaslr

2019-02-20 Thread Borislav Petkov
On Mon, Feb 18, 2019 at 09:48:20AM +0800, Dave Young wrote: > It is ideal if kernel can do it automatically, but I'm not sure if > kernel can predict the swiotlb reserved size automatically. Do you see how even more absurd this gets? If the kernel cannot know the swiotlb reserved size