Skip to contentSkip to conversation

Auxiliary bus driver support for Intel PCIe VSEC/DVSEC

PATCH RESEND Superseded David E. Box 4 participants 29 messages Dec 8, 2021 – Dec 22, 2021

Subsystems (8)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

David E. Box

author maintainer
#0 lore raw

v2 cover Auxiliary bus driver support for Intel PCIe VSEC/DVSEC

This series makes changes to the current intel_pmt driver to give it broader support for Intel defined PCIe VSEC and DVSEC features. It moves the implementation from MFD to the auxiliary bus and creates a generic framework for enumerating the extended capabilities. It also adds support for a new VSEC, Software Defined Silicon (SDSi).

Version 2 adds two new patches, sample code and testing.

Resend due to missing 'PATCH' in Subject of previous series.

David E. Box (6):
PCI: Add #defines for accessing PCIe DVSEC fields driver core: auxiliary bus: Add driver data helpers platform/x86/intel: Move intel_pmt from MFD to Auxiliary Bus platform/x86: Add Intel Software Defined Silicon driver sample/sdsi: Sample of SDSi provisiong using sysfs
selftests: sdsi: test sysfs setup

 .../ABI/testing/sysfs-driver-intel_sdsi       |  77 +++
 MAINTAINERS                                   |  19 +-
 drivers/mfd/Kconfig                           |  10 -
 drivers/mfd/Makefile                          |   1 -
 drivers/mfd/intel_pmt.c                       | 261 --------
 drivers/platform/x86/intel/Kconfig            |  23 +
 drivers/platform/x86/intel/Makefile           |   4 +
 drivers/platform/x86/intel/pmt/Kconfig        |   4 +-
 drivers/platform/x86/intel/pmt/class.c        |  21 +-
 drivers/platform/x86/intel/pmt/class.h        |   5 +-
 drivers/platform/x86/intel/pmt/crashlog.c     |  47 +-
 drivers/platform/x86/intel/pmt/telemetry.c    |  46 +-
 drivers/platform/x86/intel/sdsi.c             | 571 ++++++++++++++++++
 drivers/platform/x86/intel/vsec.c             | 418 +++++++++++++
 drivers/platform/x86/intel/vsec.h             |  43 ++
 include/linux/auxiliary_bus.h                 |  10 +
 include/uapi/linux/pci_regs.h                 |   4 +
 samples/sdsi/Makefile                         |   9 +
 samples/sdsi/sdsi-sample.c                    | 399 ++++++++++++
 tools/testing/selftests/drivers/sdsi/sdsi.sh  |  18 +
 .../selftests/drivers/sdsi/sdsi_test.py       | 166 +++++
 21 files changed, 1821 insertions(+), 335 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-driver-intel_sdsi
 delete mode 100644 drivers/mfd/intel_pmt.c
 create mode 100644 drivers/platform/x86/intel/sdsi.c
 create mode 100644 drivers/platform/x86/intel/vsec.c
 create mode 100644 drivers/platform/x86/intel/vsec.h
 create mode 100644 samples/sdsi/Makefile
 create mode 100644 samples/sdsi/sdsi-sample.c
 create mode 100755 tools/testing/selftests/drivers/sdsi/sdsi.sh
 create mode 100644 tools/testing/selftests/drivers/sdsi/sdsi_test.py
Signature · 1 line
2.25.1
author maintainer
#1 lore raw

PATCH RESEND v2 1/6 PCI: Add #defines for accessing PCIe DVSEC fields

Add #defines for accessing Vendor ID, Revision, Length, and ID offsets in the Designated Vendor Specific Extended Capability (DVSEC). Defined in PCIe r5.0, sec 7.9.6.

---
V2
- No changes

 include/uapi/linux/pci_regs.h | 4 ++++
 1 file changed, 4 insertions(+)
include/uapi/linux/pci_regs.h +4 -0
index ff6ccbc6efe9..318f3f1f9e92 100644
@@ -1086,7 +1086,11 @@
 
 /* Designated Vendor-Specific (DVSEC, PCI_EXT_CAP_ID_DVSEC) */
 #define PCI_DVSEC_HEADER1		0x4 /* Designated Vendor-Specific Header1 */
+#define  PCI_DVSEC_HEADER1_VID(x)	((x) & 0xffff)
+#define  PCI_DVSEC_HEADER1_REV(x)	(((x) >> 16) & 0xf)
+#define  PCI_DVSEC_HEADER1_LEN(x)	(((x) >> 20) & 0xfff)
 #define PCI_DVSEC_HEADER2		0x8 /* Designated Vendor-Specific Header2 */
+#define  PCI_DVSEC_HEADER2_ID(x)		((x) & 0xffff)
 
 /* Data Link Feature */
 #define PCI_DLF_CAP		0x04	/* Capabilities Register */
Signature · 1 line
2.25.1
author maintainer
#2 lore raw

PATCH RESEND v2 2/6 driver core: auxiliary bus: Add driver data helpers

In reply to David E. Box

Adds get/set driver data helpers for auxiliary devices.

---
V2
- No changes

 include/linux/auxiliary_bus.h | 10 ++++++++++
 1 file changed, 10 insertions(+)
include/linux/auxiliary_bus.h +10 -0
index fc51d45f106b..a8338d456e81 100644
@@ -28,6 +28,16 @@ struct auxiliary_driver {
 	const struct auxiliary_device_id *id_table;
 };
 
