diff mbox series

[kernel,v2] powerpc/powernv/ioda: Remove explicit max window size check

Message ID 20171107034301.35120-1-aik@ozlabs.ru (mailing list archive)
State Accepted
Commit 9003a249815a15704f415954039d1c7ea27da9ad
Headers show
Series [kernel,v2] powerpc/powernv/ioda: Remove explicit max window size check | expand

Commit Message

Alexey Kardashevskiy Nov. 7, 2017, 3:43 a.m. UTC
DMA windows can only have a size of power of two on IODA2 hardware and
using memory_hotplug_max() to determine the upper limit won't work
correcly if it returns not power of two value.

This removes the check as the platform code does this check in
pnv_pci_ioda2_setup_default_config() anyway; the other client is VFIO
and that thing checks against locked_vm limit which prevents the userspace
from locking too much memory.

It is expected to impact DPDK on machines with non-power-of-two RAM size,
mostly. KVM guests are less likely to be affected as usually guests get
less than half of hosts RAM.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
Changes:
v2:
* instead of relaxing the check, this simply removes it
---
 arch/powerpc/platforms/powernv/pci-ioda.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

David Gibson Nov. 13, 2017, 11:52 p.m. UTC | #1
On Tue, Nov 07, 2017 at 02:43:01PM +1100, Alexey Kardashevskiy wrote:
> DMA windows can only have a size of power of two on IODA2 hardware and
> using memory_hotplug_max() to determine the upper limit won't work
> correcly if it returns not power of two value.
> 
> This removes the check as the platform code does this check in
> pnv_pci_ioda2_setup_default_config() anyway; the other client is VFIO
> and that thing checks against locked_vm limit which prevents the userspace
> from locking too much memory.
> 
> It is expected to impact DPDK on machines with non-power-of-two RAM size,
> mostly. KVM guests are less likely to be affected as usually guests get
> less than half of hosts RAM.
> 
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

This _can_ be called with essentially arbitrary window_size via the
VFIO code.  However, that should be constrained by the locked memory
limit, which is checked before this gets called.

> ---
> Changes:
> v2:
> * instead of relaxing the check, this simply removes it
> ---
>  arch/powerpc/platforms/powernv/pci-ioda.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
> index 1de94fb..433cf84 100644
> --- a/arch/powerpc/platforms/powernv/pci-ioda.c
> +++ b/arch/powerpc/platforms/powernv/pci-ioda.c
> @@ -2776,7 +2776,7 @@ static long pnv_pci_ioda2_table_alloc_pages(int nid, __u64 bus_offset,
>  	if (!levels || (levels > POWERNV_IOMMU_MAX_LEVELS))
>  		return -EINVAL;
>  
> -	if ((window_size > memory_hotplug_max()) || !is_power_of_2(window_size))
> +	if (!is_power_of_2(window_size))
>  		return -EINVAL;
>  
>  	/* Adjust direct table size from window_size and levels */
Michael Ellerman Nov. 14, 2017, 11:12 a.m. UTC | #2
On Tue, 2017-11-07 at 03:43:01 UTC, Alexey Kardashevskiy wrote:
> DMA windows can only have a size of power of two on IODA2 hardware and
> using memory_hotplug_max() to determine the upper limit won't work
> correcly if it returns not power of two value.
> 
> This removes the check as the platform code does this check in
> pnv_pci_ioda2_setup_default_config() anyway; the other client is VFIO
> and that thing checks against locked_vm limit which prevents the userspace
> from locking too much memory.
> 
> It is expected to impact DPDK on machines with non-power-of-two RAM size,
> mostly. KVM guests are less likely to be affected as usually guests get
> less than half of hosts RAM.
> 
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/9003a249815a15704f415954039d1c

cheers
diff mbox series

Patch

diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index 1de94fb..433cf84 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -2776,7 +2776,7 @@  static long pnv_pci_ioda2_table_alloc_pages(int nid, __u64 bus_offset,
 	if (!levels || (levels > POWERNV_IOMMU_MAX_LEVELS))
 		return -EINVAL;
 
-	if ((window_size > memory_hotplug_max()) || !is_power_of_2(window_size))
+	if (!is_power_of_2(window_size))
 		return -EINVAL;
 
 	/* Adjust direct table size from window_size and levels */