[PATCH 3/3] [RFC] drm/xe: Add media rp0/rpn sysfs attributes

Sujaritha Sundaresan sujaritha.sundaresan at intel.com
Tue Dec 19 10:07:11 UTC 2023


Add media frequency sysfs to the balance directory.

device/tile#/gt#/freq0/balance
			|- media_rp0_freq
			|- media_rpn_freq

Signed-off-by: Sujaritha Sundaresan <sujaritha.sundaresan at intel.com>
---
 drivers/gpu/drm/xe/xe_gt_balance_sysfs.c | 47 ++++++++++++++++++++++++
 drivers/gpu/drm/xe/xe_pcode_api.h        |  1 +
 2 files changed, 48 insertions(+)

diff --git a/drivers/gpu/drm/xe/xe_gt_balance_sysfs.c b/drivers/gpu/drm/xe/xe_gt_balance_sysfs.c
index 054b90ca128d..e39629c211d0 100644
--- a/drivers/gpu/drm/xe/xe_gt_balance_sysfs.c
+++ b/drivers/gpu/drm/xe/xe_gt_balance_sysfs.c
@@ -137,11 +137,58 @@ static ssize_t base_rpn_freq_show(struct device *dev, struct device_attribute *a
 }
 static DEVICE_ATTR_RO(base_rpn_freq);
 
+static ssize_t media_rp0_freq_show(struct device *dev, struct device_attribute *attr,
+				   char *buff)
+{
+	struct xe_gt *gt = dev_to_gt(dev);
+	u32 val, mbox;
+	int err;
+
+	mbox = REG_FIELD_PREP(PCODE_MB_COMMAND, PCODE_FREQUENCY_CONFIG)
+		| REG_FIELD_PREP(PCODE_MB_PARAM1, PCODE_MBOX_FC_SC_READ_FUSED_P0)
+		| REG_FIELD_PREP(PCODE_MB_PARAM2, PCODE_MBOX_DOMAIN_MEDIAFF);
+
+	err = xe_pcode_read(gt, mbox, &val, NULL);
+	if (err)
+		return err;
+
+	/* Fused media RP0 read from pcode is in units of 50 MHz */
+	val *= GT_FREQUENCY_MULTIPLIER;
+
+	return sysfs_emit(buff, "%u\n", val);
+}
+static DEVICE_ATTR_RO(media_rp0_freq);
+
+static ssize_t media_rpn_freq_show(struct device *dev, struct device_attribute *attr,
+				   char *buff)
+{
+	struct xe_gt *gt = dev_to_gt(dev);
+	u32 val, mbox;
+	int err;
+
+	mbox = REG_FIELD_PREP(PCODE_MB_COMMAND, PCODE_FREQUENCY_CONFIG)
+		| REG_FIELD_PREP(PCODE_MB_PARAM1, PCODE_MBOX_FC_SC_READ_FUSED_PN)
+		| REG_FIELD_PREP(PCODE_MB_PARAM2, PCODE_MBOX_DOMAIN_MEDIAFF);
+
+	err = xe_pcode_read(gt, mbox, &val, NULL);
+
+	if (err)
+		return err;
+
+	/* Fused media RP0 read from pcode is in units of 50 MHz */
+	val *= GT_FREQUENCY_MULTIPLIER;
+
+	return sysfs_emit(buff, "%u\n", val);
+}
+static DEVICE_ATTR_RO(media_rpn_freq);
+
 static struct attribute *balance_attrs[] = {
 	&dev_attr_base_freq_factor.attr,
 	&dev_attr_base_freq_factor_scale.attr,
 	&dev_attr_base_rp0_freq.attr,
 	&dev_attr_base_rpn_freq.attr,
+	&dev_attr_media_rp0_freq.attr,
+	&dev_attr_media_rpn_freq.attr,
 	NULL
 };
 
diff --git a/drivers/gpu/drm/xe/xe_pcode_api.h b/drivers/gpu/drm/xe/xe_pcode_api.h
index 87213b52df4a..9fe42ef87730 100644
--- a/drivers/gpu/drm/xe/xe_pcode_api.h
+++ b/drivers/gpu/drm/xe/xe_pcode_api.h
@@ -49,6 +49,7 @@
 /* PCODE_MBOX_DOMAIN_* - mailbox domain IDs */
 /* PCODE_FREQUENCY_CONFIG param2 */
 #define     PCODE_MBOX_DOMAIN_HBM		0x2
+#define     PCODE_MBOX_DOMAIN_MEDIAFF		0x3
 #define     PCODE_MBOX_DOMAIN_CHIPLET		0x6
 #define     PCODE_MBOX_DOMAIN_BASE		0x8
 #define   PCODE_QOS_MULTIPLIER_SET		0x67
-- 
2.25.1



More information about the Intel-xe mailing list