[Intel-xe] [PATCH V2 2/3] drm/xe/ats-m: Expose uid for ATS-M via sysfs

Lucas De Marchi lucas.demarchi at intel.com
Tue Nov 28 18:42:13 UTC 2023


On Fri, Nov 24, 2023 at 07:43:10PM +0530, Tejas Upadhyay wrote:
>On ATS-M CSC firmware calculated unique device id(uid) can be
>read from defined registers. Only ATS-M has this way of reading
>uid. Also ATS-M customer require this solution to locate and name
>their devices effectively.

s/Also ATS-M.*//

As this justification doesn't really belong to a commit message.

*This* solution can't be a requirement. *A* solution, with this being
the proposed one, maybe.  Imagine the mess if each customer with each
platform requires a different solution and each solution only works with
one of them.

>
>Consumer of csc uid is level0 sysman and end users using sysman.

so you mean that only ATS-M works with level0 sysman? That seems a very
poor abstraction to be done in the kernel. If we need a uid, let's give
a uid that can support different backends so we don't confine the
support to 1 platform for no reason.

Lucas De Marchi

>
>This patch exports uid to the userspace via sysfs.
>For example, uid can be read by:
>cat /sys/class/drm/cardX/device/csc_uid
>
>V2(Michal):
>  - Make separate patch for csc uid capability
>  - Use %#llx for 0x
>  - Dump error value when sysfs creation fails
>  - Have consistency in csc uid name
>
>Signed-off-by: Tejas Upadhyay <tejas.upadhyay at intel.com>
>---
> drivers/gpu/drm/xe/regs/xe_regs.h    |  3 +++
> drivers/gpu/drm/xe/xe_device.c       | 11 +++++++++++
> drivers/gpu/drm/xe/xe_device_sysfs.c | 21 +++++++++++++++++++++
> drivers/gpu/drm/xe/xe_device_types.h |  2 ++
> 4 files changed, 37 insertions(+)
>
>diff --git a/drivers/gpu/drm/xe/regs/xe_regs.h b/drivers/gpu/drm/xe/regs/xe_regs.h
>index ec9372aa739f..3599c7b38b61 100644
>--- a/drivers/gpu/drm/xe/regs/xe_regs.h
>+++ b/drivers/gpu/drm/xe/regs/xe_regs.h
>@@ -71,6 +71,9 @@
> #define XEHP_CLOCK_GATE_DIS			XE_REG(0x101014)
> #define   SGSI_SIDECLK_DIS			REG_BIT(17)
>
>+#define DEVUID_LWORD				XE_REG(0x102008)
>+#define DEVUID_HWORD				XE_REG(0x10200C)
>+
> #define GGC					XE_REG(0x108040)
> #define   GMS_MASK				REG_GENMASK(15, 8)
> #define   GGMS_MASK				REG_GENMASK(7, 6)
>diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
>index 8be765adf702..6c8a9f9d69c9 100644
>--- a/drivers/gpu/drm/xe/xe_device.c
>+++ b/drivers/gpu/drm/xe/xe_device.c
>@@ -342,6 +342,15 @@ static void xe_device_sanitize(struct drm_device *drm, void *arg)
> 		xe_gt_sanitize(gt);
> }
>
>+static void xe_read_csc_uid(struct xe_device *xe)
>+{
>+	if (xe->info.has_csc_uid) {
>+		struct xe_gt *mmio = xe_root_mmio_gt(xe);
>+
>+		xe->info.csc_uid  = xe_mmio_read64_2x32(mmio, DEVUID_LWORD);
>+	}
>+}
>+
> int xe_device_probe(struct xe_device *xe)
> {
> 	struct xe_tile *tile;
>@@ -366,6 +375,8 @@ int xe_device_probe(struct xe_device *xe)
> 	if (err)
> 		return err;
>
>+	xe_read_csc_uid(xe);
>+
> 	err = drmm_add_action_or_reset(&xe->drm, xe_driver_flr_fini, xe);
> 	if (err)
> 		return err;
>diff --git a/drivers/gpu/drm/xe/xe_device_sysfs.c b/drivers/gpu/drm/xe/xe_device_sysfs.c
>index 99113a5a2b84..4fbf0275d3bf 100644
>--- a/drivers/gpu/drm/xe/xe_device_sysfs.c
>+++ b/drivers/gpu/drm/xe/xe_device_sysfs.c
>@@ -65,11 +65,24 @@ vram_d3cold_threshold_store(struct device *dev, struct device_attribute *attr,
>
> static DEVICE_ATTR_RW(vram_d3cold_threshold);
>
>+static ssize_t csc_uid_show(struct device *dev,
>+			    struct device_attribute *attr,
>+			    char *buf)
>+{
>+	struct pci_dev *pdev = to_pci_dev(dev);
>+	struct xe_device *xe = pdev_to_xe_device(pdev);
>+
>+	return sysfs_emit(buf, "%#llx\n", xe->info.csc_uid);
>+}
>+
>+static DEVICE_ATTR_RO(csc_uid);
>+
> static void xe_device_sysfs_fini(struct drm_device *drm, void *arg)
> {
> 	struct xe_device *xe = arg;
>
> 	sysfs_remove_file(&xe->drm.dev->kobj, &dev_attr_vram_d3cold_threshold.attr);
>+	sysfs_remove_file(&xe->drm.dev->kobj, &dev_attr_csc_uid.attr);
> }
>
> void xe_device_sysfs_init(struct xe_device *xe)
>@@ -83,6 +96,14 @@ void xe_device_sysfs_init(struct xe_device *xe)
> 		return;
> 	}
>
>+	if (xe->info.has_csc_uid) {
>+		ret = sysfs_create_file(&dev->kobj, &dev_attr_csc_uid.attr);
>+		if (ret) {
>+			drm_warn(&xe->drm, "UID sysfs setup failed err=%pe\n", ERR_PTR(ret));
>+			return;
>+		}
>+	}
>+
> 	ret = drmm_add_action_or_reset(&xe->drm, xe_device_sysfs_fini, xe);
> 	if (ret)
> 		drm_warn(&xe->drm, "Failed to add sysfs fini drm action\n");
>diff --git a/drivers/gpu/drm/xe/xe_device_types.h b/drivers/gpu/drm/xe/xe_device_types.h
>index a28257b26355..eb3897309dac 100644
>--- a/drivers/gpu/drm/xe/xe_device_types.h
>+++ b/drivers/gpu/drm/xe/xe_device_types.h
>@@ -238,6 +238,8 @@ struct xe_device {
> 		u8 vm_max_level;
> 		/** @va_bits: Maximum bits of a virtual address */
> 		u8 va_bits;
>+		/** @csc_uid: device uid calculated by CSC FW, used for generating uuid */
>+		u64 csc_uid;
>
> 		/** @is_dgfx: is discrete device */
> 		u8 is_dgfx:1;
>-- 
>2.25.1
>


More information about the Intel-xe mailing list