netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 0/5] pds_core: error handling fixes
@ 2023-08-24 16:17 Shannon Nelson
  2023-08-24 16:17 ` [PATCH net 1/5] pds_core: protect devlink callbacks from fw_down state Shannon Nelson
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Shannon Nelson @ 2023-08-24 16:17 UTC (permalink / raw)
  To: shannon.nelson, brett.creeley, davem, netdev, kuba; +Cc: drivers

Some fixes for better handling of broken states.

Shannon Nelson (5):
  pds_core: protect devlink callbacks from fw_down state
  pds_core: no health reporter in VF
  pds_core: no reset command for VF
  pds_core: check for work queue before use
  pds_core: pass opcode to devcmd_wait

 drivers/net/ethernet/amd/pds_core/core.c    | 11 +++++++----
 drivers/net/ethernet/amd/pds_core/dev.c     |  9 +++------
 drivers/net/ethernet/amd/pds_core/devlink.c |  3 +++
 3 files changed, 13 insertions(+), 10 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH net 1/5] pds_core: protect devlink callbacks from fw_down state
  2023-08-24 16:17 [PATCH net 0/5] pds_core: error handling fixes Shannon Nelson
@ 2023-08-24 16:17 ` Shannon Nelson
  2023-08-24 16:17 ` [PATCH net 2/5] pds_core: no health reporter in VF Shannon Nelson
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Shannon Nelson @ 2023-08-24 16:17 UTC (permalink / raw)
  To: shannon.nelson, brett.creeley, davem, netdev, kuba; +Cc: drivers

Don't access structs that have been cleared when in the fw_down
state and the various structs have been cleaned and are waiting
to recover.  This caused a panic on rmmod when already in fw_down
and devlink_param_unregister() tried to check the parameters.

Fixes: 40ced8944536 ("pds_core: devlink params for enabling VIF support")
Signed-off-by: Shannon Nelson <shannon.nelson@amd.com>
Reviewed-by: Brett Creeley <brett.creeley@amd.com>
---
 drivers/net/ethernet/amd/pds_core/devlink.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/amd/pds_core/devlink.c b/drivers/net/ethernet/amd/pds_core/devlink.c
index 9c6b3653c1c7..d9607033bbf2 100644
--- a/drivers/net/ethernet/amd/pds_core/devlink.c
+++ b/drivers/net/ethernet/amd/pds_core/devlink.c
@@ -10,6 +10,9 @@ pdsc_viftype *pdsc_dl_find_viftype_by_id(struct pdsc *pdsc,
 {
 	int vt;
 
+	if (!pdsc->viftype_status)
+		return NULL;
+
 	for (vt = 0; vt < PDS_DEV_TYPE_MAX; vt++) {
 		if (pdsc->viftype_status[vt].dl_id == dl_id)
 			return &pdsc->viftype_status[vt];
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH net 2/5] pds_core: no health reporter in VF
  2023-08-24 16:17 [PATCH net 0/5] pds_core: error handling fixes Shannon Nelson
  2023-08-24 16:17 ` [PATCH net 1/5] pds_core: protect devlink callbacks from fw_down state Shannon Nelson
@ 2023-08-24 16:17 ` Shannon Nelson
  2023-08-24 16:17 ` [PATCH net 3/5] pds_core: no reset command for VF Shannon Nelson
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Shannon Nelson @ 2023-08-24 16:17 UTC (permalink / raw)
  To: shannon.nelson, brett.creeley, davem, netdev, kuba; +Cc: drivers

Make sure the health reporter is set up before we use it in
our devlink health updates, especially since the VF doesn't
set up the health reporter.

Fixes: 25b450c05a49 ("pds_core: add devlink health facilities")
Signed-off-by: Shannon Nelson <shannon.nelson@amd.com>
Reviewed-by: Brett Creeley <brett.creeley@amd.com>
---
 drivers/net/ethernet/amd/pds_core/core.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/amd/pds_core/core.c b/drivers/net/ethernet/amd/pds_core/core.c
