* [PATCH net 0/3] ionic: PCI error handling fixes
@ 2024-02-23 22:27 Shannon Nelson
2024-02-23 22:27 ` [PATCH net 1/3] ionic: check before releasing pci regions Shannon Nelson
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Shannon Nelson @ 2024-02-23 22:27 UTC (permalink / raw)
To: netdev, davem, kuba, edumazet, pabeni
Cc: brett.creeley, drivers, Shannon Nelson
These are a few things to make our PCI reset handling better.
Shannon Nelson (3):
ionic: check before releasing pci regions
ionic: check cmd_regs before copying in or out
ionic: restore netdev feature bits after reset
.../net/ethernet/pensando/ionic/ionic_bus_pci.c | 17 ++++++++++-------
drivers/net/ethernet/pensando/ionic/ionic_dev.c | 10 ++++++++++
.../net/ethernet/pensando/ionic/ionic_ethtool.c | 7 ++++++-
drivers/net/ethernet/pensando/ionic/ionic_fw.c | 5 +++++
drivers/net/ethernet/pensando/ionic/ionic_lif.c | 5 ++++-
.../net/ethernet/pensando/ionic/ionic_main.c | 3 +++
6 files changed, 38 insertions(+), 9 deletions(-)
--
2.17.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH net 1/3] ionic: check before releasing pci regions
2024-02-23 22:27 [PATCH net 0/3] ionic: PCI error handling fixes Shannon Nelson
@ 2024-02-23 22:27 ` Shannon Nelson
2024-02-23 22:27 ` [PATCH net 2/3] ionic: check cmd_regs before copying in or out Shannon Nelson
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Shannon Nelson @ 2024-02-23 22:27 UTC (permalink / raw)
To: netdev, davem, kuba, edumazet, pabeni
Cc: brett.creeley, drivers, Shannon Nelson
AER recovery handler can trigger a PCI Reset after tearing
down the device setup in the error detection handler. The PCI
Reset handler will also attempt to tear down the device setup,
and this second tear down needs to know that it doesn't need
to call pci_release_regions() a second time. We can clear
num_bars on tear down and use that to decide later if we need
to clear the resources. This prevents a harmless but disturbing
warning message
resource: Trying to free nonexistent resource <0xXXXXXXXXXX-0xXXXXXXXXXX>
Fixes: c3a910e1c47a ("ionic: fill out pci error handlers")
Reviewed-by: Brett Creeley <brett.creeley@amd.com>
Signed-off-by: Shannon Nelson <shannon.nelson@amd.com>
---
.../net/ethernet/pensando/ionic/ionic_bus_pci.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c b/drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c
index 10a9d80db32c..6ba8d4aca0a0 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c
@@ -93,6 +93,7 @@ static void ionic_unmap_bars(struct ionic *ionic)
bars[i].len = 0;
}
}
+ ionic->num_bars = 0;
}
void __iomem *ionic_bus_map_dbpage(struct ionic *ionic, int page_num)
@@ -215,13 +216,15 @@ static int ionic_sriov_configure(struct pci_dev *pdev, int num_vfs)
static void ionic_clear_pci(struct ionic *ionic)
{
- ionic->idev.dev_info_regs = NULL;
- ionic->idev.dev_cmd_regs = NULL;
- ionic->idev.intr_status = NULL;
- ionic->idev.intr_ctrl = NULL;
-
- ionic_unmap_bars(ionic);
- pci_release_regions(ionic->pdev);
+ if (ionic->num_bars) {
+ ionic->idev.dev_info_regs = NULL;
+ ionic->idev.dev_cmd_regs = NULL;
+ ionic->idev.intr_status = NULL;
+ ionic->idev.intr_ctrl = NULL;
+
+ ionic_unmap_bars(ionic);
+ pci_release_regions(ionic->pdev);
+ }
if (pci_is_enabled(ionic->pdev))
pci_disable_device(ionic->pdev);
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net 2/3] ionic: check cmd_regs before copying in or out
2024-02-23 22:27 [PATCH net 0/3] ionic: PCI error handling fixes Shannon Nelson
2024-02-23 22:27 ` [PATCH net 1/3] ionic: check before releasing pci regions Shannon Nelson
@ 2024-02-23 22:27 ` Shannon Nelson
2024-02-23 22:27 ` [PATCH net 3/3] ionic: restore netdev feature bits after reset Shannon Nelson
2024-02-27 12:20 ` [PATCH net 0/3] ionic: PCI error handling fixes patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: Shannon Nelson @ 2024-02-23 22:27 UTC (permalink / raw)
To: netdev, davem, kuba, edumazet, pabeni
Cc: brett.creeley, drivers, Shannon Nelson
Since we now have potential cases of NULL cmd_regs and info_regs
during a reset recovery, and left NULL if a reset recovery has
failed, we need to check that they exist before we use them.
Most of the cases were covered in the original patch where we
verify before doing the ioreadb() for health or cmd status.
However, we need to protect a few uses of io mem that could
be hit in error recovery or asynchronous threads calls as well
(e.g. ethtool or devlink handlers).
Fixes: 219e183272b4 ("ionic: no fw read when PCI reset failed")
Reviewed-by: Brett Creeley <brett.creeley@amd.com>
Signed-off-by: Shannon Nelson <shannon.nelson@amd.com>
---
drivers/net/ethernet/pensando/ionic/ionic_dev.c | 10 ++++++++++
drivers/net/ethernet/pensando/ionic/ionic_ethtool.c | 7 ++++++-
drivers/net/ethernet/pensando/ionic/ionic_fw.c | 5 +++++
drivers/net/ethernet/pensando/ionic/ionic_main.c | 3 +++
4 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/pensando/ionic/ionic_dev.c b/drivers/net/ethernet/pensando/ionic/ionic_dev.c
index 1e7c71f7f081..746072b4dbd0 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_dev.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_dev.c
@@ -319,22 +319,32 @@ int ionic_heartbeat_check(struct ionic *ionic)
u8 ionic_dev_cmd_status(struct ionic_dev *idev)
{
+ if (!idev->dev_cmd_regs)
+ return (u8)PCI_ERROR_RESPONSE;
return ioread8(&idev->dev_cmd_regs->comp.comp.status);
}
bool ionic_dev_cmd_done(struct ionic_dev *idev)
{
+ if (!idev->dev_cmd_regs)
+ return false;
return ioread32(&idev->dev_cmd_regs->done) & IONIC_DEV_CMD_DONE;
}
void ionic_dev_cmd_comp(struct ionic_dev *idev, union ionic_dev_cmd_comp *comp)
{
+ if (!idev->dev_cmd_regs)
+ return;
memcpy_fromio(comp, &idev->dev_cmd_regs->comp, sizeof(*comp));
}
void ionic_dev_cmd_go(struct ionic_dev *idev, union ionic_dev_cmd *cmd)
{
idev->opcode = cmd->cmd.opcode;
+
+ if (!idev->dev_cmd_regs)
+ return;
+
memcpy_toio(&idev->dev_cmd_regs->cmd, cmd, sizeof(*cmd));
iowrite32(0, &idev->dev_cmd_regs->done);
iowrite32(1, &idev->dev_cmd_regs->doorbell);
diff --git a/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c b/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c
index cd3c0b01402e..0ffc9c4904ac 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c
@@ -90,18 +90,23 @@ static void ionic_get_regs(struct net_device *netdev, struct ethtool_regs *regs,
void *p)
{
struct ionic_lif *lif = netdev_priv(netdev);
+ struct ionic_dev *idev;
unsigned int offset;
unsigned int size;
regs->version = IONIC_DEV_CMD_REG_VERSION;
+ idev = &lif->ionic->idev;
+ if (!idev->dev_info_regs)
+ return;
+
offset = 0;
size = IONIC_DEV_INFO_REG_COUNT * sizeof(u32);
memcpy_fromio(p + offset, lif->ionic->idev.dev_info_regs->words, size);
offset += size;
size = IONIC_DEV_CMD_REG_COUNT * sizeof(u32);
- memcpy_fromio(p + offset, lif->ionic->idev.dev_cmd_regs->words, size);
+ memcpy_fromio(p + offset, idev->dev_cmd_regs->words, size);
}
static void ionic_get_link_ext_stats(struct net_device *netdev,
diff --git a/drivers/net/ethernet/pensando/ionic/ionic_fw.c b/drivers/net/ethernet/pensando/ionic/ionic_fw.c
index 5f40324cd243..3c209c1a2337 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_fw.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_fw.c
@@ -109,6 +109,11 @@ int ionic_firmware_update(struct ionic_lif *lif, const struct firmware *fw,
dl = priv_to_devlink(ionic);
devlink_flash_update_status_notify(dl, "Preparing to flash", NULL, 0, 0);
+ if (!idev->dev_cmd_regs) {
+ err = -ENXIO;
+ goto err_out;
+ }
+
buf_sz = sizeof(idev->dev_cmd_regs->data);
netdev_dbg(netdev,
diff --git a/drivers/net/ethernet/pensando/ionic/ionic_main.c b/drivers/net/ethernet/pensando/ionic/ionic_main.c
index 165ab08ad2dd..2f479de329fe 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_main.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_main.c
@@ -416,6 +416,9 @@ static void ionic_dev_cmd_clean(struct ionic *ionic)
{
struct ionic_dev *idev = &ionic->idev;
+ if (!idev->dev_cmd_regs)
+ return;
+
iowrite32(0, &idev->dev_cmd_regs->doorbell);
memset_io(&idev->dev_cmd_regs->cmd, 0, sizeof(idev->dev_cmd_regs->cmd));
}
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net 3/3] ionic: restore netdev feature bits after reset
2024-02-23 22:27 [PATCH net 0/3] ionic: PCI error handling fixes Shannon Nelson
2024-02-23 22:27 ` [PATCH net 1/3] ionic: check before releasing pci regions Shannon Nelson
2024-02-23 22:27 ` [PATCH net 2/3] ionic: check cmd_regs before copying in or out Shannon Nelson
@ 2024-02-23 22:27 ` Shannon Nelson
2024-02-27 12:20 ` [PATCH net 0/3] ionic: PCI error handling fixes patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: Shannon Nelson @ 2024-02-23 22:27 UTC (permalink / raw)
To: netdev, davem, kuba, edumazet, pabeni
Cc: brett.creeley, drivers, Shannon Nelson
When rebuilding the lif after an FLR, be sure to restore the
current netdev features, not do the usual first time feature
init. This prevents losing user changes to things like TSO
or vlan tagging states.
Fixes: 45b84188a0a4 ("ionic: keep filters across FLR")
Reviewed-by: Brett Creeley <brett.creeley@amd.com>
Signed-off-by: Shannon Nelson <shannon.nelson@amd.com>
---
drivers/net/ethernet/pensando/ionic/ionic_lif.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
index cf2d5ad7b68c..fcb44ceeb6aa 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
@@ -3559,7 +3559,10 @@ int ionic_lif_init(struct ionic_lif *lif)
goto err_out_notifyq_deinit;
}
- err = ionic_init_nic_features(lif);
+ if (test_bit(IONIC_LIF_F_FW_RESET, lif->state))
+ err = ionic_set_nic_features(lif, lif->netdev->features);
+ else
+ err = ionic_init_nic_features(lif);
if (err)
goto err_out_notifyq_deinit;
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net 0/3] ionic: PCI error handling fixes
2024-02-23 22:27 [PATCH net 0/3] ionic: PCI error handling fixes Shannon Nelson
` (2 preceding siblings ...)
2024-02-23 22:27 ` [PATCH net 3/3] ionic: restore netdev feature bits after reset Shannon Nelson
@ 2024-02-27 12:20 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-02-27 12:20 UTC (permalink / raw)
To: Shannon Nelson
Cc: netdev, davem, kuba, edumazet, pabeni, brett.creeley, drivers
Hello:
This series was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:
On Fri, 23 Feb 2024 14:27:39 -0800 you wrote:
> These are a few things to make our PCI reset handling better.
>
> Shannon Nelson (3):
> ionic: check before releasing pci regions
> ionic: check cmd_regs before copying in or out
> ionic: restore netdev feature bits after reset
>
> [...]
Here is the summary with links:
- [net,1/3] ionic: check before releasing pci regions
https://git.kernel.org/netdev/net/c/a36b0787f074
- [net,2/3] ionic: check cmd_regs before copying in or out
https://git.kernel.org/netdev/net/c/7662fad348ac
- [net,3/3] ionic: restore netdev feature bits after reset
https://git.kernel.org/netdev/net/c/155a1efc9b96
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-02-27 12:20 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-23 22:27 [PATCH net 0/3] ionic: PCI error handling fixes Shannon Nelson
2024-02-23 22:27 ` [PATCH net 1/3] ionic: check before releasing pci regions Shannon Nelson
2024-02-23 22:27 ` [PATCH net 2/3] ionic: check cmd_regs before copying in or out Shannon Nelson
2024-02-23 22:27 ` [PATCH net 3/3] ionic: restore netdev feature bits after reset Shannon Nelson
2024-02-27 12:20 ` [PATCH net 0/3] ionic: PCI error handling fixes patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).