2022-06-29 22:15:30

by Gayatri Kammela

[permalink] [raw]
Subject: [PATCH v1 0/4] Add Raptor Lake and PCI error recovery support

Hi,

This patch set adds Raptor Lake support as well as PCI error recovery
support to PMT driver. It also has a rework patch and a fix for fixed
region handling.

Patch 1: Rework early hardware code
Patch 2: Add support for Raptor Lake
Patch 3: Fix fixed region handling
Patch 4: Add PCI error recovery support to Intel PMT

David E. Box (3):
platform/x86/intel/vsec: Rework early hardware code
platform/x86/intel/vsec: Add support for Raptor Lake
platform/x86/intel/pmt: telemetry: Fix fixed region handling

Gayatri Kammela (1):
platform/x86/intel/vsec: Add PCI error recovery support to Intel PMT

drivers/platform/x86/intel/pmt/class.c | 23 ++--
drivers/platform/x86/intel/pmt/telemetry.c | 18 ++-
drivers/platform/x86/intel/vsec.c | 130 ++++++++++++++++-----
drivers/platform/x86/intel/vsec.h | 11 +-
4 files changed, 136 insertions(+), 46 deletions(-)


base-commit: 03c765b0e3b4cb5063276b086c76f7a612856a9a
--
2.32.0


2022-06-29 22:15:43

by Gayatri Kammela

[permalink] [raw]
Subject: [PATCH v1 2/4] platform/x86/intel/vsec: Add support for Raptor Lake

From: "David E. Box" <[email protected]>

Add Raptor Lake support to Intel's PMT driver.

Cc: Srinivas Pandruvada <[email protected]>
Signed-off-by: David E. Box <[email protected]>
Signed-off-by: Gayatri Kammela <[email protected]>
---
drivers/platform/x86/intel/vsec.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/platform/x86/intel/vsec.c b/drivers/platform/x86/intel/vsec.c
index d48df46e2e27..9368a3d587ab 100644
--- a/drivers/platform/x86/intel/vsec.c
+++ b/drivers/platform/x86/intel/vsec.c
@@ -394,11 +394,13 @@ static const struct intel_vsec_platform_info dg1_info = {
#define PCI_DEVICE_ID_INTEL_VSEC_ADL 0x467d
#define PCI_DEVICE_ID_INTEL_VSEC_DG1 0x490e
#define PCI_DEVICE_ID_INTEL_VSEC_OOBMSM 0x09a7
+#define PCI_DEVICE_ID_INTEL_VSEC_RPL 0xa77d
#define PCI_DEVICE_ID_INTEL_VSEC_TGL 0x9a0d
static const struct pci_device_id intel_vsec_pci_ids[] = {
{ PCI_DEVICE_DATA(INTEL, VSEC_ADL, &tgl_info) },
{ PCI_DEVICE_DATA(INTEL, VSEC_DG1, &dg1_info) },
{ PCI_DEVICE_DATA(INTEL, VSEC_OOBMSM, &(struct intel_vsec_platform_info) {}) },
+ { PCI_DEVICE_DATA(INTEL, VSEC_RPL, &tgl_info) },
{ PCI_DEVICE_DATA(INTEL, VSEC_TGL, &tgl_info) },
{ }
};
--
2.32.0

2022-06-29 22:16:33

by Gayatri Kammela

[permalink] [raw]
Subject: [PATCH v1 4/4] platform/x86/intel/vsec: Add PCI error recovery support to Intel PMT

Add PCI error recovery support for Intel PMT driver to recover
from PCI fatal errors

Cc: Srinivas Pandruvada <[email protected]>
Cc: David E Box <[email protected]>
Signed-off-by: Gayatri Kammela <[email protected]>
---
drivers/platform/x86/intel/vsec.c | 82 ++++++++++++++++++++++++++++++-
1 file changed, 80 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/intel/vsec.c b/drivers/platform/x86/intel/vsec.c
index 9368a3d587ab..544493ae85b7 100644
--- a/drivers/platform/x86/intel/vsec.c
+++ b/drivers/platform/x86/intel/vsec.c
@@ -15,6 +15,7 @@

#include <linux/auxiliary_bus.h>
#include <linux/bits.h>
+#include <linux/delay.h>
#include <linux/kernel.h>
#include <linux/idr.h>
#include <linux/module.h>
@@ -30,9 +31,13 @@
#define INTEL_DVSEC_TABLE_BAR(x) ((x) & GENMASK(2, 0))
#define INTEL_DVSEC_TABLE_OFFSET(x) ((x) & GENMASK(31, 3))
#define TABLE_OFFSET_SHIFT 3
+#define PMT_XA_START 0
+#define PMT_XA_MAX INT_MAX
+#define PMT_XA_LIMIT XA_LIMIT(PMT_XA_START, PMT_XA_MAX)

static DEFINE_IDA(intel_vsec_ida);
static DEFINE_IDA(intel_vsec_sdsi_ida);
+static DEFINE_XARRAY_ALLOC(auxdev_array);

/**
* struct intel_vsec_header - Common fields of Intel VSEC and DVSEC registers.
@@ -132,7 +137,7 @@ static int intel_vsec_add_aux(struct pci_dev *pdev, struct intel_vsec_device *in
const char *name)
{
struct auxiliary_device *auxdev = &intel_vsec_dev->auxdev;
- int ret;
+ int ret, id;

ret = ida_alloc(intel_vsec_dev->ida, GFP_KERNEL);
if (ret < 0) {
@@ -159,7 +164,18 @@ static int intel_vsec_add_aux(struct pci_dev *pdev, struct intel_vsec_device *in
return ret;
}

- return devm_add_action_or_reset(&pdev->dev, intel_vsec_remove_aux, auxdev);
+ ret = devm_add_action_or_reset(&pdev->dev, intel_vsec_remove_aux,
+ auxdev);
+ if (ret < 0)
+ return ret;
+
+ /* Add auxdev to list */
+ ret = xa_alloc(&auxdev_array, &id, intel_vsec_dev, PMT_XA_LIMIT,
+ GFP_KERNEL);
+ if (ret)
+ return ret;
+
+ return 0;
}

