All of lore.kernel.org
 help / color / mirror / Atom feed
* [net-next PATCH v7 00/16] ACPI support for dpaa2 driver
@ 2021-03-11  6:19 ` Calvin Johnson
  0 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11  6:19 UTC (permalink / raw)
  To: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap
  Cc: linux-arm-kernel, Diana Madalina Craciun, linux-acpi,
	linux-kernel, linux.cj, netdev, Laurentiu Tudor, Calvin Johnson,
	David S. Miller, Frank Rowand, Heiner Kallweit, Ioana Radulescu,
	Jakub Kicinski, Jamie Iles, Len Brown, Rafael J. Wysocki,
	Rob Herring, devicetree


This patch set provides ACPI support to DPAA2 network drivers.

It also introduces new fwnode based APIs to support phylink and phy
layers
    Following functions are defined:
      phylink_fwnode_phy_connect()
      fwnode_mdiobus_register_phy()
      fwnode_mdiobus_register()
      fwnode_get_phy_id()
      fwnode_phy_find_device()
      device_phy_find_device()
      fwnode_get_phy_node()
      fwnode_mdio_find_device()
      acpi_get_local_address()

    First one helps in connecting phy to phylink instance.
    Next three helps in getting phy_id and registering phy to mdiobus
    Next two help in finding a phy on a mdiobus.
    Next one helps in getting phy_node from a fwnode.
    Last one is used to get local address from _ADR object.

    Corresponding OF functions are refactored.

Tested-on: LX2160ARDB


Changes in v7:
- correct fwnode_mdio_find_device() description
- check NULL in unregister_mii_timestamper()
- Call unregister_mii_timestamper() without NULL check
- Create fwnode_mdio.c and move fwnode_mdiobus_register_phy()
- include fwnode_mdio.h
- Include headers directly used in acpi_mdio.c
- Move fwnode_mdiobus_register() to fwnode_mdio.c
- Include fwnode_mdio.h
- Alphabetically sort header inclusions
- remove unnecassary checks

Changes in v6:
- Minor cleanup
- fix warning for function parameter of fwnode_mdio_find_device()
- Initialize mii_ts to NULL
- use GENMASK() and ACPI_COMPANION_SET()
- some cleanup
- remove unwanted header inclusion
- remove OF check for fixed-link
- use dev_fwnode()
- remove useless else
- replace of_device_is_available() to fwnode_device_is_available()

Changes in v5:
- More cleanup
- Replace fwnode_get_id() with acpi_get_local_address()
- add missing MODULE_LICENSE()
- replace fwnode_get_id() with OF and ACPI function calls
- replace fwnode_get_id() with OF and ACPI function calls

Changes in v4:
- More cleanup
- Improve code structure to handle all cases
- Remove redundant else from fwnode_mdiobus_register()
- Cleanup xgmac_mdio_probe()
- call phy_device_free() before returning

Changes in v3:
- Add more info on legacy DT properties "phy" and "phy-device"
- Redefine fwnode_phy_find_device() to follow of_phy_find_device()
- Use traditional comparison pattern
- Use GENMASK
- Modified to retrieve reg property value for ACPI as well
- Resolved compilation issue with CONFIG_ACPI = n
- Added more info into documentation
- Use acpi_mdiobus_register()
- Avoid unnecessary line removal
- Remove unused inclusion of acpi.h

Changes in v2:
- Updated with more description in document
- use reverse christmas tree ordering for local variables
- Refactor OF functions to use fwnode functions

Calvin Johnson (16):
  Documentation: ACPI: DSD: Document MDIO PHY
  net: phy: Introduce fwnode_mdio_find_device()
  net: phy: Introduce phy related fwnode functions
  of: mdio: Refactor of_phy_find_device()
  net: phy: Introduce fwnode_get_phy_id()
  of: mdio: Refactor of_get_phy_id()
  net: mii_timestamper: check NULL in unregister_mii_timestamper()
  net: mdiobus: Introduce fwnode_mdiobus_register_phy()
  of: mdio: Refactor of_mdiobus_register_phy()
  ACPI: utils: Introduce acpi_get_local_address()
  net: mdio: Add ACPI support code for mdio
  net: mdiobus: Introduce fwnode_mdiobus_register()
  net/fsl: Use fwnode_mdiobus_register()
  net: phylink: introduce phylink_fwnode_phy_connect()
  net: phylink: Refactor phylink_of_phy_connect()
  net: dpaa2-mac: Add ACPI support for DPAA2 MAC driver

 Documentation/firmware-guide/acpi/dsd/phy.rst | 133 ++++++++++++++++++
 MAINTAINERS                                   |   2 +
 drivers/acpi/utils.c                          |  14 ++
 .../net/ethernet/freescale/dpaa2/dpaa2-mac.c  |  84 ++++++-----
 drivers/net/ethernet/freescale/xgmac_mdio.c   |  22 +--
 drivers/net/mdio/Kconfig                      |  16 +++
 drivers/net/mdio/Makefile                     |   4 +-
 drivers/net/mdio/acpi_mdio.c                  |  56 ++++++++
 drivers/net/mdio/fwnode_mdio.c                |  98 +++++++++++++
 drivers/net/mdio/of_mdio.c                    |  80 +----------
 drivers/net/phy/mii_timestamper.c             |   3 +
 drivers/net/phy/phy_device.c                  | 109 +++++++++++++-
 drivers/net/phy/phylink.c                     |  41 ++++--
 include/linux/acpi.h                          |   7 +
 include/linux/acpi_mdio.h                     |  25 ++++
 include/linux/fwnode_mdio.h                   |  29 ++++
 include/linux/of_mdio.h                       |   6 +-
 include/linux/phy.h                           |  31 ++++
 include/linux/phylink.h                       |   3 +
 19 files changed, 631 insertions(+), 132 deletions(-)
 create mode 100644 Documentation/firmware-guide/acpi/dsd/phy.rst
 create mode 100644 drivers/net/mdio/acpi_mdio.c
 create mode 100644 drivers/net/mdio/fwnode_mdio.c
 create mode 100644 include/linux/acpi_mdio.h
 create mode 100644 include/linux/fwnode_mdio.h

-- 
2.17.1


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

* [net-next PATCH v7 00/16] ACPI support for dpaa2 driver
@ 2021-03-11  6:19 ` Calvin Johnson
  0 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11  6:19 UTC (permalink / raw)
  To: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap
  Cc: linux-arm-kernel, Diana Madalina Craciun, linux-acpi,
	linux-kernel, linux.cj, netdev, Laurentiu Tudor, Calvin Johnson,
	David S. Miller, Frank Rowand, Heiner Kallweit, Ioana Radulescu,
	Jakub Kicinski, Jamie Iles, Len Brown, Rafael J. Wysocki,
	Rob Herring, devicetree


This patch set provides ACPI support to DPAA2 network drivers.

It also introduces new fwnode based APIs to support phylink and phy
layers
    Following functions are defined:
      phylink_fwnode_phy_connect()
      fwnode_mdiobus_register_phy()
      fwnode_mdiobus_register()
      fwnode_get_phy_id()
      fwnode_phy_find_device()
      device_phy_find_device()
      fwnode_get_phy_node()
      fwnode_mdio_find_device()
      acpi_get_local_address()

    First one helps in connecting phy to phylink instance.
    Next three helps in getting phy_id and registering phy to mdiobus
    Next two help in finding a phy on a mdiobus.
    Next one helps in getting phy_node from a fwnode.
    Last one is used to get local address from _ADR object.

    Corresponding OF functions are refactored.

Tested-on: LX2160ARDB


Changes in v7:
- correct fwnode_mdio_find_device() description
- check NULL in unregister_mii_timestamper()
- Call unregister_mii_timestamper() without NULL check
- Create fwnode_mdio.c and move fwnode_mdiobus_register_phy()
- include fwnode_mdio.h
- Include headers directly used in acpi_mdio.c
- Move fwnode_mdiobus_register() to fwnode_mdio.c
- Include fwnode_mdio.h
- Alphabetically sort header inclusions
- remove unnecassary checks

Changes in v6:
- Minor cleanup
- fix warning for function parameter of fwnode_mdio_find_device()
- Initialize mii_ts to NULL
- use GENMASK() and ACPI_COMPANION_SET()
- some cleanup
- remove unwanted header inclusion
- remove OF check for fixed-link
- use dev_fwnode()
- remove useless else
- replace of_device_is_available() to fwnode_device_is_available()

Changes in v5:
- More cleanup
- Replace fwnode_get_id() with acpi_get_local_address()
- add missing MODULE_LICENSE()
- replace fwnode_get_id() with OF and ACPI function calls
- replace fwnode_get_id() with OF and ACPI function calls

Changes in v4:
- More cleanup
- Improve code structure to handle all cases
- Remove redundant else from fwnode_mdiobus_register()
- Cleanup xgmac_mdio_probe()
- call phy_device_free() before returning

Changes in v3:
- Add more info on legacy DT properties "phy" and "phy-device"
- Redefine fwnode_phy_find_device() to follow of_phy_find_device()
- Use traditional comparison pattern
- Use GENMASK
- Modified to retrieve reg property value for ACPI as well
- Resolved compilation issue with CONFIG_ACPI = n
- Added more info into documentation
- Use acpi_mdiobus_register()
- Avoid unnecessary line removal
- Remove unused inclusion of acpi.h

Changes in v2:
- Updated with more description in document
- use reverse christmas tree ordering for local variables
- Refactor OF functions to use fwnode functions

Calvin Johnson (16):
  Documentation: ACPI: DSD: Document MDIO PHY
  net: phy: Introduce fwnode_mdio_find_device()
  net: phy: Introduce phy related fwnode functions
  of: mdio: Refactor of_phy_find_device()
  net: phy: Introduce fwnode_get_phy_id()
  of: mdio: Refactor of_get_phy_id()
  net: mii_timestamper: check NULL in unregister_mii_timestamper()
  net: mdiobus: Introduce fwnode_mdiobus_register_phy()
  of: mdio: Refactor of_mdiobus_register_phy()
  ACPI: utils: Introduce acpi_get_local_address()
  net: mdio: Add ACPI support code for mdio
  net: mdiobus: Introduce fwnode_mdiobus_register()
  net/fsl: Use fwnode_mdiobus_register()
  net: phylink: introduce phylink_fwnode_phy_connect()
  net: phylink: Refactor phylink_of_phy_connect()
  net: dpaa2-mac: Add ACPI support for DPAA2 MAC driver

 Documentation/firmware-guide/acpi/dsd/phy.rst | 133 ++++++++++++++++++
 MAINTAINERS                                   |   2 +
 drivers/acpi/utils.c                          |  14 ++
 .../net/ethernet/freescale/dpaa2/dpaa2-mac.c  |  84 ++++++-----
 drivers/net/ethernet/freescale/xgmac_mdio.c   |  22 +--
 drivers/net/mdio/Kconfig                      |  16 +++
 drivers/net/mdio/Makefile                     |   4 +-
 drivers/net/mdio/acpi_mdio.c                  |  56 ++++++++
 drivers/net/mdio/fwnode_mdio.c                |  98 +++++++++++++
 drivers/net/mdio/of_mdio.c                    |  80 +----------
 drivers/net/phy/mii_timestamper.c             |   3 +
 drivers/net/phy/phy_device.c                  | 109 +++++++++++++-
 drivers/net/phy/phylink.c                     |  41 ++++--
 include/linux/acpi.h                          |   7 +
 include/linux/acpi_mdio.h                     |  25 ++++
 include/linux/fwnode_mdio.h                   |  29 ++++
 include/linux/of_mdio.h                       |   6 +-
 include/linux/phy.h                           |  31 ++++
 include/linux/phylink.h                       |   3 +
 19 files changed, 631 insertions(+), 132 deletions(-)
 create mode 100644 Documentation/firmware-guide/acpi/dsd/phy.rst
 create mode 100644 drivers/net/mdio/acpi_mdio.c
 create mode 100644 drivers/net/mdio/fwnode_mdio.c
 create mode 100644 include/linux/acpi_mdio.h
 create mode 100644 include/linux/fwnode_mdio.h

-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [net-next PATCH v7 01/16] Documentation: ACPI: DSD: Document MDIO PHY
  2021-03-11  6:19 ` Calvin Johnson
@ 2021-03-11  6:19   ` Calvin Johnson
  -1 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11  6:19 UTC (permalink / raw)
  To: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap
  Cc: linux-arm-kernel, Diana Madalina Craciun, linux-acpi,
	linux-kernel, linux.cj, netdev, Laurentiu Tudor, Calvin Johnson,
	Len Brown, Rafael J. Wysocki

Introduce ACPI mechanism to get PHYs registered on a MDIO bus and
provide them to be connected to MAC.

Describe properties "phy-handle" and "phy-mode".

Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---

Changes in v7: None
Changes in v6:
- Minor cleanup

Changes in v5:
- More cleanup

Changes in v4:
- More cleanup

Changes in v3: None
Changes in v2:
- Updated with more description in document

 Documentation/firmware-guide/acpi/dsd/phy.rst | 133 ++++++++++++++++++
 1 file changed, 133 insertions(+)
 create mode 100644 Documentation/firmware-guide/acpi/dsd/phy.rst

diff --git a/Documentation/firmware-guide/acpi/dsd/phy.rst b/Documentation/firmware-guide/acpi/dsd/phy.rst
new file mode 100644
index 000000000000..7d01ae8b3cc6
--- /dev/null
+++ b/Documentation/firmware-guide/acpi/dsd/phy.rst
@@ -0,0 +1,133 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+=========================
+MDIO bus and PHYs in ACPI
+=========================
+
+The PHYs on an MDIO bus [1] are probed and registered using
+fwnode_mdiobus_register_phy().
+
+Later, for connecting these PHYs to their respective MACs, the PHYs registered
+on the MDIO bus have to be referenced.
+
+This document introduces two _DSD properties that are to be used
+for connecting PHYs on the MDIO bus [3] to the MAC layer.
+
+These properties are defined in accordance with the "Device
+Properties UUID For _DSD" [2] document and the
+daffd814-6eba-4d8c-8a91-bc9bbf4aa301 UUID must be used in the Device
+Data Descriptors containing them.
+
+phy-handle
+----------
+For each MAC node, a device property "phy-handle" is used to reference
+the PHY that is registered on an MDIO bus. This is mandatory for
+network interfaces that have PHYs connected to MAC via MDIO bus.
+
+During the MDIO bus driver initialization, PHYs on this bus are probed
+using the _ADR object as shown below and are registered on the MDIO bus.
+
+::
+      Scope(\_SB.MDI0)
+      {
+        Device(PHY1) {
+          Name (_ADR, 0x1)
+        } // end of PHY1
+
+        Device(PHY2) {
+          Name (_ADR, 0x2)
+        } // end of PHY2
+      }
+
+Later, during the MAC driver initialization, the registered PHY devices
+have to be retrieved from the MDIO bus. For this, the MAC driver needs
+references to the previously registered PHYs which are provided
+as device object references (e.g. \_SB.MDI0.PHY1).
+
+phy-mode
+--------
+The "phy-mode" _DSD property is used to describe the connection to
+the PHY. The valid values for "phy-mode" are defined in [4].
+
+The following ASL example illustrates the usage of these properties.
+
+DSDT entry for MDIO node
+------------------------
+
+The MDIO bus has an SoC component (MDIO controller) and a platform
+component (PHYs on the MDIO bus).
+
+a) Silicon Component
+This node describes the MDIO controller, MDI0
+---------------------------------------------
+::
+	Scope(_SB)
+	{
+	  Device(MDI0) {
+	    Name(_HID, "NXP0006")
+	    Name(_CCA, 1)
+	    Name(_UID, 0)
+	    Name(_CRS, ResourceTemplate() {
+	      Memory32Fixed(ReadWrite, MDI0_BASE, MDI_LEN)
+	      Interrupt(ResourceConsumer, Level, ActiveHigh, Shared)
+	       {
+		 MDI0_IT
+	       }
+	    }) // end of _CRS for MDI0
+	  } // end of MDI0
+	}
+
+b) Platform Component
+The PHY1 and PHY2 nodes represent the PHYs connected to MDIO bus MDI0
+---------------------------------------------------------------------
+::
+	Scope(\_SB.MDI0)
+	{
+	  Device(PHY1) {
+	    Name (_ADR, 0x1)
+	  } // end of PHY1
+
+	  Device(PHY2) {
+	    Name (_ADR, 0x2)
+	  } // end of PHY2
+	}
+
+DSDT entries representing MAC nodes
+-----------------------------------
+
+Below are the MAC nodes where PHY nodes are referenced.
+phy-mode and phy-handle are used as explained earlier.
+------------------------------------------------------
+::
+	Scope(\_SB.MCE0.PR17)
+	{
+	  Name (_DSD, Package () {
+	     ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
+		 Package () {
+		     Package (2) {"phy-mode", "rgmii-id"},
+		     Package (2) {"phy-handle", \_SB.MDI0.PHY1}
+	      }
+	   })
+	}
+
+	Scope(\_SB.MCE0.PR18)
+	{
+	  Name (_DSD, Package () {
+	    ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
+		Package () {
+		    Package (2) {"phy-mode", "rgmii-id"},
+		    Package (2) {"phy-handle", \_SB.MDI0.PHY2}}
+	    }
+	  })
+	}
+
+References
+==========
+
+[1] Documentation/networking/phy.rst
+
+[2] https://www.uefi.org/sites/default/files/resources/_DSD-device-properties-UUID.pdf
+
+[3] Documentation/firmware-guide/acpi/DSD-properties-rules.rst
+
+[4] Documentation/devicetree/bindings/net/ethernet-controller.yaml
-- 
2.17.1


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

* [net-next PATCH v7 01/16] Documentation: ACPI: DSD: Document MDIO PHY
@ 2021-03-11  6:19   ` Calvin Johnson
  0 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11  6:19 UTC (permalink / raw)
  To: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap
  Cc: linux-arm-kernel, Diana Madalina Craciun, linux-acpi,
	linux-kernel, linux.cj, netdev, Laurentiu Tudor, Calvin Johnson,
	Len Brown, Rafael J. Wysocki

Introduce ACPI mechanism to get PHYs registered on a MDIO bus and
provide them to be connected to MAC.

Describe properties "phy-handle" and "phy-mode".

Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---

Changes in v7: None
Changes in v6:
- Minor cleanup

Changes in v5:
- More cleanup

Changes in v4:
- More cleanup

Changes in v3: None
Changes in v2:
- Updated with more description in document

 Documentation/firmware-guide/acpi/dsd/phy.rst | 133 ++++++++++++++++++
 1 file changed, 133 insertions(+)
 create mode 100644 Documentation/firmware-guide/acpi/dsd/phy.rst

diff --git a/Documentation/firmware-guide/acpi/dsd/phy.rst b/Documentation/firmware-guide/acpi/dsd/phy.rst
new file mode 100644
index 000000000000..7d01ae8b3cc6
--- /dev/null
+++ b/Documentation/firmware-guide/acpi/dsd/phy.rst
@@ -0,0 +1,133 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+=========================
+MDIO bus and PHYs in ACPI
+=========================
+
+The PHYs on an MDIO bus [1] are probed and registered using
+fwnode_mdiobus_register_phy().
+
+Later, for connecting these PHYs to their respective MACs, the PHYs registered
+on the MDIO bus have to be referenced.
+
+This document introduces two _DSD properties that are to be used
+for connecting PHYs on the MDIO bus [3] to the MAC layer.
+
+These properties are defined in accordance with the "Device
+Properties UUID For _DSD" [2] document and the
+daffd814-6eba-4d8c-8a91-bc9bbf4aa301 UUID must be used in the Device
+Data Descriptors containing them.
+
+phy-handle
+----------
+For each MAC node, a device property "phy-handle" is used to reference
+the PHY that is registered on an MDIO bus. This is mandatory for
+network interfaces that have PHYs connected to MAC via MDIO bus.
+
+During the MDIO bus driver initialization, PHYs on this bus are probed
+using the _ADR object as shown below and are registered on the MDIO bus.
+
+::
+      Scope(\_SB.MDI0)
+      {
+        Device(PHY1) {
+          Name (_ADR, 0x1)
+        } // end of PHY1
+
+        Device(PHY2) {
+          Name (_ADR, 0x2)
+        } // end of PHY2
+      }
+
+Later, during the MAC driver initialization, the registered PHY devices
+have to be retrieved from the MDIO bus. For this, the MAC driver needs
+references to the previously registered PHYs which are provided
+as device object references (e.g. \_SB.MDI0.PHY1).
+
+phy-mode
+--------
+The "phy-mode" _DSD property is used to describe the connection to
+the PHY. The valid values for "phy-mode" are defined in [4].
+
+The following ASL example illustrates the usage of these properties.
+
+DSDT entry for MDIO node
+------------------------
+
+The MDIO bus has an SoC component (MDIO controller) and a platform
+component (PHYs on the MDIO bus).
+
+a) Silicon Component
+This node describes the MDIO controller, MDI0
+---------------------------------------------
+::
+	Scope(_SB)
+	{
+	  Device(MDI0) {
+	    Name(_HID, "NXP0006")
+	    Name(_CCA, 1)
+	    Name(_UID, 0)
+	    Name(_CRS, ResourceTemplate() {
+	      Memory32Fixed(ReadWrite, MDI0_BASE, MDI_LEN)
+	      Interrupt(ResourceConsumer, Level, ActiveHigh, Shared)
+	       {
+		 MDI0_IT
+	       }
+	    }) // end of _CRS for MDI0
+	  } // end of MDI0
+	}
+
+b) Platform Component
+The PHY1 and PHY2 nodes represent the PHYs connected to MDIO bus MDI0
+---------------------------------------------------------------------
+::
+	Scope(\_SB.MDI0)
+	{
+	  Device(PHY1) {
+	    Name (_ADR, 0x1)
+	  } // end of PHY1
+
+	  Device(PHY2) {
+	    Name (_ADR, 0x2)
+	  } // end of PHY2
+	}
+
+DSDT entries representing MAC nodes
+-----------------------------------
+
+Below are the MAC nodes where PHY nodes are referenced.
+phy-mode and phy-handle are used as explained earlier.
+------------------------------------------------------
+::
+	Scope(\_SB.MCE0.PR17)
+	{
+	  Name (_DSD, Package () {
+	     ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
+		 Package () {
+		     Package (2) {"phy-mode", "rgmii-id"},
+		     Package (2) {"phy-handle", \_SB.MDI0.PHY1}
+	      }
+	   })
+	}
+
+	Scope(\_SB.MCE0.PR18)
+	{
+	  Name (_DSD, Package () {
+	    ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
+		Package () {
+		    Package (2) {"phy-mode", "rgmii-id"},
+		    Package (2) {"phy-handle", \_SB.MDI0.PHY2}}
+	    }
+	  })
+	}
+
+References
+==========
+
+[1] Documentation/networking/phy.rst
+
+[2] https://www.uefi.org/sites/default/files/resources/_DSD-device-properties-UUID.pdf
+
+[3] Documentation/firmware-guide/acpi/DSD-properties-rules.rst
+
+[4] Documentation/devicetree/bindings/net/ethernet-controller.yaml
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [net-next PATCH v7 02/16] net: phy: Introduce fwnode_mdio_find_device()
  2021-03-11  6:19 ` Calvin Johnson
@ 2021-03-11  6:19   ` Calvin Johnson
  -1 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11  6:19 UTC (permalink / raw)
  To: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap
  Cc: linux-arm-kernel, Diana Madalina Craciun, linux-acpi,
	linux-kernel, linux.cj, netdev, Laurentiu Tudor, Calvin Johnson,
	David S. Miller, Heiner Kallweit, Jakub Kicinski

Define fwnode_mdio_find_device() to get a pointer to the
mdio_device from fwnode passed to the function.

Refactor of_mdio_find_device() to use fwnode_mdio_find_device().

Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---

Changes in v7:
- correct fwnode_mdio_find_device() description

Changes in v6:
- fix warning for function parameter of fwnode_mdio_find_device()

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/net/mdio/of_mdio.c   | 11 +----------
 drivers/net/phy/phy_device.c | 23 +++++++++++++++++++++++
 include/linux/phy.h          |  6 ++++++
 3 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c
index ea9d5855fb52..d5e0970b2561 100644
--- a/drivers/net/mdio/of_mdio.c
+++ b/drivers/net/mdio/of_mdio.c
@@ -347,16 +347,7 @@ EXPORT_SYMBOL(of_mdiobus_register);
  */
 struct mdio_device *of_mdio_find_device(struct device_node *np)
 {
-	struct device *d;
-
-	if (!np)
-		return NULL;
-
-	d = bus_find_device_by_of_node(&mdio_bus_type, np);
-	if (!d)
-		return NULL;
-
-	return to_mdio_device(d);
+	return fwnode_mdio_find_device(of_fwnode_handle(np));
 }
 EXPORT_SYMBOL(of_mdio_find_device);
 
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index cc38e326405a..daabb17bba00 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -2819,6 +2819,29 @@ static bool phy_drv_supports_irq(struct phy_driver *phydrv)
 	return phydrv->config_intr && phydrv->handle_interrupt;
 }
 
+/**
+ * fwnode_mdio_find_device - Given a fwnode, find the mdio_device
+ * @fwnode: pointer to the mdio_device's fwnode
+ *
+ * If successful, returns a pointer to the mdio_device with the embedded
+ * struct device refcount incremented by one, or NULL on failure.
+ * The caller should call put_device() on the mdio_device after its use.
+ */
+struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode)
+{
+	struct device *d;
+
+	if (!fwnode)
+		return NULL;
+
+	d = bus_find_device_by_fwnode(&mdio_bus_type, fwnode);
+	if (!d)
+		return NULL;
+
+	return to_mdio_device(d);
+}
+EXPORT_SYMBOL(fwnode_mdio_find_device);
+
 /**
  * phy_probe - probe and init a PHY device
  * @dev: device to probe and init
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 1a12e4436b5b..f5eb1e3981a1 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -1366,11 +1366,17 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id,
 				     bool is_c45,
 				     struct phy_c45_device_ids *c45_ids);
 #if IS_ENABLED(CONFIG_PHYLIB)
+struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode);
 struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45);
 int phy_device_register(struct phy_device *phy);
 void phy_device_free(struct phy_device *phydev);
 #else
 static inline
+struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode)
+{
+	return 0;
+}
+static inline
 struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45)
 {
 	return NULL;
-- 
2.17.1


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

* [net-next PATCH v7 02/16] net: phy: Introduce fwnode_mdio_find_device()
@ 2021-03-11  6:19   ` Calvin Johnson
  0 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11  6:19 UTC (permalink / raw)
  To: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap
  Cc: linux-arm-kernel, Diana Madalina Craciun, linux-acpi,
	linux-kernel, linux.cj, netdev, Laurentiu Tudor, Calvin Johnson,
	David S. Miller, Heiner Kallweit, Jakub Kicinski

Define fwnode_mdio_find_device() to get a pointer to the
mdio_device from fwnode passed to the function.

Refactor of_mdio_find_device() to use fwnode_mdio_find_device().

Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---

Changes in v7:
- correct fwnode_mdio_find_device() description

Changes in v6:
- fix warning for function parameter of fwnode_mdio_find_device()

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/net/mdio/of_mdio.c   | 11 +----------
 drivers/net/phy/phy_device.c | 23 +++++++++++++++++++++++
 include/linux/phy.h          |  6 ++++++
 3 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c
index ea9d5855fb52..d5e0970b2561 100644
--- a/drivers/net/mdio/of_mdio.c
+++ b/drivers/net/mdio/of_mdio.c
@@ -347,16 +347,7 @@ EXPORT_SYMBOL(of_mdiobus_register);
  */
 struct mdio_device *of_mdio_find_device(struct device_node *np)
 {
-	struct device *d;
-
-	if (!np)
-		return NULL;
-
-	d = bus_find_device_by_of_node(&mdio_bus_type, np);
-	if (!d)
-		return NULL;
-
-	return to_mdio_device(d);
+	return fwnode_mdio_find_device(of_fwnode_handle(np));
 }
 EXPORT_SYMBOL(of_mdio_find_device);
 
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index cc38e326405a..daabb17bba00 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -2819,6 +2819,29 @@ static bool phy_drv_supports_irq(struct phy_driver *phydrv)
 	return phydrv->config_intr && phydrv->handle_interrupt;
 }
 
+/**
+ * fwnode_mdio_find_device - Given a fwnode, find the mdio_device
+ * @fwnode: pointer to the mdio_device's fwnode
+ *
+ * If successful, returns a pointer to the mdio_device with the embedded
+ * struct device refcount incremented by one, or NULL on failure.
+ * The caller should call put_device() on the mdio_device after its use.
+ */
+struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode)
+{
+	struct device *d;
+
+	if (!fwnode)
+		return NULL;
+
+	d = bus_find_device_by_fwnode(&mdio_bus_type, fwnode);
+	if (!d)
+		return NULL;
+
+	return to_mdio_device(d);
+}
+EXPORT_SYMBOL(fwnode_mdio_find_device);
+
 /**
  * phy_probe - probe and init a PHY device
  * @dev: device to probe and init
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 1a12e4436b5b..f5eb1e3981a1 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -1366,11 +1366,17 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id,
 				     bool is_c45,
 				     struct phy_c45_device_ids *c45_ids);
 #if IS_ENABLED(CONFIG_PHYLIB)
+struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode);
 struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45);
 int phy_device_register(struct phy_device *phy);
 void phy_device_free(struct phy_device *phydev);
 #else
 static inline
+struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode)
+{
+	return 0;
+}
+static inline
 struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45)
 {
 	return NULL;
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [net-next PATCH v7 03/16] net: phy: Introduce phy related fwnode functions
  2021-03-11  6:19 ` Calvin Johnson
@ 2021-03-11  6:19   ` Calvin Johnson
  -1 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11  6:19 UTC (permalink / raw)
  To: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap
  Cc: linux-arm-kernel, Diana Madalina Craciun, linux-acpi,
	linux-kernel, linux.cj, netdev, Laurentiu Tudor, Calvin Johnson,
	David S. Miller, Heiner Kallweit, Jakub Kicinski

Define fwnode_phy_find_device() to iterate an mdiobus and find the
phy device of the provided phy fwnode. Additionally define
device_phy_find_device() to find phy device of provided device.

Define fwnode_get_phy_node() to get phy_node using named reference.

Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3:
- Add more info on legacy DT properties "phy" and "phy-device"
- Redefine fwnode_phy_find_device() to follow of_phy_find_device()

Changes in v2:
- use reverse christmas tree ordering for local variables

 drivers/net/phy/phy_device.c | 62 ++++++++++++++++++++++++++++++++++++
 include/linux/phy.h          | 20 ++++++++++++
 2 files changed, 82 insertions(+)

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index daabb17bba00..aec8dadf5d8b 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -9,6 +9,7 @@
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
+#include <linux/acpi.h>
 #include <linux/bitmap.h>
 #include <linux/delay.h>
 #include <linux/errno.h>
@@ -2842,6 +2843,67 @@ struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode)
 }
 EXPORT_SYMBOL(fwnode_mdio_find_device);
 
+/**
+ * fwnode_phy_find_device - For provided phy_fwnode, find phy_device.
+ *
+ * @phy_fwnode: Pointer to the phy's fwnode.
+ *
+ * If successful, returns a pointer to the phy_device with the embedded
+ * struct device refcount incremented by one, or NULL on failure.
+ */
+struct phy_device *fwnode_phy_find_device(struct fwnode_handle *phy_fwnode)
+{
+	struct mdio_device *mdiodev;
+
+	mdiodev = fwnode_mdio_find_device(phy_fwnode);
+	if (!mdiodev)
+		return NULL;
+
+	if (mdiodev->flags & MDIO_DEVICE_FLAG_PHY)
+		return to_phy_device(&mdiodev->dev);
+
+	put_device(&mdiodev->dev);
+
+	return NULL;
+}
+EXPORT_SYMBOL(fwnode_phy_find_device);
+
+/**
+ * device_phy_find_device - For the given device, get the phy_device
+ * @dev: Pointer to the given device
+ *
+ * Refer return conditions of fwnode_phy_find_device().
+ */
+struct phy_device *device_phy_find_device(struct device *dev)
+{
+	return fwnode_phy_find_device(dev_fwnode(dev));
+}
+EXPORT_SYMBOL_GPL(device_phy_find_device);
+
+/**
+ * fwnode_get_phy_node - Get the phy_node using the named reference.
+ * @fwnode: Pointer to fwnode from which phy_node has to be obtained.
+ *
+ * Refer return conditions of fwnode_find_reference().
+ * For ACPI, only "phy-handle" is supported. Legacy DT properties "phy"
+ * and "phy-device" are not supported in ACPI. DT supports all the three
+ * named references to the phy node.
+ */
+struct fwnode_handle *fwnode_get_phy_node(struct fwnode_handle *fwnode)
+{
+	struct fwnode_handle *phy_node;
+
+	/* Only phy-handle is used for ACPI */
+	phy_node = fwnode_find_reference(fwnode, "phy-handle", 0);
+	if (is_acpi_node(fwnode) || !IS_ERR(phy_node))
+		return phy_node;
+	phy_node = fwnode_find_reference(fwnode, "phy", 0);
+	if (IS_ERR(phy_node))
+		phy_node = fwnode_find_reference(fwnode, "phy-device", 0);
+	return phy_node;
+}
+EXPORT_SYMBOL_GPL(fwnode_get_phy_node);
+
 /**
  * phy_probe - probe and init a PHY device
  * @dev: device to probe and init
diff --git a/include/linux/phy.h b/include/linux/phy.h
index f5eb1e3981a1..720a2a8cf355 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -1367,6 +1367,9 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id,
 				     struct phy_c45_device_ids *c45_ids);
 #if IS_ENABLED(CONFIG_PHYLIB)
 struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode);
+struct phy_device *fwnode_phy_find_device(struct fwnode_handle *phy_fwnode);
+struct phy_device *device_phy_find_device(struct device *dev);
+struct fwnode_handle *fwnode_get_phy_node(struct fwnode_handle *fwnode);
 struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45);
 int phy_device_register(struct phy_device *phy);
 void phy_device_free(struct phy_device *phydev);
@@ -1376,6 +1379,23 @@ struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode)
 {
 	return 0;
 }
+static inline
+struct phy_device *fwnode_phy_find_device(struct fwnode_handle *phy_fwnode)
+{
+	return NULL;
+}
+
+static inline struct phy_device *device_phy_find_device(struct device *dev)
+{
+	return NULL;
+}
+
+static inline
+struct fwnode_handle *fwnode_get_phy_node(struct fwnode_handle *fwnode)
+{
+	return NULL;
+}
+
 static inline
 struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45)
 {
-- 
2.17.1


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

* [net-next PATCH v7 03/16] net: phy: Introduce phy related fwnode functions
@ 2021-03-11  6:19   ` Calvin Johnson
  0 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11  6:19 UTC (permalink / raw)
  To: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap
  Cc: linux-arm-kernel, Diana Madalina Craciun, linux-acpi,
	linux-kernel, linux.cj, netdev, Laurentiu Tudor, Calvin Johnson,
	David S. Miller, Heiner Kallweit, Jakub Kicinski

Define fwnode_phy_find_device() to iterate an mdiobus and find the
phy device of the provided phy fwnode. Additionally define
device_phy_find_device() to find phy device of provided device.

Define fwnode_get_phy_node() to get phy_node using named reference.

Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3:
- Add more info on legacy DT properties "phy" and "phy-device"
- Redefine fwnode_phy_find_device() to follow of_phy_find_device()

Changes in v2:
- use reverse christmas tree ordering for local variables

 drivers/net/phy/phy_device.c | 62 ++++++++++++++++++++++++++++++++++++
 include/linux/phy.h          | 20 ++++++++++++
 2 files changed, 82 insertions(+)

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index daabb17bba00..aec8dadf5d8b 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -9,6 +9,7 @@
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
+#include <linux/acpi.h>
 #include <linux/bitmap.h>
 #include <linux/delay.h>
 #include <linux/errno.h>
@@ -2842,6 +2843,67 @@ struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode)
 }
 EXPORT_SYMBOL(fwnode_mdio_find_device);
 
+/**
+ * fwnode_phy_find_device - For provided phy_fwnode, find phy_device.
+ *
+ * @phy_fwnode: Pointer to the phy's fwnode.
+ *
+ * If successful, returns a pointer to the phy_device with the embedded
+ * struct device refcount incremented by one, or NULL on failure.
+ */
+struct phy_device *fwnode_phy_find_device(struct fwnode_handle *phy_fwnode)
+{
+	struct mdio_device *mdiodev;
+
+	mdiodev = fwnode_mdio_find_device(phy_fwnode);
+	if (!mdiodev)
+		return NULL;
+
+	if (mdiodev->flags & MDIO_DEVICE_FLAG_PHY)
+		return to_phy_device(&mdiodev->dev);
+
+	put_device(&mdiodev->dev);
+
+	return NULL;
+}
+EXPORT_SYMBOL(fwnode_phy_find_device);
+
+/**
+ * device_phy_find_device - For the given device, get the phy_device
+ * @dev: Pointer to the given device
+ *
+ * Refer return conditions of fwnode_phy_find_device().
+ */
+struct phy_device *device_phy_find_device(struct device *dev)
+{
+	return fwnode_phy_find_device(dev_fwnode(dev));
+}
+EXPORT_SYMBOL_GPL(device_phy_find_device);
+
+/**
+ * fwnode_get_phy_node - Get the phy_node using the named reference.
+ * @fwnode: Pointer to fwnode from which phy_node has to be obtained.
+ *
+ * Refer return conditions of fwnode_find_reference().
+ * For ACPI, only "phy-handle" is supported. Legacy DT properties "phy"
+ * and "phy-device" are not supported in ACPI. DT supports all the three
+ * named references to the phy node.
+ */
+struct fwnode_handle *fwnode_get_phy_node(struct fwnode_handle *fwnode)
+{
+	struct fwnode_handle *phy_node;
+
+	/* Only phy-handle is used for ACPI */
+	phy_node = fwnode_find_reference(fwnode, "phy-handle", 0);
+	if (is_acpi_node(fwnode) || !IS_ERR(phy_node))
+		return phy_node;
+	phy_node = fwnode_find_reference(fwnode, "phy", 0);
+	if (IS_ERR(phy_node))
+		phy_node = fwnode_find_reference(fwnode, "phy-device", 0);
+	return phy_node;
+}
+EXPORT_SYMBOL_GPL(fwnode_get_phy_node);
+
 /**
  * phy_probe - probe and init a PHY device
  * @dev: device to probe and init
diff --git a/include/linux/phy.h b/include/linux/phy.h
index f5eb1e3981a1..720a2a8cf355 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -1367,6 +1367,9 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id,
 				     struct phy_c45_device_ids *c45_ids);
 #if IS_ENABLED(CONFIG_PHYLIB)
 struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode);
+struct phy_device *fwnode_phy_find_device(struct fwnode_handle *phy_fwnode);
+struct phy_device *device_phy_find_device(struct device *dev);
+struct fwnode_handle *fwnode_get_phy_node(struct fwnode_handle *fwnode);
 struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45);
 int phy_device_register(struct phy_device *phy);
 void phy_device_free(struct phy_device *phydev);
@@ -1376,6 +1379,23 @@ struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode)
 {
 	return 0;
 }
+static inline
+struct phy_device *fwnode_phy_find_device(struct fwnode_handle *phy_fwnode)
+{
+	return NULL;
+}
+
+static inline struct phy_device *device_phy_find_device(struct device *dev)
+{
+	return NULL;
+}
+
+static inline
+struct fwnode_handle *fwnode_get_phy_node(struct fwnode_handle *fwnode)
+{
+	return NULL;
+}
+
 static inline
 struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45)
 {
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [net-next PATCH v7 04/16] of: mdio: Refactor of_phy_find_device()
  2021-03-11  6:19 ` Calvin Johnson
@ 2021-03-11  6:19   ` Calvin Johnson
  -1 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11  6:19 UTC (permalink / raw)
  To: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap
  Cc: linux-arm-kernel, Diana Madalina Craciun, linux-acpi,
	linux-kernel, linux.cj, netdev, Laurentiu Tudor, Calvin Johnson,
	David S. Miller, Heiner Kallweit, Jakub Kicinski

Refactor of_phy_find_device() to use fwnode_phy_find_device().

Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/net/mdio/of_mdio.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c
index d5e0970b2561..b5e0b5b22f1a 100644
--- a/drivers/net/mdio/of_mdio.c
+++ b/drivers/net/mdio/of_mdio.c
@@ -360,18 +360,7 @@ EXPORT_SYMBOL(of_mdio_find_device);
  */
 struct phy_device *of_phy_find_device(struct device_node *phy_np)
 {
-	struct mdio_device *mdiodev;
-
-	mdiodev = of_mdio_find_device(phy_np);
-	if (!mdiodev)
-		return NULL;
-
-	if (mdiodev->flags & MDIO_DEVICE_FLAG_PHY)
-		return to_phy_device(&mdiodev->dev);
-
-	put_device(&mdiodev->dev);
-
-	return NULL;
+	return fwnode_phy_find_device(of_fwnode_handle(phy_np));
 }
 EXPORT_SYMBOL(of_phy_find_device);
 
