Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/6] Support PMT features in Xe
@ 2024-05-10 20:59 Michael J. Ruhl
  2024-05-10 20:59 ` [PATCH 1/6] platform/x86/intel/vsec.h: Move to include/linux Michael J. Ruhl
                   ` (8 more replies)
  0 siblings, 9 replies; 17+ messages in thread
From: Michael J. Ruhl @ 2024-05-10 20:59 UTC (permalink / raw)
  To: intel-xe; +Cc: david.e.box, Michael J. Ruhl

DG2 and Battlemage have the Intel Platform Monitoring Technology (PMT)
feature available, but not in the "standard" (pci endpoint) way.

Add support to the vsec and Xe drivers to allow access to the PMT space
for the DG2 and BMG devices.

The intel_vsec_register() function allows drivers to provide telemetry
header information (usually found at probe time), to allow the PMT
driver to probe the telemetry features.

Battlemage has a shared memory area (selected by index), so a callback
function is required to access the appropriate PMT data.

David E. Box (3):
  platform/x86/intel/vsec.h: Move to include/linux
  platform/x86/intel/vsec: Add PMT read callbacks
  platform/x86/intel/pmt: Add support to use provided read callbacks

Michael J. Ruhl (3):
  platform/x86/intel/pmt: Add quirk for BAR0 offset adjustment
  drm/xe/vsec: Add support for DG2
  drm/xe/vsec: Support BMG devices

 drivers/gpu/drm/xe/Makefile                   |   1 +
 drivers/gpu/drm/xe/xe_device.c                |   5 +
 drivers/gpu/drm/xe/xe_device_types.h          |   5 +
 drivers/gpu/drm/xe/xe_vsec.c                  | 241 ++++++++++++++++++
 drivers/gpu/drm/xe/xe_vsec.h                  |  13 +
 drivers/platform/x86/intel/pmc/core_ssram.c   |   2 +-
 drivers/platform/x86/intel/pmt/class.c        |  33 ++-
 drivers/platform/x86/intel/pmt/class.h        |  10 +-
 drivers/platform/x86/intel/pmt/crashlog.c     |   2 +-
 drivers/platform/x86/intel/pmt/telemetry.c    |  14 +-
 drivers/platform/x86/intel/sdsi.c             |   3 +-
 drivers/platform/x86/intel/tpmi.c             |   3 +-
 drivers/platform/x86/intel/vsec.c             |  10 +-
 .../vsec.h => include/linux/intel_vsec.h      |  12 +-
 14 files changed, 325 insertions(+), 29 deletions(-)
 create mode 100644 drivers/gpu/drm/xe/xe_vsec.c
 create mode 100644 drivers/gpu/drm/xe/xe_vsec.h
 rename drivers/platform/x86/intel/vsec.h => include/linux/intel_vsec.h (92%)

-- 
2.44.0


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 1/6] platform/x86/intel/vsec.h: Move to include/linux
  2024-05-10 20:59 [PATCH 0/6] Support PMT features in Xe Michael J. Ruhl
@ 2024-05-10 20:59 ` Michael J. Ruhl
  2024-05-28 15:43   ` Ruhl, Michael J
  2024-05-10 20:59 ` [PATCH 2/6] platform/x86/intel/vsec: Add PMT read callbacks Michael J. Ruhl
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 17+ messages in thread
From: Michael J. Ruhl @ 2024-05-10 20:59 UTC (permalink / raw)
  To: intel-xe; +Cc: david.e.box

From: "David E. Box" <david.e.box@linux.intel.com>

Some drivers outside of PDX86 need access to the vsec header. Move it to
include/linux to make it easier to include.

Signed-off-by: David E. Box <david.e.box@linux.intel.com>
---
 drivers/platform/x86/intel/pmc/core_ssram.c                  | 2 +-
 drivers/platform/x86/intel/pmt/class.c                       | 2 +-
 drivers/platform/x86/intel/pmt/class.h                       | 2 +-
 drivers/platform/x86/intel/pmt/crashlog.c                    | 2 +-
 drivers/platform/x86/intel/pmt/telemetry.c                   | 2 +-
 drivers/platform/x86/intel/sdsi.c                            | 3 +--
 drivers/platform/x86/intel/tpmi.c                            | 3 +--
 drivers/platform/x86/intel/vsec.c                            | 5 ++---
 .../platform/x86/intel/vsec.h => include/linux/intel_vsec.h  | 4 ++--
 9 files changed, 11 insertions(+), 14 deletions(-)
 rename drivers/platform/x86/intel/vsec.h => include/linux/intel_vsec.h (98%)

diff --git a/drivers/platform/x86/intel/pmc/core_ssram.c b/drivers/platform/x86/intel/pmc/core_ssram.c
index 1bde86c54eb9..baddaaec25ee 100644
--- a/drivers/platform/x86/intel/pmc/core_ssram.c
+++ b/drivers/platform/x86/intel/pmc/core_ssram.c
@@ -9,11 +9,11 @@
  */
 
 #include <linux/cleanup.h>
+#include <linux/intel_vsec.h>
 #include <linux/pci.h>
 #include <linux/io-64-nonatomic-lo-hi.h>
 
 #include "core.h"
-#include "../vsec.h"
 #include "../pmt/telemetry.h"
 
 #define SSRAM_HDR_SIZE		0x100
diff --git a/drivers/platform/x86/intel/pmt/class.c b/drivers/platform/x86/intel/pmt/class.c
index 4b53940a64e2..d7939b28e937 100644
--- a/drivers/platform/x86/intel/pmt/class.c
+++ b/drivers/platform/x86/intel/pmt/class.c
@@ -9,12 +9,12 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/intel_vsec.h>
 #include <linux/io-64-nonatomic-lo-hi.h>
 #include <linux/module.h>
 #include <linux/mm.h>
 #include <linux/pci.h>
 
-#include "../vsec.h"
 #include "class.h"
 
 #define PMT_XA_START		1
diff --git a/drivers/platform/x86/intel/pmt/class.h b/drivers/platform/x86/intel/pmt/class.h
index d23c63b73ab7..d6f9ccaf28c8 100644
--- a/drivers/platform/x86/intel/pmt/class.h
+++ b/drivers/platform/x86/intel/pmt/class.h
@@ -2,13 +2,13 @@
 #ifndef _INTEL_PMT_CLASS_H
 #define _INTEL_PMT_CLASS_H
 
+#include <linux/intel_vsec.h>
 #include <linux/xarray.h>
 #include <linux/types.h>
 #include <linux/bits.h>
 #include <linux/err.h>
 #include <linux/io.h>
 
-#include "../vsec.h"
 #include "telemetry.h"
 
 /* PMT access types */
diff --git a/drivers/platform/x86/intel/pmt/crashlog.c b/drivers/platform/x86/intel/pmt/crashlog.c
index 4014c02cafdb..9079d5dffc03 100644
--- a/drivers/platform/x86/intel/pmt/crashlog.c
+++ b/drivers/platform/x86/intel/pmt/crashlog.c
@@ -9,6 +9,7 @@
  */
 
 #include <linux/auxiliary_bus.h>
+#include <linux/intel_vsec.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/pci.h>
@@ -16,7 +17,6 @@
 #include <linux/uaccess.h>
 #include <linux/overflow.h>
 
-#include "../vsec.h"
 #include "class.h"
 
 /* Crashlog discovery header types */
diff --git a/drivers/platform/x86/intel/pmt/telemetry.c b/drivers/platform/x86/intel/pmt/telemetry.c
index 09258564dfc4..3478f891ea0b 100644
--- a/drivers/platform/x86/intel/pmt/telemetry.c
+++ b/drivers/platform/x86/intel/pmt/telemetry.c
@@ -9,6 +9,7 @@
  */
 
 #include <linux/auxiliary_bus.h>
+#include <linux/intel_vsec.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/pci.h>
@@ -16,7 +17,6 @@
 #include <linux/uaccess.h>
 #include <linux/overflow.h>
 
-#include "../vsec.h"
 #include "class.h"
 
 #define TELEM_SIZE_OFFSET	0x0
diff --git a/drivers/platform/x86/intel/sdsi.c b/drivers/platform/x86/intel/sdsi.c
index 556e7c6dbb05..322ada188ee9 100644
--- a/drivers/platform/x86/intel/sdsi.c
+++ b/drivers/platform/x86/intel/sdsi.c
@@ -12,6 +12,7 @@
 #include <linux/bits.h>
 #include <linux/bitfield.h>
 #include <linux/device.h>
+#include <linux/intel_vsec.h>
 #include <linux/iopoll.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
@@ -21,8 +22,6 @@
 #include <linux/types.h>
 #include <linux/uaccess.h>
 
-#include "vsec.h"
-
 #define ACCESS_TYPE_BARID		2
 #define ACCESS_TYPE_LOCAL		3
 
diff --git a/drivers/platform/x86/intel/tpmi.c b/drivers/platform/x86/intel/tpmi.c
index 910df7c654f4..be7ea557b72d 100644
--- a/drivers/platform/x86/intel/tpmi.c
+++ b/drivers/platform/x86/intel/tpmi.c
@@ -51,6 +51,7 @@
 #include <linux/debugfs.h>
 #include <linux/delay.h>
 #include <linux/intel_tpmi.h>
+#include <linux/intel_vsec.h>
 #include <linux/io.h>
 #include <linux/iopoll.h>
 #include <linux/module.h>
@@ -59,8 +60,6 @@
 #include <linux/sizes.h>
 #include <linux/string_helpers.h>
 
-#include "vsec.h"
-
 /**
  * struct intel_tpmi_pfs_entry - TPMI PM Feature Structure (PFS) entry
  * @tpmi_id:	TPMI feature identifier (what the feature is and its data format).
diff --git a/drivers/platform/x86/intel/vsec.c b/drivers/platform/x86/intel/vsec.c
index 0fdfaf3a4f5c..5a1e964783cc 100644
--- a/drivers/platform/x86/intel/vsec.c
+++ b/drivers/platform/x86/intel/vsec.c
@@ -17,14 +17,13 @@
 #include <linux/bits.h>
 #include <linux/cleanup.h>
 #include <linux/delay.h>
-#include <linux/kernel.h>
 #include <linux/idr.h>
+#include <linux/intel_vsec.h>
+#include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/types.h>
 
-#include "vsec.h"
-
 #define PMT_XA_START			0
 #define PMT_XA_MAX			INT_MAX
 #define PMT_XA_LIMIT			XA_LIMIT(PMT_XA_START, PMT_XA_MAX)
diff --git a/drivers/platform/x86/intel/vsec.h b/include/linux/intel_vsec.h
similarity index 98%
rename from drivers/platform/x86/intel/vsec.h
rename to include/linux/intel_vsec.h
index e23e76129691..7f19a3d90abe 100644
--- a/drivers/platform/x86/intel/vsec.h
+++ b/include/linux/intel_vsec.h
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _VSEC_H
-#define _VSEC_H
+#ifndef _INTEL_VSEC_H
+#define _INTEL_VSEC_H
 
 #include <linux/auxiliary_bus.h>
 #include <linux/bits.h>
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 2/6] platform/x86/intel/vsec: Add PMT read callbacks
  2024-05-10 20:59 [PATCH 0/6] Support PMT features in Xe Michael J. Ruhl
  2024-05-10 20:59 ` [PATCH 1/6] platform/x86/intel/vsec.h: Move to include/linux Michael J. Ruhl
@ 2024-05-10 20:59 ` Michael J. Ruhl
  2024-05-10 20:59 ` [PATCH 3/6] platform/x86/intel/pmt: Add support to use provided " Michael J. Ruhl
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 17+ messages in thread
From: Michael J. Ruhl @ 2024-05-10 20:59 UTC (permalink / raw)
  To: intel-xe; +Cc: david.e.box

From: "David E. Box" <david.e.box@linux.intel.com>

Signed-off-by: David E. Box <david.e.box@linux.intel.com>
---
 drivers/platform/x86/intel/vsec.c | 1 +
 include/linux/intel_vsec.h        | 5 +++++
 2 files changed, 6 insertions(+)

diff --git a/drivers/platform/x86/intel/vsec.c b/drivers/platform/x86/intel/vsec.c
index 5a1e964783cc..5378da9354b6 100644
--- a/drivers/platform/x86/intel/vsec.c
+++ b/drivers/platform/x86/intel/vsec.c
@@ -212,6 +212,7 @@ static int intel_vsec_add_dev(struct pci_dev *pdev, struct intel_vsec_header *he
 	intel_vsec_dev->num_resources = header->num_entries;
 	intel_vsec_dev->quirks = info->quirks;
 	intel_vsec_dev->base_addr = info->base_addr;
+	intel_vsec_dev->priv_data = info->priv_data;
 
 	if (header->id == VSEC_ID_SDSI)
 		intel_vsec_dev->ida = &intel_vsec_sdsi_ida;
diff --git a/include/linux/intel_vsec.h b/include/linux/intel_vsec.h
index 7f19a3d90abe..04f915a1ba0b 100644
--- a/include/linux/intel_vsec.h
+++ b/include/linux/intel_vsec.h
@@ -67,10 +67,15 @@ enum intel_vsec_quirks {
 	VSEC_QUIRK_EARLY_HW     = BIT(4),
 };
 
+struct pmt_callbacks {
+	int (*read_telem)(void *args, u32 guid, u64 *data, u32 count);
+};
+
 /* Platform specific data */
 struct intel_vsec_platform_info {
 	struct device *parent;
 	struct intel_vsec_header **headers;
+	void *priv_data;
 	unsigned long caps;
 	unsigned long quirks;
 	u64 base_addr;
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 3/6] platform/x86/intel/pmt: Add support to use provided read callbacks
  2024-05-10 20:59 [PATCH 0/6] Support PMT features in Xe Michael J. Ruhl
  2024-05-10 20:59 ` [PATCH 1/6] platform/x86/intel/vsec.h: Move to include/linux Michael J. Ruhl
  2024-05-10 20:59 ` [PATCH 2/6] platform/x86/intel/vsec: Add PMT read callbacks Michael J. Ruhl
@ 2024-05-10 20:59 ` Michael J. Ruhl
  2024-05-13 17:15   ` Rodrigo Vivi
  2024-05-10 20:59 ` [PATCH 4/6] platform/x86/intel/pmt: Add quirk for BAR0 offset adjustment Michael J. Ruhl
                   ` (5 subsequent siblings)
  8 siblings, 1 reply; 17+ messages in thread
From: Michael J. Ruhl @ 2024-05-10 20:59 UTC (permalink / raw)
  To: intel-xe; +Cc: david.e.box

From: "David E. Box" <david.e.box@linux.intel.com>

Signed-off-by: David E. Box <david.e.box@linux.intel.com>
---
 drivers/platform/x86/intel/pmt/class.c     | 28 +++++++++++++++++-----
 drivers/platform/x86/intel/pmt/class.h     |  8 +++++--
 drivers/platform/x86/intel/pmt/telemetry.c | 10 ++++----
 3 files changed, 34 insertions(+), 12 deletions(-)

diff --git a/drivers/platform/x86/intel/pmt/class.c b/drivers/platform/x86/intel/pmt/class.c
index d7939b28e937..62e36dd89137 100644
--- a/drivers/platform/x86/intel/pmt/class.c
+++ b/drivers/platform/x86/intel/pmt/class.c
@@ -58,6 +58,24 @@ pmt_memcpy64_fromio(void *to, const u64 __iomem *from, size_t count)
 	return count;
 }
 
+void pmt_telem_read_mmio(struct pci_dev *pdev, struct pmt_callbacks *cb, u32 guid, void *buf,
+			 void __iomem *addr, u32 count)
+{
+	if (cb && cb->read_telem) {
+		count = cb->read_telem(pdev, guid, buf, count);
+		return;
+	}
+
+	if (guid == GUID_SPR_PUNIT) {
+		/* PUNIT on SPR only supports aligned 64-bit read */
+		count = pmt_memcpy64_fromio(buf, addr, count);
+		return;
+	}
+
+	memcpy_fromio(buf, addr, count);
+}
+EXPORT_SYMBOL_NS_GPL(pmt_telem_read_mmio, INTEL_PMT);
+
 /*
  * sysfs
  */