index f2c79456d745..383e3311a52c 100644
--- a/drivers/net/ethernet/amd/pds_core/core.c
+++ b/drivers/net/ethernet/amd/pds_core/core.c
@@ -524,7 +524,8 @@ static void pdsc_fw_down(struct pdsc *pdsc)
 	}
 
 	/* Notify clients of fw_down */
-	devlink_health_report(pdsc->fw_reporter, "FW down reported", pdsc);
+	if (pdsc->fw_reporter)
+		devlink_health_report(pdsc->fw_reporter, "FW down reported", pdsc);
 	pdsc_notify(PDS_EVENT_RESET, &reset_event);
 
 	pdsc_stop(pdsc);
@@ -554,8 +555,9 @@ static void pdsc_fw_up(struct pdsc *pdsc)
 
 	/* Notify clients of fw_up */
 	pdsc->fw_recoveries++;
-	devlink_health_reporter_state_update(pdsc->fw_reporter,
-					     DEVLINK_HEALTH_REPORTER_STATE_HEALTHY);
+	if (pdsc->fw_reporter)
+		devlink_health_reporter_state_update(pdsc->fw_reporter,
+						     DEVLINK_HEALTH_REPORTER_STATE_HEALTHY);
 	pdsc_notify(PDS_EVENT_RESET, &reset_event);
 
 	return;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH net 3/5] pds_core: no reset command for VF
  2023-08-24 16:17 [PATCH net 0/5] pds_core: error handling fixes Shannon Nelson
  2023-08-24 16:17 ` [PATCH net 1/5] pds_core: protect devlink callbacks from fw_down state Shannon Nelson
  2023-08-24 16:17 ` [PATCH net 2/5] pds_core: no health reporter in VF Shannon Nelson
@ 2023-08-24 16:17 ` Shannon Nelson
  2023-08-24 16:17 ` [PATCH net 4/5] pds_core: check for work queue before use Shannon Nelson
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Shannon Nelson @ 2023-08-24 16:17 UTC (permalink / raw)
  To: shannon.nelson, brett.creeley, davem, netdev, kuba; +Cc: drivers

The VF doesn't need to send a reset command, and in a PCI reset
scenario it might not have a valid IO space to write to anyway.

Fixes: 523847df1b37 ("pds_core: add devcmd device interfaces")
Signed-off-by: Shannon Nelson <shannon.nelson@amd.com>
Reviewed-by: Brett Creeley <brett.creeley@amd.com>
---
 drivers/net/ethernet/amd/pds_core/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/amd/pds_core/core.c b/drivers/net/ethernet/amd/pds_core/core.c
index 383e3311a52c..36f9b932b9e2 100644
--- a/drivers/net/ethernet/amd/pds_core/core.c
+++ b/drivers/net/ethernet/amd/pds_core/core.c
@@ -464,7 +464,8 @@ void pdsc_teardown(struct pdsc *pdsc, bool removing)
 {
 	int i;
 
-	pdsc_devcmd_reset(pdsc);
+	if (!pdsc->pdev->is_virtfn)
+		pdsc_devcmd_reset(pdsc);
 	pdsc_qcq_free(pdsc, &pdsc->notifyqcq);
 	pdsc_qcq_free(pdsc, &pdsc->adminqcq);
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH net 4/5] pds_core: check for work queue before use
  2023-08-24 16:17 [PATCH net 0/5] pds_core: error handling fixes Shannon Nelson
                   ` (2 preceding siblings ...)
  2023-08-24 16:17 ` [PATCH net 3/5] pds_core: no reset command for VF Shannon Nelson
@ 2023-08-24 16:17 ` Shannon Nelson
  2023-08-24 16:17 ` [PATCH net 5/5] pds_core: pass opcode to devcmd_wait Shannon Nelson
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Shannon Nelson @ 2023-08-24 16:17 UTC (permalink / raw)
  To: shannon.nelson, brett.creeley, davem, netdev, kuba; +Cc: drivers

Add a check that the wq exists before queuing up work for a
failed devcmd, as the PF is responsible for health and the VF
doesn't have a wq.