-- 
2.17.1


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

* [net-next PATCH v7 04/16] of: mdio: Refactor of_phy_find_device()
@ 2021-03-11  6:19   ` Calvin Johnson
  0 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11  6:19 UTC (permalink / raw)
  To: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap
  Cc: linux-arm-kernel, Diana Madalina Craciun, linux-acpi,
	linux-kernel, linux.cj, netdev, Laurentiu Tudor, Calvin Johnson,
	David S. Miller, Heiner Kallweit, Jakub Kicinski

Refactor of_phy_find_device() to use fwnode_phy_find_device().

Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/net/mdio/of_mdio.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c
index d5e0970b2561..b5e0b5b22f1a 100644
--- a/drivers/net/mdio/of_mdio.c
+++ b/drivers/net/mdio/of_mdio.c
@@ -360,18 +360,7 @@ EXPORT_SYMBOL(of_mdio_find_device);
  */
 struct phy_device *of_phy_find_device(struct device_node *phy_np)
 {
-	struct mdio_device *mdiodev;
-
-	mdiodev = of_mdio_find_device(phy_np);
-	if (!mdiodev)
-		return NULL;
-
-	if (mdiodev->flags & MDIO_DEVICE_FLAG_PHY)
-		return to_phy_device(&mdiodev->dev);
-
-	put_device(&mdiodev->dev);
-
-	return NULL;
+	return fwnode_phy_find_device(of_fwnode_handle(phy_np));
 }
 EXPORT_SYMBOL(of_phy_find_device);
 
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [net-next PATCH v7 05/16] net: phy: Introduce fwnode_get_phy_id()
  2021-03-11  6:19 ` Calvin Johnson
@ 2021-03-11  6:20   ` Calvin Johnson
  -1 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11  6:20 UTC (permalink / raw)
  To: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap
  Cc: linux-arm-kernel, Diana Madalina Craciun, linux-acpi,
	linux-kernel, linux.cj, netdev, Laurentiu Tudor, Calvin Johnson,
	David S. Miller, Heiner Kallweit, Jakub Kicinski

Extract phy_id from compatible string. This will be used by
fwnode_mdiobus_register_phy() to create phy device using the
phy_id.

Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3:
- Use traditional comparison pattern
- Use GENMASK

Changes in v2: None

 drivers/net/phy/phy_device.c | 21 +++++++++++++++++++++
 include/linux/phy.h          |  5 +++++
 2 files changed, 26 insertions(+)

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index aec8dadf5d8b..f875efe7b4d1 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -817,6 +817,27 @@ static int get_phy_c22_id(struct mii_bus *bus, int addr, u32 *phy_id)
 	return 0;
 }
 
+/* Extract the phy ID from the compatible string of the form
+ * ethernet-phy-idAAAA.BBBB.
+ */
+int fwnode_get_phy_id(struct fwnode_handle *fwnode, u32 *phy_id)
+{
+	unsigned int upper, lower;
+	const char *cp;
+	int ret;
+
+	ret = fwnode_property_read_string(fwnode, "compatible", &cp);
+	if (ret)
+		return ret;
+
+	if (sscanf(cp, "ethernet-phy-id%4x.%4x", &upper, &lower) != 2)
+		return -EINVAL;
+
+	*phy_id = ((upper & GENMASK(15, 0)) << 16) | (lower & GENMASK(15, 0));
+	return 0;
+}
+EXPORT_SYMBOL(fwnode_get_phy_id);
+
 /**
  * get_phy_device - reads the specified PHY device and returns its @phy_device
  *		    struct
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 720a2a8cf355..4b004a65762e 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -1366,6 +1366,7 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id,
 				     bool is_c45,
 				     struct phy_c45_device_ids *c45_ids);
 #if IS_ENABLED(CONFIG_PHYLIB)
+int fwnode_get_phy_id(struct fwnode_handle *fwnode, u32 *phy_id);
 struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode);
 struct phy_device *fwnode_phy_find_device(struct fwnode_handle *phy_fwnode);
 struct phy_device *device_phy_find_device(struct device *dev);
@@ -1374,6 +1375,10 @@ struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45);
 int phy_device_register(struct phy_device *phy);
 void phy_device_free(struct phy_device *phydev);
 #else
+static inline int fwnode_get_phy_id(struct fwnode_handle *fwnode, u32 *phy_id)
+{
+	return 0;
+}
 static inline
 struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode)
 {
-- 
2.17.1


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

* [net-next PATCH v7 05/16] net: phy: Introduce fwnode_get_phy_id()
@ 2021-03-11  6:20   ` Calvin Johnson
  0 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11  6:20 UTC (permalink / raw)
  To: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap
  Cc: linux-arm-kernel, Diana Madalina Craciun, linux-acpi,
	linux-kernel, linux.cj, netdev, Laurentiu Tudor, Calvin Johnson,
	David S. Miller, Heiner Kallweit, Jakub Kicinski

Extract phy_id from compatible string. This will be used by
fwnode_mdiobus_register_phy() to create phy device using the
phy_id.

Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3:
- Use traditional comparison pattern
- Use GENMASK

Changes in v2: None

 drivers/net/phy/phy_device.c | 21 +++++++++++++++++++++
 include/linux/phy.h          |  5 +++++
 2 files changed, 26 insertions(+)

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index aec8dadf5d8b..f875efe7b4d1 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -817,6 +817,27 @@ static int get_phy_c22_id(struct mii_bus *bus, int addr, u32 *phy_id)
 	return 0;
 }
 
+/* Extract the phy ID from the compatible string of the form
+ * ethernet-phy-idAAAA.BBBB.
+ */
+int fwnode_get_phy_id(struct fwnode_handle *fwnode, u32 *phy_id)
+{
+	unsigned int upper, lower;
+	const char *cp;
+	int ret;
+
+	ret = fwnode_property_read_string(fwnode, "compatible", &cp);
+	if (ret)
+		return ret;
+
+	if (sscanf(cp, "ethernet-phy-id%4x.%4x", &upper, &lower) != 2)
+		return -EINVAL;
+
+	*phy_id = ((upper & GENMASK(15, 0)) << 16) | (lower & GENMASK(15, 0));
+	return 0;
+}
+EXPORT_SYMBOL(fwnode_get_phy_id);
+
 /**
  * get_phy_device - reads the specified PHY device and returns its @phy_device
  *		    struct
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 720a2a8cf355..4b004a65762e 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -1366,6 +1366,7 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id,
 				     bool is_c45,
 				     struct phy_c45_device_ids *c45_ids);
 #if IS_ENABLED(CONFIG_PHYLIB)
+int fwnode_get_phy_id(struct fwnode_handle *fwnode, u32 *phy_id);
 struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode);
 struct phy_device *fwnode_phy_find_device(struct fwnode_handle *phy_fwnode);
 struct phy_device *device_phy_find_device(struct device *dev);
@@ -1374,6 +1375,10 @@ struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45);
 int phy_device_register(struct phy_device *phy);
 void phy_device_free(struct phy_device *phydev);
 #else
+static inline int fwnode_get_phy_id(struct fwnode_handle *fwnode, u32 *phy_id)
+{
+	return 0;
+}
 static inline
 struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode)
 {
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [net-next PATCH v7 06/16] of: mdio: Refactor of_get_phy_id()
  2021-03-11  6:19 ` Calvin Johnson
@ 2021-03-11  6:20   ` Calvin Johnson
  -1 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11  6:20 UTC (permalink / raw)
  To: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap
  Cc: linux-arm-kernel, Diana Madalina Craciun, linux-acpi,
	linux-kernel, linux.cj, netdev, Laurentiu Tudor, Calvin Johnson,
	David S. Miller, Heiner Kallweit, Jakub Kicinski

With the introduction of fwnode_get_phy_id(), refactor of_get_phy_id()
to use fwnode equivalent.

Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/net/mdio/of_mdio.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c
index b5e0b5b22f1a..612a37970f14 100644
--- a/drivers/net/mdio/of_mdio.c
+++ b/drivers/net/mdio/of_mdio.c
@@ -29,17 +29,7 @@ MODULE_LICENSE("GPL");
  * ethernet-phy-idAAAA.BBBB */
 static int of_get_phy_id(struct device_node *device, u32 *phy_id)
 {
-	struct property *prop;
-	const char *cp;
-	unsigned int upper, lower;
-
-	of_property_for_each_string(device, "compatible", prop, cp) {
-		if (sscanf(cp, "ethernet-phy-id%4x.%4x", &upper, &lower) == 2) {
-			*phy_id = ((upper & 0xFFFF) << 16) | (lower & 0xFFFF);
-			return 0;
-		}
-	}
-	return -EINVAL;
+	return fwnode_get_phy_id(of_fwnode_handle(device), phy_id);
 }
 
 static struct mii_timestamper *of_find_mii_timestamper(struct device_node *node)
-- 
2.17.1


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

* [net-next PATCH v7 06/16] of: mdio: Refactor of_get_phy_id()
@ 2021-03-11  6:20   ` Calvin Johnson
  0 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11  6:20 UTC (permalink / raw)
  To: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap
  Cc: linux-arm-kernel, Diana Madalina Craciun, linux-acpi,
	linux-kernel, linux.cj, netdev, Laurentiu Tudor, Calvin Johnson,
	David S. Miller, Heiner Kallweit, Jakub Kicinski

With the introduction of fwnode_get_phy_id(), refactor of_get_phy_id()
to use fwnode equivalent.

Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/net/mdio/of_mdio.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c
index b5e0b5b22f1a..612a37970f14 100644
--- a/drivers/net/mdio/of_mdio.c
+++ b/drivers/net/mdio/of_mdio.c
@@ -29,17 +29,7 @@ MODULE_LICENSE("GPL");
  * ethernet-phy-idAAAA.BBBB */
 static int of_get_phy_id(struct device_node *device, u32 *phy_id)
 {
-	struct property *prop;
-	const char *cp;
-	unsigned int upper, lower;
-
-	of_property_for_each_string(device, "compatible", prop, cp) {
-		if (sscanf(cp, "ethernet-phy-id%4x.%4x", &upper, &lower) == 2) {
-			*phy_id = ((upper & 0xFFFF) << 16) | (lower & 0xFFFF);
-			return 0;
-		}
-	}
-	return -EINVAL;
+	return fwnode_get_phy_id(of_fwnode_handle(device), phy_id);
 }
 
 static struct mii_timestamper *of_find_mii_timestamper(struct device_node *node)
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [net-next PATCH v7 07/16] net: mii_timestamper: check NULL in unregister_mii_timestamper()
  2021-03-11  6:19 ` Calvin Johnson
@ 2021-03-11  6:20   ` Calvin Johnson
  -1 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11  6:20 UTC (permalink / raw)
  To: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap
  Cc: linux-arm-kernel, Diana Madalina Craciun, linux-acpi,
	linux-kernel, linux.cj, netdev, Laurentiu Tudor, Calvin Johnson,
	David S. Miller, Heiner Kallweit, Jakub Kicinski

Callers of unregister_mii_timestamper() currently check for NULL
value of mii_ts before calling it.

Place the NULL check inside unregister_mii_timestamper() and update
the callers accordingly.

Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---

Changes in v7:
- check NULL in unregister_mii_timestamper()

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/net/mdio/of_mdio.c        | 6 ++----
 drivers/net/phy/mii_timestamper.c | 3 +++
 drivers/net/phy/phy_device.c      | 3 +--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c
index 612a37970f14..48b6b8458c17 100644
--- a/drivers/net/mdio/of_mdio.c
+++ b/drivers/net/mdio/of_mdio.c
@@ -115,15 +115,13 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio,
 	else
 		phy = get_phy_device(mdio, addr, is_c45);
 	if (IS_ERR(phy)) {
-		if (mii_ts)
-			unregister_mii_timestamper(mii_ts);
+		unregister_mii_timestamper(mii_ts);
 		return PTR_ERR(phy);
 	}
 
 	rc = of_mdiobus_phy_device_register(mdio, phy, child, addr);
 	if (rc) {
-		if (mii_ts)
-			unregister_mii_timestamper(mii_ts);
+		unregister_mii_timestamper(mii_ts);
 		phy_device_free(phy);
 		return rc;
 	}
diff --git a/drivers/net/phy/mii_timestamper.c b/drivers/net/phy/mii_timestamper.c
index b71b7456462d..51ae0593a04f 100644
--- a/drivers/net/phy/mii_timestamper.c
+++ b/drivers/net/phy/mii_timestamper.c
@@ -111,6 +111,9 @@ void unregister_mii_timestamper(struct mii_timestamper *mii_ts)
 	struct mii_timestamping_desc *desc;
 	struct list_head *this;
 
+	if (!mii_ts)
+		return;
+
 	/* mii_timestamper statically registered by the PHY driver won't use the
 	 * register_mii_timestamper() and thus don't have ->device set. Don't
 	 * try to unregister these.
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index f875efe7b4d1..9c5127405d91 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -928,8 +928,7 @@ EXPORT_SYMBOL(phy_device_register);
  */
 void phy_device_remove(struct phy_device *phydev)
 {
-	if (phydev->mii_ts)
-		unregister_mii_timestamper(phydev->mii_ts);
+	unregister_mii_timestamper(phydev->mii_ts);
 
 	device_del(&phydev->mdio.dev);
 
-- 
2.17.1


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

* [net-next PATCH v7 07/16] net: mii_timestamper: check NULL in unregister_mii_timestamper()
@ 2021-03-11  6:20   ` Calvin Johnson
  0 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11  6:20 UTC (permalink / raw)
  To: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap
  Cc: linux-arm-kernel, Diana Madalina Craciun, linux-acpi,
	linux-kernel, linux.cj, netdev, Laurentiu Tudor, Calvin Johnson,
	David S. Miller, Heiner Kallweit, Jakub Kicinski

Callers of unregister_mii_timestamper() currently check for NULL
value of mii_ts before calling it.

Place the NULL check inside unregister_mii_timestamper() and update
the callers accordingly.

Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---

Changes in v7:
- check NULL in unregister_mii_timestamper()

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/net/mdio/of_mdio.c        | 6 ++----
 drivers/net/phy/mii_timestamper.c | 3 +++
 drivers/net/phy/phy_device.c      | 3 +--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c
index 612a37970f14..48b6b8458c17 100644
--- a/drivers/net/mdio/of_mdio.c
+++ b/drivers/net/mdio/of_mdio.c
@@ -115,15 +115,13 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio,
 	else
 		phy = get_phy_device(mdio, addr, is_c45);
 	if (IS_ERR(phy)) {
-		if (mii_ts)
-			unregister_mii_timestamper(mii_ts);
+		unregister_mii_timestamper(mii_ts);
 		return PTR_ERR(phy);
 	}
 
 	rc = of_mdiobus_phy_device_register(mdio, phy, child, addr);
 	if (rc) {
-		if (mii_ts)
-			unregister_mii_timestamper(mii_ts);
+		unregister_mii_timestamper(mii_ts);
 		phy_device_free(phy);
 		return rc;
 	}
diff --git a/drivers/net/phy/mii_timestamper.c b/drivers/net/phy/mii_timestamper.c
index b71b7456462d..51ae0593a04f 100644
--- a/drivers/net/phy/mii_timestamper.c
+++ b/drivers/net/phy/mii_timestamper.c
@@ -111,6 +111,9 @@ void unregister_mii_timestamper(struct mii_timestamper *mii_ts)
 	struct mii_timestamping_desc *desc;
 	struct list_head *this;
 
+	if (!mii_ts)
+		return;
+
 	/* mii_timestamper statically registered by the PHY driver won't use the
 	 * register_mii_timestamper() and thus don't have ->device set. Don't
 	 * try to unregister these.
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index f875efe7b4d1..9c5127405d91 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -928,8 +928,7 @@ EXPORT_SYMBOL(phy_device_register);
  */
 void phy_device_remove(struct phy_device *phydev)
 {
-	if (phydev->mii_ts)
-		unregister_mii_timestamper(phydev->mii_ts);
+	unregister_mii_timestamper(phydev->mii_ts);
 
 	device_del(&phydev->mdio.dev);
 
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [net-next PATCH v7 08/16] net: mdiobus: Introduce fwnode_mdiobus_register_phy()
  2021-03-11  6:19 ` Calvin Johnson
@ 2021-03-11  6:20   ` Calvin Johnson
  -1 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11  6:20 UTC (permalink / raw)
  To: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap
  Cc: linux-arm-kernel, Diana Madalina Craciun, linux-acpi,
	linux-kernel, linux.cj, netdev, Laurentiu Tudor, Calvin Johnson,
	David S. Miller, Frank Rowand, Heiner Kallweit, Jakub Kicinski,
	Rob Herring, devicetree

Introduce fwnode_mdiobus_register_phy() to register PHYs on the
mdiobus. From the compatible string, identify whether the PHY is
c45 and based on this create a PHY device instance which is
registered on the mdiobus.

uninitialized symbol 'mii_ts'
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---

Changes in v7:
- Call unregister_mii_timestamper() without NULL check
- Create fwnode_mdio.c and move fwnode_mdiobus_register_phy()

Changes in v6:
- Initialize mii_ts to NULL

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 MAINTAINERS                    |  1 +
 drivers/net/mdio/Kconfig       |  9 ++++
 drivers/net/mdio/Makefile      |  3 +-
 drivers/net/mdio/fwnode_mdio.c | 77 ++++++++++++++++++++++++++++++++++
 drivers/net/mdio/of_mdio.c     |  3 +-
 include/linux/fwnode_mdio.h    | 24 +++++++++++
 include/linux/of_mdio.h        |  6 ++-
 7 files changed, 120 insertions(+), 3 deletions(-)
 create mode 100644 drivers/net/mdio/fwnode_mdio.c
 create mode 100644 include/linux/fwnode_mdio.h

diff --git a/MAINTAINERS b/MAINTAINERS
index e1fa5ad9bb30..146de41d2656 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6680,6 +6680,7 @@ F:	Documentation/devicetree/bindings/net/mdio*
 F:	Documentation/devicetree/bindings/net/qca,ar803x.yaml
 F:	Documentation/networking/phy.rst
 F:	drivers/net/mdio/
+F:	drivers/net/mdio/fwnode_mdio.c
 F:	drivers/net/mdio/of_mdio.c
 F:	drivers/net/pcs/
 F:	drivers/net/phy/
diff --git a/drivers/net/mdio/Kconfig b/drivers/net/mdio/Kconfig
index a10cc460d7cf..2d5bf5ccffb5 100644
--- a/drivers/net/mdio/Kconfig
+++ b/drivers/net/mdio/Kconfig
@@ -19,6 +19,15 @@ config MDIO_BUS
 	  reflects whether the mdio_bus/mdio_device code is built as a
 	  loadable module or built-in.
 
+config FWNODE_MDIO
+	def_tristate PHYLIB
+	depends on ACPI
+	depends on OF
+	depends on PHYLIB
+	select FIXED_PHY
+	help
+	  FWNODE MDIO bus (Ethernet PHY) accessors
+
 config OF_MDIO
 	def_tristate PHYLIB
 	depends on OF
diff --git a/drivers/net/mdio/Makefile b/drivers/net/mdio/Makefile
index 5c498dde463f..ea5390e2ef84 100644
--- a/drivers/net/mdio/Makefile
+++ b/drivers/net/mdio/Makefile
@@ -1,7 +1,8 @@
 # SPDX-License-Identifier: GPL-2.0
 # Makefile for Linux MDIO bus drivers
 
-obj-$(CONFIG_OF_MDIO)	+= of_mdio.o
+obj-$(CONFIG_FWNODE_MDIO)	+= fwnode_mdio.o
+obj-$(CONFIG_OF_MDIO)		+= of_mdio.o
 
 obj-$(CONFIG_MDIO_ASPEED)		+= mdio-aspeed.o
 obj-$(CONFIG_MDIO_BCM_IPROC)		+= mdio-bcm-iproc.o
diff --git a/drivers/net/mdio/fwnode_mdio.c b/drivers/net/mdio/fwnode_mdio.c
new file mode 100644
index 000000000000..0982e816a6fb
--- /dev/null
+++ b/drivers/net/mdio/fwnode_mdio.c
@@ -0,0 +1,77 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * fwnode helpers for the MDIO (Ethernet PHY) API
+ *
+ * This file provides helper functions for extracting PHY device information
+ * out of the fwnode and using it to populate an mii_bus.
+ */
+
+#include <linux/acpi.h>
+#include <linux/of.h>
+#include <linux/of_mdio.h>
+#include <linux/phy.h>
+
+MODULE_AUTHOR("Calvin Johnson <calvin.johnson@oss.nxp.com>");
+MODULE_LICENSE("GPL");
+
+int fwnode_mdiobus_register_phy(struct mii_bus *bus,
+				struct fwnode_handle *child, u32 addr)
+{
+	struct mii_timestamper *mii_ts = NULL;
+	struct phy_device *phy;
+	bool is_c45 = false;
+	u32 phy_id;
+	int rc;
+
+	if (is_of_node(child)) {
+		mii_ts = of_find_mii_timestamper(to_of_node(child));
+		if (IS_ERR(mii_ts))
+			return PTR_ERR(mii_ts);
+	}
+
+	rc = fwnode_property_match_string(child, "compatible", "ethernet-phy-ieee802.3-c45");
+	if (rc >= 0)
+		is_c45 = true;
+
+	if (is_c45 || fwnode_get_phy_id(child, &phy_id))
+		phy = get_phy_device(bus, addr, is_c45);
+	else
+		phy = phy_device_create(bus, addr, phy_id, 0, NULL);
+	if (IS_ERR(phy)) {
+		unregister_mii_timestamper(mii_ts);
+		return PTR_ERR(phy);
+	}
+
+	if (is_acpi_node(child)) {
+		phy->irq = bus->irq[addr];
+
+		/* Associate the fwnode with the device structure so it
+		 * can be looked up later.
+		 */
+		phy->mdio.dev.fwnode = child;
+
+		/* All data is now stored in the phy struct, so register it */
+		rc = phy_device_register(phy);
+		if (rc) {
+			phy_device_free(phy);
+			fwnode_handle_put(phy->mdio.dev.fwnode);
+			return rc;
+		}
+	} else if (is_of_node(child)) {
+		rc = of_mdiobus_phy_device_register(bus, phy, to_of_node(child), addr);
+		if (rc) {
+			unregister_mii_timestamper(mii_ts);
+			phy_device_free(phy);
+			return rc;
+		}
+	}
+
+	/* phy->mii_ts may already be defined by the PHY driver. A
+	 * mii_timestamper probed via the device tree will still have
+	 * precedence.
+	 */
+	if (mii_ts)
+		phy->mii_ts = mii_ts;
+	return 0;
+}
+EXPORT_SYMBOL(fwnode_mdiobus_register_phy);
diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c
index 48b6b8458c17..db293e0b8249 100644
--- a/drivers/net/mdio/of_mdio.c
+++ b/drivers/net/mdio/of_mdio.c
@@ -32,7 +32,7 @@ static int of_get_phy_id(struct device_node *device, u32 *phy_id)
 	return fwnode_get_phy_id(of_fwnode_handle(device), phy_id);
 }
 
-static struct mii_timestamper *of_find_mii_timestamper(struct device_node *node)
+struct mii_timestamper *of_find_mii_timestamper(struct device_node *node)
 {
 	struct of_phandle_args arg;
 	int err;
@@ -49,6 +49,7 @@ static struct mii_timestamper *of_find_mii_timestamper(struct device_node *node)
 
 	return register_mii_timestamper(arg.np, arg.args[0]);
 }
+EXPORT_SYMBOL(of_find_mii_timestamper);
 
 int of_mdiobus_phy_device_register(struct mii_bus *mdio, struct phy_device *phy,
 			      struct device_node *child, u32 addr)
diff --git a/include/linux/fwnode_mdio.h b/include/linux/fwnode_mdio.h
new file mode 100644
index 000000000000..8c0392845916
--- /dev/null
+++ b/include/linux/fwnode_mdio.h
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * FWNODE helper for the MDIO (Ethernet PHY) API
+ */
+
+#ifndef __LINUX_FWNODE_MDIO_H
+#define __LINUX_FWNODE_MDIO_H
+
+#include <linux/phy.h>
+
+#if IS_ENABLED(CONFIG_FWNODE_MDIO)
+int fwnode_mdiobus_register_phy(struct mii_bus *bus,
+				struct fwnode_handle *child, u32 addr);
+
+#else /* CONFIG_FWNODE_MDIO */
+static inline int fwnode_mdiobus_register_phy(struct mii_bus *bus,
+					      struct fwnode_handle *child,
+					      u32 addr)
+{
+	return -EINVAL;
+}
+#endif
+
+#endif /* __LINUX_FWNODE_MDIO_H */
diff --git a/include/linux/of_mdio.h b/include/linux/of_mdio.h
index 2b05e7f7c238..e4ee6c4d9431 100644
--- a/include/linux/of_mdio.h
+++ b/include/linux/of_mdio.h
@@ -31,6 +31,7 @@ struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np);
 int of_phy_register_fixed_link(struct device_node *np);
 void of_phy_deregister_fixed_link(struct device_node *np);
 bool of_phy_is_fixed_link(struct device_node *np);
+struct mii_timestamper *of_find_mii_timestamper(struct device_node *np);
 int of_mdiobus_phy_device_register(struct mii_bus *mdio, struct phy_device *phy,
 				   struct device_node *child, u32 addr);
 
@@ -118,7 +119,10 @@ static inline bool of_phy_is_fixed_link(struct device_node *np)
 {
 	return false;
 }
-
+static inline struct mii_timestamper *of_find_mii_timestamper(struct device_node *np)
+{
+	return NULL;
+}
 static inline int of_mdiobus_phy_device_register(struct mii_bus *mdio,
 					    struct phy_device *phy,
 					    struct device_node *child, u32 addr)
-- 
2.17.1


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

* [net-next PATCH v7 08/16] net: mdiobus: Introduce fwnode_mdiobus_register_phy()
@ 2021-03-11  6:20   ` Calvin Johnson
  0 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11  6:20 UTC (permalink / raw)
  To: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap
  Cc: linux-arm-kernel, Diana Madalina Craciun, linux-acpi,
	linux-kernel, linux.cj, netdev, Laurentiu Tudor, Calvin Johnson,
	David S. Miller, Frank Rowand, Heiner Kallweit, Jakub Kicinski,
	Rob Herring, devicetree

Introduce fwnode_mdiobus_register_phy() to register PHYs on the
mdiobus. From the compatible string, identify whether the PHY is
c45 and based on this create a PHY device instance which is
registered on the mdiobus.

uninitialized symbol 'mii_ts'
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---

Changes in v7:
- Call unregister_mii_timestamper() without NULL check
- Create fwnode_mdio.c and move fwnode_mdiobus_register_phy()

Changes in v6:
- Initialize mii_ts to NULL

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 MAINTAINERS                    |  1 +
 drivers/net/mdio/Kconfig       |  9 ++++
 drivers/net/mdio/Makefile      |  3 +-
 drivers/net/mdio/fwnode_mdio.c | 77 ++++++++++++++++++++++++++++++++++
 drivers/net/mdio/of_mdio.c     |  3 +-
 include/linux/fwnode_mdio.h    | 24 +++++++++++
 include/linux/of_mdio.h        |  6 ++-
 7 files changed, 120 insertions(+), 3 deletions(-)
 create mode 100644 drivers/net/mdio/fwnode_mdio.c
 create mode 100644 include/linux/fwnode_mdio.h

diff --git a/MAINTAINERS b/MAINTAINERS
index e1fa5ad9bb30..146de41d2656 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6680,6 +6680,7 @@ F:	Documentation/devicetree/bindings/net/mdio*
 F:	Documentation/devicetree/bindings/net/qca,ar803x.yaml
 F:	Documentation/networking/phy.rst
 F:	drivers/net/mdio/
+F:	drivers/net/mdio/fwnode_mdio.c
 F:	drivers/net/mdio/of_mdio.c
 F:	drivers/net/pcs/
 F:	drivers/net/phy/
diff --git a/drivers/net/mdio/Kconfig b/drivers/net/mdio/Kconfig
index a10cc460d7cf..2d5bf5ccffb5 100644
--- a/drivers/net/mdio/Kconfig
+++ b/drivers/net/mdio/Kconfig
@@ -19,6 +19,15 @@ config MDIO_BUS
 	  reflects whether the mdio_bus/mdio_device code is built as a
 	  loadable module or built-in.
 
+config FWNODE_MDIO
+	def_tristate PHYLIB
+	depends on ACPI
+	depends on OF
+	depends on PHYLIB
+	select FIXED_PHY
+	help
+	  FWNODE MDIO bus (Ethernet PHY) accessors
+
 config OF_MDIO
 	def_tristate PHYLIB
 	depends on OF
diff --git a/drivers/net/mdio/Makefile b/drivers/net/mdio/Makefile
index 5c498dde463f..ea5390e2ef84 100644
--- a/drivers/net/mdio/Makefile
+++ b/drivers/net/mdio/Makefile
@@ -1,7 +1,8 @@
 # SPDX-License-Identifier: GPL-2.0
 # Makefile for Linux MDIO bus drivers
 
-obj-$(CONFIG_OF_MDIO)	+= of_mdio.o
+obj-$(CONFIG_FWNODE_MDIO)	+= fwnode_mdio.o
+obj-$(CONFIG_OF_MDIO)		+= of_mdio.o
 
 obj-$(CONFIG_MDIO_ASPEED)		+= mdio-aspeed.o
 obj-$(CONFIG_MDIO_BCM_IPROC)		+= mdio-bcm-iproc.o
diff --git a/drivers/net/mdio/fwnode_mdio.c b/drivers/net/mdio/fwnode_mdio.c
new file mode 100644
index 000000000000..0982e816a6fb
--- /dev/null
+++ b/drivers/net/mdio/fwnode_mdio.c
@@ -0,0 +1,77 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * fwnode helpers for the MDIO (Ethernet PHY) API
+ *
+ * This file provides helper functions for extracting PHY device information
+ * out of the fwnode and using it to populate an mii_bus.
+ */
+
+#include <linux/acpi.h>
+#include <linux/of.h>
+#include <linux/of_mdio.h>
+#include <linux/phy.h>
+
+MODULE_AUTHOR("Calvin Johnson <calvin.johnson@oss.nxp.com>");
+MODULE_LICENSE("GPL");
+
+int fwnode_mdiobus_register_phy(struct mii_bus *bus,
+				struct fwnode_handle *child, u32 addr)
+{
+	struct mii_timestamper *mii_ts = NULL;
+	struct phy_device *phy;
+	bool is_c45 = false;
+	u32 phy_id;
+	int rc;
+
+	if (is_of_node(child)) {
+		mii_ts = of_find_mii_timestamper(to_of_node(child));
+		if (IS_ERR(mii_ts))
+			return PTR_ERR(mii_ts);
+	}
+
+	rc = fwnode_property_match_string(child, "compatible", "ethernet-phy-ieee802.3-c45");
+	if (rc >= 0)
+		is_c45 = true;
+
+	if (is_c45 || fwnode_get_phy_id(child, &phy_id))
+		phy = get_phy_device(bus, addr, is_c45);
+	else
+		phy = phy_device_create(bus, addr, phy_id, 0, NULL);
+	if (IS_ERR(phy)) {
+		unregister_mii_timestamper(mii_ts);
+		return PTR_ERR(phy);
+	}
+
+	if (is_acpi_node(child)) {
+		phy->irq = bus->irq[addr];
+
+		/* Associate the fwnode with the device structure so it
+		 * can be looked up later.
+		 */
+		phy->mdio.dev.fwnode = child;
+
+		/* All data is now stored in the phy struct, so register it */
+		rc = phy_device_register(phy);
+		if (rc) {
+			phy_device_free(phy);
+			fwnode_handle_put(phy->mdio.dev.fwnode);
+			return rc;
+		}
+	} else if (is_of_node(child)) {
+		rc = of_mdiobus_phy_device_register(bus, phy, to_of_node(child), addr);
+		if (rc) {
+			unregister_mii_timestamper(mii_ts);
+			phy_device_free(phy);
+			return rc;
+		}
+	}
+
+	/* phy->mii_ts may already be defined by the PHY driver. A
+	 * mii_timestamper probed via the device tree will still have
+	 * precedence.
+	 */
+	if (mii_ts)
+		phy->mii_ts = mii_ts;
+	return 0;
+}
+EXPORT_SYMBOL(fwnode_mdiobus_register_phy);
diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c
index 48b6b8458c17..db293e0b8249 100644
--- a/drivers/net/mdio/of_mdio.c
+++ b/drivers/net/mdio/of_mdio.c
@@ -32,7 +32,7 @@ static int of_get_phy_id(struct device_node *device, u32 *phy_id)
 	return fwnode_get_phy_id(of_fwnode_handle(device), phy_id);
 }
 
-static struct mii_timestamper *of_find_mii_timestamper(struct device_node *node)
+struct mii_timestamper *of_find_mii_timestamper(struct device_node *node)
 {
 	struct of_phandle_args arg;
 	int err;
@@ -49,6 +49,7 @@ static struct mii_timestamper *of_find_mii_timestamper(struct device_node *node)
 
 	return register_mii_timestamper(arg.np, arg.args[0]);
 }
+EXPORT_SYMBOL(of_find_mii_timestamper);
 
 int of_mdiobus_phy_device_register(struct mii_bus *mdio, struct phy_device *phy,
 			      struct device_node *child, u32 addr)
diff --git a/include/linux/fwnode_mdio.h b/include/linux/fwnode_mdio.h
new file mode 100644
index 000000000000..8c0392845916
--- /dev/null
+++ b/include/linux/fwnode_mdio.h
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * FWNODE helper for the MDIO (Ethernet PHY) API
+ */
+
+#ifndef __LINUX_FWNODE_MDIO_H
+#define __LINUX_FWNODE_MDIO_H
+
+#include <linux/phy.h>
+
+#if IS_ENABLED(CONFIG_FWNODE_MDIO)
+int fwnode_mdiobus_register_phy(struct mii_bus *bus,
+				struct fwnode_handle *child, u32 addr);
+
+#else /* CONFIG_FWNODE_MDIO */
+static inline int fwnode_mdiobus_register_phy(struct mii_bus *bus,
+					      struct fwnode_handle *child,
+					      u32 addr)
+{
+	return -EINVAL;
+}
+#endif
+
+#endif /* __LINUX_FWNODE_MDIO_H */
diff --git a/include/linux/of_mdio.h b/include/linux/of_mdio.h
index 2b05e7f7c238..e4ee6c4d9431 100644
--- a/include/linux/of_mdio.h
+++ b/include/linux/of_mdio.h
@@ -31,6 +31,7 @@ struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np);
 int of_phy_register_fixed_link(struct device_node *np);
 void of_phy_deregister_fixed_link(struct device_node *np);
 bool of_phy_is_fixed_link(struct device_node *np);
+struct mii_timestamper *of_find_mii_timestamper(struct device_node *np);
 int of_mdiobus_phy_device_register(struct mii_bus *mdio, struct phy_device *phy,
 				   struct device_node *child, u32 addr);
 
@@ -118,7 +119,10 @@ static inline bool of_phy_is_fixed_link(struct device_node *np)
 {
 	return false;
 }
-
+static inline struct mii_timestamper *of_find_mii_timestamper(struct device_node *np)
+{
+	return NULL;
+}
 static inline int of_mdiobus_phy_device_register(struct mii_bus *mdio,
 					    struct phy_device *phy,
 					    struct device_node *child, u32 addr)
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [net-next PATCH v7 09/16] of: mdio: Refactor of_mdiobus_register_phy()
  2021-03-11  6:19 ` Calvin Johnson
