platform/x86/intel/vsec: reset state before re-enumerating
PATCH 1/1 platform/x86/intel/vsec: reset state before re-enumerating
The change referenced by the Fixes tag split the VSEC enumeration logic out of intel_vsec_pci_probe() and made PCIe error recovery call intel_vsec_pci_init() directly. This avoids another pcim_enable_device() devm action and another devm allocation during slot reset, but it also means that error recovery reuses the priv structure allocated by probe.
On the initial probe, priv is zeroed by devm_kzalloc(), so state[], suppliers[] and found_caps start from their initial values. During slot reset, the existing aux devices are removed before re-enumerating, but the reused priv still records the old devices as registered and the old capabilities as found.
The next intel_vsec_pci_init() call can therefore short-circuit in intel_vsec_register_device() with -EEXIST, or stop early because found_caps already matches info->caps. The aux devices removed during slot reset are then not recreated, leaving VSEC functionality missing after PCIe error recovery.
Reset the VSEC registration state after removing the old aux devices and before re-enumerating them.
--- drivers/platform/x86/intel/vsec.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/platform/x86/intel/vsec.c +15 -0
@@ -51,6 +51,13 @@ struct vsec_priv {unsigned long found_caps; }; +static void intel_vsec_reset_state (struct vsec_priv *priv) +{ +memset (priv->suppliers,0 ,sizeof (priv->suppliers)); +memset (priv->state,0 ,sizeof (priv->state)); + priv->found_caps =0 ; +} +static const char *intel_vsec_name (enum intel_vsec_id id) {switch (id) {
@@ -850,6 +857,7 @@ static pci_ers_result_t intel_vsec_pci_slot_reset(struct pci_dev *pdev) {struct intel_vsec_device *intel_vsec_dev;pci_ers_result_t status =PCI_ERS_RESULT_DISCONNECT ; +struct vsec_priv *priv =pci_get_drvdata (pdev);unsigned long index;dev_info (&pdev->dev,"Resetting PCI slot\n" );
@@ -870,6 +878,13 @@ static pci_ers_result_t intel_vsec_pci_slot_reset(struct pci_dev *pdev)devm_release_action (&pdev->dev, intel_vsec_remove_aux, &intel_vsec_dev->auxdev); } + +/* +* intel_vsec_pci_init() reuses priv. Reset the registration state +* after tearing down old aux devices or the rewalk will skip them as +* already registered. +*/ +intel_vsec_reset_state (priv);pci_restore_state (pdev);intel_vsec_pci_init (pdev);
Signature · 1 line
2.43.0
drivers/platform/x86/intel/vsec.c struct vsec_priv { · line 59
Quoted 11 lines · Guangshuo Li
+++
b/drivers/platform/x86/intel/vsec.cdrivers/platform/x86/intel/vsec.c +6
-0@@ -51,6 +51,13 @@ struct vsec_priv {unsigned long found_caps; }; +static void intel_vsec_reset_state (struct vsec_priv *priv) +{ +memset (priv->suppliers,0 ,sizeof (priv->suppliers)); +memset (priv->state,0 ,sizeof (priv->state)); + priv->found_caps =0 ; +}
Seems fragile to selectively zero only portions of struct vsec_priv. If the struct is amended later on with additional fields, it's quite possible that nobody thinks about zeroing them here.
It's probably more robust to zero the entire struct and re-populate the info field.
I also don't think a separate function to reset the struct is necessary as I don't expect additional callers down the road. So I suggest zeroing the struct inline in intel_vsec_pci_slot_reset().
@David Box: I've asked off-list for reset recovery to be tested, I'm hereby renewing that request. See section "Software error injection"
in: Documentation/PCI/pcieaer-howto.rst
Thanks,
Lukas
David Box
maintainerQuoted 20 lines · Lukas Wunner
drivers/platform/x86/intel/vsec.c struct vsec_priv { · line 59
Quoted 11 lines · Guangshuo Li
+++
b/drivers/platform/x86/intel/vsec.cdrivers/platform/x86/intel/vsec.c +6
-0@@ -51,6 +51,13 @@ struct vsec_priv {unsigned long found_caps; }; +static void intel_vsec_reset_state (struct vsec_priv *priv) +{ +memset (priv->suppliers,0 ,sizeof (priv->suppliers)); +memset (priv->state,0 ,sizeof (priv->state)); + priv->found_caps =0 ; +}Seems fragile to selectively zero only portions of struct
vsec_priv. If the struct is amended later on with additional fields, it's quite possible that nobody thinks about zeroing them here.It's probably more robust to zero the entire struct and re-populate the info field.
Quoted 7 lines
I also don't think a separate function to reset the struct is necessary as I don't expect additional callers down the road. So I suggest zeroing the struct inline in
intel_vsec_pci_slot_reset().@David Box: I've asked off-list for reset recovery to be tested, I'm hereby renewing that request. See section "Software error injection"
in:Documentation/PCI/pcieaer-howto.rst
We'll do the test and let you know. Thanks.
David
Hi Lukas,
I've performed a reset recovery test on an Intel Ponte Vecchio machine with an OOBMSM PCIe function that vsec binds to. I injected the following unrecoverable error into the bus with aer-inject:
# fatal.aer AER DOMAIN 0x0 BUS 0x84 DEV 0x0 FN 0 UNCOR_STATUS MALF_TLP HEADER_LOG 0 0 0 0
Running in Bash:
gta@DUT10580PVC:~$ sudo ./aer-inject/aer-inject -s 0000:82:02.0 fatal.aer
Without the patch, the associated PMT telemetry endpoints don't come back.
gta@DUT10580PVC:~$ ls -l /sys/class/intel_pmt/ | grep -E 'telem[456]' gta@DUT10580PVC:~$ # no output
With the patch that adds a intel_vsec_reset_state call, they do come back after injecting the error:
gta@DUT10580PVC:~$ ls -l /sys/class/intel_pmt/ | grep -E 'telem[456]' lrwxrwxrwx 1 root root 0 Aug 3 21:32 telem4 -> ../../devices/pci0000:80/0000:80:05.0/0000:81:00.0/0000:82:02.0/0000:84:00.1/intel_vsec.telemetry.1/intel_pmt/telem4
lrwxrwxrwx 1 root root 0 Aug 3 21:32 telem5 -> ../../devices/pci0000:80/0000:80:05.0/0000:81:00.0/0000:82:02.0/0000:84:00.1/intel_vsec.telemetry.1/intel_pmt/telem5
lrwxrwxrwx 1 root root 0 Aug 3 21:32 telem6 -> ../../devices/pci0000:80/0000:80:05.0/0000:81:00.0/0000:82:02.0/0000:84:00.1/intel_vsec.telemetry.1/intel_pmt/telem6
Best,
Mike Bottini
Quoted 30 lines · David Box
Quoted 19 lines · Lukas Wunner
drivers/platform/x86/intel/vsec.c struct vsec_priv { · line 59
Quoted 11 lines · Guangshuo Li
+++
b/drivers/platform/x86/intel/vsec.cdrivers/platform/x86/intel/vsec.c +6
-0@@ -51,6 +51,13 @@ struct vsec_priv {unsigned long found_caps; }; +static void intel_vsec_reset_state (struct vsec_priv *priv) +{ +memset (priv->suppliers,0 ,sizeof (priv->suppliers)); +memset (priv->state,0 ,sizeof (priv->state)); + priv->found_caps =0 ; +}Seems fragile to selectively zero only portions of struct
vsec_priv. If the struct is amended later on with additional fields, it's quite possible that nobody thinks about zeroing them here.It's probably more robust to zero the entire struct and re-populate the info field.
Quoted 7 lines
I also don't think a separate function to reset the struct is necessary as I don't expect additional callers down the road. So I suggest zeroing the struct inline in
intel_vsec_pci_slot_reset().@David Box: I've asked off-list for reset recovery to be tested, I'm hereby renewing that request. See section "Software error injection"
in:Documentation/PCI/pcieaer-howto.rstWe'll do the test and let you know. Thanks.
David
Ilpo Järvinen
maintainerQuoted 6 lines · Guangshuo Li
The change referenced by the Fixes tag split the VSEC enumeration logic out of
intel_vsec_pci_probe()and made PCIe error recovery callintel_vsec_pci_init()directly. This avoids anotherpcim_enable_device()devm action and another devm allocation during slot reset, but it also means that error recovery reuses the priv structure allocated by probe.
Quoted 7 lines
On the initial probe, priv is zeroed by
devm_kzalloc(), so state[], suppliers[] andfound_capsstart from their initial values. During slot reset, the existing aux devices are removed before re-enumerating, but the reused priv still records the old devices as registered and the old capabilities as found.[...]
Thank you for your contribution, it has been applied to my local review-ilpo-next branch. Note it will show up in the public platform-drivers-x86/review-ilpo-next branch only once I've pushed my local branch there, which might take a while.
FYI [if applicable to your patch], as per Linus' policy change, also fixes are mostly routed through for-next unless the fix is for a commit introduced in the most recent cycle or is clearly a regression fix.
The list of commits applied:
[1/1] platform/x86/intel/vsec: reset state before re-enumerating
commit: 34744f72e1b83b8fc55f7321819c4bc8daab0a69
--
i.