Skip to contentSkip to conversation

net/cxgbe: init data value before reading seeprom

PATCH Applied Emmanuel Roullit 4 participants 10 messages Jan 24, 2017 – Feb 14, 2017 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 net/cxgbe: init data value before reading seeprom

data value could have been garbage if VPD access timed out for VPD read request could not been issued.

Found with clang static analysis:
drivers/net/cxgbe/base/t4_hw.c:1577:22:
warning: The left operand of '&' is a garbage value

        } while ((stats_reg & 0x1) && --max_poll);
                  ~~~~~~~~~ ^
Fixes 17ba077c5c54 ("net/cxgbe: support register dump")
---
 drivers/net/cxgbe/base/t4_hw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/cxgbe/base/t4_hw.c +1 -1
index 7e79adf6d..c089b068d 100644
@@ -1532,7 +1532,7 @@ int t4_seeprom_write(struct adapter *adapter, u32 addr, u32 data)
 {
 	unsigned int base = adapter->params.pci.vpd_cap_addr;
 	int ret;
-	u32 stats_reg;
+	u32 stats_reg = 0;
 	int max_poll;
 
 	/* VPD Accesses must alway be 4-byte aligned!
Signature · 1 line
2.11.0
#1 lore raw

PATCH 2/3 net/cxgbe: remove unused variable usage

Found with clang static analysis:
drivers/net/cxgbe/sge.c:900:3: warning:
Value stored to 'in_use' is never read

        in_use += q->size;
        ^         ~~~~~~~
Fixes c167acb61278 ("net/cxgbe: use I/O device memory read/write API")
---
 drivers/net/cxgbe/sge.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/net/cxgbe/sge.c +0 -4
index fc03a0c26..42051ca01 100644
@@ -891,14 +891,10 @@ static inline int should_tx_packet_coalesce(struct sge_eth_txq *txq,
 	unsigned int flits, ndesc;
 	unsigned char type = 0;
 	int credits, hw_cidx = ntohs(q->stat->cidx);
-	int in_use = q->pidx - hw_cidx + flits_to_desc(q->coalesce.flits);
 
 	/* use coal WR type 1 when no frags are present */
 	type = (mbuf->nb_segs == 1) ? 1 : 0;
 
-	if (in_use < 0)
-		in_use += q->size;
-
 	if (unlikely(type != q->coalesce.type && q->coalesce.idx))
 		ship_tx_pkt_coalesce_wr(adap, txq);
 
Signature · 1 line
2.11.0
#2 lore raw

Re: [PATCH 2/3] net/cxgbe: remove unused variable usage

Quoted 18 lines · Emmanuel Roullit

Found with clang static analysis:
drivers/net/cxgbe/sge.c:900:3: warning:
Value stored to 'in_use' is never read

        in_use += q->size;
        ^         ~~~~~~~
Fixes c167acb61278 ("net/cxgbe: use I/O device memory read/write API")
---
 drivers/net/cxgbe/sge.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/net/cxgbe/sge.c +0 -0
index fc03a0c26..42051ca01 100644

drivers/net/cxgbe/sge.c static inline int should_tx_packet_coalesce(struct sge_eth_txq *txq, · line 900

Quoted 10 lines
drivers/net/cxgbe/sge.c +0 -3
@@ -891,14 +891,10 @@ static inline int should_tx_packet_coalesce(struct sge_eth_txq *txq,
 	unsigned int flits, ndesc;
 	unsigned char type = 0;
 	int credits, hw_cidx = ntohs(q->stat->cidx);
-	int in_use = q->pidx - hw_cidx + flits_to_desc(q->coalesce.flits);
 
 	/* use coal WR type 1 when no frags are present */
 	type = (mbuf->nb_segs == 1) ? 1 : 0;
 
-	if (in_use < 0)
-		in_use += q->size;

Intention can be "q->in_use" here. That change can be proper fix instead of removing.

I will wait for maintainers comment to get the patch.

Quoted 5 lines
drivers/net/cxgbe/sge.c +0 -1
-
 	if (unlikely(type != q->coalesce.type && q->coalesce.idx))
 		ship_tx_pkt_coalesce_wr(adap, txq);
 
#3 lore raw

Re: [PATCH 2/3] net/cxgbe: remove unused variable usage

Quoted 8 lines · Ferruh Yigit
Quoted 7 lines · Emmanuel Roullit

Found with clang static analysis:
drivers/net/cxgbe/sge.c:900:3: warning:
Value stored to 'in_use' is never read

        in_use += q->size;
        ^         ~~~~~~~
Fixes c167acb61278 ("net/cxgbe: use I/O device memory read/write API")

This fixes line seems to be wrong. Should be:

Fixes 4a01078b4fd1 ("cxgbe: add Tx support")
Quoted 19 lines
Quoted 19 lines
---
 drivers/net/cxgbe/sge.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/net/cxgbe/sge.c +0 -1
index fc03a0c26..42051ca01 100644
@@ -891,14 +891,10 @@ static inline int should_tx_packet_coalesce(struct sge_eth_txq *txq,
 	unsigned int flits, ndesc;
 	unsigned char type = 0;
 	int credits, hw_cidx = ntohs(q->stat->cidx);
-	int in_use = q->pidx - hw_cidx + flits_to_desc(q->coalesce.flits);
 
 	/* use coal WR type 1 when no frags are present */
 	type = (mbuf->nb_segs == 1) ? 1 : 0;
 
Quoted 8 lines

drivers/net/cxgbe/sge.c static inline int should_tx_packet_coalesce(struct sge_eth_txq *txq, · line 900

Quoted 2 lines
drivers/net/cxgbe/sge.c +0 -2
-	if (in_use < 0)
-		in_use += q->size;

Intention can be "q->in_use" here. That change can be proper fix instead of removing.

I will wait for maintainers comment to get the patch.

in_use can be removed. Also, Patch 2 and 3 can be merged.

Quoted 6 lines

drivers/net/cxgbe/sge.c static inline int should_tx_packet_coalesce(struct sge_eth_txq *txq, · line 900

Quoted 5 lines
drivers/net/cxgbe/sge.c +0 -1
-
 	if (unlikely(type != q->coalesce.type && q->coalesce.idx))
 		ship_tx_pkt_coalesce_wr(adap, txq);
 

Thanks,
Rahul

Acked-by Rahul Lakkireddy Applied
#4 lore raw

Re: [PATCH 2/3] net/cxgbe: remove unused variable usage

Quoted 10 lines · Rahul Lakkireddy
Quoted 8 lines · Ferruh Yigit
Quoted 7 lines · Emmanuel Roullit

Found with clang static analysis:
drivers/net/cxgbe/sge.c:900:3: warning:
Value stored to 'in_use' is never read

        in_use += q->size;
        ^         ~~~~~~~
Fixes c167acb61278 ("net/cxgbe: use I/O device memory read/write API")
Quoted 8 lines

This fixes line seems to be wrong. Should be:

Quoted 2 lines
Quoted 2 lines
Fixes 4a01078b4fd1 ("cxgbe: add Tx support")

Applied to dpdk-next-net/master, thanks.

(patch 2/3 and 3/3 merged)

#5 lore raw

Re: [PATCH 2/3] net/cxgbe: remove unused variable usage

Quoted 16 lines · Ferruh Yigit
Quoted 15 lines · Rahul Lakkireddy
Quoted 8 lines · Ferruh Yigit
Quoted 7 lines · Emmanuel Roullit

Found with clang static analysis:
drivers/net/cxgbe/sge.c:900:3: warning:
Value stored to 'in_use' is never read

        in_use += q->size;
        ^         ~~~~~~~
Fixes c167acb61278 ("net/cxgbe: use I/O device memory read/write API")

This fixes line seems to be wrong. Should be:

Quoted 1 line
Quoted 1 line
Quoted 4 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Fixes 4a01078b4fd1 ("cxgbe: add Tx support")

I doubt the necessary of picking it to a stable release: it doesn't fix a real bug after all. Therefore, I will drop it for v16.11.1.

	--yliu 
Quoted 7 lines

Applied to dpdk-next-net/master, thanks.

(patch 2/3 and 3/3 merged)

#6 lore raw

PATCH 3/3 net/cxgbe: remove unused variable

In reply to Emmanuel Roullit
Fixes c167acb61278 ("net/cxgbe: use I/O device memory read/write API")
---
 drivers/net/cxgbe/sge.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/cxgbe/sge.c +1 -1
index 42051ca01..37b609040 100644
@@ -890,7 +890,7 @@ static inline int should_tx_packet_coalesce(struct sge_eth_txq *txq,
 	struct sge_txq *q = &txq->q;
 	unsigned int flits, ndesc;
 	unsigned char type = 0;
-	int credits, hw_cidx = ntohs(q->stat->cidx);
+	int credits;
 
 	/* use coal WR type 1 when no frags are present */
 	type = (mbuf->nb_segs == 1) ? 1 : 0;
Signature · 1 line
2.11.0
#7 lore raw

Re: [PATCH 3/3] net/cxgbe: remove unused variable

Quoted 12 lines · Emmanuel Roullit
Fixes c167acb61278 ("net/cxgbe: use I/O device memory read/write API")
---
 drivers/net/cxgbe/sge.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/cxgbe/sge.c +0 -0
index 42051ca01..37b609040 100644

drivers/net/cxgbe/sge.c static inline int should_tx_packet_coalesce(struct sge_eth_txq *txq, · line 893

Quoted 5 lines
drivers/net/cxgbe/sge.c +1 -1
@@ -890,7 +890,7 @@ static inline int should_tx_packet_coalesce(struct sge_eth_txq *txq,
 	struct sge_txq *q = &txq->q;
 	unsigned int flits, ndesc;
 	unsigned char type = 0;
-	int credits, hw_cidx = ntohs(q->stat->cidx);
+	int credits;

This depends on patch 2/3, so this patch will wait it to be clarified.

Quoted 4 lines
drivers/net/cxgbe/sge.c +0 -0
 	/* use coal WR type 1 when no frags are present */
 	type = (mbuf->nb_segs == 1) ? 1 : 0;
 
Applied
#8 lore raw
In reply to Emmanuel Roullit
Quoted 6 lines · Emmanuel Roullit

data value could have been garbage if VPD access timed out for VPD read request could not been issued.

Found with clang static analysis:
drivers/net/cxgbe/base/t4_hw.c:1577:22:
warning: The left operand of '&' is a garbage value

Quoted 6 lines
        } while ((stats_reg & 0x1) && --max_poll);
                  ~~~~~~~~~ ^
Fixes 17ba077c5c54 ("net/cxgbe: support register dump")

Applied to dpdk-next-net/master, thanks.

#9 lore raw
Quoted 10 lines · Ferruh Yigit
Quoted 9 lines · Emmanuel Roullit

data value could have been garbage if VPD access timed out for VPD read request could not been issued.

Found with clang static analysis:
drivers/net/cxgbe/base/t4_hw.c:1577:22:
warning: The left operand of '&' is a garbage value

        } while ((stats_reg & 0x1) && --max_poll);
                  ~~~~~~~~~ ^
Quoted 6 lines
Quoted 3 lines
Fixes 17ba077c5c54 ("net/cxgbe: support register dump")

Applied to dpdk-next-net/master, thanks.

Fixes fe0bd9ee5da3 ("net/cxgbe: support EEPROM access")