+static inline void *auxiliary_get_drvdata(struct auxiliary_device *auxdev)
+{
+	return dev_get_drvdata(&auxdev->dev);
+}
+
+static inline void auxiliary_set_drvdata(struct auxiliary_device *auxdev, void *data)
+{
+	dev_set_drvdata(&auxdev->dev, data);
+}
+
 static inline struct auxiliary_device *to_auxiliary_dev(struct device *dev)
 {
 	return container_of(dev, struct auxiliary_device, dev);
Signature · 1 line
2.25.1
author maintainer
#3 lore raw

PATCH RESEND v2 3/6 platform/x86/intel: Move intel_pmt from MFD to Auxiliary Bus

In reply to David E. Box

Intel Platform Monitoring Technology (PMT) support is indicated by presence of an Intel defined PCIe Designated Vendor Specific Extended Capabilities (DVSEC) structure with a PMT specific ID. The current MFD implementation creates child devices for each PMT feature, currently telemetry, watcher, and crashlog. However DVSEC structures may also be used by Intel to indicate support for other features. The Out Of Band Management Services Module (OOBMSM) uses DVSEC to enumerate several features, including PMT. In order to support them it is necessary to modify the intel_pmt driver to handle the creation of the child devices more generically. To that end, modify the driver to create child devices for any VSEC/DVSEC features on supported devices (indicated by PCI ID). Additionally, move the implementation from MFD to the Auxiliary bus. VSEC/DVSEC features are really multifunctional PCI devices, not platform devices as MFD was designed for. Auxiliary bus gives more flexibility by allowing the definition of custom structures that can be shared between associated auxiliary devices and the parent device. Also, rename the driver from intel_pmt to intel_vsec to better reflect the purpose.

This series also removes the current runtime pm support which was not complete to begin with. None of the current devices require runtime pm. However the support will be replaced when a device is added that requires it.

---
V2
- Clarify status of missing pm support in commit message
- Clarify why auxiliary bus is preferred in commit message

 MAINTAINERS                                |  12 +-
 drivers/mfd/Kconfig                        |  10 -
 drivers/mfd/Makefile                       |   1 -
 drivers/mfd/intel_pmt.c                    | 261 -------------
 drivers/platform/x86/intel/Kconfig         |  11 +
 drivers/platform/x86/intel/Makefile        |   2 +
 drivers/platform/x86/intel/pmt/Kconfig     |   4 +-
 drivers/platform/x86/intel/pmt/class.c     |  21 +-
 drivers/platform/x86/intel/pmt/class.h     |   5 +-
 drivers/platform/x86/intel/pmt/crashlog.c  |  47 +--
 drivers/platform/x86/intel/pmt/telemetry.c |  46 +--
 drivers/platform/x86/intel/vsec.c          | 408 +++++++++++++++++++++
 drivers/platform/x86/intel/vsec.h          |  43 +++
 13 files changed, 536 insertions(+), 335 deletions(-)
 delete mode 100644 drivers/mfd/intel_pmt.c
 create mode 100644 drivers/platform/x86/intel/vsec.c
 create mode 100644 drivers/platform/x86/intel/vsec.h
MAINTAINERS +8 -4
index 43007f2d29e0..cd2b10a86f09 100644
@@ -9752,10 +9752,9 @@ S:	Maintained
 F:	drivers/mfd/intel_soc_pmic*
 F:	include/linux/mfd/intel_soc_pmic*
 
-INTEL PMT DRIVER
-M:	"David E. Box" <[email protected]>
-S:	Maintained
-F:	drivers/mfd/intel_pmt.c
+INTEL PMT DRIVERS
+M:	David E. Box <[email protected]>
+S:	Supported
 F:	drivers/platform/x86/intel/pmt/
 
 INTEL PRO/WIRELESS 2100, 2200BG, 2915ABG NETWORK CONNECTION SUPPORT
@@ -9822,6 +9821,11 @@ L:	[email protected]
 S:	Maintained
 F:	drivers/platform/x86/intel/uncore-frequency.c
 
+INTEL VENDOR SPECIFIC EXTENDED CAPABILITIES DRIVER
+M:	David E. Box <[email protected]>
+S:	Supported
+F:	drivers/platform/x86/intel/vsec.*
+
 INTEL VIRTUAL BUTTON DRIVER
 M:	AceLan Kao <[email protected]>
 L:	[email protected]
drivers/mfd/Kconfig +0 -10
index 3fb480818599..ac7b23eb62c2 100644
@@ -692,16 +692,6 @@ config MFD_INTEL_PMC_BXT
 	  Register and P-unit access. In addition this creates devices
 	  for iTCO watchdog and telemetry that are part of the PMC.
 
-config MFD_INTEL_PMT
-	tristate "Intel Platform Monitoring Technology (PMT) support"
-	depends on X86 && PCI
-	select MFD_CORE
-	help
-	  The Intel Platform Monitoring Technology (PMT) is an interface that
-	  provides access to hardware monitor registers. This driver supports
-	  Telemetry, Watcher, and Crashlog PMT capabilities/devices for
-	  platforms starting from Tiger Lake.
-
 config MFD_IPAQ_MICRO
 	bool "Atmel Micro ASIC (iPAQ h3100/h3600/h3700) Support"
 	depends on SA1100_H3100 || SA1100_H3600
drivers/mfd/Makefile +0 -1
index 0b1b629aef3e..31734d9318e2 100644
@@ -211,7 +211,6 @@ obj-$(CONFIG_MFD_INTEL_LPSS)	+= intel-lpss.o
 obj-$(CONFIG_MFD_INTEL_LPSS_PCI)	+= intel-lpss-pci.o
 obj-$(CONFIG_MFD_INTEL_LPSS_ACPI)	+= intel-lpss-acpi.o
 obj-$(CONFIG_MFD_INTEL_PMC_BXT)	+= intel_pmc_bxt.o
-obj-$(CONFIG_MFD_INTEL_PMT)	+= intel_pmt.o
 obj-$(CONFIG_MFD_PALMAS)	+= palmas.o
 obj-$(CONFIG_MFD_VIPERBOARD)    += viperboard.o
 obj-$(CONFIG_MFD_NTXEC)		+= ntxec.o
drivers/mfd/intel_pmt.c deleted +0 -261

261 lines not on this page · raw message

drivers/platform/x86/intel/Kconfig +11 -0
index 38ce3e344589..35a5d1a5eba8 100644
@@ -184,4 +184,15 @@ config INTEL_UNCORE_FREQ_CONTROL
 	  To compile this driver as a module, choose M here: the module
 	  will be called intel-uncore-frequency.
 
+config INTEL_VSEC
+	tristate "Intel Vendor Specific Extended Capabilities Driver"
+	depends on PCI
+	select AUXILIARY_BUS
+	help
+	  Adds support for feature drivers exposed using Intel PCIe VSEC and
+	  DVSEC.
+
+	  To compile this driver as a module, choose M here: the module will
+	  be called intel_vsec.
+
 endif # X86_PLATFORM_DRIVERS_INTEL
drivers/platform/x86/intel/Makefile +2 -0
index 7c24be2423d8..8ecdf709fb17 100644
@@ -26,6 +26,8 @@ intel_int0002_vgpio-y			:= int0002_vgpio.o
 obj-$(CONFIG_INTEL_INT0002_VGPIO)	+= intel_int0002_vgpio.o
 intel_oaktrail-y			:= oaktrail.o
 obj-$(CONFIG_INTEL_OAKTRAIL)		+= intel_oaktrail.o
+intel_vsec-y				:= vsec.o
+obj-$(CONFIG_INTEL_VSEC)		+= intel_vsec.o
 
 # Intel PMIC / PMC / P-Unit drivers
 intel_bxtwc_tmu-y			:= bxtwc_tmu.o
drivers/platform/x86/intel/pmt/Kconfig +2 -2
index d630f883a717..e916fc966221 100644
@@ -17,7 +17,7 @@ config INTEL_PMT_CLASS
 
 config INTEL_PMT_TELEMETRY
 	tristate "Intel Platform Monitoring Technology (PMT) Telemetry driver"
-	depends on MFD_INTEL_PMT
+	depends on INTEL_VSEC
 	select INTEL_PMT_CLASS
 	help
 	  The Intel Platform Monitory Technology (PMT) Telemetry driver provides
@@ -29,7 +29,7 @@ config INTEL_PMT_TELEMETRY
 
 config INTEL_PMT_CRASHLOG
 	tristate "Intel Platform Monitoring Technology (PMT) Crashlog driver"
-	depends on MFD_INTEL_PMT
+	depends on INTEL_VSEC
 	select INTEL_PMT_CLASS
 	help
 	  The Intel Platform Monitoring Technology (PMT) crashlog driver provides
drivers/platform/x86/intel/pmt/class.c +10 -11
index 659b1073033c..1c9e3f3ea41c 100644
@@ -13,6 +13,7 @@
 #include <linux/mm.h>
 #include <linux/pci.h>
 
+#include "../vsec.h"
 #include "class.h"
 
 #define PMT_XA_START		0
@@ -281,31 +282,29 @@ static int intel_pmt_dev_register(struct intel_pmt_entry *entry,
 	return ret;
 }
 
-int intel_pmt_dev_create(struct intel_pmt_entry *entry,
-			 struct intel_pmt_namespace *ns,
-			 struct platform_device *pdev, int idx)
+int intel_pmt_dev_create(struct intel_pmt_entry *entry, struct intel_pmt_namespace *ns,
+			 struct intel_vsec_device *intel_vsec_dev, int idx)
 {
+	struct device *dev = &intel_vsec_dev->auxdev.dev;
 	struct intel_pmt_header header;
 	struct resource	*disc_res;
-	int ret = -ENODEV;
+	int ret;
 
-	disc_res = platform_get_resource(pdev, IORESOURCE_MEM, idx);
-	if (!disc_res)
-		return ret;
+	disc_res = &intel_vsec_dev->resource[idx];
 
-	entry->disc_table = devm_platform_ioremap_resource(pdev, idx);
+	entry->disc_table = devm_ioremap_resource(dev, disc_res);
 	if (IS_ERR(entry->disc_table))
 		return PTR_ERR(entry->disc_table);
 
-	ret = ns->pmt_header_decode(entry, &header, &pdev->dev);
+	ret = ns->pmt_header_decode(entry, &header, dev);
 	if (ret)
 		return ret;
 
-	ret = intel_pmt_populate_entry(entry, &header, &pdev->dev, disc_res);
+	ret = intel_pmt_populate_entry(entry, &header, dev, disc_res);
 	if (ret)
 		return ret;
 
-	return intel_pmt_dev_register(entry, ns, &pdev->dev);
+	return intel_pmt_dev_register(entry, ns, dev);
 
 }
 EXPORT_SYMBOL_GPL(intel_pmt_dev_create);
drivers/platform/x86/intel/pmt/class.h +3 -2
index 1337019c2873..db11d58867ce 100644
@@ -2,13 +2,14 @@
 #ifndef _INTEL_PMT_CLASS_H
 #define _INTEL_PMT_CLASS_H
 
-#include <linux/platform_device.h>
 #include <linux/xarray.h>
 #include <linux/types.h>
 #include <linux/bits.h>
 #include <linux/err.h>
 #include <linux/io.h>
 
+#include "../vsec.h"
+
 /* PMT access types */
 #define ACCESS_BARID		2
 #define ACCESS_LOCAL		3
@@ -47,7 +48,7 @@ struct intel_pmt_namespace {
 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,
-			 struct platform_device *pdev, int idx);
+			 struct intel_vsec_device *dev, int idx);
 void intel_pmt_dev_destroy(struct intel_pmt_entry *entry,
 			   struct intel_pmt_namespace *ns);
 #endif
drivers/platform/x86/intel/pmt/crashlog.c +25 -22

106 lines not on this page · raw message

drivers/platform/x86/intel/pmt/telemetry.c +24 -22

106 lines not on this page · raw message

drivers/platform/x86/intel/vsec.c new file +408 -0

408 lines not on this page · raw message

drivers/platform/x86/intel/vsec.h new file +43 -0

43 lines not on this page · raw message

Signature · 1 line
2.25.1
maintainer
#4 lore raw

Re: [PATCH RESEND V2 3/6] platform/x86/intel: Move intel_pmt from MFD to Auxiliary Bus

drivers/platform/x86/intel/vsec.c line 403