@ 2021-03-11  6:20   ` Calvin Johnson
  -1 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11  6:20 UTC (permalink / raw)
  To: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap
  Cc: linux-arm-kernel, Diana Madalina Craciun, linux-acpi,
	linux-kernel, linux.cj, netdev, Laurentiu Tudor, Calvin Johnson,
	David S. Miller, Heiner Kallweit, Jakub Kicinski

Refactor of_mdiobus_register_phy() to use fwnode_mdiobus_register_phy().

Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---

Changes in v7:
- include fwnode_mdio.h

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/net/mdio/of_mdio.c | 39 ++------------------------------------
 1 file changed, 2 insertions(+), 37 deletions(-)

diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c
index db293e0b8249..eebd4d9e1656 100644
--- a/drivers/net/mdio/of_mdio.c
+++ b/drivers/net/mdio/of_mdio.c
@@ -12,6 +12,7 @@
 #include <linux/device.h>
 #include <linux/netdevice.h>
 #include <linux/err.h>
+#include <linux/fwnode_mdio.h>
 #include <linux/phy.h>
 #include <linux/phy_fixed.h>
 #include <linux/of.h>
@@ -98,43 +99,7 @@ EXPORT_SYMBOL(of_mdiobus_phy_device_register);
 static int of_mdiobus_register_phy(struct mii_bus *mdio,
 				    struct device_node *child, u32 addr)
 {
-	struct mii_timestamper *mii_ts;
-	struct phy_device *phy;
-	bool is_c45;
-	int rc;
-	u32 phy_id;
-
-	mii_ts = of_find_mii_timestamper(child);
-	if (IS_ERR(mii_ts))
-		return PTR_ERR(mii_ts);
-
-	is_c45 = of_device_is_compatible(child,
-					 "ethernet-phy-ieee802.3-c45");
-
-	if (!is_c45 && !of_get_phy_id(child, &phy_id))
-		phy = phy_device_create(mdio, addr, phy_id, 0, NULL);
-	else
-		phy = get_phy_device(mdio, addr, is_c45);
-	if (IS_ERR(phy)) {
-		unregister_mii_timestamper(mii_ts);
-		return PTR_ERR(phy);
-	}
-
-	rc = of_mdiobus_phy_device_register(mdio, phy, child, addr);
-	if (rc) {
-		unregister_mii_timestamper(mii_ts);
-		phy_device_free(phy);
-		return rc;
-	}
-
-	/* phy->mii_ts may already be defined by the PHY driver. A
-	 * mii_timestamper probed via the device tree will still have
-	 * precedence.
-	 */
-	if (mii_ts)
-		phy->mii_ts = mii_ts;
-
-	return 0;
+	return fwnode_mdiobus_register_phy(mdio, of_fwnode_handle(child), addr);
 }
 
 static int of_mdiobus_register_device(struct mii_bus *mdio,
-- 
2.17.1


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

* [net-next PATCH v7 09/16] of: mdio: Refactor of_mdiobus_register_phy()
@ 2021-03-11  6:20   ` Calvin Johnson
  0 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11  6:20 UTC (permalink / raw)
  To: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap
  Cc: linux-arm-kernel, Diana Madalina Craciun, linux-acpi,
	linux-kernel, linux.cj, netdev, Laurentiu Tudor, Calvin Johnson,
	David S. Miller, Heiner Kallweit, Jakub Kicinski

Refactor of_mdiobus_register_phy() to use fwnode_mdiobus_register_phy().

Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---

Changes in v7:
- include fwnode_mdio.h

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/net/mdio/of_mdio.c | 39 ++------------------------------------
 1 file changed, 2 insertions(+), 37 deletions(-)

diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c
index db293e0b8249..eebd4d9e1656 100644
--- a/drivers/net/mdio/of_mdio.c
+++ b/drivers/net/mdio/of_mdio.c
@@ -12,6 +12,7 @@
 #include <linux/device.h>
 #include <linux/netdevice.h>
 #include <linux/err.h>
+#include <linux/fwnode_mdio.h>
 #include <linux/phy.h>
 #include <linux/phy_fixed.h>
 #include <linux/of.h>
@@ -98,43 +99,7 @@ EXPORT_SYMBOL(of_mdiobus_phy_device_register);
 static int of_mdiobus_register_phy(struct mii_bus *mdio,
 				    struct device_node *child, u32 addr)
 {
-	struct mii_timestamper *mii_ts;
-	struct phy_device *phy;
-	bool is_c45;
-	int rc;
-	u32 phy_id;
-
-	mii_ts = of_find_mii_timestamper(child);
-	if (IS_ERR(mii_ts))
-		return PTR_ERR(mii_ts);
-
-	is_c45 = of_device_is_compatible(child,
-					 "ethernet-phy-ieee802.3-c45");
-
-	if (!is_c45 && !of_get_phy_id(child, &phy_id))
-		phy = phy_device_create(mdio, addr, phy_id, 0, NULL);
-	else
-		phy = get_phy_device(mdio, addr, is_c45);
-	if (IS_ERR(phy)) {
-		unregister_mii_timestamper(mii_ts);
-		return PTR_ERR(phy);
-	}
-
-	rc = of_mdiobus_phy_device_register(mdio, phy, child, addr);
-	if (rc) {
-		unregister_mii_timestamper(mii_ts);
-		phy_device_free(phy);
-		return rc;
-	}
-
-	/* phy->mii_ts may already be defined by the PHY driver. A
-	 * mii_timestamper probed via the device tree will still have
-	 * precedence.
-	 */
-	if (mii_ts)
-		phy->mii_ts = mii_ts;
-
-	return 0;
+	return fwnode_mdiobus_register_phy(mdio, of_fwnode_handle(child), addr);
 }
 
 static int of_mdiobus_register_device(struct mii_bus *mdio,
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [net-next PATCH v7 10/16] ACPI: utils: Introduce acpi_get_local_address()
  2021-03-11  6:19 ` Calvin Johnson
@ 2021-03-11  6:20   ` Calvin Johnson
  -1 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11  6:20 UTC (permalink / raw)
  To: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap
  Cc: linux-arm-kernel, Diana Madalina Craciun, linux-acpi,
	linux-kernel, linux.cj, netdev, Laurentiu Tudor, Calvin Johnson,
	Len Brown, Rafael J. Wysocki

Introduce a wrapper around the _ADR evaluation.

Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---

Changes in v7: None
Changes in v6: None
Changes in v5:
- Replace fwnode_get_id() with acpi_get_local_address()

Changes in v4:
- Improve code structure to handle all cases

Changes in v3:
- Modified to retrieve reg property value for ACPI as well
- Resolved compilation issue with CONFIG_ACPI = n
- Added more info into documentation

Changes in v2: None

 drivers/acpi/utils.c | 14 ++++++++++++++
 include/linux/acpi.h |  7 +++++++
 2 files changed, 21 insertions(+)

diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index 682edd913b3b..41fe380a09a7 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -277,6 +277,20 @@ acpi_evaluate_integer(acpi_handle handle,
 
 EXPORT_SYMBOL(acpi_evaluate_integer);
 
+int acpi_get_local_address(acpi_handle handle, u32 *addr)
+{
+	unsigned long long adr;
+	acpi_status status;
+
+	status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &adr);
+	if (ACPI_FAILURE(status))
+		return -ENODATA;
+
+	*addr = (u32)adr;
+	return 0;
+}
+EXPORT_SYMBOL(acpi_get_local_address);
+
 acpi_status
 acpi_evaluate_reference(acpi_handle handle,
 			acpi_string pathname,
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index fcdaab723916..700f9fc303ab 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -706,6 +706,8 @@ static inline u64 acpi_arch_get_root_pointer(void)
 }
 #endif
 
+int acpi_get_local_address(acpi_handle handle, u32 *addr);
+
 #else	/* !CONFIG_ACPI */
 
 #define acpi_disabled 1
@@ -953,6 +955,11 @@ static inline struct acpi_device *acpi_resource_consumer(struct resource *res)
 	return NULL;
 }
 
+static inline int acpi_get_local_address(acpi_handle handle, u32 *addr)
+{
+	return -ENODEV;
+}
+
 #endif	/* !CONFIG_ACPI */
 
 #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
-- 
2.17.1


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

* [net-next PATCH v7 10/16] ACPI: utils: Introduce acpi_get_local_address()
@ 2021-03-11  6:20   ` Calvin Johnson
  0 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11  6:20 UTC (permalink / raw)
  To: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap
  Cc: linux-arm-kernel, Diana Madalina Craciun, linux-acpi,
	linux-kernel, linux.cj, netdev, Laurentiu Tudor, Calvin Johnson,
	Len Brown, Rafael J. Wysocki

Introduce a wrapper around the _ADR evaluation.

Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---

Changes in v7: None
Changes in v6: None
Changes in v5:
- Replace fwnode_get_id() with acpi_get_local_address()

Changes in v4:
- Improve code structure to handle all cases

Changes in v3:
- Modified to retrieve reg property value for ACPI as well
- Resolved compilation issue with CONFIG_ACPI = n
- Added more info into documentation

Changes in v2: None

 drivers/acpi/utils.c | 14 ++++++++++++++
 include/linux/acpi.h |  7 +++++++
 2 files changed, 21 insertions(+)

diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index 682edd913b3b..41fe380a09a7 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -277,6 +277,20 @@ acpi_evaluate_integer(acpi_handle handle,
 
 EXPORT_SYMBOL(acpi_evaluate_integer);
 
+int acpi_get_local_address(acpi_handle handle, u32 *addr)
+{
+	unsigned long long adr;
+	acpi_status status;
+
+	status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &adr);
+	if (ACPI_FAILURE(status))
+		return -ENODATA;
+
+	*addr = (u32)adr;
+	return 0;
+}
+EXPORT_SYMBOL(acpi_get_local_address);
+
 acpi_status
 acpi_evaluate_reference(acpi_handle handle,
 			acpi_string pathname,
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index fcdaab723916..700f9fc303ab 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -706,6 +706,8 @@ static inline u64 acpi_arch_get_root_pointer(void)
 }
 #endif
 
+int acpi_get_local_address(acpi_handle handle, u32 *addr);
+
 #else	/* !CONFIG_ACPI */
 
 #define acpi_disabled 1
@@ -953,6 +955,11 @@ static inline struct acpi_device *acpi_resource_consumer(struct resource *res)
 	return NULL;
 }
 
+static inline int acpi_get_local_address(acpi_handle handle, u32 *addr)
+{
+	return -ENODEV;
+}
+
 #endif	/* !CONFIG_ACPI */
 
 #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [net-next PATCH v7 11/16] net: mdio: Add ACPI support code for mdio
  2021-03-11  6:19 ` Calvin Johnson
@ 2021-03-11  6:20   ` Calvin Johnson
  -1 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11  6:20 UTC (permalink / raw)
  To: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap
  Cc: linux-arm-kernel, Diana Madalina Craciun, linux-acpi,
	linux-kernel, linux.cj, netdev, Laurentiu Tudor, Calvin Johnson,
	David S. Miller, Heiner Kallweit, Jakub Kicinski

Define acpi_mdiobus_register() to Register mii_bus and create PHYs for
each ACPI child node.

Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---

Changes in v7:
- Include headers directly used in acpi_mdio.c

Changes in v6:
- use GENMASK() and ACPI_COMPANION_SET()
- some cleanup
- remove unwanted header inclusion

Changes in v5:
- add missing MODULE_LICENSE()
- replace fwnode_get_id() with OF and ACPI function calls

Changes in v4: None
Changes in v3: None
Changes in v2: None

 MAINTAINERS                  |  1 +
 drivers/net/mdio/Kconfig     |  7 +++++
 drivers/net/mdio/Makefile    |  1 +
 drivers/net/mdio/acpi_mdio.c | 56 ++++++++++++++++++++++++++++++++++++
 include/linux/acpi_mdio.h    | 25 ++++++++++++++++
 5 files changed, 90 insertions(+)
 create mode 100644 drivers/net/mdio/acpi_mdio.c
 create mode 100644 include/linux/acpi_mdio.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 146de41d2656..051377b7fa94 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6680,6 +6680,7 @@ F:	Documentation/devicetree/bindings/net/mdio*
 F:	Documentation/devicetree/bindings/net/qca,ar803x.yaml
 F:	Documentation/networking/phy.rst
 F:	drivers/net/mdio/
+F:	drivers/net/mdio/acpi_mdio.c
 F:	drivers/net/mdio/fwnode_mdio.c
 F:	drivers/net/mdio/of_mdio.c
 F:	drivers/net/pcs/
diff --git a/drivers/net/mdio/Kconfig b/drivers/net/mdio/Kconfig
index 2d5bf5ccffb5..fc8c787b448f 100644
--- a/drivers/net/mdio/Kconfig
+++ b/drivers/net/mdio/Kconfig
@@ -36,6 +36,13 @@ config OF_MDIO
 	help
 	  OpenFirmware MDIO bus (Ethernet PHY) accessors
 
+config ACPI_MDIO
+	def_tristate PHYLIB
+	depends on ACPI
+	depends on PHYLIB
+	help
+	  ACPI MDIO bus (Ethernet PHY) accessors
+
 if MDIO_BUS
 
 config MDIO_DEVRES
diff --git a/drivers/net/mdio/Makefile b/drivers/net/mdio/Makefile
index ea5390e2ef84..e8b739a3df1c 100644
--- a/drivers/net/mdio/Makefile
+++ b/drivers/net/mdio/Makefile
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 # Makefile for Linux MDIO bus drivers
 
+obj-$(CONFIG_ACPI_MDIO)		+= acpi_mdio.o
 obj-$(CONFIG_FWNODE_MDIO)	+= fwnode_mdio.o
 obj-$(CONFIG_OF_MDIO)		+= of_mdio.o
 
diff --git a/drivers/net/mdio/acpi_mdio.c b/drivers/net/mdio/acpi_mdio.c
new file mode 100644
index 000000000000..60a86e3fc246
--- /dev/null
+++ b/drivers/net/mdio/acpi_mdio.c
@@ -0,0 +1,56 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * ACPI helpers for the MDIO (Ethernet PHY) API
+ *
+ * This file provides helper functions for extracting PHY device information
+ * out of the ACPI ASL and using it to populate an mii_bus.
+ */
+
+#include <linux/acpi.h>
+#include <linux/acpi_mdio.h>
+#include <linux/bits.h>
+#include <linux/dev_printk.h>
+#include <linux/fwnode_mdio.h>
+#include <linux/module.h>
+#include <linux/types.h>
+
+MODULE_AUTHOR("Calvin Johnson <calvin.johnson@oss.nxp.com>");
+MODULE_LICENSE("GPL");
+
+/**
+ * acpi_mdiobus_register - Register mii_bus and create PHYs from the ACPI ASL.
+ * @mdio: pointer to mii_bus structure
+ * @fwnode: pointer to fwnode of MDIO bus.
+ *
+ * This function registers the mii_bus structure and registers a phy_device
+ * for each child node of @fwnode.
+ */
+int acpi_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode)
+{
+	struct fwnode_handle *child;
+	u32 addr;
+	int ret;
+
+	/* Mask out all PHYs from auto probing. */
+	mdio->phy_mask = GENMASK(31, 0);
+	ret = mdiobus_register(mdio);
+	if (ret)
+		return ret;
+
+	ACPI_COMPANION_SET(&mdio->dev, to_acpi_device_node(fwnode));
+
+	/* Loop over the child nodes and register a phy_device for each PHY */
+	fwnode_for_each_child_node(fwnode, child) {
+		ret = acpi_get_local_address(ACPI_HANDLE_FWNODE(child), &addr);
+		if (ret || addr >= PHY_MAX_ADDR)
+			continue;
+
+		ret = fwnode_mdiobus_register_phy(mdio, child, addr);
+		if (ret == -ENODEV)
+			dev_err(&mdio->dev,
+				"MDIO device at address %d is missing.\n",
+				addr);
+	}
+	return 0;
+}
+EXPORT_SYMBOL(acpi_mdiobus_register);
diff --git a/include/linux/acpi_mdio.h b/include/linux/acpi_mdio.h
new file mode 100644
index 000000000000..748d261fe2f9
--- /dev/null
+++ b/include/linux/acpi_mdio.h
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * ACPI helper for the MDIO (Ethernet PHY) API
+ */
+
+#ifndef __LINUX_ACPI_MDIO_H
+#define __LINUX_ACPI_MDIO_H
+
+#include <linux/phy.h>
+
+#if IS_ENABLED(CONFIG_ACPI_MDIO)
+int acpi_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode);
+#else /* CONFIG_ACPI_MDIO */
+static inline int acpi_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode)
+{
+	/*
+	 * Fall back to mdiobus_register() function to register a bus.
+	 * This way, we don't have to keep compat bits around in drivers.
+	 */
+
+	return mdiobus_register(mdio);
+}
+#endif
+
+#endif /* __LINUX_ACPI_MDIO_H */
-- 
2.17.1


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

* [net-next PATCH v7 11/16] net: mdio: Add ACPI support code for mdio
@ 2021-03-11  6:20   ` Calvin Johnson
  0 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11  6:20 UTC (permalink / raw)
  To: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap
  Cc: linux-arm-kernel, Diana Madalina Craciun, linux-acpi,
	linux-kernel, linux.cj, netdev, Laurentiu Tudor, Calvin Johnson,
	David S. Miller, Heiner Kallweit, Jakub Kicinski

Define acpi_mdiobus_register() to Register mii_bus and create PHYs for
each ACPI child node.

Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---

Changes in v7:
- Include headers directly used in acpi_mdio.c

Changes in v6:
- use GENMASK() and ACPI_COMPANION_SET()
- some cleanup
- remove unwanted header inclusion

Changes in v5:
- add missing MODULE_LICENSE()
- replace fwnode_get_id() with OF and ACPI function calls

Changes in v4: None
Changes in v3: None
Changes in v2: None

 MAINTAINERS                  |  1 +
 drivers/net/mdio/Kconfig     |  7 +++++
 drivers/net/mdio/Makefile    |  1 +
 drivers/net/mdio/acpi_mdio.c | 56 ++++++++++++++++++++++++++++++++++++
 include/linux/acpi_mdio.h    | 25 ++++++++++++++++
 5 files changed, 90 insertions(+)
 create mode 100644 drivers/net/mdio/acpi_mdio.c
 create mode 100644 include/linux/acpi_mdio.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 146de41d2656..051377b7fa94 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6680,6 +6680,7 @@ F:	Documentation/devicetree/bindings/net/mdio*
 F:	Documentation/devicetree/bindings/net/qca,ar803x.yaml
 F:	Documentation/networking/phy.rst
 F:	drivers/net/mdio/
+F:	drivers/net/mdio/acpi_mdio.c
 F:	drivers/net/mdio/fwnode_mdio.c
 F:	drivers/net/mdio/of_mdio.c
 F:	drivers/net/pcs/
diff --git a/drivers/net/mdio/Kconfig b/drivers/net/mdio/Kconfig
index 2d5bf5ccffb5..fc8c787b448f 100644
--- a/drivers/net/mdio/Kconfig
+++ b/drivers/net/mdio/Kconfig
@@ -36,6 +36,13 @@ config OF_MDIO
 	help
 	  OpenFirmware MDIO bus (Ethernet PHY) accessors
 
+config ACPI_MDIO
+	def_tristate PHYLIB
+	depends on ACPI
+	depends on PHYLIB
+	help
+	  ACPI MDIO bus (Ethernet PHY) accessors
+
 if MDIO_BUS
 
 config MDIO_DEVRES
diff --git a/drivers/net/mdio/Makefile b/drivers/net/mdio/Makefile
index ea5390e2ef84..e8b739a3df1c 100644
--- a/drivers/net/mdio/Makefile
+++ b/drivers/net/mdio/Makefile
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 # Makefile for Linux MDIO bus drivers
 
+obj-$(CONFIG_ACPI_MDIO)		+= acpi_mdio.o
 obj-$(CONFIG_FWNODE_MDIO)	+= fwnode_mdio.o
 obj-$(CONFIG_OF_MDIO)		+= of_mdio.o
 
diff --git a/drivers/net/mdio/acpi_mdio.c b/drivers/net/mdio/acpi_mdio.c
new file mode 100644
index 000000000000..60a86e3fc246
--- /dev/null
+++ b/drivers/net/mdio/acpi_mdio.c
@@ -0,0 +1,56 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * ACPI helpers for the MDIO (Ethernet PHY) API
+ *
+ * This file provides helper functions for extracting PHY device information
+ * out of the ACPI ASL and using it to populate an mii_bus.
+ */
+
+#include <linux/acpi.h>
+#include <linux/acpi_mdio.h>
+#include <linux/bits.h>
+#include <linux/dev_printk.h>
+#include <linux/fwnode_mdio.h>
+#include <linux/module.h>
+#include <linux/types.h>
+
+MODULE_AUTHOR("Calvin Johnson <calvin.johnson@oss.nxp.com>");
+MODULE_LICENSE("GPL");
+
+/**
+ * acpi_mdiobus_register - Register mii_bus and create PHYs from the ACPI ASL.
+ * @mdio: pointer to mii_bus structure
+ * @fwnode: pointer to fwnode of MDIO bus.
+ *
+ * This function registers the mii_bus structure and registers a phy_device
+ * for each child node of @fwnode.
+ */
+int acpi_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode)
+{
+	struct fwnode_handle *child;
+	u32 addr;
+	int ret;
+
+	/* Mask out all PHYs from auto probing. */
+	mdio->phy_mask = GENMASK(31, 0);
+	ret = mdiobus_register(mdio);
+	if (ret)
+		return ret;
+
+	ACPI_COMPANION_SET(&mdio->dev, to_acpi_device_node(fwnode));
+
+	/* Loop over the child nodes and register a phy_device for each PHY */
+	fwnode_for_each_child_node(fwnode, child) {
+		ret = acpi_get_local_address(ACPI_HANDLE_FWNODE(child), &addr);
+		if (ret || addr >= PHY_MAX_ADDR)
+			continue;
+
+		ret = fwnode_mdiobus_register_phy(mdio, child, addr);
+		if (ret == -ENODEV)
+			dev_err(&mdio->dev,
+				"MDIO device at address %d is missing.\n",
+				addr);
+	}
+	return 0;
+}
+EXPORT_SYMBOL(acpi_mdiobus_register);
diff --git a/include/linux/acpi_mdio.h b/include/linux/acpi_mdio.h
new file mode 100644
index 000000000000..748d261fe2f9
--- /dev/null
+++ b/include/linux/acpi_mdio.h
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * ACPI helper for the MDIO (Ethernet PHY) API
+ */
+
+#ifndef __LINUX_ACPI_MDIO_H
+#define __LINUX_ACPI_MDIO_H
+
+#include <linux/phy.h>
+
+#if IS_ENABLED(CONFIG_ACPI_MDIO)
+int acpi_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode);
+#else /* CONFIG_ACPI_MDIO */
+static inline int acpi_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode)
+{
+	/*
+	 * Fall back to mdiobus_register() function to register a bus.
+	 * This way, we don't have to keep compat bits around in drivers.
+	 */
+
+	return mdiobus_register(mdio);
+}
+#endif
+
+#endif /* __LINUX_ACPI_MDIO_H */
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [net-next PATCH v7 12/16] net: mdiobus: Introduce fwnode_mdiobus_register()
  2021-03-11  6:19 ` Calvin Johnson
@ 2021-03-11  6:20   ` Calvin Johnson
  -1 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11  6:20 UTC (permalink / raw)
  To: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap
  Cc: linux-arm-kernel, Diana Madalina Craciun, linux-acpi,
	linux-kernel, linux.cj, netdev, Laurentiu Tudor, Calvin Johnson,
	David S. Miller, Heiner Kallweit, Jakub Kicinski

Introduce fwnode_mdiobus_register() to register PHYs on the  mdiobus.
If the fwnode is DT node, then call of_mdiobus_register().
If it is an ACPI node, then call acpi_mdiobus_register().

Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---

Changes in v7:
- Move fwnode_mdiobus_register() to fwnode_mdio.c

Changes in v6: None
Changes in v5: None
Changes in v4:
- Remove redundant else from fwnode_mdiobus_register()

Changes in v3:
- Use acpi_mdiobus_register()

Changes in v2: None

 drivers/net/mdio/fwnode_mdio.c | 21 +++++++++++++++++++++
 include/linux/fwnode_mdio.h    |  5 +++++
 2 files changed, 26 insertions(+)

diff --git a/drivers/net/mdio/fwnode_mdio.c b/drivers/net/mdio/fwnode_mdio.c
index 0982e816a6fb..523c2778b287 100644
--- a/drivers/net/mdio/fwnode_mdio.c
+++ b/drivers/net/mdio/fwnode_mdio.c
@@ -7,6 +7,7 @@
  */
 
 #include <linux/acpi.h>
+#include <linux/acpi_mdio.h>
 #include <linux/of.h>
 #include <linux/of_mdio.h>
 #include <linux/phy.h>
@@ -75,3 +76,23 @@ int fwnode_mdiobus_register_phy(struct mii_bus *bus,
 	return 0;
 }
 EXPORT_SYMBOL(fwnode_mdiobus_register_phy);
+
+/**
+ * fwnode_mdiobus_register - Register mii_bus and create PHYs from fwnode
+ * @mdio: pointer to mii_bus structure
+ * @fwnode: pointer to fwnode of MDIO bus.
+ *
+ * This function returns of_mdiobus_register() for DT and
+ * acpi_mdiobus_register() for ACPI.
+ */
+int fwnode_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode)
+{
+	if (is_of_node(fwnode))
+		return of_mdiobus_register(mdio, to_of_node(fwnode));
+
+	if (is_acpi_node(fwnode))
+		return acpi_mdiobus_register(mdio, fwnode);
+
+	return -EINVAL;
+}
+EXPORT_SYMBOL(fwnode_mdiobus_register);
diff --git a/include/linux/fwnode_mdio.h b/include/linux/fwnode_mdio.h
index 8c0392845916..20f22211260b 100644
--- a/include/linux/fwnode_mdio.h
+++ b/include/linux/fwnode_mdio.h
@@ -12,6 +12,7 @@
 int fwnode_mdiobus_register_phy(struct mii_bus *bus,
 				struct fwnode_handle *child, u32 addr);
 
