Skip to contentSkip to conversation

accel/ivpu: Limit DMA address width to 42 bits on 40XX and later

PATCH In review Karol Wachowski 2 participants 3 messages Oct 6 – Oct 8

Subsystems (2)
lore
Share & tools
lore

Karol Wachowski

author maintainer
#0 lore raw

PATCH 1/1 accel/ivpu: Limit DMA address width to 42 bits on 40XX and later

On 40XX and later the NPU does not treat address bits 42 and above as part of the memory address, as the hardware uses them internally, but ivpu sets a 48-bit DMA mask for these generations.

In practice the IOMMU capabilities already limit the DMA addresses to 42 bits, so this does not fix an observed problem. Set the DMA mask to 42 bits anyway, so the driver does not depend on the IOMMU configuration to stay within the range the NPU can address. 37XX keeps its 38-bit mask.

---
 drivers/accel/ivpu/ivpu_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/accel/ivpu/ivpu_drv.c +1 -1
index ab1a9448c2cc..6b71edf566e7 100644
@@ -709,7 +709,7 @@ static int ivpu_pci_init(struct ivpu_device *vdev)
 	}
 
 	if (ivpu_hw_ip_gen(vdev) >= IVPU_HW_IP_40XX)
-		dma_bits = 48;
+		dma_bits = 42;
 	else
 		dma_bits = 38;
 
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Karol Wachowski

On 40XX and later the NPU does not treat address bits 42 and above as part of the memory address, as the hardware uses them internally, but ivpu sets a 48-bit DMA mask for these generations.

In practice the IOMMU capabilities already limit the DMA addresses to 42 bits, so this does not fix an observed problem. Set the DMA mask to 42 bits anyway, so the driver does not depend on the IOMMU configuration to stay within the range the NPU can address. 37XX keeps its 38-bit mask.

Quoted 18 lines
---
  drivers/accel/ivpu/ivpu_drv.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/accel/ivpu/ivpu_drv.c +1 -1
index ab1a9448c2cc..6b71edf566e7 100644
@@ -709,7 +709,7 @@ static int ivpu_pci_init(struct ivpu_device *vdev)
  	}
 
  	if (ivpu_hw_ip_gen(vdev) >= IVPU_HW_IP_40XX)
-		dma_bits = 48;
+		dma_bits = 42;
  	else
  		dma_bits = 38;
 
author maintainer
#2 lore raw
Quoted 5 lines · Dawid Osuchowski
Quoted 4 lines · Karol Wachowski

On 40XX and later the NPU does not treat address bits 42 and above as part of the memory address, as the hardware uses them internally, but ivpu sets a 48-bit DMA mask for these generations.

Quoted 8 lines
Quoted 6 lines

In practice the IOMMU capabilities already limit the DMA addresses to 42 bits, so this does not fix an observed problem. Set the DMA mask to 42 bits anyway, so the driver does not depend on the IOMMU configuration to stay within the range the NPU can address. 37XX keeps its 38-bit mask.

Thanks, pushed to drm-misc-next.

Quoted 18 lines
Quoted 17 lines

---
  drivers/accel/ivpu/ivpu_drv.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/accel/ivpu/ivpu_drv.c +1 -1
index ab1a9448c2cc..6b71edf566e7 100644
@@ -709,7 +709,7 @@ static int ivpu_pci_init(struct ivpu_device *vdev)
       }
       if (ivpu_hw_ip_gen(vdev) >= IVPU_HW_IP_40XX)
-        dma_bits = 48;
+        dma_bits = 42;

      else
          dma_bits = 38;