Quoted 5 lines · David E. Box
drivers/platform/x86/intel/vsec.c new file +5 -0
+static struct pci_driver intel_vsec_pci_driver = {
+	.name = "intel_vsec",
+	.id_table = intel_vsec_pci_ids,
+	.probe = intel_vsec_pci_probe,
+};

So when the PCI device is removed from the system you leak resources and have dangling devices?

Why no PCI remove driver callback?

thanks,

greg k-h

author maintainer
#5 lore raw

Re: [PATCH RESEND V2 3/6] platform/x86/intel: Move intel_pmt from MFD to Auxiliary Bus

Quoted 9 lines · Greg KH

drivers/platform/x86/intel/vsec.c line 403

Quoted 5 lines · David E. Box
drivers/platform/x86/intel/vsec.c new file +5 -0
+static struct pci_driver intel_vsec_pci_driver = {
+       .name = "intel_vsec",
+       .id_table = intel_vsec_pci_ids,
+       .probe = intel_vsec_pci_probe,
+};

So when the PCI device is removed from the system you leak resources and have dangling devices?

No.

Quoted 2 lines

Why no PCI remove driver callback?

After probe all resources are device managed. There's nothing to explicitly clean up. When the PCI device is removed, all aux devices are automatically removed. This is the case for the SDSi driver as well.

David

Quoted 4 lines

thanks,

greg k-h

maintainer
#6 lore raw

Re: [PATCH RESEND V2 3/6] platform/x86/intel: Move intel_pmt from MFD to Auxiliary Bus

Quoted 11 lines · David E. Box
Quoted 9 lines · Greg KH

drivers/platform/x86/intel/vsec.c line 403

Quoted 5 lines · David E. Box
drivers/platform/x86/intel/vsec.c new file +5 -0
+static struct pci_driver intel_vsec_pci_driver = {
+       .name = "intel_vsec",
+       .id_table = intel_vsec_pci_ids,
+       .probe = intel_vsec_pci_probe,
+};

So when the PCI device is removed from the system you leak resources and have dangling devices?

Quoted 8 lines

No.

Quoted 2 lines

Why no PCI remove driver callback?

After probe all resources are device managed. There's nothing to explicitly clean up. When the PCI device is removed, all aux devices are automatically removed. This is the case for the SDSi driver as well.

Where is the "automatic cleanup" happening? As this pci driver is bound to the PCI device, when the device is removed, what is called in this driver to remove the resources allocated in the probe callback?

confused,

greg k-h

author maintainer
#7 lore raw

Re: [PATCH RESEND V2 3/6] platform/x86/intel: Move intel_pmt from MFD to Auxiliary Bus

Quoted 23 lines · Greg KH
Quoted 14 lines · David E. Box
Quoted 9 lines · Greg KH

drivers/platform/x86/intel/vsec.c line 403

Quoted 5 lines · David E. Box
drivers/platform/x86/intel/vsec.c new file +5 -0
+static struct pci_driver intel_vsec_pci_driver = {
+       .name = "intel_vsec",
+       .id_table = intel_vsec_pci_ids,
+       .probe = intel_vsec_pci_probe,
+};

So when the PCI device is removed from the system you leak resources and have dangling devices?

No.

Quoted 1 line
Quoted 7 lines
Quoted 1 line

Why no PCI remove driver callback?

After probe all resources are device managed. There's nothing to explicitly clean up. When the PCI
device is removed, all aux devices are automatically removed. This is the case for the SDSi driver
as well.

Quoted 5 lines

Where is the "automatic cleanup" happening?  As this pci driver is bound to the PCI device, when the device is removed, what is called in this driver to remove the resources allocated in the probe callback?

confused,

devm_add_action_or_reset(&pdev->dev, intel_vsec_remove_aux, auxdev)

intel_vsec_remove_aux() gets called when the PCI device is removed. It calls auxiliary_device_unit() which in turn calls the auxdev release() function that cleans up resources.

When the auxdev is removed, all resources that were dev_m added by the SDSi driver are released too which is why it has no remove() either. I'll add the tests that check this.

David

Quoted 2 lines

greg k-h

maintainer
#8 lore raw

Re: [PATCH RESEND V2 3/6] platform/x86/intel: Move intel_pmt from MFD to Auxiliary Bus

Quoted 24 lines · David E. Box
Quoted 23 lines · Greg KH
Quoted 21 lines · David E. Box
Quoted 9 lines · Greg KH

drivers/platform/x86/intel/vsec.c line 403

Quoted 5 lines · David E. Box
drivers/platform/x86/intel/vsec.c new file +5 -0
+static struct pci_driver intel_vsec_pci_driver = {
+       .name = "intel_vsec",
+       .id_table = intel_vsec_pci_ids,
+       .probe = intel_vsec_pci_probe,
+};

So when the PCI device is removed from the system you leak resources and have dangling devices?

No.

Quoted 2 lines

Why no PCI remove driver callback?

After probe all resources are device managed. There's nothing to explicitly clean up. When the PCI
device is removed, all aux devices are automatically removed. This is the case for the SDSi driver
as well.

Quoted 7 lines
Quoted 5 lines

Where is the "automatic cleanup" happening?  As this pci driver is bound to the PCI device, when the device is removed, what is called in this driver to remove the resources allocated in the probe callback?

confused,

devm_add_action_or_reset(&pdev->dev, intel_vsec_remove_aux, auxdev)

Wow that is opaque. Why not do it on remove instead?

Quoted 2 lines

intel_vsec_remove_aux() gets called when the PCI device is removed. It calls auxiliary_device_unit() which in turn calls the auxdev release() function that cleans up resources.

Does this happen when the device is removed, or when the binding of driver <-> device is removed?

Quoted 2 lines

When the auxdev is removed, all resources that were dev_m added by the SDSi driver are released too which is why it has no remove() either. I'll add the tests that check this.

Please do so and document it well, as that is an odd "pattern".

thanks,

greg k-h

author maintainer
#9 lore raw

Re: [PATCH RESEND V2 3/6] platform/x86/intel: Move intel_pmt from MFD to Auxiliary Bus

Quoted 30 lines · Greg KH
Quoted 29 lines · David E. Box
Quoted 28 lines · Greg KH
Quoted 14 lines · David E. Box
Quoted 9 lines · Greg KH

drivers/platform/x86/intel/vsec.c line 403

Quoted 5 lines · David E. Box
drivers/platform/x86/intel/vsec.c new file +5 -0
+static struct pci_driver intel_vsec_pci_driver = {
+       .name = "intel_vsec",
+       .id_table = intel_vsec_pci_ids,
+       .probe = intel_vsec_pci_probe,
+};

So when the PCI device is removed from the system you leak resources and have dangling devices?

No.

Quoted 1 line
Quoted 8 lines
Quoted 1 line

Why no PCI remove driver callback?

After probe all resources are device managed. There's nothing to explicitly clean up. When the
PCI
device is removed, all aux devices are automatically removed. This is the case for the SDSi driver
as well.

Where is the "automatic cleanup" happening?  As this pci driver is bound to the PCI device, when the device is removed, what is called in this driver to remove the resources allocated in the probe callback?

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

confused,

devm_add_action_or_reset(&pdev->dev, intel_vsec_remove_aux, auxdev)

Wow that is opaque.  Why not do it on remove instead?

This code is common for auxdev cleanup. AFAICT most auxiliary bus code is done by drivers that have some other primary function. They clean up their primary function resources in remove, but they clean up the auxdev using the method above. In this case the sole purpose of this driver is to create the auxdev. There are no other resources beyond what the auxdev is using.

Adding runtime pm to the pci driver will change this. Remove will be needed then.

Quoted 7 lines
Quoted 4 lines

intel_vsec_remove_aux() gets called when the PCI device is removed. It calls auxiliary_device_unit()
which in turn calls the auxdev release() function that cleans up resources.

Does this happen when the device is removed, or when the binding of driver <-> device is removed?

It happens when the device is removed as tested by unbinding it.

Quoted 6 lines
Quoted 4 lines

When the auxdev is removed, all resources that were dev_m added by the SDSi driver are released too
which is why it has no remove() either. I'll add the tests that check this.

Please do so and document it well, as that is an odd "pattern".

Sure, but I don't think it's that odd in practice given what I already mentioned.

David

Quoted 4 lines

thanks,

greg k-h

maintainer
#10 lore raw

Re: [PATCH RESEND V2 3/6] platform/x86/intel: Move intel_pmt from MFD to Auxiliary Bus

Quoted 35 lines · David E. Box
Quoted 34 lines · Greg KH
Quoted 32 lines · David E. Box
Quoted 24 lines · Greg KH
Quoted 14 lines · David E. Box
Quoted 9 lines · Greg KH

Review

Quoted 5 lines · David E. Box
(quoted diff) +5 -0
+static struct pci_driver intel_vsec_pci_driver = {
+       .name = "intel_vsec",
+       .id_table = intel_vsec_pci_ids,
+       .probe = intel_vsec_pci_probe,
+};

