Re: [net-next: PATCH 10/12] net: dsa: add ACPI support

From: Andrew Lunn
Date: Mon Jun 20 2022 - 14:32:18 EST


> static int dsa_port_parse_dsa(struct dsa_port *dp)
> {
> + /* Cascade switch connection is not supported in ACPI world. */
> + if (is_acpi_node(dp->fwnode)) {
> + dev_warn(dp->ds->dev,
> + "DSA type is not supported with ACPI, disable port #%d\n",
> + dp->index);
> + dp->type = DSA_PORT_TYPE_UNUSED;
> + return 0;
> + }
> +

Did you try this? I'm not sure it will work correctly. When a switch
registers with the DSA core, the core will poke around in DT and fill
in various bits of information, including the DSA links. Once that has
completed, the core will look at all the switches registered so far
and try to determine if it has a complete set, i.e, it has both ends
of all DSA links. If it does have a complete set, it then calls the
setup methods on each switch, and gets them configured. If it finds it
does not have a complete setup, it does nothing, waiting for the next
switch to register.

So if somebody passed an ACPI description with multiple switches, it
is likely to call the setup methods as soon as the first switch is
registered. And it might call those same setup methods a second time,
when the second switch registers, on both switches. And when the third
switch registers, it will probably call the setup methods yet again on
all the switches....

You will have a much safer system if you return -EINVAL if you find a
DSA link in ACPI. That should abort the switch probe.

Andrew