+int fwnode_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode);
 #else /* CONFIG_FWNODE_MDIO */
 static inline int fwnode_mdiobus_register_phy(struct mii_bus *bus,
 					      struct fwnode_handle *child,
@@ -19,6 +20,10 @@ static inline int fwnode_mdiobus_register_phy(struct mii_bus *bus,
 {
 	return -EINVAL;
 }
+static int fwnode_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode)
+{
+	return -EINVAL;
+}
 #endif
 
 #endif /* __LINUX_FWNODE_MDIO_H */
-- 
2.17.1


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

* [net-next PATCH v7 12/16] net: mdiobus: Introduce fwnode_mdiobus_register()
@ 2021-03-11  6:20   ` Calvin Johnson
  0 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11  6:20 UTC (permalink / raw)
  To: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap
  Cc: linux-arm-kernel, Diana Madalina Craciun, linux-acpi,
	linux-kernel, linux.cj, netdev, Laurentiu Tudor, Calvin Johnson,
	David S. Miller, Heiner Kallweit, Jakub Kicinski

Introduce fwnode_mdiobus_register() to register PHYs on the  mdiobus.
If the fwnode is DT node, then call of_mdiobus_register().
If it is an ACPI node, then call acpi_mdiobus_register().

Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---

Changes in v7:
- Move fwnode_mdiobus_register() to fwnode_mdio.c

Changes in v6: None
Changes in v5: None
Changes in v4:
- Remove redundant else from fwnode_mdiobus_register()

Changes in v3:
- Use acpi_mdiobus_register()

Changes in v2: None

 drivers/net/mdio/fwnode_mdio.c | 21 +++++++++++++++++++++
 include/linux/fwnode_mdio.h    |  5 +++++
 2 files changed, 26 insertions(+)

diff --git a/drivers/net/mdio/fwnode_mdio.c b/drivers/net/mdio/fwnode_mdio.c
index 0982e816a6fb..523c2778b287 100644
--- a/drivers/net/mdio/fwnode_mdio.c
+++ b/drivers/net/mdio/fwnode_mdio.c
@@ -7,6 +7,7 @@
  */
 
 #include <linux/acpi.h>
+#include <linux/acpi_mdio.h>
 #include <linux/of.h>
 #include <linux/of_mdio.h>
 #include <linux/phy.h>
@@ -75,3 +76,23 @@ int fwnode_mdiobus_register_phy(struct mii_bus *bus,
 	return 0;
 }
 EXPORT_SYMBOL(fwnode_mdiobus_register_phy);
+
+/**
+ * fwnode_mdiobus_register - Register mii_bus and create PHYs from fwnode
+ * @mdio: pointer to mii_bus structure
+ * @fwnode: pointer to fwnode of MDIO bus.
+ *
+ * This function returns of_mdiobus_register() for DT and
+ * acpi_mdiobus_register() for ACPI.
+ */
+int fwnode_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode)
+{
+	if (is_of_node(fwnode))
+		return of_mdiobus_register(mdio, to_of_node(fwnode));
+
+	if (is_acpi_node(fwnode))
+		return acpi_mdiobus_register(mdio, fwnode);
+
+	return -EINVAL;
+}
+EXPORT_SYMBOL(fwnode_mdiobus_register);
diff --git a/include/linux/fwnode_mdio.h b/include/linux/fwnode_mdio.h
index 8c0392845916..20f22211260b 100644
--- a/include/linux/fwnode_mdio.h
+++ b/include/linux/fwnode_mdio.h
@@ -12,6 +12,7 @@
 int fwnode_mdiobus_register_phy(struct mii_bus *bus,
 				struct fwnode_handle *child, u32 addr);
 
+int fwnode_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode);
 #else /* CONFIG_FWNODE_MDIO */
 static inline int fwnode_mdiobus_register_phy(struct mii_bus *bus,
 					      struct fwnode_handle *child,
@@ -19,6 +20,10 @@ static inline int fwnode_mdiobus_register_phy(struct mii_bus *bus,
 {
 	return -EINVAL;
 }
+static int fwnode_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode)
+{
+	return -EINVAL;
+}
 #endif
 
 #endif /* __LINUX_FWNODE_MDIO_H */
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [net-next PATCH v7 13/16] net/fsl: Use fwnode_mdiobus_register()
  2021-03-11  6:19 ` Calvin Johnson
@ 2021-03-11  6:20   ` Calvin Johnson
  -1 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11  6:20 UTC (permalink / raw)
  To: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap
  Cc: linux-arm-kernel, Diana Madalina Craciun, linux-acpi,
	linux-kernel, linux.cj, netdev, Laurentiu Tudor, Calvin Johnson,
	David S. Miller, Jakub Kicinski, Jamie Iles

fwnode_mdiobus_register() internally takes care of both DT
and ACPI cases to register mdiobus. Replace existing
of_mdiobus_register() with fwnode_mdiobus_register().

Note: For both ACPI and DT cases, endianness of MDIO controller
need to be specified using "little-endian" property.

Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---

Changes in v7:
- Include fwnode_mdio.h
- Alphabetically sort header inclusions

Changes in v6: None
Changes in v5: None
Changes in v4:
- Cleanup xgmac_mdio_probe()

Changes in v3:
- Avoid unnecessary line removal
- Remove unused inclusion of acpi.h

Changes in v2: None

 drivers/net/ethernet/freescale/xgmac_mdio.c | 22 ++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/freescale/xgmac_mdio.c b/drivers/net/ethernet/freescale/xgmac_mdio.c
index bfa2826c5545..6daf1fb2e9ea 100644
--- a/drivers/net/ethernet/freescale/xgmac_mdio.c
+++ b/drivers/net/ethernet/freescale/xgmac_mdio.c
@@ -2,6 +2,7 @@
  * QorIQ 10G MDIO Controller
  *
  * Copyright 2012 Freescale Semiconductor, Inc.
+ * Copyright 2021 NXP
  *
  * Authors: Andy Fleming <afleming@freescale.com>
  *          Timur Tabi <timur@freescale.com>
@@ -11,15 +12,16 @@
  * kind, whether express or implied.
  */
 
-#include <linux/kernel.h>
-#include <linux/slab.h>
+#include <linux/fwnode_mdio.h>
 #include <linux/interrupt.h>
-#include <linux/module.h>
-#include <linux/phy.h>
+#include <linux/kernel.h>
 #include <linux/mdio.h>
+#include <linux/module.h>
 #include <linux/of_address.h>
-#include <linux/of_platform.h>
 #include <linux/of_mdio.h>
+#include <linux/of_platform.h>
+#include <linux/phy.h>
+#include <linux/slab.h>
 
 /* Number of microseconds to wait for a register to respond */
 #define TIMEOUT	1000
@@ -243,10 +245,9 @@ static int xgmac_mdio_read(struct mii_bus *bus, int phy_id, int regnum)
 
 static int xgmac_mdio_probe(struct platform_device *pdev)
 {
-	struct device_node *np = pdev->dev.of_node;
-	struct mii_bus *bus;
-	struct resource *res;
 	struct mdio_fsl_priv *priv;
+	struct resource *res;
+	struct mii_bus *bus;
 	int ret;
 
 	/* In DPAA-1, MDIO is one of the many FMan sub-devices. The FMan
@@ -279,13 +280,16 @@ static int xgmac_mdio_probe(struct platform_device *pdev)
 		goto err_ioremap;
 	}
 
+	/* For both ACPI and DT cases, endianness of MDIO controller
+	 * needs to be specified using "little-endian" property.
+	 */
 	priv->is_little_endian = device_property_read_bool(&pdev->dev,
 							   "little-endian");
 
 	priv->has_a011043 = device_property_read_bool(&pdev->dev,
 						      "fsl,erratum-a011043");
 
-	ret = of_mdiobus_register(bus, np);
+	ret = fwnode_mdiobus_register(bus, pdev->dev.fwnode);
 	if (ret) {
 		dev_err(&pdev->dev, "cannot register MDIO bus\n");
 		goto err_registration;
-- 
2.17.1


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

* [net-next PATCH v7 13/16] net/fsl: Use fwnode_mdiobus_register()
@ 2021-03-11  6:20   ` Calvin Johnson
  0 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11  6:20 UTC (permalink / raw)
  To: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap
  Cc: linux-arm-kernel, Diana Madalina Craciun, linux-acpi,
	linux-kernel, linux.cj, netdev, Laurentiu Tudor, Calvin Johnson,
	David S. Miller, Jakub Kicinski, Jamie Iles

fwnode_mdiobus_register() internally takes care of both DT
and ACPI cases to register mdiobus. Replace existing
of_mdiobus_register() with fwnode_mdiobus_register().

Note: For both ACPI and DT cases, endianness of MDIO controller
need to be specified using "little-endian" property.

Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---

Changes in v7:
- Include fwnode_mdio.h
- Alphabetically sort header inclusions

Changes in v6: None
Changes in v5: None
Changes in v4:
- Cleanup xgmac_mdio_probe()

Changes in v3:
- Avoid unnecessary line removal
- Remove unused inclusion of acpi.h

Changes in v2: None

 drivers/net/ethernet/freescale/xgmac_mdio.c | 22 ++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/freescale/xgmac_mdio.c b/drivers/net/ethernet/freescale/xgmac_mdio.c
index bfa2826c5545..6daf1fb2e9ea 100644
--- a/drivers/net/ethernet/freescale/xgmac_mdio.c
+++ b/drivers/net/ethernet/freescale/xgmac_mdio.c
@@ -2,6 +2,7 @@
  * QorIQ 10G MDIO Controller
  *
  * Copyright 2012 Freescale Semiconductor, Inc.
+ * Copyright 2021 NXP
  *
  * Authors: Andy Fleming <afleming@freescale.com>
  *          Timur Tabi <timur@freescale.com>
@@ -11,15 +12,16 @@
  * kind, whether express or implied.
  */
 
-#include <linux/kernel.h>
-#include <linux/slab.h>
+#include <linux/fwnode_mdio.h>
 #include <linux/interrupt.h>
-#include <linux/module.h>
-#include <linux/phy.h>
+#include <linux/kernel.h>
 #include <linux/mdio.h>
+#include <linux/module.h>
 #include <linux/of_address.h>
-#include <linux/of_platform.h>
 #include <linux/of_mdio.h>
+#include <linux/of_platform.h>
+#include <linux/phy.h>
+#include <linux/slab.h>
 
 /* Number of microseconds to wait for a register to respond */
 #define TIMEOUT	1000
@@ -243,10 +245,9 @@ static int xgmac_mdio_read(struct mii_bus *bus, int phy_id, int regnum)
 
 static int xgmac_mdio_probe(struct platform_device *pdev)
 {
-	struct device_node *np = pdev->dev.of_node;
-	struct mii_bus *bus;
-	struct resource *res;
 	struct mdio_fsl_priv *priv;
+	struct resource *res;
+	struct mii_bus *bus;
 	int ret;
 
 	/* In DPAA-1, MDIO is one of the many FMan sub-devices. The FMan
@@ -279,13 +280,16 @@ static int xgmac_mdio_probe(struct platform_device *pdev)
 		goto err_ioremap;
 	}
 
+	/* For both ACPI and DT cases, endianness of MDIO controller
+	 * needs to be specified using "little-endian" property.
+	 */
 	priv->is_little_endian = device_property_read_bool(&pdev->dev,
 							   "little-endian");
 
 	priv->has_a011043 = device_property_read_bool(&pdev->dev,
 						      "fsl,erratum-a011043");
 
-	ret = of_mdiobus_register(bus, np);
+	ret = fwnode_mdiobus_register(bus, pdev->dev.fwnode);
 	if (ret) {
 		dev_err(&pdev->dev, "cannot register MDIO bus\n");
 		goto err_registration;
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [net-next PATCH v7 14/16] net: phylink: introduce phylink_fwnode_phy_connect()
  2021-03-11  6:19 ` Calvin Johnson
@ 2021-03-11  6:20   ` Calvin Johnson
  -1 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11  6:20 UTC (permalink / raw)
  To: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap
  Cc: linux-arm-kernel, Diana Madalina Craciun, linux-acpi,
	linux-kernel, linux.cj, netdev, Laurentiu Tudor, Calvin Johnson,
	David S. Miller, Heiner Kallweit, Jakub Kicinski

Define phylink_fwnode_phy_connect() to connect phy specified by
a fwnode to a phylink instance.

Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---

Changes in v7: None
Changes in v6:
- remove OF check for fixed-link

Changes in v5: None
Changes in v4:
- call phy_device_free() before returning

Changes in v3: None
Changes in v2: None

 drivers/net/phy/phylink.c | 54 +++++++++++++++++++++++++++++++++++++++
 include/linux/phylink.h   |  3 +++
 2 files changed, 57 insertions(+)

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 053c92e02cd8..23753f92e0a6 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -5,6 +5,7 @@
  *
  * Copyright (C) 2015 Russell King
  */
+#include <linux/acpi.h>
 #include <linux/ethtool.h>
 #include <linux/export.h>
 #include <linux/gpio/consumer.h>
@@ -1124,6 +1125,59 @@ int phylink_of_phy_connect(struct phylink *pl, struct device_node *dn,
 }
 EXPORT_SYMBOL_GPL(phylink_of_phy_connect);
 
+/**
+ * phylink_fwnode_phy_connect() - connect the PHY specified in the fwnode.
+ * @pl: a pointer to a &struct phylink returned from phylink_create()
+ * @fwnode: a pointer to a &struct fwnode_handle.
+ * @flags: PHY-specific flags to communicate to the PHY device driver
+ *
+ * Connect the phy specified @fwnode to the phylink instance specified
+ * by @pl.
+ *
+ * Returns 0 on success or a negative errno.
+ */
+int phylink_fwnode_phy_connect(struct phylink *pl,
+			       struct fwnode_handle *fwnode,
+			       u32 flags)
+{
+	struct fwnode_handle *phy_fwnode;
+	struct phy_device *phy_dev;
+	int ret;
+
+	/* Fixed links and 802.3z are handled without needing a PHY */
+	if (pl->cfg_link_an_mode == MLO_AN_FIXED ||
+	    (pl->cfg_link_an_mode == MLO_AN_INBAND &&
+	     phy_interface_mode_is_8023z(pl->link_interface)))
+		return 0;
+
+	phy_fwnode = fwnode_get_phy_node(fwnode);
+	if (IS_ERR(phy_fwnode)) {
+		if (pl->cfg_link_an_mode == MLO_AN_PHY)
+			return -ENODEV;
+		return 0;
+	}
+
+	phy_dev = fwnode_phy_find_device(phy_fwnode);
+	/* We're done with the phy_node handle */
+	fwnode_handle_put(phy_fwnode);
+	if (!phy_dev)
+		return -ENODEV;
+
+	ret = phy_attach_direct(pl->netdev, phy_dev, flags,
+				pl->link_interface);
+	if (ret) {
+		phy_device_free(phy_dev);
+		return ret;
+	}
+
+	ret = phylink_bringup_phy(pl, phy_dev, pl->link_config.interface);
+	if (ret)
+		phy_detach(phy_dev);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(phylink_fwnode_phy_connect);
+
 /**
  * phylink_disconnect_phy() - disconnect any PHY attached to the phylink
  *   instance.
diff --git a/include/linux/phylink.h b/include/linux/phylink.h
index d81a714cfbbd..75d4f99090fd 100644
--- a/include/linux/phylink.h
+++ b/include/linux/phylink.h
@@ -439,6 +439,9 @@ void phylink_destroy(struct phylink *);
 
 int phylink_connect_phy(struct phylink *, struct phy_device *);
 int phylink_of_phy_connect(struct phylink *, struct device_node *, u32 flags);
+int phylink_fwnode_phy_connect(struct phylink *pl,
+			       struct fwnode_handle *fwnode,
+			       u32 flags);
 void phylink_disconnect_phy(struct phylink *);
 
 void phylink_mac_change(struct phylink *, bool up);
-- 
2.17.1


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

* [net-next PATCH v7 14/16] net: phylink: introduce phylink_fwnode_phy_connect()
@ 2021-03-11  6:20   ` Calvin Johnson
  0 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11  6:20 UTC (permalink / raw)
  To: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap
  Cc: linux-arm-kernel, Diana Madalina Craciun, linux-acpi,
	linux-kernel, linux.cj, netdev, Laurentiu Tudor, Calvin Johnson,
	David S. Miller, Heiner Kallweit, Jakub Kicinski

Define phylink_fwnode_phy_connect() to connect phy specified by
a fwnode to a phylink instance.

Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---

Changes in v7: None
Changes in v6:
- remove OF check for fixed-link

Changes in v5: None
Changes in v4:
- call phy_device_free() before returning

Changes in v3: None
Changes in v2: None

 drivers/net/phy/phylink.c | 54 +++++++++++++++++++++++++++++++++++++++
 include/linux/phylink.h   |  3 +++
 2 files changed, 57 insertions(+)

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 053c92e02cd8..23753f92e0a6 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -5,6 +5,7 @@
  *
  * Copyright (C) 2015 Russell King
  */
+#include <linux/acpi.h>
 #include <linux/ethtool.h>
 #include <linux/export.h>
 #include <linux/gpio/consumer.h>
@@ -1124,6 +1125,59 @@ int phylink_of_phy_connect(struct phylink *pl, struct device_node *dn,
 }
 EXPORT_SYMBOL_GPL(phylink_of_phy_connect);
 
+/**
+ * phylink_fwnode_phy_connect() - connect the PHY specified in the fwnode.
+ * @pl: a pointer to a &struct phylink returned from phylink_create()
+ * @fwnode: a pointer to a &struct fwnode_handle.
+ * @flags: PHY-specific flags to communicate to the PHY device driver
+ *
+ * Connect the phy specified @fwnode to the phylink instance specified
+ * by @pl.
+ *
+ * Returns 0 on success or a negative errno.
+ */
+int phylink_fwnode_phy_connect(struct phylink *pl,
+			       struct fwnode_handle *fwnode,
+			       u32 flags)
+{
+	struct fwnode_handle *phy_fwnode;
+	struct phy_device *phy_dev;
+	int ret;
+
+	/* Fixed links and 802.3z are handled without needing a PHY */
+	if (pl->cfg_link_an_mode == MLO_AN_FIXED ||
+	    (pl->cfg_link_an_mode == MLO_AN_INBAND &&
+	     phy_interface_mode_is_8023z(pl->link_interface)))
+		return 0;
+
+	phy_fwnode = fwnode_get_phy_node(fwnode);
+	if (IS_ERR(phy_fwnode)) {
+		if (pl->cfg_link_an_mode == MLO_AN_PHY)
+			return -ENODEV;
+		return 0;
+	}
+
+	phy_dev = fwnode_phy_find_device(phy_fwnode);
+	/* We're done with the phy_node handle */
+	fwnode_handle_put(phy_fwnode);
+	if (!phy_dev)
+		return -ENODEV;
+
+	ret = phy_attach_direct(pl->netdev, phy_dev, flags,
+				pl->link_interface);
+	if (ret) {
+		phy_device_free(phy_dev);
+		return ret;
+	}
+
+	ret = phylink_bringup_phy(pl, phy_dev, pl->link_config.interface);
+	if (ret)
+		phy_detach(phy_dev);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(phylink_fwnode_phy_connect);
+
 /**
  * phylink_disconnect_phy() - disconnect any PHY attached to the phylink
  *   instance.
diff --git a/include/linux/phylink.h b/include/linux/phylink.h
index d81a714cfbbd..75d4f99090fd 100644
--- a/include/linux/phylink.h
+++ b/include/linux/phylink.h
@@ -439,6 +439,9 @@ void phylink_destroy(struct phylink *);
 
 int phylink_connect_phy(struct phylink *, struct phy_device *);
 int phylink_of_phy_connect(struct phylink *, struct device_node *, u32 flags);
+int phylink_fwnode_phy_connect(struct phylink *pl,
+			       struct fwnode_handle *fwnode,
+			       u32 flags);
 void phylink_disconnect_phy(struct phylink *);
 
 void phylink_mac_change(struct phylink *, bool up);
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [net-next PATCH v7 15/16] net: phylink: Refactor phylink_of_phy_connect()
  2021-03-11  6:19 ` Calvin Johnson
@ 2021-03-11  6:20   ` Calvin Johnson
  -1 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11  6:20 UTC (permalink / raw)
  To: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap
  Cc: linux-arm-kernel, Diana Madalina Craciun, linux-acpi,
	linux-kernel, linux.cj, netdev, Laurentiu Tudor, Calvin Johnson,
	David S. Miller, Heiner Kallweit, Jakub Kicinski

Refactor phylink_of_phy_connect() to use phylink_fwnode_phy_connect().

Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/net/phy/phylink.c | 39 +--------------------------------------
 1 file changed, 1 insertion(+), 38 deletions(-)

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 23753f92e0a6..ce7e918430c8 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -1084,44 +1084,7 @@ EXPORT_SYMBOL_GPL(phylink_connect_phy);
 int phylink_of_phy_connect(struct phylink *pl, struct device_node *dn,
 			   u32 flags)
 {
-	struct device_node *phy_node;
-	struct phy_device *phy_dev;
-	int ret;
-
-	/* Fixed links and 802.3z are handled without needing a PHY */
-	if (pl->cfg_link_an_mode == MLO_AN_FIXED ||
-	    (pl->cfg_link_an_mode == MLO_AN_INBAND &&
-	     phy_interface_mode_is_8023z(pl->link_interface)))
-		return 0;
-
-	phy_node = of_parse_phandle(dn, "phy-handle", 0);
-	if (!phy_node)
-		phy_node = of_parse_phandle(dn, "phy", 0);
-	if (!phy_node)
-		phy_node = of_parse_phandle(dn, "phy-device", 0);
-
-	if (!phy_node) {
-		if (pl->cfg_link_an_mode == MLO_AN_PHY)
-			return -ENODEV;
-		return 0;
-	}
-
-	phy_dev = of_phy_find_device(phy_node);
-	/* We're done with the phy_node handle */
-	of_node_put(phy_node);
-	if (!phy_dev)
-		return -ENODEV;
-
-	ret = phy_attach_direct(pl->netdev, phy_dev, flags,
-				pl->link_interface);
-	if (ret)
-		return ret;
-
-	ret = phylink_bringup_phy(pl, phy_dev, pl->link_config.interface);
-	if (ret)
-		phy_detach(phy_dev);
-
-	return ret;
+	return phylink_fwnode_phy_connect(pl, of_fwnode_handle(dn), flags);
 }
 EXPORT_SYMBOL_GPL(phylink_of_phy_connect);
 
-- 
2.17.1


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

* [net-next PATCH v7 15/16] net: phylink: Refactor phylink_of_phy_connect()
@ 2021-03-11  6:20   ` Calvin Johnson
  0 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11  6:20 UTC (permalink / raw)
  To: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap
  Cc: linux-arm-kernel, Diana Madalina Craciun, linux-acpi,
	linux-kernel, linux.cj, netdev, Laurentiu Tudor, Calvin Johnson,
	David S. Miller, Heiner Kallweit, Jakub Kicinski

Refactor phylink_of_phy_connect() to use phylink_fwnode_phy_connect().

Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/net/phy/phylink.c | 39 +--------------------------------------
 1 file changed, 1 insertion(+), 38 deletions(-)

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 23753f92e0a6..ce7e918430c8 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -1084,44 +1084,7 @@ EXPORT_SYMBOL_GPL(phylink_connect_phy);
 int phylink_of_phy_connect(struct phylink *pl, struct device_node *dn,
 			   u32 flags)
 {
-	struct device_node *phy_node;
-	struct phy_device *phy_dev;
-	int ret;
-
-	/* Fixed links and 802.3z are handled without needing a PHY */
-	if (pl->cfg_link_an_mode == MLO_AN_FIXED ||
-	    (pl->cfg_link_an_mode == MLO_AN_INBAND &&
-	     phy_interface_mode_is_8023z(pl->link_interface)))
-		return 0;
-
-	phy_node = of_parse_phandle(dn, "phy-handle", 0);
-	if (!phy_node)
-		phy_node = of_parse_phandle(dn, "phy", 0);
-	if (!phy_node)
-		phy_node = of_parse_phandle(dn, "phy-device", 0);
-
-	if (!phy_node) {
-		if (pl->cfg_link_an_mode == MLO_AN_PHY)
-			return -ENODEV;
-		return 0;
-	}
-
-	phy_dev = of_phy_find_device(phy_node);
-	/* We're done with the phy_node handle */
-	of_node_put(phy_node);
-	if (!phy_dev)
-		return -ENODEV;
-
-	ret = phy_attach_direct(pl->netdev, phy_dev, flags,
-				pl->link_interface);
-	if (ret)
-		return ret;
-
-	ret = phylink_bringup_phy(pl, phy_dev, pl->link_config.interface);
-	if (ret)
-		phy_detach(phy_dev);
-
-	return ret;
+	return phylink_fwnode_phy_connect(pl, of_fwnode_handle(dn), flags);
 }
 EXPORT_SYMBOL_GPL(phylink_of_phy_connect);
 
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [net-next PATCH v7 16/16] net: dpaa2-mac: Add ACPI support for DPAA2 MAC driver
  2021-03-11  6:19 ` Calvin Johnson
@ 2021-03-11  6:20   ` Calvin Johnson
  -1 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11  6:20 UTC (permalink / raw)
  To: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap
  Cc: linux-arm-kernel, Diana Madalina Craciun, linux-acpi,
	linux-kernel, linux.cj, netdev, Laurentiu Tudor, Calvin Johnson,
	David S. Miller, Ioana Radulescu, Jakub Kicinski

Modify dpaa2_mac_get_node() to get the dpmac fwnode from either
DT or ACPI.

Modify dpaa2_mac_get_if_mode() to get interface mode from dpmac_node
which is a fwnode.

Modify dpaa2_pcs_create() to create pcs from dpmac_node fwnode.

Modify dpaa2_mac_connect() to support ACPI along with DT.

Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---

Changes in v7:
- remove unnecassary checks

Changes in v6:
- use dev_fwnode()
- remove useless else
- replace of_device_is_available() to fwnode_device_is_available()

Changes in v5:
- replace fwnode_get_id() with OF and ACPI function calls

Changes in v4: None
Changes in v3: None
Changes in v2:
- Refactor OF functions to use fwnode functions

 .../net/ethernet/freescale/dpaa2/dpaa2-mac.c  | 84 +++++++++++--------
 1 file changed, 50 insertions(+), 34 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
index ccaf7e35abeb..0cb6760dce88 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
@@ -1,6 +1,9 @@
 // SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
 /* Copyright 2019 NXP */
 
+#include <linux/acpi.h>
+#include <linux/property.h>
+
 #include "dpaa2-eth.h"
 #include "dpaa2-mac.h"
 
@@ -34,39 +37,51 @@ static int phy_mode(enum dpmac_eth_if eth_if, phy_interface_t *if_mode)
 	return 0;
 }
 
-/* Caller must call of_node_put on the returned value */
-static struct device_node *dpaa2_mac_get_node(u16 dpmac_id)
+static struct fwnode_handle *dpaa2_mac_get_node(struct device *dev,
+						u16 dpmac_id)
 {
-	struct device_node *dpmacs, *dpmac = NULL;
-	u32 id;
+	struct fwnode_handle *fwnode, *parent, *child  = NULL;
+	struct device_node *dpmacs = NULL;
 	int err;
+	u32 id;
 
-	dpmacs = of_find_node_by_name(NULL, "dpmacs");
-	if (!dpmacs)
-		return NULL;
+	fwnode = dev_fwnode(dev->parent);
+	if (is_of_node(fwnode)) {
+		dpmacs = of_find_node_by_name(NULL, "dpmacs");
+		if (!dpmacs)
+			return NULL;
+		parent = of_fwnode_handle(dpmacs);
+	} else if (is_acpi_node(fwnode)) {
+		parent = fwnode;
+	}
 
-	while ((dpmac = of_get_next_child(dpmacs, dpmac)) != NULL) {
-		err = of_property_read_u32(dpmac, "reg", &id);
+	fwnode_for_each_child_node(parent, child) {
+		err = -EINVAL;
+		if (is_acpi_device_node(child))
+			err = acpi_get_local_address(ACPI_HANDLE_FWNODE(child), &id);
+		else if (is_of_node(child))
+			err = of_property_read_u32(to_of_node(child), "reg", &id);
 		if (err)
 			continue;
-		if (id == dpmac_id)
-			break;
-	}
 
+		if (id == dpmac_id) {
+			of_node_put(dpmacs);
+			return child;
+		}
+	}
 	of_node_put(dpmacs);
-
-	return dpmac;
+	return NULL;
 }
 
-static int dpaa2_mac_get_if_mode(struct device_node *node,
+static int dpaa2_mac_get_if_mode(struct fwnode_handle *dpmac_node,
 				 struct dpmac_attr attr)
 {
 	phy_interface_t if_mode;
 	int err;
 
-	err = of_get_phy_mode(node, &if_mode);
-	if (!err)
-		return if_mode;
+	err = fwnode_get_phy_mode(dpmac_node);
+	if (err > 0)
+		return err;
 
 	err = phy_mode(attr.eth_if, &if_mode);
 	if (!err)
@@ -235,26 +250,27 @@ static const struct phylink_mac_ops dpaa2_mac_phylink_ops = {
 };
 
 static int dpaa2_pcs_create(struct dpaa2_mac *mac,
-			    struct device_node *dpmac_node, int id)
+			    struct fwnode_handle *dpmac_node,
+			    int id)
 {
 	struct mdio_device *mdiodev;
-	struct device_node *node;
+	struct fwnode_handle *node;
 
-	node = of_parse_phandle(dpmac_node, "pcs-handle", 0);
-	if (!node) {
+	node = fwnode_find_reference(dpmac_node, "pcs-handle", 0);
+	if (IS_ERR(node)) {
 		/* do not error out on old DTS files */
 		netdev_warn(mac->net_dev, "pcs-handle node not found\n");
 		return 0;
 	}
 
-	if (!of_device_is_available(node)) {
+	if (!fwnode_device_is_available(node)) {
 		netdev_err(mac->net_dev, "pcs-handle node not available\n");
-		of_node_put(node);
+		fwnode_handle_put(node);
 		return -ENODEV;
 	}
 
-	mdiodev = of_mdio_find_device(node);
-	of_node_put(node);
+	mdiodev = fwnode_mdio_find_device(node);
+	fwnode_handle_put(node);
 	if (!mdiodev)
 		return -EPROBE_DEFER;
 
@@ -283,13 +299,13 @@ static void dpaa2_pcs_destroy(struct dpaa2_mac *mac)
 int dpaa2_mac_connect(struct dpaa2_mac *mac)
 {
 	struct net_device *net_dev = mac->net_dev;
-	struct device_node *dpmac_node;
+	struct fwnode_handle *dpmac_node = NULL;
 	struct phylink *phylink;
 	int err;
 
 	mac->if_link_type = mac->attr.link_type;
 
-	dpmac_node = dpaa2_mac_get_node(mac->attr.id);
+	dpmac_node = dpaa2_mac_get_node(&mac->mc_dev->dev, mac->attr.id);
 	if (!dpmac_node) {
 		netdev_err(net_dev, "No dpmac@%d node found.\n", mac->attr.id);
 		return -ENODEV;
@@ -306,7 +322,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac)
 	 * error out if the interface mode requests them and there is no PHY
 	 * to act upon them
 	 */
-	if (of_phy_is_fixed_link(dpmac_node) &&
+	if (of_phy_is_fixed_link(to_of_node(dpmac_node)) &&
 	    (mac->if_mode == PHY_INTERFACE_MODE_RGMII_ID ||
 	     mac->if_mode == PHY_INTERFACE_MODE_RGMII_RXID ||
 	     mac->if_mode == PHY_INTERFACE_MODE_RGMII_TXID)) {
@@ -327,7 +343,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac)
 	mac->phylink_config.type = PHYLINK_NETDEV;
 
 	phylink = phylink_create(&mac->phylink_config,
-				 of_fwnode_handle(dpmac_node), mac->if_mode,
+				 dpmac_node, mac->if_mode,
 				 &dpaa2_mac_phylink_ops);
 	if (IS_ERR(phylink)) {
 		err = PTR_ERR(phylink);
@@ -338,13 +354,13 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac)
 	if (mac->pcs)
 		phylink_set_pcs(mac->phylink, &mac->pcs->pcs);
 
-	err = phylink_of_phy_connect(mac->phylink, dpmac_node, 0);
+	err = phylink_fwnode_phy_connect(mac->phylink, dpmac_node, 0);
 	if (err) {
-		netdev_err(net_dev, "phylink_of_phy_connect() = %d\n", err);
+		netdev_err(net_dev, "phylink_fwnode_phy_connect() = %d\n", err);
 		goto err_phylink_destroy;
 	}
 
-	of_node_put(dpmac_node);
+	fwnode_handle_put(dpmac_node);
 
 	return 0;
 
@@ -353,7 +369,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac)
 err_pcs_destroy:
 	dpaa2_pcs_destroy(mac);
 err_put_node:
-	of_node_put(dpmac_node);
+	fwnode_handle_put(dpmac_node);
 
 	return err;
 }
-- 
2.17.1


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

* [net-next PATCH v7 16/16] net: dpaa2-mac: Add ACPI support for DPAA2 MAC driver
@ 2021-03-11  6:20   ` Calvin Johnson
  0 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11  6:20 UTC (permalink / raw)
  To: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap
  Cc: linux-arm-kernel, Diana Madalina Craciun, linux-acpi,
	linux-kernel, linux.cj, netdev, Laurentiu Tudor, Calvin Johnson,
	David S. Miller, Ioana Radulescu, Jakub Kicinski

Modify dpaa2_mac_get_node() to get the dpmac fwnode from either
DT or ACPI.

Modify dpaa2_mac_get_if_mode() to get interface mode from dpmac_node
which is a fwnode.

Modify dpaa2_pcs_create() to create pcs from dpmac_node fwnode.

Modify dpaa2_mac_connect() to support ACPI along with DT.

Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---

Changes in v7:
- remove unnecassary checks

Changes in v6:
- use dev_fwnode()
- remove useless else
- replace of_device_is_available() to fwnode_device_is_available()

Changes in v5:
- replace fwnode_get_id() with OF and ACPI function calls

Changes in v4: None
Changes in v3: None
Changes in v2:
- Refactor OF functions to use fwnode functions

 .../net/ethernet/freescale/dpaa2/dpaa2-mac.c  | 84 +++++++++++--------
 1 file changed, 50 insertions(+), 34 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
index ccaf7e35abeb..0cb6760dce88 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
@@ -1,6 +1,9 @@
 // SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
 /* Copyright 2019 NXP */
 
+#include <linux/acpi.h>
+#include <linux/property.h>
+
 #include "dpaa2-eth.h"
 #include "dpaa2-mac.h"
 
@@ -34,39 +37,51 @@ static int phy_mode(enum dpmac_eth_if eth_if, phy_interface_t *if_mode)
 	return 0;
 }
 
-/* Caller must call of_node_put on the returned value */
-static struct device_node *dpaa2_mac_get_node(u16 dpmac_id)
+static struct fwnode_handle *dpaa2_mac_get_node(struct device *dev,
+						u16 dpmac_id)
 {
-	struct device_node *dpmacs, *dpmac = NULL;
-	u32 id;
+	struct fwnode_handle *fwnode, *parent, *child  = NULL;
+	struct device_node *dpmacs = NULL;
 	int err;
+	u32 id;
 
-	dpmacs = of_find_node_by_name(NULL, "dpmacs");
-	if (!dpmacs)
-		return NULL;
+	fwnode = dev_fwnode(dev->parent);
+	if (is_of_node(fwnode)) {
+		dpmacs = of_find_node_by_name(NULL, "dpmacs");
+		if (!dpmacs)
+			return NULL;
+		parent = of_fwnode_handle(dpmacs);
+	} else if (is_acpi_node(fwnode)) {
+		parent = fwnode;
+	}
 
-	while ((dpmac = of_get_next_child(dpmacs, dpmac)) != NULL) {
-		err = of_property_read_u32(dpmac, "reg", &id);
+	fwnode_for_each_child_node(parent, child) {
+		err = -EINVAL;
+		if (is_acpi_device_node(child))
+			err = acpi_get_local_address(ACPI_HANDLE_FWNODE(child), &id);
+		else if (is_of_node(child))
+			err = of_property_read_u32(to_of_node(child), "reg", &id);
 		if (err)
 			continue;
-		if (id == dpmac_id)
-			break;
-	}
 
+		if (id == dpmac_id) {
+			of_node_put(dpmacs);
+			return child;
+		}
+	}
 	of_node_put(dpmacs);
-
-	return dpmac;
+	return NULL;
 }
 
-static int dpaa2_mac_get_if_mode(struct device_node *node,
+static int dpaa2_mac_get_if_mode(struct fwnode_handle *dpmac_node,
 				 struct dpmac_attr attr)
 {
 	phy_interface_t if_mode;
 	int err;
 
-	err = of_get_phy_mode(node, &if_mode);
-	if (!err)
-		return if_mode;
+	err = fwnode_get_phy_mode(dpmac_node);
+	if (err > 0)
+		return err;
 
 	err = phy_mode(attr.eth_if, &if_mode);
 	if (!err)
@@ -235,26 +250,27 @@ static const struct phylink_mac_ops dpaa2_mac_phylink_ops = {
 };
 
 static int dpaa2_pcs_create(struct dpaa2_mac *mac,
-			    struct device_node *dpmac_node, int id)
+			    struct fwnode_handle *dpmac_node,
+			    int id)
 {
 	struct mdio_device *mdiodev;
-	struct device_node *node;
+	struct fwnode_handle *node;
 
-	node = of_parse_phandle(dpmac_node, "pcs-handle", 0);
-	if (!node) {
+	node = fwnode_find_reference(dpmac_node, "pcs-handle", 0);
+	if (IS_ERR(node)) {
 		/* do not error out on old DTS files */
 		netdev_warn(mac->net_dev, "pcs-handle node not found\n");
 		return 0;
 	}
 
-	if (!of_device_is_available(node)) {
+	if (!fwnode_device_is_available(node)) {
 		netdev_err(mac->net_dev, "pcs-handle node not available\n");
-		of_node_put(node);
+		fwnode_handle_put(node);
 		return -ENODEV;
 	}
 
-	mdiodev = of_mdio_find_device(node);
-	of_node_put(node);
+	mdiodev = fwnode_mdio_find_device(node);
+	fwnode_handle_put(node);
 	if (!mdiodev)
 		return -EPROBE_DEFER;
 
@@ -283,13 +299,13 @@ static void dpaa2_pcs_destroy(struct dpaa2_mac *mac)
 int dpaa2_mac_connect(struct dpaa2_mac *mac)
 {
 	struct net_device *net_dev = mac->net_dev;
-	struct device_node *dpmac_node;
+	struct fwnode_handle *dpmac_node = NULL;
 	struct phylink *phylink;
 	int err;
 
 	mac->if_link_type = mac->attr.link_type;
 
-	dpmac_node = dpaa2_mac_get_node(mac->attr.id);
+	dpmac_node = dpaa2_mac_get_node(&mac->mc_dev->dev, mac->attr.id);
 	if (!dpmac_node) {
 		netdev_err(net_dev, "No dpmac@%d node found.\n", mac->attr.id);
 		return -ENODEV;
@@ -306,7 +322,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac)
 	 * error out if the interface mode requests them and there is no PHY
 	 * to act upon them
 	 */
-	if (of_phy_is_fixed_link(dpmac_node) &&
+	if (of_phy_is_fixed_link(to_of_node(dpmac_node)) &&
 	    (mac->if_mode == PHY_INTERFACE_MODE_RGMII_ID ||
 	     mac->if_mode == PHY_INTERFACE_MODE_RGMII_RXID ||
 	     mac->if_mode == PHY_INTERFACE_MODE_RGMII_TXID)) {
@@ -327,7 +343,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac)
 	mac->phylink_config.type = PHYLINK_NETDEV;
 
 	phylink = phylink_create(&mac->phylink_config,
-				 of_fwnode_handle(dpmac_node), mac->if_mode,
+				 dpmac_node, mac->if_mode,
 				 &dpaa2_mac_phylink_ops);
 	if (IS_ERR(phylink)) {
 		err = PTR_ERR(phylink);
@@ -338,13 +354,13 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac)
 	if (mac->pcs)
 		phylink_set_pcs(mac->phylink, &mac->pcs->pcs);
 
-	err = phylink_of_phy_connect(mac->phylink, dpmac_node, 0);
+	err = phylink_fwnode_phy_connect(mac->phylink, dpmac_node, 0);
 	if (err) {
-		netdev_err(net_dev, "phylink_of_phy_connect() = %d\n", err);
+		netdev_err(net_dev, "phylink_fwnode_phy_connect() = %d\n", err);
 		goto err_phylink_destroy;
 	}
 
-	of_node_put(dpmac_node);
+	fwnode_handle_put(dpmac_node);
 
 	return 0;
 
@@ -353,7 +369,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac)
 err_pcs_destroy:
 	dpaa2_pcs_destroy(mac);
 err_put_node:
-	of_node_put(dpmac_node);
+	fwnode_handle_put(dpmac_node);
 
 	return err;
 }
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [net-next PATCH v7 02/16] net: phy: Introduce fwnode_mdio_find_device()
  2021-03-11  6:19   ` Calvin Johnson
@ 2021-03-11  6:50     ` Saravana Kannan
  -1 siblings, 0 replies; 64+ messages in thread
From: Saravana Kannan @ 2021-03-11  6:50 UTC (permalink / raw)
  To: Calvin Johnson
  Cc: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Randy Dunlap, linux-arm-kernel, Diana Madalina Craciun,
	ACPI Devel Maling List, LKML, linux.cj, netdev, Laurentiu Tudor,
	David S. Miller, Heiner Kallweit, Jakub Kicinski

On Wed, Mar 10, 2021 at 10:21 PM Calvin Johnson
<calvin.johnson@oss.nxp.com> wrote:
>
> Define fwnode_mdio_find_device() to get a pointer to the
> mdio_device from fwnode passed to the function.
>
> Refactor of_mdio_find_device() to use fwnode_mdio_find_device().
>
> Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
> ---
>
> Changes in v7:
> - correct fwnode_mdio_find_device() description
>
> Changes in v6:
> - fix warning for function parameter of fwnode_mdio_find_device()
>
> Changes in v5: None
> Changes in v4: None
> Changes in v3: None
> Changes in v2: None
>
>  drivers/net/mdio/of_mdio.c   | 11 +----------
>  drivers/net/phy/phy_device.c | 23 +++++++++++++++++++++++
>  include/linux/phy.h          |  6 ++++++
>  3 files changed, 30 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c
> index ea9d5855fb52..d5e0970b2561 100644
> --- a/drivers/net/mdio/of_mdio.c
> +++ b/drivers/net/mdio/of_mdio.c
> @@ -347,16 +347,7 @@ EXPORT_SYMBOL(of_mdiobus_register);
>   */
>  struct mdio_device *of_mdio_find_device(struct device_node *np)
>  {
> -       struct device *d;
> -
> -       if (!np)
> -               return NULL;
> -
> -       d = bus_find_device_by_of_node(&mdio_bus_type, np);
> -       if (!d)
> -               return NULL;
> -
> -       return to_mdio_device(d);
> +       return fwnode_mdio_find_device(of_fwnode_handle(np));
>  }
>  EXPORT_SYMBOL(of_mdio_find_device);
>
> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> index cc38e326405a..daabb17bba00 100644
> --- a/drivers/net/phy/phy_device.c
> +++ b/drivers/net/phy/phy_device.c
> @@ -2819,6 +2819,29 @@ static bool phy_drv_supports_irq(struct phy_driver *phydrv)
>         return phydrv->config_intr && phydrv->handle_interrupt;
>  }
>
> +/**
> + * fwnode_mdio_find_device - Given a fwnode, find the mdio_device
> + * @fwnode: pointer to the mdio_device's fwnode
> + *
> + * If successful, returns a pointer to the mdio_device with the embedded
> + * struct device refcount incremented by one, or NULL on failure.
> + * The caller should call put_device() on the mdio_device after its use.
> + */
> +struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode)
> +{
> +       struct device *d;
> +
> +       if (!fwnode)
> +               return NULL;
> +
> +       d = bus_find_device_by_fwnode(&mdio_bus_type, fwnode);

Sorry about the late review, but can you look into using
get_dev_from_fwnode()? As long as you aren't registering two devices
for the same fwnode, it's an O(1) operation instead of having to loop
through a list of devices in a bus. You can check the returned
device's bus type if you aren't sure about not registering two devices
with the same fw_node and then fall back to this looping.

-Saravana

> +       if (!d)
> +               return NULL;
> +
> +       return to_mdio_device(d);
> +}
> +EXPORT_SYMBOL(fwnode_mdio_find_device);
> +
>  /**
>   * phy_probe - probe and init a PHY device
>   * @dev: device to probe and init
> diff --git a/include/linux/phy.h b/include/linux/phy.h
> index 1a12e4436b5b..f5eb1e3981a1 100644
> --- a/include/linux/phy.h
> +++ b/include/linux/phy.h
> @@ -1366,11 +1366,17 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id,
>                                      bool is_c45,
>                                      struct phy_c45_device_ids *c45_ids);
>  #if IS_ENABLED(CONFIG_PHYLIB)
> +struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode);
>  struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45);
>  int phy_device_register(struct phy_device *phy);
>  void phy_device_free(struct phy_device *phydev);
>  #else
>  static inline
> +struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode)
> +{
> +       return 0;
> +}
> +static inline
>  struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45)
>  {
>         return NULL;
> --
> 2.17.1
>

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

* Re: [net-next PATCH v7 02/16] net: phy: Introduce fwnode_mdio_find_device()
@ 2021-03-11  6:50     ` Saravana Kannan
  0 siblings, 0 replies; 64+ messages in thread
From: Saravana Kannan @ 2021-03-11  6:50 UTC (permalink / raw)
  To: Calvin Johnson
  Cc: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Randy Dunlap, linux-arm-kernel, Diana Madalina Craciun,
	ACPI Devel Maling List, LKML, linux.cj, netdev, Laurentiu Tudor,
	David S. Miller, Heiner Kallweit, Jakub Kicinski

On Wed, Mar 10, 2021 at 10:21 PM Calvin Johnson
<calvin.johnson@oss.nxp.com> wrote:
>
> Define fwnode_mdio_find_device() to get a pointer to the
> mdio_device from fwnode passed to the function.
>
> Refactor of_mdio_find_device() to use fwnode_mdio_find_device().
>
> Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
> ---
>
> Changes in v7:
> - correct fwnode_mdio_find_device() description
>
> Changes in v6:
> - fix warning for function parameter of fwnode_mdio_find_device()
>
> Changes in v5: None
> Changes in v4: None
> Changes in v3: None
> Changes in v2: None
>
>  drivers/net/mdio/of_mdio.c   | 11 +----------
>  drivers/net/phy/phy_device.c | 23 +++++++++++++++++++++++
>  include/linux/phy.h          |  6 ++++++
>  3 files changed, 30 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c
> index ea9d5855fb52..d5e0970b2561 100644
> --- a/drivers/net/mdio/of_mdio.c
> +++ b/drivers/net/mdio/of_mdio.c
> @@ -347,16 +347,7 @@ EXPORT_SYMBOL(of_mdiobus_register);
>   */
>  struct mdio_device *of_mdio_find_device(struct device_node *np)
>  {
> -       struct device *d;
> -
> -       if (!np)
> -               return NULL;
> -
> -       d = bus_find_device_by_of_node(&mdio_bus_type, np);
> -       if (!d)
> -               return NULL;
> -
> -       return to_mdio_device(d);
> +       return fwnode_mdio_find_device(of_fwnode_handle(np));
>  }
>  EXPORT_SYMBOL(of_mdio_find_device);
>
> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> index cc38e326405a..daabb17bba00 100644
> --- a/drivers/net/phy/phy_device.c
> +++ b/drivers/net/phy/phy_device.c
> @@ -2819,6 +2819,29 @@ static bool phy_drv_supports_irq(struct phy_driver *phydrv)
>         return phydrv->config_intr && phydrv->handle_interrupt;
>  }
>
> +/**
> + * fwnode_mdio_find_device - Given a fwnode, find the mdio_device
> + * @fwnode: pointer to the mdio_device's fwnode
> + *
> + * If successful, returns a pointer to the mdio_device with the embedded
> + * struct device refcount incremented by one, or NULL on failure.
> + * The caller should call put_device() on the mdio_device after its use.
> + */
> +struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode)
> +{
> +       struct device *d;
> +
> +       if (!fwnode)
> +               return NULL;
> +
> +       d = bus_find_device_by_fwnode(&mdio_bus_type, fwnode);

Sorry about the late review, but can you look into using
get_dev_from_fwnode()? As long as you aren't registering two devices
for the same fwnode, it's an O(1) operation instead of having to loop
through a list of devices in a bus. You can check the returned
device's bus type if you aren't sure about not registering two devices
with the same fw_node and then fall back to this looping.

-Saravana

> +       if (!d)
> +               return NULL;
> +
> +       return to_mdio_device(d);
> +}
> +EXPORT_SYMBOL(fwnode_mdio_find_device);
> +
>  /**
>   * phy_probe - probe and init a PHY device
>   * @dev: device to probe and init
> diff --git a/include/linux/phy.h b/include/linux/phy.h
> index 1a12e4436b5b..f5eb1e3981a1 100644
> --- a/include/linux/phy.h
> +++ b/include/linux/phy.h
> @@ -1366,11 +1366,17 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id,
>                                      bool is_c45,
>                                      struct phy_c45_device_ids *c45_ids);
>  #if IS_ENABLED(CONFIG_PHYLIB)
> +struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode);
>  struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45);
>  int phy_device_register(struct phy_device *phy);
>  void phy_device_free(struct phy_device *phydev);
>  #else
>  static inline
> +struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode)
> +{
> +       return 0;
> +}
> +static inline
>  struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45)
>  {
>         return NULL;
> --
> 2.17.1
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [net-next PATCH v7 07/16] net: mii_timestamper: check NULL in unregister_mii_timestamper()
  2021-03-11  6:20   ` Calvin Johnson
@ 2021-03-11 12:04     ` Andy Shevchenko
  -1 siblings, 0 replies; 64+ messages in thread
From: Andy Shevchenko @ 2021-03-11 12:04 UTC (permalink / raw)
  To: Calvin Johnson
  Cc: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Florian Fainelli, Russell King - ARM Linux admin,
	Cristi Sovaiala, Florin Laurentiu Chiculita, Ioana Ciornei,
	Madalin Bucur, Heikki Krogerus, Marcin Wojtas,
	Pieter Jansen Van Vuuren, Jon, Saravana Kannan, Randy Dunlap,
	linux-arm Mailing List, Diana Madalina Craciun,
	ACPI Devel Maling List, Linux Kernel Mailing List, linux.cj,
	netdev, Laurentiu Tudor, David S. Miller, Heiner Kallweit,
	Jakub Kicinski

On Thu, Mar 11, 2021 at 8:21 AM Calvin Johnson
<calvin.johnson@oss.nxp.com> wrote:
>
> Callers of unregister_mii_timestamper() currently check for NULL
> value of mii_ts before calling it.
>
> Place the NULL check inside unregister_mii_timestamper() and update
> the callers accordingly

FWIW,
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

(Don't remember if it has been suggested by somebody, in that case
perhaps Suggested-by?)

> Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
> ---
>
> Changes in v7:
> - check NULL in unregister_mii_timestamper()
>
> Changes in v6: None
> Changes in v5: None
> Changes in v4: None
> Changes in v3: None
> Changes in v2: None
>
>  drivers/net/mdio/of_mdio.c        | 6 ++----
>  drivers/net/phy/mii_timestamper.c | 3 +++
>  drivers/net/phy/phy_device.c      | 3 +--
>  3 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c
> index 612a37970f14..48b6b8458c17 100644
> --- a/drivers/net/mdio/of_mdio.c
> +++ b/drivers/net/mdio/of_mdio.c
> @@ -115,15 +115,13 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio,
>         else
>                 phy = get_phy_device(mdio, addr, is_c45);
>         if (IS_ERR(phy)) {
> -               if (mii_ts)
> -                       unregister_mii_timestamper(mii_ts);
> +               unregister_mii_timestamper(mii_ts);
>                 return PTR_ERR(phy);
>         }
>
>         rc = of_mdiobus_phy_device_register(mdio, phy, child, addr);
>         if (rc) {
> -               if (mii_ts)
> -                       unregister_mii_timestamper(mii_ts);
> +               unregister_mii_timestamper(mii_ts);
>                 phy_device_free(phy);
>                 return rc;
>         }
> diff --git a/drivers/net/phy/mii_timestamper.c b/drivers/net/phy/mii_timestamper.c
> index b71b7456462d..51ae0593a04f 100644
> --- a/drivers/net/phy/mii_timestamper.c
> +++ b/drivers/net/phy/mii_timestamper.c
> @@ -111,6 +111,9 @@ void unregister_mii_timestamper(struct mii_timestamper *mii_ts)
>         struct mii_timestamping_desc *desc;
>         struct list_head *this;
>
> +       if (!mii_ts)
> +               return;
> +
>         /* mii_timestamper statically registered by the PHY driver won't use the
>          * register_mii_timestamper() and thus don't have ->device set. Don't
>          * try to unregister these.
> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> index f875efe7b4d1..9c5127405d91 100644
> --- a/drivers/net/phy/phy_device.c
> +++ b/drivers/net/phy/phy_device.c
> @@ -928,8 +928,7 @@ EXPORT_SYMBOL(phy_device_register);
>   */
>  void phy_device_remove(struct phy_device *phydev)
>  {
> -       if (phydev->mii_ts)
> -               unregister_mii_timestamper(phydev->mii_ts);
> +       unregister_mii_timestamper(phydev->mii_ts);
>
>         device_del(&phydev->mdio.dev);
>
> --
> 2.17.1
>


-- 
With Best Regards,
Andy Shevchenko

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

* Re: [net-next PATCH v7 07/16] net: mii_timestamper: check NULL in unregister_mii_timestamper()
@ 2021-03-11 12:04     ` Andy Shevchenko
  0 siblings, 0 replies; 64+ messages in thread
From: Andy Shevchenko @ 2021-03-11 12:04 UTC (permalink / raw)
  To: Calvin Johnson
  Cc: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Florian Fainelli, Russell King - ARM Linux admin,
	Cristi Sovaiala, Florin Laurentiu Chiculita, Ioana Ciornei,
	Madalin Bucur, Heikki Krogerus, Marcin Wojtas,
	Pieter Jansen Van Vuuren, Jon, Saravana Kannan, Randy Dunlap,
	linux-arm Mailing List, Diana Madalina Craciun,
	ACPI Devel Maling List, Linux Kernel Mailing List, linux.cj,
	netdev, Laurentiu Tudor, David S. Miller, Heiner Kallweit,
	Jakub Kicinski

On Thu, Mar 11, 2021 at 8:21 AM Calvin Johnson
<calvin.johnson@oss.nxp.com> wrote:
>
> Callers of unregister_mii_timestamper() currently check for NULL
> value of mii_ts before calling it.
>
> Place the NULL check inside unregister_mii_timestamper() and update
> the callers accordingly

FWIW,
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

(Don't remember if it has been suggested by somebody, in that case
perhaps Suggested-by?)

> Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
> ---
>
> Changes in v7:
> - check NULL in unregister_mii_timestamper()
>
> Changes in v6: None
> Changes in v5: None
> Changes in v4: None
> Changes in v3: None
> Changes in v2: None
>
>  drivers/net/mdio/of_mdio.c        | 6 ++----
>  drivers/net/phy/mii_timestamper.c | 3 +++
>  drivers/net/phy/phy_device.c      | 3 +--
>  3 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c
> index 612a37970f14..48b6b8458c17 100644
> --- a/drivers/net/mdio/of_mdio.c
> +++ b/drivers/net/mdio/of_mdio.c
> @@ -115,15 +115,13 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio,
>         else
>                 phy = get_phy_device(mdio, addr, is_c45);
>         if (IS_ERR(phy)) {
> -               if (mii_ts)
> -                       unregister_mii_timestamper(mii_ts);
> +               unregister_mii_timestamper(mii_ts);
>                 return PTR_ERR(phy);
>         }
>
>         rc = of_mdiobus_phy_device_register(mdio, phy, child, addr);
>         if (rc) {
> -               if (mii_ts)
> -                       unregister_mii_timestamper(mii_ts);
> +               unregister_mii_timestamper(mii_ts);
>                 phy_device_free(phy);
>                 return rc;
>         }
> diff --git a/drivers/net/phy/mii_timestamper.c b/drivers/net/phy/mii_timestamper.c
> index b71b7456462d..51ae0593a04f 100644
> --- a/drivers/net/phy/mii_timestamper.c
> +++ b/drivers/net/phy/mii_timestamper.c
> @@ -111,6 +111,9 @@ void unregister_mii_timestamper(struct mii_timestamper *mii_ts)
>         struct mii_timestamping_desc *desc;
>         struct list_head *this;
>
> +       if (!mii_ts)
> +               return;
> +
>         /* mii_timestamper statically registered by the PHY driver won't use the
>          * register_mii_timestamper() and thus don't have ->device set. Don't
>          * try to unregister these.
> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> index f875efe7b4d1..9c5127405d91 100644
> --- a/drivers/net/phy/phy_device.c
> +++ b/drivers/net/phy/phy_device.c
> @@ -928,8 +928,7 @@ EXPORT_SYMBOL(phy_device_register);
>   */
>  void phy_device_remove(struct phy_device *phydev)
>  {
> -       if (phydev->mii_ts)
> -               unregister_mii_timestamper(phydev->mii_ts);
> +       unregister_mii_timestamper(phydev->mii_ts);
>
>         device_del(&phydev->mdio.dev);
>
> --
> 2.17.1
>


-- 
With Best Regards,
Andy Shevchenko

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [net-next PATCH v7 08/16] net: mdiobus: Introduce fwnode_mdiobus_register_phy()
  2021-03-11  6:20   ` Calvin Johnson
@ 2021-03-11 12:09     ` Andy Shevchenko
  -1 siblings, 0 replies; 64+ messages in thread
From: Andy Shevchenko @ 2021-03-11 12:09 UTC (permalink / raw)
  To: Calvin Johnson
  Cc: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Florian Fainelli, Russell King - ARM Linux admin,
	Cristi Sovaiala, Florin Laurentiu Chiculita, Ioana Ciornei,
	Madalin Bucur, Heikki Krogerus, Marcin Wojtas,
	Pieter Jansen Van Vuuren, Jon, Saravana Kannan, Randy Dunlap,
	linux-arm Mailing List, Diana Madalina Craciun,
	ACPI Devel Maling List, Linux Kernel Mailing List, linux.cj,
	netdev, Laurentiu Tudor, David S. Miller, Frank Rowand,
	Heiner Kallweit, Jakub Kicinski, Rob Herring, devicetree

On Thu, Mar 11, 2021 at 8:21 AM Calvin Johnson
<calvin.johnson@oss.nxp.com> wrote:
>
> Introduce fwnode_mdiobus_register_phy() to register PHYs on the
> mdiobus. From the compatible string, identify whether the PHY is
> c45 and based on this create a PHY device instance which is
> registered on the mdiobus.

> uninitialized symbol 'mii_ts'
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

I don't think it's important to have it in a history of Git. I would
move this after the cutter '---' line below.

> Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
> ---
>
> Changes in v7:
> - Call unregister_mii_timestamper() without NULL check
> - Create fwnode_mdio.c and move fwnode_mdiobus_register_phy()
>
> Changes in v6:
> - Initialize mii_ts to NULL
>
> Changes in v5: None
> Changes in v4: None
> Changes in v3: None
> Changes in v2: None
>
>  MAINTAINERS                    |  1 +
>  drivers/net/mdio/Kconfig       |  9 ++++
>  drivers/net/mdio/Makefile      |  3 +-
>  drivers/net/mdio/fwnode_mdio.c | 77 ++++++++++++++++++++++++++++++++++
>  drivers/net/mdio/of_mdio.c     |  3 +-
>  include/linux/fwnode_mdio.h    | 24 +++++++++++
>  include/linux/of_mdio.h        |  6 ++-
>  7 files changed, 120 insertions(+), 3 deletions(-)
>  create mode 100644 drivers/net/mdio/fwnode_mdio.c
>  create mode 100644 include/linux/fwnode_mdio.h
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index e1fa5ad9bb30..146de41d2656 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -6680,6 +6680,7 @@ F:        Documentation/devicetree/bindings/net/mdio*
>  F:     Documentation/devicetree/bindings/net/qca,ar803x.yaml
>  F:     Documentation/networking/phy.rst
>  F:     drivers/net/mdio/
> +F:     drivers/net/mdio/fwnode_mdio.c
>  F:     drivers/net/mdio/of_mdio.c
>  F:     drivers/net/pcs/
>  F:     drivers/net/phy/
> diff --git a/drivers/net/mdio/Kconfig b/drivers/net/mdio/Kconfig
> index a10cc460d7cf..2d5bf5ccffb5 100644
> --- a/drivers/net/mdio/Kconfig
> +++ b/drivers/net/mdio/Kconfig
> @@ -19,6 +19,15 @@ config MDIO_BUS
>           reflects whether the mdio_bus/mdio_device code is built as a
>           loadable module or built-in.
>
> +config FWNODE_MDIO
> +       def_tristate PHYLIB

(Seems "selectable only" item)

> +       depends on ACPI
> +       depends on OF

Wouldn't be better to have
  depends on (ACPI || OF) || COMPILE_TEST

And honestly I don't understand it in either (AND or OR) variant. Why
do you need a dependency like this for fwnode API?

Moreover dependencies don't work for "selectable only" items.

> +       depends on PHYLIB
> +       select FIXED_PHY
> +       help
> +         FWNODE MDIO bus (Ethernet PHY) accessors
> +
>  config OF_MDIO
>         def_tristate PHYLIB
>         depends on OF
> diff --git a/drivers/net/mdio/Makefile b/drivers/net/mdio/Makefile
> index 5c498dde463f..ea5390e2ef84 100644
> --- a/drivers/net/mdio/Makefile
> +++ b/drivers/net/mdio/Makefile
> @@ -1,7 +1,8 @@
>  # SPDX-License-Identifier: GPL-2.0
>  # Makefile for Linux MDIO bus drivers
>
> -obj-$(CONFIG_OF_MDIO)  += of_mdio.o
> +obj-$(CONFIG_FWNODE_MDIO)      += fwnode_mdio.o
> +obj-$(CONFIG_OF_MDIO)          += of_mdio.o
>
>  obj-$(CONFIG_MDIO_ASPEED)              += mdio-aspeed.o
>  obj-$(CONFIG_MDIO_BCM_IPROC)           += mdio-bcm-iproc.o
> diff --git a/drivers/net/mdio/fwnode_mdio.c b/drivers/net/mdio/fwnode_mdio.c
> new file mode 100644
> index 000000000000..0982e816a6fb
> --- /dev/null
> +++ b/drivers/net/mdio/fwnode_mdio.c
> @@ -0,0 +1,77 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * fwnode helpers for the MDIO (Ethernet PHY) API
> + *
> + * This file provides helper functions for extracting PHY device information
> + * out of the fwnode and using it to populate an mii_bus.
> + */
> +
> +#include <linux/acpi.h>
> +#include <linux/of.h>
> +#include <linux/of_mdio.h>
> +#include <linux/phy.h>
> +
> +MODULE_AUTHOR("Calvin Johnson <calvin.johnson@oss.nxp.com>");
> +MODULE_LICENSE("GPL");
> +
> +int fwnode_mdiobus_register_phy(struct mii_bus *bus,
> +                               struct fwnode_handle *child, u32 addr)
> +{
> +       struct mii_timestamper *mii_ts = NULL;
> +       struct phy_device *phy;
> +       bool is_c45 = false;
> +       u32 phy_id;
> +       int rc;
> +
> +       if (is_of_node(child)) {
> +               mii_ts = of_find_mii_timestamper(to_of_node(child));
> +               if (IS_ERR(mii_ts))
> +                       return PTR_ERR(mii_ts);
> +       }
> +
> +       rc = fwnode_property_match_string(child, "compatible", "ethernet-phy-ieee802.3-c45");
> +       if (rc >= 0)
> +               is_c45 = true;
> +
> +       if (is_c45 || fwnode_get_phy_id(child, &phy_id))
> +               phy = get_phy_device(bus, addr, is_c45);
> +       else
> +               phy = phy_device_create(bus, addr, phy_id, 0, NULL);
> +       if (IS_ERR(phy)) {
> +               unregister_mii_timestamper(mii_ts);
> +               return PTR_ERR(phy);
> +       }
> +
> +       if (is_acpi_node(child)) {
> +               phy->irq = bus->irq[addr];
> +
> +               /* Associate the fwnode with the device structure so it
> +                * can be looked up later.
> +                */
> +               phy->mdio.dev.fwnode = child;
> +
> +               /* All data is now stored in the phy struct, so register it */
> +               rc = phy_device_register(phy);
> +               if (rc) {
> +                       phy_device_free(phy);
> +                       fwnode_handle_put(phy->mdio.dev.fwnode);
> +                       return rc;
> +               }
> +       } else if (is_of_node(child)) {
> +               rc = of_mdiobus_phy_device_register(bus, phy, to_of_node(child), addr);
> +               if (rc) {
> +                       unregister_mii_timestamper(mii_ts);
> +                       phy_device_free(phy);
> +                       return rc;
> +               }
> +       }
> +
> +       /* phy->mii_ts may already be defined by the PHY driver. A
> +        * mii_timestamper probed via the device tree will still have
> +        * precedence.
> +        */
> +       if (mii_ts)
> +               phy->mii_ts = mii_ts;
> +       return 0;
> +}
> +EXPORT_SYMBOL(fwnode_mdiobus_register_phy);
> diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c
> index 48b6b8458c17..db293e0b8249 100644
> --- a/drivers/net/mdio/of_mdio.c
> +++ b/drivers/net/mdio/of_mdio.c
> @@ -32,7 +32,7 @@ static int of_get_phy_id(struct device_node *device, u32 *phy_id)
>         return fwnode_get_phy_id(of_fwnode_handle(device), phy_id);
>  }
>
> -static struct mii_timestamper *of_find_mii_timestamper(struct device_node *node)
> +struct mii_timestamper *of_find_mii_timestamper(struct device_node *node)
>  {
>         struct of_phandle_args arg;
>         int err;
> @@ -49,6 +49,7 @@ static struct mii_timestamper *of_find_mii_timestamper(struct device_node *node)
>
>         return register_mii_timestamper(arg.np, arg.args[0]);
>  }
> +EXPORT_SYMBOL(of_find_mii_timestamper);
>
>  int of_mdiobus_phy_device_register(struct mii_bus *mdio, struct phy_device *phy,
>                               struct device_node *child, u32 addr)
> diff --git a/include/linux/fwnode_mdio.h b/include/linux/fwnode_mdio.h
> new file mode 100644
> index 000000000000..8c0392845916
> --- /dev/null
> +++ b/include/linux/fwnode_mdio.h
> @@ -0,0 +1,24 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/*
> + * FWNODE helper for the MDIO (Ethernet PHY) API
> + */
> +
> +#ifndef __LINUX_FWNODE_MDIO_H
> +#define __LINUX_FWNODE_MDIO_H
> +
> +#include <linux/phy.h>
> +
> +#if IS_ENABLED(CONFIG_FWNODE_MDIO)
> +int fwnode_mdiobus_register_phy(struct mii_bus *bus,
> +                               struct fwnode_handle *child, u32 addr);
> +
> +#else /* CONFIG_FWNODE_MDIO */
> +static inline int fwnode_mdiobus_register_phy(struct mii_bus *bus,
> +                                             struct fwnode_handle *child,
> +                                             u32 addr)
> +{
> +       return -EINVAL;
> +}
> +#endif
> +
> +#endif /* __LINUX_FWNODE_MDIO_H */
> diff --git a/include/linux/of_mdio.h b/include/linux/of_mdio.h
> index 2b05e7f7c238..e4ee6c4d9431 100644
> --- a/include/linux/of_mdio.h
> +++ b/include/linux/of_mdio.h
> @@ -31,6 +31,7 @@ struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np);
>  int of_phy_register_fixed_link(struct device_node *np);
>  void of_phy_deregister_fixed_link(struct device_node *np);
>  bool of_phy_is_fixed_link(struct device_node *np);
> +struct mii_timestamper *of_find_mii_timestamper(struct device_node *np);
>  int of_mdiobus_phy_device_register(struct mii_bus *mdio, struct phy_device *phy,
>                                    struct device_node *child, u32 addr);
>
> @@ -118,7 +119,10 @@ static inline bool of_phy_is_fixed_link(struct device_node *np)
>  {
>         return false;
>  }
> -
> +static inline struct mii_timestamper *of_find_mii_timestamper(struct device_node *np)
> +{
> +       return NULL;
> +}
>  static inline int of_mdiobus_phy_device_register(struct mii_bus *mdio,
>                                             struct phy_device *phy,
>                                             struct device_node *child, u32 addr)
> --
> 2.17.1
>


-- 
With Best Regards,
Andy Shevchenko

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

* Re: [net-next PATCH v7 08/16] net: mdiobus: Introduce fwnode_mdiobus_register_phy()
@ 2021-03-11 12:09     ` Andy Shevchenko
  0 siblings, 0 replies; 64+ messages in thread
From: Andy Shevchenko @ 2021-03-11 12:09 UTC (permalink / raw)
  To: Calvin Johnson
  Cc: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Florian Fainelli, Russell King - ARM Linux admin,
	Cristi Sovaiala, Florin Laurentiu Chiculita, Ioana Ciornei,
	Madalin Bucur, Heikki Krogerus, Marcin Wojtas,
	Pieter Jansen Van Vuuren, Jon, Saravana Kannan, Randy Dunlap,
	linux-arm Mailing List, Diana Madalina Craciun,
	ACPI Devel Maling List, Linux Kernel Mailing List, linux.cj,
	netdev, Laurentiu Tudor, David S. Miller, Frank Rowand,
	Heiner Kallweit, Jakub Kicinski, Rob Herring, devicetree

On Thu, Mar 11, 2021 at 8:21 AM Calvin Johnson
<calvin.johnson@oss.nxp.com> wrote:
>
> Introduce fwnode_mdiobus_register_phy() to register PHYs on the
> mdiobus. From the compatible string, identify whether the PHY is
> c45 and based on this create a PHY device instance which is
> registered on the mdiobus.

> uninitialized symbol 'mii_ts'
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

I don't think it's important to have it in a history of Git. I would
move this after the cutter '---' line below.

> Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
> ---
>
> Changes in v7:
> - Call unregister_mii_timestamper() without NULL check
> - Create fwnode_mdio.c and move fwnode_mdiobus_register_phy()
>
> Changes in v6:
> - Initialize mii_ts to NULL
>
> Changes in v5: None
> Changes in v4: None
> Changes in v3: None
> Changes in v2: None
>
>  MAINTAINERS                    |  1 +
>  drivers/net/mdio/Kconfig       |  9 ++++
>  drivers/net/mdio/Makefile      |  3 +-
>  drivers/net/mdio/fwnode_mdio.c | 77 ++++++++++++++++++++++++++++++++++
>  drivers/net/mdio/of_mdio.c     |  3 +-
>  include/linux/fwnode_mdio.h    | 24 +++++++++++
>  include/linux/of_mdio.h        |  6 ++-
>  7 files changed, 120 insertions(+), 3 deletions(-)
>  create mode 100644 drivers/net/mdio/fwnode_mdio.c
>  create mode 100644 include/linux/fwnode_mdio.h
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index e1fa5ad9bb30..146de41d2656 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -6680,6 +6680,7 @@ F:        Documentation/devicetree/bindings/net/mdio*
>  F:     Documentation/devicetree/bindings/net/qca,ar803x.yaml
>  F:     Documentation/networking/phy.rst
>  F:     drivers/net/mdio/
> +F:     drivers/net/mdio/fwnode_mdio.c
>  F:     drivers/net/mdio/of_mdio.c
>  F:     drivers/net/pcs/
>  F:     drivers/net/phy/
> diff --git a/drivers/net/mdio/Kconfig b/drivers/net/mdio/Kconfig
> index a10cc460d7cf..2d5bf5ccffb5 100644
> --- a/drivers/net/mdio/Kconfig
> +++ b/drivers/net/mdio/Kconfig
> @@ -19,6 +19,15 @@ config MDIO_BUS
>           reflects whether the mdio_bus/mdio_device code is built as a
>           loadable module or built-in.
>
> +config FWNODE_MDIO
> +       def_tristate PHYLIB

(Seems "selectable only" item)

> +       depends on ACPI
> +       depends on OF

Wouldn't be better to have
  depends on (ACPI || OF) || COMPILE_TEST

And honestly I don't understand it in either (AND or OR) variant. Why
do you need a dependency like this for fwnode API?

Moreover dependencies don't work for "selectable only" items.

> +       depends on PHYLIB
> +       select FIXED_PHY
> +       help
> +         FWNODE MDIO bus (Ethernet PHY) accessors
> +
>  config OF_MDIO
>         def_tristate PHYLIB
>         depends on OF
> diff --git a/drivers/net/mdio/Makefile b/drivers/net/mdio/Makefile
> index 5c498dde463f..ea5390e2ef84 100644
> --- a/drivers/net/mdio/Makefile
> +++ b/drivers/net/mdio/Makefile
> @@ -1,7 +1,8 @@
>  # SPDX-License-Identifier: GPL-2.0
>  # Makefile for Linux MDIO bus drivers
>
> -obj-$(CONFIG_OF_MDIO)  += of_mdio.o
> +obj-$(CONFIG_FWNODE_MDIO)      += fwnode_mdio.o
> +obj-$(CONFIG_OF_MDIO)          += of_mdio.o
>
>  obj-$(CONFIG_MDIO_ASPEED)              += mdio-aspeed.o
>  obj-$(CONFIG_MDIO_BCM_IPROC)           += mdio-bcm-iproc.o
> diff --git a/drivers/net/mdio/fwnode_mdio.c b/drivers/net/mdio/fwnode_mdio.c
> new file mode 100644
> index 000000000000..0982e816a6fb
> --- /dev/null
> +++ b/drivers/net/mdio/fwnode_mdio.c
> @@ -0,0 +1,77 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * fwnode helpers for the MDIO (Ethernet PHY) API
> + *
> + * This file provides helper functions for extracting PHY device information
> + * out of the fwnode and using it to populate an mii_bus.
> + */
> +
> +#include <linux/acpi.h>
> +#include <linux/of.h>
> +#include <linux/of_mdio.h>
> +#include <linux/phy.h>
> +
> +MODULE_AUTHOR("Calvin Johnson <calvin.johnson@oss.nxp.com>");
> +MODULE_LICENSE("GPL");
> +
> +int fwnode_mdiobus_register_phy(struct mii_bus *bus,
> +                               struct fwnode_handle *child, u32 addr)
> +{
> +       struct mii_timestamper *mii_ts = NULL;
> +       struct phy_device *phy;
> +       bool is_c45 = false;
> +       u32 phy_id;
> +       int rc;
> +
> +       if (is_of_node(child)) {
> +               mii_ts = of_find_mii_timestamper(to_of_node(child));
> +               if (IS_ERR(mii_ts))
> +                       return PTR_ERR(mii_ts);
> +       }
> +
> +       rc = fwnode_property_match_string(child, "compatible", "ethernet-phy-ieee802.3-c45");
> +       if (rc >= 0)
> +               is_c45 = true;
> +
> +       if (is_c45 || fwnode_get_phy_id(child, &phy_id))
> +               phy = get_phy_device(bus, addr, is_c45);
> +       else
> +               phy = phy_device_create(bus, addr, phy_id, 0, NULL);
> +       if (IS_ERR(phy)) {
> +               unregister_mii_timestamper(mii_ts);
> +               return PTR_ERR(phy);
> +       }
> +
> +       if (is_acpi_node(child)) {
> +               phy->irq = bus->irq[addr];
> +
> +               /* Associate the fwnode with the device structure so it
> +                * can be looked up later.
> +                */
> +               phy->mdio.dev.fwnode = child;
> +
> +               /* All data is now stored in the phy struct, so register it */
> +               rc = phy_device_register(phy);
> +               if (rc) {
> +                       phy_device_free(phy);
> +                       fwnode_handle_put(phy->mdio.dev.fwnode);
> +                       return rc;
> +               }
> +       } else if (is_of_node(child)) {
> +               rc = of_mdiobus_phy_device_register(bus, phy, to_of_node(child), addr);
> +               if (rc) {
> +                       unregister_mii_timestamper(mii_ts);
> +                       phy_device_free(phy);
> +                       return rc;
> +               }
> +       }
> +
> +       /* phy->mii_ts may already be defined by the PHY driver. A
> +        * mii_timestamper probed via the device tree will still have
> +        * precedence.
> +        */
> +       if (mii_ts)
> +               phy->mii_ts = mii_ts;
> +       return 0;
> +}
> +EXPORT_SYMBOL(fwnode_mdiobus_register_phy);
> diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c
> index 48b6b8458c17..db293e0b8249 100644
> --- a/drivers/net/mdio/of_mdio.c
> +++ b/drivers/net/mdio/of_mdio.c
> @@ -32,7 +32,7 @@ static int of_get_phy_id(struct device_node *device, u32 *phy_id)
>         return fwnode_get_phy_id(of_fwnode_handle(device), phy_id);
>  }
>
> -static struct mii_timestamper *of_find_mii_timestamper(struct device_node *node)
> +struct mii_timestamper *of_find_mii_timestamper(struct device_node *node)
>  {
>         struct of_phandle_args arg;
>         int err;
> @@ -49,6 +49,7 @@ static struct mii_timestamper *of_find_mii_timestamper(struct device_node *node)
>
>         return register_mii_timestamper(arg.np, arg.args[0]);
>  }
> +EXPORT_SYMBOL(of_find_mii_timestamper);
>
>  int of_mdiobus_phy_device_register(struct mii_bus *mdio, struct phy_device *phy,
>                               struct device_node *child, u32 addr)
> diff --git a/include/linux/fwnode_mdio.h b/include/linux/fwnode_mdio.h
> new file mode 100644
> index 000000000000..8c0392845916
> --- /dev/null
> +++ b/include/linux/fwnode_mdio.h
> @@ -0,0 +1,24 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/*
> + * FWNODE helper for the MDIO (Ethernet PHY) API
> + */
> +
> +#ifndef __LINUX_FWNODE_MDIO_H
> +#define __LINUX_FWNODE_MDIO_H
> +
> +#include <linux/phy.h>
> +
> +#if IS_ENABLED(CONFIG_FWNODE_MDIO)
> +int fwnode_mdiobus_register_phy(struct mii_bus *bus,
> +                               struct fwnode_handle *child, u32 addr);
> +
> +#else /* CONFIG_FWNODE_MDIO */
> +static inline int fwnode_mdiobus_register_phy(struct mii_bus *bus,
> +                                             struct fwnode_handle *child,
> +                                             u32 addr)
> +{
> +       return -EINVAL;
> +}
> +#endif
> +
> +#endif /* __LINUX_FWNODE_MDIO_H */
> diff --git a/include/linux/of_mdio.h b/include/linux/of_mdio.h
> index 2b05e7f7c238..e4ee6c4d9431 100644
> --- a/include/linux/of_mdio.h
> +++ b/include/linux/of_mdio.h
> @@ -31,6 +31,7 @@ struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np);
>  int of_phy_register_fixed_link(struct device_node *np);
>  void of_phy_deregister_fixed_link(struct device_node *np);
>  bool of_phy_is_fixed_link(struct device_node *np);
> +struct mii_timestamper *of_find_mii_timestamper(struct device_node *np);
>  int of_mdiobus_phy_device_register(struct mii_bus *mdio, struct phy_device *phy,
>                                    struct device_node *child, u32 addr);
>
> @@ -118,7 +119,10 @@ static inline bool of_phy_is_fixed_link(struct device_node *np)
>  {
>         return false;
>  }
> -
> +static inline struct mii_timestamper *of_find_mii_timestamper(struct device_node *np)
> +{
> +       return NULL;
> +}
>  static inline int of_mdiobus_phy_device_register(struct mii_bus *mdio,
>                                             struct phy_device *phy,
>                                             struct device_node *child, u32 addr)
> --
> 2.17.1
>


-- 
With Best Regards,
Andy Shevchenko

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [net-next PATCH v7 10/16] ACPI: utils: Introduce acpi_get_local_address()
  2021-03-11  6:20   ` Calvin Johnson
@ 2021-03-11 12:10     ` Andy Shevchenko
  -1 siblings, 0 replies; 64+ messages in thread
From: Andy Shevchenko @ 2021-03-11 12:10 UTC (permalink / raw)
  To: Calvin Johnson
  Cc: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Florian Fainelli, Russell King - ARM Linux admin,
	Cristi Sovaiala, Florin Laurentiu Chiculita, Ioana Ciornei,
	Madalin Bucur, Heikki Krogerus, Marcin Wojtas,
	Pieter Jansen Van Vuuren, Jon, Saravana Kannan, Randy Dunlap,
	linux-arm Mailing List, Diana Madalina Craciun,
	ACPI Devel Maling List, Linux Kernel Mailing List, linux.cj,
	netdev, Laurentiu Tudor, Len Brown, Rafael J. Wysocki

On Thu, Mar 11, 2021 at 8:22 AM Calvin Johnson
<calvin.johnson@oss.nxp.com> wrote:
>
> Introduce a wrapper around the _ADR evaluation.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

> Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
> ---
>
> Changes in v7: None
> Changes in v6: None
> Changes in v5:
> - Replace fwnode_get_id() with acpi_get_local_address()
>
> Changes in v4:
> - Improve code structure to handle all cases
>
> Changes in v3:
> - Modified to retrieve reg property value for ACPI as well
> - Resolved compilation issue with CONFIG_ACPI = n
> - Added more info into documentation
>
> Changes in v2: None
>
>  drivers/acpi/utils.c | 14 ++++++++++++++
>  include/linux/acpi.h |  7 +++++++
>  2 files changed, 21 insertions(+)
>
> diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
> index 682edd913b3b..41fe380a09a7 100644
> --- a/drivers/acpi/utils.c
> +++ b/drivers/acpi/utils.c
> @@ -277,6 +277,20 @@ acpi_evaluate_integer(acpi_handle handle,
>
>  EXPORT_SYMBOL(acpi_evaluate_integer);
>
> +int acpi_get_local_address(acpi_handle handle, u32 *addr)
> +{
> +       unsigned long long adr;
> +       acpi_status status;
> +
> +       status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &adr);
> +       if (ACPI_FAILURE(status))
> +               return -ENODATA;
> +
> +       *addr = (u32)adr;
> +       return 0;
> +}
> +EXPORT_SYMBOL(acpi_get_local_address);
> +
>  acpi_status
>  acpi_evaluate_reference(acpi_handle handle,
>                         acpi_string pathname,
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index fcdaab723916..700f9fc303ab 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -706,6 +706,8 @@ static inline u64 acpi_arch_get_root_pointer(void)
>  }
>  #endif
>
> +int acpi_get_local_address(acpi_handle handle, u32 *addr);
> +
>  #else  /* !CONFIG_ACPI */
>
>  #define acpi_disabled 1
> @@ -953,6 +955,11 @@ static inline struct acpi_device *acpi_resource_consumer(struct resource *res)
>         return NULL;
>  }
>
> +static inline int acpi_get_local_address(acpi_handle handle, u32 *addr)
> +{
> +       return -ENODEV;
> +}
> +
>  #endif /* !CONFIG_ACPI */
>
>  #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
> --
> 2.17.1
>


-- 
With Best Regards,
Andy Shevchenko

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

* Re: [net-next PATCH v7 10/16] ACPI: utils: Introduce acpi_get_local_address()
@ 2021-03-11 12:10     ` Andy Shevchenko
  0 siblings, 0 replies; 64+ messages in thread
From: Andy Shevchenko @ 2021-03-11 12:10 UTC (permalink / raw)
  To: Calvin Johnson
  Cc: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Florian Fainelli, Russell King - ARM Linux admin,
	Cristi Sovaiala, Florin Laurentiu Chiculita, Ioana Ciornei,
	Madalin Bucur, Heikki Krogerus, Marcin Wojtas,
	Pieter Jansen Van Vuuren, Jon, Saravana Kannan, Randy Dunlap,
	linux-arm Mailing List, Diana Madalina Craciun,
	ACPI Devel Maling List, Linux Kernel Mailing List, linux.cj,
	netdev, Laurentiu Tudor, Len Brown, Rafael J. Wysocki

On Thu, Mar 11, 2021 at 8:22 AM Calvin Johnson
<calvin.johnson@oss.nxp.com> wrote:
>
> Introduce a wrapper around the _ADR evaluation.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

> Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
> ---
>
> Changes in v7: None
> Changes in v6: None
> Changes in v5:
> - Replace fwnode_get_id() with acpi_get_local_address()
>
> Changes in v4:
> - Improve code structure to handle all cases
>
> Changes in v3:
> - Modified to retrieve reg property value for ACPI as well
> - Resolved compilation issue with CONFIG_ACPI = n
> - Added more info into documentation
>
> Changes in v2: None
>
>  drivers/acpi/utils.c | 14 ++++++++++++++
>  include/linux/acpi.h |  7 +++++++
>  2 files changed, 21 insertions(+)
>
> diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
> index 682edd913b3b..41fe380a09a7 100644
> --- a/drivers/acpi/utils.c
> +++ b/drivers/acpi/utils.c
> @@ -277,6 +277,20 @@ acpi_evaluate_integer(acpi_handle handle,
>
>  EXPORT_SYMBOL(acpi_evaluate_integer);
>
> +int acpi_get_local_address(acpi_handle handle, u32 *addr)
> +{
> +       unsigned long long adr;
> +       acpi_status status;
> +
> +       status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &adr);
> +       if (ACPI_FAILURE(status))
> +               return -ENODATA;
> +
> +       *addr = (u32)adr;
> +       return 0;
> +}
> +EXPORT_SYMBOL(acpi_get_local_address);
> +
>  acpi_status
>  acpi_evaluate_reference(acpi_handle handle,
>                         acpi_string pathname,
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index fcdaab723916..700f9fc303ab 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -706,6 +706,8 @@ static inline u64 acpi_arch_get_root_pointer(void)
>  }
>  #endif
>
> +int acpi_get_local_address(acpi_handle handle, u32 *addr);
> +
>  #else  /* !CONFIG_ACPI */
>
>  #define acpi_disabled 1
> @@ -953,6 +955,11 @@ static inline struct acpi_device *acpi_resource_consumer(struct resource *res)
>         return NULL;
>  }
>
> +static inline int acpi_get_local_address(acpi_handle handle, u32 *addr)
> +{
> +       return -ENODEV;
> +}
> +
>  #endif /* !CONFIG_ACPI */
>
>  #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
> --
> 2.17.1
>


-- 
With Best Regards,
Andy Shevchenko

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [net-next PATCH v7 11/16] net: mdio: Add ACPI support code for mdio
  2021-03-11  6:20   ` Calvin Johnson
@ 2021-03-11 12:14     ` Andy Shevchenko
  -1 siblings, 0 replies; 64+ messages in thread
From: Andy Shevchenko @ 2021-03-11 12:14 UTC (permalink / raw)
  To: Calvin Johnson
  Cc: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Florian Fainelli, Russell King - ARM Linux admin,
	Cristi Sovaiala, Florin Laurentiu Chiculita, Ioana Ciornei,
	Madalin Bucur, Heikki Krogerus, Marcin Wojtas,
	Pieter Jansen Van Vuuren, Jon, Saravana Kannan, Randy Dunlap,
	linux-arm Mailing List, Diana Madalina Craciun,
	ACPI Devel Maling List, Linux Kernel Mailing List, linux.cj,
	netdev, Laurentiu Tudor, David S. Miller, Heiner Kallweit,
	Jakub Kicinski

On Thu, Mar 11, 2021 at 8:22 AM Calvin Johnson
<calvin.johnson@oss.nxp.com> wrote:
>
> Define acpi_mdiobus_register() to Register mii_bus and create PHYs for
> each ACPI child node.
>
> Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
> ---
>
> Changes in v7:
> - Include headers directly used in acpi_mdio.c
>
> Changes in v6:
> - use GENMASK() and ACPI_COMPANION_SET()
> - some cleanup
> - remove unwanted header inclusion
>
> Changes in v5:
> - add missing MODULE_LICENSE()
> - replace fwnode_get_id() with OF and ACPI function calls
>
> Changes in v4: None
> Changes in v3: None
> Changes in v2: None
>
>  MAINTAINERS                  |  1 +
>  drivers/net/mdio/Kconfig     |  7 +++++
>  drivers/net/mdio/Makefile    |  1 +
>  drivers/net/mdio/acpi_mdio.c | 56 ++++++++++++++++++++++++++++++++++++
>  include/linux/acpi_mdio.h    | 25 ++++++++++++++++
>  5 files changed, 90 insertions(+)
>  create mode 100644 drivers/net/mdio/acpi_mdio.c
>  create mode 100644 include/linux/acpi_mdio.h
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 146de41d2656..051377b7fa94 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -6680,6 +6680,7 @@ F:        Documentation/devicetree/bindings/net/mdio*
>  F:     Documentation/devicetree/bindings/net/qca,ar803x.yaml
>  F:     Documentation/networking/phy.rst
>  F:     drivers/net/mdio/
> +F:     drivers/net/mdio/acpi_mdio.c
>  F:     drivers/net/mdio/fwnode_mdio.c
>  F:     drivers/net/mdio/of_mdio.c
>  F:     drivers/net/pcs/
> diff --git a/drivers/net/mdio/Kconfig b/drivers/net/mdio/Kconfig
> index 2d5bf5ccffb5..fc8c787b448f 100644
> --- a/drivers/net/mdio/Kconfig
> +++ b/drivers/net/mdio/Kconfig
> @@ -36,6 +36,13 @@ config OF_MDIO
>         help
>           OpenFirmware MDIO bus (Ethernet PHY) accessors
>
> +config ACPI_MDIO
> +       def_tristate PHYLIB

> +       depends on ACPI
> +       depends on PHYLIB

Same issue, they are no-ops.

I guess you have to surround OF and ACPI and FWNODE variants by

if PHYLIB
...
endif

This will be an equivalent to depends on PHYLIB

and put this into Makefile

ifneq ($(CONFIG_ACPI),)
obj-$(CONFIG_PHYLIB) += acpi_mdio.o
endif

This will give you the rest, i.e. default PHYLIB + depends on ACPI

Similar for OF

> +       help
> +         ACPI MDIO bus (Ethernet PHY) accessors
> +
>  if MDIO_BUS
>
>  config MDIO_DEVRES
> diff --git a/drivers/net/mdio/Makefile b/drivers/net/mdio/Makefile
> index ea5390e2ef84..e8b739a3df1c 100644
> --- a/drivers/net/mdio/Makefile
> +++ b/drivers/net/mdio/Makefile
> @@ -1,6 +1,7 @@
>  # SPDX-License-Identifier: GPL-2.0
>  # Makefile for Linux MDIO bus drivers
>
> +obj-$(CONFIG_ACPI_MDIO)                += acpi_mdio.o
>  obj-$(CONFIG_FWNODE_MDIO)      += fwnode_mdio.o
>  obj-$(CONFIG_OF_MDIO)          += of_mdio.o
>
> diff --git a/drivers/net/mdio/acpi_mdio.c b/drivers/net/mdio/acpi_mdio.c
> new file mode 100644
> index 000000000000..60a86e3fc246
> --- /dev/null
> +++ b/drivers/net/mdio/acpi_mdio.c
> @@ -0,0 +1,56 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * ACPI helpers for the MDIO (Ethernet PHY) API
> + *
> + * This file provides helper functions for extracting PHY device information
> + * out of the ACPI ASL and using it to populate an mii_bus.
> + */
> +
> +#include <linux/acpi.h>
> +#include <linux/acpi_mdio.h>
> +#include <linux/bits.h>
> +#include <linux/dev_printk.h>
> +#include <linux/fwnode_mdio.h>
> +#include <linux/module.h>
> +#include <linux/types.h>
> +
> +MODULE_AUTHOR("Calvin Johnson <calvin.johnson@oss.nxp.com>");
> +MODULE_LICENSE("GPL");
> +
> +/**
> + * acpi_mdiobus_register - Register mii_bus and create PHYs from the ACPI ASL.
> + * @mdio: pointer to mii_bus structure
> + * @fwnode: pointer to fwnode of MDIO bus.
> + *
> + * This function registers the mii_bus structure and registers a phy_device
> + * for each child node of @fwnode.
> + */
> +int acpi_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode)
> +{
> +       struct fwnode_handle *child;
> +       u32 addr;
> +       int ret;
> +
> +       /* Mask out all PHYs from auto probing. */
> +       mdio->phy_mask = GENMASK(31, 0);
> +       ret = mdiobus_register(mdio);
> +       if (ret)
> +               return ret;
> +
> +       ACPI_COMPANION_SET(&mdio->dev, to_acpi_device_node(fwnode));
> +
> +       /* Loop over the child nodes and register a phy_device for each PHY */
> +       fwnode_for_each_child_node(fwnode, child) {
> +               ret = acpi_get_local_address(ACPI_HANDLE_FWNODE(child), &addr);
> +               if (ret || addr >= PHY_MAX_ADDR)
> +                       continue;
> +
> +               ret = fwnode_mdiobus_register_phy(mdio, child, addr);
> +               if (ret == -ENODEV)
> +                       dev_err(&mdio->dev,
> +                               "MDIO device at address %d is missing.\n",
> +                               addr);
> +       }
> +       return 0;
> +}
> +EXPORT_SYMBOL(acpi_mdiobus_register);
> diff --git a/include/linux/acpi_mdio.h b/include/linux/acpi_mdio.h
> new file mode 100644
> index 000000000000..748d261fe2f9
> --- /dev/null
> +++ b/include/linux/acpi_mdio.h
> @@ -0,0 +1,25 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/*
> + * ACPI helper for the MDIO (Ethernet PHY) API
> + */
> +
> +#ifndef __LINUX_ACPI_MDIO_H
> +#define __LINUX_ACPI_MDIO_H
> +
> +#include <linux/phy.h>
> +
> +#if IS_ENABLED(CONFIG_ACPI_MDIO)
> +int acpi_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode);
> +#else /* CONFIG_ACPI_MDIO */
> +static inline int acpi_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode)
> +{
> +       /*
> +        * Fall back to mdiobus_register() function to register a bus.
> +        * This way, we don't have to keep compat bits around in drivers.
> +        */
> +
> +       return mdiobus_register(mdio);
> +}
> +#endif
> +
> +#endif /* __LINUX_ACPI_MDIO_H */
> --
> 2.17.1
>


-- 
With Best Regards,
Andy Shevchenko

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

* Re: [net-next PATCH v7 11/16] net: mdio: Add ACPI support code for mdio
@ 2021-03-11 12:14     ` Andy Shevchenko
  0 siblings, 0 replies; 64+ messages in thread
From: Andy Shevchenko @ 2021-03-11 12:14 UTC (permalink / raw)
  To: Calvin Johnson
  Cc: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Florian Fainelli, Russell King - ARM Linux admin,
	Cristi Sovaiala, Florin Laurentiu Chiculita, Ioana Ciornei,
	Madalin Bucur, Heikki Krogerus, Marcin Wojtas,
	Pieter Jansen Van Vuuren, Jon, Saravana Kannan, Randy Dunlap,
	linux-arm Mailing List, Diana Madalina Craciun,
	ACPI Devel Maling List, Linux Kernel Mailing List, linux.cj,
	netdev, Laurentiu Tudor, David S. Miller, Heiner Kallweit,
	Jakub Kicinski

On Thu, Mar 11, 2021 at 8:22 AM Calvin Johnson
<calvin.johnson@oss.nxp.com> wrote:
>
> Define acpi_mdiobus_register() to Register mii_bus and create PHYs for
> each ACPI child node.
>
> Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
> ---
>
> Changes in v7:
> - Include headers directly used in acpi_mdio.c
>
> Changes in v6:
> - use GENMASK() and ACPI_COMPANION_SET()
> - some cleanup
> - remove unwanted header inclusion
>
> Changes in v5:
> - add missing MODULE_LICENSE()
> - replace fwnode_get_id() with OF and ACPI function calls
>
> Changes in v4: None
> Changes in v3: None
> Changes in v2: None
>
>  MAINTAINERS                  |  1 +
>  drivers/net/mdio/Kconfig     |  7 +++++
>  drivers/net/mdio/Makefile    |  1 +
>  drivers/net/mdio/acpi_mdio.c | 56 ++++++++++++++++++++++++++++++++++++
>  include/linux/acpi_mdio.h    | 25 ++++++++++++++++
>  5 files changed, 90 insertions(+)
>  create mode 100644 drivers/net/mdio/acpi_mdio.c
>  create mode 100644 include/linux/acpi_mdio.h
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 146de41d2656..051377b7fa94 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -6680,6 +6680,7 @@ F:        Documentation/devicetree/bindings/net/mdio*
>  F:     Documentation/devicetree/bindings/net/qca,ar803x.yaml
>  F:     Documentation/networking/phy.rst
>  F:     drivers/net/mdio/
> +F:     drivers/net/mdio/acpi_mdio.c
>  F:     drivers/net/mdio/fwnode_mdio.c
>  F:     drivers/net/mdio/of_mdio.c
>  F:     drivers/net/pcs/
> diff --git a/drivers/net/mdio/Kconfig b/drivers/net/mdio/Kconfig
> index 2d5bf5ccffb5..fc8c787b448f 100644
> --- a/drivers/net/mdio/Kconfig
> +++ b/drivers/net/mdio/Kconfig
> @@ -36,6 +36,13 @@ config OF_MDIO
>         help
>           OpenFirmware MDIO bus (Ethernet PHY) accessors
>
> +config ACPI_MDIO
> +       def_tristate PHYLIB

> +       depends on ACPI
> +       depends on PHYLIB

Same issue, they are no-ops.

I guess you have to surround OF and ACPI and FWNODE variants by

if PHYLIB
...
endif

This will be an equivalent to depends on PHYLIB

and put this into Makefile

ifneq ($(CONFIG_ACPI),)
obj-$(CONFIG_PHYLIB) += acpi_mdio.o
endif

This will give you the rest, i.e. default PHYLIB + depends on ACPI

Similar for OF

> +       help
> +         ACPI MDIO bus (Ethernet PHY) accessors
> +
>  if MDIO_BUS
>
>  config MDIO_DEVRES
> diff --git a/drivers/net/mdio/Makefile b/drivers/net/mdio/Makefile
> index ea5390e2ef84..e8b739a3df1c 100644
> --- a/drivers/net/mdio/Makefile
> +++ b/drivers/net/mdio/Makefile
> @@ -1,6 +1,7 @@
>  # SPDX-License-Identifier: GPL-2.0
>  # Makefile for Linux MDIO bus drivers
>
> +obj-$(CONFIG_ACPI_MDIO)                += acpi_mdio.o
>  obj-$(CONFIG_FWNODE_MDIO)      += fwnode_mdio.o
>  obj-$(CONFIG_OF_MDIO)          += of_mdio.o
>
> diff --git a/drivers/net/mdio/acpi_mdio.c b/drivers/net/mdio/acpi_mdio.c
> new file mode 100644
> index 000000000000..60a86e3fc246
> --- /dev/null
> +++ b/drivers/net/mdio/acpi_mdio.c
> @@ -0,0 +1,56 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * ACPI helpers for the MDIO (Ethernet PHY) API
> + *
> + * This file provides helper functions for extracting PHY device information
> + * out of the ACPI ASL and using it to populate an mii_bus.
> + */
> +
> +#include <linux/acpi.h>
> +#include <linux/acpi_mdio.h>
> +#include <linux/bits.h>
> +#include <linux/dev_printk.h>
> +#include <linux/fwnode_mdio.h>
> +#include <linux/module.h>
> +#include <linux/types.h>
> +
> +MODULE_AUTHOR("Calvin Johnson <calvin.johnson@oss.nxp.com>");
> +MODULE_LICENSE("GPL");
> +
> +/**
> + * acpi_mdiobus_register - Register mii_bus and create PHYs from the ACPI ASL.
> + * @mdio: pointer to mii_bus structure
> + * @fwnode: pointer to fwnode of MDIO bus.
> + *
> + * This function registers the mii_bus structure and registers a phy_device
> + * for each child node of @fwnode.
> + */
> +int acpi_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode)
> +{
> +       struct fwnode_handle *child;
> +       u32 addr;
> +       int ret;
> +
> +       /* Mask out all PHYs from auto probing. */
> +       mdio->phy_mask = GENMASK(31, 0);
> +       ret = mdiobus_register(mdio);
> +       if (ret)
> +               return ret;
> +
> +       ACPI_COMPANION_SET(&mdio->dev, to_acpi_device_node(fwnode));
> +
> +       /* Loop over the child nodes and register a phy_device for each PHY */
> +       fwnode_for_each_child_node(fwnode, child) {
> +               ret = acpi_get_local_address(ACPI_HANDLE_FWNODE(child), &addr);
> +               if (ret || addr >= PHY_MAX_ADDR)
> +                       continue;
> +
> +               ret = fwnode_mdiobus_register_phy(mdio, child, addr);
> +               if (ret == -ENODEV)
> +                       dev_err(&mdio->dev,
> +                               "MDIO device at address %d is missing.\n",
> +                               addr);
> +       }
> +       return 0;
> +}
> +EXPORT_SYMBOL(acpi_mdiobus_register);
> diff --git a/include/linux/acpi_mdio.h b/include/linux/acpi_mdio.h
> new file mode 100644
> index 000000000000..748d261fe2f9
> --- /dev/null
> +++ b/include/linux/acpi_mdio.h
> @@ -0,0 +1,25 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/*
> + * ACPI helper for the MDIO (Ethernet PHY) API
> + */
> +
> +#ifndef __LINUX_ACPI_MDIO_H
> +#define __LINUX_ACPI_MDIO_H
> +
> +#include <linux/phy.h>
> +
> +#if IS_ENABLED(CONFIG_ACPI_MDIO)
> +int acpi_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode);
> +#else /* CONFIG_ACPI_MDIO */
> +static inline int acpi_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode)
> +{
> +       /*
> +        * Fall back to mdiobus_register() function to register a bus.
> +        * This way, we don't have to keep compat bits around in drivers.
> +        */
> +
> +       return mdiobus_register(mdio);
> +}
> +#endif
> +
> +#endif /* __LINUX_ACPI_MDIO_H */
> --
> 2.17.1
>