So when the PCI device is removed from the system you leak resources and have dangling devices?

No.

Quoted 1 line
Quoted 8 lines
Quoted 1 line

Why no PCI remove driver callback?

After probe all resources are device managed. There's nothing to explicitly clean up. When the
PCI
device is removed, all aux devices are automatically removed. This is the case for the SDSi driver
as well.

Quoted 5 lines

Where is the "automatic cleanup" happening?  As this pci driver is bound to the PCI device, when the device is removed, what is called in this driver to remove the resources allocated in the probe callback?

confused,

devm_add_action_or_reset(&pdev->dev, intel_vsec_remove_aux, auxdev)

Quoted 8 lines
Quoted 1 line

Wow that is opaque.  Why not do it on remove instead?

This code is common for auxdev cleanup. AFAICT most auxiliary bus code is done by drivers that have some other primary function. They clean up their primary function resources in remove, but they clean up the auxdev using the method above. In this case the sole purpose of this driver is to create the auxdev. There are no other resources beyond what the auxdev is using.

Adding runtime pm to the pci driver will change this. Remove will be needed then.

And who will notice that being required when that happens?

Why is there no runtime PM for this driver? Do you not care about power consumption? :)

thanks,

greg k-h

author maintainer
#11 lore raw

Re: [PATCH RESEND V2 3/6] platform/x86/intel: Move intel_pmt from MFD to Auxiliary Bus

Quoted 50 lines · Greg KH
Quoted 49 lines · David E. Box
Quoted 33 lines · Greg KH
Quoted 32 lines · David E. Box
Quoted 31 lines · Greg KH
Quoted 16 lines · David E. Box
Quoted 10 lines · Greg KH

Review

Quoted 5 lines · David E. Box
(quoted diff) +5 -0
+static struct pci_driver intel_vsec_pci_driver = {
+       .name = "intel_vsec",
+       .id_table = intel_vsec_pci_ids,
+       .probe = intel_vsec_pci_probe,
+};

So when the PCI device is removed from the system you leak resources and
have dangling devices?

No.

Quoted 1 line

Why no PCI remove driver callback?

Quoted 8 lines

After probe all resources are device managed. There's nothing to explicitly clean up. When
the
PCI
device is removed, all aux devices are automatically removed. This is the case for the SDSi
driver
as well.

Where is the "automatic cleanup" happening? As this pci driver is bound
to the PCI device, when the device is removed, what is called in this driver to remove the resources allocated in the probe callback?

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

confused,

devm_add_action_or_reset(&pdev->dev, intel_vsec_remove_aux, auxdev)

Wow that is opaque. Why not do it on remove instead?

This code is common for auxdev cleanup. AFAICT most auxiliary bus code is done by drivers that have
some other primary function. They clean up their primary function resources in remove, but they
clean up the auxdev using the method above. In this case the sole purpose of this driver is to
create the auxdev. There are no other resources beyond what the auxdev is using.

Quoted 7 lines
Quoted 2 lines

Adding runtime pm to the pci driver will change this. Remove will be needed then.

And who will notice that being required when that happens?

Why is there no runtime PM for this driver? Do you not care about power consumption? :)

Of course. :)

There's a backlog of patches waiting for this series. One adds support for the telemetry device (an auxdev) on the DG2 GPU. This device requires runtime pm in order for the slot to go D3. But this also requires changes to the telemetry driver in order for runtime pm to be handled correctly. These and other patches, including a series to have all current aux drivers use the new drvdata helpers, are waiting for this.

David

Quoted 4 lines

thanks,

greg k-h

maintainer
#12 lore raw

Re: [PATCH RESEND V2 3/6] platform/x86/intel: Move intel_pmt from MFD to Auxiliary Bus

Quoted 59 lines · David E. Box
Quoted 50 lines · Greg KH
Quoted 49 lines · David E. Box
Quoted 33 lines · Greg KH
Quoted 32 lines · David E. Box
Quoted 31 lines · Greg KH
Quoted 16 lines · David E. Box
Quoted 10 lines · Greg KH

Review

Quoted 5 lines · David E. Box
(quoted diff) +5 -0
+static struct pci_driver intel_vsec_pci_driver = {
+       .name = "intel_vsec",
+       .id_table = intel_vsec_pci_ids,
+       .probe = intel_vsec_pci_probe,
+};

So when the PCI device is removed from the system you leak resources and
have dangling devices?

No.

Quoted 1 line

Why no PCI remove driver callback?

Quoted 8 lines

After probe all resources are device managed. There's nothing to explicitly clean up. When
the
PCI
device is removed, all aux devices are automatically removed. This is the case for the SDSi
driver
as well.

Where is the "automatic cleanup" happening? As this pci driver is bound
to the PCI device, when the device is removed, what is called in this driver to remove the resources allocated in the probe callback?

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

confused,

devm_add_action_or_reset(&pdev->dev, intel_vsec_remove_aux, auxdev)

Wow that is opaque. Why not do it on remove instead?

This code is common for auxdev cleanup. AFAICT most auxiliary bus code is done by drivers that have
some other primary function. They clean up their primary function resources in remove, but they
clean up the auxdev using the method above. In this case the sole purpose of this driver is to
create the auxdev. There are no other resources beyond what the auxdev is using.

Quoted 7 lines
Quoted 2 lines

Adding runtime pm to the pci driver will change this. Remove will be needed then.

And who will notice that being required when that happens?

Why is there no runtime PM for this driver? Do you not care about power consumption? :)

Quoted 8 lines

Of course. :)

There's a backlog of patches waiting for this series. One adds support for the telemetry device (an auxdev) on the DG2 GPU. This device requires runtime pm in order for the slot to go D3. But this also requires changes to the telemetry driver in order for runtime pm to be handled correctly. These and other patches, including a series to have all current aux drivers use the new drvdata helpers, are waiting for this.

I can take the aux driver drvdata patch now, through my tree, if you want, no need to make it wait for this tiny driver.

Feel free to send it independant of the existing patchset, and with the cleanup patches at the same time, should be quite easy to get merged.

thanks,

greg k-h

Acked-by
#13 lore raw

Re: [PATCH RESEND V2 3/6] platform/x86/intel: Move intel_pmt from MFD to Auxiliary Bus

Hi,

Quoted 69 lines · Greg KH
Quoted 59 lines · David E. Box
Quoted 50 lines · Greg KH
Quoted 49 lines · David E. Box
Quoted 33 lines · Greg KH
Quoted 32 lines · David E. Box
Quoted 31 lines · Greg KH
Quoted 16 lines · David E. Box
Quoted 10 lines · Greg KH

Review

Quoted 5 lines · David E. Box
(quoted diff) +5 -0
+static struct pci_driver intel_vsec_pci_driver = {
+       .name = "intel_vsec",
+       .id_table = intel_vsec_pci_ids,
+       .probe = intel_vsec_pci_probe,
+};

So when the PCI device is removed from the system you leak resources and
have dangling devices?

No.

Quoted 1 line

Why no PCI remove driver callback?

Quoted 8 lines

After probe all resources are device managed. There's nothing to explicitly clean up. When
the
PCI
device is removed, all aux devices are automatically removed. This is the case for the SDSi
driver
as well.

Where is the "automatic cleanup" happening? As this pci driver is bound
to the PCI device, when the device is removed, what is called in this driver to remove the resources allocated in the probe callback?

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

confused,

devm_add_action_or_reset(&pdev->dev, intel_vsec_remove_aux, auxdev)

Wow that is opaque. Why not do it on remove instead?

This code is common for auxdev cleanup. AFAICT most auxiliary bus code is done by drivers that have
some other primary function. They clean up their primary function resources in remove, but they
clean up the auxdev using the method above. In this case the sole purpose of this driver is to
create the auxdev. There are no other resources beyond what the auxdev is using.

Quoted 7 lines
Quoted 2 lines

Adding runtime pm to the pci driver will change this. Remove will be needed then.

And who will notice that being required when that happens?

Why is there no runtime PM for this driver? Do you not care about power consumption? :)

Quoted 8 lines

Of course. :)

There's a backlog of patches waiting for this series. One adds support for the telemetry device (an auxdev) on the DG2 GPU. This device requires runtime pm in order for the slot to go D3. But this also requires changes to the telemetry driver in order for runtime pm to be handled correctly. These and other patches, including a series to have all current aux drivers use the new drvdata helpers, are waiting for this.

Quoted 5 lines

I can take the aux driver drvdata patch now, through my tree, if you want, no need to make it wait for this tiny driver.

Feel free to send it independant of the existing patchset, and with the cleanup patches at the same time, should be quite easy to get merged.

If you're going to take that one, can you perhaps take patches 1-3 for 5.17 through your tree as well (patch 3 depends on 2/it) ?

Note there is a v4 of this series, see please use that :)

I assume the follow up patches are also going to need patch 3 (the actual conversion of the driver to aux-bus).

