]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/tyr: set DMA mask using GPU physical address
authorBeata Michalska <beata.michalska@arm.com>
Tue, 28 Apr 2026 19:19:31 +0000 (12:19 -0700)
committerAlice Ryhl <aliceryhl@google.com>
Fri, 1 May 2026 10:43:51 +0000 (10:43 +0000)
Configure the device DMA mask during probe using the GPU's physical
address capability reported in GpuInfo. This ensures DMA allocations
use an appropriate address mask.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Signed-off-by: Beata Michalska <beata.michalska@arm.com>
Co-developed-by: Deborah Brouwer <deborah.brouwer@collabora.com>
Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
Link: https://patch.msgid.link/20260428-fw-boot-prerequisites-v1-4-c69af9abe1af@collabora.com
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
drivers/gpu/drm/tyr/driver.rs

index cdb9b13bdb3291a0356a58cc9b2a18d60becb7a0..e20a5978eed6d0cc434663b65dac18c3bc8c1133 100644 (file)
@@ -11,6 +11,10 @@ use kernel::{
         Device, //
     },
     devres::Devres,
+    dma::{
+        Device as DmaDevice,
+        DmaMask, //
+    },
     drm,
     drm::ioctl,
     io::{
@@ -124,6 +128,14 @@ impl platform::Driver for TyrPlatformDriverData {
         let gpu_info = GpuInfo::new(pdev.as_ref(), &iomem)?;
         gpu_info.log(pdev.as_ref());
 
+        let pa_bits = MMU_FEATURES::from_raw(gpu_info.mmu_features)
+            .pa_bits()
+            .get();
+        // SAFETY: No concurrent DMA allocations or mappings can be made because
+        // the device is still being probed and therefore isn't being used by
+        // other threads of execution.
+        unsafe { pdev.dma_set_mask_and_coherent(DmaMask::try_new(pa_bits)?)? };
+
         let platform: ARef<platform::Device> = pdev.into();
 
         let data = try_pin_init!(TyrDrmDeviceData {