[PATCH v3 8/8] drm/tyr: add gpuvas debugfs file

Alvin Sun <[email protected]>
Newsgroups org.freedesktop.lists.dri-devel,dev.linux.lists.driver-core,org.kernel.feeds.b4-sent,org.kernel.vger.rust-for-linux
Message-ID <[email protected]>
Add a gpuvas debugfs file listing all GPU VAs for the Tyr DRM driver.
Collects VMs into a shared list during firmware init and renders them
via dump_gpuva_info on read.

Signed-off-by: Alvin Sun <[email protected]>
---
 drivers/gpu/drm/tyr/debugfs.rs | 20 ++++++++++++++++++++
 drivers/gpu/drm/tyr/driver.rs  | 10 ++++++++++
 drivers/gpu/drm/tyr/tyr.rs     |  1 +
 3 files changed, 31 insertions(+)

diff --git a/drivers/gpu/drm/tyr/debugfs.rs b/drivers/gpu/drm/tyr/debugfs.rs
new file mode 100644
index 0000000000000..0e93c629829cd
--- /dev/null
+++ b/drivers/gpu/drm/tyr/debugfs.rs
@@ -0,0 +1,20 @@
+// SPDX-License-Identifier: GPL-2.0 or MIT
+
+//! Debugfs support for the Tyr DRM driver.
+
+use kernel::{
+    debugfs::SeqShow,
+    prelude::*,
+    seq_file, //
+};
+
+use crate::driver::TyrDrmRegistrationData;
+
+/// `SeqShow` implementation for the `gpuvas` debugfs file.
+pub(crate) struct GpuvasShow;
+
+impl SeqShow<TyrDrmRegistrationData<'_>> for GpuvasShow {
+    fn show(reg_data: &TyrDrmRegistrationData<'_>, m: &seq_file::SeqFile) -> Result {
+        reg_data.vm_registry.for_each(|vm| vm.dump_gpuva_info(m))
+    }
+}
diff --git a/drivers/gpu/drm/tyr/driver.rs b/drivers/gpu/drm/tyr/driver.rs
index f26c3bb332e70..20be2dafa8421 100644
--- a/drivers/gpu/drm/tyr/driver.rs
+++ b/drivers/gpu/drm/tyr/driver.rs
@@ -7,6 +7,7 @@
         Clk,
         OptionalClk, //
     },
+    debugfs,
     device::{
         Bound,
         Core,
@@ -45,6 +46,7 @@
 };
 
 use crate::{
+    debugfs::GpuvasShow,
     file::TyrDrmFileData,
     fw::{
         irq::{
@@ -87,6 +89,9 @@ pub(crate) struct TyrDrmRegistrationData<'drm> {
     /// Firmware sections.
     pub(crate) fw: Arc<Firmware<'drm>>,
 
+    /// VM registry, used by debugfs to enumerate GPU VA spaces.
+    pub(crate) vm_registry: Arc<VmRegistry<'drm>>,
+
     #[pin]
     clks: Mutex<Clocks>,
 
@@ -198,6 +203,7 @@ fn probe<'bound>(
         let reg_data = pin_init!(TyrDrmRegistrationData {
                 pdev,
                 fw: firmware,
+                vm_registry: registry,
                 clks <- new_mutex!(Clocks {
                     core: core_clk,
                     stacks: stacks_clk,
@@ -252,6 +258,10 @@ impl drm::Driver for TyrDrmDriver {
     kernel::declare_drm_ioctls! {
         (PANTHOR_DEV_QUERY, drm_panthor_dev_query, ioctl::RENDER_ALLOW, TyrDrmFileData::dev_query),
     }
+
+    fn debugfs_init(dir: &debugfs::ScopeRef<'_, TyrDrmRegistrationData<'_>>) {
+        dir.seq_file::<GpuvasShow>(c"gpuvas");
+    }
 }
 
 struct Clocks {
diff --git a/drivers/gpu/drm/tyr/tyr.rs b/drivers/gpu/drm/tyr/tyr.rs
index e7ec450bdc9c0..6eb13c15d1657 100644
--- a/drivers/gpu/drm/tyr/tyr.rs
+++ b/drivers/gpu/drm/tyr/tyr.rs
@@ -7,6 +7,7 @@
 
 use crate::driver::TyrPlatformDriver;
 
+mod debugfs;
 mod driver;
 mod file;
 mod fw;

-- 
2.43.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.