summaryrefslogtreecommitdiff
path: root/drivers/gpu/nova-core/driver.rs
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2025-11-20 10:42:50 +1000
committerDave Airlie <airlied@redhat.com>2025-11-20 10:44:50 +1000
commitf0ded972d37150f9f889de75c9eecc5cb0730013 (patch)
tree1cbf2650fd192cd2b10d497ada78dc55721d842a /drivers/gpu/nova-core/driver.rs
parentf3a1d69f9b388271986f4efe1fd775df15b443c1 (diff)
parent77b686f688126a5f758b51441a03186e9eb1b0f1 (diff)
Merge tag 'drm-rust-next-2025-11-18' of https://gitlab.freedesktop.org/drm/rust/kernel into drm-next
Cross-subsystem Changes: Rust - Make slice::as_flattened usable on all supported versions of rustc. - Add FromBytes::from_bytes_prefix() method. Core Changes: - Update Tyr in MAINTAINERS file. - Remove redundant device ptr from Rust GEM object. - Change how AlwaysRefCounted is implemented for GEM objects. - Add deferred vm_bo cleanup to GPUVM and use it in Panthor. Driver Changes: Nova Core - Introduction of bitfield! macro, with support for different storage sizes and custom visibility. - Introduction of safe converters between integer types for which the conversion is lossless. - GSP initialized up to fully booted state on Ampere. - Use more future-proof register for GPU identification. - Various simplifications and optimizations. Nova - Select NOVA_CORE. - Depend on CONFIG_64BIT. Signed-off-by: Dave Airlie <airlied@redhat.com> From: Alice Ryhl <aliceryhl@google.com> Link: https://patch.msgid.link/aRxtJC0D1pQUepF4@google.com
Diffstat (limited to 'drivers/gpu/nova-core/driver.rs')
-rw-r--r--drivers/gpu/nova-core/driver.rs27
1 files changed, 24 insertions, 3 deletions
diff --git a/drivers/gpu/nova-core/driver.rs b/drivers/gpu/nova-core/driver.rs
index edc72052e27a..d91bbc50cde7 100644
--- a/drivers/gpu/nova-core/driver.rs
+++ b/drivers/gpu/nova-core/driver.rs
@@ -1,13 +1,20 @@
// SPDX-License-Identifier: GPL-2.0
use kernel::{
- auxiliary, c_str,
+ auxiliary,
+ c_str,
device::Core,
+ dma::Device,
+ dma::DmaMask,
pci,
- pci::{Class, ClassMask, Vendor},
+ pci::{
+ Class,
+ ClassMask,
+ Vendor, //
+ },
prelude::*,
sizes::SZ_16M,
- sync::Arc,
+ sync::Arc, //
};
use crate::gpu::Gpu;
@@ -20,6 +27,15 @@ pub(crate) struct NovaCore {
}
const BAR0_SIZE: usize = SZ_16M;
+
+// For now we only support Ampere which can use up to 47-bit DMA addresses.
+//
+// TODO: Add an abstraction for this to support newer GPUs which may support
+// larger DMA addresses. Limiting these GPUs to smaller address widths won't
+// have any adverse affects, unless installed on systems which require larger
+// DMA addresses. These systems should be quite rare.
+const GPU_DMA_BITS: u32 = 47;
+
pub(crate) type Bar0 = pci::Bar<BAR0_SIZE>;
kernel::pci_device_table!(
@@ -57,6 +73,11 @@ impl pci::Driver for NovaCore {
pdev.enable_device_mem()?;
pdev.set_master();
+ // 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::new::<GPU_DMA_BITS>())? };
+
let devres_bar = Arc::pin_init(
pdev.iomap_region_sized::<BAR0_SIZE>(0, c_str!("nova-core/bar0")),
GFP_KERNEL,