Here is my Ack for the pdx86 bits in patch 3:

And patch 1 and 3 also have acks from the PCI resp. MFD subsys maintainers, so I guess taking this all upstream through your tree is fine.

That leaves patches 4-6, 4 is the patching adding the new "Intel Software Defined Silicon driver" sysfs API and I would like to take some time to thoroughly review the new userspace API, which I don't see happening before the Christmas Holidays, so I don't plan to merge 4-6 (which depends on 3) until after 5.17-rc1.

Regards,

Hans

author maintainer
#14 lore raw

Re: [PATCH RESEND V2 3/6] platform/x86/intel: Move intel_pmt from MFD to Auxiliary Bus

Quoted 94 lines · Hans de Goede

Hi,

Quoted 85 lines · Greg KH
Quoted 72 lines · David E. Box
Quoted 60 lines · Greg KH
Quoted 59 lines · David E. Box
Quoted 38 lines · Greg KH
Quoted 37 lines · David E. Box
Quoted 36 lines · Greg KH
Quoted 17 lines · David E. Box
Quoted 11 lines · Greg KH

Review

Quoted 5 lines · David E. Box
(quoted diff) +5 -0
+static struct pci_driver intel_vsec_pci_driver = {
+       .name = "intel_vsec",
+       .id_table = intel_vsec_pci_ids,
+       .probe = intel_vsec_pci_probe,
+};

So when the PCI device is removed from the system you leak resources and
have dangling devices?

No.

Quoted 1 line

Why no PCI remove driver callback?

Quoted 10 lines

After probe all resources are device managed. There's nothing to
explicitly clean up. When
the
PCI
device is removed, all aux devices are automatically removed. This
is the case for the SDSi
driver
as well.

Where is the "automatic cleanup" happening? As this pci driver is
bound
to the PCI device, when the device is removed, what is called in this
driver to remove the resources allocated in the probe callback?

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

confused,

devm_add_action_or_reset(&pdev->dev, intel_vsec_remove_aux, auxdev)

Wow that is opaque. Why not do it on remove instead?

This code is common for auxdev cleanup. AFAICT most auxiliary bus code is
done by drivers that have
some other primary function. They clean up their primary function resources
in remove, but they
clean up the auxdev using the method above. In this case the sole purpose of
this driver is to
create the auxdev. There are no other resources beyond what the auxdev is
using.

Quoted 8 lines
Quoted 3 lines

Adding runtime pm to the pci driver will change this. Remove will be needed
then.

And who will notice that being required when that happens?

Why is there no runtime PM for this driver? Do you not care about power consumption? :)

Of course. :)

Quoted 11 lines

There's a backlog of patches waiting for this series. One adds support for the
telemetry device (an auxdev) on the DG2 GPU. This device requires runtime pm in
order for the slot to go D3. But this also requires changes to the telemetry
driver in order for runtime pm to be handled correctly. These and other patches,
including a series to have all current aux drivers use the new drvdata helpers,
are waiting for this.

Quoted 5 lines

I can take the aux driver drvdata patch now, through my tree, if you want, no need to make it wait for this tiny driver.

Feel free to send it independant of the existing patchset, and with the cleanup patches at the same time, should be quite easy to get merged.

Quoted 7 lines

If you're going to take that one, can you perhaps take patches 1-3 for 5.17 through your tree as well (patch 3 depends on 2/it) ?

Note there is a v4 of this series, see please use that :)

I assume the follow up patches are also going to need patch 3 (the actual conversion of the driver to aux-bus).

Yes.

Quoted 7 lines

Here is my Ack for the pdx86 bits in patch 3:

And patch 1 and 3 also have acks from the PCI resp. MFD subsys maintainers, so I guess taking this all upstream through your tree is fine.

Should I send 1-3 plus the drvdata cleanup patches I have to Grep? V5?

Quoted 7 lines

That leaves patches 4-6, 4 is the patching adding the new "Intel Software Defined Silicon driver" sysfs API and I would like to take some time to thoroughly review the new userspace API, which I don't see happening before the Christmas Holidays, so I don't plan to merge 4-6 (which depends on 3) until after 5.17-rc1.

Understood. Thanks.

Quoted 5 lines

Regards,

Hans

#15 lore raw

Re: [PATCH RESEND V2 3/6] platform/x86/intel: Move intel_pmt from MFD to Auxiliary Bus

Hi,

Quoted 106 lines · David E. Box
Quoted 94 lines · Hans de Goede

Hi,

Quoted 85 lines · Greg KH
Quoted 72 lines · David E. Box
Quoted 60 lines · Greg KH
Quoted 59 lines · David E. Box
Quoted 38 lines · Greg KH
Quoted 37 lines · David E. Box
Quoted 36 lines · Greg KH
Quoted 17 lines · David E. Box
Quoted 11 lines · Greg KH

Review

Quoted 5 lines · David E. Box
(quoted diff) +5 -0
+static struct pci_driver intel_vsec_pci_driver = {
+       .name = "intel_vsec",
+       .id_table = intel_vsec_pci_ids,
+       .probe = intel_vsec_pci_probe,
+};

So when the PCI device is removed from the system you leak resources and
have dangling devices?

No.

Quoted 1 line

Why no PCI remove driver callback?

Quoted 10 lines

After probe all resources are device managed. There's nothing to
explicitly clean up. When
the
PCI
device is removed, all aux devices are automatically removed. This
is the case for the SDSi
driver
as well.

Where is the "automatic cleanup" happening? As this pci driver is
bound
to the PCI device, when the device is removed, what is called in this
driver to remove the resources allocated in the probe callback?

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

confused,

devm_add_action_or_reset(&pdev->dev, intel_vsec_remove_aux, auxdev)

Wow that is opaque. Why not do it on remove instead?

This code is common for auxdev cleanup. AFAICT most auxiliary bus code is
done by drivers that have
some other primary function. They clean up their primary function resources
in remove, but they
clean up the auxdev using the method above. In this case the sole purpose of
this driver is to
create the auxdev. There are no other resources beyond what the auxdev is
using.

Quoted 8 lines
Quoted 3 lines

Adding runtime pm to the pci driver will change this. Remove will be needed
then.

And who will notice that being required when that happens?

Why is there no runtime PM for this driver? Do you not care about power consumption? :)

Of course. :)

Quoted 11 lines

There's a backlog of patches waiting for this series. One adds support for the
telemetry device (an auxdev) on the DG2 GPU. This device requires runtime pm in
order for the slot to go D3. But this also requires changes to the telemetry
driver in order for runtime pm to be handled correctly. These and other patches,
including a series to have all current aux drivers use the new drvdata helpers,
are waiting for this.

Quoted 5 lines

I can take the aux driver drvdata patch now, through my tree, if you want, no need to make it wait for this tiny driver.

Feel free to send it independant of the existing patchset, and with the cleanup patches at the same time, should be quite easy to get merged.

Quoted 7 lines

If you're going to take that one, can you perhaps take patches 1-3 for 5.17 through your tree as well (patch 3 depends on 2/it) ?

Note there is a v4 of this series, see please use that :)

I assume the follow up patches are also going to need patch 3 (the actual conversion of the driver to aux-bus).

Yes.

Quoted 1 line
Quoted 8 lines
Quoted 6 lines

Here is my Ack for the pdx86 bits in patch 3:

And patch 1 and 3 also have acks from the PCI resp. MFD subsys maintainers, so I guess taking this all upstream through your tree is fine.

Should I send 1-3 plus the drvdata cleanup patches I have to Grep? V5?

No there is no need for that v4 is fine, since no changes have been requested there is no need to send out a new version.

Regards,

Hans

maintainer
#16 lore raw

Re: [PATCH RESEND V2 3/6] platform/x86/intel: Move intel_pmt from MFD to Auxiliary Bus

Quoted 113 lines · Hans de Goede

Hi,

Quoted 110 lines · David E. Box
Quoted 94 lines · Hans de Goede

Hi,

Quoted 85 lines · Greg KH
Quoted 72 lines · David E. Box
Quoted 60 lines · Greg KH
Quoted 59 lines · David E. Box
Quoted 38 lines · Greg KH
Quoted 37 lines · David E. Box
Quoted 36 lines · Greg KH
Quoted 17 lines · David E. Box
Quoted 11 lines · Greg KH
Quoted 5 lines · David E. Box

+static struct pci_driver intel_vsec_pci_driver = {
+ .name = "intel_vsec",
+ .id_table = intel_vsec_pci_ids,
+ .probe = intel_vsec_pci_probe,
+};

So when the PCI device is removed from the system you leak resources and
have dangling devices?

No.

Quoted 1 line

Why no PCI remove driver callback?

Quoted 10 lines

After probe all resources are device managed. There's nothing to
explicitly clean up. When
the
PCI
device is removed, all aux devices are automatically removed. This
is the case for the SDSi
driver
as well.

