Skip to content

Commit 30de872

Browse files
ij-intelbjorn-helgaas
authored andcommitted
net/mlx5: Use RMW accessors for changing LNKCTL
Don't assume that only the driver would be accessing LNKCTL of the upstream bridge. ASPM policy changes can trigger write to LNKCTL outside of driver's control. Use RMW capability accessors which do proper locking to avoid losing concurrent updates to the register value. Suggested-by: Lukas Wunner <lukas@wunner.de> Fixes: eabe8e5 ("net/mlx5: Handle sync reset now event") Link: https://lore.kernel.org/r/20230717120503.15276-8-ilpo.jarvinen@linux.intel.com Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Moshe Shemesh <moshe@nvidia.com> Reviewed-by: Simon Horman <simon.horman@corigine.com>
1 parent 7189576 commit 30de872

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -384,16 +384,11 @@ static int mlx5_pci_link_toggle(struct mlx5_core_dev *dev)
384384
pci_cfg_access_lock(sdev);
385385
}
386386
/* PCI link toggle */
387-
err = pci_read_config_word(bridge, cap + PCI_EXP_LNKCTL, &reg16);
388-
if (err)
389-
return err;
390-
reg16 |= PCI_EXP_LNKCTL_LD;
391-
err = pci_write_config_word(bridge, cap + PCI_EXP_LNKCTL, reg16);
387+
err = pcie_capability_set_word(bridge, PCI_EXP_LNKCTL, PCI_EXP_LNKCTL_LD);
392388
if (err)
393389
return err;
394390
msleep(500);
395-
reg16 &= ~PCI_EXP_LNKCTL_LD;
396-
err = pci_write_config_word(bridge, cap + PCI_EXP_LNKCTL, reg16);
391+
err = pcie_capability_clear_word(bridge, PCI_EXP_LNKCTL, PCI_EXP_LNKCTL_LD);
397392
if (err)
398393
return err;
399394

0 commit comments

Comments
 (0)