]> www.infradead.org Git - users/jedix/linux-maple.git/commit
powerpc/pseries/iommu: memory notifier incorrectly adds TCEs for pmemory
authorGaurav Batra <gbatra@linux.ibm.com>
Thu, 30 Jan 2025 18:38:54 +0000 (12:38 -0600)
committerMadhavan Srinivasan <maddy@linux.ibm.com>
Tue, 11 Feb 2025 06:09:10 +0000 (11:39 +0530)
commit6aa989ab2bd0d37540c812b4270006ff794662e7
treef67765a92592b2fec7c76f18d0ad97bbf53281ae
parent67dfc11982f7e3c37f0977e74671da2391b29181
powerpc/pseries/iommu: memory notifier incorrectly adds TCEs for pmemory

iommu_mem_notifier() is invoked when RAM is dynamically added/removed. This
notifier call is responsible to add/remove TCEs from the Dynamic DMA Window
(DDW) when TCEs are pre-mapped. TCEs are pre-mapped only for RAM and not
for persistent memory (pmemory). For DMA buffers in pmemory, TCEs are
dynamically mapped when the device driver instructs to do so.

The issue is 'daxctl' command is capable of adding pmemory as "System RAM"
after LPAR boot. The command to do so is -

daxctl reconfigure-device --mode=system-ram dax0.0 --force

This will dynamically add pmemory range to LPAR RAM eventually invoking
iommu_mem_notifier(). The address range of pmemory is way beyond the Max
RAM that the LPAR can have. Which means, this range is beyond the DDW
created for the device, at device initialization time.

As a result when TCEs are pre-mapped for the pmemory range, by
iommu_mem_notifier(), PHYP HCALL returns H_PARAMETER. This failed the
command, daxctl, to add pmemory as RAM.

The solution is to not pre-map TCEs for pmemory.

Signed-off-by: Gaurav Batra <gbatra@linux.ibm.com>
Tested-by: Donet Tom <donettom@linux.ibm.com>
Reviewed-by: Donet Tom <donettom@linux.ibm.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20250130183854.92258-1-gbatra@linux.ibm.com
arch/powerpc/include/asm/mmzone.h
arch/powerpc/mm/numa.c
arch/powerpc/platforms/pseries/iommu.c