]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/xe/pf: Make GGTT/LMEM debugfs files per-tile
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Sun, 28 Sep 2025 14:00:28 +0000 (16:00 +0200)
committerMichal Wajdeczko <michal.wajdeczko@intel.com>
Mon, 29 Sep 2025 22:03:52 +0000 (00:03 +0200)
Due to initial design of the Xe debugfs, the GGTT and LMEM files
were defined on the primary GT, instead of being per-tile.

While PF provisioning code is now still maintaining GGTT and LMEM
also on the per primary-GT level, this will be refactored soon,
but we can fix debugfs layout now, as part of the new SR-IOV tree.

For backward compatibility we will provide some symlinks that can
be removed once our tools will be fully converted.

As we are making all those changes in the user facing interface,
take this as apportunity to also start replacing the "LMEM" term,
used by the SR-IOV code, with the "VRAM" term, used by Xe driver.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Link: https://lore.kernel.org/r/20250928140029.198847-7-michal.wajdeczko@intel.com
drivers/gpu/drm/xe/xe_gt_sriov_pf_debugfs.c
drivers/gpu/drm/xe/xe_tile_sriov_pf_debugfs.c

index fbb3cb3200fb5994964c558d8649c7d2d56809a0..44fec2aae5365a381218cfac863b466fea983911 100644 (file)
@@ -100,46 +100,6 @@ static const struct drm_info_list pf_info[] = {
        },
 };
 