Fixes: c2dbb0904310 ("pds_core: health timer and workqueue")
Signed-off-by: Shannon Nelson <shannon.nelson@amd.com>
Reviewed-by: Brett Creeley <brett.creeley@amd.com>
---
 drivers/net/ethernet/amd/pds_core/dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/amd/pds_core/dev.c b/drivers/net/ethernet/amd/pds_core/dev.c
index debe5216fe29..524f422ee7ac 100644
--- a/drivers/net/ethernet/amd/pds_core/dev.c
+++ b/drivers/net/ethernet/amd/pds_core/dev.c
@@ -183,7 +183,7 @@ int pdsc_devcmd_locked(struct pdsc *pdsc, union pds_core_dev_cmd *cmd,
 	err = pdsc_devcmd_wait(pdsc, max_seconds);
 	memcpy_fromio(comp, &pdsc->cmd_regs->comp, sizeof(*comp));
 
-	if (err == -ENXIO || err == -ETIMEDOUT)
+	if ((err == -ENXIO || err == -ETIMEDOUT) && pdsc->wq)
 		queue_work(pdsc->wq, &pdsc->health_work);
 
 	return err;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH net 5/5] pds_core: pass opcode to devcmd_wait
  2023-08-24 16:17 [PATCH net 0/5] pds_core: error handling fixes Shannon Nelson
                   ` (3 preceding siblings ...)
  2023-08-24 16:17 ` [PATCH net 4/5] pds_core: check for work queue before use Shannon Nelson
@ 2023-08-24 16:17 ` Shannon Nelson
  2023-08-25 11:47 ` [PATCH net 0/5] pds_core: error handling fixes Simon Horman
  2023-08-26  2:10 ` patchwork-bot+netdevbpf
  6 siblings, 0 replies; 8+ messages in thread
From: Shannon Nelson @ 2023-08-24 16:17 UTC (permalink / raw)
  To: shannon.nelson, brett.creeley, davem, netdev, kuba; +Cc: drivers

Don't rely on the PCI memory for the devcmd opcode because we
read a 0xff value if the PCI bus is broken, which can cause us
to report a bogus dev_cmd opcode later.

Fixes: 523847df1b37 ("pds_core: add devcmd device interfaces")
Signed-off-by: Shannon Nelson <shannon.nelson@amd.com>
Reviewed-by: Brett Creeley <brett.creeley@amd.com>
---
 drivers/net/ethernet/amd/pds_core/dev.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/amd/pds_core/dev.c b/drivers/net/ethernet/amd/pds_core/dev.c
index 524f422ee7ac..f77cd9f5a2fd 100644
--- a/drivers/net/ethernet/amd/pds_core/dev.c
+++ b/drivers/net/ethernet/amd/pds_core/dev.c
@@ -121,7 +121,7 @@ static const char *pdsc_devcmd_str(int opcode)
 	}
 }
 
-static int pdsc_devcmd_wait(struct pdsc *pdsc, int max_seconds)
+static int pdsc_devcmd_wait(struct pdsc *pdsc, u8 opcode, int max_seconds)
 {
 	struct device *dev = pdsc->dev;
 	unsigned long start_time;
@@ -131,9 +131,6 @@ static int pdsc_devcmd_wait(struct pdsc *pdsc, int max_seconds)
 	int done = 0;
 	int err = 0;
 	int status;
-	int opcode;
-
-	opcode = ioread8(&pdsc->cmd_regs->cmd.opcode);
 
 	start_time = jiffies;
 	max_wait = start_time + (max_seconds * HZ);
@@ -180,7 +177,7 @@ int pdsc_devcmd_locked(struct pdsc *pdsc, union pds_core_dev_cmd *cmd,
 
 	memcpy_toio(&pdsc->cmd_regs->cmd, cmd, sizeof(*cmd));
 	pdsc_devcmd_dbell(pdsc);
-	err = pdsc_devcmd_wait(pdsc, max_seconds);
+	err = pdsc_devcmd_wait(pdsc, cmd->opcode, max_seconds);
 	memcpy_fromio(comp, &pdsc->cmd_regs->comp, sizeof(*comp));
 
 	if ((err == -ENXIO || err == -ETIMEDOUT) && pdsc->wq)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH net 0/5] pds_core: error handling fixes
  2023-08-24 16:17 [PATCH net 0/5] pds_core: error handling fixes Shannon Nelson
                   ` (4 preceding siblings ...)
  2023-08-24 16:17 ` [PATCH net 5/5] pds_core: pass opcode to devcmd_wait Shannon Nelson
@ 2023-08-25 11:47 ` Simon Horman
  2023-08-26  2:10 ` patchwork-bot+netdevbpf
  6 siblings, 0 replies; 8+ messages in thread
From: Simon Horman @ 2023-08-25 11:47 UTC (permalink / raw)
  To: Shannon Nelson; +Cc: brett.creeley, davem, netdev, kuba, drivers

On Thu, Aug 24, 2023 at 09:17:49AM -0700, Shannon Nelson wrote:
> Some fixes for better handling of broken states.
> 
> Shannon Nelson (5):
>   pds_core: protect devlink callbacks from fw_down state
>   pds_core: no health reporter in VF
>   pds_core: no reset command for VF
>   pds_core: check for work queue before use
>   pds_core: pass opcode to devcmd_wait
> 
>  drivers/net/ethernet/amd/pds_core/core.c    | 11 +++++++----
>  drivers/net/ethernet/amd/pds_core/dev.c     |  9 +++------
>  drivers/net/ethernet/amd/pds_core/devlink.c |  3 +++
>  3 files changed, 13 insertions(+), 10 deletions(-)

For series,

Reviewed-by: Simon Horman <horms@kernel.org>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net 0/5] pds_core: error handling fixes
  2023-08-24 16:17 [PATCH net 0/5] pds_core: error handling fixes Shannon Nelson
                   ` (5 preceding siblings ...)
  2023-08-25 11:47 ` [PATCH net 0/5] pds_core: error handling fixes Simon Horman
@ 2023-08-26  2:10 ` patchwork-bot+netdevbpf
  6 siblings, 0 replies; 8+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-08-26  2:10 UTC (permalink / raw)
  To: Shannon Nelson; +Cc: brett.creeley, davem, netdev, kuba, drivers