Where is the "automatic cleanup" happening? As this pci driver is
bound
to the PCI device, when the device is removed, what is called in this
driver to remove the resources allocated in the probe callback?

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

confused,

devm_add_action_or_reset(&pdev->dev, intel_vsec_remove_aux, auxdev)

Wow that is opaque. Why not do it on remove instead?

This code is common for auxdev cleanup. AFAICT most auxiliary bus code is
done by drivers that have
some other primary function. They clean up their primary function resources
in remove, but they
clean up the auxdev using the method above. In this case the sole purpose of
this driver is to
create the auxdev. There are no other resources beyond what the auxdev is
using.

Quoted 8 lines
Quoted 3 lines

Adding runtime pm to the pci driver will change this. Remove will be needed
then.

And who will notice that being required when that happens?

Why is there no runtime PM for this driver? Do you not care about power consumption? :)

Of course. :)

Quoted 11 lines

There's a backlog of patches waiting for this series. One adds support for the
telemetry device (an auxdev) on the DG2 GPU. This device requires runtime pm in
order for the slot to go D3. But this also requires changes to the telemetry
driver in order for runtime pm to be handled correctly. These and other patches,
including a series to have all current aux drivers use the new drvdata helpers,
are waiting for this.

Quoted 5 lines

I can take the aux driver drvdata patch now, through my tree, if you want, no need to make it wait for this tiny driver.

Feel free to send it independant of the existing patchset, and with the cleanup patches at the same time, should be quite easy to get merged.

Quoted 7 lines

If you're going to take that one, can you perhaps take patches 1-3 for 5.17 through your tree as well (patch 3 depends on 2/it) ?

Note there is a v4 of this series, see please use that :)

I assume the follow up patches are also going to need patch 3 (the actual conversion of the driver to aux-bus).

Yes.

Quoted 5 lines

Here is my Ack for the pdx86 bits in patch 3:

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

And patch 1 and 3 also have acks from the PCI resp. MFD subsys maintainers, so I guess taking this all upstream through your tree is fine.

Should I send 1-3 plus the drvdata cleanup patches I have to Grep? V5?

No there is no need for that v4 is fine, since no changes have been requested there is no need to send out a new version.

I've taken patches 1-3 of this series now, thanks.

greg k-h

author maintainer
#17 lore raw

PATCH RESEND v2 4/6 platform/x86: Add Intel Software Defined Silicon driver

In reply to David E. Box

Intel Software Defined Silicon (SDSi) is a post manufacturing mechanism for activating additional silicon features. Features are enabled through a license activation process. The SDSi driver provides a per socket, sysfs attribute interface for applications to perform 3 main provisioning functions:

1. Provision an Authentication Key Certificate (AKC), a key written to internal NVRAM that is used to authenticate a capability specific activation payload.

2. Provision a Capability Activation Payload (CAP), a token authenticated using the AKC and applied to the CPU configuration to activate a new feature.

3. Read the SDSi State Certificate, containing the CPU configuration state.

The operations perform function specific mailbox commands that forward the requests to SDSi hardware to perform authentication of the payloads and enable the silicon configuration (to be made available after power cycling).

The SDSi device itself is enumerated as an auxiliary device from the intel_vsec driver and as such has a build dependency on CONFIG_INTEL_VSEC.

---
V2
- Use sysfs_emit() in guid_show()
- Fix language in ABI, suggested by Bjorn
- Fix wrong directory name in ABI doc

 .../ABI/testing/sysfs-driver-intel_sdsi       |  77 +++
 MAINTAINERS                                   |   5 +
 drivers/platform/x86/intel/Kconfig            |  12 +
 drivers/platform/x86/intel/Makefile           |   2 +
 drivers/platform/x86/intel/sdsi.c             | 571 ++++++++++++++++++
 drivers/platform/x86/intel/vsec.c             |  12 +-
 6 files changed, 678 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/ABI/testing/sysfs-driver-intel_sdsi
 create mode 100644 drivers/platform/x86/intel/sdsi.c
Documentation/ABI/testing/sysfs-driver-intel_sdsi new file +77 -0
new file mode 100644
index 000000000000..6544f35abb98
@@ -0,0 +1,77 @@
+What:		/sys/bus/auxiliary/devices/intel_vsec.sdsi.X
+Date:		Dec 2021
+KernelVersion:	5.17
+Contact:	"David E. Box" <[email protected]>
+Description:
+		This folder contains interface files for accessing Intel
+		Software Defined Silicon (SDSi) features on a CPU. X
+		represents the socket instance (though not the socket ID).
+		The socket ID is determined by reading the registers file
+		and decoding it per the specification.
+
+		Some files communicate with SDSi hardware through a mailbox.
+		Should the operation fail, one of the following error codes
+		may be returned:
+
+		Error Code	Cause
+	        ----------	-----
+	        EIO		General mailbox failure. Log may indicate cause.
+	        EBUSY		Mailbox is owned by another agent.
+	        EPERM		SDSI capability is not enabled in hardware.
+	        EPROTO		Failure in mailbox protocol detected by driver.
+				See log for details.
+	        EOVERFLOW	For provision commands, the size of the data
+				exceeds what may be written.
+	        ESPIPE		Seeking is not allowed.
+	        ETIMEDOUT	Failure to complete mailbox transaction in time.
+
+What:		/sys/bus/auxiliary/devices/intel_vsec.sdsi.X/guid
+Date:		Dec 2021
+KernelVersion:	5.17
+Contact:	"David E. Box" <[email protected]>
+Description:
+		(RO) The GUID for the registers file. The GUID identifies
+		the layout of the registers file in this folder.
+		Information about the register layouts for a particular GUID
+		is available at http://github.com/intel/intel-sdsi
+
+What:		/sys/bus/auxiliary/devices/intel_vsec.sdsi.X/registers
+Date:		Dec 2021
+KernelVersion:	5.17
+Contact:	"David E. Box" <[email protected]>
+Description:
+		(RO) Contains information needed by applications to provision
+		a CPU and monitor status information. The layout of this file
+		is determined by the GUID in this folder. Information about the
+		layout for a particular GUID is available at
+		http://github.com/intel/intel-sdsi
+
+What:		/sys/bus/auxiliary/devices/intel_vsec.sdsi.X/provision_akc
+Date:		Dec 2021
+KernelVersion:	5.17
+Contact:	"David E. Box" <[email protected]>
+Description:
+		(WO) Used to write an Authentication Key Certificate (AKC) to
+		the SDSi NVRAM for the CPU. The AKC is used to authenticate a
+		Capability Activation Payload. Mailbox command.
+
+What:		/sys/bus/auxiliary/devices/intel_vsec.sdsi.X/provision_cap
+Date:		Dec 2021
+KernelVersion:	5.17
+Contact:	"David E. Box" <[email protected]>
+Description:
+		(WO) Used to write a Capability Activation Payload (CAP) to the
+		SDSi NVRAM for the CPU. CAPs are used to activate a given CPU
+		feature. A CAP is validated by SDSi hardware using a previously
+		provisioned AKC file. Upon successful authentication, the CPU
+		configuration is updated. A cold reboot is required to fully
+		activate the feature. Mailbox command.
+
+What:		/sys/bus/auxiliary/devices/intel_vsec.sdsi.X/state_certificate
+Date:		Dec 2021
+KernelVersion:	5.17
+Contact:	"David E. Box" <[email protected]>
+Description:
+		(RO) Used to read back the current State Certificate for the CPU
+		from SDSi hardware. The State Certificate contains information
+		about the current licenses on the CPU. Mailbox command.
MAINTAINERS +5 -0
index cd2b10a86f09..af7f17e7400f 100644
@@ -9783,6 +9783,11 @@ S:	Maintained
 F:	arch/x86/include/asm/intel_scu_ipc.h
 F:	drivers/platform/x86/intel_scu_*
 
+INTEL SDSI DRIVER
+M:	David E. Box <[email protected]>
+S:	Supported
+F:	drivers/platform/x86/intel/sdsi.c
+
 INTEL SKYLAKE INT3472 ACPI DEVICE DRIVER
 M:	Daniel Scally <[email protected]>
 S:	Maintained
drivers/platform/x86/intel/Kconfig +12 -0
index 35a5d1a5eba8..0c24b626c6ed 100644
@@ -147,6 +147,18 @@ config INTEL_RST
 	  firmware will copy the memory contents back to RAM and resume the OS
 	  as usual.
 
+config INTEL_SDSI
+	tristate "Intel Software Defined Silicon Driver"
+	depends on INTEL_VSEC
+	depends on X86_64
+	help
+	  This driver enables access to the Intel Software Defined Silicon
+	  interface used to provision silicon features with an authentication
+	  certificate and capability license.
+
+	  To compile this driver as a module, choose M here: the module will
+	  be called intel_sdsi.
+
 config INTEL_SMARTCONNECT
 	tristate "Intel Smart Connect disabling driver"
 	depends on ACPI
