Re: [RFC PATCH net-next 02/11] net: dsa: microchip: lan937x: update SMI index

From: Vladimir Oltean
Date: Fri Feb 03 2023 - 18:18:28 EST


On Thu, Feb 02, 2023 at 06:29:21PM +0530, Rakesh Sankaranarayanan wrote:
> Current DSA driver register mdio interface for a port in the
> format of SMI-switch_index:port_number, switch_index is derived
> using variable ds->index. For a single switch ds->index will be
> always zero, and for cascaded switch, ds->index should be one.
> But it is found that ds->index is getting updated only after
> mdio_register stage. Update mdio_register to use variable directly
> from device tree using "dsa,member" identifier.
>
> Signed-off-by: Rakesh Sankaranarayanan <rakesh.sankaranarayanan@xxxxxxxxxxxxx>
> ---

Impossible, check again.

The call path is:

ksz_switch_register()
-> dsa_register_switch()
-> dsa_switch_probe()
-> dsa_switch_parse_of()
-> dsa_switch_parse_member_of()
-> sets ds->index
-> dsa_tree_setup()
-> dsa_tree_setup_switches()
-> dsa_switch_setup()
-> ksz_setup()
-> ksz_mdio_register()
-> you claim ds->index isn't set

You don't even need to be an expert on the code path, you can grep for
"ds->index = ", put a dump_stack() where it's set and one where you need
it, and compare in the stack trace which functions are common and where
they diverge.