Skip to contentSkip to conversation

ionic: driver updates

PATCH In review Shannon Nelson 2 participants 8 messages Feb 17, 2022 – Feb 19, 2022

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

cover ionic: driver updates

These are a couple of checkpatch cleanup patches, a bug fix, and something to alleviate memory pressure in tight places.

Brett Creeley (1):
ionic: Use vzalloc for large per-queue related buffers

Shannon Nelson (3):
ionic: catch transition back to RUNNING with fw_generation 0
ionic: prefer strscpy over strlcpy
ionic: clean up comments and whitespace

 drivers/net/ethernet/pensando/ionic/ionic_dev.c  |  4 ++--
 .../net/ethernet/pensando/ionic/ionic_ethtool.c  |  6 +++---
 drivers/net/ethernet/pensando/ionic/ionic_if.h   |  6 +++---
 drivers/net/ethernet/pensando/ionic/ionic_lif.c  | 16 +++++++---------
 .../net/ethernet/pensando/ionic/ionic_stats.c    |  1 -
 drivers/net/ethernet/pensando/ionic/ionic_txrx.c |  1 -
 6 files changed, 15 insertions(+), 19 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/4 ionic: catch transition back to RUNNING with fw_generation 0

In some graceful updates that get initially triggered by the RESET event, especially with older firmware, the fw_generation bits don't change but the fw_status is seen to go to 0 then back to 1. However, the driver didn't perform the restart, remained waiting for fw_generation to change, and got left in limbo.

This is because the clearing of idev->fw_status_ready to 0 didn't happen correctly as it was buried in the transition
trigger: since the transition down was triggered not here but in the RESET event handler, the clear to 0 didn't happen, so the transition back to 1 wasn't detected.

Fix this particular case by bringing the setting of idev->fw_status_ready back out to where it was before.

Fixes 398d1e37f960 ("ionic: add FW_STOPPING state")
---
 drivers/net/ethernet/pensando/ionic/ionic_dev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_dev.c +2 -2