drivers/platform/x86/intel/Makefile +2 -0
index 8ecdf709fb17..6a3a4510d89a 100644
@@ -26,6 +26,8 @@ intel_int0002_vgpio-y			:= int0002_vgpio.o
 obj-$(CONFIG_INTEL_INT0002_VGPIO)	+= intel_int0002_vgpio.o
 intel_oaktrail-y			:= oaktrail.o
 obj-$(CONFIG_INTEL_OAKTRAIL)		+= intel_oaktrail.o
+intel_sdsi-y				:= sdsi.o
+obj-$(CONFIG_INTEL_SDSI)		+= intel_sdsi.o
 intel_vsec-y				:= vsec.o
 obj-$(CONFIG_INTEL_VSEC)		+= intel_vsec.o
 
drivers/platform/x86/intel/sdsi.c new file +571 -0

571 lines not on this page · raw message

drivers/platform/x86/intel/vsec.c +11 -1
index c3bdd75ed690..bed436bf181f 100644
@@ -32,6 +32,7 @@
 #define TABLE_OFFSET_SHIFT		3
 
 static DEFINE_IDA(intel_vsec_ida);
+static DEFINE_IDA(intel_vsec_sdsi_ida);
 
 /**
  * struct intel_vsec_header - Common fields of Intel VSEC and DVSEC registers.
@@ -63,12 +64,14 @@ enum intel_vsec_id {
 	VSEC_ID_TELEMETRY	= 2,
 	VSEC_ID_WATCHER		= 3,
 	VSEC_ID_CRASHLOG	= 4,
+	VSEC_ID_SDSI		= 65,
 };
 
 static enum intel_vsec_id intel_vsec_allow_list[] = {
 	VSEC_ID_TELEMETRY,
 	VSEC_ID_WATCHER,
 	VSEC_ID_CRASHLOG,
+	VSEC_ID_SDSI,
 };
 
 static const char *intel_vsec_name(enum intel_vsec_id id)
@@ -83,6 +86,9 @@ static const char *intel_vsec_name(enum intel_vsec_id id)
 	case VSEC_ID_CRASHLOG:
 		return "crashlog";
 
+	case VSEC_ID_SDSI:
+		return "sdsi";
+
 	default:
 		return NULL;
 	}
@@ -211,7 +217,11 @@ static int intel_vsec_add_dev(struct pci_dev *pdev, struct intel_vsec_header *he
 	intel_vsec_dev->resource = res;
 	intel_vsec_dev->num_resources = header->num_entries;
 	intel_vsec_dev->quirks = quirks;
-	intel_vsec_dev->ida = &intel_vsec_ida;
+
+	if (header->id == VSEC_ID_SDSI)
+		intel_vsec_dev->ida = &intel_vsec_sdsi_ida;
+	else
+		intel_vsec_dev->ida = &intel_vsec_ida;
 
 	return intel_vsec_add_aux(pdev, intel_vsec_dev, intel_vsec_name(header->id));
 }
Signature · 1 line
2.25.1
maintainer
#18 lore raw

Re: [PATCH RESEND V2 4/6] platform/x86: Add Intel Software Defined Silicon driver

Quoted 34 lines · David E. Box

Intel Software Defined Silicon (SDSi) is a post manufacturing mechanism for activating additional silicon features. Features are enabled through a license activation process. The SDSi driver provides a per socket, sysfs attribute interface for applications to perform 3 main provisioning functions:

1. Provision an Authentication Key Certificate (AKC), a key written to internal NVRAM that is used to authenticate a capability specific activation payload.

2. Provision a Capability Activation Payload (CAP), a token authenticated using the AKC and applied to the CPU configuration to activate a new feature.

3. Read the SDSi State Certificate, containing the CPU configuration state.

The operations perform function specific mailbox commands that forward the requests to SDSi hardware to perform authentication of the payloads and enable the silicon configuration (to be made available after power cycling).

The SDSi device itself is enumerated as an auxiliary device from the intel_vsec driver and as such has a build dependency on CONFIG_INTEL_VSEC.

---
V2
- Use sysfs_emit() in guid_show()
- Fix language in ABI, suggested by Bjorn
- Fix wrong directory name in ABI doc

Quoted 9 lines
 .../ABI/testing/sysfs-driver-intel_sdsi       |  77 +++
 MAINTAINERS                                   |   5 +
 drivers/platform/x86/intel/Kconfig            |  12 +
 drivers/platform/x86/intel/Makefile           |   2 +
 drivers/platform/x86/intel/sdsi.c             | 571 ++++++++++++++++++
 drivers/platform/x86/intel/vsec.c             |  12 +-
 6 files changed, 678 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/ABI/testing/sysfs-driver-intel_sdsi
 create mode 100644 drivers/platform/x86/intel/sdsi.c

Again, no release functions?

odd.

maintainer
#19 lore raw

Re: [PATCH RESEND V2 4/6] platform/x86: Add Intel Software Defined Silicon driver

In reply to David E. Box
Quoted 22 lines · David E. Box

Intel Software Defined Silicon (SDSi) is a post manufacturing mechanism for activating additional silicon features. Features are enabled through a license activation process. The SDSi driver provides a per socket, sysfs attribute interface for applications to perform 3 main provisioning functions:

1. Provision an Authentication Key Certificate (AKC), a key written to internal NVRAM that is used to authenticate a capability specific activation payload.

2. Provision a Capability Activation Payload (CAP), a token authenticated using the AKC and applied to the CPU configuration to activate a new feature.

3. Read the SDSi State Certificate, containing the CPU configuration state.

The operations perform function specific mailbox commands that forward the requests to SDSi hardware to perform authentication of the payloads and enable the silicon configuration (to be made available after power cycling).

Quoted 4 lines

The SDSi device itself is enumerated as an auxiliary device from the intel_vsec driver and as such has a build dependency on CONFIG_INTEL_VSEC.

There is no code at this link :(

author maintainer
#20 lore raw

Re: [PATCH RESEND V2 4/6] platform/x86: Add Intel Software Defined Silicon driver

Quoted 23 lines · Greg KH
Quoted 22 lines · David E. Box

Intel Software Defined Silicon (SDSi) is a post manufacturing mechanism for activating additional silicon features. Features are enabled through a license activation process.  The SDSi driver provides a per socket, sysfs attribute interface for applications to perform 3 main provisioning functions:

1. Provision an Authentication Key Certificate (AKC), a key written to internal NVRAM that is used to authenticate a capability specific activation payload.

2. Provision a Capability Activation Payload (CAP), a token authenticated using the AKC and applied to the CPU configuration to activate a new feature.

3. Read the SDSi State Certificate, containing the CPU configuration state.

The operations perform function specific mailbox commands that forward the requests to SDSi hardware to perform authentication of the payloads and enable the silicon configuration (to be made available after power cycling).

Quoted 7 lines
Quoted 4 lines

The SDSi device itself is enumerated as an auxiliary device from the intel_vsec driver and as such has a build dependency on CONFIG_INTEL_VSEC.

There is no code at this link :(

Not yet. It's currently just documentation. But sample code was added to this patch series.

maintainer
#21 lore raw

Re: [PATCH RESEND V2 4/6] platform/x86: Add Intel Software Defined Silicon driver

Quoted 27 lines · David E. Box
Quoted 26 lines · Greg KH
Quoted 25 lines · David E. Box

Intel Software Defined Silicon (SDSi) is a post manufacturing mechanism for activating additional silicon features. Features are enabled through a license activation process.  The SDSi driver provides a per socket, sysfs attribute interface for applications to perform 3 main provisioning functions:

1. Provision an Authentication Key Certificate (AKC), a key written to internal NVRAM that is used to authenticate a capability specific activation payload.

2. Provision a Capability Activation Payload (CAP), a token authenticated using the AKC and applied to the CPU configuration to activate a new feature.

3. Read the SDSi State Certificate, containing the CPU configuration state.

The operations perform function specific mailbox commands that forward the requests to SDSi hardware to perform authentication of the payloads and enable the silicon configuration (to be made available after power cycling).

The SDSi device itself is enumerated as an auxiliary device from the intel_vsec driver and as such has a build dependency on CONFIG_INTEL_VSEC.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

There is no code at this link :(

Not yet. It's currently just documentation. But sample code was added to this patch series.

Is the sample code "real" and what you are going to use for this api?

thanks,

greg k-h

author maintainer
#22 lore raw

Re: [PATCH RESEND V2 4/6] platform/x86: Add Intel Software Defined Silicon driver

Quoted 28 lines · Greg KH
Quoted 27 lines · David E. Box
Quoted 26 lines · Greg KH
Quoted 25 lines · David E. Box

Intel Software Defined Silicon (SDSi) is a post manufacturing mechanism for activating additional silicon features. Features are enabled through a license activation process.  The SDSi driver provides a per socket, sysfs attribute interface for applications to perform 3 main provisioning functions:

1. Provision an Authentication Key Certificate (AKC), a key written to internal NVRAM that is used to authenticate a capability specific activation payload.

2. Provision a Capability Activation Payload (CAP), a token authenticated using the AKC and applied to the CPU configuration to activate a new feature.

3. Read the SDSi State Certificate, containing the CPU configuration state.

The operations perform function specific mailbox commands that forward the requests to SDSi hardware to perform authentication of the payloads and enable the silicon configuration (to be made available after power cycling).

The SDSi device itself is enumerated as an auxiliary device from the intel_vsec driver and as such has a build dependency on CONFIG_INTEL_VSEC.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

There is no code at this link :(

Not yet. It's currently just documentation. But sample code was added to this patch series.

Is the sample code "real" and what you are going to use for this api?

It's real in that it could be used to provision real certificates on a production system.

David

Quoted 4 lines

thanks,

greg k-h

maintainer
#23 lore raw

Re: [PATCH RESEND V2 4/6] platform/x86: Add Intel Software Defined Silicon driver

Quoted 31 lines · David E. Box
Quoted 30 lines · Greg KH
Quoted 29 lines · David E. Box
Quoted 28 lines · Greg KH
Quoted 26 lines · David E. Box

Intel Software Defined Silicon (SDSi) is a post manufacturing mechanism for activating additional silicon features. Features are enabled through a license activation process.  The SDSi driver provides a per socket, sysfs attribute interface for applications to perform 3 main provisioning functions:

1. Provision an Authentication Key Certificate (AKC), a key written to internal NVRAM that is used to authenticate a capability specific activation payload.

2. Provision a Capability Activation Payload (CAP), a token authenticated using the AKC and applied to the CPU configuration to activate a new feature.

3. Read the SDSi State Certificate, containing the CPU configuration state.

The operations perform function specific mailbox commands that forward the requests to SDSi hardware to perform authentication of the payloads and enable the silicon configuration (to be made available after power cycling).

The SDSi device itself is enumerated as an auxiliary device from the intel_vsec driver and as such has a build dependency on CONFIG_INTEL_VSEC.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

There is no code at this link :(

Not yet. It's currently just documentation. But sample code was added to this patch series.

Is the sample code "real" and what you are going to use for this api?

It's real in that it could be used to provision real certificates on a production system.

Great, so it's all you need, you should move it to tools/ and be done with it! :)

thanks,

greg k-h

maintainer
#24 lore raw

Re: [PATCH RESEND V2 4/6] platform/x86: Add Intel Software Defined Silicon driver

In reply to David E. Box
Quoted 22 lines · David E. Box

Intel Software Defined Silicon (SDSi) is a post manufacturing mechanism for activating additional silicon features. Features are enabled through a license activation process. The SDSi driver provides a per socket, sysfs attribute interface for applications to perform 3 main provisioning functions:

1. Provision an Authentication Key Certificate (AKC), a key written to internal NVRAM that is used to authenticate a capability specific activation payload.

2. Provision a Capability Activation Payload (CAP), a token authenticated using the AKC and applied to the CPU configuration to activate a new feature.

3. Read the SDSi State Certificate, containing the CPU configuration state.

The operations perform function specific mailbox commands that forward the requests to SDSi hardware to perform authentication of the payloads and enable the silicon configuration (to be made available after power cycling).

Quoted 4 lines

The SDSi device itself is enumerated as an auxiliary device from the intel_vsec driver and as such has a build dependency on CONFIG_INTEL_VSEC.

Also, why not put the documentation that you have currently at that link in this commit in the driver itself? That would make it much more self-contained and live longer than some random external web link that could go away at any moment.

thanks,

greg k-h

author maintainer
#25 lore raw

Re: [PATCH RESEND V2 4/6] platform/x86: Add Intel Software Defined Silicon driver

Quoted 26 lines · Greg KH
Quoted 25 lines · David E. Box

Intel Software Defined Silicon (SDSi) is a post manufacturing mechanism for activating additional silicon features. Features are enabled through a license activation process.  The SDSi driver provides a per socket, sysfs attribute interface for applications to perform 3 main provisioning functions:

1. Provision an Authentication Key Certificate (AKC), a key written to internal NVRAM that is used to authenticate a capability specific activation payload.

2. Provision a Capability Activation Payload (CAP), a token authenticated using the AKC and applied to the CPU configuration to activate a new feature.

3. Read the SDSi State Certificate, containing the CPU configuration state.

The operations perform function specific mailbox commands that forward the requests to SDSi hardware to perform authentication of the payloads and enable the silicon configuration (to be made available after power cycling).

The SDSi device itself is enumerated as an auxiliary device from the intel_vsec driver and as such has a build dependency on CONFIG_INTEL_VSEC.

Quoted 6 lines
Quoted 1 line

Also, why not put the documentation that you have currently at that link in this commit in the driver itself?  That would make it much more self-contained and live longer than some random external web link that could go away at any moment.

The documentation describes the hardware interface only. It's not OS specific so it was easier to add a link. But there's no problem adding a copy to Documentaion in the kernel.

David

Quoted 4 lines

thanks,

greg k-h

#26 lore raw

Re: [PATCH RESEND V2 4/6] platform/x86: Add Intel Software Defined Silicon driver

In reply to David E. Box

Documentation/ABI/testing/sysfs-driver-intel_sdsi line 6

Quoted 1 line · David E. Box
Documentation/ABI/testing/sysfs-driver-intel_sdsi new file +1 -0
+		This folder contains interface files for accessing Intel

s/folder/directory ?

author maintainer
#27 lore raw

PATCH RESEND v2 5/6 sample/sdsi: Sample of SDSi provisiong using sysfs

In reply to David E. Box

Sample application showing usage of Intel Software Defined Silicon sysfs ABI.

---
V2
- New patch

 MAINTAINERS                |   1 +
 samples/sdsi/Makefile      |   9 +
 samples/sdsi/sdsi-sample.c | 399 +++++++++++++++++++++++++++++++++++++
 3 files changed, 409 insertions(+)
 create mode 100644 samples/sdsi/Makefile
 create mode 100644 samples/sdsi/sdsi-sample.c
MAINTAINERS +1 -0
index af7f17e7400f..ba9603fb7f62 100644
@@ -9787,6 +9787,7 @@ INTEL SDSI DRIVER
 M:	David E. Box <[email protected]>
 S:	Supported
 F:	drivers/platform/x86/intel/sdsi.c
+F:	samples/sdsi/
 
 INTEL SKYLAKE INT3472 ACPI DEVICE DRIVER
 M:	Daniel Scally <[email protected]>
samples/sdsi/Makefile new file +9 -0
new file mode 100644
index 000000000000..17ac82a5623d
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: GPL-2.0
+
+.PHONY: sdsi-sample
+
+sdsi-sample: sdsi-sample.o
+	$(CC) -Wall $^ -o $@
+
+clean:
+	rm *.o sdsi-sample
samples/sdsi/sdsi-sample.c new file +399 -0

399 lines not on this page · raw message

Signature · 1 line
2.25.1
author maintainer
#28 lore raw

PATCH RESEND v2 6/6 selftests: sdsi: test sysfs setup

In reply to David E. Box

Tests file configuration and error handling of the Intel Software Defined Silicon sysfs ABI.

---
V2
- New patch

 MAINTAINERS                                   |   1 +
 tools/testing/selftests/drivers/sdsi/sdsi.sh  |  18 ++
 .../selftests/drivers/sdsi/sdsi_test.py       | 166 ++++++++++++++++++
 3 files changed, 185 insertions(+)
 create mode 100755 tools/testing/selftests/drivers/sdsi/sdsi.sh
 create mode 100644 tools/testing/selftests/drivers/sdsi/sdsi_test.py
MAINTAINERS +1 -0
index ba9603fb7f62..3bc2a7bff168 100644
@@ -9788,6 +9788,7 @@ M:	David E. Box <[email protected]>
 S:	Supported
 F:	drivers/platform/x86/intel/sdsi.c
 F:	samples/sdsi/
+F:	tools/testing/selftests/drivers/sdsi/
 
 INTEL SKYLAKE INT3472 ACPI DEVICE DRIVER
 M:	Daniel Scally <[email protected]>
tools/testing/selftests/drivers/sdsi/sdsi.sh new file +18 -0
new file mode 100755
index 000000000000..8db71961d164
@@ -0,0 +1,18 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+# Runs tests for the intel_sdsi driver
+
+if ! /sbin/modprobe -q -r intel_sdsi; then
+	echo "drivers/sdsi: [SKIP]"
+	exit 77
+fi
+
+if /sbin/modprobe -q intel_sdsi; then
+	python3 -m pytest sdsi_test.py
+	/sbin/modprobe -q -r intel_sdsi
+
+	echo "drivers/sdsi: ok"
+else
+	echo "drivers/sdsi: [FAIL]"
+	exit 1
+fi
tools/testing/selftests/drivers/sdsi/sdsi_test.py new file +166 -0

166 lines not on this page · raw message

Signature · 1 line
2.25.1