-/*
- *      /sys/kernel/debug/dri/BDF/
- *      ├── sriov
- *      :   ├── pf
- *          :   ├── tile0
- *              :   ├── gt0
- *                  :   ├── ggtt_available
- *                      ├── ggtt_provisioned
- */
-
-static const struct drm_info_list pf_ggtt_info[] = {
-       {
-               "ggtt_available",
-               .show = xe_gt_debugfs_simple_show,
-               .data = xe_gt_sriov_pf_config_print_available_ggtt,
-       },
-       {
-               "ggtt_provisioned",
-               .show = xe_gt_debugfs_simple_show,
-               .data = xe_gt_sriov_pf_config_print_ggtt,
-       },
-};
-
-/*
- *      /sys/kernel/debug/dri/BDF/
- *      ├── sriov
- *      :   ├── pf
- *          :   ├── tile0
- *              :   ├── gt0
- *                  :   ├── lmem_provisioned
- */
-
-static const struct drm_info_list pf_lmem_info[] = {
-       {
-               "lmem_provisioned",
-               .show = xe_gt_debugfs_simple_show,
-               .data = xe_gt_sriov_pf_config_print_lmem,
-       },
-};
-
 /*
  *      /sys/kernel/debug/dri/BDF/
  *      ├── sriov
@@ -199,9 +159,7 @@ static void pf_add_policy_attrs(struct xe_gt *gt, struct dentry *parent)
  *      :   ├── pf
  *          │   ├── tile0
  *          │   :   ├── gt0
- *          │       :   ├── ggtt_spare
- *          │           ├── lmem_spare
- *          │           ├── doorbells_spare
+ *          │       :   ├── doorbells_spare
  *          │           ├── contexts_spare
  *          │           ├── exec_quantum_ms
  *          │           ├── preempt_timeout_us
@@ -209,9 +167,7 @@ static void pf_add_policy_attrs(struct xe_gt *gt, struct dentry *parent)
  *          ├── vf1
  *          :   ├── tile0
  *              :   ├── gt0
- *                  :   ├── ggtt_quota
- *                      ├── lmem_quota
- *                      ├── doorbells_quota
+ *                  :   ├── doorbells_quota
  *                      ├── contexts_quota
  *                      ├── exec_quantum_ms
  *                      ├── preempt_timeout_us
@@ -249,8 +205,6 @@ static int CONFIG##_get(void *data, u64 *val)                                       \
                                                                                \
 DEFINE_DEBUGFS_ATTRIBUTE(CONFIG##_fops, CONFIG##_get, CONFIG##_set, FORMAT)
 
-DEFINE_SRIOV_GT_CONFIG_DEBUGFS_ATTRIBUTE(ggtt, u64, "%llu\n");
-DEFINE_SRIOV_GT_CONFIG_DEBUGFS_ATTRIBUTE(lmem, u64, "%llu\n");
 DEFINE_SRIOV_GT_CONFIG_DEBUGFS_ATTRIBUTE(ctxs, u32, "%llu\n");
 DEFINE_SRIOV_GT_CONFIG_DEBUGFS_ATTRIBUTE(dbs, u32, "%llu\n");
 DEFINE_SRIOV_GT_CONFIG_DEBUGFS_ATTRIBUTE(exec_quantum, u32, "%llu\n");
@@ -331,13 +285,6 @@ static void pf_add_config_attrs(struct xe_gt *gt, struct dentry *parent, unsigne
        xe_gt_assert(gt, gt == extract_gt(parent));
        xe_gt_assert(gt, vfid == extract_vfid(parent));
 
-       if (xe_gt_is_main_type(gt)) {
-               debugfs_create_file_unsafe(vfid ? "ggtt_quota" : "ggtt_spare",
-                                          0644, parent, parent, &ggtt_fops);
-               if (xe_device_has_lmtt(gt_to_xe(gt)))
-                       debugfs_create_file_unsafe(vfid ? "lmem_quota" : "lmem_spare",
-                                                  0644, parent, parent, &lmem_fops);
-       }
        debugfs_create_file_unsafe(vfid ? "doorbells_quota" : "doorbells_spare",
                                   0644, parent, parent, &dbs_fops);
        debugfs_create_file_unsafe(vfid ? "contexts_quota" : "contexts_spare",
@@ -558,6 +505,28 @@ static const struct file_operations config_blob_ops = {
        .llseek         = default_llseek,
 };
 
+static void pf_add_compat_attrs(struct xe_gt *gt, struct dentry *dent, unsigned int vfid)
+{
+       struct xe_device *xe = gt_to_xe(gt);
+
+       if (!xe_gt_is_main_type(gt))
+               return;
+
+       if (vfid) {
+               debugfs_create_symlink("ggtt_quota", dent, "../ggtt_quota");
+               if (xe_device_has_lmtt(xe))
+                       debugfs_create_symlink("lmem_quota", dent, "../vram_quota");
+       } else {
+               debugfs_create_symlink("ggtt_spare", dent, "../ggtt_spare");
+               debugfs_create_symlink("ggtt_available", dent, "../ggtt_available");
+               debugfs_create_symlink("ggtt_provisioned", dent, "../ggtt_provisioned");
+               if (xe_device_has_lmtt(xe)) {
+                       debugfs_create_symlink("lmem_spare", dent, "../vram_spare");
+                       debugfs_create_symlink("lmem_provisioned", dent, "../vram_provisioned");
+               }
+       }
+}
+
 static void pf_populate_gt(struct xe_gt *gt, struct dentry *dent, unsigned int vfid)
 {
        struct xe_device *xe = gt_to_xe(gt);
@@ -583,17 +552,10 @@ static void pf_populate_gt(struct xe_gt *gt, struct dentry *dent, unsigned int v
                pf_add_policy_attrs(gt, dent);
 
                drm_debugfs_create_files(pf_info, ARRAY_SIZE(pf_info), dent, minor);
-
-               if (xe_gt_is_main_type(gt)) {
-                       drm_debugfs_create_files(pf_ggtt_info,
-                                                ARRAY_SIZE(pf_ggtt_info),
-                                                dent, minor);
-                       if (xe_device_has_lmtt(xe))
-                               drm_debugfs_create_files(pf_lmem_info,
-                                                        ARRAY_SIZE(pf_lmem_info),
-                                                        dent, minor);
-               }
        }
+
+       /* for backward compatibility only */
+       pf_add_compat_attrs(gt, dent, vfid);
 }
 
 /**
index 335a79d096395bdc4769d63e0cfa322f908a06e8..c8df18af4d00c4179351c51b5d36c2778adeb738 100644 (file)
@@ -8,9 +8,13 @@
 
 #include "xe_device.h"
 #include "xe_device_types.h"
+#include "xe_gt_sriov_pf_config.h"
 #include "xe_gt_sriov_pf_debugfs.h"
+#include "xe_pm.h"
+#include "xe_tile_debugfs.h"
 #include "xe_tile_sriov_pf_debugfs.h"
 #include "xe_sriov.h"
+#include "xe_sriov_pf.h"
 
 /*
  *      /sys/kernel/debug/dri/BDF/
@@ -53,11 +57,143 @@ static unsigned int extract_vfid(struct dentry *d)
        return pp == extract_xe(d) ? PFID : (uintptr_t)pp;
 }
 
+/*
+ *      /sys/kernel/debug/dri/BDF/
+ *      ├── sriov
+ *      :   ├── pf
+ *          :   ├── tile0
+ *              :   ├── ggtt_available
+ *                  ├── ggtt_provisioned
+ */
+
+static int pf_config_print_available_ggtt(struct xe_tile *tile, struct drm_printer *p)
+{
+       return xe_gt_sriov_pf_config_print_available_ggtt(tile->primary_gt, p);
+}
+
+static int pf_config_print_ggtt(struct xe_tile *tile, struct drm_printer *p)
+{
+       return xe_gt_sriov_pf_config_print_ggtt(tile->primary_gt, p);
+}
+
+static const struct drm_info_list pf_ggtt_info[] = {
+       {
+               "ggtt_available",
+               .show = xe_tile_debugfs_simple_show,
+               .data = pf_config_print_available_ggtt,
+       },
+       {
+               "ggtt_provisioned",
+               .show = xe_tile_debugfs_simple_show,
+               .data = pf_config_print_ggtt,
+       },
+};
+
+/*
+ *      /sys/kernel/debug/dri/BDF/
+ *      ├── sriov
+ *      :   ├── pf
+ *          :   ├── tile0
+ *              :   ├── vram_provisioned
+ */
+
+static int pf_config_print_vram(struct xe_tile *tile, struct drm_printer *p)
+{
+       return xe_gt_sriov_pf_config_print_lmem(tile->primary_gt, p);
+}
+
+static const struct drm_info_list pf_vram_info[] = {
+       {
+               "vram_provisioned",
+               .show = xe_tile_debugfs_simple_show,
+               .data = pf_config_print_vram,
+       },
+};
+
+/*
+ *      /sys/kernel/debug/dri/BDF/
+ *      ├── sriov
+ *      │   ├── pf
+ *      │   │   ├── tile0
+ *      │   │   │   ├── ggtt_spare
+ *      │   │   │   ├── vram_spare
+ *      │   │   ├── tile1
+ *      │   │   :   :
+ *      │   ├── vf1
+ *      │   :   ├── tile0
+ *      │       │   ├── ggtt_quota
+ *      │       │   ├── vram_quota
+ *      │       ├── tile1
+ *      │       :   :
+ */
+
+#define DEFINE_SRIOV_TILE_CONFIG_DEBUGFS_ATTRIBUTE(NAME, CONFIG, TYPE, FORMAT) \
+                                                                               \
+static int NAME##_set(void *data, u64 val)                                     \
+{                                                                              \
+       struct xe_tile *tile = extract_tile(data);                              \
+       unsigned int vfid = extract_vfid(data);                                 \
+       struct xe_gt *gt = tile->primary_gt;                                    \
+       struct xe_device *xe = tile->xe;                                        \
+       int err;                                                                \
+                                                                               \
+       if (val > (TYPE)~0ull)                                                  \
+               return -EOVERFLOW;                                              \
+                                                                               \
+       xe_pm_runtime_get(xe);                                                  \
+       err = xe_sriov_pf_wait_ready(xe) ?:                                     \
+             xe_gt_sriov_pf_config_set_##CONFIG(gt, vfid, val);                \
+       xe_pm_runtime_put(xe);                                                  \
+                                                                               \
+       return err;                                                             \
+}                                                                              \
+                                                                               \
+static int NAME##_get(void *data, u64 *val)                                    \
+{                                                                              \
+       struct xe_tile *tile = extract_tile(data);                              \
+       unsigned int vfid = extract_vfid(data);                                 \
+       struct xe_gt *gt = tile->primary_gt;                                    \
+                                                                               \
+       *val = xe_gt_sriov_pf_config_get_##CONFIG(gt, vfid);                    \
+       return 0;                                                               \
+}                                                                              \
+                                                                               \
+DEFINE_DEBUGFS_ATTRIBUTE(NAME##_fops, NAME##_get, NAME##_set, FORMAT)
+
+DEFINE_SRIOV_TILE_CONFIG_DEBUGFS_ATTRIBUTE(ggtt, ggtt, u64, "%llu\n");
+DEFINE_SRIOV_TILE_CONFIG_DEBUGFS_ATTRIBUTE(vram, lmem, u64, "%llu\n");
+
+static void pf_add_config_attrs(struct xe_tile *tile, struct dentry *dent, unsigned int vfid)
+{
+       xe_tile_assert(tile, tile == extract_tile(dent));
+       xe_tile_assert(tile, vfid == extract_vfid(dent));
+
+       debugfs_create_file_unsafe(vfid ? "ggtt_quota" : "ggtt_spare",
+                                  0644, dent, dent, &ggtt_fops);
+       if (xe_device_has_lmtt(tile->xe))
+               debugfs_create_file_unsafe(vfid ? "vram_quota" : "vram_spare",
+                                          0644, dent, dent, &vram_fops);
+}
+
 static void pf_populate_tile(struct xe_tile *tile, struct dentry *dent, unsigned int vfid)
 {
+       struct xe_device *xe = tile->xe;
+       struct drm_minor *minor = xe->drm.primary;
        struct xe_gt *gt;
        unsigned int id;
 
+       pf_add_config_attrs(tile, dent, vfid);
+
+       if (!vfid) {
+               drm_debugfs_create_files(pf_ggtt_info,
+                                        ARRAY_SIZE(pf_ggtt_info),
+                                        dent, minor);
+               if (xe_device_has_lmtt(xe))
+                       drm_debugfs_create_files(pf_vram_info,
+                                                ARRAY_SIZE(pf_vram_info),
+                                                dent, minor);
+       }
+
        for_each_gt_on_tile(gt, tile, id)
                xe_gt_sriov_pf_debugfs_populate(gt, dent, vfid);
 }