index 52a1b5cfd8e7..faeedc8db6f4 100644
@@ -206,6 +206,8 @@ int ionic_heartbeat_check(struct ionic *ionic)
 	if (fw_status_ready != idev->fw_status_ready) {
 		bool trigger = false;
 
+		idev->fw_status_ready = fw_status_ready;
+
 		if (!fw_status_ready && lif &&
 		    !test_bit(IONIC_LIF_F_FW_RESET, lif->state) &&
 		    !test_and_set_bit(IONIC_LIF_F_FW_STOPPING, lif->state)) {
@@ -222,8 +224,6 @@ int ionic_heartbeat_check(struct ionic *ionic)
 		if (trigger) {
 			struct ionic_deferred_work *work;
 
-			idev->fw_status_ready = fw_status_ready;
-
 			work = kzalloc(sizeof(*work), GFP_ATOMIC);
 			if (work) {
 				work->type = IONIC_DW_TYPE_LIF_RESET;
Signature · 1 line
2.17.1
maintainer
#2 lore raw

Re: [PATCH net-next 1/4] ionic: catch transition back to RUNNING with fw_generation 0

Quoted 12 lines · On Thu, 17 Feb 2022 14:02:49 -0800 Shannon Nelson wrote:

In some graceful updates that get initially triggered by the RESET event, especially with older firmware, the fw_generation bits don't change but the fw_status is seen to go to 0 then back to 1. However, the driver didn't perform the restart, remained waiting for fw_generation to change, and got left in limbo.

This is because the clearing of idev->fw_status_ready to 0 didn't happen correctly as it was buried in the transition
trigger: since the transition down was triggered not here but in the RESET event handler, the clear to 0 didn't happen, so the transition back to 1 wasn't detected.

Quoted 5 lines

Fix this particular case by bringing the setting of idev->fw_status_ready back out to where it was before.

Fixes 398d1e37f960 ("ionic: add FW_STOPPING state")

This looks like a fix, and should go separately to net. Is there a reason behind posting together? The other patches don't even depend on this one.

#3 lore raw

Re: [PATCH net-next 1/4] ionic: catch transition back to RUNNING with fw_generation 0

Quoted 13 lines · Jakub Kicinski
Quoted 12 lines · On Thu, 17 Feb 2022 14:02:49 -0800 Shannon Nelson wrote:

In some graceful updates that get initially triggered by the RESET event, especially with older firmware, the fw_generation bits don't change but the fw_status is seen to go to 0 then back to 1. However, the driver didn't perform the restart, remained waiting for fw_generation to change, and got left in limbo.

This is because the clearing of idev->fw_status_ready to 0 didn't happen correctly as it was buried in the transition
trigger: since the transition down was triggered not here but in the RESET event handler, the clear to 0 didn't happen, so the transition back to 1 wasn't detected.

Quoted 8 lines
Quoted 5 lines

Fix this particular case by bringing the setting of idev->fw_status_ready back out to where it was before.

Fixes 398d1e37f960 ("ionic: add FW_STOPPING state")

This looks like a fix, and should go separately to net. Is there a reason behind posting together? The other patches don't even depend on this one.

I posted it to net-next because the patch it is fixing is still in net-next and not in net or stable yet.

sln

maintainer
#4 lore raw

Re: [PATCH net-next 1/4] ionic: catch transition back to RUNNING with fw_generation 0

Quoted 7 lines · On Fri, 18 Feb 2022 09:30:45 -0800 Shannon Nelson wrote:
Quoted 3 lines · Jakub Kicinski

This looks like a fix, and should go separately to net. Is there a reason behind posting together? The other patches don't even depend on this one.

I posted it to net-next because the patch it is fixing is still in net-next and not in net or stable yet.

Not sure how I missed that, sorry.

Applied now, thanks!

#5 lore raw

PATCH 2/4 ionic: Use vzalloc for large per-queue related buffers

In reply to Shannon Nelson

From: Brett Creeley <[email protected]>

Use vzalloc for per-queue info structs that don't need any DMA mapping to help relieve memory pressure found when used in our limited SOC environment.

---
 drivers/net/ethernet/pensando/ionic/ionic_lif.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_lif.c +6 -8
index 542e395fb037..4101529c300b 100644
@@ -393,11 +393,11 @@ static void ionic_qcq_free(struct ionic_lif *lif, struct ionic_qcq *qcq)
 	ionic_qcq_intr_free(lif, qcq);
 
 	if (qcq->cq.info) {
-		devm_kfree(dev, qcq->cq.info);
+		vfree(qcq->cq.info);
 		qcq->cq.info = NULL;
 	}
 	if (qcq->q.info) {
-		devm_kfree(dev, qcq->q.info);
+		vfree(qcq->q.info);
 		qcq->q.info = NULL;
 	}
 }
@@ -528,8 +528,7 @@ static int ionic_qcq_alloc(struct ionic_lif *lif, unsigned int type,
 	new->q.dev = dev;
 	new->flags = flags;
 
-	new->q.info = devm_kcalloc(dev, num_descs, sizeof(*new->q.info),
-				   GFP_KERNEL);
+	new->q.info = vzalloc(num_descs * sizeof(*new->q.info));
 	if (!new->q.info) {
 		netdev_err(lif->netdev, "Cannot allocate queue info\n");
 		err = -ENOMEM;
@@ -550,8 +549,7 @@ static int ionic_qcq_alloc(struct ionic_lif *lif, unsigned int type,
 	if (err)
 		goto err_out;
 
-	new->cq.info = devm_kcalloc(dev, num_descs, sizeof(*new->cq.info),
-				    GFP_KERNEL);
+	new->cq.info = vzalloc(num_descs * sizeof(*new->cq.info));
 	if (!new->cq.info) {
 		netdev_err(lif->netdev, "Cannot allocate completion queue info\n");
 		err = -ENOMEM;
@@ -640,14 +638,14 @@ static int ionic_qcq_alloc(struct ionic_lif *lif, unsigned int type,
 err_out_free_q:
 	dma_free_coherent(dev, new->q_size, new->q_base, new->q_base_pa);
 err_out_free_cq_info:
-	devm_kfree(dev, new->cq.info);
+	vfree(new->cq.info);
 err_out_free_irq:
 	if (flags & IONIC_QCQ_F_INTR) {
 		devm_free_irq(dev, new->intr.vector, &new->napi);
 		ionic_intr_free(lif->ionic, new->intr.index);
 	}
 err_out_free_q_info:
-	devm_kfree(dev, new->q.info);
+	vfree(new->q.info);
 err_out_free_qcq:
 	devm_kfree(dev, new);
 err_out:
Signature · 1 line
2.17.1
#6 lore raw

PATCH 3/4 ionic: prefer strscpy over strlcpy

In reply to Shannon Nelson

Replace strlcpy with strscpy to clean up a checkpatch complaint.

---
 drivers/net/ethernet/pensando/ionic/ionic_ethtool.c | 6 +++---
 drivers/net/ethernet/pensando/ionic/ionic_lif.c     | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_ethtool.c +3 -3
index 386a5cf1e224..01c22701482d 100644
@@ -74,10 +74,10 @@ static void ionic_get_drvinfo(struct net_device *netdev,
 	struct ionic_lif *lif = netdev_priv(netdev);
 	struct ionic *ionic = lif->ionic;
 
-	strlcpy(drvinfo->driver, IONIC_DRV_NAME, sizeof(drvinfo->driver));
-	strlcpy(drvinfo->fw_version, ionic->idev.dev_info.fw_version,
+	strscpy(drvinfo->driver, IONIC_DRV_NAME, sizeof(drvinfo->driver));
+	strscpy(drvinfo->fw_version, ionic->idev.dev_info.fw_version,
 		sizeof(drvinfo->fw_version));
-	strlcpy(drvinfo->bus_info, ionic_bus_info(ionic),
+	strscpy(drvinfo->bus_info, ionic_bus_info(ionic),
 		sizeof(drvinfo->bus_info));
 }
 
drivers/net/ethernet/pensando/ionic/ionic_lif.c +1 -1
index 4101529c300b..d19d977e5ee6 100644
@@ -3301,7 +3301,7 @@ static void ionic_lif_set_netdev_info(struct ionic_lif *lif)
 		},
 	};
 
-	strlcpy(ctx.cmd.lif_setattr.name, lif->netdev->name,
+	strscpy(ctx.cmd.lif_setattr.name, lif->netdev->name,
 		sizeof(ctx.cmd.lif_setattr.name));
 
 	ionic_adminq_post_wait(lif, &ctx);
Signature · 1 line
2.17.1
#7 lore raw

PATCH 4/4 ionic: clean up comments and whitespace

In reply to Shannon Nelson

Fix up some checkpatch complaints that have crept in:
doubled words words, mispellled words, doubled lines.

---
 drivers/net/ethernet/pensando/ionic/ionic_if.h    | 6 +++---
 drivers/net/ethernet/pensando/ionic/ionic_stats.c | 1 -
 drivers/net/ethernet/pensando/ionic/ionic_txrx.c  | 1 -
 3 files changed, 3 insertions(+), 5 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_if.h +3 -3
index 278610ed7227..4a90f611c611 100644
@@ -759,7 +759,7 @@ enum ionic_txq_desc_opcode {
  *                   IONIC_TXQ_DESC_OPCODE_CSUM_HW:
  *                      Offload 16-bit checksum computation to hardware.
  *                      If @csum_l3 is set then the packet's L3 checksum is
- *                      updated. Similarly, if @csum_l4 is set the the L4
+ *                      updated. Similarly, if @csum_l4 is set the L4
  *                      checksum is updated. If @encap is set then encap header
  *                      checksums are also updated.
  *
@@ -1368,9 +1368,9 @@ union ionic_port_config {
  * @status:             link status (enum ionic_port_oper_status)
  * @id:                 port id
  * @speed:              link speed (in Mbps)
- * @link_down_count:    number of times link went from from up to down
+ * @link_down_count:    number of times link went from up to down
  * @fec_type:           fec type (enum ionic_port_fec_type)
- * @xcvr:               tranceiver status
+ * @xcvr:               transceiver status
  */
 struct ionic_port_status {
 	__le32 id;
drivers/net/ethernet/pensando/ionic/ionic_stats.c +0 -1
index fd6806b4a1b9..9859a4432985 100644
@@ -151,7 +151,6 @@ static const struct ionic_stat_desc ionic_rx_stats_desc[] = {
 	IONIC_RX_STAT_DESC(vlan_stripped),
 };
 
-
 #define IONIC_NUM_LIF_STATS ARRAY_SIZE(ionic_lif_stats_desc)
 #define IONIC_NUM_PORT_STATS ARRAY_SIZE(ionic_port_stats_desc)
 #define IONIC_NUM_TX_STATS ARRAY_SIZE(ionic_tx_stats_desc)
drivers/net/ethernet/pensando/ionic/ionic_txrx.c +0 -1
index d197a70a49c9..f54035455ad6 100644
@@ -10,7 +10,6 @@
 #include "ionic_lif.h"
 #include "ionic_txrx.h"
 
-
 static inline void ionic_txq_post(struct ionic_queue *q, bool ring_dbell,
 				  ionic_desc_cb cb_func, void *cb_arg)
 {
Signature · 1 line
2.17.1