Re: [PATCH 3/3] powerpc/powernv/npu: Remove atsd_threshold debugfs setting

2018-10-02 Thread Alistair Popple
Looks good to me, thanks! Reviewed-by: Alistair Popple On Thursday, 27 September 2018 4:23:11 PM AEST Mark Hairgrove wrote: > This threshold is no longer used now that all invalidates issue a single > ATSD to each active NPU. > > Signed-off-by: Mark Hairgrove > --- > arch

Re: [PATCH 1/3] powerpc/powernv/npu: Reduce eieio usage when issuing ATSD invalidates

2018-10-02 Thread Alistair Popple
Thanks, this looks good to me. Reviewed-by: Alistair Popple On Thursday, 27 September 2018 4:23:09 PM AEST Mark Hairgrove wrote: > There are two types of ATSDs issued to the NPU: invalidates targeting a > specific virtual address and invalidates targeting the whole address > space

Re: [PATCH 2/3] powerpc/powernv/npu: Use size-based ATSD invalidates

2018-10-02 Thread Alistair Popple
> > > > We also support 4K page sizes on PPC. If I am not mistaken this means every > > ATSD > > would invalidate the entire GPU TLB for a the given PID on those systems. > > Could > > we change the above check to `if (size <= PAGE_64K)` to avoid this? > > PPC supports 4K pages but the GPU ATS

Re: [PATCH v2 1/3] powerpc/powernv/npu: Reduce eieio usage when issuing ATSD invalidates

2018-10-03 Thread Alistair Popple
Reviewed-by: Alistair Popple On Wednesday, 3 October 2018 11:51:32 AM AEST Mark Hairgrove wrote: > There are two types of ATSDs issued to the NPU: invalidates targeting a > specific virtual address and invalidates targeting the whole address > space. In both cases prior to this ch

Re: [PATCH v2 2/3] powerpc/powernv/npu: Use size-based ATSD invalidates

2018-10-03 Thread Alistair Popple
Reviewed-By: Alistair Popple On Wednesday, 3 October 2018 11:51:33 AM AEST Mark Hairgrove wrote: > Prior to this change only two types of ATSDs were issued to the NPU: > invalidates targeting a single page and invalidates targeting the whole > address space. The crossover point happen

Re: [PATCH v2 3/3] powerpc/powernv/npu: Remove atsd_threshold debugfs setting

2018-10-03 Thread Alistair Popple
Reviewed-by: Alistair Popple On Wednesday, 3 October 2018 11:51:34 AM AEST Mark Hairgrove wrote: > This threshold is no longer used now that all invalidates issue a single > ATSD to each active NPU. > > Signed-off-by: Mark Hairgrove > --- > arch/powerpc/platforms/powern

Re: [PATCH kernel v2] powerpc/ioda/npu: Call skiboot's hot reset hook when disabling NPU2

2018-10-15 Thread Alistair Popple
Hi Alexey, Looking at the skiboot side I think we only fence the NVLink bricks as part of a PCIe function level reset (FLR) rather than a PCI Hot or Fundamental reset which I believe is what the code here does. So to fence the bricks you would need to do either a FLR on the given link or alter Ski

Re: [PATCH kernel v2] powerpc/ioda/npu: Call skiboot's hot reset hook when disabling NPU2

2018-10-15 Thread Alistair Popple
Hi Alexey, On Tuesday, 16 October 2018 12:37:49 PM AEDT Alexey Kardashevskiy wrote: > > On 16/10/2018 11:38, Alistair Popple wrote: > > Hi Alexey, > > > > Looking at the skiboot side I think we only fence the NVLink bricks as part > > of a > > PCIe function

Re: [PATCH kernel v2] powerpc/ioda/npu: Call skiboot's hot reset hook when disabling NPU2

2018-10-15 Thread Alistair Popple
> reset_ntl() does what npu2_dev_procedure_reset() does plus more stuff, > there nothing really in npu2_dev_procedure_reset() which reset_ntl() > does not do already from the hardware standpoint. And it did stop HMIs > for me though. > > but ok, what will be sufficient then if not reset_ntl()? Ar

Re: [PATCH kernel v2] powerpc/ioda/npu: Call skiboot's hot reset hook when disabling NPU2

2018-10-16 Thread Alistair Popple
On Tuesday, 16 October 2018 1:22:53 PM AEDT Alexey Kardashevskiy wrote: > > On 16/10/2018 13:19, Alistair Popple wrote: > >> reset_ntl() does what npu2_dev_procedure_reset() does plus more stuff, > >> there nothing really in npu2_dev_procedure_reset() which reset_ntl()

Re: [PATCH kernel v2] powerpc/ioda/npu: Call skiboot's hot reset hook when disabling NPU2

2018-10-17 Thread Alistair Popple
Hi Alexey, > > wouldn't you also need to do that somewhere? Unless the driver > > does it at startup? > > VFIO performs GPU reset so I'd expect the GPUs to flush its caches > without any software interactions. Am I hoping for too much here? Sadly you are. It's not the GPU caches that need flushi

Re: [PATCH kernel v2] powerpc/ioda/npu: Call skiboot's hot reset hook when disabling NPU2

2018-10-18 Thread Alistair Popple
into this but this fencing is > still needed, is not it? Yes. Although without the flushing I think you may get HMI's on any subsequent driver loads. So from the point of view of what happens on the Skiboot/HW side this looks ok so long as all links on an NPU are assigned to

[PATCH] powerpc/npu-dma: Remove NPU DMA ops