@@ -79,11 +97,8 @@ intel_pmt_read(struct file *filp, struct kobject *kobj,
 	if (count > entry->size - off)
 		count = entry->size - off;
 
-	if (entry->guid == GUID_SPR_PUNIT)
-		/* PUNIT on SPR only supports aligned 64-bit read */
-		count = pmt_memcpy64_fromio(buf, entry->base + off, count);
-	else
-		memcpy_fromio(buf, entry->base + off, count);
+	pmt_telem_read_mmio(entry->ep->pcidev, entry->cb, entry->header.guid, buf,
+			    entry->base + off, count);
 
 	return count;
 }
@@ -239,6 +254,7 @@ static int intel_pmt_populate_entry(struct intel_pmt_entry *entry,
 
 	entry->guid = header->guid;
 	entry->size = header->size;
+	entry->cb = ivdev->priv_data;
 
 	return 0;
 }
@@ -300,7 +316,7 @@ static int intel_pmt_dev_register(struct intel_pmt_entry *entry,
 		goto fail_ioremap;
 
 	if (ns->pmt_add_endpoint) {
-		ret = ns->pmt_add_endpoint(entry, ivdev->pcidev);
+		ret = ns->pmt_add_endpoint(ivdev, entry);
 		if (ret)
 			goto fail_add_endpoint;
 	}
diff --git a/drivers/platform/x86/intel/pmt/class.h b/drivers/platform/x86/intel/pmt/class.h
index d6f9ccaf28c8..5032c5244eb4 100644
--- a/drivers/platform/x86/intel/pmt/class.h
+++ b/drivers/platform/x86/intel/pmt/class.h
@@ -24,6 +24,7 @@ struct pci_dev;
 struct telem_endpoint {
 	struct pci_dev		*pcidev;
 	struct telem_header	header;
+	struct pmt_callbacks	*cb;
 	void __iomem		*base;
 	bool			present;
 	struct kref		kref;
@@ -43,6 +44,7 @@ struct intel_pmt_entry {
 	struct kobject		*kobj;
 	void __iomem		*disc_table;
 	void __iomem		*base;
+	struct pmt_callbacks	*cb;
 	unsigned long		base_addr;
 	size_t			size;
 	u32			guid;
@@ -55,10 +57,12 @@ struct intel_pmt_namespace {
 	const struct attribute_group *attr_grp;
 	int (*pmt_header_decode)(struct intel_pmt_entry *entry,
 				 struct device *dev);
-	int (*pmt_add_endpoint)(struct intel_pmt_entry *entry,
-				struct pci_dev *pdev);
+	int (*pmt_add_endpoint)(struct intel_vsec_device *ivdev,
+				struct intel_pmt_entry *entry);
 };
 
+void pmt_telem_read_mmio(struct pci_dev *pdev, struct pmt_callbacks *cb, u32 guid, void *buf,
+			 void __iomem *addr, u32 count);
 bool intel_pmt_is_early_client_hw(struct device *dev);
 int intel_pmt_dev_create(struct intel_pmt_entry *entry,
 			 struct intel_pmt_namespace *ns,
diff --git a/drivers/platform/x86/intel/pmt/telemetry.c b/drivers/platform/x86/intel/pmt/telemetry.c
index 3478f891ea0b..c9feac859e57 100644
--- a/drivers/platform/x86/intel/pmt/telemetry.c
+++ b/drivers/platform/x86/intel/pmt/telemetry.c
@@ -93,8 +93,8 @@ static int pmt_telem_header_decode(struct intel_pmt_entry *entry,
 	return 0;
 }
 
-static int pmt_telem_add_endpoint(struct intel_pmt_entry *entry,
-				  struct pci_dev *pdev)
+static int pmt_telem_add_endpoint(struct intel_vsec_device *ivdev,
+				  struct intel_pmt_entry *entry)
 {
 	struct telem_endpoint *ep;
 
@@ -104,13 +104,14 @@ static int pmt_telem_add_endpoint(struct intel_pmt_entry *entry,
 		return -ENOMEM;
 
 	ep = entry->ep;
-	ep->pcidev = pdev;
+	ep->pcidev = ivdev->pcidev;
 	ep->header.access_type = entry->header.access_type;
 	ep->header.guid = entry->header.guid;
 	ep->header.base_offset = entry->header.base_offset;
 	ep->header.size = entry->header.size;
 	ep->base = entry->base;
 	ep->present = true;
+	ep->cb = ivdev->priv_data;
 
 	kref_init(&ep->kref);
 
@@ -218,7 +219,8 @@ int pmt_telem_read(struct telem_endpoint *ep, u32 id, u64 *data, u32 count)
 	if (offset + NUM_BYTES_QWORD(count) > size)
 		return -EINVAL;
 
-	memcpy_fromio(data, ep->base + offset, NUM_BYTES_QWORD(count));
+	pmt_telem_read_mmio(ep->pcidev, ep->cb, ep->header.guid, data, ep->base + offset,
+			    NUM_BYTES_QWORD(count));
 
 	return ep->present ? 0 : -EPIPE;
 }
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 4/6] platform/x86/intel/pmt: Add quirk for BAR0 offset adjustment
  2024-05-10 20:59 [PATCH 0/6] Support PMT features in Xe Michael J. Ruhl
                   ` (2 preceding siblings ...)
  2024-05-10 20:59 ` [PATCH 3/6] platform/x86/intel/pmt: Add support to use provided " Michael J. Ruhl
@ 2024-05-10 20:59 ` Michael J. Ruhl
  2024-05-30 20:59   ` David E. Box
  2024-05-10 20:59 ` [PATCH 5/6] drm/xe/vsec: Add support for DG2 Michael J. Ruhl
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 17+ messages in thread
From: Michael J. Ruhl @ 2024-05-10 20:59 UTC (permalink / raw)
  To: intel-xe; +Cc: david.e.box, Michael J. Ruhl

The offset for the discovery table is based on the P2SB bar.
If this bar is not available, the parent driver may need to
adjust the offset,

Add a quirk to allow for this adjustment.

Signed-off-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
---
 drivers/platform/x86/intel/pmt/class.c     | 3 +++
 drivers/platform/x86/intel/pmt/telemetry.c | 2 +-
 drivers/platform/x86/intel/vsec.c          | 2 +-
 include/linux/intel_vsec.h                 | 3 +++
 4 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/intel/pmt/class.c b/drivers/platform/x86/intel/pmt/class.c
index 62e36dd89137..957cf74234da 100644
--- a/drivers/platform/x86/intel/pmt/class.c
+++ b/drivers/platform/x86/intel/pmt/class.c
@@ -349,6 +349,9 @@ int intel_pmt_dev_create(struct intel_pmt_entry *entry, struct intel_pmt_namespa
 	if (IS_ERR(entry->disc_table))
 		return PTR_ERR(entry->disc_table);
 
+	if (intel_vsec_dev->quirks & VSEC_QUIRK_P2SB_OFFSET)
+		entry->base_addr = intel_vsec_dev->base_addr;
+
 	ret = ns->pmt_header_decode(entry, dev);
 	if (ret)
 		return ret;
diff --git a/drivers/platform/x86/intel/pmt/telemetry.c b/drivers/platform/x86/intel/pmt/telemetry.c
index c9feac859e57..7be9f9746363 100644
--- a/drivers/platform/x86/intel/pmt/telemetry.c
+++ b/drivers/platform/x86/intel/pmt/telemetry.c
@@ -77,7 +77,7 @@ static int pmt_telem_header_decode(struct intel_pmt_entry *entry,
 
 	header->access_type = TELEM_ACCESS(readl(disc_table));
 	header->guid = readl(disc_table + TELEM_GUID_OFFSET);
-	header->base_offset = readl(disc_table + TELEM_BASE_OFFSET);
+	header->base_offset = readl(disc_table + TELEM_BASE_OFFSET) + entry->base_addr;
 
 	/* Size is measured in DWORDS, but accessor returns bytes */
 	header->size = TELEM_SIZE(readl(disc_table));
diff --git a/drivers/platform/x86/intel/vsec.c b/drivers/platform/x86/intel/vsec.c
index 5378da9354b6..5a0dfc21eb0f 100644
--- a/drivers/platform/x86/intel/vsec.c
+++ b/drivers/platform/x86/intel/vsec.c
@@ -185,7 +185,7 @@ static int intel_vsec_add_dev(struct pci_dev *pdev, struct intel_vsec_header *he
 	if (quirks & VSEC_QUIRK_TABLE_SHIFT)
 		header->offset >>= TABLE_OFFSET_SHIFT;
 
-	if (info->base_addr)
+	if (!(quirks & VSEC_QUIRK_P2SB_OFFSET) && info->base_addr)
 		base_addr = info->base_addr;
 	else
 		base_addr = pdev->resource[header->tbir].start;
diff --git a/include/linux/intel_vsec.h b/include/linux/intel_vsec.h
index 04f915a1ba0b..68e3a42040e8 100644
--- a/include/linux/intel_vsec.h
+++ b/include/linux/intel_vsec.h
@@ -65,6 +65,9 @@ enum intel_vsec_quirks {
 
 	/* Platforms requiring quirk in the auxiliary driver */
 	VSEC_QUIRK_EARLY_HW     = BIT(4),
+
+	/* Broken P2SB access work around */
+	VSEC_QUIRK_P2SB_OFFSET  = BIT(5),
 };
 
 struct pmt_callbacks {
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 5/6] drm/xe/vsec: Add support for DG2
  2024-05-10 20:59 [PATCH 0/6] Support PMT features in Xe Michael J. Ruhl
                   ` (3 preceding siblings ...)
  2024-05-10 20:59 ` [PATCH 4/6] platform/x86/intel/pmt: Add quirk for BAR0 offset adjustment Michael J. Ruhl
@ 2024-05-10 20:59 ` Michael J. Ruhl
  2024-05-10 20:59 ` [PATCH 6/6] drm/xe/vsec: Support BMG devices Michael J. Ruhl
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 17+ messages in thread
From: Michael J. Ruhl @ 2024-05-10 20:59 UTC (permalink / raw)
  To: intel-xe; +Cc: david.e.box, Michael J. Ruhl

DG2 needs to adjust the discovery offset WRT the GT BAR
not the P2SB bar so utilize the P2SB quirk.

Add support by registering via the intel_vsec_register()
API.

Signed-off-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
---
 drivers/gpu/drm/xe/Makefile    |   1 +
 drivers/gpu/drm/xe/xe_device.c |   3 +
 drivers/gpu/drm/xe/xe_vsec.c   | 110 +++++++++++++++++++++++++++++++++
 drivers/gpu/drm/xe/xe_vsec.h   |  13 ++++
 4 files changed, 127 insertions(+)
 create mode 100644 drivers/gpu/drm/xe/xe_vsec.c
 create mode 100644 drivers/gpu/drm/xe/xe_vsec.h

diff --git a/drivers/gpu/drm/xe/Makefile b/drivers/gpu/drm/xe/Makefile
index a67977edff5b..805b27201e1a 100644
--- a/drivers/gpu/drm/xe/Makefile
+++ b/drivers/gpu/drm/xe/Makefile
@@ -143,6 +143,7 @@ xe-y += xe_bb.o \
 	xe_uc_debugfs.o \
 	xe_uc_fw.o \
 	xe_vm.o \
+	xe_vsec.o \
 	xe_vram_freq.o \
 	xe_wait_user_fence.o \
 	xe_wa.o \
diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
index 4165e1347371..e77768bc4471 100644
--- a/drivers/gpu/drm/xe/xe_device.c
+++ b/drivers/gpu/drm/xe/xe_device.c
@@ -46,6 +46,7 @@
 #include "xe_ttm_stolen_mgr.h"
 #include "xe_ttm_sys_mgr.h"
 #include "xe_vm.h"
+#include "xe_vsec.h"
 #include "xe_wait_user_fence.h"
 
 static int xe_file_open(struct drm_device *dev, struct drm_file *file)
@@ -662,6 +663,8 @@ int xe_device_probe(struct xe_device *xe)
 
 	xe_hwmon_register(xe);
 
+	xe_vsec_init(xe);
+
 	return drmm_add_action_or_reset(&xe->drm, xe_device_sanitize, xe);
 
 err_fini_display:
diff --git a/drivers/gpu/drm/xe/xe_vsec.c b/drivers/gpu/drm/xe/xe_vsec.c
new file mode 100644
index 000000000000..a91aec49d04a
--- /dev/null
+++ b/drivers/gpu/drm/xe/xe_vsec.c
@@ -0,0 +1,110 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright © 2022 - 2024 Intel Corporation
+ */
+#include <linux/intel_vsec.h>
+#include <linux/pci.h>
+
+#include "xe_device_types.h"
+#include "xe_drv.h"
+#include "xe_platform_types.h"
+#include "xe_vsec.h"
+
+#define SOC_BASE		0x280000
+
+/* from drivers/platform/x86/intel/pmt/telemetry.c */
+#define TELEM_BASE_OFFSET	0x8
+
+#define DG2_PMT_BASE		0xE8000
+#define DG2_DISCOVERY_START	0x6000
+#define DG2_TELEM_START		0x4000
+
+#define DG2_DISCOVERY_OFFSET	(SOC_BASE + DG2_PMT_BASE + DG2_DISCOVERY_START)
+#define DG2_TELEM_OFFSET	(SOC_BASE + DG2_PMT_BASE + DG2_TELEM_START)
+
+#define GFX_BAR			0
+
+static struct intel_vsec_header dg2_telemetry = {
+	.length = 0x10,
+	.id = VSEC_ID_TELEMETRY,
+	.num_entries = 1,
+	.entry_size = 3,
+	.tbir = GFX_BAR,
+	.offset = DG2_DISCOVERY_OFFSET,
+};
+
+static struct intel_vsec_header *dg2_capabilities[] = {
+	&dg2_telemetry,
+	NULL
+};
+
+static struct intel_vsec_platform_info dg2_vsec_info = {
+	.caps = VSEC_CAP_TELEMETRY,
+	.headers = dg2_capabilities,
+	.quirks = VSEC_QUIRK_EARLY_HW | VSEC_QUIRK_P2SB_OFFSET,
+};
+
+/*
+ * Access the DG2 PMT MMIO discovery table
+ *
+ * The intel_vsec driver does not typically access the discovery table.
+ * Instead, it creates a memory resource for the table and passes it
+ * to the PMT telemetry driver. Each discovery table contains 3 items,
+ *    - GUID
+ *    - Telemetry size
+ *    - Telemetry offset (offset from P2SB BAR, not GT)
+ *
+ * For DG2 we know what the telemetry offset is, but we still need to
+ * use the discovery table to pass the GUID and the size. So figure
+ * out the difference between the P2SB offset and the GT offset and
+ * save this so that the telemetry driver can use it to adjust the
+ * value.
+ */
+static int dg2_adjust_offset(struct pci_dev *pdev, struct device *dev,
+			     struct intel_vsec_platform_info *info)
+{
+	void __iomem *base;
+	u32 telem_offset;
+	u64 addr;
+
+	addr = pci_resource_start(pdev, GFX_BAR) + info->headers[0]->offset;
+	base = ioremap_wc(addr, 16);
+	if (!base)
+		return -ENOMEM;
+
+	telem_offset = readl(base + TELEM_BASE_OFFSET);
+
+	/* Use the base_addr + P2SB quirk to pass this info */
+	if (telem_offset < DG2_TELEM_OFFSET)
+		info->base_addr = -(DG2_TELEM_OFFSET - telem_offset);
+	else
+		info->base_addr = -(telem_offset - DG2_TELEM_OFFSET);
+
+	iounmap(base);
+
+	return 0;
+}
+
+/**
+ * intel_vsec_init - Initialize resources and add intel_vsec auxiliary
+ * interface
+ * @xe: valid xe instance
+ */
+void xe_vsec_init(struct xe_device *xe)
+{
+	struct intel_vsec_platform_info *info = &dg2_vsec_info;
+	struct device *dev = xe->drm.dev;
+	struct pci_dev *pdev = to_pci_dev(dev);
+	u32 ret;
+
+	ret = dg2_adjust_offset(pdev, dev, info);
+	if (ret)
+		return;
+
+	/*
+	 * Register a VSEC. Cleanup is handled using device managed
+	 * resources.
+	 */
+	intel_vsec_register(pdev, info);
+}
+MODULE_IMPORT_NS(INTEL_VSEC);
diff --git a/drivers/gpu/drm/xe/xe_vsec.h b/drivers/gpu/drm/xe/xe_vsec.h
new file mode 100644
index 000000000000..3fd29a21cad6
--- /dev/null
+++ b/drivers/gpu/drm/xe/xe_vsec.h
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright © 2022 - 2024 Intel Corporation
+ */
+
+#ifndef _XE_VSEC_H_
+#define _XE_VSEC_H_
+
+struct xe_device;
+
+void xe_vsec_init(struct xe_device *xe);
+
+#endif
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 6/6] drm/xe/vsec: Support BMG devices
  2024-05-10 20:59 [PATCH 0/6] Support PMT features in Xe Michael J. Ruhl
                   ` (4 preceding siblings ...)
  2024-05-10 20:59 ` [PATCH 5/6] drm/xe/vsec: Add support for DG2 Michael J. Ruhl
@ 2024-05-10 20:59 ` Michael J. Ruhl
  2024-05-30 21:06   ` David E. Box
  2024-05-10 21:48 ` ✓ CI.Patch_applied: success for Support PMT features in Xe Patchwork
                   ` (2 subsequent siblings)
  8 siblings, 1 reply; 17+ messages in thread
From: Michael J. Ruhl @ 2024-05-10 20:59 UTC (permalink / raw)
  To: intel-xe; +Cc: david.e.box, Michael J. Ruhl

Utilize the PMT callback API to add support for the BMG
devices.

Signed-off-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
---
 drivers/gpu/drm/xe/xe_device.c       |   2 +
 drivers/gpu/drm/xe/xe_device_types.h |   5 +
 drivers/gpu/drm/xe/xe_vsec.c         | 145 +++++++++++++++++++++++++--
 drivers/platform/x86/intel/vsec.c    |   2 +-
 4 files changed, 146 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
index e77768bc4471..940f4cf0274a 100644
--- a/drivers/gpu/drm/xe/xe_device.c
+++ b/drivers/gpu/drm/xe/xe_device.c
@@ -315,6 +315,8 @@ struct xe_device *xe_device_create(struct pci_dev *pdev,
 		goto err;
 	}
 
+	drmm_mutex_init(&xe->drm, &xe->pmt.lock);
+
 	err = xe_display_create(xe);
 	if (WARN_ON(err))
 		goto err;
diff --git a/drivers/gpu/drm/xe/xe_device_types.h b/drivers/gpu/drm/xe/xe_device_types.h
index 0af739981ebf..f451216c2283 100644
--- a/drivers/gpu/drm/xe/xe_device_types.h
+++ b/drivers/gpu/drm/xe/xe_device_types.h
@@ -448,6 +448,11 @@ struct xe_device {
 		struct mutex lock;
 	} d3cold;
 
+	struct {
+		/** @pmt.lock: protect access for telemetry data */
+		struct mutex lock;
+	} pmt;
+
 	/**
 	 * @pm_callback_task: Track the active task that is running in either
 	 * the runtime_suspend or runtime_resume callbacks.
diff --git a/drivers/gpu/drm/xe/xe_vsec.c b/drivers/gpu/drm/xe/xe_vsec.c
index a91aec49d04a..ac840a1e20a4 100644
--- a/drivers/gpu/drm/xe/xe_vsec.c
+++ b/drivers/gpu/drm/xe/xe_vsec.c
@@ -5,9 +5,12 @@
 #include <linux/intel_vsec.h>
 #include <linux/pci.h>
 
+#include "xe_device.h"
 #include "xe_device_types.h"
 #include "xe_drv.h"
+#include "xe_mmio.h"
 #include "xe_platform_types.h"
+#include "xe_pm.h"
 #include "xe_vsec.h"
 
 #define SOC_BASE		0x280000
@@ -15,6 +18,10 @@
 /* from drivers/platform/x86/intel/pmt/telemetry.c */
 #define TELEM_BASE_OFFSET	0x8
 
+/* Decode the guid information */
+#define GUID_RECORD_MASK GENMASK(1, 0)
+#define GUID_CAP_TYPE    GENMASK(3, 2)
+
 #define DG2_PMT_BASE		0xE8000
 #define DG2_DISCOVERY_START	0x6000
 #define DG2_TELEM_START		0x4000
@@ -22,8 +29,18 @@
 #define DG2_DISCOVERY_OFFSET	(SOC_BASE + DG2_PMT_BASE + DG2_DISCOVERY_START)
 #define DG2_TELEM_OFFSET	(SOC_BASE + DG2_PMT_BASE + DG2_TELEM_START)
 
+#define BMG_PMT_BASE		0xDB000
+#define BMG_DISCOVERY_OFFSET	(SOC_BASE + BMG_PMT_BASE)
+
+#define BMG_TELEMETRY_BASE	0xE0000
+#define BMG_TELEMETRY_OFFSET	(SOC_BASE + BMG_TELEMETRY_BASE)
+
 #define GFX_BAR			0
 
+#define SG_REMAP_INDEX1		XE_REG(SOC_BASE + 0x08)
+#define SG_REMAP_ACCESS(_mem)	((_mem) << 24)
+#define SG_REMAP_BITS		GENMASK(31, 24)
+
 static struct intel_vsec_header dg2_telemetry = {
 	.length = 0x10,
 	.id = VSEC_ID_TELEMETRY,
@@ -38,12 +55,106 @@ static struct intel_vsec_header *dg2_capabilities[] = {
 	NULL
 };
 
-static struct intel_vsec_platform_info dg2_vsec_info = {
-	.caps = VSEC_CAP_TELEMETRY,
-	.headers = dg2_capabilities,
-	.quirks = VSEC_QUIRK_EARLY_HW | VSEC_QUIRK_P2SB_OFFSET,
+static struct intel_vsec_header bmg_telemetry = {
+	.length = 0x10,
+	.id = VSEC_ID_TELEMETRY,
+	.num_entries = 2,
+	.entry_size = 4,
+	.tbir = GFX_BAR,
+	.offset = BMG_DISCOVERY_OFFSET,
+};
+
+static struct intel_vsec_header *bmg_capabilities[] = {
+	&bmg_telemetry,
+	NULL
+};
+
+enum xe_vsec {
+	XE_VSEC_UNKNOWN = 0,
+	XE_VSEC_DG2,
+	XE_VSEC_BMG,
+};
+
+static struct intel_vsec_platform_info xe_vsec_info[] = {
+	[XE_VSEC_DG2] = {
+		.caps = VSEC_CAP_TELEMETRY,
+		.headers = dg2_capabilities,
+		.quirks = VSEC_QUIRK_EARLY_HW | VSEC_QUIRK_P2SB_OFFSET,
+	},
+	[XE_VSEC_BMG] = {
+		.caps = VSEC_CAP_TELEMETRY,
+		.headers = bmg_capabilities,
+	},
+	{ }
 };
 
+#define PUNIT_AGGREGATOR 0
+#define OOBMSM_AGG0      1
+
+/*
+ * The telemetry memory space shares a common offset.  To get the appropriate
+ * data, set the index based on the GUID bits.
+ *
+ * The GUID will have the following bits to decode:
+ *   (2bits) - Record-ID (0-PUNIT, 1-OOBMSM_0, 2-OOBMSM_1)
+ *   (2bits) - Capability Type (Crashlog-0, Telemetry Aggregator-1, Watcher-2)
+ *   ... <other that are not currently relevant>
+ *
+ * Currently only the record-id is set.  Once the other bits are set, the
+ * decode path will get a little more complex.
+ */
+static int xe_pmt_telem_read(void *args, u32 guid, u64 *data, u32 count)
+{
+	struct xe_device *xe = pdev_to_xe_device((struct pci_dev *)args);
+	void __iomem *telem_addr = xe->tiles[0].mmio.regs + BMG_TELEMETRY_OFFSET;
+	u32 telem_region = guid & GUID_RECORD_MASK;
+	int ret = 0;
+
+	/* Update the base offset (if necessary) for the specific telementry region */
+	switch (telem_region) {
+	case PUNIT_AGGREGATOR:
+		telem_addr += 0x200;
+		break;
+	case OOBMSM_AGG0:
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	mutex_lock(&xe->pmt.lock);
+	if (xe_pm_runtime_get_if_active(xe) > 0) {
+		/* set SoC re-mapper index register based on guid memory region */
+		xe_mmio_rmw32(xe->tiles[0].primary_gt, SG_REMAP_INDEX1, SG_REMAP_BITS,
+			      SG_REMAP_ACCESS(telem_region));
+
+		memcpy_fromio(data, telem_addr, count);
+
+		xe_pm_runtime_put(xe);
+
+		ret = count;
+	}
+	mutex_unlock(&xe->pmt.lock);
+
+	return ret;
+}
+
+struct pmt_callbacks xe_pmt_cb = {
+	.read_telem = xe_pmt_telem_read,
+};
+
+static const int vsec_platforms[] = {
+	[XE_DG2] = XE_VSEC_DG2,
+	[XE_BATTLEMAGE] = XE_VSEC_BMG,
+};
+
+static enum xe_vsec get_platform_info(struct xe_device *xe)
+{
+	if (xe->info.platform > XE_BATTLEMAGE)
+		return XE_VSEC_UNKNOWN;
+
+	return vsec_platforms[xe->info.platform];
+}
+
 /*
  * Access the DG2 PMT MMIO discovery table
  *
@@ -92,15 +203,35 @@ static int dg2_adjust_offset(struct pci_dev *pdev, struct device *dev,
  */
 void xe_vsec_init(struct xe_device *xe)
 {
-	struct intel_vsec_platform_info *info = &dg2_vsec_info;
+	struct intel_vsec_platform_info *info;
 	struct device *dev = xe->drm.dev;
 	struct pci_dev *pdev = to_pci_dev(dev);
+	enum xe_vsec platform;
 	u32 ret;
 
-	ret = dg2_adjust_offset(pdev, dev, info);
-	if (ret)
+	platform = get_platform_info(xe);
+	if (platform == XE_VSEC_UNKNOWN)
+		return;
+
+	info = &xe_vsec_info[platform];
+	if (!info->headers)
 		return;
 
+	switch (platform) {
+	case XE_VSEC_DG2:
+		ret = dg2_adjust_offset(pdev, dev, info);
+		if (ret)
+			return;
+		break;
+
+	case XE_VSEC_BMG:
+		info->priv_data = &xe_pmt_cb;
+		break;
+
+	default:
+		break;
+	}
+
 	/*
 	 * Register a VSEC. Cleanup is handled using device managed
 	 * resources.
diff --git a/drivers/platform/x86/intel/vsec.c b/drivers/platform/x86/intel/vsec.c
index 5a0dfc21eb0f..f59f8ac87b4e 100644
--- a/drivers/platform/x86/intel/vsec.c
+++ b/drivers/platform/x86/intel/vsec.c
@@ -341,7 +341,7 @@ static bool intel_vsec_walk_vsec(struct pci_dev *pdev,
 void intel_vsec_register(struct pci_dev *pdev,
 			 struct intel_vsec_platform_info *info)
 {
-	if (!pdev || !info)
+	if (!pdev || !info || !info->headers)
 		return;
 
 	intel_vsec_walk_header(pdev, info);
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* ✓ CI.Patch_applied: success for Support PMT features in Xe
  2024-05-10 20:59 [PATCH 0/6] Support PMT features in Xe Michael J. Ruhl
                   ` (5 preceding siblings ...)
  2024-05-10 20:59 ` [PATCH 6/6] drm/xe/vsec: Support BMG devices Michael J. Ruhl
@ 2024-05-10 21:48 ` Patchwork
  2024-05-10 21:48 ` ✗ CI.checkpatch: warning " Patchwork
  2024-05-10 21:49 ` ✗ CI.KUnit: failure " Patchwork
  8 siblings, 0 replies; 17+ messages in thread
From: Patchwork @ 2024-05-10 21:48 UTC (permalink / raw)
  To: Michael J. Ruhl; +Cc: intel-xe

== Series Details ==

Series: Support PMT features in Xe
URL   : https://patchwork.freedesktop.org/series/133472/
State : success

== Summary ==

=== Applying kernel patches on branch 'drm-tip' with base: ===
Base commit: 7aa7a8842f00 drm-tip: 2024y-05m-10d-21h-07m-16s UTC integration manifest
=== git am output follows ===
Applying: platform/x86/intel/vsec.h: Move to include/linux
Applying: platform/x86/intel/vsec: Add PMT read callbacks
Applying: platform/x86/intel/pmt: Add support to use provided read callbacks
Applying: platform/x86/intel/pmt: Add quirk for BAR0 offset adjustment
Applying: drm/xe/vsec: Add support for DG2
Applying: drm/xe/vsec: Support BMG devices



^ permalink raw reply	[flat|nested] 17+ messages in thread

* ✗ CI.checkpatch: warning for Support PMT features in Xe
  2024-05-10 20:59 [PATCH 0/6] Support PMT features in Xe Michael J. Ruhl
                   ` (6 preceding siblings ...)
  2024-05-10 21:48 ` ✓ CI.Patch_applied: success for Support PMT features in Xe Patchwork
@ 2024-05-10 21:48 ` Patchwork
  2024-05-10 21:49 ` ✗ CI.KUnit: failure " Patchwork
  8 siblings, 0 replies; 17+ messages in thread
From: Patchwork @ 2024-05-10 21:48 UTC (permalink / raw)
  To: Michael J. Ruhl; +Cc: intel-xe

== Series Details ==

Series: Support PMT features in Xe
URL   : https://patchwork.freedesktop.org/series/133472/
State : warning

== Summary ==

+ KERNEL=/kernel
+ git clone https://gitlab.freedesktop.org/drm/maintainer-tools mt
Cloning into 'mt'...
warning: redirecting to https://gitlab.freedesktop.org/drm/maintainer-tools.git/
+ git -C mt rev-list -n1 origin/master
57b97a66dd129aea93991dc66cd10477f7a05cf8
+ cd /kernel
+ git config --global --add safe.directory /kernel
+ git log -n1
commit 8b2ef09f05c89646778f28d81e46faaf494f9ba3
Author: Michael J. Ruhl <michael.j.ruhl@intel.com>
Date:   Fri May 10 16:59:38 2024 -0400

    drm/xe/vsec: Support BMG devices
    
    Utilize the PMT callback API to add support for the BMG
    devices.
    
    Signed-off-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
+ /mt/dim checkpatch 7aa7a8842f00c5749e1a21cd2cf6dfc0e3e3a18e drm-intel
45e66198c1c7 platform/x86/intel/vsec.h: Move to include/linux
-:170: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating?
#170: 
rename from drivers/platform/x86/intel/vsec.h

total: 0 errors, 1 warnings, 0 checks, 121 lines checked
62016f9d3e49 platform/x86/intel/vsec: Add PMT read callbacks
-:7: WARNING:COMMIT_MESSAGE: Missing commit description - Add an appropriate one

total: 0 errors, 1 warnings, 0 checks, 22 lines checked
a3a40effd45c platform/x86/intel/pmt: Add support to use provided read callbacks
-:8: WARNING:COMMIT_MESSAGE: Missing commit description - Add an appropriate one

total: 0 errors, 1 warnings, 0 checks, 114 lines checked
ec8b9e86c2e6 platform/x86/intel/pmt: Add quirk for BAR0 offset adjustment
430242e0aaf1 drm/xe/vsec: Add support for DG2
Traceback (most recent call last):
  File "scripts/spdxcheck.py", line 6, in <module>
    from ply import lex, yacc
ModuleNotFoundError: No module named 'ply'
Traceback (most recent call last):
  File "scripts/spdxcheck.py", line 6, in <module>
    from ply import lex, yacc
ModuleNotFoundError: No module named 'ply'
-:48: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating?
#48: 
new file mode 100644

total: 0 errors, 1 warnings, 0 checks, 145 lines checked
8b2ef09f05c8 drm/xe/vsec: Support BMG devices



^ permalink raw reply	[flat|nested] 17+ messages in thread

* ✗ CI.KUnit: failure for Support PMT features in Xe
  2024-05-10 20:59 [PATCH 0/6] Support PMT features in Xe Michael J. Ruhl
                   ` (7 preceding siblings ...)
  2024-05-10 21:48 ` ✗ CI.checkpatch: warning " Patchwork
@ 2024-05-10 21:49 ` Patchwork
  8 siblings, 0 replies; 17+ messages in thread
From: Patchwork @ 2024-05-10 21:49 UTC (permalink / raw)
  To: Michael J. Ruhl; +Cc: intel-xe

== Series Details ==

Series: Support PMT features in Xe
URL   : https://patchwork.freedesktop.org/series/133472/
State : failure

== Summary ==

+ trap cleanup EXIT
+ /kernel/tools/testing/kunit/kunit.py run --kunitconfig /kernel/drivers/gpu/drm/xe/.kunitconfig
ERROR:root:../arch/x86/um/user-offsets.c:17:6: warning: no previous prototype for ‘foo’ [-Wmissing-prototypes]
   17 | void foo(void)
      |      ^~~
In file included from ../arch/um/kernel/asm-offsets.c:1:
../arch/x86/um/shared/sysdep/kernel-offsets.h:9:6: warning: no previous prototype for ‘foo’ [-Wmissing-prototypes]
    9 | void foo(void)
      |      ^~~
../arch/x86/um/bugs_64.c:9:6: warning: no previous prototype for ‘arch_check_bugs’ [-Wmissing-prototypes]
    9 | void arch_check_bugs(void)
      |      ^~~~~~~~~~~~~~~
../arch/x86/um/bugs_64.c:13:6: warning: no previous prototype for ‘arch_examine_signal’ [-Wmissing-prototypes]
   13 | void arch_examine_signal(int sig, struct uml_pt_regs *regs)
      |      ^~~~~~~~~~~~~~~~~~~
../arch/x86/um/os-Linux/registers.c:146:15: warning: no previous prototype for ‘get_thread_reg’ [-Wmissing-prototypes]
  146 | unsigned long get_thread_reg(int reg, jmp_buf *buf)
      |               ^~~~~~~~~~~~~~
../arch/x86/um/fault.c:18:5: warning: no previous prototype for ‘arch_fixup’ [-Wmissing-prototypes]
   18 | int arch_fixup(unsigned long address, struct uml_pt_regs *regs)
      |     ^~~~~~~~~~
../arch/x86/um/os-Linux/mcontext.c:7:6: warning: no previous prototype for ‘get_regs_from_mc’ [-Wmissing-prototypes]
    7 | void get_regs_from_mc(struct uml_pt_regs *regs, mcontext_t *mc)
      |      ^~~~~~~~~~~~~~~~
../arch/x86/um/vdso/um_vdso.c:16:5: warning: no previous prototype for ‘__vdso_clock_gettime’ [-Wmissing-prototypes]
   16 | int __vdso_clock_gettime(clockid_t clock, struct __kernel_old_timespec *ts)
      |     ^~~~~~~~~~~~~~~~~~~~
../arch/x86/um/vdso/um_vdso.c:30:5: warning: no previous prototype for ‘__vdso_gettimeofday’ [-Wmissing-prototypes]
   30 | int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz)
      |     ^~~~~~~~~~~~~~~~~~~
../arch/x86/um/vdso/um_vdso.c:44:21: warning: no previous prototype for ‘__vdso_time’ [-Wmissing-prototypes]
   44 | __kernel_old_time_t __vdso_time(__kernel_old_time_t *t)
      |                     ^~~~~~~~~~~
../arch/x86/um/vdso/um_vdso.c:57:1: warning: no previous prototype for ‘__vdso_getcpu’ [-Wmissing-prototypes]
   57 | __vdso_getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *unused)
      | ^~~~~~~~~~~~~
../arch/um/os-Linux/skas/process.c:107:6: warning: no previous prototype for ‘wait_stub_done’ [-Wmissing-prototypes]
  107 | void wait_stub_done(int pid)
      |      ^~~~~~~~~~~~~~
../arch/um/os-Linux/skas/process.c:683:6: warning: no previous prototype for ‘__switch_mm’ [-Wmissing-prototypes]
  683 | void __switch_mm(struct mm_id *mm_idp)
      |      ^~~~~~~~~~~
../arch/um/os-Linux/main.c:187:7: warning: no previous prototype for ‘__wrap_malloc’ [-Wmissing-prototypes]
  187 | void *__wrap_malloc(int size)
      |       ^~~~~~~~~~~~~
../arch/um/os-Linux/main.c:208:7: warning: no previous prototype for ‘__wrap_calloc’ [-Wmissing-prototypes]
  208 | void *__wrap_calloc(int n, int size)
      |       ^~~~~~~~~~~~~
../arch/um/os-Linux/main.c:222:6: warning: no previous prototype for ‘__wrap_free’ [-Wmissing-prototypes]
  222 | void __wrap_free(void *ptr)
      |      ^~~~~~~~~~~
../arch/um/kernel/skas/process.c:36:12: warning: no previous prototype for ‘start_uml’ [-Wmissing-prototypes]
   36 | int __init start_uml(void)
      |            ^~~~~~~~~
../arch/um/os-Linux/mem.c:28:6: warning: no previous prototype for ‘kasan_map_memory’ [-Wmissing-prototypes]
   28 | void kasan_map_memory(void *start, size_t len)
      |      ^~~~~~~~~~~~~~~~
../arch/um/os-Linux/mem.c:212:13: warning: no previous prototype for ‘check_tmpexec’ [-Wmissing-prototypes]
  212 | void __init check_tmpexec(void)
      |             ^~~~~~~~~~~~~
../arch/x86/um/ptrace_64.c:111:5: warning: no previous prototype for ‘poke_user’ [-Wmissing-prototypes]
  111 | int poke_user(struct task_struct *child, long addr, long data)
      |     ^~~~~~~~~
../arch/x86/um/ptrace_64.c:171:5: warning: no previous prototype for ‘peek_user’ [-Wmissing-prototypes]
  171 | int peek_user(struct task_struct *child, long addr, long data)
      |     ^~~~~~~~~
../arch/um/kernel/skas/mmu.c:17:5: warning: no previous prototype for ‘init_new_context’ [-Wmissing-prototypes]
   17 | int init_new_context(struct task_struct *task, struct mm_struct *mm)
      |     ^~~~~~~~~~~~~~~~
../arch/um/kernel/skas/mmu.c:60:6: warning: no previous prototype for ‘destroy_context’ [-Wmissing-prototypes]
   60 | void destroy_context(struct mm_struct *mm)
      |      ^~~~~~~~~~~~~~~
../arch/um/os-Linux/signal.c:75:6: warning: no previous prototype for ‘sig_handler’ [-Wmissing-prototypes]
   75 | void sig_handler(int sig, struct siginfo *si, mcontext_t *mc)
      |      ^~~~~~~~~~~
../arch/um/os-Linux/signal.c:111:6: warning: no previous prototype for ‘timer_alarm_handler’ [-Wmissing-prototypes]
  111 | void timer_alarm_handler(int sig, struct siginfo *unused_si, mcontext_t *mc)
      |      ^~~~~~~~~~~~~~~~~~~
../arch/um/os-Linux/start_up.c:301:12: warning: no previous prototype for ‘parse_iomem’ [-Wmissing-prototypes]
  301 | int __init parse_iomem(char *str, int *add)
      |            ^~~~~~~~~~~
../arch/x86/um/signal.c:560:6: warning: no previous prototype for ‘sys_rt_sigreturn’ [-Wmissing-prototypes]
  560 | long sys_rt_sigreturn(void)
      |      ^~~~~~~~~~~~~~~~
../arch/um/kernel/mem.c:202:8: warning: no previous prototype for ‘pgd_alloc’ [-Wmissing-prototypes]
  202 | pgd_t *pgd_alloc(struct mm_struct *mm)
      |        ^~~~~~~~~
../arch/um/kernel/mem.c:215:7: warning: no previous prototype for ‘uml_kmalloc’ [-Wmissing-prototypes]
  215 | void *uml_kmalloc(int size, int flags)
      |       ^~~~~~~~~~~
../arch/um/kernel/process.c:51:5: warning: no previous prototype for ‘pid_to_processor_id’ [-Wmissing-prototypes]
   51 | int pid_to_processor_id(int pid)
      |     ^~~~~~~~~~~~~~~~~~~
../arch/um/kernel/process.c:87:7: warning: no previous prototype for ‘__switch_to’ [-Wmissing-prototypes]
   87 | void *__switch_to(struct task_struct *from, struct task_struct *to)
      |       ^~~~~~~~~~~
../arch/um/kernel/process.c:140:6: warning: no previous prototype for ‘fork_handler’ [-Wmissing-prototypes]
  140 | void fork_handler(void)
      |      ^~~~~~~~~~~~
../arch/um/kernel/process.c:217:6: warning: no previous prototype for ‘arch_cpu_idle’ [-Wmissing-prototypes]
  217 | void arch_cpu_idle(void)
      |      ^~~~~~~~~~~~~
../arch/um/kernel/process.c:253:5: warning: no previous prototype for ‘copy_to_user_proc’ [-Wmissing-prototypes]
  253 | int copy_to_user_proc(void __user *to, void *from, int size)
      |     ^~~~~~~~~~~~~~~~~
../arch/um/kernel/process.c:263:5: warning: no previous prototype for ‘clear_user_proc’ [-Wmissing-prototypes]
  263 | int clear_user_proc(void __user *buf, int size)
      |     ^~~~~~~~~~~~~~~
../arch/um/kernel/process.c:271:6: warning: no previous prototype for ‘set_using_sysemu’ [-Wmissing-prototypes]
  271 | void set_using_sysemu(int value)
      |      ^~~~~~~~~~~~~~~~
../arch/um/kernel/process.c:278:5: warning: no previous prototype for ‘get_using_sysemu’ [-Wmissing-prototypes]
  278 | int get_using_sysemu(void)
      |     ^~~~~~~~~~~~~~~~
../arch/um/kernel/process.c:316:12: warning: no previous prototype for ‘make_proc_sysemu’ [-Wmissing-prototypes]
  316 | int __init make_proc_sysemu(void)
      |            ^~~~~~~~~~~~~~~~
../arch/um/kernel/process.c:348:15: warning: no previous prototype for ‘arch_align_stack’ [-Wmissing-prototypes]
  348 | unsigned long arch_align_stack(unsigned long sp)
      |               ^~~~~~~~~~~~~~~~
../arch/um/kernel/reboot.c:45:6: warning: no previous prototype for ‘machine_restart’ [-Wmissing-prototypes]
   45 | void machine_restart(char * __unused)
      |      ^~~~~~~~~~~~~~~
../arch/um/kernel/reboot.c:51:6: warning: no previous prototype for ‘machine_power_off’ [-Wmissing-prototypes]
   51 | void machine_power_off(void)
      |      ^~~~~~~~~~~~~~~~~
../arch/um/kernel/reboot.c:57:6: warning: no previous prototype for ‘machine_halt’ [-Wmissing-prototypes]
   57 | void machine_halt(void)
      |      ^~~~~~~~~~~~
../arch/x86/um/syscalls_64.c:48:6: warning: no previous prototype for ‘arch_switch_to’ [-Wmissing-prototypes]
   48 | void arch_switch_to(struct task_struct *to)
      |      ^~~~~~~~~~~~~~
../arch/um/kernel/tlb.c:579:6: warning: no previous prototype for ‘flush_tlb_mm_range’ [-Wmissing-prototypes]
  579 | void flush_tlb_mm_range(struct mm_struct *mm, unsigned long start,
      |      ^~~~~~~~~~~~~~~~~~
../arch/um/kernel/tlb.c:594:6: warning: no previous prototype for ‘force_flush_all’ [-Wmissing-prototypes]
  594 | void force_flush_all(void)
      |      ^~~~~~~~~~~~~~~
../arch/um/kernel/kmsg_dump.c:60:12: warning: no previous prototype for ‘kmsg_dumper_stdout_init’ [-Wmissing-prototypes]
   60 | int __init kmsg_dumper_stdout_init(void)
      |            ^~~~~~~~~~~~~~~~~~~~~~~
../arch/um/kernel/um_arch.c:408:19: warning: no previous prototype for ‘read_initrd’ [-Wmissing-prototypes]
  408 | int __init __weak read_initrd(void)
      |                   ^~~~~~~~~~~
../arch/um/kernel/um_arch.c:461:7: warning: no previous prototype for ‘text_poke’ [-Wmissing-prototypes]
  461 | void *text_poke(void *addr, const void *opcode, size_t len)
      |       ^~~~~~~~~
../arch/um/kernel/um_arch.c:473:6: warning: no previous prototype for ‘text_poke_sync’ [-Wmissing-prototypes]
  473 | void text_poke_sync(void)
      |      ^~~~~~~~~~~~~~
../lib/iomap.c:156:5: warning: no previous prototype for ‘ioread64_lo_hi’ [-Wmissing-prototypes]
  156 | u64 ioread64_lo_hi(const void __iomem *addr)
      |     ^~~~~~~~~~~~~~
../lib/iomap.c:163:5: warning: no previous prototype for ‘ioread64_hi_lo’ [-Wmissing-prototypes]
  163 | u64 ioread64_hi_lo(const void __iomem *addr)
      |     ^~~~~~~~~~~~~~
../lib/iomap.c:170:5: warning: no previous prototype for ‘ioread64be_lo_hi’ [-Wmissing-prototypes]
  170 | u64 ioread64be_lo_hi(const void __iomem *addr)
      |     ^~~~~~~~~~~~~~~~
../lib/iomap.c:178:5: warning: no previous prototype for ‘ioread64be_hi_lo’ [-Wmissing-prototypes]
  178 | u64 ioread64be_hi_lo(const void __iomem *addr)
      |     ^~~~~~~~~~~~~~~~
../lib/iomap.c:264:6: warning: no previous prototype for ‘iowrite64_lo_hi’ [-Wmissing-prototypes]
  264 | void iowrite64_lo_hi(u64 val, void __iomem *addr)
      |      ^~~~~~~~~~~~~~~
../lib/iomap.c:272:6: warning: no previous prototype for ‘iowrite64_hi_lo’ [-Wmissing-prototypes]
  272 | void iowrite64_hi_lo(u64 val, void __iomem *addr)
      |      ^~~~~~~~~~~~~~~
../lib/iomap.c:280:6: warning: no previous prototype for ‘iowrite64be_lo_hi’ [-Wmissing-prototypes]
  280 | void iowrite64be_lo_hi(u64 val, void __iomem *addr)
      |      ^~~~~~~~~~~~~~~~~
../lib/iomap.c:288:6: warning: no previous prototype for ‘iowrite64be_hi_lo’ [-Wmissing-prototypes]
  288 | void iowrite64be_hi_lo(u64 val, void __iomem *addr)
      |      ^~~~~~~~~~~~~~~~~
/usr/bin/ld: drivers/gpu/drm/xe/xe_vsec.o: in function `xe_vsec_init':
xe_vsec.c:(.text+0x16e): undefined reference to `intel_vsec_register'
collect2: error: ld returned 1 exit status
make[3]: *** [../scripts/Makefile.vmlinux:37: vmlinux] Error 1
make[2]: *** [/kernel/Makefile:1160: vmlinux] Error 2
make[1]: *** [/kernel/Makefile:240: __sub-make] Error 2
make: *** [Makefile:240: __sub-make] Error 2

[21:48:39] Configuring KUnit Kernel ...
Generating .config ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
[21:48:45] Building KUnit Kernel ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
Building with:
$ make ARCH=um O=.kunit --jobs=48
+ cleanup
++ stat -c %u:%g /kernel
+ chown -R 1003:1003 /kernel



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 3/6] platform/x86/intel/pmt: Add support to use provided read callbacks
  2024-05-10 20:59 ` [PATCH 3/6] platform/x86/intel/pmt: Add support to use provided " Michael J. Ruhl
@ 2024-05-13 17:15   ` Rodrigo Vivi
  0 siblings, 0 replies; 17+ messages in thread
From: Rodrigo Vivi @ 2024-05-13 17:15 UTC (permalink / raw)
  To: Michael J. Ruhl; +Cc: intel-xe, david.e.box

On Fri, May 10, 2024 at 04:59:35PM -0400, Michael J. Ruhl wrote:
> From: "David E. Box" <david.e.box@linux.intel.com>
> 

This patch needs a commit message.

> Signed-off-by: David E. Box <david.e.box@linux.intel.com>

Whenever sending email on other's behalf, please always remind to sign it off.

Also, these patches should also had been sent to platform-driver-x86@vger.kernel.org
and linux-kernel@vger.kernel.org

and perhaps cc'ing other maintainers listed by
scripts/get_maintainer.pl

And later, likely trying to get their ack to get then
trough drm-xe-next where we are adding the first usage of these.

> ---
>  drivers/platform/x86/intel/pmt/class.c     | 28 +++++++++++++++++-----
>  drivers/platform/x86/intel/pmt/class.h     |  8 +++++--
>  drivers/platform/x86/intel/pmt/telemetry.c | 10 ++++----
>  3 files changed, 34 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/platform/x86/intel/pmt/class.c b/drivers/platform/x86/intel/pmt/class.c
> index d7939b28e937..62e36dd89137 100644
> --- a/drivers/platform/x86/intel/pmt/class.c
> +++ b/drivers/platform/x86/intel/pmt/class.c
> @@ -58,6 +58,24 @@ pmt_memcpy64_fromio(void *to, const u64 __iomem *from, size_t count)
>  	return count;
>  }
>  
> +void pmt_telem_read_mmio(struct pci_dev *pdev, struct pmt_callbacks *cb, u32 guid, void *buf,
> +			 void __iomem *addr, u32 count)
> +{
> +	if (cb && cb->read_telem) {
> +		count = cb->read_telem(pdev, guid, buf, count);
> +		return;
> +	}
> +
> +	if (guid == GUID_SPR_PUNIT) {
> +		/* PUNIT on SPR only supports aligned 64-bit read */
> +		count = pmt_memcpy64_fromio(buf, addr, count);
> +		return;
> +	}
> +
> +	memcpy_fromio(buf, addr, count);
> +}
> +EXPORT_SYMBOL_NS_GPL(pmt_telem_read_mmio, INTEL_PMT);
> +
>  /*
>   * sysfs
>   */
> @@ -79,11 +97,8 @@ intel_pmt_read(struct file *filp, struct kobject *kobj,
>  	if (count > entry->size - off)
>  		count = entry->size - off;
>  
> -	if (entry->guid == GUID_SPR_PUNIT)
> -		/* PUNIT on SPR only supports aligned 64-bit read */
> -		count = pmt_memcpy64_fromio(buf, entry->base + off, count);
> -	else
> -		memcpy_fromio(buf, entry->base + off, count);
> +	pmt_telem_read_mmio(entry->ep->pcidev, entry->cb, entry->header.guid, buf,
> +			    entry->base + off, count);
>  
>  	return count;
>  }
> @@ -239,6 +254,7 @@ static int intel_pmt_populate_entry(struct intel_pmt_entry *entry,
>  
>  	entry->guid = header->guid;
>  	entry->size = header->size;
> +	entry->cb = ivdev->priv_data;
>  
>  	return 0;
>  }
> @@ -300,7 +316,7 @@ static int intel_pmt_dev_register(struct intel_pmt_entry *entry,
>  		goto fail_ioremap;
>  
>  	if (ns->pmt_add_endpoint) {
> -		ret = ns->pmt_add_endpoint(entry, ivdev->pcidev);
> +		ret = ns->pmt_add_endpoint(ivdev, entry);
>  		if (ret)
>  			goto fail_add_endpoint;
>  	}
> diff --git a/drivers/platform/x86/intel/pmt/class.h b/drivers/platform/x86/intel/pmt/class.h
> index d6f9ccaf28c8..5032c5244eb4 100644
> --- a/drivers/platform/x86/intel/pmt/class.h
> +++ b/drivers/platform/x86/intel/pmt/class.h
> @@ -24,6 +24,7 @@ struct pci_dev;
>  struct telem_endpoint {
>  	struct pci_dev		*pcidev;
>  	struct telem_header	header;
> +	struct pmt_callbacks	*cb;
>  	void __iomem		*base;
>  	bool			present;
>  	struct kref		kref;
> @@ -43,6 +44,7 @@ struct intel_pmt_entry {
>  	struct kobject		*kobj;
>  	void __iomem		*disc_table;
>  	void __iomem		*base;
> +	struct pmt_callbacks	*cb;
>  	unsigned long		base_addr;
>  	size_t			size;
>  	u32			guid;
> @@ -55,10 +57,12 @@ struct intel_pmt_namespace {
>  	const struct attribute_group *attr_grp;
>  	int (*pmt_header_decode)(struct intel_pmt_entry *entry,
>  				 struct device *dev);
> -	int (*pmt_add_endpoint)(struct intel_pmt_entry *entry,
> -				struct pci_dev *pdev);
> +	int (*pmt_add_endpoint)(struct intel_vsec_device *ivdev,
> +				struct intel_pmt_entry *entry);
>  };
>  
> +void pmt_telem_read_mmio(struct pci_dev *pdev, struct pmt_callbacks *cb, u32 guid, void *buf,
> +			 void __iomem *addr, u32 count);
>  bool intel_pmt_is_early_client_hw(struct device *dev);
>  int intel_pmt_dev_create(struct intel_pmt_entry *entry,
>  			 struct intel_pmt_namespace *ns,
> diff --git a/drivers/platform/x86/intel/pmt/telemetry.c b/drivers/platform/x86/intel/pmt/telemetry.c
> index 3478f891ea0b..c9feac859e57 100644
> --- a/drivers/platform/x86/intel/pmt/telemetry.c
> +++ b/drivers/platform/x86/intel/pmt/telemetry.c
> @@ -93,8 +93,8 @@ static int pmt_telem_header_decode(struct intel_pmt_entry *entry,
>  	return 0;
>  }
>  
> -static int pmt_telem_add_endpoint(struct intel_pmt_entry *entry,
> -				  struct pci_dev *pdev)
> +static int pmt_telem_add_endpoint(struct intel_vsec_device *ivdev,
> +				  struct intel_pmt_entry *entry)
>  {
>  	struct telem_endpoint *ep;
>  
> @@ -104,13 +104,14 @@ static int pmt_telem_add_endpoint(struct intel_pmt_entry *entry,
>  		return -ENOMEM;
>  
>  	ep = entry->ep;
> -	ep->pcidev = pdev;
> +	ep->pcidev = ivdev->pcidev;
>  	ep->header.access_type = entry->header.access_type;
>  	ep->header.guid = entry->header.guid;
>  	ep->header.base_offset = entry->header.base_offset;
>  	ep->header.size = entry->header.size;
>  	ep->base = entry->base;
>  	ep->present = true;
> +	ep->cb = ivdev->priv_data;
>  
>  	kref_init(&ep->kref);
>  
> @@ -218,7 +219,8 @@ int pmt_telem_read(struct telem_endpoint *ep, u32 id, u64 *data, u32 count)
>  	if (offset + NUM_BYTES_QWORD(count) > size)
>  		return -EINVAL;
>  
> -	memcpy_fromio(data, ep->base + offset, NUM_BYTES_QWORD(count));
> +	pmt_telem_read_mmio(ep->pcidev, ep->cb, ep->header.guid, data, ep->base + offset,
> +			    NUM_BYTES_QWORD(count));
>  
>  	return ep->present ? 0 : -EPIPE;
>  }
> -- 
> 2.44.0
> 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: [PATCH 1/6] platform/x86/intel/vsec.h: Move to include/linux
  2024-05-10 20:59 ` [PATCH 1/6] platform/x86/intel/vsec.h: Move to include/linux Michael J. Ruhl
@ 2024-05-28 15:43   ` Ruhl, Michael J
  2024-05-30 21:07     ` David E. Box
  0 siblings, 1 reply; 17+ messages in thread
From: Ruhl, Michael J @ 2024-05-28 15:43 UTC (permalink / raw)
  To: Ruhl, Michael J, intel-xe@lists.freedesktop.org
  Cc: david.e.box@linux.intel.com

Hi David,

Do you have any comments on the first 3 patches?

What are the next steps to move them forward?

Thanks,

Mike


>-----Original Message-----
>From: Intel-xe <intel-xe-bounces@lists.freedesktop.org> On Behalf Of Michael
>J. Ruhl
>Sent: Friday, May 10, 2024 5:00 PM
>To: intel-xe@lists.freedesktop.org
>Cc: david.e.box@linux.intel.com
>Subject: [PATCH 1/6] platform/x86/intel/vsec.h: Move to include/linux
>
>From: "David E. Box" <david.e.box@linux.intel.com>
>
>Some drivers outside of PDX86 need access to the vsec header. Move it to
>include/linux to make it easier to include.
>
>Signed-off-by: David E. Box <david.e.box@linux.intel.com>
>---
> drivers/platform/x86/intel/pmc/core_ssram.c                  | 2 +-
> drivers/platform/x86/intel/pmt/class.c                       | 2 +-
> drivers/platform/x86/intel/pmt/class.h                       | 2 +-
> drivers/platform/x86/intel/pmt/crashlog.c                    | 2 +-
> drivers/platform/x86/intel/pmt/telemetry.c                   | 2 +-
> drivers/platform/x86/intel/sdsi.c                            | 3 +--
> drivers/platform/x86/intel/tpmi.c                            | 3 +--
> drivers/platform/x86/intel/vsec.c                            | 5 ++---
> .../platform/x86/intel/vsec.h => include/linux/intel_vsec.h  | 4 ++--
> 9 files changed, 11 insertions(+), 14 deletions(-)
> rename drivers/platform/x86/intel/vsec.h => include/linux/intel_vsec.h (98%)
>
>diff --git a/drivers/platform/x86/intel/pmc/core_ssram.c
>b/drivers/platform/x86/intel/pmc/core_ssram.c
>index 1bde86c54eb9..baddaaec25ee 100644
>--- a/drivers/platform/x86/intel/pmc/core_ssram.c
>+++ b/drivers/platform/x86/intel/pmc/core_ssram.c
>@@ -9,11 +9,11 @@
>  */
>
> #include <linux/cleanup.h>
>+#include <linux/intel_vsec.h>
> #include <linux/pci.h>
> #include <linux/io-64-nonatomic-lo-hi.h>
>
> #include "core.h"
>-#include "../vsec.h"
> #include "../pmt/telemetry.h"
>
> #define SSRAM_HDR_SIZE		0x100
>diff --git a/drivers/platform/x86/intel/pmt/class.c
>b/drivers/platform/x86/intel/pmt/class.c
>index 4b53940a64e2..d7939b28e937 100644
>--- a/drivers/platform/x86/intel/pmt/class.c
>+++ b/drivers/platform/x86/intel/pmt/class.c
>@@ -9,12 +9,12 @@
>  */
>
> #include <linux/kernel.h>
>+#include <linux/intel_vsec.h>
> #include <linux/io-64-nonatomic-lo-hi.h>
> #include <linux/module.h>
> #include <linux/mm.h>
> #include <linux/pci.h>
>
>-#include "../vsec.h"
> #include "class.h"
>
> #define PMT_XA_START		1
>diff --git a/drivers/platform/x86/intel/pmt/class.h
>b/drivers/platform/x86/intel/pmt/class.h
>index d23c63b73ab7..d6f9ccaf28c8 100644
>--- a/drivers/platform/x86/intel/pmt/class.h
>+++ b/drivers/platform/x86/intel/pmt/class.h
>@@ -2,13 +2,13 @@
> #ifndef _INTEL_PMT_CLASS_H
> #define _INTEL_PMT_CLASS_H
>
>+#include <linux/intel_vsec.h>
> #include <linux/xarray.h>
> #include <linux/types.h>
> #include <linux/bits.h>
> #include <linux/err.h>
> #include <linux/io.h>
>
>-#include "../vsec.h"
> #include "telemetry.h"
>
> /* PMT access types */
>diff --git a/drivers/platform/x86/intel/pmt/crashlog.c
>b/drivers/platform/x86/intel/pmt/crashlog.c
>index 4014c02cafdb..9079d5dffc03 100644
>--- a/drivers/platform/x86/intel/pmt/crashlog.c
>+++ b/drivers/platform/x86/intel/pmt/crashlog.c
>@@ -9,6 +9,7 @@
>  */
>
> #include <linux/auxiliary_bus.h>
>+#include <linux/intel_vsec.h>
> #include <linux/kernel.h>
> #include <linux/module.h>
> #include <linux/pci.h>
>@@ -16,7 +17,6 @@
> #include <linux/uaccess.h>
> #include <linux/overflow.h>
>
>-#include "../vsec.h"
> #include "class.h"
>
> /* Crashlog discovery header types */
>diff --git a/drivers/platform/x86/intel/pmt/telemetry.c
>b/drivers/platform/x86/intel/pmt/telemetry.c
>index 09258564dfc4..3478f891ea0b 100644
>--- a/drivers/platform/x86/intel/pmt/telemetry.c
>+++ b/drivers/platform/x86/intel/pmt/telemetry.c
>@@ -9,6 +9,7 @@
>  */
>
> #include <linux/auxiliary_bus.h>
>+#include <linux/intel_vsec.h>
> #include <linux/kernel.h>
> #include <linux/module.h>
> #include <linux/pci.h>
>@@ -16,7 +17,6 @@
> #include <linux/uaccess.h>
> #include <linux/overflow.h>
>
>-#include "../vsec.h"
> #include "class.h"
>
> #define TELEM_SIZE_OFFSET	0x0
>diff --git a/drivers/platform/x86/intel/sdsi.c
>b/drivers/platform/x86/intel/sdsi.c
>index 556e7c6dbb05..322ada188ee9 100644
>--- a/drivers/platform/x86/intel/sdsi.c
>+++ b/drivers/platform/x86/intel/sdsi.c
>@@ -12,6 +12,7 @@
> #include <linux/bits.h>
> #include <linux/bitfield.h>
> #include <linux/device.h>
>+#include <linux/intel_vsec.h>
> #include <linux/iopoll.h>
> #include <linux/kernel.h>
> #include <linux/module.h>
>@@ -21,8 +22,6 @@
> #include <linux/types.h>
> #include <linux/uaccess.h>
>
>-#include "vsec.h"
>-
> #define ACCESS_TYPE_BARID		2
> #define ACCESS_TYPE_LOCAL		3
>
>diff --git a/drivers/platform/x86/intel/tpmi.c
>b/drivers/platform/x86/intel/tpmi.c
>index 910df7c654f4..be7ea557b72d 100644
>--- a/drivers/platform/x86/intel/tpmi.c
>+++ b/drivers/platform/x86/intel/tpmi.c
>@@ -51,6 +51,7 @@
> #include <linux/debugfs.h>
> #include <linux/delay.h>
> #include <linux/intel_tpmi.h>
>+#include <linux/intel_vsec.h>
> #include <linux/io.h>
> #include <linux/iopoll.h>
> #include <linux/module.h>
>@@ -59,8 +60,6 @@
> #include <linux/sizes.h>
> #include <linux/string_helpers.h>
>
>-#include "vsec.h"
>-
> /**
>  * struct intel_tpmi_pfs_entry - TPMI PM Feature Structure (PFS) entry
>  * @tpmi_id:	TPMI feature identifier (what the feature is and its data
>format).
>diff --git a/drivers/platform/x86/intel/vsec.c
>b/drivers/platform/x86/intel/vsec.c
>index 0fdfaf3a4f5c..5a1e964783cc 100644
>--- a/drivers/platform/x86/intel/vsec.c
>+++ b/drivers/platform/x86/intel/vsec.c
>@@ -17,14 +17,13 @@
> #include <linux/bits.h>
> #include <linux/cleanup.h>
> #include <linux/delay.h>
>-#include <linux/kernel.h>
> #include <linux/idr.h>
>+#include <linux/intel_vsec.h>
>+#include <linux/kernel.h>
> #include <linux/module.h>
> #include <linux/pci.h>
> #include <linux/types.h>
>
>-#include "vsec.h"
>-
> #define PMT_XA_START			0
> #define PMT_XA_MAX			INT_MAX
> #define PMT_XA_LIMIT			XA_LIMIT(PMT_XA_START,
>PMT_XA_MAX)
>diff --git a/drivers/platform/x86/intel/vsec.h b/include/linux/intel_vsec.h
>similarity index 98%
>rename from drivers/platform/x86/intel/vsec.h
>rename to include/linux/intel_vsec.h
>index e23e76129691..7f19a3d90abe 100644
>--- a/drivers/platform/x86/intel/vsec.h
>+++ b/include/linux/intel_vsec.h
>@@ -1,6 +1,6 @@
> /* SPDX-License-Identifier: GPL-2.0 */
>-#ifndef _VSEC_H
>-#define _VSEC_H
>+#ifndef _INTEL_VSEC_H
>+#define _INTEL_VSEC_H
>
> #include <linux/auxiliary_bus.h>
> #include <linux/bits.h>
>--
>2.44.0


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 4/6] platform/x86/intel/pmt: Add quirk for BAR0 offset adjustment
  2024-05-10 20:59 ` [PATCH 4/6] platform/x86/intel/pmt: Add quirk for BAR0 offset adjustment Michael J. Ruhl
@ 2024-05-30 20:59   ` David E. Box
  2024-05-31 15:40     ` Ruhl, Michael J
  0 siblings, 1 reply; 17+ messages in thread
From: David E. Box @ 2024-05-30 20:59 UTC (permalink / raw)
  To: Michael J. Ruhl, intel-xe

On Fri, 2024-05-10 at 16:59 -0400, Michael J. Ruhl wrote:
> The offset for the discovery table is based on the P2SB bar.
> If this bar is not available, the parent driver may need to
> adjust the offset,
> 
> Add a quirk to allow for this adjustment.

I'm not a fan of using base_addr in this was to adjust the offset. There was a
version that provided a separate base_adjust field to adjust the offset. Is this
change only needed for DG2?

David

> 
> Signed-off-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
> ---
>  drivers/platform/x86/intel/pmt/class.c     | 3 +++
>  drivers/platform/x86/intel/pmt/telemetry.c | 2 +-
>  drivers/platform/x86/intel/vsec.c          | 2 +-
>  include/linux/intel_vsec.h                 | 3 +++
>  4 files changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/platform/x86/intel/pmt/class.c
> b/drivers/platform/x86/intel/pmt/class.c
> index 62e36dd89137..957cf74234da 100644
> --- a/drivers/platform/x86/intel/pmt/class.c
> +++ b/drivers/platform/x86/intel/pmt/class.c
> @@ -349,6 +349,9 @@ int intel_pmt_dev_create(struct intel_pmt_entry *entry,
> struct intel_pmt_namespa
>  	if (IS_ERR(entry->disc_table))
>  		return PTR_ERR(entry->disc_table);
>  
> +	if (intel_vsec_dev->quirks & VSEC_QUIRK_P2SB_OFFSET)
> +		entry->base_addr = intel_vsec_dev->base_addr;
> +
>  	ret = ns->pmt_header_decode(entry, dev);
>  	if (ret)
>  		return ret;
> diff --git a/drivers/platform/x86/intel/pmt/telemetry.c
> b/drivers/platform/x86/intel/pmt/telemetry.c
> index c9feac859e57..7be9f9746363 100644
> --- a/drivers/platform/x86/intel/pmt/telemetry.c
> +++ b/drivers/platform/x86/intel/pmt/telemetry.c
> @@ -77,7 +77,7 @@ static int pmt_telem_header_decode(struct intel_pmt_entry
> *entry,
>  
>  	header->access_type = TELEM_ACCESS(readl(disc_table));
>  	header->guid = readl(disc_table + TELEM_GUID_OFFSET);
> -	header->base_offset = readl(disc_table + TELEM_BASE_OFFSET);
> +	header->base_offset = readl(disc_table + TELEM_BASE_OFFSET) + entry-
> >base_addr;
>  
>  	/* Size is measured in DWORDS, but accessor returns bytes */
>  	header->size = TELEM_SIZE(readl(disc_table));
> diff --git a/drivers/platform/x86/intel/vsec.c
> b/drivers/platform/x86/intel/vsec.c
> index 5378da9354b6..5a0dfc21eb0f 100644
> --- a/drivers/platform/x86/intel/vsec.c
> +++ b/drivers/platform/x86/intel/vsec.c
> @@ -185,7 +185,7 @@ static int intel_vsec_add_dev(struct pci_dev *pdev, struct
> intel_vsec_header *he
>  	if (quirks & VSEC_QUIRK_TABLE_SHIFT)
>  		header->offset >>= TABLE_OFFSET_SHIFT;
>  
> -	if (info->base_addr)
> +	if (!(quirks & VSEC_QUIRK_P2SB_OFFSET) && info->base_addr)
>  		base_addr = info->base_addr;
>  	else
>  		base_addr = pdev->resource[header->tbir].start;
> diff --git a/include/linux/intel_vsec.h b/include/linux/intel_vsec.h
> index 04f915a1ba0b..68e3a42040e8 100644
> --- a/include/linux/intel_vsec.h
> +++ b/include/linux/intel_vsec.h
> @@ -65,6 +65,9 @@ enum intel_vsec_quirks {
>  
>  	/* Platforms requiring quirk in the auxiliary driver */
>  	VSEC_QUIRK_EARLY_HW     = BIT(4),
> +
> +	/* Broken P2SB access work around */
> +	VSEC_QUIRK_P2SB_OFFSET  = BIT(5),
>  };
>  
>  struct pmt_callbacks {


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 6/6] drm/xe/vsec: Support BMG devices
  2024-05-10 20:59 ` [PATCH 6/6] drm/xe/vsec: Support BMG devices Michael J. Ruhl
@ 2024-05-30 21:06   ` David E. Box
  2024-05-31 15:42     ` Ruhl, Michael J
  0 siblings, 1 reply; 17+ messages in thread
From: David E. Box @ 2024-05-30 21:06 UTC (permalink / raw)
  To: Michael J. Ruhl, intel-xe

On Fri, 2024-05-10 at 16:59 -0400, Michael J. Ruhl wrote:
> Utilize the PMT callback API to add support for the BMG
> devices.
> 
> Signed-off-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
> ---
>  drivers/gpu/drm/xe/xe_device.c       |   2 +
>  drivers/gpu/drm/xe/xe_device_types.h |   5 +
>  drivers/gpu/drm/xe/xe_vsec.c         | 145 +++++++++++++++++++++++++--
>  drivers/platform/x86/intel/vsec.c    |   2 +-
>  4 files changed, 146 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
> index e77768bc4471..940f4cf0274a 100644
> --- a/drivers/gpu/drm/xe/xe_device.c
> +++ b/drivers/gpu/drm/xe/xe_device.c
> @@ -315,6 +315,8 @@ struct xe_device *xe_device_create(struct pci_dev *pdev,
>  		goto err;
>  	}
>  
> +	drmm_mutex_init(&xe->drm, &xe->pmt.lock);
> +
>  	err = xe_display_create(xe);
>  	if (WARN_ON(err))
>  		goto err;
> diff --git a/drivers/gpu/drm/xe/xe_device_types.h
> b/drivers/gpu/drm/xe/xe_device_types.h
> index 0af739981ebf..f451216c2283 100644
> --- a/drivers/gpu/drm/xe/xe_device_types.h
> +++ b/drivers/gpu/drm/xe/xe_device_types.h
> @@ -448,6 +448,11 @@ struct xe_device {
>  		struct mutex lock;
>  	} d3cold;
>  
> +	struct {
> +		/** @pmt.lock: protect access for telemetry data */
> +		struct mutex lock;
> +	} pmt;
> +
>  	/**
>  	 * @pm_callback_task: Track the active task that is running in either
>  	 * the runtime_suspend or runtime_resume callbacks.
> diff --git a/drivers/gpu/drm/xe/xe_vsec.c b/drivers/gpu/drm/xe/xe_vsec.c
> index a91aec49d04a..ac840a1e20a4 100644
> --- a/drivers/gpu/drm/xe/xe_vsec.c
> +++ b/drivers/gpu/drm/xe/xe_vsec.c
> @@ -5,9 +5,12 @@
>  #include <linux/intel_vsec.h>
>  #include <linux/pci.h>
>  
> +#include "xe_device.h"
>  #include "xe_device_types.h"
>  #include "xe_drv.h"
> +#include "xe_mmio.h"
>  #include "xe_platform_types.h"
> +#include "xe_pm.h"
>  #include "xe_vsec.h"
>  
>  #define SOC_BASE		0x280000
> @@ -15,6 +18,10 @@
>  /* from drivers/platform/x86/intel/pmt/telemetry.c */
>  #define TELEM_BASE_OFFSET	0x8
>  
> +/* Decode the guid information */
> +#define GUID_RECORD_MASK GENMASK(1, 0)
> +#define GUID_CAP_TYPE    GENMASK(3, 2)
> +
>  #define DG2_PMT_BASE		0xE8000
>  #define DG2_DISCOVERY_START	0x6000
>  #define DG2_TELEM_START		0x4000
> @@ -22,8 +29,18 @@
>  #define DG2_DISCOVERY_OFFSET	(SOC_BASE + DG2_PMT_BASE +
> DG2_DISCOVERY_START)
>  #define DG2_TELEM_OFFSET	(SOC_BASE + DG2_PMT_BASE + DG2_TELEM_START)
>  
> +#define BMG_PMT_BASE		0xDB000
> +#define BMG_DISCOVERY_OFFSET	(SOC_BASE + BMG_PMT_BASE)
> +
> +#define BMG_TELEMETRY_BASE	0xE0000
> +#define BMG_TELEMETRY_OFFSET	(SOC_BASE + BMG_TELEMETRY_BASE)
> +
>  #define GFX_BAR			0
>  
> +#define SG_REMAP_INDEX1		XE_REG(SOC_BASE + 0x08)
> +#define SG_REMAP_ACCESS(_mem)	((_mem) << 24)
> +#define SG_REMAP_BITS		GENMASK(31, 24)
> +
>  static struct intel_vsec_header dg2_telemetry = {
>  	.length = 0x10,
>  	.id = VSEC_ID_TELEMETRY,
> @@ -38,12 +55,106 @@ static struct intel_vsec_header *dg2_capabilities[] = {
>  	NULL
>  };
>  
> -static struct intel_vsec_platform_info dg2_vsec_info = {
> -	.caps = VSEC_CAP_TELEMETRY,
> -	.headers = dg2_capabilities,
> -	.quirks = VSEC_QUIRK_EARLY_HW | VSEC_QUIRK_P2SB_OFFSET,
> +static struct intel_vsec_header bmg_telemetry = {
> +	.length = 0x10,
> +	.id = VSEC_ID_TELEMETRY,
> +	.num_entries = 2,
> +	.entry_size = 4,
> +	.tbir = GFX_BAR,
> +	.offset = BMG_DISCOVERY_OFFSET,
> +};
> +
> +static struct intel_vsec_header *bmg_capabilities[] = {
> +	&bmg_telemetry,
> +	NULL
> +};
> +
> +enum xe_vsec {
> +	XE_VSEC_UNKNOWN = 0,
> +	XE_VSEC_DG2,
> +	XE_VSEC_BMG,
> +};
> +
> +static struct intel_vsec_platform_info xe_vsec_info[] = {
> +	[XE_VSEC_DG2] = {
> +		.caps = VSEC_CAP_TELEMETRY,
> +		.headers = dg2_capabilities,
> +		.quirks = VSEC_QUIRK_EARLY_HW | VSEC_QUIRK_P2SB_OFFSET,
> +	},
> +	[XE_VSEC_BMG] = {
> +		.caps = VSEC_CAP_TELEMETRY,
> +		.headers = bmg_capabilities,
> +	},
> +	{ }

There is some cleanup here as well to support handling multiple platforms. Can
these structures just be added to the initial DG2 patch?

David

>  };
>  
> +#define PUNIT_AGGREGATOR 0
> +#define OOBMSM_AGG0      1
> +
> +/*
> + * The telemetry memory space shares a common offset.  To get the appropriate
> + * data, set the index based on the GUID bits.
> + *
> + * The GUID will have the following bits to decode:
> + *   (2bits) - Record-ID (0-PUNIT, 1-OOBMSM_0, 2-OOBMSM_1)
> + *   (2bits) - Capability Type (Crashlog-0, Telemetry Aggregator-1, Watcher-
> 2)
> + *   ... <other that are not currently relevant>
> + *
> + * Currently only the record-id is set.  Once the other bits are set, the
> + * decode path will get a little more complex.
> + */
> +static int xe_pmt_telem_read(void *args, u32 guid, u64 *data, u32 count)
> +{
> +	struct xe_device *xe = pdev_to_xe_device((struct pci_dev *)args);
> +	void __iomem *telem_addr = xe->tiles[0].mmio.regs +
> BMG_TELEMETRY_OFFSET;
> +	u32 telem_region = guid & GUID_RECORD_MASK;
> +	int ret = 0;
> +
> +	/* Update the base offset (if necessary) for the specific telementry
> region */
> +	switch (telem_region) {
> +	case PUNIT_AGGREGATOR:
> +		telem_addr += 0x200;
> +		break;
> +	case OOBMSM_AGG0:
> +		break;
> +	default:
> +		return -EINVAL;
> +	}
> +
> +	mutex_lock(&xe->pmt.lock);
> +	if (xe_pm_runtime_get_if_active(xe) > 0) {
> +		/* set SoC re-mapper index register based on guid memory
> region */
> +		xe_mmio_rmw32(xe->tiles[0].primary_gt, SG_REMAP_INDEX1,
> SG_REMAP_BITS,
> +			      SG_REMAP_ACCESS(telem_region));
> +
> +		memcpy_fromio(data, telem_addr, count);
> +
> +		xe_pm_runtime_put(xe);
> +
> +		ret = count;
> +	}
> +	mutex_unlock(&xe->pmt.lock);
> +
> +	return ret;
> +}
> +
> +struct pmt_callbacks xe_pmt_cb = {
> +	.read_telem = xe_pmt_telem_read,
> +};
> +
> +static const int vsec_platforms[] = {
> +	[XE_DG2] = XE_VSEC_DG2,
> +	[XE_BATTLEMAGE] = XE_VSEC_BMG,
> +};
> +
> +static enum xe_vsec get_platform_info(struct xe_device *xe)
> +{
> +	if (xe->info.platform > XE_BATTLEMAGE)
> +		return XE_VSEC_UNKNOWN;
> +
> +	return vsec_platforms[xe->info.platform];
> +}
> +
>  /*
>   * Access the DG2 PMT MMIO discovery table
>   *
> @@ -92,15 +203,35 @@ static int dg2_adjust_offset(struct pci_dev *pdev, struct
> device *dev,
>   */
>  void xe_vsec_init(struct xe_device *xe)
>  {
> -	struct intel_vsec_platform_info *info = &dg2_vsec_info;
> +	struct intel_vsec_platform_info *info;
>  	struct device *dev = xe->drm.dev;
>  	struct pci_dev *pdev = to_pci_dev(dev);
> +	enum xe_vsec platform;
>  	u32 ret;
>  
> -	ret = dg2_adjust_offset(pdev, dev, info);
> -	if (ret)
> +	platform = get_platform_info(xe);
> +	if (platform == XE_VSEC_UNKNOWN)
> +		return;
> +
> +	info = &xe_vsec_info[platform];
> +	if (!info->headers)
>  		return;
>  
> +	switch (platform) {
> +	case XE_VSEC_DG2:
> +		ret = dg2_adjust_offset(pdev, dev, info);
> +		if (ret)
> +			return;
> +		break;
> +
> +	case XE_VSEC_BMG:
> +		info->priv_data = &xe_pmt_cb;
> +		break;
> +
> +	default:
> +		break;
> +	}
> +
>  	/*
>  	 * Register a VSEC. Cleanup is handled using device managed
>  	 * resources.
> diff --git a/drivers/platform/x86/intel/vsec.c
> b/drivers/platform/x86/intel/vsec.c
> index 5a0dfc21eb0f..f59f8ac87b4e 100644
> --- a/drivers/platform/x86/intel/vsec.c
> +++ b/drivers/platform/x86/intel/vsec.c
> @@ -341,7 +341,7 @@ static bool intel_vsec_walk_vsec(struct pci_dev *pdev,
>  void intel_vsec_register(struct pci_dev *pdev,
>  			 struct intel_vsec_platform_info *info)
>  {
> -	if (!pdev || !info)
> +	if (!pdev || !info || !info->headers)
>  		return;
>  
>  	intel_vsec_walk_header(pdev, info);


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/6] platform/x86/intel/vsec.h: Move to include/linux
  2024-05-28 15:43   ` Ruhl, Michael J
@ 2024-05-30 21:07     ` David E. Box
  0 siblings, 0 replies; 17+ messages in thread
From: David E. Box @ 2024-05-30 21:07 UTC (permalink / raw)
  To: Ruhl, Michael J, intel-xe@lists.freedesktop.org

On Tue, 2024-05-28 at 15:43 +0000, Ruhl, Michael J wrote:
> Hi David,
> 
> Do you have any comments on the first 3 patches?
> 
> What are the next steps to move them forward?

I have sent you an update of my patches. You can replace in this series in your
V2.

> 
> Thanks,
> 
> Mike
> 
> 
> > -----Original Message-----
> > From: Intel-xe <intel-xe-bounces@lists.freedesktop.org> On Behalf Of Michael
> > J. Ruhl
> > Sent: Friday, May 10, 2024 5:00 PM
> > To: intel-xe@lists.freedesktop.org
> > Cc: david.e.box@linux.intel.com
> > Subject: [PATCH 1/6] platform/x86/intel/vsec.h: Move to include/linux
> > 
> > From: "David E. Box" <david.e.box@linux.intel.com>
> > 
> > Some drivers outside of PDX86 need access to the vsec header. Move it to
> > include/linux to make it easier to include.
> > 
> > Signed-off-by: David E. Box <david.e.box@linux.intel.com>
> > ---
> > drivers/platform/x86/intel/pmc/core_ssram.c                  | 2 +-
> > drivers/platform/x86/intel/pmt/class.c                       | 2 +-
> > drivers/platform/x86/intel/pmt/class.h                       | 2 +-
> > drivers/platform/x86/intel/pmt/crashlog.c                    | 2 +-
> > drivers/platform/x86/intel/pmt/telemetry.c                   | 2 +-
> > drivers/platform/x86/intel/sdsi.c                            | 3 +--
> > drivers/platform/x86/intel/tpmi.c                            | 3 +--
> > drivers/platform/x86/intel/vsec.c                            | 5 ++---
> > .../platform/x86/intel/vsec.h => include/linux/intel_vsec.h  | 4 ++--
> > 9 files changed, 11 insertions(+), 14 deletions(-)
> > rename drivers/platform/x86/intel/vsec.h => include/linux/intel_vsec.h (98%)
> > 
> > diff --git a/drivers/platform/x86/intel/pmc/core_ssram.c
> > b/drivers/platform/x86/intel/pmc/core_ssram.c
> > index 1bde86c54eb9..baddaaec25ee 100644
> > --- a/drivers/platform/x86/intel/pmc/core_ssram.c
> > +++ b/drivers/platform/x86/intel/pmc/core_ssram.c
> > @@ -9,11 +9,11 @@
> >  */
> > 
> > #include <linux/cleanup.h>
> > +#include <linux/intel_vsec.h>
> > #include <linux/pci.h>
> > #include <linux/io-64-nonatomic-lo-hi.h>
> > 
> > #include "core.h"
> > -#include "../vsec.h"
> > #include "../pmt/telemetry.h"
> > 
> > #define SSRAM_HDR_SIZE		0x100
> > diff --git a/drivers/platform/x86/intel/pmt/class.c
> > b/drivers/platform/x86/intel/pmt/class.c
> > index 4b53940a64e2..d7939b28e937 100644
> > --- a/drivers/platform/x86/intel/pmt/class.c
> > +++ b/drivers/platform/x86/intel/pmt/class.c
> > @@ -9,12 +9,12 @@
> >  */
> > 
> > #include <linux/kernel.h>
> > +#include <linux/intel_vsec.h>
> > #include <linux/io-64-nonatomic-lo-hi.h>
> > #include <linux/module.h>
> > #include <linux/mm.h>
> > #include <linux/pci.h>
> > 
> > -#include "../vsec.h"
> > #include "class.h"
> > 
> > #define PMT_XA_START		1
> > diff --git a/drivers/platform/x86/intel/pmt/class.h
> > b/drivers/platform/x86/intel/pmt/class.h
> > index d23c63b73ab7..d6f9ccaf28c8 100644
> > --- a/drivers/platform/x86/intel/pmt/class.h
> > +++ b/drivers/platform/x86/intel/pmt/class.h
> > @@ -2,13 +2,13 @@
> > #ifndef _INTEL_PMT_CLASS_H
> > #define _INTEL_PMT_CLASS_H
> > 
> > +#include <linux/intel_vsec.h>
> > #include <linux/xarray.h>
> > #include <linux/types.h>
> > #include <linux/bits.h>
> > #include <linux/err.h>
> > #include <linux/io.h>
> > 
> > -#include "../vsec.h"
> > #include "telemetry.h"
> > 
> > /* PMT access types */
> > diff --git a/drivers/platform/x86/intel/pmt/crashlog.c
> > b/drivers/platform/x86/intel/pmt/crashlog.c
> > index 4014c02cafdb..9079d5dffc03 100644
> > --- a/drivers/platform/x86/intel/pmt/crashlog.c
> > +++ b/drivers/platform/x86/intel/pmt/crashlog.c
> > @@ -9,6 +9,7 @@
> >  */
> > 
> > #include <linux/auxiliary_bus.h>
> > +#include <linux/intel_vsec.h>
> > #include <linux/kernel.h>
> > #include <linux/module.h>
> > #include <linux/pci.h>
> > @@ -16,7 +17,6 @@
> > #include <linux/uaccess.h>
> > #include <linux/overflow.h>
> > 
> > -#include "../vsec.h"
> > #include "class.h"
> > 
> > /* Crashlog discovery header types */
> > diff --git a/drivers/platform/x86/intel/pmt/telemetry.c
> > b/drivers/platform/x86/intel/pmt/telemetry.c
> > index 09258564dfc4..3478f891ea0b 100644
> > --- a/drivers/platform/x86/intel/pmt/telemetry.c
> > +++ b/drivers/platform/x86/intel/pmt/telemetry.c
> > @@ -9,6 +9,7 @@
> >  */
> > 
> > #include <linux/auxiliary_bus.h>
> > +#include <linux/intel_vsec.h>
> > #include <linux/kernel.h>
> > #include <linux/module.h>
> > #include <linux/pci.h>
> > @@ -16,7 +17,6 @@
> > #include <linux/uaccess.h>
> > #include <linux/overflow.h>
> > 
> > -#include "../vsec.h"
> > #include "class.h"
> > 
> > #define TELEM_SIZE_OFFSET	0x0
> > diff --git a/drivers/platform/x86/intel/sdsi.c
> > b/drivers/platform/x86/intel/sdsi.c
> > index 556e7c6dbb05..322ada188ee9 100644
> > --- a/drivers/platform/x86/intel/sdsi.c
> > +++ b/drivers/platform/x86/intel/sdsi.c
> > @@ -12,6 +12,7 @@
> > #include <linux/bits.h>
> > #include <linux/bitfield.h>
> > #include <linux/device.h>
> > +#include <linux/intel_vsec.h>
> > #include <linux/iopoll.h>
> > #include <linux/kernel.h>
> > #include <linux/module.h>
> > @@ -21,8 +22,6 @@
> > #include <linux/types.h>
> > #include <linux/uaccess.h>
> > 
> > -#include "vsec.h"
> > -
> > #define ACCESS_TYPE_BARID		2
> > #define ACCESS_TYPE_LOCAL		3
> > 
> > diff --git a/drivers/platform/x86/intel/tpmi.c
> > b/drivers/platform/x86/intel/tpmi.c
> > index 910df7c654f4..be7ea557b72d 100644
> > --- a/drivers/platform/x86/intel/tpmi.c
> > +++ b/drivers/platform/x86/intel/tpmi.c
> > @@ -51,6 +51,7 @@
> > #include <linux/debugfs.h>
> > #include <linux/delay.h>
> > #include <linux/intel_tpmi.h>
> > +#include <linux/intel_vsec.h>
> > #include <linux/io.h>
> > #include <linux/iopoll.h>
> > #include <linux/module.h>
> > @@ -59,8 +60,6 @@
> > #include <linux/sizes.h>
> > #include <linux/string_helpers.h>
> > 
> > -#include "vsec.h"
> > -
> > /**
> >  * struct intel_tpmi_pfs_entry - TPMI PM Feature Structure (PFS) entry
> >  * @tpmi_id:	TPMI feature identifier (what the feature is and its data
> > format).
> > diff --git a/drivers/platform/x86/intel/vsec.c
> > b/drivers/platform/x86/intel/vsec.c
> > index 0fdfaf3a4f5c..5a1e964783cc 100644
> > --- a/drivers/platform/x86/intel/vsec.c
> > +++ b/drivers/platform/x86/intel/vsec.c
> > @@ -17,14 +17,13 @@
> > #include <linux/bits.h>
> > #include <linux/cleanup.h>
> > #include <linux/delay.h>
> > -#include <linux/kernel.h>
> > #include <linux/idr.h>
> > +#include <linux/intel_vsec.h>
> > +#include <linux/kernel.h>
> > #include <linux/module.h>
> > #include <linux/pci.h>
> > #include <linux/types.h>
> > 
> > -#include "vsec.h"
> > -
> > #define PMT_XA_START			0
> > #define PMT_XA_MAX			INT_MAX
> > #define PMT_XA_LIMIT			XA_LIMIT(PMT_XA_START,
> > PMT_XA_MAX)
> > diff --git a/drivers/platform/x86/intel/vsec.h b/include/linux/intel_vsec.h
> > similarity index 98%
> > rename from drivers/platform/x86/intel/vsec.h
> > rename to include/linux/intel_vsec.h
> > index e23e76129691..7f19a3d90abe 100644
> > --- a/drivers/platform/x86/intel/vsec.h
> > +++ b/include/linux/intel_vsec.h
> > @@ -1,6 +1,6 @@
> > /* SPDX-License-Identifier: GPL-2.0 */
> > -#ifndef _VSEC_H
> > -#define _VSEC_H
> > +#ifndef _INTEL_VSEC_H
> > +#define _INTEL_VSEC_H
> > 
> > #include <linux/auxiliary_bus.h>
> > #include <linux/bits.h>
> > --
> > 2.44.0
> 


^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: [PATCH 4/6] platform/x86/intel/pmt: Add quirk for BAR0 offset adjustment
  2024-05-30 20:59   ` David E. Box
@ 2024-05-31 15:40     ` Ruhl, Michael J
  0 siblings, 0 replies; 17+ messages in thread
From: Ruhl, Michael J @ 2024-05-31 15:40 UTC (permalink / raw)
  To: david.e.box@linux.intel.com, intel-xe@lists.freedesktop.org

>-----Original Message-----
>From: David E. Box <david.e.box@linux.intel.com>
>Sent: Thursday, May 30, 2024 5:00 PM
>To: Ruhl, Michael J <michael.j.ruhl@intel.com>; intel-xe@lists.freedesktop.org
>Subject: Re: [PATCH 4/6] platform/x86/intel/pmt: Add quirk for BAR0 offset
>adjustment
>
>On Fri, 2024-05-10 at 16:59 -0400, Michael J. Ruhl wrote:
>> The offset for the discovery table is based on the P2SB bar.
>> If this bar is not available, the parent driver may need to
>> adjust the offset,
>>
>> Add a quirk to allow for this adjustment.
>
>I'm not a fan of using base_addr in this was to adjust the offset. There was a
>version that provided a separate base_adjust field to adjust the offset. Is this
>change only needed for DG2?

Yes.   This change is needed for DG2 support.  My understanding is that DG2 support
is desired.

How can we get the base_adjust code included?  Shall I update my patch with this change?

Umm,

Would it make sense to do patch 6 first (BMG support) and then backfill with the DG2 patches?

Thanks!

Mike

>David
>
>>
>> Signed-off-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
>> ---
>>  drivers/platform/x86/intel/pmt/class.c     | 3 +++
>>  drivers/platform/x86/intel/pmt/telemetry.c | 2 +-
>>  drivers/platform/x86/intel/vsec.c          | 2 +-
>>  include/linux/intel_vsec.h                 | 3 +++
>>  4 files changed, 8 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/platform/x86/intel/pmt/class.c
>> b/drivers/platform/x86/intel/pmt/class.c
>> index 62e36dd89137..957cf74234da 100644
>> --- a/drivers/platform/x86/intel/pmt/class.c
>> +++ b/drivers/platform/x86/intel/pmt/class.c
>> @@ -349,6 +349,9 @@ int intel_pmt_dev_create(struct intel_pmt_entry
>*entry,
>> struct intel_pmt_namespa
>>  	if (IS_ERR(entry->disc_table))
>>  		return PTR_ERR(entry->disc_table);
>>
>> +	if (intel_vsec_dev->quirks & VSEC_QUIRK_P2SB_OFFSET)
>> +		entry->base_addr = intel_vsec_dev->base_addr;
>> +
>>  	ret = ns->pmt_header_decode(entry, dev);
>>  	if (ret)
>>  		return ret;
>> diff --git a/drivers/platform/x86/intel/pmt/telemetry.c
>> b/drivers/platform/x86/intel/pmt/telemetry.c
>> index c9feac859e57..7be9f9746363 100644
>> --- a/drivers/platform/x86/intel/pmt/telemetry.c
>> +++ b/drivers/platform/x86/intel/pmt/telemetry.c
>> @@ -77,7 +77,7 @@ static int pmt_telem_header_decode(struct
>intel_pmt_entry
>> *entry,
>>
>>  	header->access_type = TELEM_ACCESS(readl(disc_table));
>>  	header->guid = readl(disc_table + TELEM_GUID_OFFSET);
>> -	header->base_offset = readl(disc_table + TELEM_BASE_OFFSET);
>> +	header->base_offset = readl(disc_table + TELEM_BASE_OFFSET) +
>entry-
>> >base_addr;
>>
>>  	/* Size is measured in DWORDS, but accessor returns bytes */
>>  	header->size = TELEM_SIZE(readl(disc_table));
>> diff --git a/drivers/platform/x86/intel/vsec.c
>> b/drivers/platform/x86/intel/vsec.c
>> index 5378da9354b6..5a0dfc21eb0f 100644
>> --- a/drivers/platform/x86/intel/vsec.c
>> +++ b/drivers/platform/x86/intel/vsec.c
>> @@ -185,7 +185,7 @@ static int intel_vsec_add_dev(struct pci_dev *pdev,
>struct
>> intel_vsec_header *he
>>  	if (quirks & VSEC_QUIRK_TABLE_SHIFT)
>>  		header->offset >>= TABLE_OFFSET_SHIFT;
>>
>> -	if (info->base_addr)
>> +	if (!(quirks & VSEC_QUIRK_P2SB_OFFSET) && info->base_addr)
>>  		base_addr = info->base_addr;
>>  	else
>>  		base_addr = pdev->resource[header->tbir].start;
>> diff --git a/include/linux/intel_vsec.h b/include/linux/intel_vsec.h
>> index 04f915a1ba0b..68e3a42040e8 100644
>> --- a/include/linux/intel_vsec.h
>> +++ b/include/linux/intel_vsec.h
>> @@ -65,6 +65,9 @@ enum intel_vsec_quirks {
>>
>>  	/* Platforms requiring quirk in the auxiliary driver */
>>  	VSEC_QUIRK_EARLY_HW     = BIT(4),
>> +
>> +	/* Broken P2SB access work around */
>> +	VSEC_QUIRK_P2SB_OFFSET  = BIT(5),
>>  };
>>
>>  struct pmt_callbacks {


^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: [PATCH 6/6] drm/xe/vsec: Support BMG devices
  2024-05-30 21:06   ` David E. Box
@ 2024-05-31 15:42     ` Ruhl, Michael J
  0 siblings, 0 replies; 17+ messages in thread
From: Ruhl, Michael J @ 2024-05-31 15:42 UTC (permalink / raw)
  To: david.e.box@linux.intel.com, intel-xe@lists.freedesktop.org

>-----Original Message-----
>From: David E. Box <david.e.box@linux.intel.com>
>Sent: Thursday, May 30, 2024 5:07 PM
>To: Ruhl, Michael J <michael.j.ruhl@intel.com>; intel-xe@lists.freedesktop.org
>Subject: Re: [PATCH 6/6] drm/xe/vsec: Support BMG devices
>
>On Fri, 2024-05-10 at 16:59 -0400, Michael J. Ruhl wrote:
>> Utilize the PMT callback API to add support for the BMG
>> devices.
>>
>> Signed-off-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
>> ---
>>  drivers/gpu/drm/xe/xe_device.c       |   2 +
>>  drivers/gpu/drm/xe/xe_device_types.h |   5 +
>>  drivers/gpu/drm/xe/xe_vsec.c         | 145 +++++++++++++++++++++++++--
>>  drivers/platform/x86/intel/vsec.c    |   2 +-
>>  4 files changed, 146 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/xe/xe_device.c
>b/drivers/gpu/drm/xe/xe_device.c
>> index e77768bc4471..940f4cf0274a 100644
>> --- a/drivers/gpu/drm/xe/xe_device.c
>> +++ b/drivers/gpu/drm/xe/xe_device.c
>> @@ -315,6 +315,8 @@ struct xe_device *xe_device_create(struct pci_dev
>*pdev,
>>  		goto err;
>>  	}
>>
>> +	drmm_mutex_init(&xe->drm, &xe->pmt.lock);
>> +
>>  	err = xe_display_create(xe);
>>  	if (WARN_ON(err))
>>  		goto err;
>> diff --git a/drivers/gpu/drm/xe/xe_device_types.h
>> b/drivers/gpu/drm/xe/xe_device_types.h
>> index 0af739981ebf..f451216c2283 100644
>> --- a/drivers/gpu/drm/xe/xe_device_types.h
>> +++ b/drivers/gpu/drm/xe/xe_device_types.h
>> @@ -448,6 +448,11 @@ struct xe_device {
>>  		struct mutex lock;
>>  	} d3cold;
>>
>> +	struct {
>> +		/** @pmt.lock: protect access for telemetry data */
>> +		struct mutex lock;
>> +	} pmt;
>> +
>>  	/**
>>  	 * @pm_callback_task: Track the active task that is running in either
>>  	 * the runtime_suspend or runtime_resume callbacks.
>> diff --git a/drivers/gpu/drm/xe/xe_vsec.c b/drivers/gpu/drm/xe/xe_vsec.c
>> index a91aec49d04a..ac840a1e20a4 100644
>> --- a/drivers/gpu/drm/xe/xe_vsec.c
>> +++ b/drivers/gpu/drm/xe/xe_vsec.c
>> @@ -5,9 +5,12 @@
>>  #include <linux/intel_vsec.h>
>>  #include <linux/pci.h>
>>
>> +#include "xe_device.h"
>>  #include "xe_device_types.h"
>>  #include "xe_drv.h"
>> +#include "xe_mmio.h"
>>  #include "xe_platform_types.h"
>> +#include "xe_pm.h"
>>  #include "xe_vsec.h"
>>
>>  #define SOC_BASE		0x280000
>> @@ -15,6 +18,10 @@
>>  /* from drivers/platform/x86/intel/pmt/telemetry.c */
>>  #define TELEM_BASE_OFFSET	0x8
>>
>> +/* Decode the guid information */
>> +#define GUID_RECORD_MASK GENMASK(1, 0)
>> +#define GUID_CAP_TYPE    GENMASK(3, 2)
>> +
>>  #define DG2_PMT_BASE		0xE8000
>>  #define DG2_DISCOVERY_START	0x6000
>>  #define DG2_TELEM_START		0x4000
>> @@ -22,8 +29,18 @@
>>  #define DG2_DISCOVERY_OFFSET	(SOC_BASE + DG2_PMT_BASE +
>> DG2_DISCOVERY_START)
>>  #define DG2_TELEM_OFFSET	(SOC_BASE + DG2_PMT_BASE +
>DG2_TELEM_START)
>>
>> +#define BMG_PMT_BASE		0xDB000
>> +#define BMG_DISCOVERY_OFFSET	(SOC_BASE + BMG_PMT_BASE)
>> +
>> +#define BMG_TELEMETRY_BASE	0xE0000
>> +#define BMG_TELEMETRY_OFFSET	(SOC_BASE + BMG_TELEMETRY_BASE)
>> +
>>  #define GFX_BAR			0
>>
>> +#define SG_REMAP_INDEX1		XE_REG(SOC_BASE + 0x08)
>> +#define SG_REMAP_ACCESS(_mem)	((_mem) << 24)
>> +#define SG_REMAP_BITS		GENMASK(31, 24)
>> +
>>  static struct intel_vsec_header dg2_telemetry = {
>>  	.length = 0x10,
>>  	.id = VSEC_ID_TELEMETRY,
>> @@ -38,12 +55,106 @@ static struct intel_vsec_header *dg2_capabilities[] =
>{
>>  	NULL
>>  };
>>
>> -static struct intel_vsec_platform_info dg2_vsec_info = {
>> -	.caps = VSEC_CAP_TELEMETRY,
>> -	.headers = dg2_capabilities,
>> -	.quirks = VSEC_QUIRK_EARLY_HW | VSEC_QUIRK_P2SB_OFFSET,
>> +static struct intel_vsec_header bmg_telemetry = {
>> +	.length = 0x10,
>> +	.id = VSEC_ID_TELEMETRY,
>> +	.num_entries = 2,
>> +	.entry_size = 4,
>> +	.tbir = GFX_BAR,
>> +	.offset = BMG_DISCOVERY_OFFSET,
>> +};
>> +
>> +static struct intel_vsec_header *bmg_capabilities[] = {
>> +	&bmg_telemetry,
>> +	NULL
>> +};
>> +
>> +enum xe_vsec {
>> +	XE_VSEC_UNKNOWN = 0,
>> +	XE_VSEC_DG2,
>> +	XE_VSEC_BMG,
>> +};
>> +
>> +static struct intel_vsec_platform_info xe_vsec_info[] = {
>> +	[XE_VSEC_DG2] = {
>> +		.caps = VSEC_CAP_TELEMETRY,
>> +		.headers = dg2_capabilities,
>> +		.quirks = VSEC_QUIRK_EARLY_HW |
>VSEC_QUIRK_P2SB_OFFSET,
>> +	},
>> +	[XE_VSEC_BMG] = {
>> +		.caps = VSEC_CAP_TELEMETRY,
>> +		.headers = bmg_capabilities,
>> +	},
>> +	{ }
>
>There is some cleanup here as well to support handling multiple platforms. Can
>these structures just be added to the initial DG2 patch?

I will reorder the patches so that DG2 gets support after BMG.  So we can just add the
data structures as needed.

Thanks!

M

>David
>
>>  };
>>
>> +#define PUNIT_AGGREGATOR 0
>> +#define OOBMSM_AGG0      1
>> +
>> +/*
>> + * The telemetry memory space shares a common offset.  To get the
>appropriate
>> + * data, set the index based on the GUID bits.
>> + *
>> + * The GUID will have the following bits to decode:
>> + *   (2bits) - Record-ID (0-PUNIT, 1-OOBMSM_0, 2-OOBMSM_1)
>> + *   (2bits) - Capability Type (Crashlog-0, Telemetry Aggregator-1, Watcher-
>> 2)
>> + *   ... <other that are not currently relevant>
>> + *
>> + * Currently only the record-id is set.  Once the other bits are set, the
>> + * decode path will get a little more complex.
>> + */
>> +static int xe_pmt_telem_read(void *args, u32 guid, u64 *data, u32 count)
>> +{
>> +	struct xe_device *xe = pdev_to_xe_device((struct pci_dev *)args);
>> +	void __iomem *telem_addr = xe->tiles[0].mmio.regs +
>> BMG_TELEMETRY_OFFSET;
>> +	u32 telem_region = guid & GUID_RECORD_MASK;
>> +	int ret = 0;
>> +
>> +	/* Update the base offset (if necessary) for the specific telementry
>> region */
>> +	switch (telem_region) {
>> +	case PUNIT_AGGREGATOR:
>> +		telem_addr += 0x200;
>> +		break;
>> +	case OOBMSM_AGG0:
>> +		break;
>> +	default:
>> +		return -EINVAL;
>> +	}
>> +
>> +	mutex_lock(&xe->pmt.lock);
>> +	if (xe_pm_runtime_get_if_active(xe) > 0) {
>> +		/* set SoC re-mapper index register based on guid memory
>> region */
>> +		xe_mmio_rmw32(xe->tiles[0].primary_gt, SG_REMAP_INDEX1,
>> SG_REMAP_BITS,
>> +			      SG_REMAP_ACCESS(telem_region));
>> +
>> +		memcpy_fromio(data, telem_addr, count);
>> +
>> +		xe_pm_runtime_put(xe);
>> +
>> +		ret = count;
>> +	}
>> +	mutex_unlock(&xe->pmt.lock);
>> +
>> +	return ret;
>> +}
>> +
>> +struct pmt_callbacks xe_pmt_cb = {
>> +	.read_telem = xe_pmt_telem_read,
>> +};
>> +
>> +static const int vsec_platforms[] = {
>> +	[XE_DG2] = XE_VSEC_DG2,
>> +	[XE_BATTLEMAGE] = XE_VSEC_BMG,
>> +};
>> +
>> +static enum xe_vsec get_platform_info(struct xe_device *xe)
>> +{
>> +	if (xe->info.platform > XE_BATTLEMAGE)
>> +		return XE_VSEC_UNKNOWN;
>> +
>> +	return vsec_platforms[xe->info.platform];
>> +}
>> +
>>  /*
>>   * Access the DG2 PMT MMIO discovery table
>>   *
>> @@ -92,15 +203,35 @@ static int dg2_adjust_offset(struct pci_dev *pdev,
>struct
>> device *dev,
>>   */
>>  void xe_vsec_init(struct xe_device *xe)
>>  {
>> -	struct intel_vsec_platform_info *info = &dg2_vsec_info;
>> +	struct intel_vsec_platform_info *info;
>>  	struct device *dev = xe->drm.dev;
>>  	struct pci_dev *pdev = to_pci_dev(dev);
>> +	enum xe_vsec platform;
>>  	u32 ret;
>>
>> -	ret = dg2_adjust_offset(pdev, dev, info);
>> -	if (ret)
>> +	platform = get_platform_info(xe);
>> +	if (platform == XE_VSEC_UNKNOWN)
>> +		return;
>> +
>> +	info = &xe_vsec_info[platform];
>> +	if (!info->headers)
>>  		return;
>>
>> +	switch (platform) {
>> +	case XE_VSEC_DG2:
>> +		ret = dg2_adjust_offset(pdev, dev, info);
>> +		if (ret)
>> +			return;
>> +		break;
>> +
>> +	case XE_VSEC_BMG:
>> +		info->priv_data = &xe_pmt_cb;
>> +		break;
>> +
>> +	default:
>> +		break;
>> +	}
>> +
>>  	/*
>>  	 * Register a VSEC. Cleanup is handled using device managed
>>  	 * resources.
>> diff --git a/drivers/platform/x86/intel/vsec.c
>> b/drivers/platform/x86/intel/vsec.c
>> index 5a0dfc21eb0f..f59f8ac87b4e 100644
>> --- a/drivers/platform/x86/intel/vsec.c
>> +++ b/drivers/platform/x86/intel/vsec.c
>> @@ -341,7 +341,7 @@ static bool intel_vsec_walk_vsec(struct pci_dev
>*pdev,
>>  void intel_vsec_register(struct pci_dev *pdev,
>>  			 struct intel_vsec_platform_info *info)
>>  {
>> -	if (!pdev || !info)
>> +	if (!pdev || !info || !info->headers)
>>  		return;
>>
>>  	intel_vsec_walk_header(pdev, info);


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2024-05-31 15:42 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-10 20:59 [PATCH 0/6] Support PMT features in Xe Michael J. Ruhl
2024-05-10 20:59 ` [PATCH 1/6] platform/x86/intel/vsec.h: Move to include/linux Michael J. Ruhl
2024-05-28 15:43   ` Ruhl, Michael J
2024-05-30 21:07     ` David E. Box
2024-05-10 20:59 ` [PATCH 2/6] platform/x86/intel/vsec: Add PMT read callbacks Michael J. Ruhl
2024-05-10 20:59 ` [PATCH 3/6] platform/x86/intel/pmt: Add support to use provided " Michael J. Ruhl
2024-05-13 17:15   ` Rodrigo Vivi
2024-05-10 20:59 ` [PATCH 4/6] platform/x86/intel/pmt: Add quirk for BAR0 offset adjustment Michael J. Ruhl
2024-05-30 20:59   ` David E. Box
2024-05-31 15:40     ` Ruhl, Michael J
2024-05-10 20:59 ` [PATCH 5/6] drm/xe/vsec: Add support for DG2 Michael J. Ruhl
2024-05-10 20:59 ` [PATCH 6/6] drm/xe/vsec: Support BMG devices Michael J. Ruhl
2024-05-30 21:06   ` David E. Box
2024-05-31 15:42     ` Ruhl, Michael J
2024-05-10 21:48 ` ✓ CI.Patch_applied: success for Support PMT features in Xe Patchwork
2024-05-10 21:48 ` ✗ CI.checkpatch: warning " Patchwork
2024-05-10 21:49 ` ✗ CI.KUnit: failure " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox