[net-next,v4,4/4] net: dsa: mv88e6xxx: mask apparently non-existing phys during probing

Message ID 20230315163846.3114-5-klaus.kudielka@gmail.com
State New
Headers
Series net: dsa: mv88e6xxx: accelerate C45 scan |

Commit Message

Klaus Kudielka March 15, 2023, 4:38 p.m. UTC
  To avoid excessive mdio bus transactions during probing, mask all phy
addresses that do not exist (there is a 1:1 mapping between switch port
number and phy address).

Suggested-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Klaus Kudielka <klaus.kudielka@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---

Notes:
    v2: Patch is new

 drivers/net/dsa/mv88e6xxx/chip.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Vladimir Oltean March 17, 2023, 3:33 p.m. UTC | #1
On Wed, Mar 15, 2023 at 05:38:46PM +0100, Klaus Kudielka wrote:
> To avoid excessive mdio bus transactions during probing, mask all phy
> addresses that do not exist (there is a 1:1 mapping between switch port
> number and phy address).
> 
> Suggested-by: Andrew Lunn <andrew@lunn.ch>
> Signed-off-by: Klaus Kudielka <klaus.kudielka@gmail.com>
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
> ---

Reviewed-by: Vladimir Oltean <olteanv@gmail.com>

Note that on Turris MOX, the PHYs are described in the device tree, so
the MDIO bus is not auto-scanned and this patch has no effect, therefore
I won't add my Tested-by tag here.
  
Florian Fainelli March 17, 2023, 5:07 p.m. UTC | #2
On 3/15/23 09:38, Klaus Kudielka wrote:
> To avoid excessive mdio bus transactions during probing, mask all phy
> addresses that do not exist (there is a 1:1 mapping between switch port
> number and phy address).
> 
> Suggested-by: Andrew Lunn <andrew@lunn.ch>
> Signed-off-by: Klaus Kudielka <klaus.kudielka@gmail.com>
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
  
Marek Behún March 19, 2023, 10:06 a.m. UTC | #3
On Wed, 15 Mar 2023 17:38:46 +0100
Klaus Kudielka <klaus.kudielka@gmail.com> wrote:

> To avoid excessive mdio bus transactions during probing, mask all phy
> addresses that do not exist (there is a 1:1 mapping between switch port
> number and phy address).
> 
> Suggested-by: Andrew Lunn <andrew@lunn.ch>
> Signed-off-by: Klaus Kudielka <klaus.kudielka@gmail.com>
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
> ---
> 
> Notes:
>     v2: Patch is new
> 
>  drivers/net/dsa/mv88e6xxx/chip.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
> index 29b0f3bb1c..c52798d9ce 100644
> --- a/drivers/net/dsa/mv88e6xxx/chip.c
> +++ b/drivers/net/dsa/mv88e6xxx/chip.c
> @@ -3797,6 +3797,7 @@ static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
>  	bus->read_c45 = mv88e6xxx_mdio_read_c45;
>  	bus->write_c45 = mv88e6xxx_mdio_write_c45;
>  	bus->parent = chip->dev;
> +	bus->phy_mask = GENMASK(31, mv88e6xxx_num_ports(chip));

shouldnt this be
  GENMASK(31, mv88e6xxx_num_ports(chip) + chip->info->phy_base_addr) |
  GENMASK(chip->info->phy_base_addr, 0)
?
Or alternatively
  ~GENMASK(chip->info->phy_base_addr + mv88e6xxx_num_ports(chip),
           chip->info->phy_base_addr)

Marek
  
Vladimir Oltean March 19, 2023, 1:34 p.m. UTC | #4
On Sun, Mar 19, 2023 at 11:06:06AM +0100, Marek Behún wrote:
> > +	bus->phy_mask = GENMASK(31, mv88e6xxx_num_ports(chip));
> 
> shouldnt this be
>   GENMASK(31, mv88e6xxx_num_ports(chip) + chip->info->phy_base_addr) |
>   GENMASK(chip->info->phy_base_addr, 0)
> ?
> Or alternatively
>   ~GENMASK(chip->info->phy_base_addr + mv88e6xxx_num_ports(chip),
>            chip->info->phy_base_addr)

Good point. Would you mind sending a patch? I prefer the second variant BTW.
  
Vladimir Oltean March 19, 2023, 1:35 p.m. UTC | #5
On Sun, Mar 19, 2023 at 11:06:06AM +0100, Marek Behún wrote:
>   ~GENMASK(chip->info->phy_base_addr + mv88e6xxx_num_ports(chip),
>            chip->info->phy_base_addr)

But it needs to be ~GENMASK(base + num - 1, base), no?
  

Patch

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 29b0f3bb1c..c52798d9ce 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -3797,6 +3797,7 @@  static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
 	bus->read_c45 = mv88e6xxx_mdio_read_c45;
 	bus->write_c45 = mv88e6xxx_mdio_write_c45;
 	bus->parent = chip->dev;
+	bus->phy_mask = GENMASK(31, mv88e6xxx_num_ports(chip));
 
 	if (!external) {
 		err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);