static int intel_vsec_add_dev(struct pci_dev *pdev, struct intel_vsec_header *header,
@@ -345,6 +361,7 @@ static int intel_vsec_pci_probe(struct pci_dev *pdev, const struct pci_device_id
if (ret)
return ret;

+ pci_save_state(pdev);
info = (struct intel_vsec_platform_info *)id->driver_data;
if (!info)
return -EINVAL;
@@ -406,10 +423,71 @@ static const struct pci_device_id intel_vsec_pci_ids[] = {
};
MODULE_DEVICE_TABLE(pci, intel_vsec_pci_ids);

+static pci_ers_result_t intel_vsec_pci_error_detected(struct pci_dev *pdev,
+ pci_channel_state_t state)
+{
+ pci_channel_state_t status = PCI_ERS_RESULT_NEED_RESET;
+
+ dev_info(&pdev->dev, "PCI error detected, state %d", state);
+
+ if (state == pci_channel_io_perm_failure)
+ status = PCI_ERS_RESULT_DISCONNECT;
+ else
+ pci_disable_device(pdev);
+
+ return status;
+}
+
+static pci_ers_result_t intel_vsec_pci_slot_reset(struct pci_dev *pdev)
+{
+ struct intel_vsec_device *intel_vsec_dev;
+ pci_channel_state_t status = PCI_ERS_RESULT_DISCONNECT;
+ const struct pci_device_id *pci_dev_id;
+ unsigned long index;
+
+ dev_info(&pdev->dev, "Resetting PCI slot\n");
+
+ msleep(2000);
+ if (pci_enable_device(pdev)) {
+ dev_info(&pdev->dev,
+ "Failed to re-enable PCI device after reset.\n");
+ goto out;
+ }
+
+ status = PCI_ERS_RESULT_RECOVERED;
+
+ xa_for_each(&auxdev_array, index, intel_vsec_dev) {
+ /* check if pdev doesn't match */
+ if (pdev != intel_vsec_dev->pcidev)
+ continue;
+ devm_release_action(&pdev->dev, intel_vsec_remove_aux,
+ &intel_vsec_dev->auxdev);
+ }
+ pci_disable_device(pdev);
+ pci_restore_state(pdev);
+ pci_dev_id = pci_match_id(intel_vsec_pci_ids, pdev);
+ intel_vsec_pci_probe(pdev, pci_dev_id);
+
+out:
+ return status;
+}
+
+void intel_vsec_pci_resume(struct pci_dev *pdev)
+{
+ dev_info(&pdev->dev, "Done resuming PCI device\n");
+}
+
+const struct pci_error_handlers intel_vsec_pci_err_handlers = {
+ .error_detected = intel_vsec_pci_error_detected,
+ .slot_reset = intel_vsec_pci_slot_reset,
+ .resume = intel_vsec_pci_resume,
+};
+
static struct pci_driver intel_vsec_pci_driver = {
.name = "intel_vsec",
.id_table = intel_vsec_pci_ids,
.probe = intel_vsec_pci_probe,
+ .err_handler = &intel_vsec_pci_err_handlers,
};
module_pci_driver(intel_vsec_pci_driver);

--
2.32.0

2022-06-29 22:28:51

by Gayatri Kammela

[permalink] [raw]
Subject: [PATCH v1 3/4] platform/x86/intel/pmt: telemetry: Fix fixed region handling

From: "David E. Box" <[email protected]>

Use the telem_type and the fixed block guid to determine if an entry is a
fixed region. For certain platforms we don't support this.

Cc: Srinivas Pandruvada <[email protected]>
Signed-off-by: David E. Box <[email protected]>
Signed-off-by: Gayatri Kammela <[email protected]>
---
drivers/platform/x86/intel/pmt/telemetry.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/platform/x86/intel/pmt/telemetry.c b/drivers/platform/x86/intel/pmt/telemetry.c
index f73ecfd4a309..5e4009c05ecf 100644
--- a/drivers/platform/x86/intel/pmt/telemetry.c
+++ b/drivers/platform/x86/intel/pmt/telemetry.c
@@ -23,12 +23,19 @@
#define TELEM_GUID_OFFSET 0x4
#define TELEM_BASE_OFFSET 0x8
#define TELEM_ACCESS(v) ((v) & GENMASK(3, 0))
+#define TELEM_TYPE(v) (((v) & GENMASK(7, 4)) >> 4)
/* size is in bytes */
#define TELEM_SIZE(v) (((v) & GENMASK(27, 12)) >> 10)

/* Used by client hardware to identify a fixed telemetry entry*/
#define TELEM_CLIENT_FIXED_BLOCK_GUID 0x10000000

+enum telem_type {
+ TELEM_TYPE_PUNIT = 0,
+ TELEM_TYPE_CRASHLOG,
+ TELEM_TYPE_PUNIT_FIXED,
+};
+
struct pmt_telem_priv {
int num_entries;
struct intel_pmt_entry entry[];
@@ -39,10 +46,15 @@ static bool pmt_telem_region_overlaps(struct intel_pmt_entry *entry,
{
u32 guid = readl(entry->disc_table + TELEM_GUID_OFFSET);

- if (guid != TELEM_CLIENT_FIXED_BLOCK_GUID)
- return false;
+ if (intel_pmt_is_early_client_hw(dev)) {
+ u32 type = TELEM_TYPE(readl(entry->disc_table));
+
+ if ((type == TELEM_TYPE_PUNIT_FIXED) ||
+ (guid == TELEM_CLIENT_FIXED_BLOCK_GUID))
+ return true;
+ }

- return intel_pmt_is_early_client_hw(dev);
+ return false;
}

static int pmt_telem_header_decode(struct intel_pmt_entry *entry,
--
2.32.0

2022-07-02 09:58:26

by Hans de Goede

[permalink] [raw]
Subject: Re: [PATCH v1 0/4] Add Raptor Lake and PCI error recovery support

Hi,

On 6/30/22 00:13, Gayatri Kammela wrote:
> Hi,
>
> This patch set adds Raptor Lake support as well as PCI error recovery
> support to PMT driver. It also has a rework patch and a fix for fixed
> region handling.
>
> Patch 1: Rework early hardware code
> Patch 2: Add support for Raptor Lake
> Patch 3: Fix fixed region handling
> Patch 4: Add PCI error recovery support to Intel PMT

Thank you for your patch-series, I've applied the series to my
review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Note it will show up in my review-hans branch once I've pushed my
local branch there, which might take a while.

Once I've run some tests on this branch the patches there will be
added to the platform-drivers-x86/for-next branch and eventually
will be included in the pdx86 pull-request to Linus for the next
merge-window.

Regards,

Hans


>
> David E. Box (3):
> platform/x86/intel/vsec: Rework early hardware code
> platform/x86/intel/vsec: Add support for Raptor Lake
> platform/x86/intel/pmt: telemetry: Fix fixed region handling
>
> Gayatri Kammela (1):
> platform/x86/intel/vsec: Add PCI error recovery support to Intel PMT
>
> drivers/platform/x86/intel/pmt/class.c | 23 ++--
> drivers/platform/x86/intel/pmt/telemetry.c | 18 ++-
> drivers/platform/x86/intel/vsec.c | 130 ++++++++++++++++-----
> drivers/platform/x86/intel/vsec.h | 11 +-
> 4 files changed, 136 insertions(+), 46 deletions(-)
>
>
> base-commit: 03c765b0e3b4cb5063276b086c76f7a612856a9a

2022-07-05 20:19:46

by Gayatri Kammela

[permalink] [raw]
Subject: Re: [PATCH v1 0/4] Add Raptor Lake and PCI error recovery support

On 7/2/2022 2:54 AM, Hans de Goede wrote:

> Hi,
>
> On 6/30/22 00:13, Gayatri Kammela wrote:
>> Hi,
>>
>> This patch set adds Raptor Lake support as well as PCI error recovery
>> support to PMT driver. It also has a rework patch and a fix for fixed
>> region handling.
>>
>> Patch 1: Rework early hardware code
>> Patch 2: Add support for Raptor Lake
>> Patch 3: Fix fixed region handling
>> Patch 4: Add PCI error recovery support to Intel PMT
> Thank you for your patch-series, I've applied the series to my
> review-hans branch:
> https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans
>
> Note it will show up in my review-hans branch once I've pushed my
> local branch there, which might take a while.
>
> Once I've run some tests on this branch the patches there will be
> added to the platform-drivers-x86/for-next branch and eventually
> will be included in the pdx86 pull-request to Linus for the next
> merge-window.
>
> Regards,
>
> Hans
>
Thank you Hans!
>> David E. Box (3):
>> platform/x86/intel/vsec: Rework early hardware code
>> platform/x86/intel/vsec: Add support for Raptor Lake
>> platform/x86/intel/pmt: telemetry: Fix fixed region handling
>>
>> Gayatri Kammela (1):
>> platform/x86/intel/vsec: Add PCI error recovery support to Intel PMT
>>
>> drivers/platform/x86/intel/pmt/class.c | 23 ++--
>> drivers/platform/x86/intel/pmt/telemetry.c | 18 ++-
>> drivers/platform/x86/intel/vsec.c | 130 ++++++++++++++++-----
>> drivers/platform/x86/intel/vsec.h | 11 +-
>> 4 files changed, 136 insertions(+), 46 deletions(-)
>>
>>
>> base-commit: 03c765b0e3b4cb5063276b086c76f7a612856a9a