linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: dsa: qca8k: Initialize the switch with correct number of ports
@ 2019-10-24 13:46 Michal Vokáč
  2019-10-24 13:58 ` Andrew Lunn
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Michal Vokáč @ 2019-10-24 13:46 UTC (permalink / raw)
  To: Vivien Didelot, David S. Miller, Jakub Kicinski, Andrew Lunn
  Cc: Florian Fainelli, netdev, linux-kernel, Michal Vokáč

Since commit 0394a63acfe2 ("net: dsa: enable and disable all ports")
the dsa core disables all unused ports of a switch. In this case
disabling ports with numbers higher than QCA8K_NUM_PORTS causes that
some switch registers are overwritten with incorrect content.

To fix this, initialize the dsa_switch->num_ports with correct number
of ports.

Fixes: 7e99e3470172 ("net: dsa: remove dsa_switch_alloc helper")
Signed-off-by: Michal Vokáč <michal.vokac@ysoft.com>
---
I actually tried and gave a T-b tag to the whole series that contains
the offending commit but obviously I was not careful enough. Who knows
what was on my mind and what I actually tested back then. Sorry.

 drivers/net/dsa/qca8k.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c
index 7e742cd491e8..36c6ed98f8e7 100644
--- a/drivers/net/dsa/qca8k.c
+++ b/drivers/net/dsa/qca8k.c
@@ -1083,7 +1083,7 @@ qca8k_sw_probe(struct mdio_device *mdiodev)
 		return -ENOMEM;
 
 	priv->ds->dev = &mdiodev->dev;
-	priv->ds->num_ports = DSA_MAX_PORTS;
+	priv->ds->num_ports = QCA8K_NUM_PORTS;
 	priv->ds->priv = priv;
 	priv->ops = qca8k_switch_ops;
 	priv->ds->ops = &priv->ops;
-- 
2.1.4


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

* Re: [PATCH net-next] net: dsa: qca8k: Initialize the switch with correct number of ports
  2019-10-24 13:46 [PATCH net-next] net: dsa: qca8k: Initialize the switch with correct number of ports Michal Vokáč
@ 2019-10-24 13:58 ` Andrew Lunn
  2019-10-24 14:12 ` Andrew Lunn
  2019-10-28 20:39 ` David Miller
  2 siblings, 0 replies; 6+ messages in thread
From: Andrew Lunn @ 2019-10-24 13:58 UTC (permalink / raw)
  To: Michal Vokáč
  Cc: Vivien Didelot, David S. Miller, Jakub Kicinski,
	Florian Fainelli, netdev, linux-kernel

On Thu, Oct 24, 2019 at 03:46:58PM +0200, Michal Vokáč wrote:
> Since commit 0394a63acfe2 ("net: dsa: enable and disable all ports")
> the dsa core disables all unused ports of a switch. In this case
> disabling ports with numbers higher than QCA8K_NUM_PORTS causes that
> some switch registers are overwritten with incorrect content.
> 
> To fix this, initialize the dsa_switch->num_ports with correct number
> of ports.
> 
> Fixes: 7e99e3470172 ("net: dsa: remove dsa_switch_alloc helper")
> Signed-off-by: Michal Vokáč <michal.vokac@ysoft.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH net-next] net: dsa: qca8k: Initialize the switch with correct number of ports
  2019-10-24 13:46 [PATCH net-next] net: dsa: qca8k: Initialize the switch with correct number of ports Michal Vokáč
  2019-10-24 13:58 ` Andrew Lunn
@ 2019-10-24 14:12 ` Andrew Lunn
  2019-10-24 16:33   ` Florian Fainelli
  2019-10-28 20:39 ` David Miller
  2 siblings, 1 reply; 6+ messages in thread
From: Andrew Lunn @ 2019-10-24 14:12 UTC (permalink / raw)
  To: Michal Vokáč
  Cc: Vivien Didelot, David S. Miller, Jakub Kicinski,
	Florian Fainelli, netdev, linux-kernel

On Thu, Oct 24, 2019 at 03:46:58PM +0200, Michal Vokáč wrote:
> Since commit 0394a63acfe2 ("net: dsa: enable and disable all ports")
> the dsa core disables all unused ports of a switch. In this case
> disabling ports with numbers higher than QCA8K_NUM_PORTS causes that
> some switch registers are overwritten with incorrect content.

Humm.

The same problem might exist in other drivers:

linux/drivers/net/dsa$ grep -r "ds->num_ports = DSA_MAX_PORTS"
qca8k.c:	priv->ds->num_ports = DSA_MAX_PORTS;
b53/b53_common.c:	ds->num_ports = DSA_MAX_PORTS;
mt7530.c:	priv->ds->num_ports = DSA_MAX_PORTS;
microchip/ksz_common.c:	ds->num_ports = DSA_MAX_PORTS;
dsa_loop.c:	ds->num_ports = DSA_MAX_PORTS;

dsa_loop.c looks O.K, it does support DSA_MAX_PORTS ports.

But the others?

    Andrew

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

