Skip to contentSkip to conversation

net: dsa: qca8k: Use up to 7 ports for all operations

PATCH Applied Michal Vokáč 3 participants 4 messages Sep 26, 2019 – Sep 30, 2019

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

PATCH 1/1 net: dsa: qca8k: Use up to 7 ports for all operations

The QCA8K family supports up to 7 ports. So use the existing QCA8K_NUM_PORTS define to allocate the switch structure and limit all operations with the switch ports.

This was not an issue until commit 0394a63acfe2 ("net: dsa: enable and disable all ports") disabled all unused ports. Since the unused ports 7-11 are outside of the correct register range on this switch some registers were rewritten with invalid content.

Fixes 6b93fb46480a ("net-next: dsa: add new driver for qca8xxx family")
Fixes a0c02161ecfc ("net: dsa: variable number of ports")
Fixes 0394a63acfe2 ("net: dsa: enable and disable all ports")

---
I am not sure which of the fixes tags should be used but this definetelly fixes something..

IMHO the 0394a63acfe2 ("net: dsa: enable and disable all ports") did not cause the issue but made it visible.

 drivers/net/dsa/qca8k.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/dsa/qca8k.c +2 -2
index 16f15c93a102..bbeeb8618c80 100644
@@ -705,7 +705,7 @@ qca8k_setup(struct dsa_switch *ds)
 		    BIT(0) << QCA8K_GLOBAL_FW_CTRL1_UC_DP_S);
 
 	/* Setup connection between CPU port & user ports */
-	for (i = 0; i < DSA_MAX_PORTS; i++) {
+	for (i = 0; i < QCA8K_NUM_PORTS; i++) {
 		/* CPU port gets connected to all user ports of the switch */
 		if (dsa_is_cpu_port(ds, i)) {
 			qca8k_rmw(priv, QCA8K_PORT_LOOKUP_CTRL(QCA8K_CPU_PORT),
@@ -1074,7 +1074,7 @@ qca8k_sw_probe(struct mdio_device *mdiodev)
 	if (id != QCA8K_ID_QCA8337)
 		return -ENODEV;
 
-	priv->ds = dsa_switch_alloc(&mdiodev->dev, DSA_MAX_PORTS);
+	priv->ds = dsa_switch_alloc(&mdiodev->dev, QCA8K_NUM_PORTS);
 	if (!priv->ds)
 		return -ENOMEM;
 
Signature · 1 line
2.1.4
#1 lore raw
Quoted 9 lines · Michal Vokáč

The QCA8K family supports up to 7 ports. So use the existing QCA8K_NUM_PORTS define to allocate the switch structure and limit all operations with the switch ports.

This was not an issue until commit 0394a63acfe2 ("net: dsa: enable and disable all ports") disabled all unused ports. Since the unused ports 7-11 are outside of the correct register range on this switch some registers were rewritten with invalid content.

Quoted 4 lines
Fixes 6b93fb46480a ("net-next: dsa: add new driver for qca8xxx family")
Fixes a0c02161ecfc ("net: dsa: variable number of ports")
Fixes 0394a63acfe2 ("net: dsa: enable and disable all ports")

More recent patches on the list are getting attention. Is this one falling through the cracks?

Quoted 33 lines

---
I am not sure which of the fixes tags should be used but this definetelly fixes something..

IMHO the 0394a63acfe2 ("net: dsa: enable and disable all ports") did not cause the issue but made it visible.

  drivers/net/dsa/qca8k.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/dsa/qca8k.c +2 -2
index 16f15c93a102..bbeeb8618c80 100644
@@ -705,7 +705,7 @@ qca8k_setup(struct dsa_switch *ds)
  		    BIT(0) << QCA8K_GLOBAL_FW_CTRL1_UC_DP_S);
 
  	/* Setup connection between CPU port & user ports */
-	for (i = 0; i < DSA_MAX_PORTS; i++) {
+	for (i = 0; i < QCA8K_NUM_PORTS; i++) {
  		/* CPU port gets connected to all user ports of the switch */
  		if (dsa_is_cpu_port(ds, i)) {
  			qca8k_rmw(priv, QCA8K_PORT_LOOKUP_CTRL(QCA8K_CPU_PORT),
@@ -1074,7 +1074,7 @@ qca8k_sw_probe(struct mdio_device *mdiodev)
  	if (id != QCA8K_ID_QCA8337)
  		return -ENODEV;
 
-	priv->ds = dsa_switch_alloc(&mdiodev->dev, DSA_MAX_PORTS);
+	priv->ds = dsa_switch_alloc(&mdiodev->dev, QCA8K_NUM_PORTS);
  	if (!priv->ds)
  		return -ENOMEM;
 
maintainer Reviewed-by
#2 lore raw
Quoted 10 lines · Michal Vokáč
Quoted 9 lines · Michal Vokáč

The QCA8K family supports up to 7 ports. So use the existing QCA8K_NUM_PORTS define to allocate the switch structure and limit all operations with the switch ports.

This was not an issue until commit 0394a63acfe2 ("net: dsa: enable and disable all ports") disabled all unused ports. Since the unused ports 7-11 are outside of the correct register range on this switch some registers were rewritten with invalid content.

Quoted 7 lines
Quoted 4 lines
Fixes 6b93fb46480a ("net-next: dsa: add new driver for qca8xxx family")
Fixes a0c02161ecfc ("net: dsa: variable number of ports")
Fixes 0394a63acfe2 ("net: dsa: enable and disable all ports")

More recent patches on the list are getting attention. Is this one falling through the cracks?

Probably not, it is missing a review-by, from somebody David trusts.

Andrew

maintainer Applied
#3 lore raw
In reply to Michal Vokáč

From: Michal Vokáč <[email protected]>
Date: Thu, 26 Sep 2019 10:59:17 +0200

Quoted 9 lines

The QCA8K family supports up to 7 ports. So use the existing QCA8K_NUM_PORTS define to allocate the switch structure and limit all operations with the switch ports.

This was not an issue until commit 0394a63acfe2 ("net: dsa: enable and disable all ports") disabled all unused ports. Since the unused ports 7-11 are outside of the correct register range on this switch some registers were rewritten with invalid content.

Quoted 4 lines
Fixes 6b93fb46480a ("net-next: dsa: add new driver for qca8xxx family")
Fixes a0c02161ecfc ("net: dsa: variable number of ports")
Fixes 0394a63acfe2 ("net: dsa: enable and disable all ports")

Applied.