-- 
With Best Regards,
Andy Shevchenko

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [net-next PATCH v7 02/16] net: phy: Introduce fwnode_mdio_find_device()
  2021-03-11  6:50     ` Saravana Kannan
@ 2021-03-11 16:58       ` Calvin Johnson
  -1 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11 16:58 UTC (permalink / raw)
  To: Saravana Kannan
  Cc: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Randy Dunlap, linux-arm-kernel, Diana Madalina Craciun,
	ACPI Devel Maling List, LKML, linux.cj, netdev, Laurentiu Tudor,
	David S. Miller, Heiner Kallweit, Jakub Kicinski

On Wed, Mar 10, 2021 at 10:50:57PM -0800, Saravana Kannan wrote:
> On Wed, Mar 10, 2021 at 10:21 PM Calvin Johnson
> <calvin.johnson@oss.nxp.com> wrote:
> >
> > Define fwnode_mdio_find_device() to get a pointer to the
> > mdio_device from fwnode passed to the function.
> >
> > Refactor of_mdio_find_device() to use fwnode_mdio_find_device().
> >
> > Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
> > ---
> >
> > Changes in v7:
> > - correct fwnode_mdio_find_device() description
> >
> > Changes in v6:
> > - fix warning for function parameter of fwnode_mdio_find_device()
> >
> > Changes in v5: None
> > Changes in v4: None
> > Changes in v3: None
> > Changes in v2: None
> >
> >  drivers/net/mdio/of_mdio.c   | 11 +----------
> >  drivers/net/phy/phy_device.c | 23 +++++++++++++++++++++++
> >  include/linux/phy.h          |  6 ++++++
> >  3 files changed, 30 insertions(+), 10 deletions(-)
> >
> > diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c
> > index ea9d5855fb52..d5e0970b2561 100644
> > --- a/drivers/net/mdio/of_mdio.c
> > +++ b/drivers/net/mdio/of_mdio.c
> > @@ -347,16 +347,7 @@ EXPORT_SYMBOL(of_mdiobus_register);
> >   */
> >  struct mdio_device *of_mdio_find_device(struct device_node *np)
> >  {
> > -       struct device *d;
> > -
> > -       if (!np)
> > -               return NULL;
> > -
> > -       d = bus_find_device_by_of_node(&mdio_bus_type, np);
> > -       if (!d)
> > -               return NULL;
> > -
> > -       return to_mdio_device(d);
> > +       return fwnode_mdio_find_device(of_fwnode_handle(np));
> >  }
> >  EXPORT_SYMBOL(of_mdio_find_device);
> >
> > diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> > index cc38e326405a..daabb17bba00 100644
> > --- a/drivers/net/phy/phy_device.c
> > +++ b/drivers/net/phy/phy_device.c
> > @@ -2819,6 +2819,29 @@ static bool phy_drv_supports_irq(struct phy_driver *phydrv)
> >         return phydrv->config_intr && phydrv->handle_interrupt;
> >  }
> >
> > +/**
> > + * fwnode_mdio_find_device - Given a fwnode, find the mdio_device
> > + * @fwnode: pointer to the mdio_device's fwnode
> > + *
> > + * If successful, returns a pointer to the mdio_device with the embedded
> > + * struct device refcount incremented by one, or NULL on failure.
> > + * The caller should call put_device() on the mdio_device after its use.
> > + */
> > +struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode)
> > +{
> > +       struct device *d;
> > +
> > +       if (!fwnode)
> > +               return NULL;
> > +
> > +       d = bus_find_device_by_fwnode(&mdio_bus_type, fwnode);
> 
> Sorry about the late review, but can you look into using
> get_dev_from_fwnode()? As long as you aren't registering two devices
> for the same fwnode, it's an O(1) operation instead of having to loop
> through a list of devices in a bus. You can check the returned
> device's bus type if you aren't sure about not registering two devices
> with the same fw_node and then fall back to this looping.

I think it is better to keep it simple and clear with
bus_find_device_by_fwnode() instead of the additional code that comes
with get_dev_from_fwnode() until it has clear advantage over the former.

regards
Calvin

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

* Re: [net-next PATCH v7 02/16] net: phy: Introduce fwnode_mdio_find_device()
@ 2021-03-11 16:58       ` Calvin Johnson
  0 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11 16:58 UTC (permalink / raw)
  To: Saravana Kannan
  Cc: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Randy Dunlap, linux-arm-kernel, Diana Madalina Craciun,
	ACPI Devel Maling List, LKML, linux.cj, netdev, Laurentiu Tudor,
	David S. Miller, Heiner Kallweit, Jakub Kicinski

On Wed, Mar 10, 2021 at 10:50:57PM -0800, Saravana Kannan wrote:
> On Wed, Mar 10, 2021 at 10:21 PM Calvin Johnson
> <calvin.johnson@oss.nxp.com> wrote:
> >
> > Define fwnode_mdio_find_device() to get a pointer to the
> > mdio_device from fwnode passed to the function.
> >
> > Refactor of_mdio_find_device() to use fwnode_mdio_find_device().
> >
> > Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
> > ---
> >
> > Changes in v7:
> > - correct fwnode_mdio_find_device() description
> >
> > Changes in v6:
> > - fix warning for function parameter of fwnode_mdio_find_device()
> >
> > Changes in v5: None
> > Changes in v4: None
> > Changes in v3: None
> > Changes in v2: None
> >
> >  drivers/net/mdio/of_mdio.c   | 11 +----------
> >  drivers/net/phy/phy_device.c | 23 +++++++++++++++++++++++
> >  include/linux/phy.h          |  6 ++++++
> >  3 files changed, 30 insertions(+), 10 deletions(-)
> >
> > diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c
> > index ea9d5855fb52..d5e0970b2561 100644
> > --- a/drivers/net/mdio/of_mdio.c
> > +++ b/drivers/net/mdio/of_mdio.c
> > @@ -347,16 +347,7 @@ EXPORT_SYMBOL(of_mdiobus_register);
> >   */
> >  struct mdio_device *of_mdio_find_device(struct device_node *np)
> >  {
> > -       struct device *d;
> > -
> > -       if (!np)
> > -               return NULL;
> > -
> > -       d = bus_find_device_by_of_node(&mdio_bus_type, np);
> > -       if (!d)
> > -               return NULL;
> > -
> > -       return to_mdio_device(d);
> > +       return fwnode_mdio_find_device(of_fwnode_handle(np));
> >  }
> >  EXPORT_SYMBOL(of_mdio_find_device);
> >
> > diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> > index cc38e326405a..daabb17bba00 100644
> > --- a/drivers/net/phy/phy_device.c
> > +++ b/drivers/net/phy/phy_device.c
> > @@ -2819,6 +2819,29 @@ static bool phy_drv_supports_irq(struct phy_driver *phydrv)
> >         return phydrv->config_intr && phydrv->handle_interrupt;
> >  }
> >
> > +/**
> > + * fwnode_mdio_find_device - Given a fwnode, find the mdio_device
> > + * @fwnode: pointer to the mdio_device's fwnode
> > + *
> > + * If successful, returns a pointer to the mdio_device with the embedded
> > + * struct device refcount incremented by one, or NULL on failure.
> > + * The caller should call put_device() on the mdio_device after its use.
> > + */
> > +struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode)
> > +{
> > +       struct device *d;
> > +
> > +       if (!fwnode)
> > +               return NULL;
> > +
> > +       d = bus_find_device_by_fwnode(&mdio_bus_type, fwnode);
> 
> Sorry about the late review, but can you look into using
> get_dev_from_fwnode()? As long as you aren't registering two devices
> for the same fwnode, it's an O(1) operation instead of having to loop
> through a list of devices in a bus. You can check the returned
> device's bus type if you aren't sure about not registering two devices
> with the same fw_node and then fall back to this looping.

I think it is better to keep it simple and clear with
bus_find_device_by_fwnode() instead of the additional code that comes
with get_dev_from_fwnode() until it has clear advantage over the former.

regards
Calvin

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [net-next PATCH v7 07/16] net: mii_timestamper: check NULL in unregister_mii_timestamper()
  2021-03-11 12:04     ` Andy Shevchenko
@ 2021-03-11 17:03       ` Calvin Johnson
  -1 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11 17:03 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Florian Fainelli, Russell King - ARM Linux admin,
	Cristi Sovaiala, Florin Laurentiu Chiculita, Ioana Ciornei,
	Madalin Bucur, Heikki Krogerus, Marcin Wojtas,
	Pieter Jansen Van Vuuren, Jon, Saravana Kannan, Randy Dunlap,
	linux-arm Mailing List, Diana Madalina Craciun,
	ACPI Devel Maling List, Linux Kernel Mailing List, linux.cj,
	netdev, Laurentiu Tudor, David S. Miller, Heiner Kallweit,
	Jakub Kicinski

On Thu, Mar 11, 2021 at 02:04:48PM +0200, Andy Shevchenko wrote:
> On Thu, Mar 11, 2021 at 8:21 AM Calvin Johnson
> <calvin.johnson@oss.nxp.com> wrote:
> >
> > Callers of unregister_mii_timestamper() currently check for NULL
> > value of mii_ts before calling it.
> >
> > Place the NULL check inside unregister_mii_timestamper() and update
> > the callers accordingly
> 
> FWIW,
> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> 
> (Don't remember if it has been suggested by somebody, in that case
> perhaps Suggested-by?)

It is the result of your suggestion[1]. So, I'll keep both Suggested-by and
Reviewed-by with your name.

[1] https://lore.kernel.org/linux-arm-kernel/20210218052654.28995-1-calvin.johnson@oss.nxp.com/T/#m8d209f08f97fe1dc7249a63ad97b39311d14a9b3

Thanks
Calvin

> 
> > Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
> > ---
> >
> > Changes in v7:
> > - check NULL in unregister_mii_timestamper()
> >
> > Changes in v6: None
> > Changes in v5: None
> > Changes in v4: None
> > Changes in v3: None
> > Changes in v2: None
> >
> >  drivers/net/mdio/of_mdio.c        | 6 ++----
> >  drivers/net/phy/mii_timestamper.c | 3 +++
> >  drivers/net/phy/phy_device.c      | 3 +--
> >  3 files changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c
> > index 612a37970f14..48b6b8458c17 100644
> > --- a/drivers/net/mdio/of_mdio.c
> > +++ b/drivers/net/mdio/of_mdio.c
> > @@ -115,15 +115,13 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio,
> >         else
> >                 phy = get_phy_device(mdio, addr, is_c45);
> >         if (IS_ERR(phy)) {
> > -               if (mii_ts)
> > -                       unregister_mii_timestamper(mii_ts);
> > +               unregister_mii_timestamper(mii_ts);
> >                 return PTR_ERR(phy);
> >         }
> >
> >         rc = of_mdiobus_phy_device_register(mdio, phy, child, addr);
> >         if (rc) {
> > -               if (mii_ts)
> > -                       unregister_mii_timestamper(mii_ts);
> > +               unregister_mii_timestamper(mii_ts);
> >                 phy_device_free(phy);
> >                 return rc;
> >         }
> > diff --git a/drivers/net/phy/mii_timestamper.c b/drivers/net/phy/mii_timestamper.c
> > index b71b7456462d..51ae0593a04f 100644
> > --- a/drivers/net/phy/mii_timestamper.c
> > +++ b/drivers/net/phy/mii_timestamper.c
> > @@ -111,6 +111,9 @@ void unregister_mii_timestamper(struct mii_timestamper *mii_ts)
> >         struct mii_timestamping_desc *desc;
> >         struct list_head *this;
> >
> > +       if (!mii_ts)
> > +               return;
> > +
> >         /* mii_timestamper statically registered by the PHY driver won't use the
> >          * register_mii_timestamper() and thus don't have ->device set. Don't
> >          * try to unregister these.
> > diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> > index f875efe7b4d1..9c5127405d91 100644
> > --- a/drivers/net/phy/phy_device.c
> > +++ b/drivers/net/phy/phy_device.c
> > @@ -928,8 +928,7 @@ EXPORT_SYMBOL(phy_device_register);
> >   */
> >  void phy_device_remove(struct phy_device *phydev)
> >  {
> > -       if (phydev->mii_ts)
> > -               unregister_mii_timestamper(phydev->mii_ts);
> > +       unregister_mii_timestamper(phydev->mii_ts);
> >
> >         device_del(&phydev->mdio.dev);
> >
> > --
> > 2.17.1
> >
> 
> 
> -- 
> With Best Regards,
> Andy Shevchenko

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

* Re: [net-next PATCH v7 07/16] net: mii_timestamper: check NULL in unregister_mii_timestamper()
@ 2021-03-11 17:03       ` Calvin Johnson
  0 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11 17:03 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Florian Fainelli, Russell King - ARM Linux admin,
	Cristi Sovaiala, Florin Laurentiu Chiculita, Ioana Ciornei,
	Madalin Bucur, Heikki Krogerus, Marcin Wojtas,
	Pieter Jansen Van Vuuren, Jon, Saravana Kannan, Randy Dunlap,
	linux-arm Mailing List, Diana Madalina Craciun,
	ACPI Devel Maling List, Linux Kernel Mailing List, linux.cj,
	netdev, Laurentiu Tudor, David S. Miller, Heiner Kallweit,
	Jakub Kicinski

On Thu, Mar 11, 2021 at 02:04:48PM +0200, Andy Shevchenko wrote:
> On Thu, Mar 11, 2021 at 8:21 AM Calvin Johnson
> <calvin.johnson@oss.nxp.com> wrote:
> >
> > Callers of unregister_mii_timestamper() currently check for NULL
> > value of mii_ts before calling it.
> >
> > Place the NULL check inside unregister_mii_timestamper() and update
> > the callers accordingly
> 
> FWIW,
> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> 
> (Don't remember if it has been suggested by somebody, in that case
> perhaps Suggested-by?)

It is the result of your suggestion[1]. So, I'll keep both Suggested-by and
Reviewed-by with your name.

[1] https://lore.kernel.org/linux-arm-kernel/20210218052654.28995-1-calvin.johnson@oss.nxp.com/T/#m8d209f08f97fe1dc7249a63ad97b39311d14a9b3

Thanks
Calvin

> 
> > Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
> > ---
> >
> > Changes in v7:
> > - check NULL in unregister_mii_timestamper()
> >
> > Changes in v6: None
> > Changes in v5: None
> > Changes in v4: None
> > Changes in v3: None
> > Changes in v2: None
> >
> >  drivers/net/mdio/of_mdio.c        | 6 ++----
> >  drivers/net/phy/mii_timestamper.c | 3 +++
> >  drivers/net/phy/phy_device.c      | 3 +--
> >  3 files changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c
> > index 612a37970f14..48b6b8458c17 100644
> > --- a/drivers/net/mdio/of_mdio.c
> > +++ b/drivers/net/mdio/of_mdio.c
> > @@ -115,15 +115,13 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio,
> >         else
> >                 phy = get_phy_device(mdio, addr, is_c45);
> >         if (IS_ERR(phy)) {
> > -               if (mii_ts)
> > -                       unregister_mii_timestamper(mii_ts);
> > +               unregister_mii_timestamper(mii_ts);
> >                 return PTR_ERR(phy);
> >         }
> >
> >         rc = of_mdiobus_phy_device_register(mdio, phy, child, addr);
> >         if (rc) {
> > -               if (mii_ts)
> > -                       unregister_mii_timestamper(mii_ts);
> > +               unregister_mii_timestamper(mii_ts);
> >                 phy_device_free(phy);
> >                 return rc;
> >         }
> > diff --git a/drivers/net/phy/mii_timestamper.c b/drivers/net/phy/mii_timestamper.c
> > index b71b7456462d..51ae0593a04f 100644
> > --- a/drivers/net/phy/mii_timestamper.c
> > +++ b/drivers/net/phy/mii_timestamper.c
> > @@ -111,6 +111,9 @@ void unregister_mii_timestamper(struct mii_timestamper *mii_ts)
> >         struct mii_timestamping_desc *desc;
> >         struct list_head *this;
> >
> > +       if (!mii_ts)
> > +               return;
> > +
> >         /* mii_timestamper statically registered by the PHY driver won't use the
> >          * register_mii_timestamper() and thus don't have ->device set. Don't
> >          * try to unregister these.
> > diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> > index f875efe7b4d1..9c5127405d91 100644
> > --- a/drivers/net/phy/phy_device.c
> > +++ b/drivers/net/phy/phy_device.c
> > @@ -928,8 +928,7 @@ EXPORT_SYMBOL(phy_device_register);
> >   */
> >  void phy_device_remove(struct phy_device *phydev)
> >  {
> > -       if (phydev->mii_ts)
> > -               unregister_mii_timestamper(phydev->mii_ts);
> > +       unregister_mii_timestamper(phydev->mii_ts);
> >
> >         device_del(&phydev->mdio.dev);
> >
> > --
> > 2.17.1
> >
> 
> 
> -- 
> With Best Regards,
> Andy Shevchenko

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [net-next PATCH v7 08/16] net: mdiobus: Introduce fwnode_mdiobus_register_phy()
  2021-03-11 12:09     ` Andy Shevchenko
@ 2021-03-11 18:00       ` Calvin Johnson
  -1 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11 18:00 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Florian Fainelli, Russell King - ARM Linux admin,
	Cristi Sovaiala, Florin Laurentiu Chiculita, Ioana Ciornei,
	Madalin Bucur, Heikki Krogerus, Marcin Wojtas,
	Pieter Jansen Van Vuuren, Jon, Saravana Kannan, Randy Dunlap,
	linux-arm Mailing List, Diana Madalina Craciun,
	ACPI Devel Maling List, Linux Kernel Mailing List, linux.cj,
	netdev, Laurentiu Tudor, David S. Miller, Frank Rowand,
	Heiner Kallweit, Jakub Kicinski, Rob Herring, devicetree

On Thu, Mar 11, 2021 at 02:09:37PM +0200, Andy Shevchenko wrote:
> On Thu, Mar 11, 2021 at 8:21 AM Calvin Johnson
> <calvin.johnson@oss.nxp.com> wrote:
> >
> > Introduce fwnode_mdiobus_register_phy() to register PHYs on the
> > mdiobus. From the compatible string, identify whether the PHY is
> > c45 and based on this create a PHY device instance which is
> > registered on the mdiobus.
> 
> > uninitialized symbol 'mii_ts'
> > Reported-by: kernel test robot <lkp@intel.com>
> > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> I don't think it's important to have it in a history of Git. I would
> move this after the cutter '---' line below.

Sorry. I thought I had removed it. Will definitely take care next time.

> 
> > Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
> > ---
> >
> > Changes in v7:
> > - Call unregister_mii_timestamper() without NULL check
> > - Create fwnode_mdio.c and move fwnode_mdiobus_register_phy()
> >
> > Changes in v6:
> > - Initialize mii_ts to NULL
> >
> > Changes in v5: None
> > Changes in v4: None
> > Changes in v3: None
> > Changes in v2: None
> >
> >  MAINTAINERS                    |  1 +
> >  drivers/net/mdio/Kconfig       |  9 ++++
> >  drivers/net/mdio/Makefile      |  3 +-
> >  drivers/net/mdio/fwnode_mdio.c | 77 ++++++++++++++++++++++++++++++++++
> >  drivers/net/mdio/of_mdio.c     |  3 +-
> >  include/linux/fwnode_mdio.h    | 24 +++++++++++
> >  include/linux/of_mdio.h        |  6 ++-
> >  7 files changed, 120 insertions(+), 3 deletions(-)
> >  create mode 100644 drivers/net/mdio/fwnode_mdio.c
> >  create mode 100644 include/linux/fwnode_mdio.h
> >
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index e1fa5ad9bb30..146de41d2656 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -6680,6 +6680,7 @@ F:        Documentation/devicetree/bindings/net/mdio*
> >  F:     Documentation/devicetree/bindings/net/qca,ar803x.yaml
> >  F:     Documentation/networking/phy.rst
> >  F:     drivers/net/mdio/
> > +F:     drivers/net/mdio/fwnode_mdio.c
> >  F:     drivers/net/mdio/of_mdio.c
> >  F:     drivers/net/pcs/
> >  F:     drivers/net/phy/
> > diff --git a/drivers/net/mdio/Kconfig b/drivers/net/mdio/Kconfig
> > index a10cc460d7cf..2d5bf5ccffb5 100644
> > --- a/drivers/net/mdio/Kconfig
> > +++ b/drivers/net/mdio/Kconfig
> > @@ -19,6 +19,15 @@ config MDIO_BUS
> >           reflects whether the mdio_bus/mdio_device code is built as a
> >           loadable module or built-in.
> >
> > +config FWNODE_MDIO
> > +       def_tristate PHYLIB
> 
> (Seems "selectable only" item)

What do you mean by "selectable only" item here? Can you please point to some
other example?

> 
> > +       depends on ACPI
> > +       depends on OF
> 
> Wouldn't be better to have
>   depends on (ACPI || OF) || COMPILE_TEST
> 
> And honestly I don't understand it in either (AND or OR) variant. Why
> do you need a dependency like this for fwnode API?

Here, fwnode_mdiobus_register_phy() uses objects from both ACPI and OF.

> 
> Moreover dependencies don't work for "selectable only" items.
> 
> > +       depends on PHYLIB
> > +       select FIXED_PHY
> > +       help
> > +         FWNODE MDIO bus (Ethernet PHY) accessors
> > +
> >  config OF_MDIO
> >         def_tristate PHYLIB
> >         depends on OF
> > diff --git a/drivers/net/mdio/Makefile b/drivers/net/mdio/Makefile
> > index 5c498dde463f..ea5390e2ef84 100644
> > --- a/drivers/net/mdio/Makefile
> > +++ b/drivers/net/mdio/Makefile
> > @@ -1,7 +1,8 @@
> >  # SPDX-License-Identifier: GPL-2.0
> >  # Makefile for Linux MDIO bus drivers
> >
> > -obj-$(CONFIG_OF_MDIO)  += of_mdio.o
> > +obj-$(CONFIG_FWNODE_MDIO)      += fwnode_mdio.o
> > +obj-$(CONFIG_OF_MDIO)          += of_mdio.o
> >
> >  obj-$(CONFIG_MDIO_ASPEED)              += mdio-aspeed.o
> >  obj-$(CONFIG_MDIO_BCM_IPROC)           += mdio-bcm-iproc.o
> > diff --git a/drivers/net/mdio/fwnode_mdio.c b/drivers/net/mdio/fwnode_mdio.c
> > new file mode 100644
> > index 000000000000..0982e816a6fb
> > --- /dev/null
> > +++ b/drivers/net/mdio/fwnode_mdio.c
> > @@ -0,0 +1,77 @@
> > +// SPDX-License-Identifier: GPL-2.0-only
> > +/*
> > + * fwnode helpers for the MDIO (Ethernet PHY) API
> > + *
> > + * This file provides helper functions for extracting PHY device information
> > + * out of the fwnode and using it to populate an mii_bus.
> > + */
> > +
> > +#include <linux/acpi.h>
> > +#include <linux/of.h>
> > +#include <linux/of_mdio.h>
> > +#include <linux/phy.h>
> > +
> > +MODULE_AUTHOR("Calvin Johnson <calvin.johnson@oss.nxp.com>");
> > +MODULE_LICENSE("GPL");
> > +
> > +int fwnode_mdiobus_register_phy(struct mii_bus *bus,
> > +                               struct fwnode_handle *child, u32 addr)
> > +{
> > +       struct mii_timestamper *mii_ts = NULL;
> > +       struct phy_device *phy;
> > +       bool is_c45 = false;
> > +       u32 phy_id;
> > +       int rc;
> > +
> > +       if (is_of_node(child)) {
> > +               mii_ts = of_find_mii_timestamper(to_of_node(child));
> > +               if (IS_ERR(mii_ts))
> > +                       return PTR_ERR(mii_ts);
> > +       }
> > +
> > +       rc = fwnode_property_match_string(child, "compatible", "ethernet-phy-ieee802.3-c45");
> > +       if (rc >= 0)
> > +               is_c45 = true;
> > +
> > +       if (is_c45 || fwnode_get_phy_id(child, &phy_id))
> > +               phy = get_phy_device(bus, addr, is_c45);
> > +       else
> > +               phy = phy_device_create(bus, addr, phy_id, 0, NULL);
> > +       if (IS_ERR(phy)) {
> > +               unregister_mii_timestamper(mii_ts);
> > +               return PTR_ERR(phy);
> > +       }
> > +
> > +       if (is_acpi_node(child)) {
> > +               phy->irq = bus->irq[addr];
> > +
> > +               /* Associate the fwnode with the device structure so it
> > +                * can be looked up later.
> > +                */
> > +               phy->mdio.dev.fwnode = child;
> > +
> > +               /* All data is now stored in the phy struct, so register it */
> > +               rc = phy_device_register(phy);
> > +               if (rc) {
> > +                       phy_device_free(phy);
> > +                       fwnode_handle_put(phy->mdio.dev.fwnode);
> > +                       return rc;
> > +               }
> > +       } else if (is_of_node(child)) {
> > +               rc = of_mdiobus_phy_device_register(bus, phy, to_of_node(child), addr);
> > +               if (rc) {
> > +                       unregister_mii_timestamper(mii_ts);
> > +                       phy_device_free(phy);
> > +                       return rc;
> > +               }
> > +       }
> > +
> > +       /* phy->mii_ts may already be defined by the PHY driver. A
> > +        * mii_timestamper probed via the device tree will still have
> > +        * precedence.
> > +        */
> > +       if (mii_ts)
> > +               phy->mii_ts = mii_ts;
> > +       return 0;
> > +}
> > +EXPORT_SYMBOL(fwnode_mdiobus_register_phy);
> > diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c
> > index 48b6b8458c17..db293e0b8249 100644
> > --- a/drivers/net/mdio/of_mdio.c
> > +++ b/drivers/net/mdio/of_mdio.c
> > @@ -32,7 +32,7 @@ static int of_get_phy_id(struct device_node *device, u32 *phy_id)
> >         return fwnode_get_phy_id(of_fwnode_handle(device), phy_id);
> >  }
> >
> > -static struct mii_timestamper *of_find_mii_timestamper(struct device_node *node)
> > +struct mii_timestamper *of_find_mii_timestamper(struct device_node *node)
> >  {
> >         struct of_phandle_args arg;
> >         int err;
> > @@ -49,6 +49,7 @@ static struct mii_timestamper *of_find_mii_timestamper(struct device_node *node)
> >
> >         return register_mii_timestamper(arg.np, arg.args[0]);
> >  }
> > +EXPORT_SYMBOL(of_find_mii_timestamper);
> >
> >  int of_mdiobus_phy_device_register(struct mii_bus *mdio, struct phy_device *phy,
> >                               struct device_node *child, u32 addr)
> > diff --git a/include/linux/fwnode_mdio.h b/include/linux/fwnode_mdio.h
> > new file mode 100644
> > index 000000000000..8c0392845916
> > --- /dev/null
> > +++ b/include/linux/fwnode_mdio.h
> > @@ -0,0 +1,24 @@
> > +/* SPDX-License-Identifier: GPL-2.0-only */
> > +/*
> > + * FWNODE helper for the MDIO (Ethernet PHY) API
> > + */
> > +
> > +#ifndef __LINUX_FWNODE_MDIO_H
> > +#define __LINUX_FWNODE_MDIO_H
> > +
> > +#include <linux/phy.h>
> > +
> > +#if IS_ENABLED(CONFIG_FWNODE_MDIO)
> > +int fwnode_mdiobus_register_phy(struct mii_bus *bus,
> > +                               struct fwnode_handle *child, u32 addr);
> > +
> > +#else /* CONFIG_FWNODE_MDIO */
> > +static inline int fwnode_mdiobus_register_phy(struct mii_bus *bus,
> > +                                             struct fwnode_handle *child,
> > +                                             u32 addr)
> > +{
> > +       return -EINVAL;
> > +}
> > +#endif
> > +
> > +#endif /* __LINUX_FWNODE_MDIO_H */
> > diff --git a/include/linux/of_mdio.h b/include/linux/of_mdio.h
> > index 2b05e7f7c238..e4ee6c4d9431 100644
> > --- a/include/linux/of_mdio.h
> > +++ b/include/linux/of_mdio.h
> > @@ -31,6 +31,7 @@ struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np);
> >  int of_phy_register_fixed_link(struct device_node *np);
> >  void of_phy_deregister_fixed_link(struct device_node *np);
> >  bool of_phy_is_fixed_link(struct device_node *np);
> > +struct mii_timestamper *of_find_mii_timestamper(struct device_node *np);
> >  int of_mdiobus_phy_device_register(struct mii_bus *mdio, struct phy_device *phy,
> >                                    struct device_node *child, u32 addr);
> >
> > @@ -118,7 +119,10 @@ static inline bool of_phy_is_fixed_link(struct device_node *np)
> >  {
> >         return false;
> >  }
> > -
> > +static inline struct mii_timestamper *of_find_mii_timestamper(struct device_node *np)
> > +{
> > +       return NULL;
> > +}
> >  static inline int of_mdiobus_phy_device_register(struct mii_bus *mdio,
> >                                             struct phy_device *phy,
> >                                             struct device_node *child, u32 addr)
> > --
> > 2.17.1
> >
> 
> 
Regards
Calvin


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