* Re: [PATCH net-next] net: dsa: qca8k: Initialize the switch with correct number of ports
  2019-10-24 14:12 ` Andrew Lunn
@ 2019-10-24 16:33   ` Florian Fainelli
  2019-10-25 10:50     ` Michal Vokáč
  0 siblings, 1 reply; 6+ messages in thread
From: Florian Fainelli @ 2019-10-24 16:33 UTC (permalink / raw)
  To: Andrew Lunn, Michal Vokáč
  Cc: Vivien Didelot, David S. Miller, Jakub Kicinski, netdev, linux-kernel

On 10/24/19 7:12 AM, Andrew Lunn wrote:
> On Thu, Oct 24, 2019 at 03:46:58PM +0200, Michal Vokáč wrote:
>> Since commit 0394a63acfe2 ("net: dsa: enable and disable all ports")
>> the dsa core disables all unused ports of a switch. In this case
>> disabling ports with numbers higher than QCA8K_NUM_PORTS causes that
>> some switch registers are overwritten with incorrect content.
> 
> Humm.
> 
> The same problem might exist in other drivers:
> 
> linux/drivers/net/dsa$ grep -r "ds->num_ports = DSA_MAX_PORTS"
> qca8k.c:	priv->ds->num_ports = DSA_MAX_PORTS;
> b53/b53_common.c:	ds->num_ports = DSA_MAX_PORTS;

Not for b53 because this later gets clamped with dev->num_ports in
b53_setup().

> mt7530.c:	priv->ds->num_ports = DSA_MAX_PORTS;
> microchip/ksz_common.c:	ds->num_ports = DSA_MAX_PORTS;
> dsa_loop.c:	ds->num_ports = DSA_MAX_PORTS;
> 
> dsa_loop.c looks O.K, it does support DSA_MAX_PORTS ports.
> 
> But the others?
> 
>     Andrew
> 


-- 
Florian

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

* Re: [PATCH net-next] net: dsa: qca8k: Initialize the switch with correct number of ports
  2019-10-24 16:33   ` Florian Fainelli
@ 2019-10-25 10:50     ` Michal Vokáč
  0 siblings, 0 replies; 6+ messages in thread
From: Michal Vokáč @ 2019-10-25 10:50 UTC (permalink / raw)
  To: Florian Fainelli, Andrew Lunn
  Cc: Vivien Didelot, David S. Miller, Jakub Kicinski, netdev, linux-kernel

On 24. 10. 19 18:33, Florian Fainelli wrote:
> On 10/24/19 7:12 AM, Andrew Lunn wrote:
>> On Thu, Oct 24, 2019 at 03:46:58PM +0200, Michal Vokáč wrote:
>>> Since commit 0394a63acfe2 ("net: dsa: enable and disable all ports")
>>> the dsa core disables all unused ports of a switch. In this case
>>> disabling ports with numbers higher than QCA8K_NUM_PORTS causes that
>>> some switch registers are overwritten with incorrect content.
>>
>> Humm.
>>
>> The same problem might exist in other drivers:
>>
>> linux/drivers/net/dsa$ grep -r "ds->num_ports = DSA_MAX_PORTS"
>> qca8k.c:	priv->ds->num_ports = DSA_MAX_PORTS;
>> b53/b53_common.c:	ds->num_ports = DSA_MAX_PORTS;
> 
> Not for b53 because this later gets clamped with dev->num_ports in
> b53_setup().

I quickly checked the code and I think there is still an issue
in the b53_enable_port and b53_disable_port functions which are
called from the dsa_port_setup().

>> mt7530.c:	priv->ds->num_ports = DSA_MAX_PORTS;
>> microchip/ksz_common.c:	ds->num_ports = DSA_MAX_PORTS;

At first glance it looks like mt7530 and microchip has the same problem.

>> dsa_loop.c:	ds->num_ports = DSA_MAX_PORTS;
>>
>> dsa_loop.c looks O.K, it does support DSA_MAX_PORTS ports.
>>
>> But the others?
>>
>>      Andrew

I can respin and fix those drivers as well. Or a separate patch
for each one?

Michal

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

* Re: [PATCH net-next] net: dsa: qca8k: Initialize the switch with correct number of ports
  2019-10-24 13:46 [PATCH net-next] net: dsa: qca8k: Initialize the switch with correct number of ports Michal Vokáč
  2019-10-24 13:58 ` Andrew Lunn
  2019-10-24 14:12 ` Andrew Lunn
@ 2019-10-28 20:39 ` David Miller
  2 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2019-10-28 20:39 UTC (permalink / raw)
  To: michal.vokac
  Cc: vivien.didelot, jakub.kicinski, andrew, f.fainelli, netdev, linux-kernel

From: Michal Vokáč <michal.vokac@ysoft.com>
Date: Thu, 24 Oct 2019 15:46:58 +0200

> Since commit 0394a63acfe2 ("net: dsa: enable and disable all ports")
> the dsa core disables all unused ports of a switch. In this case
> disabling ports with numbers higher than QCA8K_NUM_PORTS causes that
> some switch registers are overwritten with incorrect content.
> 
> To fix this, initialize the dsa_switch->num_ports with correct number
> of ports.
> 
> Fixes: 7e99e3470172 ("net: dsa: remove dsa_switch_alloc helper")
> Signed-off-by: Michal Vokáč <michal.vokac@ysoft.com>

Applied.

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

end of thread, other threads:[~2019-10-28 20:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-24 13:46 [PATCH net-next] net: dsa: qca8k: Initialize the switch with correct number of ports Michal Vokáč
2019-10-24 13:58 ` Andrew Lunn
2019-10-24 14:12 ` Andrew Lunn
2019-10-24 16:33   ` Florian Fainelli
2019-10-25 10:50     ` Michal Vokáč
2019-10-28 20:39 ` David Miller

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).