diff mbox series

[net-next:,08/12] ACPI: scan: prevent double enumeration of MDIO bus children

Message ID 20220620150225.1307946-9-mw@semihalf.com
State New
Headers show
Series ACPI support for DSA | expand

Commit Message

Marcin Wojtas June 20, 2022, 3:02 p.m. UTC
The MDIO bus is responsible for probing and registering its respective
children, such as PHYs or other kind of devices.

It is required that ACPI scan code should not enumerate such
devices, leaving this task for the generic MDIO bus routines,
which are initiated by the controller driver.

This patch prevents unwanted enumeration of the devices by setting
'enumeration_by_parent' flag, depending on whether their parent
device is a member of a known list of MDIO controllers. For now,
the Marvell MDIO controllers' IDs are added.

Signed-off-by: Marcin Wojtas <mw@semihalf.com>
---
 drivers/acpi/scan.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Comments

Andy Shevchenko June 20, 2022, 5:53 p.m. UTC | #1
On Mon, Jun 20, 2022 at 05:02:21PM +0200, Marcin Wojtas wrote:
> The MDIO bus is responsible for probing and registering its respective
> children, such as PHYs or other kind of devices.
> 
> It is required that ACPI scan code should not enumerate such
> devices, leaving this task for the generic MDIO bus routines,
> which are initiated by the controller driver.
> 
> This patch prevents unwanted enumeration of the devices by setting
> 'enumeration_by_parent' flag, depending on whether their parent
> device is a member of a known list of MDIO controllers. For now,
> the Marvell MDIO controllers' IDs are added.

This flag is used for serial buses that are not self-discoverable. Not sure
about MDIO, but the current usage has a relation to the _CRS. Have you
considered to propose the MdioSerialBus() resource type to ACPI specification?
Marcin Wojtas June 20, 2022, 11:04 p.m. UTC | #2
pon., 20 cze 2022 o 19:53 Andy Shevchenko
<andriy.shevchenko@linux.intel.com> napisał(a):
>
> On Mon, Jun 20, 2022 at 05:02:21PM +0200, Marcin Wojtas wrote:
> > The MDIO bus is responsible for probing and registering its respective
> > children, such as PHYs or other kind of devices.
> >
> > It is required that ACPI scan code should not enumerate such
> > devices, leaving this task for the generic MDIO bus routines,
> > which are initiated by the controller driver.
> >
> > This patch prevents unwanted enumeration of the devices by setting
> > 'enumeration_by_parent' flag, depending on whether their parent
> > device is a member of a known list of MDIO controllers. For now,
> > the Marvell MDIO controllers' IDs are added.
>
> This flag is used for serial buses that are not self-discoverable. Not sure
> about MDIO, but the current usage has a relation to the _CRS. Have you
> considered to propose the MdioSerialBus() resource type to ACPI specification?
>