* Re: [net-next PATCH v7 08/16] net: mdiobus: Introduce fwnode_mdiobus_register_phy()
@ 2021-03-11 18:00       ` Calvin Johnson
  0 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-11 18:00 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Florian Fainelli, Russell King - ARM Linux admin,
	Cristi Sovaiala, Florin Laurentiu Chiculita, Ioana Ciornei,
	Madalin Bucur, Heikki Krogerus, Marcin Wojtas,
	Pieter Jansen Van Vuuren, Jon, Saravana Kannan, Randy Dunlap,
	linux-arm Mailing List, Diana Madalina Craciun,
	ACPI Devel Maling List, Linux Kernel Mailing List, linux.cj,
	netdev, Laurentiu Tudor, David S. Miller, Frank Rowand,
	Heiner Kallweit, Jakub Kicinski, Rob Herring, devicetree

On Thu, Mar 11, 2021 at 02:09:37PM +0200, Andy Shevchenko wrote:
> On Thu, Mar 11, 2021 at 8:21 AM Calvin Johnson
> <calvin.johnson@oss.nxp.com> wrote:
> >
> > Introduce fwnode_mdiobus_register_phy() to register PHYs on the
> > mdiobus. From the compatible string, identify whether the PHY is
> > c45 and based on this create a PHY device instance which is
> > registered on the mdiobus.
> 
> > uninitialized symbol 'mii_ts'
> > Reported-by: kernel test robot <lkp@intel.com>
> > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> I don't think it's important to have it in a history of Git. I would
> move this after the cutter '---' line below.

Sorry. I thought I had removed it. Will definitely take care next time.

> 
> > Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
> > ---
> >
> > Changes in v7:
> > - Call unregister_mii_timestamper() without NULL check
> > - Create fwnode_mdio.c and move fwnode_mdiobus_register_phy()
> >
> > Changes in v6:
> > - Initialize mii_ts to NULL
> >
> > Changes in v5: None
> > Changes in v4: None
> > Changes in v3: None
> > Changes in v2: None
> >
> >  MAINTAINERS                    |  1 +
> >  drivers/net/mdio/Kconfig       |  9 ++++
> >  drivers/net/mdio/Makefile      |  3 +-
> >  drivers/net/mdio/fwnode_mdio.c | 77 ++++++++++++++++++++++++++++++++++
> >  drivers/net/mdio/of_mdio.c     |  3 +-
> >  include/linux/fwnode_mdio.h    | 24 +++++++++++
> >  include/linux/of_mdio.h        |  6 ++-
> >  7 files changed, 120 insertions(+), 3 deletions(-)
> >  create mode 100644 drivers/net/mdio/fwnode_mdio.c
> >  create mode 100644 include/linux/fwnode_mdio.h
> >
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index e1fa5ad9bb30..146de41d2656 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -6680,6 +6680,7 @@ F:        Documentation/devicetree/bindings/net/mdio*
> >  F:     Documentation/devicetree/bindings/net/qca,ar803x.yaml
> >  F:     Documentation/networking/phy.rst
> >  F:     drivers/net/mdio/
> > +F:     drivers/net/mdio/fwnode_mdio.c
> >  F:     drivers/net/mdio/of_mdio.c
> >  F:     drivers/net/pcs/
> >  F:     drivers/net/phy/
> > diff --git a/drivers/net/mdio/Kconfig b/drivers/net/mdio/Kconfig
> > index a10cc460d7cf..2d5bf5ccffb5 100644
> > --- a/drivers/net/mdio/Kconfig
> > +++ b/drivers/net/mdio/Kconfig
> > @@ -19,6 +19,15 @@ config MDIO_BUS
> >           reflects whether the mdio_bus/mdio_device code is built as a
> >           loadable module or built-in.
> >
> > +config FWNODE_MDIO
> > +       def_tristate PHYLIB
> 
> (Seems "selectable only" item)

What do you mean by "selectable only" item here? Can you please point to some
other example?

> 
> > +       depends on ACPI
> > +       depends on OF
> 
> Wouldn't be better to have
>   depends on (ACPI || OF) || COMPILE_TEST
> 
> And honestly I don't understand it in either (AND or OR) variant. Why
> do you need a dependency like this for fwnode API?

Here, fwnode_mdiobus_register_phy() uses objects from both ACPI and OF.

> 
> Moreover dependencies don't work for "selectable only" items.
> 
> > +       depends on PHYLIB
> > +       select FIXED_PHY
> > +       help
> > +         FWNODE MDIO bus (Ethernet PHY) accessors
> > +
> >  config OF_MDIO
> >         def_tristate PHYLIB
> >         depends on OF
> > diff --git a/drivers/net/mdio/Makefile b/drivers/net/mdio/Makefile
> > index 5c498dde463f..ea5390e2ef84 100644
> > --- a/drivers/net/mdio/Makefile
> > +++ b/drivers/net/mdio/Makefile
> > @@ -1,7 +1,8 @@
> >  # SPDX-License-Identifier: GPL-2.0
> >  # Makefile for Linux MDIO bus drivers
> >
> > -obj-$(CONFIG_OF_MDIO)  += of_mdio.o
> > +obj-$(CONFIG_FWNODE_MDIO)      += fwnode_mdio.o
> > +obj-$(CONFIG_OF_MDIO)          += of_mdio.o
> >
> >  obj-$(CONFIG_MDIO_ASPEED)              += mdio-aspeed.o
> >  obj-$(CONFIG_MDIO_BCM_IPROC)           += mdio-bcm-iproc.o
> > diff --git a/drivers/net/mdio/fwnode_mdio.c b/drivers/net/mdio/fwnode_mdio.c
> > new file mode 100644
> > index 000000000000..0982e816a6fb
> > --- /dev/null
> > +++ b/drivers/net/mdio/fwnode_mdio.c
> > @@ -0,0 +1,77 @@
> > +// SPDX-License-Identifier: GPL-2.0-only
> > +/*
> > + * fwnode helpers for the MDIO (Ethernet PHY) API
> > + *
> > + * This file provides helper functions for extracting PHY device information
> > + * out of the fwnode and using it to populate an mii_bus.
> > + */
> > +
> > +#include <linux/acpi.h>
> > +#include <linux/of.h>
> > +#include <linux/of_mdio.h>
> > +#include <linux/phy.h>
> > +
> > +MODULE_AUTHOR("Calvin Johnson <calvin.johnson@oss.nxp.com>");
> > +MODULE_LICENSE("GPL");
> > +
> > +int fwnode_mdiobus_register_phy(struct mii_bus *bus,
> > +                               struct fwnode_handle *child, u32 addr)
> > +{
> > +       struct mii_timestamper *mii_ts = NULL;
> > +       struct phy_device *phy;
> > +       bool is_c45 = false;
> > +       u32 phy_id;
> > +       int rc;
> > +
> > +       if (is_of_node(child)) {
> > +               mii_ts = of_find_mii_timestamper(to_of_node(child));
> > +               if (IS_ERR(mii_ts))
> > +                       return PTR_ERR(mii_ts);
> > +       }
> > +
> > +       rc = fwnode_property_match_string(child, "compatible", "ethernet-phy-ieee802.3-c45");
> > +       if (rc >= 0)
> > +               is_c45 = true;
> > +
> > +       if (is_c45 || fwnode_get_phy_id(child, &phy_id))
> > +               phy = get_phy_device(bus, addr, is_c45);
> > +       else
> > +               phy = phy_device_create(bus, addr, phy_id, 0, NULL);
> > +       if (IS_ERR(phy)) {
> > +               unregister_mii_timestamper(mii_ts);
> > +               return PTR_ERR(phy);
> > +       }
> > +
> > +       if (is_acpi_node(child)) {
> > +               phy->irq = bus->irq[addr];
> > +
> > +               /* Associate the fwnode with the device structure so it
> > +                * can be looked up later.
> > +                */
> > +               phy->mdio.dev.fwnode = child;
> > +
> > +               /* All data is now stored in the phy struct, so register it */
> > +               rc = phy_device_register(phy);
> > +               if (rc) {
> > +                       phy_device_free(phy);
> > +                       fwnode_handle_put(phy->mdio.dev.fwnode);
> > +                       return rc;
> > +               }
> > +       } else if (is_of_node(child)) {
> > +               rc = of_mdiobus_phy_device_register(bus, phy, to_of_node(child), addr);
> > +               if (rc) {
> > +                       unregister_mii_timestamper(mii_ts);
> > +                       phy_device_free(phy);
> > +                       return rc;
> > +               }
> > +       }
> > +
> > +       /* phy->mii_ts may already be defined by the PHY driver. A
> > +        * mii_timestamper probed via the device tree will still have
> > +        * precedence.
> > +        */
> > +       if (mii_ts)
> > +               phy->mii_ts = mii_ts;
> > +       return 0;
> > +}
> > +EXPORT_SYMBOL(fwnode_mdiobus_register_phy);
> > diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c
> > index 48b6b8458c17..db293e0b8249 100644
> > --- a/drivers/net/mdio/of_mdio.c
> > +++ b/drivers/net/mdio/of_mdio.c
> > @@ -32,7 +32,7 @@ static int of_get_phy_id(struct device_node *device, u32 *phy_id)
> >         return fwnode_get_phy_id(of_fwnode_handle(device), phy_id);
> >  }
> >
> > -static struct mii_timestamper *of_find_mii_timestamper(struct device_node *node)
> > +struct mii_timestamper *of_find_mii_timestamper(struct device_node *node)
> >  {
> >         struct of_phandle_args arg;
> >         int err;
> > @@ -49,6 +49,7 @@ static struct mii_timestamper *of_find_mii_timestamper(struct device_node *node)
> >
> >         return register_mii_timestamper(arg.np, arg.args[0]);
> >  }
> > +EXPORT_SYMBOL(of_find_mii_timestamper);
> >
> >  int of_mdiobus_phy_device_register(struct mii_bus *mdio, struct phy_device *phy,
> >                               struct device_node *child, u32 addr)
> > diff --git a/include/linux/fwnode_mdio.h b/include/linux/fwnode_mdio.h
> > new file mode 100644
> > index 000000000000..8c0392845916
> > --- /dev/null
> > +++ b/include/linux/fwnode_mdio.h
> > @@ -0,0 +1,24 @@
> > +/* SPDX-License-Identifier: GPL-2.0-only */
> > +/*
> > + * FWNODE helper for the MDIO (Ethernet PHY) API
> > + */
> > +
> > +#ifndef __LINUX_FWNODE_MDIO_H
> > +#define __LINUX_FWNODE_MDIO_H
> > +
> > +#include <linux/phy.h>
> > +
> > +#if IS_ENABLED(CONFIG_FWNODE_MDIO)
> > +int fwnode_mdiobus_register_phy(struct mii_bus *bus,
> > +                               struct fwnode_handle *child, u32 addr);
> > +
> > +#else /* CONFIG_FWNODE_MDIO */
> > +static inline int fwnode_mdiobus_register_phy(struct mii_bus *bus,
> > +                                             struct fwnode_handle *child,
> > +                                             u32 addr)
> > +{
> > +       return -EINVAL;
> > +}
> > +#endif
> > +
> > +#endif /* __LINUX_FWNODE_MDIO_H */
> > diff --git a/include/linux/of_mdio.h b/include/linux/of_mdio.h
> > index 2b05e7f7c238..e4ee6c4d9431 100644
> > --- a/include/linux/of_mdio.h
> > +++ b/include/linux/of_mdio.h
> > @@ -31,6 +31,7 @@ struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np);
> >  int of_phy_register_fixed_link(struct device_node *np);
> >  void of_phy_deregister_fixed_link(struct device_node *np);
> >  bool of_phy_is_fixed_link(struct device_node *np);
> > +struct mii_timestamper *of_find_mii_timestamper(struct device_node *np);
> >  int of_mdiobus_phy_device_register(struct mii_bus *mdio, struct phy_device *phy,
> >                                    struct device_node *child, u32 addr);
> >
> > @@ -118,7 +119,10 @@ static inline bool of_phy_is_fixed_link(struct device_node *np)
> >  {
> >         return false;
> >  }
> > -
> > +static inline struct mii_timestamper *of_find_mii_timestamper(struct device_node *np)
> > +{
> > +       return NULL;
> > +}
> >  static inline int of_mdiobus_phy_device_register(struct mii_bus *mdio,
> >                                             struct phy_device *phy,
> >                                             struct device_node *child, u32 addr)
> > --
> > 2.17.1
> >
> 
> 
Regards
Calvin


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [net-next PATCH v7 08/16] net: mdiobus: Introduce fwnode_mdiobus_register_phy()
  2021-03-11 18:00       ` Calvin Johnson