Hello:

This series was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Thu, 24 Aug 2023 09:17:49 -0700 you wrote:
> Some fixes for better handling of broken states.
> 
> Shannon Nelson (5):
>   pds_core: protect devlink callbacks from fw_down state
>   pds_core: no health reporter in VF
>   pds_core: no reset command for VF
>   pds_core: check for work queue before use
>   pds_core: pass opcode to devcmd_wait
> 
> [...]

Here is the summary with links:
  - [net,1/5] pds_core: protect devlink callbacks from fw_down state
    https://git.kernel.org/netdev/net/c/91202ce78fcd
  - [net,2/5] pds_core: no health reporter in VF
    https://git.kernel.org/netdev/net/c/e48b894a1db7
  - [net,3/5] pds_core: no reset command for VF
    https://git.kernel.org/netdev/net/c/95e383226d6f
  - [net,4/5] pds_core: check for work queue before use
    https://git.kernel.org/netdev/net/c/969cfd4c8ca5
  - [net,5/5] pds_core: pass opcode to devcmd_wait
    https://git.kernel.org/netdev/net/c/0ea064e74bc8

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] 8+ messages in thread

end of thread, other threads:[~2023-08-26  2:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-24 16:17 [PATCH net 0/5] pds_core: error handling fixes Shannon Nelson
2023-08-24 16:17 ` [PATCH net 1/5] pds_core: protect devlink callbacks from fw_down state Shannon Nelson
2023-08-24 16:17 ` [PATCH net 2/5] pds_core: no health reporter in VF Shannon Nelson
2023-08-24 16:17 ` [PATCH net 3/5] pds_core: no reset command for VF Shannon Nelson
2023-08-24 16:17 ` [PATCH net 4/5] pds_core: check for work queue before use Shannon Nelson
2023-08-24 16:17 ` [PATCH net 5/5] pds_core: pass opcode to devcmd_wait Shannon Nelson
2023-08-25 11:47 ` [PATCH net 0/5] pds_core: error handling fixes Simon Horman
2023-08-26  2:10 ` 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).