Indeed, one of the cases checked in the
acpi_device_enumeration_by_parent() is checking _CRS (of the bus child
device) for being of the serial bus type. Currently I see
I2C/SPI/UARTSerialBus resource descriptors in the specification. Since
MDIO doesn't seem to require any special description macros like the
mentioned ones (for instance see I2CSerialBusV2 [1]), Based on
example: dfda4492322ed ("ACPI / scan: Do not enumerate Indirect IO
host children"), I thought of similar one perhaps being applicable.

Maybe there is some different, more proper solution, I'd be happy to
hear from the ACPI Maintainers.

[1] https://uefi.org/specs/ACPI/6.4/19_ASL_Reference/ACPI_Source_Language_Reference.html?highlight=i2cserialbus#i2cserialbusterm

Best regards,
Marcin
Rafael J. Wysocki June 22, 2022, 12:09 p.m. UTC | #3
On Tue, Jun 21, 2022 at 1:05 AM Marcin Wojtas <mw@semihalf.com> wrote:
>
> pon., 20 cze 2022 o 19:53 Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> napisał(a):
> >
> > On Mon, Jun 20, 2022 at 05:02:21PM +0200, Marcin Wojtas wrote:
> > > The MDIO bus is responsible for probing and registering its respective
> > > children, such as PHYs or other kind of devices.
> > >
> > > It is required that ACPI scan code should not enumerate such
> > > devices, leaving this task for the generic MDIO bus routines,
> > > which are initiated by the controller driver.
> > >
> > > This patch prevents unwanted enumeration of the devices by setting
> > > 'enumeration_by_parent' flag, depending on whether their parent
> > > device is a member of a known list of MDIO controllers. For now,
> > > the Marvell MDIO controllers' IDs are added.
> >
> > This flag is used for serial buses that are not self-discoverable. Not sure
> > about MDIO, but the current usage has a relation to the _CRS. Have you
> > considered to propose the MdioSerialBus() resource type to ACPI specification?
> >
>
> Indeed, one of the cases checked in the
> acpi_device_enumeration_by_parent() is checking _CRS (of the bus child
> device) for being of the serial bus type. Currently I see
> I2C/SPI/UARTSerialBus resource descriptors in the specification. Since
> MDIO doesn't seem to require any special description macros like the
> mentioned ones (for instance see I2CSerialBusV2 [1]), Based on
> example: dfda4492322ed ("ACPI / scan: Do not enumerate Indirect IO
> host children"), I thought of similar one perhaps being applicable.
>
> Maybe there is some different, more proper solution, I'd be happy to
> hear from the ACPI Maintainers.
>
> [1] https://uefi.org/specs/ACPI/6.4/19_ASL_Reference/ACPI_Source_Language_Reference.html?highlight=i2cserialbus#i2cserialbusterm

Well, the approach based on lists of device IDs is not scalable and
generally used as the last resort one.

It would be a lot better to have a way of representing connections to
the MDIO bus as resources in _CRS.
Marcin Wojtas June 22, 2022, 3:05 p.m. UTC | #4
śr., 22 cze 2022 o 14:09 Rafael J. Wysocki <rafael@kernel.org> napisał(a):
>
> On Tue, Jun 21, 2022 at 1:05 AM Marcin Wojtas <mw@semihalf.com> wrote:
> >
> > pon., 20 cze 2022 o 19:53 Andy Shevchenko
> > <andriy.shevchenko@linux.intel.com> napisał(a):
> > >
> > > On Mon, Jun 20, 2022 at 05:02:21PM +0200, Marcin Wojtas wrote:
> > > > The MDIO bus is responsible for probing and registering its respective
> > > > children, such as PHYs or other kind of devices.
> > > >
> > > > It is required that ACPI scan code should not enumerate such
> > > > devices, leaving this task for the generic MDIO bus routines,
> > > > which are initiated by the controller driver.
> > > >
> > > > This patch prevents unwanted enumeration of the devices by setting
> > > > 'enumeration_by_parent' flag, depending on whether their parent
> > > > device is a member of a known list of MDIO controllers. For now,
> > > > the Marvell MDIO controllers' IDs are added.
> > >
> > > This flag is used for serial buses that are not self-discoverable. Not sure
> > > about MDIO, but the current usage has a relation to the _CRS. Have you
> > > considered to propose the MdioSerialBus() resource type to ACPI specification?
> > >
> >
> > Indeed, one of the cases checked in the
> > acpi_device_enumeration_by_parent() is checking _CRS (of the bus child
> > device) for being of the serial bus type. Currently I see
> > I2C/SPI/UARTSerialBus resource descriptors in the specification. Since
> > MDIO doesn't seem to require any special description macros like the
> > mentioned ones (for instance see I2CSerialBusV2 [1]), Based on
> > example: dfda4492322ed ("ACPI / scan: Do not enumerate Indirect IO
> > host children"), I thought of similar one perhaps being applicable.
> >
> > Maybe there is some different, more proper solution, I'd be happy to
> > hear from the ACPI Maintainers.
> >
> > [1] https://uefi.org/specs/ACPI/6.4/19_ASL_Reference/ACPI_Source_Language_Reference.html?highlight=i2cserialbus#i2cserialbusterm
>
> Well, the approach based on lists of device IDs is not scalable and
> generally used as the last resort one.
>
> It would be a lot better to have a way of representing connections to
> the MDIO bus as resources in _CRS.

Thank you for your input. I will submit a proposal for MDIOSerialBus
_CRS resource macro then.

Best regards,
Marcin
diff mbox series

Patch

diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 762b61f67e6c..d703c35dc218 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1716,6 +1716,18 @@  static bool acpi_is_indirect_io_slave(struct acpi_device *device)
 	return parent && !acpi_match_device_ids(parent, indirect_io_hosts);
 }
 
+static bool acpi_is_mdio_child(struct acpi_device *device)
+{
+	struct acpi_device *parent = device->parent;
+	static const struct acpi_device_id mdio_controllers[] = {
+		{"MRVL0100", 0},
+		{"MRVL0101", 0},
+		{}
+	};
+
+	return parent && !acpi_match_device_ids(parent, mdio_controllers);
+}
+
 static bool acpi_device_enumeration_by_parent(struct acpi_device *device)
 {
 	struct list_head resource_list;
@@ -1756,6 +1768,9 @@  static bool acpi_device_enumeration_by_parent(struct acpi_device *device)
 	if (acpi_is_indirect_io_slave(device))
 		return true;
 
+	if (acpi_is_mdio_child(device))
+		return true;
+
 	/* Macs use device properties in lieu of _CRS resources */
 	if (x86_apple_machine &&
 	    (fwnode_property_present(&device->fwnode, "spiSclkPeriod") ||