Skip to contentSkip to conversation

ionic: minor code fixes

PATCH Applied Shannon Nelson 3 participants 6 messages Dec 12, 2024 – Dec 15, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover ionic: minor code fixes

These are a couple of code fixes for the ionic driver.

Brett Creeley (1):
ionic: Fix netdev notifier unregister on failure

Shannon Nelson (2):
ionic: no double destroy workqueue
ionic: use ee->offset when returning sprom data

v2: dropped nb_work removal from first patch

v1: https://lore.kernel.org/netdev/[email protected]/

 drivers/net/ethernet/pensando/ionic/ionic_dev.c     | 5 ++++-
 drivers/net/ethernet/pensando/ionic/ionic_ethtool.c | 4 ++--
 drivers/net/ethernet/pensando/ionic/ionic_lif.c     | 4 ++--
 3 files changed, 8 insertions(+), 5 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 1/3 ionic: Fix netdev notifier unregister on failure

From: Brett Creeley <[email protected]>

If register_netdev() fails, then the driver leaks the netdev notifier. Fix this by calling ionic_lif_unregister() on register_netdev() failure. This will also call ionic_lif_unregister_phc() if it has already been registered.

Fixes 30b87ab4c0b3 ("ionic: remove lif list concept")
---
 drivers/net/ethernet/pensando/ionic/ionic_lif.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_lif.c +2 -2
index 40496587b2b3..3d3f936779f7 100644
@@ -3869,8 +3869,8 @@ int ionic_lif_register(struct ionic_lif *lif)
 	/* only register LIF0 for now */
 	err = register_netdev(lif->netdev);
 	if (err) {
-		dev_err(lif->ionic->dev, "Cannot register net device, aborting\n");
-		ionic_lif_unregister_phc(lif);
+		dev_err(lif->ionic->dev, "Cannot register net device: %d, aborting\n", err);
+		ionic_lif_unregister(lif);
 		return err;
 	}
 
Signature · 1 line
2.17.1
#2 lore raw

PATCH v2 2/3 ionic: no double destroy workqueue

In reply to Shannon Nelson

There are some FW error handling paths that can cause us to try to destroy the workqueue more than once, so let's be sure we're checking for that.

The case where this popped up was in an AER event where the handlers got called in such a way that ionic_reset_prepare() and thus ionic_dev_teardown() got called twice in a row. The second time through the workqueue was already destroyed, and destroy_workqueue() choked on the bad wq pointer.

We didn't hit this in AER handler testing before because at that time we weren't using a private workqueue. Later we replaced the use of the system workqueue with our own private workqueue but hadn't rerun the AER handler testing since then.

Fixes 9e25450da700 ("ionic: add private workqueue per-device")
---
 drivers/net/ethernet/pensando/ionic/ionic_dev.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/pensando/ionic/ionic_dev.c +4 -1
index 9e42d599840d..57edcde9e6f8 100644
@@ -277,7 +277,10 @@ void ionic_dev_teardown(struct ionic *ionic)
 	idev->phy_cmb_pages = 0;
 	idev->cmb_npages = 0;
 
-	destroy_workqueue(ionic->wq);
+	if (ionic->wq) {
+		destroy_workqueue(ionic->wq);
+		ionic->wq = NULL;
+	}
 	mutex_destroy(&idev->cmb_inuse_lock);
 }
 
Signature · 1 line
2.17.1
#3 lore raw

PATCH v2 3/3 ionic: use ee->offset when returning sprom data

In reply to Shannon Nelson

Some calls into ionic_get_module_eeprom() don't use a single full buffer size, but instead multiple calls with an offset. Teach our driver to use the offset correctly so we can respond appropriately to the caller.

Fixes 4d03e00a2140 ("ionic: Add initial ethtool support")
---
 drivers/net/ethernet/pensando/ionic/ionic_ethtool.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_ethtool.c +2 -2
index dda22fa4448c..9b7f78b6cdb1 100644
@@ -961,8 +961,8 @@ static int ionic_get_module_eeprom(struct net_device *netdev,
 	len = min_t(u32, sizeof(xcvr->sprom), ee->len);
 
 	do {
-		memcpy(data, xcvr->sprom, len);
-		memcpy(tbuf, xcvr->sprom, len);
+		memcpy(data, &xcvr->sprom[ee->offset], len);
+		memcpy(tbuf, &xcvr->sprom[ee->offset], len);
 
 		/* Let's make sure we got a consistent copy */
 		if (!memcmp(data, tbuf, len))
Signature · 1 line
2.17.1
#4 lore raw
In reply to Shannon Nelson
Quoted 11 lines · Shannon Nelson

These are a couple of code fixes for the ionic driver.

Brett Creeley (1):
ionic: Fix netdev notifier unregister on failure

Shannon Nelson (2):
ionic: no double destroy workqueue
ionic: use ee->offset when returning sprom data

v2: dropped nb_work removal from first patch

Thanks for splitting that out. Everything still looks good to me.

#5 lore raw
In reply to Shannon Nelson
This series was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Thu, 12 Dec 2024 13:31:54 -0800 you wrote:

These are a couple of code fixes for the ionic driver.

Brett Creeley (1):
ionic: Fix netdev notifier unregister on failure

Shannon Nelson (2):
ionic: no double destroy workqueue
ionic: use ee->offset when returning sprom data

[...]

Here is the summary with links:
- [v2,net,1/3] ionic: Fix netdev notifier unregister on failure

    https://git.kernel.org/netdev/net/c/9590d32e090e
  - [v2,net,2/3] ionic: no double destroy workqueue
    https://git.kernel.org/netdev/net/c/746e6ae2e202
  - [v2,net,3/3] ionic: use ee->offset when returning sprom data
    https://git.kernel.org/netdev/net/c/b096d62ba132

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html