@ 2021-03-11 18:14         ` Andy Shevchenko
  -1 siblings, 0 replies; 64+ messages in thread
From: Andy Shevchenko @ 2021-03-11 18:14 UTC (permalink / raw)
  To: Calvin Johnson
  Cc: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Florian Fainelli, Russell King - ARM Linux admin,
	Cristi Sovaiala, Florin Laurentiu Chiculita, Ioana Ciornei,
	Madalin Bucur, Heikki Krogerus, Marcin Wojtas,
	Pieter Jansen Van Vuuren, Jon, Saravana Kannan, Randy Dunlap,
	linux-arm Mailing List, Diana Madalina Craciun,
	ACPI Devel Maling List, Linux Kernel Mailing List, linux.cj,
	netdev, Laurentiu Tudor, David S. Miller, Frank Rowand,
	Heiner Kallweit, Jakub Kicinski, Rob Herring, devicetree

On Thu, Mar 11, 2021 at 8:00 PM Calvin Johnson
<calvin.johnson@oss.nxp.com> wrote:
> On Thu, Mar 11, 2021 at 02:09:37PM +0200, Andy Shevchenko wrote:
> > On Thu, Mar 11, 2021 at 8:21 AM Calvin Johnson
> > <calvin.johnson@oss.nxp.com> wrote:

...

> > > +config FWNODE_MDIO
> > > +       def_tristate PHYLIB
> >
> > (Seems "selectable only" item)
>
> What do you mean by "selectable only" item here? Can you please point to some
> other example?

The Kconfig sections without descriptions are not user-visible.
No user can run menuconfig and check a box with "I want this to be compiled".

tristate // selectable-only
tristate "bla bla bla" // user visible and selectable

> > > +       depends on ACPI
> > > +       depends on OF
> >
> > Wouldn't be better to have
> >   depends on (ACPI || OF) || COMPILE_TEST
> >
> > And honestly I don't understand it in either (AND or OR) variant. Why
> > do you need a dependency like this for fwnode API?
>
> Here, fwnode_mdiobus_register_phy() uses objects from both ACPI and OF.

APIs? Calls? What really fails if we have !ACPI and / or !OF?

> > Moreover dependencies don't work for "selectable only" items.
> >
> > > +       depends on PHYLIB
> > > +       select FIXED_PHY

--
With Best Regards,
Andy Shevchenko

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

* Re: [net-next PATCH v7 08/16] net: mdiobus: Introduce fwnode_mdiobus_register_phy()
@ 2021-03-11 18:14         ` Andy Shevchenko
  0 siblings, 0 replies; 64+ messages in thread
From: Andy Shevchenko @ 2021-03-11 18:14 UTC (permalink / raw)
  To: Calvin Johnson
  Cc: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Florian Fainelli, Russell King - ARM Linux admin,
	Cristi Sovaiala, Florin Laurentiu Chiculita, Ioana Ciornei,
	Madalin Bucur, Heikki Krogerus, Marcin Wojtas,
	Pieter Jansen Van Vuuren, Jon, Saravana Kannan, Randy Dunlap,
	linux-arm Mailing List, Diana Madalina Craciun,
	ACPI Devel Maling List, Linux Kernel Mailing List, linux.cj,
	netdev, Laurentiu Tudor, David S. Miller, Frank Rowand,
	Heiner Kallweit, Jakub Kicinski, Rob Herring, devicetree

On Thu, Mar 11, 2021 at 8:00 PM Calvin Johnson
<calvin.johnson@oss.nxp.com> wrote:
> On Thu, Mar 11, 2021 at 02:09:37PM +0200, Andy Shevchenko wrote:
> > On Thu, Mar 11, 2021 at 8:21 AM Calvin Johnson
> > <calvin.johnson@oss.nxp.com> wrote:

...

> > > +config FWNODE_MDIO
> > > +       def_tristate PHYLIB
> >
> > (Seems "selectable only" item)
>
> What do you mean by "selectable only" item here? Can you please point to some
> other example?

The Kconfig sections without descriptions are not user-visible.
No user can run menuconfig and check a box with "I want this to be compiled".

tristate // selectable-only
tristate "bla bla bla" // user visible and selectable

> > > +       depends on ACPI
> > > +       depends on OF
> >
> > Wouldn't be better to have
> >   depends on (ACPI || OF) || COMPILE_TEST
> >
> > And honestly I don't understand it in either (AND or OR) variant. Why
> > do you need a dependency like this for fwnode API?
>
> Here, fwnode_mdiobus_register_phy() uses objects from both ACPI and OF.

APIs? Calls? What really fails if we have !ACPI and / or !OF?

> > Moreover dependencies don't work for "selectable only" items.
> >
> > > +       depends on PHYLIB
> > > +       select FIXED_PHY

--
With Best Regards,
Andy Shevchenko

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [net-next PATCH v7 08/16] net: mdiobus: Introduce fwnode_mdiobus_register_phy()
  2021-03-11  6:20   ` Calvin Johnson
  (?)
  (?)
@ 2021-03-11 23:29   ` kernel test robot
  -1 siblings, 0 replies; 64+ messages in thread
From: kernel test robot @ 2021-03-11 23:29 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2150 bytes --]

Hi Calvin,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Calvin-Johnson/ACPI-support-for-dpaa2-driver/20210311-142527
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 34bb975126419e86bc3b95e200dc41de6c6ca69c
config: x86_64-randconfig-a013-20210311 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 574a9dabc63ba1e7a04c08d4bde2eacd61b44ce1)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # https://github.com/0day-ci/linux/commit/d6150b3cf85a42cb75a1d93b64ce7cdf8e58d4d9
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Calvin-Johnson/ACPI-support-for-dpaa2-driver/20210311-142527
        git checkout d6150b3cf85a42cb75a1d93b64ce7cdf8e58d4d9
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/net/mdio/fwnode_mdio.c:17:5: warning: no previous prototype for function 'fwnode_mdiobus_register_phy' [-Wmissing-prototypes]
   int fwnode_mdiobus_register_phy(struct mii_bus *bus,
       ^
   drivers/net/mdio/fwnode_mdio.c:17:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   int fwnode_mdiobus_register_phy(struct mii_bus *bus,
   ^
   static 
   1 warning generated.


vim +/fwnode_mdiobus_register_phy +17 drivers/net/mdio/fwnode_mdio.c

    16	
  > 17	int fwnode_mdiobus_register_phy(struct mii_bus *bus,

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 38568 bytes --]

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

* Re: [net-next PATCH v7 12/16] net: mdiobus: Introduce fwnode_mdiobus_register()
  2021-03-11  6:20   ` Calvin Johnson
  (?)
@ 2021-03-12  0:46   ` kernel test robot
  -1 siblings, 0 replies; 64+ messages in thread
From: kernel test robot @ 2021-03-12  0:46 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 4991 bytes --]

Hi Calvin,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Calvin-Johnson/ACPI-support-for-dpaa2-driver/20210311-142527
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 34bb975126419e86bc3b95e200dc41de6c6ca69c
config: x86_64-randconfig-a013-20210311 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 574a9dabc63ba1e7a04c08d4bde2eacd61b44ce1)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # https://github.com/0day-ci/linux/commit/fc2494f709d3130a0c1dbb4d3769904ee869185b
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Calvin-Johnson/ACPI-support-for-dpaa2-driver/20210311-142527
        git checkout fc2494f709d3130a0c1dbb4d3769904ee869185b
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/net/mdio/fwnode_mdio.c:18:5: warning: no previous prototype for function 'fwnode_mdiobus_register_phy' [-Wmissing-prototypes]
   int fwnode_mdiobus_register_phy(struct mii_bus *bus,
       ^
   drivers/net/mdio/fwnode_mdio.c:18:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   int fwnode_mdiobus_register_phy(struct mii_bus *bus,
   ^
   static 
>> drivers/net/mdio/fwnode_mdio.c:88:5: warning: no previous prototype for function 'fwnode_mdiobus_register' [-Wmissing-prototypes]
   int fwnode_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode)
       ^
   drivers/net/mdio/fwnode_mdio.c:88:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   int fwnode_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode)
   ^
   static 
   2 warnings generated.


vim +/fwnode_mdiobus_register +88 drivers/net/mdio/fwnode_mdio.c

    17	
  > 18	int fwnode_mdiobus_register_phy(struct mii_bus *bus,
    19					struct fwnode_handle *child, u32 addr)
    20	{
    21		struct mii_timestamper *mii_ts = NULL;
    22		struct phy_device *phy;
    23		bool is_c45 = false;
    24		u32 phy_id;
    25		int rc;
    26	
    27		if (is_of_node(child)) {
    28			mii_ts = of_find_mii_timestamper(to_of_node(child));
    29			if (IS_ERR(mii_ts))
    30				return PTR_ERR(mii_ts);
    31		}
    32	
    33		rc = fwnode_property_match_string(child, "compatible", "ethernet-phy-ieee802.3-c45");
    34		if (rc >= 0)
    35			is_c45 = true;
    36	
    37		if (is_c45 || fwnode_get_phy_id(child, &phy_id))
    38			phy = get_phy_device(bus, addr, is_c45);
    39		else
    40			phy = phy_device_create(bus, addr, phy_id, 0, NULL);
    41		if (IS_ERR(phy)) {
    42			unregister_mii_timestamper(mii_ts);
    43			return PTR_ERR(phy);
    44		}
    45	
    46		if (is_acpi_node(child)) {
    47			phy->irq = bus->irq[addr];
    48	
    49			/* Associate the fwnode with the device structure so it
    50			 * can be looked up later.
    51			 */
    52			phy->mdio.dev.fwnode = child;
    53	
    54			/* All data is now stored in the phy struct, so register it */
    55			rc = phy_device_register(phy);
    56			if (rc) {
    57				phy_device_free(phy);
    58				fwnode_handle_put(phy->mdio.dev.fwnode);
    59				return rc;
    60			}
    61		} else if (is_of_node(child)) {
    62			rc = of_mdiobus_phy_device_register(bus, phy, to_of_node(child), addr);
    63			if (rc) {
    64				unregister_mii_timestamper(mii_ts);
    65				phy_device_free(phy);
    66				return rc;
    67			}
    68		}
    69	
    70		/* phy->mii_ts may already be defined by the PHY driver. A
    71		 * mii_timestamper probed via the device tree will still have
    72		 * precedence.
    73		 */
    74		if (mii_ts)
    75			phy->mii_ts = mii_ts;
    76		return 0;
    77	}
    78	EXPORT_SYMBOL(fwnode_mdiobus_register_phy);
    79	
    80	/**
    81	 * fwnode_mdiobus_register - Register mii_bus and create PHYs from fwnode
    82	 * @mdio: pointer to mii_bus structure
    83	 * @fwnode: pointer to fwnode of MDIO bus.
    84	 *
    85	 * This function returns of_mdiobus_register() for DT and
    86	 * acpi_mdiobus_register() for ACPI.
    87	 */
  > 88	int fwnode_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode)

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 38572 bytes --]

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

* Re: [net-next PATCH v7 11/16] net: mdio: Add ACPI support code for mdio
  2021-03-11 12:14     ` Andy Shevchenko
@ 2021-03-15 10:21       ` Calvin Johnson
  -1 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-15 10:21 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Florian Fainelli, Russell King - ARM Linux admin,
	Cristi Sovaiala, Florin Laurentiu Chiculita, Ioana Ciornei,
	Madalin Bucur, Heikki Krogerus, Marcin Wojtas,
	Pieter Jansen Van Vuuren, Jon, Saravana Kannan, Randy Dunlap,
	linux-arm Mailing List, Diana Madalina Craciun,
	ACPI Devel Maling List, Linux Kernel Mailing List, linux.cj,
	netdev, Laurentiu Tudor, David S. Miller, Heiner Kallweit,
	Jakub Kicinski

On Thu, Mar 11, 2021 at 02:14:37PM +0200, Andy Shevchenko wrote:
> On Thu, Mar 11, 2021 at 8:22 AM Calvin Johnson
> <calvin.johnson@oss.nxp.com> wrote:
> >
> > Define acpi_mdiobus_register() to Register mii_bus and create PHYs for
> > each ACPI child node.
> >
> > Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
> > ---
> >
> > Changes in v7:
> > - Include headers directly used in acpi_mdio.c
> >
> > Changes in v6:
> > - use GENMASK() and ACPI_COMPANION_SET()
> > - some cleanup
> > - remove unwanted header inclusion
> >
> > Changes in v5:
> > - add missing MODULE_LICENSE()
> > - replace fwnode_get_id() with OF and ACPI function calls
> >
> > Changes in v4: None
> > Changes in v3: None
> > Changes in v2: None
> >
> >  MAINTAINERS                  |  1 +
> >  drivers/net/mdio/Kconfig     |  7 +++++
> >  drivers/net/mdio/Makefile    |  1 +
> >  drivers/net/mdio/acpi_mdio.c | 56 ++++++++++++++++++++++++++++++++++++
> >  include/linux/acpi_mdio.h    | 25 ++++++++++++++++
> >  5 files changed, 90 insertions(+)
> >  create mode 100644 drivers/net/mdio/acpi_mdio.c
> >  create mode 100644 include/linux/acpi_mdio.h
> >
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index 146de41d2656..051377b7fa94 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -6680,6 +6680,7 @@ F:        Documentation/devicetree/bindings/net/mdio*
> >  F:     Documentation/devicetree/bindings/net/qca,ar803x.yaml
> >  F:     Documentation/networking/phy.rst
> >  F:     drivers/net/mdio/
> > +F:     drivers/net/mdio/acpi_mdio.c
> >  F:     drivers/net/mdio/fwnode_mdio.c
> >  F:     drivers/net/mdio/of_mdio.c
> >  F:     drivers/net/pcs/
> > diff --git a/drivers/net/mdio/Kconfig b/drivers/net/mdio/Kconfig
> > index 2d5bf5ccffb5..fc8c787b448f 100644
> > --- a/drivers/net/mdio/Kconfig
> > +++ b/drivers/net/mdio/Kconfig
> > @@ -36,6 +36,13 @@ config OF_MDIO
> >         help
> >           OpenFirmware MDIO bus (Ethernet PHY) accessors
> >
> > +config ACPI_MDIO
> > +       def_tristate PHYLIB
> 
> > +       depends on ACPI
> > +       depends on PHYLIB
> 
> Same issue, they are no-ops.
> 
> I guess you have to surround OF and ACPI and FWNODE variants by
> 
> if PHYLIB
> ...
> endif
> 
> This will be an equivalent to depends on PHYLIB
> 
> and put this into Makefile
> 
> ifneq ($(CONFIG_ACPI),)
> obj-$(CONFIG_PHYLIB) += acpi_mdio.o
> endif
> 
> This will give you the rest, i.e. default PHYLIB + depends on ACPI
> 
> Similar for OF
> 

I checked the effect of y/n/m choice of PHYLIB on FWNODE_MDIO.
As expected with def_tristate, whenever PHYLIB changes to y/n/m corresponding
change is reflected on FWNODE_MDIO, also considering the state of other
depending CONFIGS like OF and ACPI.

Symbol: FWNODE_MDIO [=n]
│
  │ Type  : tristate
│
  │ Defined at drivers/net/mdio/Kconfig:22
│
  │   Depends on: NETDEVICES [=y] && MDIO_DEVICE [=y] && ACPI [=y] && OF [=y] &&
PHYLIB [=n]                                                          │
  │ Selects: FIXED_PHY [=n]

Effect is similar for ACPI_MDIO and OF_MDIO.

So instead of above proposed method, I think what you proposed in your earlier
email, i.e, "depends on (ACPI || OF) || COMPILE_TEST" seems to be better for
FWNODE_MDIO.

Shall we go ahead with this?

Regards
Calvin

> > +       help
> > +         ACPI MDIO bus (Ethernet PHY) accessors
> > +
> >  if MDIO_BUS
> >
> >  config MDIO_DEVRES
> > diff --git a/drivers/net/mdio/Makefile b/drivers/net/mdio/Makefile
> > index ea5390e2ef84..e8b739a3df1c 100644
> > --- a/drivers/net/mdio/Makefile
> > +++ b/drivers/net/mdio/Makefile
> > @@ -1,6 +1,7 @@
> >  # SPDX-License-Identifier: GPL-2.0
> >  # Makefile for Linux MDIO bus drivers
> >
> > +obj-$(CONFIG_ACPI_MDIO)                += acpi_mdio.o
> >  obj-$(CONFIG_FWNODE_MDIO)      += fwnode_mdio.o
> >  obj-$(CONFIG_OF_MDIO)          += of_mdio.o
> >
> > diff --git a/drivers/net/mdio/acpi_mdio.c b/drivers/net/mdio/acpi_mdio.c
> > new file mode 100644
> > index 000000000000..60a86e3fc246
> > --- /dev/null
> > +++ b/drivers/net/mdio/acpi_mdio.c
> > @@ -0,0 +1,56 @@
> > +// SPDX-License-Identifier: GPL-2.0-only
> > +/*
> > + * ACPI helpers for the MDIO (Ethernet PHY) API
> > + *
> > + * This file provides helper functions for extracting PHY device information
> > + * out of the ACPI ASL and using it to populate an mii_bus.
> > + */
> > +
> > +#include <linux/acpi.h>
> > +#include <linux/acpi_mdio.h>
> > +#include <linux/bits.h>
> > +#include <linux/dev_printk.h>
> > +#include <linux/fwnode_mdio.h>
> > +#include <linux/module.h>
> > +#include <linux/types.h>
> > +
> > +MODULE_AUTHOR("Calvin Johnson <calvin.johnson@oss.nxp.com>");
> > +MODULE_LICENSE("GPL");
> > +
> > +/**
> > + * acpi_mdiobus_register - Register mii_bus and create PHYs from the ACPI ASL.
> > + * @mdio: pointer to mii_bus structure
> > + * @fwnode: pointer to fwnode of MDIO bus.
> > + *
> > + * This function registers the mii_bus structure and registers a phy_device
> > + * for each child node of @fwnode.
> > + */
> > +int acpi_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode)
> > +{
> > +       struct fwnode_handle *child;
> > +       u32 addr;
> > +       int ret;
> > +
> > +       /* Mask out all PHYs from auto probing. */
> > +       mdio->phy_mask = GENMASK(31, 0);
> > +       ret = mdiobus_register(mdio);
> > +       if (ret)
> > +               return ret;
> > +
> > +       ACPI_COMPANION_SET(&mdio->dev, to_acpi_device_node(fwnode));
> > +
> > +       /* Loop over the child nodes and register a phy_device for each PHY */
> > +       fwnode_for_each_child_node(fwnode, child) {
> > +               ret = acpi_get_local_address(ACPI_HANDLE_FWNODE(child), &addr);
> > +               if (ret || addr >= PHY_MAX_ADDR)
> > +                       continue;
> > +
> > +               ret = fwnode_mdiobus_register_phy(mdio, child, addr);
> > +               if (ret == -ENODEV)
> > +                       dev_err(&mdio->dev,
> > +                               "MDIO device at address %d is missing.\n",
> > +                               addr);
> > +       }
> > +       return 0;
> > +}
> > +EXPORT_SYMBOL(acpi_mdiobus_register);
> > diff --git a/include/linux/acpi_mdio.h b/include/linux/acpi_mdio.h
> > new file mode 100644
> > index 000000000000..748d261fe2f9
> > --- /dev/null
> > +++ b/include/linux/acpi_mdio.h
> > @@ -0,0 +1,25 @@
> > +/* SPDX-License-Identifier: GPL-2.0-only */
> > +/*
> > + * ACPI helper for the MDIO (Ethernet PHY) API
> > + */
> > +
> > +#ifndef __LINUX_ACPI_MDIO_H
> > +#define __LINUX_ACPI_MDIO_H
> > +
> > +#include <linux/phy.h>
> > +
> > +#if IS_ENABLED(CONFIG_ACPI_MDIO)
> > +int acpi_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode);
> > +#else /* CONFIG_ACPI_MDIO */
> > +static inline int acpi_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode)
> > +{
> > +       /*
> > +        * Fall back to mdiobus_register() function to register a bus.
> > +        * This way, we don't have to keep compat bits around in drivers.
> > +        */
> > +
> > +       return mdiobus_register(mdio);
> > +}
> > +#endif
> > +
> > +#endif /* __LINUX_ACPI_MDIO_H */
> > --
> > 2.17.1
> >
> 
> 
> -- 
> With Best Regards,
> Andy Shevchenko

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