2018-10-30 Thread Alistair Popple
likely to go unnoticed. It is instead simpler to remove these operations and let the generic DMA code print warnings (eg. via a NULL pointer deref) in cases of buggy drivers attempting dma operations on NVLink devices. Signed-off-by: Alistair Popple --- arch/powerpc/platforms/powernv/npu-dma.c

Re: [PATCH kernel v3 05/22] powerpc/powernv/npu: Add helper to access struct npu for NPU device

2018-11-13 Thread Alistair Popple
Reviewed-by: Alistair Popple On Tuesday, 13 November 2018 7:28:06 PM AEDT Alexey Kardashevskiy wrote: > This step is to help removing the npu struct from pnv_phb so it > can be used by pseries as well. > > Signed-off-by: Alexey Kardashevskiy > Reviewed-by: David Gibson > -

Re: [PATCH kernel v3 06/22] powerpc/powernv: Detach npu struct from pnv_phb

2018-11-13 Thread Alistair Popple
Hi Alexey, On Tuesday, 13 November 2018 7:28:07 PM AEDT Alexey Kardashevskiy wrote: > static struct npu *npdev_to_npu(struct pci_dev *npdev) > { > - struct pnv_phb *nphb; > + struct pci_controller *hose = pci_bus_to_host(npdev->bus); > + struct npu *npu; > > - nphb = pci_bus_to_

Re: [PATCH kernel v3 07/22] powerpc/powernv/npu: Move OPAL calls away from context manipulation

2018-11-13 Thread Alistair Popple
> - /* > - * Setup the NPU context table for a particular GPU. These need to be > - * per-GPU as we need the tables to filter ATSDs when there are no > - * active contexts on a particular GPU. It is safe for these to be > - * called concurrently with destroy as the OPAL call

Re: [PATCH kernel] powerpc/powernv/npu: Remove unused headers and a macro.

2018-11-28 Thread Alistair Popple
Thanks! Looks like a reasonable cleanup. Assuming it compiles I can't see any reason not to add: Acked-by: Alistair Popple On Thursday, 29 November 2018 1:11:34 PM AEDT Alexey Kardashevskiy wrote: > Ping? > > On 28/09/2018 16:48, Alexey Kardashevskiy wrote: > > The macro

Re: [PATCH] powerpc/powernv/npu: Remove redundant change_pte() hook

2019-02-04 Thread Alistair Popple
et_pte_at was > > called later). Thanks for the fixup. I didn't realise that invalidate_range() always gets called but I now see that is the case so this change looks good to me as well. Reviewed-by: Alistair Popple > > All the necessary cache invalidation should all be

Re: [PATCH kernel] powerpc/ioda/npu2: Call hot reset skiboot hook when disabling NPU

2018-07-11 Thread Alistair Popple
Hi Alexey, On Wednesday, 11 July 2018 7:45:10 PM AEST Alexey Kardashevskiy wrote: > On Thu, 7 Jun 2018 17:06:07 +1000 > Alexey Kardashevskiy wrote: > > > This brings NPU2 in a safe mode when it does not throw HMI if GPU > > coherent memory is gone. It might be helpful if you you could describe

Re: [PATCH] powerpc/powernv: Fix concurrency issue with npu->mmio_atsd_usage

2018-08-02 Thread Alistair Popple
investigate. However this patch looks good. Acked-by: Alistair Popple > Signed-off-by: Reza Arbab > --- > arch/powerpc/platforms/powernv/npu-dma.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/arch/powerpc/platforms/powernv/npu-dma.c > b/a

Re: [PATCH 4/8] powerpc: Mark 4xx as Orphan in MAINTAINERS

2020-02-24 Thread Alistair Popple
Acked-by: Alistair Popple On Tuesday, 25 February 2020 10:31:42 AM AEDT Michael Ellerman wrote: > The 4xx platforms are no longer maintained. > > Cc: Alistair Popple > Cc: Matt Porter > Signed-off-by: Michael Ellerman > --- > MAINTAINERS | 5 + > 1 file ch

Re: [PATCH 6/6] powerpc/64s/radix: introduce options to disable use of the tlbie instruction

2019-09-02 Thread Alistair Popple
Nick, On Tuesday, 3 September 2019 1:29:31 AM AEST Nicholas Piggin wrote: > Introduce two options to control the use of the tlbie instruction. A > boot time option which completely disables the kernel using the > instruction, this is currently incompatible with HASH MMU, KVM, and > coherent accele

[PATCH v2] PPC: Set reserved PCR bits

2019-09-09 Thread Alistair Popple
Section 1.3.3. Signed-off-by: Alistair Popple Signed-off-by: Jordan Niethe Tested-by: Joel Stanley --- v2: Added some clarifications to the commit message --- arch/powerpc/include/asm/reg.h | 3 +++ arch/powerpc/kernel/cpu_setup_power.S | 6 ++ arch/powerpc/kernel/dt_cpu_ftrs.c

[PATCH 1/2] powerpc: Fix definition of PCR bits to work with old binutils

2019-09-16 Thread Alistair Popple
fix. This fixes the build errors by updating the definitions to use the __MASK() macro which selects the appropriate suffix. Signed-off-by: Alistair Popple --- arch/powerpc/include/asm/reg.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/include/asm/reg.h b

[PATCH 2/2] PPC: Set reserved PCR bits

2019-09-16 Thread Alistair Popple
on reserved bits in Section 1.3.3. Signed-off-by: Alistair Popple Signed-off-by: Jordan Niethe Tested-by: Joel Stanley --- arch/powerpc/include/asm/reg.h | 3 +++ arch/powerpc/kernel/cpu_setup_power.S | 6 ++ arch/powerpc/kernel/dt_cpu_ftrs.c | 3 ++- arch/powerpc/kvm

Re: [PATCH v2] PPC: Set reserved PCR bits

2019-09-16 Thread Alistair Popple
Those definitions were introduced in a previous commit so I've posted a new series to fix the definitions first. Thanks. - Alistair On Monday, 16 September 2019 7:49:26 PM AEST Michael Ellerman wrote: > Alistair Popple writes: > > Currently the reserved bits of the Processor

Re: [PATCH] powerpc/kvm: Fix kvmppc_vcore->in_guest value in kvmhv_switch_to_host

2019-10-03 Thread Alistair Popple
Reviewed-by: Alistair Popple On Friday, 4 October 2019 12:53:17 PM AEST Jordan Niethe wrote: > kvmhv_switch_to_host() in arch/powerpc/kvm/book3s_hv_rmhandlers.S needs > to set kvmppc_vcore->in_guest to 0 to signal secondary CPUs to continue. > This happens after resetting the PCR. B

Re: [PATCH] powerpc/kvm: Fix kvmppc_vcore->in_guest value in kvmhv_switch_to_host

2019-10-07 Thread Alistair Popple
_IMMEDIATE(r6, PCR_MASK) > + cmpld r0, r6 > beq 18f > - li r0, 0 > - mtspr SPRN_PCR, r0 > + mtspr SPRN_PCR, r6 > 18: > /* Signal secondary CPUs to continue */ > stb r0,VCORE_IN_GUEST(r5) Easy to understand h

[RFC PATCH v2 0/3] Invalidate secondary IOMMU TLB on permission upgrade

2023-07-07 Thread Alistair Popple
ug is adopted. The kernel TLB flushing functions may also need updating (see comments in patch 2). [1] - https://lore.kernel.org/all/20230602011518.787006-1-sea...@google.com/ [2] - https://lore.kernel.org/linux-mm/zjmr5bw8l+bbz...@ziepe.ca/ Alistair Popple (3): mm_notifiers: Rename invalidate_

[RFC PATCH v2 1/3] mm_notifiers: Rename invalidate_range notifier

2023-07-07 Thread Alistair Popple
arch_invalidate_secondary_tlbs() and update documention. Signed-off-by: Alistair Popple Suggested-by: Jason Gunthorpe --- arch/x86/mm/tlb.c | 1 +- drivers/iommu/amd/iommu_v2.c| 10 +-- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 13 ++-- drivers/iommu

[RFC PATCH v2 2/3] mmu_notifiers: Call arch_invalidate_secondary_tlbs() when invalidating TLBs

2023-07-07 Thread Alistair Popple
e notifier callback requires a non-NULL mm_struct. Therefore these invalidations are already not happening and it is assumed they are not required because IOMMUs are only attached to userspace memory maps. Signed-off-by: Alistair Popple Suggested-by: Jason Gunthorpe --- As this is an RFC I haven&#

[RFC PATCH v2 3/3] mmu_notifiers: Don't invalidate secondary TLBs as part of mmu_notifier_invalidate_range_end()

2023-07-07 Thread Alistair Popple
() functions. Signed-off-by: Alistair Popple --- include/linux/mmu_notifier.h | 56 + kernel/events/uprobes.c | 2 +- mm/huge_memory.c | 25 ++--- mm/hugetlb.c | 2 +- mm/memory.c | 8 + mm

[PATCH 0/4] Invalidate secondary IOMMU TLB on permission upgrade

2023-07-18 Thread Alistair Popple
/lore.kernel.org/all/20230602011518.787006-1-sea...@google.com/ [2] - https://lore.kernel.org/linux-mm/zjmr5bw8l+bbz...@ziepe.ca/ Alistair Popple (4): mm_notifiers: Rename invalidate_range notifier arm64/smmu: Use TLBI ASID when invalidating entire range mmu_notifiers: Call arch_invalidate_s

[PATCH 1/4] mm_notifiers: Rename invalidate_range notifier

2023-07-18 Thread Alistair Popple
arch_invalidate_secondary_tlbs() and update documention. Signed-off-by: Alistair Popple Suggested-by: Jason Gunthorpe --- arch/x86/mm/tlb.c | 1 +- drivers/iommu/amd/iommu_v2.c| 10 +-- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 13 ++-- drivers/iommu

[PATCH 2/4] arm64/smmu: Use TLBI ASID when invalidating entire range

2023-07-18 Thread Alistair Popple
: Alistair Popple --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 16 +--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c index aa63cff..dbc812a 100644 --- a/drivers/iommu

[PATCH 3/4] mmu_notifiers: Call arch_invalidate_secondary_tlbs() when invalidating TLBs

2023-07-18 Thread Alistair Popple
the IOMMUs require this. Signed-off-by: Alistair Popple Suggested-by: Jason Gunthorpe --- arch/arm64/include/asm/tlbflush.h | 5 + arch/powerpc/include/asm/book3s/64/tlbflush.h | 1 + arch/powerpc/mm/book3s64/radix_hugetlbpage.c | 1 + arch/powerpc/mm/book3s64/radix_tlb.c

[PATCH 4/4] mmu_notifiers: Don't invalidate secondary TLBs as part of mmu_notifier_invalidate_range_end()

2023-07-18 Thread Alistair Popple
() functions. Signed-off-by: Alistair Popple --- include/linux/mmu_notifier.h | 56 + kernel/events/uprobes.c | 2 +- mm/huge_memory.c | 25 ++--- mm/hugetlb.c | 2 +- mm/memory.c | 8 + mm

Re: [PATCH 1/4] mm_notifiers: Rename invalidate_range notifier

2023-07-18 Thread Alistair Popple
Andrew Morton writes: > On Tue, 18 Jul 2023 14:57:12 -0300 Jason Gunthorpe wrote: > >> On Tue, Jul 18, 2023 at 05:56:15PM +1000, Alistair Popple wrote: >> > diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h >> > index b466172..48c81b9 100644

Re: [PATCH 0/4] Invalidate secondary IOMMU TLB on permission upgrade

2023-07-18 Thread Alistair Popple
"Tian, Kevin" writes: >> From: Anshuman Khandual >> Sent: Wednesday, July 19, 2023 11:04 AM >> >> On 7/18/23 13:26, Alistair Popple wrote: >> > The main change is to move secondary TLB invalidation mmu notifier >> > callbacks into th

[PATCH v2 0/5] Invalidate secondary IOMMU TLB on permission upgrade

2023-07-19 Thread Alistair Popple
ired. [1] - https://lore.kernel.org/all/20230602011518.787006-1-sea...@google.com/ [2] - https://lore.kernel.org/linux-mm/zjmr5bw8l+bbz...@ziepe.ca/ Alistair Popple (5): arm64/smmu: Use TLBI ASID when invalidating entire range mmu_notifiers: Fixup comment in mmu_interval_read_begin() mmu_notifiers: Call i

[PATCH v2 1/5] arm64/smmu: Use TLBI ASID when invalidating entire range

2023-07-19 Thread Alistair Popple
: Alistair Popple --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 16 +--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c index a5a63b1..2a19784 100644 --- a/drivers/iommu

[PATCH v2 2/5] mmu_notifiers: Fixup comment in mmu_interval_read_begin()

2023-07-19 Thread Alistair Popple
The comment in mmu_interval_read_begin() refers to a function that doesn't exist and uses the wrong call-back name. The op for mmu interval notifiers is mmu_interval_notifier_ops->invalidate() so fix the comment up to reflect that. Signed-off-by: Alistair Popple --- mm/mmu_notifi

[PATCH v2 3/5] mmu_notifiers: Call invalidate_range() when invalidating TLBs

2023-07-19 Thread Alistair Popple
the IOMMUs require this. Signed-off-by: Alistair Popple Suggested-by: Jason Gunthorpe --- arch/arm64/include/asm/tlbflush.h | 5 + arch/powerpc/include/asm/book3s/64/tlbflush.h | 1 + arch/powerpc/mm/book3s64/radix_hugetlbpage.c | 1 + arch/powerpc/mm/book3s64/radix_tlb.c

[PATCH v2 4/5] mmu_notifiers: Don't invalidate secondary TLBs as part of mmu_notifier_invalidate_range_end()

2023-07-19 Thread Alistair Popple
() functions. Signed-off-by: Alistair Popple --- include/linux/mmu_notifier.h | 56 + kernel/events/uprobes.c | 2 +- mm/huge_memory.c | 25 ++--- mm/hugetlb.c | 1 +- mm/memory.c | 8 + mm

[PATCH v2 5/5] mmu_notifiers: Rename invalidate_range notifier

2023-07-19 Thread Alistair Popple
arch_invalidate_secondary_tlbs() and update documention. Signed-off-by: Alistair Popple Suggested-by: Jason Gunthorpe --- arch/arm64/include/asm/tlbflush.h | 6 +- arch/powerpc/mm/book3s64/radix_hugetlbpage.c| 2 +- arch/powerpc/mm/book3s64/radix_tlb.c| 10 ++-- arch/x86/mm/tlb.c

Re: [PATCH v2 3/5] mmu_notifiers: Call invalidate_range() when invalidating TLBs

2023-07-19 Thread Alistair Popple
SeongJae Park writes: > Hi Alistair, > > On Wed, 19 Jul 2023 22:18:44 +1000 Alistair Popple wrote: > >> The invalidate_range() is going to become an architecture specific mmu >> notifier used to keep the TLB of secondary MMUs such as an IOMMU in >> sync with the

[PATCH v3 1/5] arm64/smmu: Use TLBI ASID when invalidating entire range

2023-07-20 Thread Alistair Popple
: Alistair Popple --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 16 +--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c index a5a63b1..2a19784 100644 --- a/drivers/iommu

[PATCH v3 0/5] Invalidate secondary IOMMU TLB on permission upgrade

2023-07-20 Thread Alistair Popple
.787006-1-sea...@google.com/ [2] - https://lore.kernel.org/linux-mm/zjmr5bw8l+bbz...@ziepe.ca/ Alistair Popple (5): arm64/smmu: Use TLBI ASID when invalidating entire range mmu_notifiers: Fixup comment in mmu_interval_read_begin() mmu_notifiers: Call invalidate_range() when invalidating TLBs m

[PATCH v3 2/5] mmu_notifiers: Fixup comment in mmu_interval_read_begin()

2023-07-20 Thread Alistair Popple
The comment in mmu_interval_read_begin() refers to a function that doesn't exist and uses the wrong call-back name. The op for mmu interval notifiers is mmu_interval_notifier_ops->invalidate() so fix the comment up to reflect that. Signed-off-by: Alistair Popple --- mm/mmu_notifi

[PATCH v3 3/5] mmu_notifiers: Call invalidate_range() when invalidating TLBs

2023-07-20 Thread Alistair Popple
the IOMMUs require this. Signed-off-by: Alistair Popple Suggested-by: Jason Gunthorpe Tested-by: SeongJae Park --- arch/arm64/include/asm/tlbflush.h | 5 + arch/powerpc/include/asm/book3s/64/tlbflush.h | 1 + arch/powerpc/mm/book3s64/radix_hugetlbpage.c | 1 + arch/powerpc/m

[PATCH v3 4/5] mmu_notifiers: Don't invalidate secondary TLBs as part of mmu_notifier_invalidate_range_end()

2023-07-20 Thread Alistair Popple
() functions. Signed-off-by: Alistair Popple --- include/linux/mmu_notifier.h | 56 + kernel/events/uprobes.c | 2 +- mm/huge_memory.c | 25 ++--- mm/hugetlb.c | 1 +- mm/memory.c | 8 + mm

[PATCH v3 5/5] mmu_notifiers: Rename invalidate_range notifier

2023-07-20 Thread Alistair Popple
arch_invalidate_secondary_tlbs() and update documention. Signed-off-by: Alistair Popple Suggested-by: Jason Gunthorpe --- arch/arm64/include/asm/tlbflush.h | 6 +- arch/powerpc/mm/book3s64/radix_hugetlbpage.c| 2 +- arch/powerpc/mm/book3s64/radix_tlb.c| 10 ++-- arch/x86/include

Re: [PATCH v2 3/5] mmu_notifiers: Call invalidate_range() when invalidating TLBs

2023-07-24 Thread Alistair Popple
Luis Chamberlain writes: >> diff --git a/arch/x86/include/asm/tlbflush.h >> b/arch/x86/include/asm/tlbflush.h >> index 837e4a50281a..79c46da919b9 100644 >> --- a/arch/x86/include/asm/tlbflush.h >> +++ b/arch/x86/include/asm/tlbflush.h >> @@ -4,6 +4,7 @@ >> >> #include >> #include >> +#in

Re: [PATCH v2 3/5] mmu_notifiers: Call invalidate_range() when invalidating TLBs

2023-07-24 Thread Alistair Popple
Michael Ellerman writes: > Alistair Popple writes: >> The invalidate_range() is going to become an architecture specific mmu >> notifier used to keep the TLB of secondary MMUs such as an IOMMU in >> sync with the CPU page tables. Currently it is called from separate >

[PATCH v4 0/5] Invalidate secondary IOMMU TLB on permission upgrade

2023-07-25 Thread Alistair Popple
re.kernel.org/all/20230602011518.787006-1-sea...@google.com/ [2] - https://lore.kernel.org/linux-mm/zjmr5bw8l+bbz...@ziepe.ca/ Alistair Popple (5): arm64/smmu: Use TLBI ASID when invalidating entire range mmu_notifiers: Fixup comment in mmu_interval_read_begin() mmu_notifiers: C

[PATCH v4 1/5] arm64/smmu: Use TLBI ASID when invalidating entire range

2023-07-25 Thread Alistair Popple
: Alistair Popple Reviewed-by: Jason Gunthorpe --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 16 +--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c index a5a63b1

[PATCH v4 2/5] mmu_notifiers: Fixup comment in mmu_interval_read_begin()

2023-07-25 Thread Alistair Popple
The comment in mmu_interval_read_begin() refers to a function that doesn't exist and uses the wrong call-back name. The op for mmu interval notifiers is mmu_interval_notifier_ops->invalidate() so fix the comment up to reflect that. Signed-off-by: Alistair Popple Reviewed-by: Jason G

[PATCH v4 3/5] mmu_notifiers: Call invalidate_range() when invalidating TLBs

2023-07-25 Thread Alistair Popple
the IOMMUs require this. Signed-off-by: Alistair Popple Suggested-by: Jason Gunthorpe Tested-by: SeongJae Park Acked-by: Catalin Marinas Reviewed-by: Jason Gunthorpe --- arch/arm64/include/asm/tlbflush.h | 5 + arch/powerpc/include/asm/book3s/64/tlbflush.h | 1 + arch/

[PATCH v4 4/5] mmu_notifiers: Don't invalidate secondary TLBs as part of mmu_notifier_invalidate_range_end()

2023-07-25 Thread Alistair Popple
() functions. Signed-off-by: Alistair Popple Reviewed-by: Jason Gunthorpe --- include/linux/mmu_notifier.h | 56 + kernel/events/uprobes.c | 2 +- mm/huge_memory.c | 25 ++--- mm/hugetlb.c | 1 +- mm/memory.c

[PATCH v4 5/5] mmu_notifiers: Rename invalidate_range notifier

2023-07-25 Thread Alistair Popple
arch_invalidate_secondary_tlbs() and update documention. Signed-off-by: Alistair Popple Suggested-by: Jason Gunthorpe Acked-by: Catalin Marinas Reviewed-by: Jason Gunthorpe --- arch/arm64/include/asm/tlbflush.h | 6 +- arch/powerpc/mm/book3s64/radix_hugetlbpage.c| 2 +- arch/powerpc/mm

Re: [PATCH v2 1/2] mm/migrate_device.c: Copy pte dirty bit to page

2022-08-23 Thread Alistair Popple
"Huang, Ying" writes: > Peter Xu writes: > >> On Thu, Aug 18, 2022 at 02:34:45PM +0800, Huang, Ying wrote: >>> > In this specific case, the only way to do safe tlb batching in my mind is: >>> > >>> > pte_offset_map_lock(); >>> > arch_enter_lazy_mmu_mode(); >>> > // If any pending t

[PATCH v3 1/3] mm/migrate_device.c: Flush TLB while holding PTL

2022-08-23 Thread Alistair Popple
ock() [ page is still accessible via stale TLB ] flush_tlb_range() In this case the page may still be accessed via the stale TLB entry after madvise returns. Fix this by flushing the TLB while holding the PTL. Signed-off-by: Alistair Popple Reported-by: Nadav Amit Fixes: 8c3328f1f36a (

[PATCH v3 2/3] mm/migrate_device.c: Copy pte dirty bit to page

2022-08-23 Thread Alistair Popple
uently accessed. Prevent this by copying the dirty bit to the page when removing the pte to match what try_to_migrate_one() does. Signed-off-by: Alistair Popple Acked-by: Peter Xu Reported-by: Huang Ying Fixes: 8c3328f1f36a ("mm/migrate: migrate_vma() unmap page from vma while collec

[PATCH v3 3/3] selftests/hmm-tests: Add test for dirty bits

2022-08-23 Thread Alistair Popple
We were not correctly copying PTE dirty bits to pages during migrate_vma_setup() calls. This could potentially lead to data loss, so add a test for this. Signed-off-by: Alistair Popple --- tools/testing/selftests/vm/hmm-tests.c | 124 ++- 1 file changed, 124 insertions

Re: [PATCH v3 1/3] mm/migrate_device.c: Flush TLB while holding PTL

2022-08-24 Thread Alistair Popple
David Hildenbrand writes: > On 24.08.22 05:03, Alistair Popple wrote: >> When clearing a PTE the TLB should be flushed whilst still holding the >> PTL to avoid a potential race with madvise/munmap/etc. For example >> consider the following sequence: >> >> C

Re: [PATCH v2 1/2] mm/migrate_device.c: Copy pte dirty bit to page

2022-08-24 Thread Alistair Popple
Peter Xu writes: > On Wed, Aug 24, 2022 at 04:25:44PM -0400, Peter Xu wrote: >> On Wed, Aug 24, 2022 at 11:56:25AM +1000, Alistair Popple wrote: >> > >> Still I don't know whether there'll be any side effect of having stall >> > >> tlbs >>

Re: [PATCH v2 1/2] mm/migrate_device.c: Copy pte dirty bit to page

2022-08-24 Thread Alistair Popple
Alistair Popple writes: > Peter Xu writes: >>> But it's kind of against a pure "optimization" in that if trylock failed, >>> we'll clear the mpfn so the src[i] will be zero at last. Then will we >>> directly give up on this page, or will w

Re: [PATCH v2 1/2] mm/migrate_device.c: Copy pte dirty bit to page

2022-08-25 Thread Alistair Popple
Peter Xu writes: > On Thu, Aug 25, 2022 at 11:24:03AM +1000, Alistair Popple wrote: >> By the way it's still an optimisation because in most cases we can avoid >> calling try_to_migrate() and walking the rmap altogether if we install >> the migration entries here.

Re: [PATCH v3 2/3] mm/migrate_device.c: Copy pte dirty bit to page

2022-08-25 Thread Alistair Popple
Peter Xu writes: > On Wed, Aug 24, 2022 at 01:03:38PM +1000, Alistair Popple wrote: >> migrate_vma_setup() has a fast path in migrate_vma_collect_pmd() that >> installs migration entries directly if it can lock the migrating page. >> When removing a dirty pte the dirty

Re: [PATCH v3 1/3] mm/migrate_device.c: Flush TLB while holding PTL

2022-08-25 Thread Alistair Popple
"Huang, Ying" writes: > Alistair Popple writes: > >> When clearing a PTE the TLB should be flushed whilst still holding the >> PTL to avoid a potential race with madvise/munmap/etc. For example >> consider the following sequence: >>

Re: [PATCH v3 2/3] mm/migrate_device.c: Copy pte dirty bit to page

2022-08-25 Thread Alistair Popple
Peter Xu writes: > On Fri, Aug 26, 2022 at 08:21:44AM +1000, Alistair Popple wrote: >> >> Peter Xu writes: >> >> > On Wed, Aug 24, 2022 at 01:03:38PM +1000, Alistair Popple wrote: >> >> migrate_vma_setup() has a fast path in migrate_vma_collect_p

[PATCH v4 1/4] mm/migrate_device.c: Flush TLB while holding PTL

2022-09-01 Thread Alistair Popple
ock() [ page is still accessible via stale TLB ] flush_tlb_range() In this case the page may still be accessed via the stale TLB entry after madvise returns. Fix this by flushing the TLB while holding the PTL. Signed-off-by: Alistair Popple Reported-by: Nadav Amit Reviewed-by: "Hua

[PATCH v4 2/4] mm/migrate_device.c: Add missing flush_cache_page()

2022-09-01 Thread Alistair Popple
Currently we only call flush_cache_page() for the anon_exclusive case, however in both cases we clear the pte so should flush the cache. Signed-off-by: Alistair Popple Fixes: 8c3328f1f36a ("mm/migrate: migrate_vma() unmap page from vma while collecting pages") Cc: sta...@vger.

[PATCH v4 3/4] mm/migrate_device.c: Copy pte dirty bit to page

2022-09-01 Thread Alistair Popple
uently accessed. Prevent this by copying the dirty bit to the page when removing the pte to match what try_to_migrate_one() does. Signed-off-by: Alistair Popple Acked-by: Peter Xu Reviewed-by: "Huang, Ying" Reported-by: "Huang, Ying" Fixes: 8c3328f1f36a ("mm/migrate:

[PATCH v4 4/4] selftests/hmm-tests: Add test for dirty bits

2022-09-01 Thread Alistair Popple
We were not correctly copying PTE dirty bits to pages during migrate_vma_setup() calls. This could potentially lead to data loss, so add a test for this. Signed-off-by: Alistair Popple --- tools/testing/selftests/vm/hmm-tests.c | 124 ++- 1 file changed, 124 insertions

Re: [PATCH v4 4/4] selftests/hmm-tests: Add test for dirty bits

2022-09-07 Thread Alistair Popple
John Hubbard writes: > On 9/1/22 17:35, Alistair Popple wrote: [...] >> +/* >> + * Try and migrate a dirty page that has previously been swapped to disk. >> This >> + * checks that we don't loose dirty bits. > > s/loose/lose/ Thanks. >

Re: [PATCH v4 4/4] selftests/hmm-tests: Add test for dirty bits

2022-09-12 Thread Alistair Popple
John Hubbard writes: > On 9/7/22 04:13, Alistair Popple wrote: >>>> + /* >>>> + * Attempt to migrate memory to device, which should fail because >>>> + * hopefully some pages are backed by swap storage. >>>> + */ >>>>

[PATCH] hmm-tests: Fix migrate_dirty_page test

2022-09-12 Thread Alistair Popple
at it. Signed-off-by: Alistair Popple Fixes: 5cc88e844e87 ("selftests/hmm-tests: add test for dirty bits") --- tools/testing/selftests/vm/hmm-tests.c | 50 +++--- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/vm/hmm-tests.c

Re: [PATCH] hmm-tests: Fix migrate_dirty_page test

2022-09-13 Thread Alistair Popple
David Hildenbrand writes: > On 13.09.22 07:22, Alistair Popple wrote: >> As noted by John Hubbard the original test relied on side effects of the >> implementation of migrate_vma_setup() to detect if pages had been >> swapped to disk or not. This is subject to change in fu

[PATCH v2] hmm-tests: Fix migrate_dirty_page test

2022-09-14 Thread Alistair Popple
at it. Signed-off-by: Alistair Popple Fixes: 5cc88e844e87 ("selftests/hmm-tests: add test for dirty bits") Reviewed-by: Mika Penttilä --- Changes for v2: - Added Mika's Reviewed-by (Thanks!) - Moved pagemap checks into vm_util.c as suggested by David H. --- tools/testing/s

[PATCH 0/7] Fix several device private page reference counting issues

2022-09-25 Thread Alistair Popple
. Unfortunately I lack the hardware to test on either of these so would appreciate it if someone with access could test those. Alistair Popple (7): mm/memory.c: Fix race when faulting a device private page mm: Free device private pages have zero refcount mm/migrate_device.c: Refactor

[PATCH 1/7] mm/memory.c: Fix race when faulting a device private page

2022-09-25 Thread Alistair Popple
o see if it's expected or not. Signed-off-by: Alistair Popple --- arch/powerpc/kvm/book3s_hv_uvmem.c | 15 ++- drivers/gpu/drm/amd/amdkfd/kfd_migrate.c | 17 +++-- drivers/gpu/drm/amd/amdkfd/kfd_migrate.h | 2 +- drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 11 +--

[PATCH 2/7] mm: Free device private pages have zero refcount

2022-09-25 Thread Alistair Popple
ns such as get_page_unless_zero(). Signed-off-by: Alistair Popple --- arch/powerpc/kvm/book3s_hv_uvmem.c | 1 + drivers/gpu/drm/amd/amdkfd/kfd_migrate.c | 1 + drivers/gpu/drm/nouveau/nouveau_dmem.c | 1 + lib/test_hmm.c | 1 + mm/memremap.c| 5

[PATCH 3/7] mm/migrate_device.c: Refactor migrate_vma and migrate_deivce_coherent_page()

2022-09-25 Thread Alistair Popple
this isn't true for device private memory, and a future change requires similar functionality for device private memory. So refactor the code into something more sensible for migrating device memory without a vma. Signed-off-by: Alistair Popple --- mm/migrate_device.c

[PATCH 4/7] mm/migrate_device.c: Add migrate_device_range()

2022-09-25 Thread Alistair Popple
n free up device memory. To allow that this patch introduces the migrate_device family of functions which are functionally similar to migrate_vma but which skips the initial lookup based on mapping. Signed-off-by: Alistair Popple --- include/linux/migrate.h | 7 +++- mm/migrate_device.c

[PATCH 5/7] nouveau/dmem: Refactor nouveau_dmem_fault_copy_one()

2022-09-25 Thread Alistair Popple
. Refactor out the core functionality so that it is not specific to fault handling. Signed-off-by: Alistair Popple --- drivers/gpu/drm/nouveau/nouveau_dmem.c | 59 +-- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_dmem.c b

[PATCH 6/7] nouveau/dmem: Evict device private memory during release

2022-09-25 Thread Alistair Popple
callbacks have all been freed. Fix this by migrating any mappings back to normal CPU memory prior to freeing the GPU memory chunks and associated device private pages. Signed-off-by: Alistair Popple --- I assume the AMD driver might have a similar issue. However I can't see where device privat

[PATCH 7/7] hmm-tests: Add test for migrate_device_range()

2022-09-25 Thread Alistair Popple
Signed-off-by: Alistair Popple --- lib/test_hmm.c | 119 +- lib/test_hmm_uapi.h| 1 +- tools/testing/selftests/vm/hmm-tests.c | 49 +++- 3 files changed, 148 insertions(+), 21 deletions(-) diff --git a/lib/test_hmm.c

Re: [PATCH 6/7] nouveau/dmem: Evict device private memory during release

2022-09-26 Thread Alistair Popple
John Hubbard writes: > On 9/26/22 14:35, Lyude Paul wrote: >>> + for (i = 0; i < npages; i++) { >>> + if (src_pfns[i] & MIGRATE_PFN_MIGRATE) { >>> + struct page *dpage; >>> + >>> + /* >>> +* _GFP_NOFAIL because the GPU is going

Re: [PATCH 6/7] nouveau/dmem: Evict device private memory during release

2022-09-26 Thread Alistair Popple
Felix Kuehling writes: > On 2022-09-26 17:35, Lyude Paul wrote: >> On Mon, 2022-09-26 at 16:03 +1000, Alistair Popple wrote: >>> When the module is unloaded or a GPU is unbound from the module it is >>> possible for device private pages to be left mapped in curr

Re: [PATCH 2/7] mm: Free device private pages have zero refcount

2022-09-26 Thread Alistair Popple
Jason Gunthorpe writes: > On Mon, Sep 26, 2022 at 04:03:06PM +1000, Alistair Popple wrote: >> Since 27674ef6c73f ("mm: remove the extra ZONE_DEVICE struct page >> refcount") device private pages have no longer had an extra reference >> count when the page is in u

Re: [PATCH 5/7] nouveau/dmem: Refactor nouveau_dmem_fault_copy_one()

2022-09-28 Thread Alistair Popple
Lyude Paul writes: > On Mon, 2022-09-26 at 16:03 +1000, Alistair Popple wrote: >> nouveau_dmem_fault_copy_one() is used during handling of CPU faults via >> the migrate_to_ram() callback and is used to copy data from GPU to CPU >> memory. It is currently specific to faul

Re: [PATCH 1/7] mm/memory.c: Fix race when faulting a device private page

2022-09-28 Thread Alistair Popple
Michael Ellerman writes: > Alistair Popple writes: >> When the CPU tries to access a device private page the migrate_to_ram() >> callback associated with the pgmap for the page is called. However no >> reference is taken on the faulting page. Therefore a concurrent >&

Re: [PATCH 2/7] mm: Free device private pages have zero refcount

2022-09-29 Thread Alistair Popple
Dan Williams writes: > Alistair Popple wrote: >> >> Jason Gunthorpe writes: >> >> > On Mon, Sep 26, 2022 at 04:03:06PM +1000, Alistair Popple wrote: >> >> Since 27674ef6c73f ("mm: remove the extra ZONE_DEVICE struct page >> >>

[RFC PATCH 01/19] mm: Introduce vm_account

2023-01-23 Thread Alistair Popple
counting to different counters as required. A future change will extend this to also account against a cgroup for pinned pages. Signed-off-by: Alistair Popple Cc: linux-ker...@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org Cc: linux-f...@vger.kernel.org Cc: linux-r...@vger.kernel.org Cc:

[RFC PATCH 08/19] vfio/spapr_tce: Convert accounting to pinned_vm

2023-01-23 Thread Alistair Popple
Convert from accounting pages against locked_vm to accounting them to pinned_vm. This allows struct vm_account to be used to track the mm_struct used to charge the pages. A future change also uses this to track a cgroup for controlling pinned pages. Signed-off-by: Alistair Popple Cc: Michael

[RFC PATCH 12/19] kvm/book3s_64_vio: Convert account_locked_vm() to vm_account_pinned()

2023-01-23 Thread Alistair Popple
book3s_64_vio currently accounts for pinned pages with account_locked_vm() which charges the pages to mm->locked_vm. To make this consistent with other drivers switch to using vm_account_pinned(). Signed-off-by: Alistair Popple Cc: Michael Ellerman Cc: Nicholas Piggin Cc: Christophe Leroy

Re: [RFC PATCH 01/19] mm: Introduce vm_account

2023-01-30 Thread Alistair Popple
Jason Gunthorpe writes: > On Tue, Jan 24, 2023 at 04:42:30PM +1100, Alistair Popple wrote: >> +/** >> + * enum vm_account_flags - Determine how pinned/locked memory is accounted. >> + * @VM_ACCOUNT_TASK: Account pinned memory to mm->pinned_vm. >> + * @VM_ACCOUNT_B

[PATCH 01/19] mm: Introduce vm_account

2023-02-05 Thread Alistair Popple
accounting to different counters as required. A future change will extend this to also account against a cgroup for pinned pages. Signed-off-by: Alistair Popple Cc: linux-ker...@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org Cc: linux-f...@vger.kernel.org Cc: linux-r...@vger.kernel.org Cc:

[PATCH 08/19] vfio/spapr_tce: Convert accounting to pinned_vm

2023-02-05 Thread Alistair Popple
Convert from accounting pages against locked_vm to accounting them to pinned_vm. This allows struct vm_account to be used to track the mm_struct used to charge the pages. A future change also uses this to track a cgroup for controlling pinned pages. Signed-off-by: Alistair Popple Cc: Michael

<    1   2   3   4   5   6   7   8   >