* [Intel-wired-lan] [PATCH net v2] i40e: Add restoration of VF MSI-X state during PCI reset
@ 2022-02-21 15:13 Mateusz Palczewski
2022-02-21 15:53 ` Paul Menzel
2022-02-22 1:44 ` kernel test robot
0 siblings, 2 replies; 3+ messages in thread
From: Mateusz Palczewski @ 2022-02-21 15:13 UTC (permalink / raw)
To: intel-wired-lan
From: Slawomir Laba <slawomirx.laba@intel.com>
During a PCI FLR the MSI-X Enable flag in the VF PCI MSI-X capability
register will be cleared. This can lead to issues when a VF is
assigned to a VM because in these cases the VF driver receives no
indication of the PF PCI error/reset and additionally it is incapable
of restoring the cleared flag in the hypervisor configuration space
without fully reinitializing the driver interrupt functionality.
Since the VF driver is unable to easily resolve this condition on its own,
restore the VF MSI-X flag during the PF PCI reset handling.
Fixes: 19b7960b2da1 ("i40e: implement split PCI error reset handler")
Signed-off-by: Slawomir Laba <slawomirx.laba@intel.com>
Signed-off-by: Karen Sornek <karen.sornek@intel.com>
Signed-off-by: Mateusz Palczewski <mateusz.palczewski@intel.com>
---
v2: Fixed compilation error
---
drivers/net/ethernet/intel/i40e/i40e_main.c | 2 ++
.../ethernet/intel/i40e/i40e_virtchnl_pf.c | 32 +++++++++++++++++++
.../ethernet/intel/i40e/i40e_virtchnl_pf.h | 1 +
3 files changed, 35 insertions(+)
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 2f8ddfa..442b68a 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -16151,6 +16151,8 @@ static void i40e_pci_error_reset_done(struct pci_dev *pdev)
return;
i40e_reset_and_rebuild(pf, false, false);
+
+ i40e_restore_all_vfs_msi_state(pdev);
}
/**
diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
index 2606e8f..5aaa669 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
@@ -152,6 +152,38 @@ void i40e_vc_notify_reset(struct i40e_pf *pf)
(u8 *)&pfe, sizeof(struct virtchnl_pf_event));
}
+/**
+ * i40e_restore_all_vfs_msi_state - restore VF MSI state after PF FLR
+ * @pdev: pointer to a pci_dev structure
+ *
+ * Called when recovering from a PF FLR to restore interrupt capability to
+ * the VFs.
+ */
+void i40e_restore_all_vfs_msi_state(struct pci_dev *pdev)
+{
+ struct pci_dev *vfdev;
+ u16 vf_id;
+ int pos;
+
+ /* Continue only if this is a PF */
+ if (!pdev->is_physfn)
+ return;
+
+ if (!pci_num_vf(pdev))
+ return;
+
+ pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_SRIOV);
+ if (pos) {
+ pci_read_config_word(pdev, pos + PCI_SRIOV_VF_DID, &vf_id);
+ vfdev = pci_get_device(pdev->vendor, vf_id, NULL);
+ while (vfdev) {
+ if (vfdev->is_virtfn && vfdev->physfn == pdev)
+ pci_restore_msi_state(vfdev);
+ vfdev = pci_get_device(pdev->vendor, vf_id, vfdev);
+ }
+ }
+}
+
/**
* i40e_vc_notify_vf_reset
* @vf: pointer to the VF structure
diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h
index a554d0a..7c5f166 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h
+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h
@@ -134,6 +134,7 @@ int i40e_ndo_set_vf_spoofchk(struct net_device *netdev, int vf_id, bool enable);
void i40e_vc_notify_link_state(struct i40e_pf *pf);
void i40e_vc_notify_reset(struct i40e_pf *pf);
+void i40e_restore_all_vfs_msi_state(struct pci_dev *pdev);
int i40e_get_vf_stats(struct net_device *netdev, int vf_id,
struct ifla_vf_stats *vf_stats);
--
2.27.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Intel-wired-lan] [PATCH net v2] i40e: Add restoration of VF MSI-X state during PCI reset
2022-02-21 15:13 [Intel-wired-lan] [PATCH net v2] i40e: Add restoration of VF MSI-X state during PCI reset Mateusz Palczewski
@ 2022-02-21 15:53 ` Paul Menzel
2022-02-22 1:44 ` kernel test robot
1 sibling, 0 replies; 3+ messages in thread
From: Paul Menzel @ 2022-02-21 15:53 UTC (permalink / raw)
To: intel-wired-lan
Dear Slawomir, dear Mateusz,
Am 21.02.22 um 16:13 schrieb Mateusz Palczewski:
> From: Slawomir Laba <slawomirx.laba@intel.com>
Thank you for your patch. To shorten the commit message summary, maybe
just use: i40e Restore VF MSI-X state during PCI reset
> During a PCI FLR the MSI-X Enable flag in the VF PCI MSI-X capability
> register will be cleared. This can lead to issues when a VF is
> assigned to a VM because in these cases the VF driver receives no
> indication of the PF PCI error/reset and additionally it is incapable
> of restoring the cleared flag in the hypervisor configuration space
> without fully reinitializing the driver interrupt functionality.
For the record, can you please document the exact test environment to
reproduce the issue, and what error is seen.
> Since the VF driver is unable to easily resolve this condition on its own,
> restore the VF MSI-X flag during the PF PCI reset handling.
>
> Fixes: 19b7960b2da1 ("i40e: implement split PCI error reset handler")
> Signed-off-by: Slawomir Laba <slawomirx.laba@intel.com>
> Signed-off-by: Karen Sornek <karen.sornek@intel.com>
> Signed-off-by: Mateusz Palczewski <mateusz.palczewski@intel.com>
> ---
> v2: Fixed compilation error
> ---
> drivers/net/ethernet/intel/i40e/i40e_main.c | 2 ++
> .../ethernet/intel/i40e/i40e_virtchnl_pf.c | 32 +++++++++++++++++++
> .../ethernet/intel/i40e/i40e_virtchnl_pf.h | 1 +
> 3 files changed, 35 insertions(+)
>
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
> index 2f8ddfa..442b68a 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_main.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
> @@ -16151,6 +16151,8 @@ static void i40e_pci_error_reset_done(struct pci_dev *pdev)
> return;
>
> i40e_reset_and_rebuild(pf, false, false);
> +
> + i40e_restore_all_vfs_msi_state(pdev);
> }
>
> /**
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
> index 2606e8f..5aaa669 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
> @@ -152,6 +152,38 @@ void i40e_vc_notify_reset(struct i40e_pf *pf)
> (u8 *)&pfe, sizeof(struct virtchnl_pf_event));
> }
>
> +/**
> + * i40e_restore_all_vfs_msi_state - restore VF MSI state after PF FLR
> + * @pdev: pointer to a pci_dev structure
> + *
> + * Called when recovering from a PF FLR to restore interrupt capability to
> + * the VFs.
> + */
> +void i40e_restore_all_vfs_msi_state(struct pci_dev *pdev)
> +{
> + struct pci_dev *vfdev;
> + u16 vf_id;
> + int pos;
Use u16 to match pci_find_ext_capability() signature?
> +
> + /* Continue only if this is a PF */
> + if (!pdev->is_physfn)
> + return;
> +
> + if (!pci_num_vf(pdev))
> + return;
> +
> + pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_SRIOV);
> + if (pos) {
> + pci_read_config_word(pdev, pos + PCI_SRIOV_VF_DID, &vf_id);
> + vfdev = pci_get_device(pdev->vendor, vf_id, NULL);
> + while (vfdev) {
> + if (vfdev->is_virtfn && vfdev->physfn == pdev)
> + pci_restore_msi_state(vfdev);
> + vfdev = pci_get_device(pdev->vendor, vf_id, vfdev);
Move that in the while condition (and initialize vfdev with NULL to
follow the pattern in `Documentation/PCI/pci.rst`?
struct pci_dev *dev = NULL;
while (dev = pci_get_device(VENDOR_ID, DEVICE_ID, dev))
configure_device(dev);
> + }
> + }
> +}
> +
> /**
> * i40e_vc_notify_vf_reset
> * @vf: pointer to the VF structure
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h
> index a554d0a..7c5f166 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h
> +++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h
> @@ -134,6 +134,7 @@ int i40e_ndo_set_vf_spoofchk(struct net_device *netdev, int vf_id, bool enable);
>
> void i40e_vc_notify_link_state(struct i40e_pf *pf);
> void i40e_vc_notify_reset(struct i40e_pf *pf);
> +void i40e_restore_all_vfs_msi_state(struct pci_dev *pdev);
> int i40e_get_vf_stats(struct net_device *netdev, int vf_id,
> struct ifla_vf_stats *vf_stats);
>
Kind regards,
Paul
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Intel-wired-lan] [PATCH net v2] i40e: Add restoration of VF MSI-X state during PCI reset
2022-02-21 15:13 [Intel-wired-lan] [PATCH net v2] i40e: Add restoration of VF MSI-X state during PCI reset Mateusz Palczewski
2022-02-21 15:53 ` Paul Menzel
@ 2022-02-22 1:44 ` kernel test robot
1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2022-02-22 1:44 UTC (permalink / raw)
To: intel-wired-lan
Hi Mateusz,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on net/master]
url: https://github.com/0day-ci/linux/commits/Mateusz-Palczewski/i40e-Add-restoration-of-VF-MSI-X-state-during-PCI-reset/20220221-231705
base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git 8940e6b669ca1196ce0a0549c819078096390f76
config: alpha-buildonly-randconfig-r003-20220221 (https://download.01.org/0day-ci/archive/20220222/202202220925.i3vWGofk-lkp at intel.com/config)
compiler: alpha-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/ccbd216cb10be64cf9cb5d848bbadedc60bc3878
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Mateusz-Palczewski/i40e-Add-restoration-of-VF-MSI-X-state-during-PCI-reset/20220221-231705
git checkout ccbd216cb10be64cf9cb5d848bbadedc60bc3878
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=alpha SHELL=/bin/bash drivers/net/ethernet/intel/i40e/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c: In function 'i40e_restore_all_vfs_msi_state':
>> drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c:180:56: error: 'struct pci_dev' has no member named 'physfn'; did you mean 'is_physfn'?
180 | if (vfdev->is_virtfn && vfdev->physfn == pdev)
| ^~~~~~
| is_physfn
vim +180 drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
154
155 /**
156 * i40e_restore_all_vfs_msi_state - restore VF MSI state after PF FLR
157 * @pdev: pointer to a pci_dev structure
158 *
159 * Called when recovering from a PF FLR to restore interrupt capability to
160 * the VFs.
161 */
162 void i40e_restore_all_vfs_msi_state(struct pci_dev *pdev)
163 {
164 struct pci_dev *vfdev;
165 u16 vf_id;
166 int pos;
167
168 /* Continue only if this is a PF */
169 if (!pdev->is_physfn)
170 return;
171
172 if (!pci_num_vf(pdev))
173 return;
174
175 pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_SRIOV);
176 if (pos) {
177 pci_read_config_word(pdev, pos + PCI_SRIOV_VF_DID, &vf_id);
178 vfdev = pci_get_device(pdev->vendor, vf_id, NULL);
179 while (vfdev) {
> 180 if (vfdev->is_virtfn && vfdev->physfn == pdev)
181 pci_restore_msi_state(vfdev);
182 vfdev = pci_get_device(pdev->vendor, vf_id, vfdev);
183 }
184 }
185 }
186
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all at lists.01.org
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-02-22 1:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-21 15:13 [Intel-wired-lan] [PATCH net v2] i40e: Add restoration of VF MSI-X state during PCI reset Mateusz Palczewski
2022-02-21 15:53 ` Paul Menzel
2022-02-22 1:44 ` kernel test robot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.