Skip to contentSkip to conversation

Add some performance and frequency sysfs nodes

PATCH Superseded Sujaritha Sundaresan 3 participants 17 messages Sep 1, 2023 – Sep 26, 2023

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Add some performance and frequency sysfs nodes

Adding base performace and vram frequency attributes to sysfs.

Sujaritha Sundaresan (3):
drm/xe: Add a couple of pcode helpers
drm/xe: Add base performance sysfs attributes drm/xe: Sysfs entries to query vram fused min, max frequency

 drivers/gpu/drm/xe/xe_guc_pc.c    | 170 ++++++++++++++++++++++++++++++
 drivers/gpu/drm/xe/xe_pcode.c     |  28 +++++
 drivers/gpu/drm/xe/xe_pcode.h     |   3 +
 drivers/gpu/drm/xe/xe_pcode_api.h |  19 ++++
 4 files changed, 220 insertions(+)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/3 drm/xe: Add a couple of pcode helpers

Some pcode commands take additional sub-commands and parameters. Add a couple of helpers to help formatting these commands to improve code readability.

---
 drivers/gpu/drm/xe/xe_pcode.c | 28 ++++++++++++++++++++++++++++
 drivers/gpu/drm/xe/xe_pcode.h |  3 +++
 2 files changed, 31 insertions(+)
drivers/gpu/drm/xe/xe_pcode.c +28 -0
index 7f1bf2297f51..e45169f47500 100644
@@ -104,6 +104,34 @@ int xe_pcode_read(struct xe_gt *gt, u32 mbox, u32 *val, u32 *val1)
 	return err;
 }
 
+int xe_pcode_read_p(struct xe_gt *gt, u32 mbcmd, u32 p1, u32 p2, u32 *val)
+{
+	u32 mbox;
+	int err;
+
+	mbox = REG_FIELD_PREP(PCODE_MB_COMMAND, mbcmd)
+		| REG_FIELD_PREP(PCODE_MB_PARAM1, p1)
+		| REG_FIELD_PREP(PCODE_MB_PARAM2, p2);
+
+	err = xe_pcode_read(gt, mbox, val, NULL);
+
+	return err;
+}
+
+int xe_pcode_write_p(struct xe_gt *gt, u32 mbcmd, u32 p1, u32 p2, u32 val)
+{
+	u32 mbox;
+	int err;
+
+	mbox = REG_FIELD_PREP(PCODE_MB_COMMAND, mbcmd)
+		| REG_FIELD_PREP(PCODE_MB_PARAM1, p1)
+		| REG_FIELD_PREP(PCODE_MB_PARAM2, p2);
+
+	err = xe_pcode_write(gt, mbox, val);
+
+	return err;
+}
+
 static int xe_pcode_try_request(struct xe_gt *gt, u32 mbox,
 				u32 request, u32 reply_mask, u32 reply,
 				u32 *status, bool atomic, int timeout_us)
drivers/gpu/drm/xe/xe_pcode.h +3 -0
index 3b4aa8c1a3ba..8d4103afd7e0 100644
@@ -19,6 +19,9 @@ int xe_pcode_write_timeout(struct xe_gt *gt, u32 mbox, u32 val,
 #define xe_pcode_write(gt, mbox, val) \
 	xe_pcode_write_timeout(gt, mbox, val, 1)
 
+int xe_pcode_read_p(struct xe_gt *gt, u32 mbcmd, u32 p1, u32 p2, u32 *val);
+int xe_pcode_write_p(struct xe_gt *gt, u32 mbcmd, u32 p1, u32 p2, u32 val);
+
 int xe_pcode_request(struct xe_gt *gt, u32 mbox, u32 request,
 		     u32 reply_mask, u32 reply, int timeout_ms);
 
Signature · 1 line
2.25.1
maintainer
#2 lore raw

Re: [Intel-xe] [PATCH 1/3] drm/xe: Add a couple of pcode helpers

Quoted 15 lines · Sujaritha Sundaresan

Some pcode commands take additional sub-commands and parameters. Add a couple of helpers to help formatting these commands to improve code readability.

---
 drivers/gpu/drm/xe/xe_pcode.c | 28 ++++++++++++++++++++++++++++
 drivers/gpu/drm/xe/xe_pcode.h |  3 +++
 2 files changed, 31 insertions(+)
drivers/gpu/drm/xe/xe_pcode.c +0 -0
index 7f1bf2297f51..e45169f47500 100644

drivers/gpu/drm/xe/xe_pcode.c int xe_pcode_read(struct xe_gt *gt, u32 mbox, u32 *val, u32 *val1) · line 106

Quoted 3 lines
drivers/gpu/drm/xe/xe_pcode.c +0 -0
@@ -104,6 +104,34 @@ int xe_pcode_read(struct xe_gt *gt, u32 mbox, u32 *val, u32 *val1)
 	return err;
 }
 

a doc would be required...

drivers/gpu/drm/xe/xe_pcode.c int xe_pcode_read(struct xe_gt *gt, u32 mbox, u32 *val, u32 *val1) · line 107

Quoted 1 line
drivers/gpu/drm/xe/xe_pcode.c +1 -0
+int xe_pcode_read_p(struct xe_gt *gt, u32 mbcmd, u32 p1, u32 p2, u32 *val)

a better name would be nice....

drivers/gpu/drm/xe/xe_pcode.c int xe_pcode_read(struct xe_gt *gt, u32 mbox, u32 *val, u32 *val1) · line 116

Quoted 9 lines
drivers/gpu/drm/xe/xe_pcode.c +9 -0
+{
+	u32 mbox;
+	int err;
+
+	mbox = REG_FIELD_PREP(PCODE_MB_COMMAND, mbcmd)
+		| REG_FIELD_PREP(PCODE_MB_PARAM1, p1)
+		| REG_FIELD_PREP(PCODE_MB_PARAM2, p2);
+
+	err = xe_pcode_read(gt, mbox, val, NULL);

but why not simply modifying the existent one to accept 2 params?

int xe_pcode_read(struct xe_gt *gt, u32 mbox_param1, u32 mbox_param2,

    		  u32 *val, u32 *val1)

and the equivalent write...

oh, and while doing that, could you please add the missing documentation to these 2 functions?

Thanks,
Rodrigo.

Quoted 38 lines
drivers/gpu/drm/xe/xe_pcode.c +18 -0
+
+	return err;
+}
+
+int xe_pcode_write_p(struct xe_gt *gt, u32 mbcmd, u32 p1, u32 p2, u32 val)
+{
+	u32 mbox;
+	int err;
+
+	mbox = REG_FIELD_PREP(PCODE_MB_COMMAND, mbcmd)
+		| REG_FIELD_PREP(PCODE_MB_PARAM1, p1)
+		| REG_FIELD_PREP(PCODE_MB_PARAM2, p2);
+
+	err = xe_pcode_write(gt, mbox, val);
+
+	return err;
+}
+
 static int xe_pcode_try_request(struct xe_gt *gt, u32 mbox,
 				u32 request, u32 reply_mask, u32 reply,
 				u32 *status, bool atomic, int timeout_us)
drivers/gpu/drm/xe/xe_pcode.h +3 -0
index 3b4aa8c1a3ba..8d4103afd7e0 100644
@@ -19,6 +19,9 @@ int xe_pcode_write_timeout(struct xe_gt *gt, u32 mbox, u32 val,
 #define xe_pcode_write(gt, mbox, val) \
 	xe_pcode_write_timeout(gt, mbox, val, 1)
 
+int xe_pcode_read_p(struct xe_gt *gt, u32 mbcmd, u32 p1, u32 p2, u32 *val);
+int xe_pcode_write_p(struct xe_gt *gt, u32 mbcmd, u32 p1, u32 p2, u32 val);
+
 int xe_pcode_request(struct xe_gt *gt, u32 mbox, u32 request,
 		     u32 reply_mask, u32 reply, int timeout_ms);
 
Signature · 1 line
2.25.1
#3 lore raw

Re: [Intel-xe] [PATCH 1/3] drm/xe: Add a couple of pcode helpers

Quoted 38 lines · Rodrigo Vivi
Quoted 15 lines · Sujaritha Sundaresan

Some pcode commands take additional sub-commands and parameters. Add a couple of helpers to help formatting these commands to improve code readability.

---
  drivers/gpu/drm/xe/xe_pcode.c | 28 ++++++++++++++++++++++++++++
  drivers/gpu/drm/xe/xe_pcode.h |  3 +++
  2 files changed, 31 insertions(+)
drivers/gpu/drm/xe/xe_pcode.c +0 -0
index 7f1bf2297f51..e45169f47500 100644

drivers/gpu/drm/xe/xe_pcode.c int xe_pcode_read(struct xe_gt *gt, u32 mbox, u32 *val, u32 *val1) · line 106

Quoted 3 lines
drivers/gpu/drm/xe/xe_pcode.c +0 -0
@@ -104,6 +104,34 @@ int xe_pcode_read(struct xe_gt *gt, u32 mbox, u32 *val, u32 *val1)
  	return err;
  }
 

a doc would be required...

drivers/gpu/drm/xe/xe_pcode.c int xe_pcode_read(struct xe_gt *gt, u32 mbox, u32 *val, u32 *val1) · line 107

Quoted 1 line
drivers/gpu/drm/xe/xe_pcode.c +1 -0
+int xe_pcode_read_p(struct xe_gt *gt, u32 mbcmd, u32 p1, u32 p2, u32 *val)

a better name would be nice....

drivers/gpu/drm/xe/xe_pcode.c int xe_pcode_read(struct xe_gt *gt, u32 mbox, u32 *val, u32 *val1) · line 116

Quoted 9 lines
drivers/gpu/drm/xe/xe_pcode.c +9 -0
+{
+	u32 mbox;
+	int err;
+
+	mbox = REG_FIELD_PREP(PCODE_MB_COMMAND, mbcmd)
+		| REG_FIELD_PREP(PCODE_MB_PARAM1, p1)
+		| REG_FIELD_PREP(PCODE_MB_PARAM2, p2);
+
+	err = xe_pcode_read(gt, mbox, val, NULL);

but why not simply modifying the existent one to accept 2 params?

int xe_pcode_read(struct xe_gt *gt, u32 mbox_param1, u32 mbox_param2,

     		  u32 *val, u32 *val1)
Quoted 7 lines

and the equivalent write...

oh, and while doing that, could you please add the missing documentation to these 2 functions?

Thanks,
Rodrigo.

Sure that would work. Will add the docs as well.

Thanks,

Suja

Quoted 39 lines
Quoted 39 lines
drivers/gpu/drm/xe/xe_pcode.c +18 -0
+
+	return err;
+}
+
+int xe_pcode_write_p(struct xe_gt *gt, u32 mbcmd, u32 p1, u32 p2, u32 val)
+{
+	u32 mbox;
+	int err;
+
+	mbox = REG_FIELD_PREP(PCODE_MB_COMMAND, mbcmd)
+		| REG_FIELD_PREP(PCODE_MB_PARAM1, p1)
+		| REG_FIELD_PREP(PCODE_MB_PARAM2, p2);
+
+	err = xe_pcode_write(gt, mbox, val);
+
+	return err;
+}
+
  static int xe_pcode_try_request(struct xe_gt *gt, u32 mbox,
  				u32 request, u32 reply_mask, u32 reply,
  				u32 *status, bool atomic, int timeout_us)