* Re: [net-next PATCH v7 11/16] net: mdio: Add ACPI support code for mdio
@ 2021-03-15 10:21       ` Calvin Johnson
  0 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-15 10:21 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Florian Fainelli, Russell King - ARM Linux admin,
	Cristi Sovaiala, Florin Laurentiu Chiculita, Ioana Ciornei,
	Madalin Bucur, Heikki Krogerus, Marcin Wojtas,
	Pieter Jansen Van Vuuren, Jon, Saravana Kannan, Randy Dunlap,
	linux-arm Mailing List, Diana Madalina Craciun,
	ACPI Devel Maling List, Linux Kernel Mailing List, linux.cj,
	netdev, Laurentiu Tudor, David S. Miller, Heiner Kallweit,
	Jakub Kicinski

On Thu, Mar 11, 2021 at 02:14:37PM +0200, Andy Shevchenko wrote:
> On Thu, Mar 11, 2021 at 8:22 AM Calvin Johnson
> <calvin.johnson@oss.nxp.com> wrote:
> >
> > Define acpi_mdiobus_register() to Register mii_bus and create PHYs for
> > each ACPI child node.
> >
> > Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
> > ---
> >
> > Changes in v7:
> > - Include headers directly used in acpi_mdio.c
> >
> > Changes in v6:
> > - use GENMASK() and ACPI_COMPANION_SET()
> > - some cleanup
> > - remove unwanted header inclusion
> >
> > Changes in v5:
> > - add missing MODULE_LICENSE()
> > - replace fwnode_get_id() with OF and ACPI function calls
> >
> > Changes in v4: None
> > Changes in v3: None
> > Changes in v2: None
> >
> >  MAINTAINERS                  |  1 +
> >  drivers/net/mdio/Kconfig     |  7 +++++
> >  drivers/net/mdio/Makefile    |  1 +
> >  drivers/net/mdio/acpi_mdio.c | 56 ++++++++++++++++++++++++++++++++++++
> >  include/linux/acpi_mdio.h    | 25 ++++++++++++++++
> >  5 files changed, 90 insertions(+)
> >  create mode 100644 drivers/net/mdio/acpi_mdio.c
> >  create mode 100644 include/linux/acpi_mdio.h
> >
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index 146de41d2656..051377b7fa94 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -6680,6 +6680,7 @@ F:        Documentation/devicetree/bindings/net/mdio*
> >  F:     Documentation/devicetree/bindings/net/qca,ar803x.yaml
> >  F:     Documentation/networking/phy.rst
> >  F:     drivers/net/mdio/
> > +F:     drivers/net/mdio/acpi_mdio.c
> >  F:     drivers/net/mdio/fwnode_mdio.c
> >  F:     drivers/net/mdio/of_mdio.c
> >  F:     drivers/net/pcs/
> > diff --git a/drivers/net/mdio/Kconfig b/drivers/net/mdio/Kconfig
> > index 2d5bf5ccffb5..fc8c787b448f 100644
> > --- a/drivers/net/mdio/Kconfig
> > +++ b/drivers/net/mdio/Kconfig
> > @@ -36,6 +36,13 @@ config OF_MDIO
> >         help
> >           OpenFirmware MDIO bus (Ethernet PHY) accessors
> >
> > +config ACPI_MDIO
> > +       def_tristate PHYLIB
> 
> > +       depends on ACPI
> > +       depends on PHYLIB
> 
> Same issue, they are no-ops.
> 
> I guess you have to surround OF and ACPI and FWNODE variants by
> 
> if PHYLIB
> ...
> endif
> 
> This will be an equivalent to depends on PHYLIB
> 
> and put this into Makefile
> 
> ifneq ($(CONFIG_ACPI),)
> obj-$(CONFIG_PHYLIB) += acpi_mdio.o
> endif
> 
> This will give you the rest, i.e. default PHYLIB + depends on ACPI
> 
> Similar for OF
> 

I checked the effect of y/n/m choice of PHYLIB on FWNODE_MDIO.
As expected with def_tristate, whenever PHYLIB changes to y/n/m corresponding
change is reflected on FWNODE_MDIO, also considering the state of other
depending CONFIGS like OF and ACPI.

Symbol: FWNODE_MDIO [=n]
│
  │ Type  : tristate
│
  │ Defined at drivers/net/mdio/Kconfig:22
│
  │   Depends on: NETDEVICES [=y] && MDIO_DEVICE [=y] && ACPI [=y] && OF [=y] &&
PHYLIB [=n]                                                          │
  │ Selects: FIXED_PHY [=n]

Effect is similar for ACPI_MDIO and OF_MDIO.

So instead of above proposed method, I think what you proposed in your earlier
email, i.e, "depends on (ACPI || OF) || COMPILE_TEST" seems to be better for
FWNODE_MDIO.

Shall we go ahead with this?

Regards
Calvin

> > +       help
> > +         ACPI MDIO bus (Ethernet PHY) accessors
> > +
> >  if MDIO_BUS
> >
> >  config MDIO_DEVRES
> > diff --git a/drivers/net/mdio/Makefile b/drivers/net/mdio/Makefile
> > index ea5390e2ef84..e8b739a3df1c 100644
> > --- a/drivers/net/mdio/Makefile
> > +++ b/drivers/net/mdio/Makefile
> > @@ -1,6 +1,7 @@
> >  # SPDX-License-Identifier: GPL-2.0
> >  # Makefile for Linux MDIO bus drivers
> >
> > +obj-$(CONFIG_ACPI_MDIO)                += acpi_mdio.o
> >  obj-$(CONFIG_FWNODE_MDIO)      += fwnode_mdio.o
> >  obj-$(CONFIG_OF_MDIO)          += of_mdio.o
> >
> > diff --git a/drivers/net/mdio/acpi_mdio.c b/drivers/net/mdio/acpi_mdio.c
> > new file mode 100644
> > index 000000000000..60a86e3fc246
> > --- /dev/null
> > +++ b/drivers/net/mdio/acpi_mdio.c
> > @@ -0,0 +1,56 @@
> > +// SPDX-License-Identifier: GPL-2.0-only
> > +/*
> > + * ACPI helpers for the MDIO (Ethernet PHY) API
> > + *
> > + * This file provides helper functions for extracting PHY device information
> > + * out of the ACPI ASL and using it to populate an mii_bus.
> > + */
> > +
> > +#include <linux/acpi.h>
> > +#include <linux/acpi_mdio.h>
> > +#include <linux/bits.h>
> > +#include <linux/dev_printk.h>
> > +#include <linux/fwnode_mdio.h>
> > +#include <linux/module.h>
> > +#include <linux/types.h>
> > +
> > +MODULE_AUTHOR("Calvin Johnson <calvin.johnson@oss.nxp.com>");
> > +MODULE_LICENSE("GPL");
> > +
> > +/**
> > + * acpi_mdiobus_register - Register mii_bus and create PHYs from the ACPI ASL.
> > + * @mdio: pointer to mii_bus structure
> > + * @fwnode: pointer to fwnode of MDIO bus.
> > + *
> > + * This function registers the mii_bus structure and registers a phy_device
> > + * for each child node of @fwnode.
> > + */
> > +int acpi_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode)
> > +{
> > +       struct fwnode_handle *child;
> > +       u32 addr;
> > +       int ret;
> > +
> > +       /* Mask out all PHYs from auto probing. */
> > +       mdio->phy_mask = GENMASK(31, 0);
> > +       ret = mdiobus_register(mdio);
> > +       if (ret)
> > +               return ret;
> > +
> > +       ACPI_COMPANION_SET(&mdio->dev, to_acpi_device_node(fwnode));
> > +
> > +       /* Loop over the child nodes and register a phy_device for each PHY */
> > +       fwnode_for_each_child_node(fwnode, child) {
> > +               ret = acpi_get_local_address(ACPI_HANDLE_FWNODE(child), &addr);
> > +               if (ret || addr >= PHY_MAX_ADDR)
> > +                       continue;
> > +
> > +               ret = fwnode_mdiobus_register_phy(mdio, child, addr);
> > +               if (ret == -ENODEV)
> > +                       dev_err(&mdio->dev,
> > +                               "MDIO device at address %d is missing.\n",
> > +                               addr);
> > +       }
> > +       return 0;
> > +}
> > +EXPORT_SYMBOL(acpi_mdiobus_register);
> > diff --git a/include/linux/acpi_mdio.h b/include/linux/acpi_mdio.h
> > new file mode 100644
> > index 000000000000..748d261fe2f9
> > --- /dev/null
> > +++ b/include/linux/acpi_mdio.h
> > @@ -0,0 +1,25 @@
> > +/* SPDX-License-Identifier: GPL-2.0-only */
> > +/*
> > + * ACPI helper for the MDIO (Ethernet PHY) API
> > + */
> > +
> > +#ifndef __LINUX_ACPI_MDIO_H
> > +#define __LINUX_ACPI_MDIO_H
> > +
> > +#include <linux/phy.h>
> > +
> > +#if IS_ENABLED(CONFIG_ACPI_MDIO)
> > +int acpi_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode);
> > +#else /* CONFIG_ACPI_MDIO */
> > +static inline int acpi_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode)
> > +{
> > +       /*
> > +        * Fall back to mdiobus_register() function to register a bus.
> > +        * This way, we don't have to keep compat bits around in drivers.
> > +        */
> > +
> > +       return mdiobus_register(mdio);
> > +}
> > +#endif
> > +
> > +#endif /* __LINUX_ACPI_MDIO_H */
> > --
> > 2.17.1
> >
> 
> 
> -- 
> With Best Regards,
> Andy Shevchenko

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [net-next PATCH v7 04/16] of: mdio: Refactor of_phy_find_device()
  2021-03-11  6:19   ` Calvin Johnson
@ 2021-03-16 19:17     ` Daniel Thompson
  -1 siblings, 0 replies; 64+ messages in thread
From: Daniel Thompson @ 2021-03-16 19:17 UTC (permalink / raw)
  To: Calvin Johnson
  Cc: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap, linux-arm-kernel,
	Diana Madalina Craciun, linux-acpi, linux-kernel, linux.cj,
	netdev, Laurentiu Tudor, David S. Miller, Heiner Kallweit,
	Jakub Kicinski

On Thu, Mar 11, 2021 at 11:49:59AM +0530, Calvin Johnson wrote:
> Refactor of_phy_find_device() to use fwnode_phy_find_device().
> 
> Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>

This patch series is provoking depmod dependency cycles for me and
it bisected down to this patch (although I think later patches in
the series add further cycles).

The problems emerge when running modules_install either directly or
indirectly via packaging rules such as bindeb-pkg.

~~~
make -j16 INSTALL_MOD_PATH=$PWD/modules modules_install
...
  INSTALL sound/usb/misc/snd-ua101.ko
  INSTALL sound/usb/snd-usb-audio.ko
  INSTALL sound/usb/snd-usbmidi-lib.ko
  INSTALL sound/xen/snd_xen_front.ko
  DEPMOD  5.12.0-rc3-00009-g1fda33bf463d
depmod: ERROR: Cycle detected: fwnode_mdio -> of_mdio -> fwnode_mdio
depmod: ERROR: Found 2 modules in dependency cycles!
~~~

Kconfig can be found here:
https://gist.github.com/daniel-thompson/6a7d224f3d3950ffa3f63f979b636474

This Kconfig file is for a highly modular kernel derived from the Debian
5.10 arm64 kernel config. I was not able to reproduce using the defconfig
kernel for arm64.


Daniel.


> ---
> 
> Changes in v7: None
> Changes in v6: None
> Changes in v5: None
> Changes in v4: None
> Changes in v3: None
> Changes in v2: None
> 
>  drivers/net/mdio/of_mdio.c | 13 +------------
>  1 file changed, 1 insertion(+), 12 deletions(-)
> 
> diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c
> index d5e0970b2561..b5e0b5b22f1a 100644
> --- a/drivers/net/mdio/of_mdio.c
> +++ b/drivers/net/mdio/of_mdio.c
> @@ -360,18 +360,7 @@ EXPORT_SYMBOL(of_mdio_find_device);
>   */
>  struct phy_device *of_phy_find_device(struct device_node *phy_np)
>  {
> -	struct mdio_device *mdiodev;
> -
> -	mdiodev = of_mdio_find_device(phy_np);
> -	if (!mdiodev)
> -		return NULL;
> -
> -	if (mdiodev->flags & MDIO_DEVICE_FLAG_PHY)
> -		return to_phy_device(&mdiodev->dev);
> -
> -	put_device(&mdiodev->dev);
> -
> -	return NULL;
> +	return fwnode_phy_find_device(of_fwnode_handle(phy_np));
>  }
>  EXPORT_SYMBOL(of_phy_find_device);
>  

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

* Re: [net-next PATCH v7 04/16] of: mdio: Refactor of_phy_find_device()
@ 2021-03-16 19:17     ` Daniel Thompson
  0 siblings, 0 replies; 64+ messages in thread
From: Daniel Thompson @ 2021-03-16 19:17 UTC (permalink / raw)
  To: Calvin Johnson
  Cc: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap, linux-arm-kernel,
	Diana Madalina Craciun, linux-acpi, linux-kernel, linux.cj,
	netdev, Laurentiu Tudor, David S. Miller, Heiner Kallweit,
	Jakub Kicinski

On Thu, Mar 11, 2021 at 11:49:59AM +0530, Calvin Johnson wrote:
> Refactor of_phy_find_device() to use fwnode_phy_find_device().
> 
> Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>

This patch series is provoking depmod dependency cycles for me and
it bisected down to this patch (although I think later patches in
the series add further cycles).

The problems emerge when running modules_install either directly or
indirectly via packaging rules such as bindeb-pkg.

~~~
make -j16 INSTALL_MOD_PATH=$PWD/modules modules_install
...
  INSTALL sound/usb/misc/snd-ua101.ko
  INSTALL sound/usb/snd-usb-audio.ko
  INSTALL sound/usb/snd-usbmidi-lib.ko
  INSTALL sound/xen/snd_xen_front.ko
  DEPMOD  5.12.0-rc3-00009-g1fda33bf463d
depmod: ERROR: Cycle detected: fwnode_mdio -> of_mdio -> fwnode_mdio
depmod: ERROR: Found 2 modules in dependency cycles!
~~~

Kconfig can be found here:
https://gist.github.com/daniel-thompson/6a7d224f3d3950ffa3f63f979b636474

This Kconfig file is for a highly modular kernel derived from the Debian
5.10 arm64 kernel config. I was not able to reproduce using the defconfig
kernel for arm64.


Daniel.


> ---
> 
> Changes in v7: None
> Changes in v6: None
> Changes in v5: None
> Changes in v4: None
> Changes in v3: None
> Changes in v2: None
> 
>  drivers/net/mdio/of_mdio.c | 13 +------------
>  1 file changed, 1 insertion(+), 12 deletions(-)
> 
> diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c
> index d5e0970b2561..b5e0b5b22f1a 100644
> --- a/drivers/net/mdio/of_mdio.c
> +++ b/drivers/net/mdio/of_mdio.c
> @@ -360,18 +360,7 @@ EXPORT_SYMBOL(of_mdio_find_device);
>   */
>  struct phy_device *of_phy_find_device(struct device_node *phy_np)
>  {
> -	struct mdio_device *mdiodev;
> -
> -	mdiodev = of_mdio_find_device(phy_np);
> -	if (!mdiodev)
> -		return NULL;
> -
> -	if (mdiodev->flags & MDIO_DEVICE_FLAG_PHY)
> -		return to_phy_device(&mdiodev->dev);
> -
> -	put_device(&mdiodev->dev);
> -
> -	return NULL;
> +	return fwnode_phy_find_device(of_fwnode_handle(phy_np));
>  }
>  EXPORT_SYMBOL(of_phy_find_device);
>  

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [net-next PATCH v7 04/16] of: mdio: Refactor of_phy_find_device()
  2021-03-16 19:17     ` Daniel Thompson
@ 2021-03-17  8:45       ` Calvin Johnson
  -1 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-17  8:45 UTC (permalink / raw)
  To: Daniel Thompson
  Cc: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap, linux-arm-kernel,
	Diana Madalina Craciun, linux-acpi, linux-kernel, linux.cj,
	netdev, Laurentiu Tudor, David S. Miller, Heiner Kallweit,
	Jakub Kicinski

Hi Daniel,

On Tue, Mar 16, 2021 at 07:17:19PM +0000, Daniel Thompson wrote:
> On Thu, Mar 11, 2021 at 11:49:59AM +0530, Calvin Johnson wrote:
> > Refactor of_phy_find_device() to use fwnode_phy_find_device().
> > 
> > Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
> 
> This patch series is provoking depmod dependency cycles for me and
> it bisected down to this patch (although I think later patches in
> the series add further cycles).
> 
> The problems emerge when running modules_install either directly or
> indirectly via packaging rules such as bindeb-pkg.
> 
> ~~~
> make -j16 INSTALL_MOD_PATH=$PWD/modules modules_install
> ...
>   INSTALL sound/usb/misc/snd-ua101.ko
>   INSTALL sound/usb/snd-usb-audio.ko
>   INSTALL sound/usb/snd-usbmidi-lib.ko
>   INSTALL sound/xen/snd_xen_front.ko
>   DEPMOD  5.12.0-rc3-00009-g1fda33bf463d
> depmod: ERROR: Cycle detected: fwnode_mdio -> of_mdio -> fwnode_mdio
> depmod: ERROR: Found 2 modules in dependency cycles!
> ~~~
> 
> Kconfig can be found here:
> https://gist.github.com/daniel-thompson/6a7d224f3d3950ffa3f63f979b636474
> 
> This Kconfig file is for a highly modular kernel derived from the Debian
> 5.10 arm64 kernel config. I was not able to reproduce using the defconfig
> kernel for arm64.
> 
Thanks for catching this. I'm able to reproduce the issue and will fix it.

By the way, is there any integration tool/mechanism out there to which I can
submit the patch series and build for various possible configs like these?

Thanks
Calvin

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

* Re: [net-next PATCH v7 04/16] of: mdio: Refactor of_phy_find_device()
@ 2021-03-17  8:45       ` Calvin Johnson
  0 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-17  8:45 UTC (permalink / raw)
  To: Daniel Thompson
  Cc: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap, linux-arm-kernel,
	Diana Madalina Craciun, linux-acpi, linux-kernel, linux.cj,
	netdev, Laurentiu Tudor, David S. Miller, Heiner Kallweit,
	Jakub Kicinski

Hi Daniel,

On Tue, Mar 16, 2021 at 07:17:19PM +0000, Daniel Thompson wrote:
> On Thu, Mar 11, 2021 at 11:49:59AM +0530, Calvin Johnson wrote:
> > Refactor of_phy_find_device() to use fwnode_phy_find_device().
> > 
> > Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
> 
> This patch series is provoking depmod dependency cycles for me and
> it bisected down to this patch (although I think later patches in
> the series add further cycles).
> 
> The problems emerge when running modules_install either directly or
> indirectly via packaging rules such as bindeb-pkg.
> 
> ~~~
> make -j16 INSTALL_MOD_PATH=$PWD/modules modules_install
> ...
>   INSTALL sound/usb/misc/snd-ua101.ko
>   INSTALL sound/usb/snd-usb-audio.ko
>   INSTALL sound/usb/snd-usbmidi-lib.ko
>   INSTALL sound/xen/snd_xen_front.ko
>   DEPMOD  5.12.0-rc3-00009-g1fda33bf463d
> depmod: ERROR: Cycle detected: fwnode_mdio -> of_mdio -> fwnode_mdio
> depmod: ERROR: Found 2 modules in dependency cycles!
> ~~~
> 
> Kconfig can be found here:
> https://gist.github.com/daniel-thompson/6a7d224f3d3950ffa3f63f979b636474
> 
> This Kconfig file is for a highly modular kernel derived from the Debian
> 5.10 arm64 kernel config. I was not able to reproduce using the defconfig
> kernel for arm64.
> 
Thanks for catching this. I'm able to reproduce the issue and will fix it.

By the way, is there any integration tool/mechanism out there to which I can
submit the patch series and build for various possible configs like these?

Thanks
Calvin

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [net-next PATCH v7 04/16] of: mdio: Refactor of_phy_find_device()
  2021-03-17  8:45       ` Calvin Johnson
@ 2021-03-19 11:21         ` Daniel Thompson
  -1 siblings, 0 replies; 64+ messages in thread
From: Daniel Thompson @ 2021-03-19 11:21 UTC (permalink / raw)
  To: Calvin Johnson
  Cc: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap, linux-arm-kernel,
	Diana Madalina Craciun, linux-acpi, linux-kernel, linux.cj,
	netdev, Laurentiu Tudor, David S. Miller, Heiner Kallweit,
	Jakub Kicinski

On Wed, Mar 17, 2021 at 02:15:20PM +0530, Calvin Johnson wrote:
> Hi Daniel,
> 
> On Tue, Mar 16, 2021 at 07:17:19PM +0000, Daniel Thompson wrote:
> > On Thu, Mar 11, 2021 at 11:49:59AM +0530, Calvin Johnson wrote:
> > > Refactor of_phy_find_device() to use fwnode_phy_find_device().
> > > 
> > > Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
> > 
> > This patch series is provoking depmod dependency cycles for me and
> > it bisected down to this patch (although I think later patches in
> > the series add further cycles).
> > 
> > The problems emerge when running modules_install either directly or
> > indirectly via packaging rules such as bindeb-pkg.
> > 
> > ~~~
> > make -j16 INSTALL_MOD_PATH=$PWD/modules modules_install
> > ...
> >   INSTALL sound/usb/misc/snd-ua101.ko
> >   INSTALL sound/usb/snd-usb-audio.ko
> >   INSTALL sound/usb/snd-usbmidi-lib.ko
> >   INSTALL sound/xen/snd_xen_front.ko
> >   DEPMOD  5.12.0-rc3-00009-g1fda33bf463d
> > depmod: ERROR: Cycle detected: fwnode_mdio -> of_mdio -> fwnode_mdio
> > depmod: ERROR: Found 2 modules in dependency cycles!
> > ~~~
> > 
> > Kconfig can be found here:
> > https://gist.github.com/daniel-thompson/6a7d224f3d3950ffa3f63f979b636474
> > 
> > This Kconfig file is for a highly modular kernel derived from the Debian
> > 5.10 arm64 kernel config. I was not able to reproduce using the defconfig
> > kernel for arm64.
> > 
> Thanks for catching this. I'm able to reproduce the issue and will fix it.
> 
> By the way, is there any integration tool/mechanism out there to which I can
> submit the patch series and build for various possible configs like these?

Not sure which autotester would be most likely to pick this up.

This issue is slightly unusual because it broke the install rather then
the build... and lots of people (including me) primarily run build
tests ;-) .

Anyhow, I guess the best way to pick up module problems like this is
going to be an `allmodconfig` build followed up with `rm -rf modtest;
make modules_install INSTALL_MOD_PATH=$PWD/modtest`.


Daniel.

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

* Re: [net-next PATCH v7 04/16] of: mdio: Refactor of_phy_find_device()
@ 2021-03-19 11:21         ` Daniel Thompson
  0 siblings, 0 replies; 64+ messages in thread
From: Daniel Thompson @ 2021-03-19 11:21 UTC (permalink / raw)
  To: Calvin Johnson
  Cc: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap, linux-arm-kernel,
	Diana Madalina Craciun, linux-acpi, linux-kernel, linux.cj,
	netdev, Laurentiu Tudor, David S. Miller, Heiner Kallweit,
	Jakub Kicinski

On Wed, Mar 17, 2021 at 02:15:20PM +0530, Calvin Johnson wrote:
> Hi Daniel,
> 
> On Tue, Mar 16, 2021 at 07:17:19PM +0000, Daniel Thompson wrote:
> > On Thu, Mar 11, 2021 at 11:49:59AM +0530, Calvin Johnson wrote:
> > > Refactor of_phy_find_device() to use fwnode_phy_find_device().
> > > 
> > > Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
> > 
> > This patch series is provoking depmod dependency cycles for me and
> > it bisected down to this patch (although I think later patches in
> > the series add further cycles).
> > 
> > The problems emerge when running modules_install either directly or
> > indirectly via packaging rules such as bindeb-pkg.
> > 
> > ~~~
> > make -j16 INSTALL_MOD_PATH=$PWD/modules modules_install
> > ...
> >   INSTALL sound/usb/misc/snd-ua101.ko
> >   INSTALL sound/usb/snd-usb-audio.ko
> >   INSTALL sound/usb/snd-usbmidi-lib.ko
> >   INSTALL sound/xen/snd_xen_front.ko
> >   DEPMOD  5.12.0-rc3-00009-g1fda33bf463d
> > depmod: ERROR: Cycle detected: fwnode_mdio -> of_mdio -> fwnode_mdio
> > depmod: ERROR: Found 2 modules in dependency cycles!
> > ~~~
> > 
> > Kconfig can be found here:
> > https://gist.github.com/daniel-thompson/6a7d224f3d3950ffa3f63f979b636474
> > 
> > This Kconfig file is for a highly modular kernel derived from the Debian
> > 5.10 arm64 kernel config. I was not able to reproduce using the defconfig
> > kernel for arm64.
> > 
> Thanks for catching this. I'm able to reproduce the issue and will fix it.
> 
> By the way, is there any integration tool/mechanism out there to which I can
> submit the patch series and build for various possible configs like these?

Not sure which autotester would be most likely to pick this up.

This issue is slightly unusual because it broke the install rather then
the build... and lots of people (including me) primarily run build
tests ;-) .

Anyhow, I guess the best way to pick up module problems like this is
going to be an `allmodconfig` build followed up with `rm -rf modtest;
make modules_install INSTALL_MOD_PATH=$PWD/modtest`.


Daniel.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [net-next PATCH v7 04/16] of: mdio: Refactor of_phy_find_device()
  2021-03-19 11:21         ` Daniel Thompson
@ 2021-03-23  5:27           ` Calvin Johnson
  -1 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-23  5:27 UTC (permalink / raw)
  To: Daniel Thompson
  Cc: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap, linux-arm-kernel,
	Diana Madalina Craciun, linux-acpi, linux-kernel, linux.cj,
	netdev, Laurentiu Tudor, David S. Miller, Heiner Kallweit,
	Jakub Kicinski

On Fri, Mar 19, 2021 at 11:21:15AM +0000, Daniel Thompson wrote:
> On Wed, Mar 17, 2021 at 02:15:20PM +0530, Calvin Johnson wrote:
> > Hi Daniel,
> > 
> > On Tue, Mar 16, 2021 at 07:17:19PM +0000, Daniel Thompson wrote:
> > > On Thu, Mar 11, 2021 at 11:49:59AM +0530, Calvin Johnson wrote:
> > > > Refactor of_phy_find_device() to use fwnode_phy_find_device().
> > > > 
> > > > Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
> > > 
> > > This patch series is provoking depmod dependency cycles for me and
> > > it bisected down to this patch (although I think later patches in
> > > the series add further cycles).
> > > 
> > > The problems emerge when running modules_install either directly or
> > > indirectly via packaging rules such as bindeb-pkg.
> > > 
> > > ~~~
> > > make -j16 INSTALL_MOD_PATH=$PWD/modules modules_install
> > > ...
> > >   INSTALL sound/usb/misc/snd-ua101.ko
> > >   INSTALL sound/usb/snd-usb-audio.ko
> > >   INSTALL sound/usb/snd-usbmidi-lib.ko
> > >   INSTALL sound/xen/snd_xen_front.ko
> > >   DEPMOD  5.12.0-rc3-00009-g1fda33bf463d
> > > depmod: ERROR: Cycle detected: fwnode_mdio -> of_mdio -> fwnode_mdio
> > > depmod: ERROR: Found 2 modules in dependency cycles!
> > > ~~~
> > > 
> > > Kconfig can be found here:
> > > https://gist.github.com/daniel-thompson/6a7d224f3d3950ffa3f63f979b636474
> > > 
> > > This Kconfig file is for a highly modular kernel derived from the Debian
> > > 5.10 arm64 kernel config. I was not able to reproduce using the defconfig
> > > kernel for arm64.
> > > 
> > Thanks for catching this. I'm able to reproduce the issue and will fix it.
> > 
> > By the way, is there any integration tool/mechanism out there to which I can
> > submit the patch series and build for various possible configs like these?
> 
> Not sure which autotester would be most likely to pick this up.
> 
> This issue is slightly unusual because it broke the install rather then
> the build... and lots of people (including me) primarily run build
> tests ;-) .
> 
> Anyhow, I guess the best way to pick up module problems like this is
> going to be an `allmodconfig` build followed up with `rm -rf modtest;
> make modules_install INSTALL_MOD_PATH=$PWD/modtest`.

Thanks Daniel for the info.

To resolve this issue, I need to add more fwnode MDIO functions.
I'm working on these. Meanwhile, will separately send out two patches
that got Reviewed-by tag.

Regards
Calvin

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

* Re: [net-next PATCH v7 04/16] of: mdio: Refactor of_phy_find_device()
@ 2021-03-23  5:27           ` Calvin Johnson
  0 siblings, 0 replies; 64+ messages in thread
From: Calvin Johnson @ 2021-03-23  5:27 UTC (permalink / raw)
  To: Daniel Thompson
  Cc: Grant Likely, Rafael J . Wysocki, Jeremy Linton, Andrew Lunn,
	Andy Shevchenko, Florian Fainelli,
	Russell King - ARM Linux admin, Cristi Sovaiala,
	Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur,
	Heikki Krogerus, Marcin Wojtas, Pieter Jansen Van Vuuren, Jon,
	Saravana Kannan, Randy Dunlap, linux-arm-kernel,
	Diana Madalina Craciun, linux-acpi, linux-kernel, linux.cj,
	netdev, Laurentiu Tudor, David S. Miller, Heiner Kallweit,
	Jakub Kicinski

On Fri, Mar 19, 2021 at 11:21:15AM +0000, Daniel Thompson wrote:
> On Wed, Mar 17, 2021 at 02:15:20PM +0530, Calvin Johnson wrote:
> > Hi Daniel,
> > 
> > On Tue, Mar 16, 2021 at 07:17:19PM +0000, Daniel Thompson wrote:
> > > On Thu, Mar 11, 2021 at 11:49:59AM +0530, Calvin Johnson wrote:
> > > > Refactor of_phy_find_device() to use fwnode_phy_find_device().
> > > > 
> > > > Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
> > > 
> > > This patch series is provoking depmod dependency cycles for me and
> > > it bisected down to this patch (although I think later patches in
> > > the series add further cycles).
> > > 
> > > The problems emerge when running modules_install either directly or
> > > indirectly via packaging rules such as bindeb-pkg.
> > > 
> > > ~~~
> > > make -j16 INSTALL_MOD_PATH=$PWD/modules modules_install
> > > ...
> > >   INSTALL sound/usb/misc/snd-ua101.ko
> > >   INSTALL sound/usb/snd-usb-audio.ko
> > >   INSTALL sound/usb/snd-usbmidi-lib.ko
> > >   INSTALL sound/xen/snd_xen_front.ko
> > >   DEPMOD  5.12.0-rc3-00009-g1fda33bf463d
> > > depmod: ERROR: Cycle detected: fwnode_mdio -> of_mdio -> fwnode_mdio
> > > depmod: ERROR: Found 2 modules in dependency cycles!
> > > ~~~
> > > 
> > > Kconfig can be found here:
> > > https://gist.github.com/daniel-thompson/6a7d224f3d3950ffa3f63f979b636474
> > > 
> > > This Kconfig file is for a highly modular kernel derived from the Debian
> > > 5.10 arm64 kernel config. I was not able to reproduce using the defconfig
> > > kernel for arm64.
> > > 
> > Thanks for catching this. I'm able to reproduce the issue and will fix it.
> > 
> > By the way, is there any integration tool/mechanism out there to which I can
> > submit the patch series and build for various possible configs like these?
> 
> Not sure which autotester would be most likely to pick this up.
> 
> This issue is slightly unusual because it broke the install rather then
> the build... and lots of people (including me) primarily run build
> tests ;-) .
> 
> Anyhow, I guess the best way to pick up module problems like this is
> going to be an `allmodconfig` build followed up with `rm -rf modtest;
> make modules_install INSTALL_MOD_PATH=$PWD/modtest`.

Thanks Daniel for the info.

To resolve this issue, I need to add more fwnode MDIO functions.
I'm working on these. Meanwhile, will separately send out two patches
that got Reviewed-by tag.

Regards
Calvin

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2021-03-23  5:29 UTC | newest]

Thread overview: 64+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-11  6:19 [net-next PATCH v7 00/16] ACPI support for dpaa2 driver Calvin Johnson
2021-03-11  6:19 ` Calvin Johnson
2021-03-11  6:19 ` [net-next PATCH v7 01/16] Documentation: ACPI: DSD: Document MDIO PHY Calvin Johnson
2021-03-11  6:19   ` Calvin Johnson
2021-03-11  6:19 ` [net-next PATCH v7 02/16] net: phy: Introduce fwnode_mdio_find_device() Calvin Johnson
2021-03-11  6:19   ` Calvin Johnson
2021-03-11  6:50   ` Saravana Kannan
2021-03-11  6:50     ` Saravana Kannan
2021-03-11 16:58     ` Calvin Johnson
2021-03-11 16:58       ` Calvin Johnson
2021-03-11  6:19 ` [net-next PATCH v7 03/16] net: phy: Introduce phy related fwnode functions Calvin Johnson
2021-03-11  6:19   ` Calvin Johnson
2021-03-11  6:19 ` [net-next PATCH v7 04/16] of: mdio: Refactor of_phy_find_device() Calvin Johnson
2021-03-11  6:19   ` Calvin Johnson
2021-03-16 19:17   ` Daniel Thompson
2021-03-16 19:17     ` Daniel Thompson
2021-03-17  8:45     ` Calvin Johnson
2021-03-17  8:45       ` Calvin Johnson
2021-03-19 11:21       ` Daniel Thompson
2021-03-19 11:21         ` Daniel Thompson
2021-03-23  5:27         ` Calvin Johnson
2021-03-23  5:27           ` Calvin Johnson
2021-03-11  6:20 ` [net-next PATCH v7 05/16] net: phy: Introduce fwnode_get_phy_id() Calvin Johnson
2021-03-11  6:20   ` Calvin Johnson
2021-03-11  6:20 ` [net-next PATCH v7 06/16] of: mdio: Refactor of_get_phy_id() Calvin Johnson
2021-03-11  6:20   ` Calvin Johnson
2021-03-11  6:20 ` [net-next PATCH v7 07/16] net: mii_timestamper: check NULL in unregister_mii_timestamper() Calvin Johnson
2021-03-11  6:20   ` Calvin Johnson
2021-03-11 12:04   ` Andy Shevchenko
2021-03-11 12:04     ` Andy Shevchenko
2021-03-11 17:03     ` Calvin Johnson
2021-03-11 17:03       ` Calvin Johnson
2021-03-11  6:20 ` [net-next PATCH v7 08/16] net: mdiobus: Introduce fwnode_mdiobus_register_phy() Calvin Johnson
2021-03-11  6:20   ` Calvin Johnson
2021-03-11 12:09   ` Andy Shevchenko
2021-03-11 12:09     ` Andy Shevchenko
2021-03-11 18:00     ` Calvin Johnson
2021-03-11 18:00       ` Calvin Johnson
2021-03-11 18:14       ` Andy Shevchenko
2021-03-11 18:14         ` Andy Shevchenko
2021-03-11 23:29   ` kernel test robot
2021-03-11  6:20 ` [net-next PATCH v7 09/16] of: mdio: Refactor of_mdiobus_register_phy() Calvin Johnson
2021-03-11  6:20   ` Calvin Johnson
2021-03-11  6:20 ` [net-next PATCH v7 10/16] ACPI: utils: Introduce acpi_get_local_address() Calvin Johnson
2021-03-11  6:20   ` Calvin Johnson
2021-03-11 12:10   ` Andy Shevchenko
2021-03-11 12:10     ` Andy Shevchenko
2021-03-11  6:20 ` [net-next PATCH v7 11/16] net: mdio: Add ACPI support code for mdio Calvin Johnson
2021-03-11  6:20   ` Calvin Johnson
2021-03-11 12:14   ` Andy Shevchenko
2021-03-11 12:14     ` Andy Shevchenko
2021-03-15 10:21     ` Calvin Johnson
2021-03-15 10:21       ` Calvin Johnson
2021-03-11  6:20 ` [net-next PATCH v7 12/16] net: mdiobus: Introduce fwnode_mdiobus_register() Calvin Johnson
2021-03-11  6:20   ` Calvin Johnson
2021-03-12  0:46   ` kernel test robot
2021-03-11  6:20 ` [net-next PATCH v7 13/16] net/fsl: Use fwnode_mdiobus_register() Calvin Johnson
2021-03-11  6:20   ` Calvin Johnson
2021-03-11  6:20 ` [net-next PATCH v7 14/16] net: phylink: introduce phylink_fwnode_phy_connect() Calvin Johnson
2021-03-11  6:20   ` Calvin Johnson
2021-03-11  6:20 ` [net-next PATCH v7 15/16] net: phylink: Refactor phylink_of_phy_connect() Calvin Johnson
2021-03-11  6:20   ` Calvin Johnson
2021-03-11  6:20 ` [net-next PATCH v7 16/16] net: dpaa2-mac: Add ACPI support for DPAA2 MAC driver Calvin Johnson
2021-03-11  6:20   ` Calvin Johnson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.