drivers/gpu/drm/xe/xe_pcode.h +3 -0
index 3b4aa8c1a3ba..8d4103afd7e0 100644
@@ -19,6 +19,9 @@ int xe_pcode_write_timeout(struct xe_gt *gt, u32 mbox, u32 val,
  #define xe_pcode_write(gt, mbox, val) \
  	xe_pcode_write_timeout(gt, mbox, val, 1)
 
+int xe_pcode_read_p(struct xe_gt *gt, u32 mbcmd, u32 p1, u32 p2, u32 *val);
+int xe_pcode_write_p(struct xe_gt *gt, u32 mbcmd, u32 p1, u32 p2, u32 val);
+
  int xe_pcode_request(struct xe_gt *gt, u32 mbox, u32 request,
  		     u32 reply_mask, u32 reply, int timeout_ms);
 
Signature · 1 line
2.25.1
#4 lore raw

Re: [Intel-xe] [PATCH 1/3] drm/xe: Add a couple of pcode helpers

Quoted 46 lines · Sujaritha
Quoted 44 lines · Rodrigo Vivi
Quoted 15 lines · Sujaritha Sundaresan

Some pcode commands take additional sub-commands and parameters. Add a couple of helpers to help formatting these commands to improve code readability.

---
  drivers/gpu/drm/xe/xe_pcode.c | 28 ++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_pcode.h |  3 +++

  2 files changed, 31 insertions(+)
drivers/gpu/drm/xe/xe_pcode.c +0 -0
index 7f1bf2297f51..e45169f47500 100644

drivers/gpu/drm/xe/xe_pcode.c int xe_pcode_read(struct xe_gt *gt, u32 mbox, · line 106

Quoted 3 lines
drivers/gpu/drm/xe/xe_pcode.c +0 -0
@@ -104,6 +104,34 @@ int xe_pcode_read(struct xe_gt *gt, u32 mbox, 
 u32 *val, u32 *val1)
       return err;
   }

a doc would be required...

drivers/gpu/drm/xe/xe_pcode.c int xe_pcode_read(struct xe_gt *gt, u32 mbox, · line 108

Quoted 2 lines
drivers/gpu/drm/xe/xe_pcode.c +1 -0
+int xe_pcode_read_p(struct xe_gt *gt, u32 mbcmd, u32 p1, u32 p2, 
 u32 *val)

a better name would be nice....

drivers/gpu/drm/xe/xe_pcode.c int xe_pcode_read(struct xe_gt *gt, u32 mbox, u32 *val, u32 *val1) · line 116

Quoted 9 lines
drivers/gpu/drm/xe/xe_pcode.c +9 -0
+{
+    u32 mbox;
+    int err;
+
+    mbox = REG_FIELD_PREP(PCODE_MB_COMMAND, mbcmd)
+        | REG_FIELD_PREP(PCODE_MB_PARAM1, p1)
+        | REG_FIELD_PREP(PCODE_MB_PARAM2, p2);
+
+    err = xe_pcode_read(gt, mbox, val, NULL);

but why not simply modifying the existent one to accept 2 params?

int xe_pcode_read(struct xe_gt *gt, u32 mbox_param1, u32 mbox_param2, u32 *val, u32 *val1)

and the equivalent write...

oh, and while doing that, could you please add the missing documentation to these 2 functions?

Quoted 8 lines
Quoted 2 lines

Thanks,
Rodrigo.

Sure that would work. Will add the docs as well.

Thanks,

Suja

Hi Rodrigo,

Another question,

I can change the existing pcode_read function, but would it be better to have a separate new write equivalent ?

Quoted 41 lines
Quoted 41 lines
Quoted 41 lines
drivers/gpu/drm/xe/xe_pcode.c +18 -0
+
+    return err;
+}
+
+int xe_pcode_write_p(struct xe_gt *gt, u32 mbcmd, u32 p1, u32 p2, 
 u32 val)
+{
+    u32 mbox;
+    int err;
+
+    mbox = REG_FIELD_PREP(PCODE_MB_COMMAND, mbcmd)
+        | REG_FIELD_PREP(PCODE_MB_PARAM1, p1)
+        | REG_FIELD_PREP(PCODE_MB_PARAM2, p2);
+
+    err = xe_pcode_write(gt, mbox, val);
+
+    return err;
+}
+
   static int xe_pcode_try_request(struct xe_gt *gt, u32 mbox,

                  u32 request, u32 reply_mask, u32 reply, u32 *status, bool atomic, int timeout_us)

drivers/gpu/drm/xe/xe_pcode.h +2 -0
index 3b4aa8c1a3ba..8d4103afd7e0 100644
@@ -19,6 +19,9 @@ int xe_pcode_write_timeout(struct xe_gt *gt, u32 
 mbox, u32 val,
   #define xe_pcode_write(gt, mbox, val) \
       xe_pcode_write_timeout(gt, mbox, val, 1)
   +int xe_pcode_read_p(struct xe_gt *gt, u32 mbcmd, u32 p1, u32 p2, u32 *val);
+int xe_pcode_write_p(struct xe_gt *gt, u32 mbcmd, u32 p1, u32 p2, 
 u32 val);
+
   int xe_pcode_request(struct xe_gt *gt, u32 mbox, u32 request,

               u32 reply_mask, u32 reply, int timeout_ms); --
2.25.1

maintainer
#5 lore raw

Re: [Intel-xe] [PATCH 1/3] drm/xe: Add a couple of pcode helpers

Quoted 56 lines · Sujaritha
Quoted 54 lines · Sujaritha
Quoted 40 lines · Rodrigo Vivi
Quoted 16 lines · Sujaritha Sundaresan

Some pcode commands take additional sub-commands and parameters. Add a couple of helpers to help formatting these commands to improve code readability.

---
  drivers/gpu/drm/xe/xe_pcode.c | 28 ++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_pcode.h |  3 +++

  2 files changed, 31 insertions(+)
drivers/gpu/drm/xe/xe_pcode.c +0 -0
index 7f1bf2297f51..e45169f47500 100644

drivers/gpu/drm/xe/xe_pcode.c int xe_pcode_read(struct xe_gt *gt, u32 · line 106

Quoted 3 lines
drivers/gpu/drm/xe/xe_pcode.c +0 -0
@@ -104,6 +104,34 @@ int xe_pcode_read(struct xe_gt *gt, u32
 mbox, u32 *val, u32 *val1)
       return err;
   }

a doc would be required...

drivers/gpu/drm/xe/xe_pcode.c int xe_pcode_read(struct xe_gt *gt, u32 · line 108

Quoted 2 lines
drivers/gpu/drm/xe/xe_pcode.c +1 -0
+int xe_pcode_read_p(struct xe_gt *gt, u32 mbcmd, u32 p1, u32
 p2, u32 *val)

a better name would be nice....

drivers/gpu/drm/xe/xe_pcode.c int xe_pcode_read(struct xe_gt *gt, u32 mbox, u32 *val, u32 *val1) · line 116

Quoted 9 lines
drivers/gpu/drm/xe/xe_pcode.c +9 -0
+{
+    u32 mbox;
+    int err;
+
+    mbox = REG_FIELD_PREP(PCODE_MB_COMMAND, mbcmd)
+        | REG_FIELD_PREP(PCODE_MB_PARAM1, p1)
+        | REG_FIELD_PREP(PCODE_MB_PARAM2, p2);
+
+    err = xe_pcode_read(gt, mbox, val, NULL);

but why not simply modifying the existent one to accept 2 params?

int xe_pcode_read(struct xe_gt *gt, u32 mbox_param1, u32 mbox_param2, u32 *val, u32 *val1)

Quoted 7 lines

and the equivalent write...

oh, and while doing that, could you please add the missing documentation to these 2 functions?

Thanks,
Rodrigo.

Sure that would work. Will add the docs as well.

Thanks,

Quoted 8 lines
Quoted 1 line

Suja

Hi Rodrigo,

Another question,

I can change the existing pcode_read function, but would it be better to have a separate new write equivalent ?

I wonder if we should do s/xe_pcode_write_timeout(/xe_pcode_write(

where timeout is still an argument but it can be null. And then we merge with your options here and make a single write fn.

Quoted 44 lines
Quoted 44 lines
Quoted 44 lines
Quoted 44 lines
drivers/gpu/drm/xe/xe_pcode.c +18 -0
+
+    return err;
+}
+
+int xe_pcode_write_p(struct xe_gt *gt, u32 mbcmd, u32 p1, u32
 p2, u32 val)
+{
+    u32 mbox;
+    int err;
+
+    mbox = REG_FIELD_PREP(PCODE_MB_COMMAND, mbcmd)
+        | REG_FIELD_PREP(PCODE_MB_PARAM1, p1)
+        | REG_FIELD_PREP(PCODE_MB_PARAM2, p2);
+
+    err = xe_pcode_write(gt, mbox, val);
+
+    return err;
+}
+
   static int xe_pcode_try_request(struct xe_gt *gt, u32 mbox,

                  u32 request, u32 reply_mask, u32 reply, u32 *status, bool atomic, int timeout_us)

drivers/gpu/drm/xe/xe_pcode.h +0 -0
index 3b4aa8c1a3ba..8d4103afd7e0 100644
@@ -19,6 +19,9 @@ int xe_pcode_write_timeout(struct xe_gt *gt,
 u32 mbox, u32 val,
   #define xe_pcode_write(gt, mbox, val) \
       xe_pcode_write_timeout(gt, mbox, val, 1)

  +int xe_pcode_read_p(struct xe_gt *gt, u32 mbcmd, u32 p1, u32 p2, u32 *val);
+int xe_pcode_write_p(struct xe_gt *gt, u32 mbcmd, u32 p1, u32 p2, u32 val);
+
  int xe_pcode_request(struct xe_gt *gt, u32 mbox, u32 request, u32 reply_mask, u32 reply, int timeout_ms); --
2.25.1

#6 lore raw

Re: [Intel-xe] [PATCH 1/3] drm/xe: Add a couple of pcode helpers

Quoted 57 lines · Rodrigo Vivi
Quoted 56 lines · Sujaritha
Quoted 46 lines · Sujaritha
Quoted 45 lines · Rodrigo Vivi
Quoted 16 lines · Sujaritha Sundaresan

Some pcode commands take additional sub-commands and parameters. Add a couple of helpers to help formatting these commands to improve code readability.

---
   drivers/gpu/drm/xe/xe_pcode.c | 28 ++++++++++++++++++++++++++++
   drivers/gpu/drm/xe/xe_pcode.h |  3 +++
   2 files changed, 31 insertions(+)
drivers/gpu/drm/xe/xe_pcode.c +0 -0
index 7f1bf2297f51..e45169f47500 100644

drivers/gpu/drm/xe/xe_pcode.c int xe_pcode_read(struct xe_gt *gt, u32 · line 106

Quoted 3 lines
drivers/gpu/drm/xe/xe_pcode.c +0 -0
@@ -104,6 +104,34 @@ int xe_pcode_read(struct xe_gt *gt, u32
 mbox, u32 *val, u32 *val1)
       return err;
   }

a doc would be required...

drivers/gpu/drm/xe/xe_pcode.c int xe_pcode_read(struct xe_gt *gt, u32 · line 108

Quoted 2 lines
drivers/gpu/drm/xe/xe_pcode.c +1 -0
+int xe_pcode_read_p(struct xe_gt *gt, u32 mbcmd, u32 p1, u32
 p2, u32 *val)

a better name would be nice....

drivers/gpu/drm/xe/xe_pcode.c int xe_pcode_read(struct xe_gt *gt, u32 mbox, u32 *val, u32 *val1) · line 116

Quoted 9 lines
drivers/gpu/drm/xe/xe_pcode.c +9 -0
+{
+    u32 mbox;
+    int err;
+
+    mbox = REG_FIELD_PREP(PCODE_MB_COMMAND, mbcmd)
+        | REG_FIELD_PREP(PCODE_MB_PARAM1, p1)
+        | REG_FIELD_PREP(PCODE_MB_PARAM2, p2);
+
+    err = xe_pcode_read(gt, mbox, val, NULL);

but why not simply modifying the existent one to accept 2 params?

int xe_pcode_read(struct xe_gt *gt, u32 mbox_param1, u32 mbox_param2,
               u32 *val, u32 *val1)

and the equivalent write...

oh, and while doing that, could you please add the missing documentation to these 2 functions?

Quoted 7 lines
Quoted 2 lines

Thanks,
Rodrigo.

Sure that would work. Will add the docs as well.

Thanks,

Suja

Hi Rodrigo,

Quoted 8 lines
Quoted 4 lines

Another question,

I can change the existing pcode_read function, but would it be better to have a separate new write equivalent ?

I wonder if we should do s/xe_pcode_write_timeout(/xe_pcode_write(

where timeout is still an argument but it can be null. And then we merge with your options here and make a single write fn.

I'll see if this works out.

Thanks,

Suja

Quoted 42 lines
Quoted 42 lines
Quoted 42 lines
Quoted 42 lines
Quoted 42 lines
drivers/gpu/drm/xe/xe_pcode.c +18 -0
+
+    return err;
+}
+
+int xe_pcode_write_p(struct xe_gt *gt, u32 mbcmd, u32 p1, u32
 p2, u32 val)
+{
+    u32 mbox;
+    int err;
+
+    mbox = REG_FIELD_PREP(PCODE_MB_COMMAND, mbcmd)
+        | REG_FIELD_PREP(PCODE_MB_PARAM1, p1)
+        | REG_FIELD_PREP(PCODE_MB_PARAM2, p2);
+
+    err = xe_pcode_write(gt, mbox, val);
+
+    return err;
+}
+
   static int xe_pcode_try_request(struct xe_gt *gt, u32 mbox,

                  u32 request, u32 reply_mask, u32 reply, u32 *status, bool atomic, int timeout_us)

drivers/gpu/drm/xe/xe_pcode.h +2 -0
index 3b4aa8c1a3ba..8d4103afd7e0 100644
@@ -19,6 +19,9 @@ int xe_pcode_write_timeout(struct xe_gt *gt,
 u32 mbox, u32 val,
   #define xe_pcode_write(gt, mbox, val) \
       xe_pcode_write_timeout(gt, mbox, val, 1)
   +int xe_pcode_read_p(struct xe_gt *gt, u32 mbcmd, u32 p1, u32
 p2, u32 *val);
+int xe_pcode_write_p(struct xe_gt *gt, u32 mbcmd, u32 p1, u32
 p2, u32 val);
+
   int xe_pcode_request(struct xe_gt *gt, u32 mbox, u32 request,
                u32 reply_mask, u32 reply, int timeout_ms);
   --

2.25.1

#7 lore raw

Re: [Intel-xe] [PATCH 1/3] drm/xe: Add a couple of pcode helpers

Quoted 65 lines · Sujaritha
Quoted 63 lines · Rodrigo Vivi
Quoted 53 lines · Sujaritha
Quoted 52 lines · Sujaritha
Quoted 40 lines · Rodrigo Vivi
Quoted 16 lines · Sujaritha Sundaresan

Some pcode commands take additional sub-commands and parameters. Add a couple of helpers to help formatting these commands to improve code readability.

---
   drivers/gpu/drm/xe/xe_pcode.c | 28 ++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_pcode.h |  3 +++

   2 files changed, 31 insertions(+)
drivers/gpu/drm/xe/xe_pcode.c +0 -0
index 7f1bf2297f51..e45169f47500 100644

drivers/gpu/drm/xe/xe_pcode.c int xe_pcode_read(struct xe_gt *gt, u32 · line 106

Quoted 3 lines
drivers/gpu/drm/xe/xe_pcode.c +0 -0
@@ -104,6 +104,34 @@ int xe_pcode_read(struct xe_gt *gt, u32
 mbox, u32 *val, u32 *val1)
        return err;
    }

a doc would be required...

drivers/gpu/drm/xe/xe_pcode.c int xe_pcode_read(struct xe_gt *gt, u32 · line 108

Quoted 2 lines
drivers/gpu/drm/xe/xe_pcode.c +1 -0
+int xe_pcode_read_p(struct xe_gt *gt, u32 mbcmd, u32 p1, u32
 p2, u32 *val)

a better name would be nice....

drivers/gpu/drm/xe/xe_pcode.c int xe_pcode_read(struct xe_gt *gt, u32 mbox, u32 *val, u32 *val1) · line 116

Quoted 9 lines
drivers/gpu/drm/xe/xe_pcode.c +9 -0
+{
+    u32 mbox;
+    int err;
+
+    mbox = REG_FIELD_PREP(PCODE_MB_COMMAND, mbcmd)
+        | REG_FIELD_PREP(PCODE_MB_PARAM1, p1)
+        | REG_FIELD_PREP(PCODE_MB_PARAM2, p2);
+
+    err = xe_pcode_read(gt, mbox, val, NULL);

but why not simply modifying the existent one to accept 2 params?

int xe_pcode_read(struct xe_gt *gt, u32 mbox_param1, u32 mbox_param2, u32 *val, u32 *val1)

Quoted 7 lines

and the equivalent write...

oh, and while doing that, could you please add the missing documentation to these 2 functions?

Thanks,
Rodrigo.

Sure that would work. Will add the docs as well.

Thanks,

Quoted 7 lines
Quoted 1 line

Suja

Hi Rodrigo,

Another question,

I can change the existing pcode_read function, but would it be better to have a separate new write equivalent ?

I wonder if we should do s/xe_pcode_write_timeout(/xe_pcode_write(

Quoted 9 lines
Quoted 2 lines

where timeout is still an argument but it can be null. And then we merge with your options here and make a single write fn.

I'll see if this works out.

Thanks,

Suja

Hi Rodrigo,

As I am making the final fixes, looks like it would be better to have separate new read/write functions.

With changing the existing read/write functions, we are having to change the pcode_mailbox_rw function.

That is causing issues with other existing functions. Shall I keep the new functions defined separately ?

Thanks,

Suja

Quoted 42 lines
Quoted 42 lines
Quoted 42 lines
Quoted 42 lines
Quoted 42 lines
Quoted 42 lines
drivers/gpu/drm/xe/xe_pcode.c +18 -0
+
+    return err;
+}
+
+int xe_pcode_write_p(struct xe_gt *gt, u32 mbcmd, u32 p1, u32
 p2, u32 val)
+{
+    u32 mbox;
+    int err;
+
+    mbox = REG_FIELD_PREP(PCODE_MB_COMMAND, mbcmd)
+        | REG_FIELD_PREP(PCODE_MB_PARAM1, p1)
+        | REG_FIELD_PREP(PCODE_MB_PARAM2, p2);
+
+    err = xe_pcode_write(gt, mbox, val);
+
+    return err;
+}
+
    static int xe_pcode_try_request(struct xe_gt *gt, u32 mbox,

                   u32 request, u32 reply_mask, u32 reply, u32 *status, bool atomic, int timeout_us)

drivers/gpu/drm/xe/xe_pcode.h +0 -0
index 3b4aa8c1a3ba..8d4103afd7e0 100644
@@ -19,6 +19,9 @@ int xe_pcode_write_timeout(struct xe_gt *gt,
 u32 mbox, u32 val,
    #define xe_pcode_write(gt, mbox, val) \
        xe_pcode_write_timeout(gt, mbox, val, 1)

   +int xe_pcode_read_p(struct xe_gt *gt, u32 mbcmd, u32 p1, u32 p2, u32 *val);
+int xe_pcode_write_p(struct xe_gt *gt, u32 mbcmd, u32 p1, u32 p2, u32 val);
+
   int xe_pcode_request(struct xe_gt *gt, u32 mbox, u32 request, u32 reply_mask, u32 reply, int timeout_ms); --
2.25.1

maintainer
#8 lore raw

Re: [Intel-xe] [PATCH 1/3] drm/xe: Add a couple of pcode helpers

Quoted 81 lines · Sujaritha
Quoted 68 lines · Sujaritha
Quoted 66 lines · Rodrigo Vivi
Quoted 55 lines · Sujaritha
Quoted 54 lines · Sujaritha
Quoted 41 lines · Rodrigo Vivi
Quoted 17 lines · Sujaritha Sundaresan

Some pcode commands take additional sub-commands and parameters. Add a
couple of helpers to help formatting these commands to improve code readability.

---
   drivers/gpu/drm/xe/xe_pcode.c | 28 ++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_pcode.h |  3 +++

   2 files changed, 31 insertions(+)
drivers/gpu/drm/xe/xe_pcode.c +0 -0
index 7f1bf2297f51..e45169f47500 100644

drivers/gpu/drm/xe/xe_pcode.c int xe_pcode_read(struct xe_gt *gt, u32 · line 106

Quoted 3 lines
drivers/gpu/drm/xe/xe_pcode.c +0 -0
@@ -104,6 +104,34 @@ int xe_pcode_read(struct xe_gt *gt, u32
 mbox, u32 *val, u32 *val1)
        return err;
    }

a doc would be required...

drivers/gpu/drm/xe/xe_pcode.c int xe_pcode_read(struct xe_gt *gt, u32 · line 108

Quoted 2 lines
drivers/gpu/drm/xe/xe_pcode.c +1 -0
+int xe_pcode_read_p(struct xe_gt *gt, u32 mbcmd, u32 p1, u32
 p2, u32 *val)

a better name would be nice....

drivers/gpu/drm/xe/xe_pcode.c int xe_pcode_read(struct xe_gt *gt, u32 · line 117

Quoted 9 lines
drivers/gpu/drm/xe/xe_pcode.c +9 -0
+{
+    u32 mbox;
+    int err;
+
+    mbox = REG_FIELD_PREP(PCODE_MB_COMMAND, mbcmd)
+        | REG_FIELD_PREP(PCODE_MB_PARAM1, p1)
+        | REG_FIELD_PREP(PCODE_MB_PARAM2, p2);
+
+    err = xe_pcode_read(gt, mbox, val, NULL);

but why not simply modifying the existent one to accept 2 params?

int xe_pcode_read(struct xe_gt *gt, u32 mbox_param1, u32 mbox_param2, u32 *val, u32 *val1)

Quoted 8 lines

and the equivalent write...

oh, and while doing that, could you please add the missing documentation
to these 2 functions?

Thanks,
Rodrigo.

Sure that would work. Will add the docs as well.

Thanks,

Quoted 8 lines
Quoted 1 line

Suja

Hi Rodrigo,

Another question,

I can change the existing pcode_read function, but would it be better to
have a separate new write equivalent ?

I wonder if we should do s/xe_pcode_write_timeout(/xe_pcode_write(

Quoted 9 lines
Quoted 2 lines

where timeout is still an argument but it can be null. And then we merge with your options here and make a single write fn.

I'll see if this works out.

Thanks,

Suja

Hi Rodrigo,

Quoted 8 lines

As I am making the final fixes, looks like it would be better to have separate new read/write functions.

With changing the existing read/write functions, we are having to change the pcode_mailbox_rw function.

That is causing issues with other existing functions. Shall I keep the new functions defined separately ?

I'm really sorry for having missed this here.
I still believe that there are ways of combining them, even if we have to change the internal rw function. But if that gets too complicated or too ugly fine, let's have something alternative, but with a better naming

Quoted 47 lines

Thanks,

Suja

Quoted 42 lines
Quoted 42 lines
Quoted 42 lines
Quoted 42 lines
Quoted 42 lines
Quoted 42 lines
drivers/gpu/drm/xe/xe_pcode.c +18 -0
+
+    return err;
+}
+
+int xe_pcode_write_p(struct xe_gt *gt, u32 mbcmd, u32 p1, u32
 p2, u32 val)
+{
+    u32 mbox;
+    int err;
+
+    mbox = REG_FIELD_PREP(PCODE_MB_COMMAND, mbcmd)
+        | REG_FIELD_PREP(PCODE_MB_PARAM1, p1)
+        | REG_FIELD_PREP(PCODE_MB_PARAM2, p2);
+
+    err = xe_pcode_write(gt, mbox, val);
+
+    return err;
+}
+
    static int xe_pcode_try_request(struct xe_gt *gt, u32 mbox,

                   u32 request, u32 reply_mask, u32 reply, u32 *status, bool atomic, int timeout_us)

drivers/gpu/drm/xe/xe_pcode.h +0 -0
index 3b4aa8c1a3ba..8d4103afd7e0 100644
@@ -19,6 +19,9 @@ int xe_pcode_write_timeout(struct xe_gt *gt,
 u32 mbox, u32 val,
    #define xe_pcode_write(gt, mbox, val) \
        xe_pcode_write_timeout(gt, mbox, val, 1)

   +int xe_pcode_read_p(struct xe_gt *gt, u32 mbcmd, u32 p1, u32 p2, u32 *val);
+int xe_pcode_write_p(struct xe_gt *gt, u32 mbcmd, u32 p1, u32 p2, u32 val);
+
   int xe_pcode_request(struct xe_gt *gt, u32 mbox, u32 request, u32 reply_mask, u32 reply, int timeout_ms); --
2.25.1

#9 lore raw

PATCH 2/3 drm/xe: Add base performance sysfs attributes

In reply to Sujaritha Sundaresan

Add the following attribute to Xe sysfs
- base_freq_factor
- base_freq_factor.scale
- base_freq_rp0
- base_freq_rpn

---
 drivers/gpu/drm/xe/xe_guc_pc.c    | 116 ++++++++++++++++++++++++++++++
 drivers/gpu/drm/xe/xe_pcode_api.h |  19 +++++
 2 files changed, 135 insertions(+)
drivers/gpu/drm/xe/xe_guc_pc.c +116 -0
index c03bb58e7049..6a139d1dbf66 100644
@@ -20,6 +20,7 @@
 #include "xe_map.h"
 #include "xe_mmio.h"
 #include "xe_pcode.h"
+#include "xe_pcode_api.h"
 
 #define MCHBAR_MIRROR_BASE_SNB	0x140000
 
@@ -37,6 +38,9 @@
 #define GT_FREQUENCY_MULTIPLIER	50
 #define GEN9_FREQ_SCALER	3
 
+#define U8_8_VAL_MASK           0xffff
+#define U8_8_SCALE_TO_VALUE     "0.00390625"
+
 /**
  * DOC: GuC Power Conservation (PC)
  *
@@ -642,6 +646,112 @@ static const struct attribute *pc_attrs[] = {
 	NULL
 };
 
+static ssize_t freq_factor_scale_show(struct device *dev,
+				      struct device_attribute *attr,
+				      char *buff)
+{
+	return sysfs_emit(buff, "%s\n", U8_8_SCALE_TO_VALUE);
+}
+
+static ssize_t base_freq_factor_show(struct device *dev,
+				     struct device_attribute *attr,
+				     char *buff)
+{
+	struct kobject *kobj = &dev->kobj;
+	struct xe_gt *gt = kobj_to_gt(kobj);
+	u32 val;
+	int err;
+
+	err = xe_pcode_read_p(gt, PVC_PCODE_QOS_MULTIPLIER_GET,
+				PCODE_MBOX_DOMAIN_CHIPLET,
+				PCODE_MBOX_DOMAIN_BASE, &val);
+	if (err)
+		return err;
+
+	val &= U8_8_VAL_MASK;
+
+	return sysfs_emit(buff, "%u\n", val);
+}
+
+static ssize_t base_freq_factor_store(struct device *dev,
+				      struct device_attribute *attr,
+				      const char *buff, size_t count)
+{
+	struct kobject *kobj = &dev->kobj;
+	struct xe_gt *gt = kobj_to_gt(kobj);
+	u32 val;
+	int err;
+
+	err = kstrtou32(buff, 0, &val);
+	if (err)
+		return err;
+
+	if (val > U8_8_VAL_MASK)
+		return -EINVAL;
+
+	err = xe_pcode_write_p(gt, PVC_PCODE_QOS_MULTIPLIER_SET,
+				PCODE_MBOX_DOMAIN_CHIPLET,
+				PCODE_MBOX_DOMAIN_BASE, val);
+	if (err)
+		return err;
+
+	return count;
+}
+static DEVICE_ATTR_RW(base_freq_factor);
+static struct device_attribute dev_attr_base_freq_factor_scale =
+	__ATTR(base_freq_factor.scale, 0444, freq_factor_scale_show, NULL);
+
+
+static ssize_t base_freq_rp0_show(struct device *dev, struct device_attribute *attr,
+				  char *buff)
+{
+	struct kobject *kobj = &dev->kobj;
+	struct xe_gt *gt = kobj_to_gt(kobj);
+	u32 val;
+	int err;
+
+	err = xe_pcode_read_p(gt, XEHP_PCODE_FREQUENCY_CONFIG,
+				PCODE_MBOX_FC_SC_READ_FUSED_P0,
+				PCODE_MBOX_DOMAIN_BASE, &val);
+	if (err)
+		return err;
+
+	/* data_out - Fused P0 for domain ID in units of 50 MHz */
+	val *= GT_FREQUENCY_MULTIPLIER;
+
+	return sysfs_emit(buff, "%u\n", val);
+}
+static DEVICE_ATTR_RO(base_freq_rp0);
+
+static ssize_t base_freq_rpn_show(struct device *dev, struct device_attribute *attr,
+				  char *buff)
+{
+	struct kobject *kobj = &dev->kobj;
+	struct xe_gt *gt = kobj_to_gt(kobj);
+	u32 val;
+	int err;
+
+	err = xe_pcode_read_p(gt, XEHP_PCODE_FREQUENCY_CONFIG,
+				PCODE_MBOX_FC_SC_READ_FUSED_PN,
+				PCODE_MBOX_DOMAIN_BASE, &val);
+	if (err)
+		return err;
+
+	/* data_out - Fused Pn for domain ID in units of 50 MHz */
+	val *= GT_FREQUENCY_MULTIPLIER;
+
+	return sysfs_emit(buff, "%u\n", val);
+}
+static DEVICE_ATTR_RO(base_freq_rpn);
+
+static const struct attribute *pvc_perf_power_attrs[] = {
+	&dev_attr_base_freq_factor.attr,
+	&dev_attr_base_freq_factor_scale.attr,
+	&dev_attr_base_freq_rp0.attr,
+	&dev_attr_base_freq_rpn.attr,
+	NULL
+};
+
 static void mtl_init_fused_rp_values(struct xe_guc_pc *pc)
 {
 	struct xe_gt *gt = pc_to_gt(pc);
@@ -925,6 +1035,12 @@ int xe_guc_pc_init(struct xe_guc_pc *pc)
 	if (err)
 		return err;
 
+	if (xe->info.platform == XE_PVC) {
+		err = sysfs_create_files(gt->sysfs, pvc_perf_power_attrs);
+		if (err)
+			return err;
+	}
+
 	err = drmm_add_action_or_reset(&xe->drm, pc_fini, pc);
 	if (err)
 		return err;
drivers/gpu/drm/xe/xe_pcode_api.h +19 -0
index 837ff7c71280..da4114bfaa7a 100644
@@ -30,6 +30,25 @@
 #define   PCODE_READ_MIN_FREQ_TABLE	0x9
 #define   PCODE_FREQ_RING_RATIO_SHIFT	16
 
+#define   XEHP_PCODE_FREQUENCY_CONFIG			0x6e	/* xehp, pvc */
+/* XEHP_PCODE_FREQUENCY_CONFIG sub-commands (param1) */
+#define     PCODE_MBOX_FC_SC_READ_FUSED_P0		0x0
+#define     PCODE_MBOX_FC_SC_READ_FUSED_PN		0x1
+/* PCODE_MBOX_DOMAIN_* - mailbox domain IDs */
+/* XEHP_PCODE_FREQUENCY_CONFIG param2 */
+#define     PCODE_MBOX_DOMAIN_NONE			0x0
+#define     PCODE_MBOX_DOMAIN_GT			0x1
+#define     PCODE_MBOX_DOMAIN_HBM			0x2
+#define     PCODE_MBOX_DOMAIN_MEDIAFF			0x3
+#define     PCODE_MBOX_DOMAIN_MEDIA_SAMPLER		0x4
+#define     PCODE_MBOX_DOMAIN_SYSTOLIC_ARRAY		0x5
+#define     PCODE_MBOX_DOMAIN_CHIPLET			0x6
+#define     PCODE_MBOX_DOMAIN_BASE_CHIPLET_LINK		0x7
+#define     PCODE_MBOX_DOMAIN_BASE			0x8
+#define   PVC_PCODE_QOS_MULTIPLIER_SET			0x67
+/* See PCODE_MBOX_DOMAIN_* - mailbox domain IDs - param1 and 2 */
+#define   PVC_PCODE_QOS_MULTIPLIER_GET			0x66
+
 /* PCODE Init */
 #define   DGFX_PCODE_STATUS		0x7E
 #define     DGFX_GET_INIT_STATUS	0x0
Signature · 1 line
2.25.1
maintainer
#10 lore raw

Re: [Intel-xe] [PATCH 2/3] drm/xe: Add base performance sysfs attributes

drivers/gpu/drm/xe/xe_guc_pc.c

Quoted 16 lines · Sujaritha Sundaresan

Add the following attribute to Xe sysfs
- base_freq_factor
- base_freq_factor.scale
- base_freq_rp0
- base_freq_rpn

---
 drivers/gpu/drm/xe/xe_guc_pc.c    | 116 ++++++++++++++++++++++++++++++
 drivers/gpu/drm/xe/xe_pcode_api.h |  19 +++++
 2 files changed, 135 insertions(+)
drivers/gpu/drm/xe/xe_guc_pc.c +0 -0
index c03bb58e7049..6a139d1dbf66 100644

again, this has nothing to do with guc_pc.
We clearly need a new component to handle the frequency.

Quoted 177 lines
drivers/gpu/drm/xe/xe_guc_pc.c +116 -0
@@ -20,6 +20,7 @@
 #include "xe_map.h"
 #include "xe_mmio.h"
 #include "xe_pcode.h"
+#include "xe_pcode_api.h"
 
 #define MCHBAR_MIRROR_BASE_SNB	0x140000
 
@@ -37,6 +38,9 @@
 #define GT_FREQUENCY_MULTIPLIER	50
 #define GEN9_FREQ_SCALER	3
 
+#define U8_8_VAL_MASK           0xffff
+#define U8_8_SCALE_TO_VALUE     "0.00390625"
+
 /**
  * DOC: GuC Power Conservation (PC)
  *
@@ -642,6 +646,112 @@ static const struct attribute *pc_attrs[] = {
 	NULL
 };
 
+static ssize_t freq_factor_scale_show(struct device *dev,
+				      struct device_attribute *attr,
+				      char *buff)
+{
+	return sysfs_emit(buff, "%s\n", U8_8_SCALE_TO_VALUE);
+}
+
+static ssize_t base_freq_factor_show(struct device *dev,
+				     struct device_attribute *attr,
+				     char *buff)
+{
+	struct kobject *kobj = &dev->kobj;
+	struct xe_gt *gt = kobj_to_gt(kobj);
+	u32 val;
+	int err;
+
+	err = xe_pcode_read_p(gt, PVC_PCODE_QOS_MULTIPLIER_GET,
+				PCODE_MBOX_DOMAIN_CHIPLET,
+				PCODE_MBOX_DOMAIN_BASE, &val);
+	if (err)
+		return err;
+
+	val &= U8_8_VAL_MASK;
+
+	return sysfs_emit(buff, "%u\n", val);
+}
+
+static ssize_t base_freq_factor_store(struct device *dev,
+				      struct device_attribute *attr,
+				      const char *buff, size_t count)
+{
+	struct kobject *kobj = &dev->kobj;
+	struct xe_gt *gt = kobj_to_gt(kobj);
+	u32 val;
+	int err;
+
+	err = kstrtou32(buff, 0, &val);
+	if (err)
+		return err;
+
+	if (val > U8_8_VAL_MASK)
+		return -EINVAL;
+
+	err = xe_pcode_write_p(gt, PVC_PCODE_QOS_MULTIPLIER_SET,
+				PCODE_MBOX_DOMAIN_CHIPLET,
+				PCODE_MBOX_DOMAIN_BASE, val);
+	if (err)
+		return err;
+
+	return count;
+}
+static DEVICE_ATTR_RW(base_freq_factor);
+static struct device_attribute dev_attr_base_freq_factor_scale =
+	__ATTR(base_freq_factor.scale, 0444, freq_factor_scale_show, NULL);
+
+
+static ssize_t base_freq_rp0_show(struct device *dev, struct device_attribute *attr,
+				  char *buff)
+{
+	struct kobject *kobj = &dev->kobj;
+	struct xe_gt *gt = kobj_to_gt(kobj);
+	u32 val;
+	int err;
+
+	err = xe_pcode_read_p(gt, XEHP_PCODE_FREQUENCY_CONFIG,
+				PCODE_MBOX_FC_SC_READ_FUSED_P0,
+				PCODE_MBOX_DOMAIN_BASE, &val);
+	if (err)
+		return err;
+
+	/* data_out - Fused P0 for domain ID in units of 50 MHz */
+	val *= GT_FREQUENCY_MULTIPLIER;
+
+	return sysfs_emit(buff, "%u\n", val);
+}
+static DEVICE_ATTR_RO(base_freq_rp0);
+
+static ssize_t base_freq_rpn_show(struct device *dev, struct device_attribute *attr,
+				  char *buff)
+{
+	struct kobject *kobj = &dev->kobj;
+	struct xe_gt *gt = kobj_to_gt(kobj);
+	u32 val;
+	int err;
+
+	err = xe_pcode_read_p(gt, XEHP_PCODE_FREQUENCY_CONFIG,
+				PCODE_MBOX_FC_SC_READ_FUSED_PN,
+				PCODE_MBOX_DOMAIN_BASE, &val);
+	if (err)
+		return err;
+
+	/* data_out - Fused Pn for domain ID in units of 50 MHz */
+	val *= GT_FREQUENCY_MULTIPLIER;
+
+	return sysfs_emit(buff, "%u\n", val);
+}
+static DEVICE_ATTR_RO(base_freq_rpn);
+
+static const struct attribute *pvc_perf_power_attrs[] = {
+	&dev_attr_base_freq_factor.attr,
+	&dev_attr_base_freq_factor_scale.attr,
+	&dev_attr_base_freq_rp0.attr,
+	&dev_attr_base_freq_rpn.attr,
+	NULL
+};
+
 static void mtl_init_fused_rp_values(struct xe_guc_pc *pc)
 {
 	struct xe_gt *gt = pc_to_gt(pc);
@@ -925,6 +1035,12 @@ int xe_guc_pc_init(struct xe_guc_pc *pc)
 	if (err)
 		return err;
 
+	if (xe->info.platform == XE_PVC) {
+		err = sysfs_create_files(gt->sysfs, pvc_perf_power_attrs);
+		if (err)
+			return err;
+	}
+
 	err = drmm_add_action_or_reset(&xe->drm, pc_fini, pc);
 	if (err)
 		return err;
drivers/gpu/drm/xe/xe_pcode_api.h +19 -0
index 837ff7c71280..da4114bfaa7a 100644
@@ -30,6 +30,25 @@
 #define   PCODE_READ_MIN_FREQ_TABLE	0x9
 #define   PCODE_FREQ_RING_RATIO_SHIFT	16
 
+#define   XEHP_PCODE_FREQUENCY_CONFIG			0x6e	/* xehp, pvc */
+/* XEHP_PCODE_FREQUENCY_CONFIG sub-commands (param1) */
+#define     PCODE_MBOX_FC_SC_READ_FUSED_P0		0x0
+#define     PCODE_MBOX_FC_SC_READ_FUSED_PN		0x1
+/* PCODE_MBOX_DOMAIN_* - mailbox domain IDs */
+/* XEHP_PCODE_FREQUENCY_CONFIG param2 */
+#define     PCODE_MBOX_DOMAIN_NONE			0x0
+#define     PCODE_MBOX_DOMAIN_GT			0x1
+#define     PCODE_MBOX_DOMAIN_HBM			0x2
+#define     PCODE_MBOX_DOMAIN_MEDIAFF			0x3
+#define     PCODE_MBOX_DOMAIN_MEDIA_SAMPLER		0x4
+#define     PCODE_MBOX_DOMAIN_SYSTOLIC_ARRAY		0x5
+#define     PCODE_MBOX_DOMAIN_CHIPLET			0x6
+#define     PCODE_MBOX_DOMAIN_BASE_CHIPLET_LINK		0x7
+#define     PCODE_MBOX_DOMAIN_BASE			0x8
+#define   PVC_PCODE_QOS_MULTIPLIER_SET			0x67
+/* See PCODE_MBOX_DOMAIN_* - mailbox domain IDs - param1 and 2 */
+#define   PVC_PCODE_QOS_MULTIPLIER_GET			0x66
+
 /* PCODE Init */
 #define   DGFX_PCODE_STATUS		0x7E
 #define     DGFX_GET_INIT_STATUS	0x0
Signature · 1 line
2.25.1
#11 lore raw

Re: [Intel-xe] [PATCH 2/3] drm/xe: Add base performance sysfs attributes

Quoted 13 lines · Rodrigo Vivi
Quoted 12 lines · Sujaritha Sundaresan

Add the following attribute to Xe sysfs
- base_freq_factor
- base_freq_factor.scale
- base_freq_rp0
- base_freq_rpn

---
  drivers/gpu/drm/xe/xe_guc_pc.c    | 116 ++++++++++++++++++++++++++++++
  drivers/gpu/drm/xe/xe_pcode_api.h |  19 +++++
  2 files changed, 135 insertions(+)
Quoted 6 lines

drivers/gpu/drm/xe/xe_guc_pc.c

Quoted 4 lines
drivers/gpu/drm/xe/xe_guc_pc.c +0 -0
index c03bb58e7049..6a139d1dbf66 100644

again, this has nothing to do with guc_pc.
We clearly need a new component to handle the frequency.

Right. will look to define a new xe_freq component

Thanks,

Suja

Quoted 178 lines
Quoted 178 lines
drivers/gpu/drm/xe/xe_guc_pc.c +116 -0
@@ -20,6 +20,7 @@
  #include "xe_map.h"
  #include "xe_mmio.h"
  #include "xe_pcode.h"
+#include "xe_pcode_api.h"
 
  #define MCHBAR_MIRROR_BASE_SNB	0x140000
 
@@ -37,6 +38,9 @@
  #define GT_FREQUENCY_MULTIPLIER	50
  #define GEN9_FREQ_SCALER	3
 
+#define U8_8_VAL_MASK           0xffff
+#define U8_8_SCALE_TO_VALUE     "0.00390625"
+
  /**
   * DOC: GuC Power Conservation (PC)
   *
@@ -642,6 +646,112 @@ static const struct attribute *pc_attrs[] = {
  	NULL
  };
 
+static ssize_t freq_factor_scale_show(struct device *dev,
+				      struct device_attribute *attr,
+				      char *buff)
+{
+	return sysfs_emit(buff, "%s\n", U8_8_SCALE_TO_VALUE);
+}
+
+static ssize_t base_freq_factor_show(struct device *dev,
+				     struct device_attribute *attr,
+				     char *buff)
+{
+	struct kobject *kobj = &dev->kobj;
+	struct xe_gt *gt = kobj_to_gt(kobj);
+	u32 val;
+	int err;
+
+	err = xe_pcode_read_p(gt, PVC_PCODE_QOS_MULTIPLIER_GET,
+				PCODE_MBOX_DOMAIN_CHIPLET,
+				PCODE_MBOX_DOMAIN_BASE, &val);
+	if (err)
+		return err;
+
+	val &= U8_8_VAL_MASK;
+
+	return sysfs_emit(buff, "%u\n", val);
+}
+
+static ssize_t base_freq_factor_store(struct device *dev,
+				      struct device_attribute *attr,
+				      const char *buff, size_t count)
+{
+	struct kobject *kobj = &dev->kobj;
+	struct xe_gt *gt = kobj_to_gt(kobj);
+	u32 val;
+	int err;
+
+	err = kstrtou32(buff, 0, &val);
+	if (err)
+		return err;
+
+	if (val > U8_8_VAL_MASK)
+		return -EINVAL;
+
+	err = xe_pcode_write_p(gt, PVC_PCODE_QOS_MULTIPLIER_SET,
+				PCODE_MBOX_DOMAIN_CHIPLET,
+				PCODE_MBOX_DOMAIN_BASE, val);
+	if (err)
+		return err;
+
+	return count;
+}
+static DEVICE_ATTR_RW(base_freq_factor);
+static struct device_attribute dev_attr_base_freq_factor_scale =
+	__ATTR(base_freq_factor.scale, 0444, freq_factor_scale_show, NULL);
+
+
+static ssize_t base_freq_rp0_show(struct device *dev, struct device_attribute *attr,
+				  char *buff)
+{
+	struct kobject *kobj = &dev->kobj;
+	struct xe_gt *gt = kobj_to_gt(kobj);
+	u32 val;
+	int err;
+
+	err = xe_pcode_read_p(gt, XEHP_PCODE_FREQUENCY_CONFIG,
+				PCODE_MBOX_FC_SC_READ_FUSED_P0,
+				PCODE_MBOX_DOMAIN_BASE, &val);
+	if (err)
+		return err;
+
+	/* data_out - Fused P0 for domain ID in units of 50 MHz */
+	val *= GT_FREQUENCY_MULTIPLIER;
+
+	return sysfs_emit(buff, "%u\n", val);
+}
+static DEVICE_ATTR_RO(base_freq_rp0);
+
+static ssize_t base_freq_rpn_show(struct device *dev, struct device_attribute *attr,
+				  char *buff)
+{
+	struct kobject *kobj = &dev->kobj;
+	struct xe_gt *gt = kobj_to_gt(kobj);
+	u32 val;
+	int err;
+
+	err = xe_pcode_read_p(gt, XEHP_PCODE_FREQUENCY_CONFIG,
+				PCODE_MBOX_FC_SC_READ_FUSED_PN,
+				PCODE_MBOX_DOMAIN_BASE, &val);
+	if (err)
+		return err;
+
+	/* data_out - Fused Pn for domain ID in units of 50 MHz */
+	val *= GT_FREQUENCY_MULTIPLIER;
+
+	return sysfs_emit(buff, "%u\n", val);
+}
+static DEVICE_ATTR_RO(base_freq_rpn);
+
+static const struct attribute *pvc_perf_power_attrs[] = {
+	&dev_attr_base_freq_factor.attr,
+	&dev_attr_base_freq_factor_scale.attr,
+	&dev_attr_base_freq_rp0.attr,
+	&dev_attr_base_freq_rpn.attr,
+	NULL
+};
+
  static void mtl_init_fused_rp_values(struct xe_guc_pc *pc)
  {
  	struct xe_gt *gt = pc_to_gt(pc);
@@ -925,6 +1035,12 @@ int xe_guc_pc_init(struct xe_guc_pc *pc)
  	if (err)
  		return err;
 
+	if (xe->info.platform == XE_PVC) {
+		err = sysfs_create_files(gt->sysfs, pvc_perf_power_attrs);
+		if (err)
+			return err;
+	}
+
  	err = drmm_add_action_or_reset(&xe->drm, pc_fini, pc);
  	if (err)
  		return err;
drivers/gpu/drm/xe/xe_pcode_api.h +19 -0
index 837ff7c71280..da4114bfaa7a 100644
@@ -30,6 +30,25 @@
  #define   PCODE_READ_MIN_FREQ_TABLE	0x9
  #define   PCODE_FREQ_RING_RATIO_SHIFT	16
 
+#define   XEHP_PCODE_FREQUENCY_CONFIG			0x6e	/* xehp, pvc */
+/* XEHP_PCODE_FREQUENCY_CONFIG sub-commands (param1) */
+#define     PCODE_MBOX_FC_SC_READ_FUSED_P0		0x0
+#define     PCODE_MBOX_FC_SC_READ_FUSED_PN		0x1
+/* PCODE_MBOX_DOMAIN_* - mailbox domain IDs */
+/* XEHP_PCODE_FREQUENCY_CONFIG param2 */
+#define     PCODE_MBOX_DOMAIN_NONE			0x0
+#define     PCODE_MBOX_DOMAIN_GT			0x1
+#define     PCODE_MBOX_DOMAIN_HBM			0x2
+#define     PCODE_MBOX_DOMAIN_MEDIAFF			0x3
+#define     PCODE_MBOX_DOMAIN_MEDIA_SAMPLER		0x4
+#define     PCODE_MBOX_DOMAIN_SYSTOLIC_ARRAY		0x5
+#define     PCODE_MBOX_DOMAIN_CHIPLET			0x6
+#define     PCODE_MBOX_DOMAIN_BASE_CHIPLET_LINK		0x7
+#define     PCODE_MBOX_DOMAIN_BASE			0x8
+#define   PVC_PCODE_QOS_MULTIPLIER_SET			0x67
+/* See PCODE_MBOX_DOMAIN_* - mailbox domain IDs - param1 and 2 */
+#define   PVC_PCODE_QOS_MULTIPLIER_GET			0x66
+
  /* PCODE Init */
  #define   DGFX_PCODE_STATUS		0x7E
  #define     DGFX_GET_INIT_STATUS	0x0
Signature · 1 line
2.25.1
#12 lore raw

Re: [Intel-xe] [PATCH 2/3] drm/xe: Add base performance sysfs attributes

Quoted 23 lines · Sujaritha
Quoted 14 lines · Rodrigo Vivi
Quoted 13 lines · Sujaritha Sundaresan

Add the following attribute to Xe sysfs
- base_freq_factor
- base_freq_factor.scale
- base_freq_rp0
- base_freq_rpn

---
  drivers/gpu/drm/xe/xe_guc_pc.c    | 116
++++++++++++++++++++++++++++++
  drivers/gpu/drm/xe/xe_pcode_api.h |  19 +++++

  2 files changed, 135 insertions(+)
Quoted 6 lines

drivers/gpu/drm/xe/xe_guc_pc.c

Quoted 4 lines
drivers/gpu/drm/xe/xe_guc_pc.c +0 -0
index c03bb58e7049..6a139d1dbf66 100644

again, this has nothing to do with guc_pc.
We clearly need a new component to handle the frequency.

Quoted 5 lines

Right. will look to define a new xe_freq component

Thanks,

Suja

Hi Rodrigo,

I've moved a lot of the frequency attributes I'm adding to a new file

with a new xe_freq component.

Does that work for this ?

Thanks,

Suja

Quoted 177 lines
Quoted 177 lines
Quoted 177 lines
drivers/gpu/drm/xe/xe_guc_pc.c +1 -0
@@ -20,6 +20,7 @@
   #include "xe_map.h"
   #include "xe_mmio.h"
   #include "xe_pcode.h"
+#include "xe_pcode_api.h"
     #define MCHBAR_MIRROR_BASE_SNB    0x140000

  @@ -37,6 +38,9 @@
  #define GT_FREQUENCY_MULTIPLIER    50
  #define GEN9_FREQ_SCALER    3
  +#define U8_8_VAL_MASK           0xffff

drivers/gpu/drm/xe/xe_guc_pc.c +2 -0
+#define U8_8_SCALE_TO_VALUE     "0.00390625"
+

  /**
   * DOC: GuC Power Conservation (PC)
   *

drivers/gpu/drm/xe/xe_guc_pc.c +0 -0
@@ -642,6 +646,112 @@ static const struct attribute *pc_attrs[] = {

      NULL
  };
  +static ssize_t freq_factor_scale_show(struct device *dev, +                      struct device_attribute *attr, +                      char *buff)

drivers/gpu/drm/xe/xe_guc_pc.c +51 -0
+{
+    return sysfs_emit(buff, "%s\n", U8_8_SCALE_TO_VALUE);
+}
+
+static ssize_t base_freq_factor_show(struct device *dev,
+                     struct device_attribute *attr,
+                     char *buff)
+{
+    struct kobject *kobj = &dev->kobj;
+    struct xe_gt *gt = kobj_to_gt(kobj);
+    u32 val;
+    int err;
+
+    err = xe_pcode_read_p(gt, PVC_PCODE_QOS_MULTIPLIER_GET,
+                PCODE_MBOX_DOMAIN_CHIPLET,
+                PCODE_MBOX_DOMAIN_BASE, &val);
+    if (err)
+        return err;
+
+    val &= U8_8_VAL_MASK;
+
+    return sysfs_emit(buff, "%u\n", val);
+}
+
+static ssize_t base_freq_factor_store(struct device *dev,
+                      struct device_attribute *attr,
+                      const char *buff, size_t count)
+{
+    struct kobject *kobj = &dev->kobj;
+    struct xe_gt *gt = kobj_to_gt(kobj);
+    u32 val;
+    int err;
+
+    err = kstrtou32(buff, 0, &val);
+    if (err)
+        return err;
+
+    if (val > U8_8_VAL_MASK)
+        return -EINVAL;
+
+    err = xe_pcode_write_p(gt, PVC_PCODE_QOS_MULTIPLIER_SET,
+                PCODE_MBOX_DOMAIN_CHIPLET,
+                PCODE_MBOX_DOMAIN_BASE, val);
+    if (err)
+        return err;
+
+    return count;
+}
+static DEVICE_ATTR_RW(base_freq_factor);
+static struct device_attribute dev_attr_base_freq_factor_scale =
+    __ATTR(base_freq_factor.scale, 0444, freq_factor_scale_show, 

NULL);

drivers/gpu/drm/xe/xe_guc_pc.c +3 -0
+
+
+static ssize_t base_freq_rp0_show(struct device *dev, struct 

device_attribute *attr,
+                  char *buff)

drivers/gpu/drm/xe/xe_guc_pc.c +20 -0
+{
+    struct kobject *kobj = &dev->kobj;
+    struct xe_gt *gt = kobj_to_gt(kobj);
+    u32 val;
+    int err;
+
+    err = xe_pcode_read_p(gt, XEHP_PCODE_FREQUENCY_CONFIG,
+                PCODE_MBOX_FC_SC_READ_FUSED_P0,
+                PCODE_MBOX_DOMAIN_BASE, &val);
+    if (err)
+        return err;
+
+    /* data_out - Fused P0 for domain ID in units of 50 MHz */
+    val *= GT_FREQUENCY_MULTIPLIER;
+
+    return sysfs_emit(buff, "%u\n", val);
+}
+static DEVICE_ATTR_RO(base_freq_rp0);
+
+static ssize_t base_freq_rpn_show(struct device *dev, struct 

device_attribute *attr,
+                  char *buff)

drivers/gpu/drm/xe/xe_guc_pc.c +27 -0
+{
+    struct kobject *kobj = &dev->kobj;
+    struct xe_gt *gt = kobj_to_gt(kobj);
+    u32 val;
+    int err;
+
+    err = xe_pcode_read_p(gt, XEHP_PCODE_FREQUENCY_CONFIG,
+                PCODE_MBOX_FC_SC_READ_FUSED_PN,
+                PCODE_MBOX_DOMAIN_BASE, &val);
+    if (err)
+        return err;
+
+    /* data_out - Fused Pn for domain ID in units of 50 MHz */
+    val *= GT_FREQUENCY_MULTIPLIER;
+
+    return sysfs_emit(buff, "%u\n", val);
+}
+static DEVICE_ATTR_RO(base_freq_rpn);
+
+static const struct attribute *pvc_perf_power_attrs[] = {
+    &dev_attr_base_freq_factor.attr,
+    &dev_attr_base_freq_factor_scale.attr,
+    &dev_attr_base_freq_rp0.attr,
+    &dev_attr_base_freq_rpn.attr,
+    NULL
+};
+

  static void mtl_init_fused_rp_values(struct xe_guc_pc *pc) {
      struct xe_gt *gt = pc_to_gt(pc);

drivers/gpu/drm/xe/xe_guc_pc.c +5 -0
@@ -925,6 +1035,12 @@ int xe_guc_pc_init(struct xe_guc_pc *pc)
       if (err)
           return err;
   +    if (xe->info.platform == XE_PVC) {
+        err = sysfs_create_files(gt->sysfs, pvc_perf_power_attrs);
+        if (err)
+            return err;
+    }
+
       err = drmm_add_action_or_reset(&xe->drm, pc_fini, pc);
       if (err)
           return err;
drivers/gpu/drm/xe/xe_pcode_api.h +0 -0
index 837ff7c71280..da4114bfaa7a 100644
@@ -30,6 +30,25 @@
   #define   PCODE_READ_MIN_FREQ_TABLE    0x9
   #define   PCODE_FREQ_RING_RATIO_SHIFT    16

  +#define   XEHP_PCODE_FREQUENCY_CONFIG            0x6e    /* xehp, pvc */

drivers/gpu/drm/xe/xe_pcode_api.h +18 -0
+/* XEHP_PCODE_FREQUENCY_CONFIG sub-commands (param1) */
+#define     PCODE_MBOX_FC_SC_READ_FUSED_P0        0x0
+#define     PCODE_MBOX_FC_SC_READ_FUSED_PN        0x1
+/* PCODE_MBOX_DOMAIN_* - mailbox domain IDs */
+/* XEHP_PCODE_FREQUENCY_CONFIG param2 */
+#define     PCODE_MBOX_DOMAIN_NONE            0x0
+#define     PCODE_MBOX_DOMAIN_GT            0x1
+#define     PCODE_MBOX_DOMAIN_HBM            0x2
+#define     PCODE_MBOX_DOMAIN_MEDIAFF            0x3
+#define     PCODE_MBOX_DOMAIN_MEDIA_SAMPLER        0x4
+#define     PCODE_MBOX_DOMAIN_SYSTOLIC_ARRAY        0x5
+#define     PCODE_MBOX_DOMAIN_CHIPLET            0x6
+#define     PCODE_MBOX_DOMAIN_BASE_CHIPLET_LINK        0x7
+#define     PCODE_MBOX_DOMAIN_BASE            0x8
+#define   PVC_PCODE_QOS_MULTIPLIER_SET            0x67
+/* See PCODE_MBOX_DOMAIN_* - mailbox domain IDs - param1 and 2 */
+#define   PVC_PCODE_QOS_MULTIPLIER_GET            0x66
+

  /* PCODE Init */
  #define   DGFX_PCODE_STATUS        0x7E
  #define     DGFX_GET_INIT_STATUS    0x0

Signature · 1 line
2.25.1
maintainer
#13 lore raw

Re: [Intel-xe] [PATCH 2/3] drm/xe: Add base performance sysfs attributes

Quoted 32 lines · Sujaritha
Quoted 24 lines · Sujaritha
Quoted 14 lines · Rodrigo Vivi
Quoted 13 lines · Sujaritha Sundaresan

Add the following attribute to Xe sysfs
- base_freq_factor
- base_freq_factor.scale
- base_freq_rp0
- base_freq_rpn

---
  drivers/gpu/drm/xe/xe_guc_pc.c    | 116
++++++++++++++++++++++++++++++
  drivers/gpu/drm/xe/xe_pcode_api.h |  19 +++++

  2 files changed, 135 insertions(+)
Quoted 7 lines

drivers/gpu/drm/xe/xe_guc_pc.c

Quoted 5 lines
drivers/gpu/drm/xe/xe_guc_pc.c +0 -0
index c03bb58e7049..6a139d1dbf66 100644

again, this has nothing to do with guc_pc.
We clearly need a new component to handle the frequency.

Quoted 5 lines

Right. will look to define a new xe_freq component

Thanks,

Suja

Quoted 7 lines

Hi Rodrigo,

I've moved a lot of the frequency attributes I'm adding to a new file

with a new xe_freq component.

Does that work for this ?

I think so, but I might be missing something.
Is this already in the mailing list or some branch that I could peak?

Quoted 184 lines

Thanks,

Suja

Quoted 179 lines
Quoted 179 lines
Quoted 179 lines
drivers/gpu/drm/xe/xe_guc_pc.c +1 -0
@@ -20,6 +20,7 @@
   #include "xe_map.h"
   #include "xe_mmio.h"
   #include "xe_pcode.h"
+#include "xe_pcode_api.h"
     #define MCHBAR_MIRROR_BASE_SNB    0x140000

  @@ -37,6 +38,9 @@
  #define GT_FREQUENCY_MULTIPLIER    50
  #define GEN9_FREQ_SCALER    3
  +#define U8_8_VAL_MASK           0xffff

drivers/gpu/drm/xe/xe_guc_pc.c +2 -0
+#define U8_8_SCALE_TO_VALUE     "0.00390625"
+

  /**
   * DOC: GuC Power Conservation (PC)
   *

drivers/gpu/drm/xe/xe_guc_pc.c +0 -0
@@ -642,6 +646,112 @@ static const struct attribute *pc_attrs[] = {

      NULL
  };
  +static ssize_t freq_factor_scale_show(struct device *dev, +                      struct device_attribute *attr, +                      char *buff)

drivers/gpu/drm/xe/xe_guc_pc.c +51 -0
+{
+    return sysfs_emit(buff, "%s\n", U8_8_SCALE_TO_VALUE);
+}
+
+static ssize_t base_freq_factor_show(struct device *dev,
+                     struct device_attribute *attr,
+                     char *buff)
+{
+    struct kobject *kobj = &dev->kobj;
+    struct xe_gt *gt = kobj_to_gt(kobj);
+    u32 val;
+    int err;
+
+    err = xe_pcode_read_p(gt, PVC_PCODE_QOS_MULTIPLIER_GET,
+                PCODE_MBOX_DOMAIN_CHIPLET,
+                PCODE_MBOX_DOMAIN_BASE, &val);
+    if (err)
+        return err;
+
+    val &= U8_8_VAL_MASK;
+
+    return sysfs_emit(buff, "%u\n", val);
+}
+
+static ssize_t base_freq_factor_store(struct device *dev,
+                      struct device_attribute *attr,
+                      const char *buff, size_t count)
+{
+    struct kobject *kobj = &dev->kobj;
+    struct xe_gt *gt = kobj_to_gt(kobj);
+    u32 val;
+    int err;
+
+    err = kstrtou32(buff, 0, &val);
+    if (err)
+        return err;
+
+    if (val > U8_8_VAL_MASK)
+        return -EINVAL;
+
+    err = xe_pcode_write_p(gt, PVC_PCODE_QOS_MULTIPLIER_SET,
+                PCODE_MBOX_DOMAIN_CHIPLET,
+                PCODE_MBOX_DOMAIN_BASE, val);
+    if (err)
+        return err;
+
+    return count;
+}
+static DEVICE_ATTR_RW(base_freq_factor);
+static struct device_attribute dev_attr_base_freq_factor_scale =
+    __ATTR(base_freq_factor.scale, 0444,

freq_factor_scale_show, NULL);

drivers/gpu/drm/xe/xe_guc_pc.c +3 -0
+
+
+static ssize_t base_freq_rp0_show(struct device *dev, struct

device_attribute *attr,
+                  char *buff)

drivers/gpu/drm/xe/xe_guc_pc.c +20 -0
+{
+    struct kobject *kobj = &dev->kobj;
+    struct xe_gt *gt = kobj_to_gt(kobj);
+    u32 val;
+    int err;
+
+    err = xe_pcode_read_p(gt, XEHP_PCODE_FREQUENCY_CONFIG,
+                PCODE_MBOX_FC_SC_READ_FUSED_P0,
+                PCODE_MBOX_DOMAIN_BASE, &val);
+    if (err)
+        return err;
+
+    /* data_out - Fused P0 for domain ID in units of 50 MHz */
+    val *= GT_FREQUENCY_MULTIPLIER;
+
+    return sysfs_emit(buff, "%u\n", val);
+}
+static DEVICE_ATTR_RO(base_freq_rp0);
+
+static ssize_t base_freq_rpn_show(struct device *dev, struct

device_attribute *attr,
+                  char *buff)

drivers/gpu/drm/xe/xe_guc_pc.c +27 -0
+{
+    struct kobject *kobj = &dev->kobj;
+    struct xe_gt *gt = kobj_to_gt(kobj);
+    u32 val;
+    int err;
+
+    err = xe_pcode_read_p(gt, XEHP_PCODE_FREQUENCY_CONFIG,
+                PCODE_MBOX_FC_SC_READ_FUSED_PN,
+                PCODE_MBOX_DOMAIN_BASE, &val);
+    if (err)
+        return err;
+
+    /* data_out - Fused Pn for domain ID in units of 50 MHz */
+    val *= GT_FREQUENCY_MULTIPLIER;
+
+    return sysfs_emit(buff, "%u\n", val);
+}
+static DEVICE_ATTR_RO(base_freq_rpn);
+
+static const struct attribute *pvc_perf_power_attrs[] = {
+    &dev_attr_base_freq_factor.attr,
+    &dev_attr_base_freq_factor_scale.attr,
+    &dev_attr_base_freq_rp0.attr,
+    &dev_attr_base_freq_rpn.attr,
+    NULL
+};
+

  static void mtl_init_fused_rp_values(struct xe_guc_pc *pc) {
      struct xe_gt *gt = pc_to_gt(pc);

drivers/gpu/drm/xe/xe_guc_pc.c +5 -0
@@ -925,6 +1035,12 @@ int xe_guc_pc_init(struct xe_guc_pc *pc)
       if (err)
           return err;
   +    if (xe->info.platform == XE_PVC) {
+        err = sysfs_create_files(gt->sysfs, pvc_perf_power_attrs);
+        if (err)
+            return err;
+    }
+
       err = drmm_add_action_or_reset(&xe->drm, pc_fini, pc);
       if (err)
           return err;
drivers/gpu/drm/xe/xe_pcode_api.h +0 -0
index 837ff7c71280..da4114bfaa7a 100644
@@ -30,6 +30,25 @@
   #define   PCODE_READ_MIN_FREQ_TABLE    0x9
   #define   PCODE_FREQ_RING_RATIO_SHIFT    16

  +#define   XEHP_PCODE_FREQUENCY_CONFIG            0x6e    /* xehp, pvc */

drivers/gpu/drm/xe/xe_pcode_api.h +18 -0
+/* XEHP_PCODE_FREQUENCY_CONFIG sub-commands (param1) */
+#define     PCODE_MBOX_FC_SC_READ_FUSED_P0        0x0
+#define     PCODE_MBOX_FC_SC_READ_FUSED_PN        0x1
+/* PCODE_MBOX_DOMAIN_* - mailbox domain IDs */
+/* XEHP_PCODE_FREQUENCY_CONFIG param2 */
+#define     PCODE_MBOX_DOMAIN_NONE            0x0
+#define     PCODE_MBOX_DOMAIN_GT            0x1
+#define     PCODE_MBOX_DOMAIN_HBM            0x2
+#define     PCODE_MBOX_DOMAIN_MEDIAFF            0x3
+#define     PCODE_MBOX_DOMAIN_MEDIA_SAMPLER        0x4
+#define     PCODE_MBOX_DOMAIN_SYSTOLIC_ARRAY        0x5
+#define     PCODE_MBOX_DOMAIN_CHIPLET            0x6
+#define     PCODE_MBOX_DOMAIN_BASE_CHIPLET_LINK        0x7
+#define     PCODE_MBOX_DOMAIN_BASE            0x8
+#define   PVC_PCODE_QOS_MULTIPLIER_SET            0x67
+/* See PCODE_MBOX_DOMAIN_* - mailbox domain IDs - param1 and 2 */
+#define   PVC_PCODE_QOS_MULTIPLIER_GET            0x66
+

  /* PCODE Init */
  #define   DGFX_PCODE_STATUS        0x7E
  #define     DGFX_GET_INIT_STATUS    0x0

Signature · 1 line
2.25.1
#14 lore raw

Re: [Intel-xe] [PATCH 2/3] drm/xe: Add base performance sysfs attributes

Quoted 31 lines · Rodrigo Vivi
Quoted 30 lines · Sujaritha
Quoted 22 lines · Sujaritha
Quoted 14 lines · Rodrigo Vivi
Quoted 13 lines · Sujaritha Sundaresan

Add the following attribute to Xe sysfs
- base_freq_factor
- base_freq_factor.scale
- base_freq_rp0
- base_freq_rpn

---
   drivers/gpu/drm/xe/xe_guc_pc.c    | 116
++++++++++++++++++++++++++++++
   drivers/gpu/drm/xe/xe_pcode_api.h |  19 +++++
   2 files changed, 135 insertions(+)
Quoted 7 lines

drivers/gpu/drm/xe/xe_guc_pc.c

Quoted 5 lines
drivers/gpu/drm/xe/xe_guc_pc.c +0 -0
index c03bb58e7049..6a139d1dbf66 100644

again, this has nothing to do with guc_pc.
We clearly need a new component to handle the frequency.

Quoted 5 lines

Right. will look to define a new xe_freq component

Thanks,

Suja

Hi Rodrigo,

Quoted 11 lines
Quoted 5 lines

I've moved a lot of the frequency attributes I'm adding to a new file

with a new xe_freq component.

Does that work for this ?

I think so, but I might be missing something.
Is this already in the mailing list or some branch that I could peak?

Quoted 3 lines

Thanks,

Suja

Sure I can share the branch. There is a throttle reasons patch on the ML, which is similar in concept.

That's the direction I went with for the sysfs in this patch as well.

Thanks,

Suja

Quoted 178 lines
Quoted 178 lines
Quoted 178 lines
Quoted 178 lines
Quoted 178 lines
drivers/gpu/drm/xe/xe_guc_pc.c +1 -0
@@ -20,6 +20,7 @@
   #include "xe_map.h"
   #include "xe_mmio.h"
   #include "xe_pcode.h"
+#include "xe_pcode_api.h"
     #define MCHBAR_MIRROR_BASE_SNB    0x140000
   @@ -37,6 +38,9 @@
   #define GT_FREQUENCY_MULTIPLIER    50

  #define GEN9_FREQ_SCALER    3
  +#define U8_8_VAL_MASK           0xffff

drivers/gpu/drm/xe/xe_guc_pc.c +112 -0
+#define U8_8_SCALE_TO_VALUE     "0.00390625"
+
   /**
    * DOC: GuC Power Conservation (PC)
    *
@@ -642,6 +646,112 @@ static const struct attribute *pc_attrs[] = {
       NULL
   };
   +static ssize_t freq_factor_scale_show(struct device *dev,
+                      struct device_attribute *attr,
+                      char *buff)
+{
+    return sysfs_emit(buff, "%s\n", U8_8_SCALE_TO_VALUE);
+}
+
+static ssize_t base_freq_factor_show(struct device *dev,
+                     struct device_attribute *attr,
+                     char *buff)
+{
+    struct kobject *kobj = &dev->kobj;
+    struct xe_gt *gt = kobj_to_gt(kobj);
+    u32 val;
+    int err;
+
+    err = xe_pcode_read_p(gt, PVC_PCODE_QOS_MULTIPLIER_GET,
+                PCODE_MBOX_DOMAIN_CHIPLET,
+                PCODE_MBOX_DOMAIN_BASE, &val);
+    if (err)
+        return err;
+
+    val &= U8_8_VAL_MASK;
+
+    return sysfs_emit(buff, "%u\n", val);
+}
+
+static ssize_t base_freq_factor_store(struct device *dev,
+                      struct device_attribute *attr,
+                      const char *buff, size_t count)
+{
+    struct kobject *kobj = &dev->kobj;
+    struct xe_gt *gt = kobj_to_gt(kobj);
+    u32 val;
+    int err;
+
+    err = kstrtou32(buff, 0, &val);
+    if (err)
+        return err;
+
+    if (val > U8_8_VAL_MASK)
+        return -EINVAL;
+
+    err = xe_pcode_write_p(gt, PVC_PCODE_QOS_MULTIPLIER_SET,
+                PCODE_MBOX_DOMAIN_CHIPLET,
+                PCODE_MBOX_DOMAIN_BASE, val);
+    if (err)
+        return err;
+
+    return count;
+}
+static DEVICE_ATTR_RW(base_freq_factor);
+static struct device_attribute dev_attr_base_freq_factor_scale =
+    __ATTR(base_freq_factor.scale, 0444,
 freq_factor_scale_show, NULL);
+
+
+static ssize_t base_freq_rp0_show(struct device *dev, struct
 device_attribute *attr,
+                  char *buff)
+{
+    struct kobject *kobj = &dev->kobj;
+    struct xe_gt *gt = kobj_to_gt(kobj);
+    u32 val;
+    int err;
+
+    err = xe_pcode_read_p(gt, XEHP_PCODE_FREQUENCY_CONFIG,
+                PCODE_MBOX_FC_SC_READ_FUSED_P0,
+                PCODE_MBOX_DOMAIN_BASE, &val);
+    if (err)
+        return err;
+
+    /* data_out - Fused P0 for domain ID in units of 50 MHz */
+    val *= GT_FREQUENCY_MULTIPLIER;
+
+    return sysfs_emit(buff, "%u\n", val);
+}
+static DEVICE_ATTR_RO(base_freq_rp0);
+
+static ssize_t base_freq_rpn_show(struct device *dev, struct
 device_attribute *attr,
+                  char *buff)
+{
+    struct kobject *kobj = &dev->kobj;
+    struct xe_gt *gt = kobj_to_gt(kobj);
+    u32 val;
+    int err;
+
+    err = xe_pcode_read_p(gt, XEHP_PCODE_FREQUENCY_CONFIG,
+                PCODE_MBOX_FC_SC_READ_FUSED_PN,
+                PCODE_MBOX_DOMAIN_BASE, &val);
+    if (err)
+        return err;
+
+    /* data_out - Fused Pn for domain ID in units of 50 MHz */
+    val *= GT_FREQUENCY_MULTIPLIER;
+
+    return sysfs_emit(buff, "%u\n", val);
+}
+static DEVICE_ATTR_RO(base_freq_rpn);
+
+static const struct attribute *pvc_perf_power_attrs[] = {
+    &dev_attr_base_freq_factor.attr,
+    &dev_attr_base_freq_factor_scale.attr,
+    &dev_attr_base_freq_rp0.attr,
+    &dev_attr_base_freq_rpn.attr,
+    NULL
+};
+
   static void mtl_init_fused_rp_values(struct xe_guc_pc *pc)
   {
       struct xe_gt *gt = pc_to_gt(pc);
@@ -925,6 +1035,12 @@ int xe_guc_pc_init(struct xe_guc_pc *pc)
       if (err)
           return err;
   +    if (xe->info.platform == XE_PVC) {
+        err = sysfs_create_files(gt->sysfs, pvc_perf_power_attrs);
+        if (err)
+            return err;
+    }
+
       err = drmm_add_action_or_reset(&xe->drm, pc_fini, pc);
       if (err)
           return err;
drivers/gpu/drm/xe/xe_pcode_api.h +0 -0
index 837ff7c71280..da4114bfaa7a 100644
@@ -30,6 +30,25 @@
   #define   PCODE_READ_MIN_FREQ_TABLE    0x9
   #define   PCODE_FREQ_RING_RATIO_SHIFT    16
   +#define   XEHP_PCODE_FREQUENCY_CONFIG            0x6e    /*

xehp, pvc */

drivers/gpu/drm/xe/xe_pcode_api.h +18 -0
+/* XEHP_PCODE_FREQUENCY_CONFIG sub-commands (param1) */
+#define     PCODE_MBOX_FC_SC_READ_FUSED_P0        0x0
+#define     PCODE_MBOX_FC_SC_READ_FUSED_PN        0x1
+/* PCODE_MBOX_DOMAIN_* - mailbox domain IDs */
+/* XEHP_PCODE_FREQUENCY_CONFIG param2 */
+#define     PCODE_MBOX_DOMAIN_NONE            0x0
+#define     PCODE_MBOX_DOMAIN_GT            0x1
+#define     PCODE_MBOX_DOMAIN_HBM            0x2
+#define     PCODE_MBOX_DOMAIN_MEDIAFF            0x3
+#define     PCODE_MBOX_DOMAIN_MEDIA_SAMPLER        0x4
+#define     PCODE_MBOX_DOMAIN_SYSTOLIC_ARRAY        0x5
+#define     PCODE_MBOX_DOMAIN_CHIPLET            0x6
+#define     PCODE_MBOX_DOMAIN_BASE_CHIPLET_LINK        0x7
+#define     PCODE_MBOX_DOMAIN_BASE            0x8
+#define   PVC_PCODE_QOS_MULTIPLIER_SET            0x67
+/* See PCODE_MBOX_DOMAIN_* - mailbox domain IDs - param1 and 2 */
+#define   PVC_PCODE_QOS_MULTIPLIER_GET            0x66
+
   /* PCODE Init */
   #define   DGFX_PCODE_STATUS        0x7E
   #define     DGFX_GET_INIT_STATUS    0x0
Signature · 1 line
2.25.1
#15 lore raw

PATCH v2 3/3 drm/xe: Sysfs entries to query vram fused min, max frequency

In reply to Sujaritha Sundaresan

Add sysfs enteries for vram rp0 and vram rpn frequencies

v2: Fix review comments (Anshuman)

---
 drivers/gpu/drm/xe/xe_guc_pc.c | 54 ++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)
drivers/gpu/drm/xe/xe_guc_pc.c +54 -0
index 6a139d1dbf66..5084da83896b 100644
@@ -752,6 +752,54 @@ static const struct attribute *pvc_perf_power_attrs[] = {
 	NULL
 };
 
+static ssize_t freq_vram_rp0_show(struct device *dev, struct device_attribute *attr,
+				  char *buff)
+{
+	struct kobject *kobj = &dev->kobj;
+	struct xe_gt *gt = kobj_to_gt(kobj);
+	u32 val;
+	int err;
+
+	err = xe_pcode_read_p(gt, XEHP_PCODE_FREQUENCY_CONFIG,
+			      PCODE_MBOX_FC_SC_READ_FUSED_P0,
+			      PCODE_MBOX_DOMAIN_HBM, &val);
+	if (err)
+		return err;
+
+	/* data_out - Fused P0 for domain ID in units of 50 MHz */
+	val *= GT_FREQUENCY_MULTIPLIER;
+
+	return sysfs_emit(buff, "%u\n", val);
+}
+static DEVICE_ATTR_RO(freq_vram_rp0);
+
+static ssize_t freq_vram_rpn_show(struct device *dev, struct device_attribute *attr,
+				  char *buff)
+{
+	struct kobject *kobj = &dev->kobj;
+	struct xe_gt *gt = kobj_to_gt(kobj);
+	u32 val;
+	int err;
+
+	err = xe_pcode_read_p(gt, XEHP_PCODE_FREQUENCY_CONFIG,
+			      PCODE_MBOX_FC_SC_READ_FUSED_PN,
+			      PCODE_MBOX_DOMAIN_HBM, &val);
+	if (err)
+		return err;
+
+	/* data_out - Fused P0 for domain ID in units of 50 MHz */
+	val *= GT_FREQUENCY_MULTIPLIER;
+
+	return sysfs_emit(buff, "%u\n", val);
+}
+static DEVICE_ATTR_RO(freq_vram_rpn);
+
+static const struct attribute *vram_freq_attrs[] = {
+	&dev_attr_freq_vram_rp0.attr,
+	&dev_attr_freq_vram_rpn.attr,
+	NULL
+};
+
 static void mtl_init_fused_rp_values(struct xe_guc_pc *pc)
 {
 	struct xe_gt *gt = pc_to_gt(pc);
@@ -1041,6 +1089,12 @@ int xe_guc_pc_init(struct xe_guc_pc *pc)
 			return err;
 	}
 
+	if (xe->info.platform == XE_PVC) {
+		err = sysfs_create_files(tile->sysfs, vram_freq_attrs);
+		if (err)
+			return err;
+	}
+
 	err = drmm_add_action_or_reset(&xe->drm, pc_fini, pc);
 	if (err)
 		return err;
Signature · 1 line
2.25.1
#16 lore raw

[Intel-xe] ✗ CI.Patch_applied: failure for Add some performance and frequency sysfs nodes

In reply to Sujaritha Sundaresan
== Series Details ==

== Series Details ==

Series: Add some performance and frequency sysfs nodes
URL : https://patchwork.freedesktop.org/series/123164/
State : failure

== Summary ==

=== Applying kernel patches on branch 'drm-xe-next' with base: ===
Base commit: e4a038763 fixup! drm/xe: Add min/max cap for engine scheduler properties === git am output follows ===
error: patch failed: drivers/gpu/drm/xe/xe_guc_pc.c:925
error: drivers/gpu/drm/xe/xe_guc_pc.c: patch does not apply
hint: Use 'git am --show-current-patch' to see the failed patch
Applying: drm/xe: Add a couple of pcode helpers
Applying: drm/xe: Add base performance sysfs attributes
Patch failed at 0002 drm/xe: Add base performance sysfs attributes
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".