ACPI support for dpaa2 driver
Subsystems (7)
v5 cover ACPI support for dpaa2 driver
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: T2080RDB, LS1046ARDB, LS2088ARDB and LX2160ARDB
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 (15):
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: 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()
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 | 1 + drivers/acpi/utils.c | 14 ++ .../net/ethernet/freescale/dpaa2/dpaa2-mac.c | 91 +++++++----- drivers/net/ethernet/freescale/xgmac_mdio.c | 11 +- drivers/net/mdio/Kconfig | 7 + drivers/net/mdio/Makefile | 1 + drivers/net/mdio/acpi_mdio.c | 51 +++++++ drivers/net/mdio/of_mdio.c | 79 +---------- drivers/net/phy/mdio_bus.c | 86 +++++++++++ drivers/net/phy/phy_device.c | 106 ++++++++++++++ drivers/net/phy/phylink.c | 53 ++++--- include/linux/acpi.h | 7 + include/linux/acpi_mdio.h | 27 ++++ include/linux/mdio.h | 2 + include/linux/of_mdio.h | 6 +- include/linux/phy.h | 32 +++++ include/linux/phylink.h | 3 + 18 files changed, 578 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 include/linux/acpi_mdio.h
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v5 1/15 Documentation: ACPI: DSD: Document MDIO PHY
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".
---
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
Documentation/firmware-guide/acpi/dsd/phy.rst new file +133 -0
@@ -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 MAC, 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 need +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
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [net-next PATCH v5 01/15] Documentation: ACPI: DSD: Document MDIO PHY
Hi,
Just a couple of nits below:
Quoted 18 lines · Calvin Johnson
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 <[email protected]>---
Documentation/firmware-guide/acpi/dsd/phy.rst | 133 ++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 Documentation/firmware-guide/acpi/dsd/phy.rstDocumentation/firmware-guide/acpi/dsd/phy.rst new file +0
-0
Documentation/firmware-guide/acpi/dsd/phy.rst line 10
Quoted 10 lines
Documentation/firmware-guide/acpi/dsd/phy.rst new file +10
-0@@ -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 MAC, the PHYs registered on the
to a MAC,
Quoted 12 lines
Documentation/firmware-guide/acpi/dsd/phy.rst new file +12
-0+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 +----------
...
Documentation/firmware-guide/acpi/dsd/phy.rst line 43
Quoted 3 lines
Documentation/firmware-guide/acpi/dsd/phy.rst new file +3
-0+ +Later, during the MAC driver initialization, the registered PHY devices +have to be retrieved from the MDIO bus. For this, the MAC driver need
needs
Documentation/firmware-guide/acpi/dsd/phy.rst line 45
Quoted 2 lines
Documentation/firmware-guide/acpi/dsd/phy.rst new file +2
-0+references to the previously registered PHYs which are provided +as device object references (e.g. \_SB.MDI0.PHY1).
thanks.
Signature · 7 lines
~Randy _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [net-next PATCH v5 01/15] Documentation: ACPI: DSD: Document MDIO PHY
Quoted 26 lines · Randy Dunlap
Hi,
Just a couple of nits below:Quoted 22 lines · Calvin Johnson
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 <[email protected]>---
Documentation/firmware-guide/acpi/dsd/phy.rst | 133 ++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 Documentation/firmware-guide/acpi/dsd/phy.rstDocumentation/firmware-guide/acpi/dsd/phy.rst new file +4
-0@@ -0,0 +1,133 @@ +.. SPDX-License-Identifier: GPL-2.0 + +========================= +MDIO bus and PHYs in ACPI
Quoted 8 lines
Documentation/firmware-guide/acpi/dsd/phy.rst line 10
Quoted 6 lines
Documentation/firmware-guide/acpi/dsd/phy.rst new file +6
-0+========================= + +The PHYs on an MDIO bus [1] are probed and registered using +fwnode_mdiobus_register_phy(). + +Later, for connecting these PHYs to MAC, the PHYs registered on theto a MAC,
Each PHY is connected to a MAC. So I'll change it to "PHYs to their respective MACs".
Quoted 22 lines
Quoted 13 lines
Documentation/firmware-guide/acpi/dsd/phy.rst new file +12
-0+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 +----------...
Documentation/firmware-guide/acpi/dsd/phy.rst line 43
Quoted 3 lines
Documentation/firmware-guide/acpi/dsd/phy.rst new file +3
-0+ +Later, during the MAC driver initialization, the registered PHY devices +have to be retrieved from the MDIO bus. For this, the MAC driver needneeds
Quoted 8 lines
Documentation/firmware-guide/acpi/dsd/phy.rst line 45
Quoted 2 lines
Documentation/firmware-guide/acpi/dsd/phy.rst new file +2
-0+references to the previously registered PHYs which are provided +as device object references (e.g. \_SB.MDI0.PHY1).thanks.
Signature · 1 line
~Randy
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v5 2/15 net: phy: Introduce fwnode_mdio_find_device()
In reply to Calvin JohnsonDefine 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().
---
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(-)
drivers/net/mdio/of_mdio.c +1 -10
@@ -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);
drivers/net/phy/phy_device.c +23 -0
@@ -2829,6 +2829,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 +* @np: 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
include/linux/phy.h +6 -0
@@ -1349,11 +1349,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 ;
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v5 3/15 net: phy: Introduce phy related fwnode functions
In reply to Calvin JohnsonDefine 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.
---
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(+)
drivers/net/phy/phy_device.c +62 -0
@@ -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>
@@ -2852,6 +2853,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
include/linux/phy.h +20 -0
@@ -1350,6 +1350,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);
@@ -1359,6 +1362,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) {
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v5 4/15 of: mdio: Refactor of_phy_find_device()
In reply to Calvin JohnsonRefactor of_phy_find_device() to use fwnode_phy_find_device().
---
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(-)
drivers/net/mdio/of_mdio.c +1 -12
@@ -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);
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v5 5/15 net: phy: Introduce fwnode_get_phy_id()
In reply to Calvin JohnsonExtract phy_id from compatible string. This will be used by fwnode_mdiobus_register_phy() to create phy device using the phy_id.
---
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(+)
drivers/net/phy/phy_device.c +21 -0
@@ -846,6 +846,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
include/linux/phy.h +5 -0
@@ -1349,6 +1349,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);
@@ -1357,6 +1358,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) {
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v5 6/15 of: mdio: Refactor of_get_phy_id()
In reply to Calvin JohnsonWith the introduction of fwnode_get_phy_id(), refactor of_get_phy_id() to use fwnode equivalent.
---
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(-)
drivers/net/mdio/of_mdio.c +1 -11
@@ -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)
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v5 7/15 net: mdiobus: Introduce fwnode_mdiobus_register_phy()
In reply to Calvin JohnsonIntroduce 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.
---
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None
drivers/net/mdio/of_mdio.c | 3 +- drivers/net/phy/mdio_bus.c | 65 ++++++++++++++++++++++++++++++++++++++ include/linux/mdio.h | 2 ++ include/linux/of_mdio.h | 6 +++- 4 files changed, 74 insertions(+), 2 deletions(-)
drivers/net/mdio/of_mdio.c +2 -1
@@ -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)
drivers/net/phy/mdio_bus.c +65 -0
77 lines not on this page · raw message
include/linux/mdio.h +2 -0
@@ -381,6 +381,8 @@ int mdiobus_register_device(struct mdio_device *mdiodev);int mdiobus_unregister_device (struct mdio_device *mdiodev);bool mdiobus_is_registered_device (struct mii_bus *bus,int addr);struct phy_device *mdiobus_get_phy (struct mii_bus *bus,int addr); +int fwnode_mdiobus_register_phy (struct mii_bus *bus, +struct fwnode_handle *child,u32 addr);/** * mdio_module_driver() - Helper macro for registering mdio drivers
include/linux/of_mdio.h +5 -1
@@ -34,6 +34,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);
@@ -128,7 +129,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)
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Russell King - ARM Linux admin
maintainerRe: [net-next PATCH v5 07/15] net: mdiobus: Introduce fwnode_mdiobus_register_phy()
drivers/net/phy/mdio_bus.c int mdiobus_unregister_device(struct mdio_device *mdiodev) · line 113
Quoted 4 lines · Calvin Johnson
drivers/net/phy/mdio_bus.c +4
-0+int fwnode_mdiobus_register_phy (struct mii_bus *bus, +struct fwnode_handle *child,u32 addr) +{ +struct mii_timestamper *mii_ts;
If you initialise this to NULL...
Quoted 11 lines
drivers/net/phy/mdio_bus.c +11
-0+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); + } +
drivers/net/phy/mdio_bus.c int mdiobus_unregister_device(struct mdio_device *mdiodev) · line 134
Quoted 10 lines
drivers/net/phy/mdio_bus.c +10
-0+ 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)) { +if (mii_ts &&is_of_node (child))
Then you don't need is_of_node() here.
drivers/net/phy/mdio_bus.c int mdiobus_unregister_device(struct mdio_device *mdiodev) · line 168
Quoted 6 lines
drivers/net/phy/mdio_bus.c +6
-0+/* 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;
Should this be moved out of the if() case?
I'm thinking of the future where we may end up adding mii timestamper support for ACPI.
Signature · 7 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last! _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [net-next PATCH v5 07/15] net: mdiobus: Introduce fwnode_mdiobus_register_phy()
Quoted 41 lines · Russell King - ARM Linux admin
drivers/net/phy/mdio_bus.c int mdiobus_unregister_device(struct mdio_device *mdiodev) · line 113
Quoted 4 lines · Calvin Johnson
drivers/net/phy/mdio_bus.c +4
-0+int fwnode_mdiobus_register_phy (struct mii_bus *bus, +struct fwnode_handle *child,u32 addr) +{ +struct mii_timestamper *mii_ts;If you initialise this to NULL...
Quoted 11 lines
drivers/net/phy/mdio_bus.c +11
-0+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); + } +drivers/net/phy/mdio_bus.c int mdiobus_unregister_device(struct mdio_device *mdiodev) · line 134
Quoted 10 lines
drivers/net/phy/mdio_bus.c +10
-0+ 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)) { +if (mii_ts &&is_of_node (child))Then you don't need
is_of_node()here.drivers/net/phy/mdio_bus.c int mdiobus_unregister_device(struct mdio_device *mdiodev) · line 168
Quoted 6 lines
drivers/net/phy/mdio_bus.c +6
-0+/* 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;Should this be moved out of the
if()case?
Quoted 2 lines
I'm thinking of the future where we may end up adding mii timestamper support for ACPI.
Right. I'll take case of these in next version.
Thanks
Calvin
Re: [net-next PATCH v5 07/15] net: mdiobus: Introduce fwnode_mdiobus_register_phy()
In reply to Calvin JohnsonHi Calvin,
url: https://github.com/0day-ci/linux/commits/Calvin-Johnson/ACPI-support-for-dpaa2-driver/20210209-084334 base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 6626a0266566c5aea16178c5e6cd7fc4db3f2f56 config: i386-randconfig-m021-20210209 (attached as .config) compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
If you fix the issue, kindly add following tag as appropriate
New smatch warnings:drivers/net/phy/mdio_bus.c:134 fwnode_mdiobus_register_phy() error: uninitialized symbol 'mii_ts'.
Old smatch warnings:drivers/net/phy/mdio_bus.c:157 fwnode_mdiobus_register_phy() error: uninitialized symbol 'mii_ts'. drivers/net/phy/mdio_bus.c:167 fwnode_mdiobus_register_phy() error: uninitialized symbol 'mii_ts'.
vim +/mii_ts +134 drivers/net/phy/mdio_bus.c
36305d64c94998 Calvin Johnson 2021-02-08 110 int fwnode_mdiobus_register_phy(struct mii_bus *bus,
36305d64c94998 Calvin Johnson 2021-02-08 111 struct fwnode_handle *child, u32 addr)
36305d64c94998 Calvin Johnson 2021-02-08 112 {
36305d64c94998 Calvin Johnson 2021-02-08 113 struct mii_timestamper *mii_ts;
36305d64c94998 Calvin Johnson 2021-02-08 114 struct phy_device *phy;
36305d64c94998 Calvin Johnson 2021-02-08 115 bool is_c45 = false;
36305d64c94998 Calvin Johnson 2021-02-08 116 u32 phy_id;
36305d64c94998 Calvin Johnson 2021-02-08 117 int rc;
36305d64c94998 Calvin Johnson 2021-02-08 118
36305d64c94998 Calvin Johnson 2021-02-08 119 if (is_of_node(child)) {
36305d64c94998 Calvin Johnson 2021-02-08 120 mii_ts = of_find_mii_timestamper(to_of_node(child));
36305d64c94998 Calvin Johnson 2021-02-08 121 if (IS_ERR(mii_ts))
36305d64c94998 Calvin Johnson 2021-02-08 122 return PTR_ERR(mii_ts);
36305d64c94998 Calvin Johnson 2021-02-08 123 }"mii_ts" is not initialized on the else path.
36305d64c94998 Calvin Johnson 2021-02-08 124
36305d64c94998 Calvin Johnson 2021-02-08 125 rc = fwnode_property_match_string(child, "compatible", "ethernet-phy-ieee802.3-c45");
36305d64c94998 Calvin Johnson 2021-02-08 126 if (rc >= 0)
36305d64c94998 Calvin Johnson 2021-02-08 127 is_c45 = true;
36305d64c94998 Calvin Johnson 2021-02-08 128
36305d64c94998 Calvin Johnson 2021-02-08 129 if (is_c45 || fwnode_get_phy_id(child, &phy_id))
36305d64c94998 Calvin Johnson 2021-02-08 130 phy = get_phy_device(bus, addr, is_c45);
36305d64c94998 Calvin Johnson 2021-02-08 131 else
36305d64c94998 Calvin Johnson 2021-02-08 132 phy = phy_device_create(bus, addr, phy_id, 0, NULL);
36305d64c94998 Calvin Johnson 2021-02-08 133 if (IS_ERR(phy)) {
36305d64c94998 Calvin Johnson 2021-02-08 @134 if (mii_ts && is_of_node(child))
^^^^^^36305d64c94998 Calvin Johnson 2021-02-08 135 unregister_mii_timestamper(mii_ts);
36305d64c94998 Calvin Johnson 2021-02-08 136 return PTR_ERR(phy);
36305d64c94998 Calvin Johnson 2021-02-08 137 }
36305d64c94998 Calvin Johnson 2021-02-08 138
36305d64c94998 Calvin Johnson 2021-02-08 139 if (is_acpi_node(child)) {
36305d64c94998 Calvin Johnson 2021-02-08 140 phy->irq = bus->irq[addr];
36305d64c94998 Calvin Johnson 2021-02-08 141 ---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
PATCH v5 8/15 of: mdio: Refactor of_mdiobus_register_phy()
In reply to Calvin JohnsonRefactor of_mdiobus_register_phy() to use fwnode_mdiobus_register_phy().
---
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None
drivers/net/mdio/of_mdio.c | 40 +------------------------------------- 1 file changed, 1 insertion(+), 39 deletions(-)
drivers/net/mdio/of_mdio.c +1 -39
@@ -98,45 +98,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)) { -if (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); -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,
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v5 9/15 ACPI: utils: Introduce acpi_get_local_address()
In reply to Calvin JohnsonIntroduce a wrapper around the _ADR evaluation.
---
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(+)
drivers/acpi/utils.c +14 -0
@@ -296,6 +296,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,
include/linux/acpi.h +7 -0
@@ -699,6 +699,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
@@ -946,6 +948,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
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v5 10/15 net: mdio: Add ACPI support code for mdio
In reply to Calvin JohnsonDefine acpi_mdiobus_register() to Register mii_bus and create PHYs for each ACPI child node.
---
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 | 51 ++++++++++++++++++++++++++++++++++++ include/linux/acpi_mdio.h | 27 +++++++++++++++++++ 5 files changed, 87 insertions(+) create mode 100644 drivers/net/mdio/acpi_mdio.c create mode 100644 include/linux/acpi_mdio.h
MAINTAINERS +1 -0
@@ -6669,6 +6669,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/of_mdio.c F: drivers/net/pcs/ F: drivers/net/phy/
drivers/net/mdio/Kconfig +7 -0
@@ -27,6 +27,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
drivers/net/mdio/Makefile +1 -0
@@ -2,6 +2,7 @@ # Makefile for Linux MDIO bus drivers obj-$(CONFIG_OF_MDIO) += of_mdio.o +obj-$(CONFIG_ACPI_MDIO) += acpi_mdio.o obj-$(CONFIG_MDIO_ASPEED) += mdio-aspeed.o obj-$(CONFIG_MDIO_BCM_IPROC) += mdio-bcm-iproc.o
drivers/net/mdio/acpi_mdio.c new file +51 -0
51 lines not on this page · raw message
include/linux/acpi_mdio.h new file +27 -0
@@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* ACPI helpers for the MDIO (Ethernet PHY) API +* +*/ + +#ifndef __LINUX_ACPI_MDIO_H +#define __LINUX_ACPI_MDIO_H + +#include <linux/device.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 */
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [net-next PATCH v5 10/15] net: mdio: Add ACPI support code for mdio
Quoted 3 lines · Calvin Johnson
Define
acpi_mdiobus_register()to Registermii_busand create PHYs for each ACPI child node.
...
Quoted 4 lines
+/**
+ *acpi_mdiobus_register- Registermii_busand create PHYs from the ACPI ASL.+ *
Redundant blank line.
Quoted 6 lines
+ * @mdio: pointer to
mii_busstructure
+ * @fwnode: pointer to fwnode of MDIO bus.
+ *
+ * This function registers themii_busstructure and registers aphy_device
+ * for each child node of @fwnode.
+ */
drivers/net/mdio/acpi_mdio.c line 31
Quoted 9 lines
drivers/net/mdio/acpi_mdio.c new file +8
-0+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 = ~0 ;
I would rather see GENMASK(31, 0) here because in case the type of the variable is changed we will need to amend this anyway.
drivers/net/mdio/acpi_mdio.c line 36
Quoted 5 lines
drivers/net/mdio/acpi_mdio.c new file +4
-0+ ret =mdiobus_register (mdio); +if (ret) +return ret; + mdio->dev.fwnode = fwnode;
Shouldn't it be rather ACPI_SET_COMPANION() as other bus / drivers do?
Quoted 1 line
+/* Loop over the child nodes and register a
phy_devicefor each PHY */
Indentation.
drivers/net/mdio/acpi_mdio.c line 40
Quoted 4 lines
drivers/net/mdio/acpi_mdio.c new file +3
-0+fwnode_for_each_child_node (fwnode, child) { + ret =acpi_get_local_address (ACPI_HANDLE_FWNODE (child), &addr); +if ((ret) || addr >=PHY_MAX_ADDR )
Too many parentheses.
Quoted 10 lines
drivers/net/mdio/acpi_mdio.c new file +10
-0+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 ; +}
...
Quoted 4 lines
+/*
+ * ACPI helpers for the MDIO (Ethernet PHY) API
+ *
+ */
It's one line AFAICT!
...
include/linux/acpi_mdio.h line 11
Quoted 2 lines
include/linux/acpi_mdio.h new file +2
-0+#include <linux/device.h> +#include <linux/phy.h>
This seems a bit inconsistent with the below.
I see the user of mdiobus_register(). It's the only header should be included. Everything else would be forward declared like
struct fwnode_handle;
Quoted 13 lines
include/linux/acpi_mdio.h new file +13
-0+#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
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v5 11/15 net: mdiobus: Introduce fwnode_mdiobus_register()
In reply to Calvin JohnsonIntroduce 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().
---
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/phy/mdio_bus.c | 21 +++++++++++++++++++++ include/linux/phy.h | 1 + 2 files changed, 22 insertions(+)
drivers/net/phy/mdio_bus.c +21 -0
@@ -9,6 +9,7 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt#include <linux/acpi.h> +#include <linux/acpi_mdio.h> #include <linux/delay.h> #include <linux/device.h> #include <linux/errno.h>
@@ -566,6 +567,26 @@ static int mdiobus_create_device(struct mii_bus *bus,return ret; } +/** +* 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); +/** * __mdiobus_register - bring up all the PHYs on a given bus and attach them to bus * @bus: target mii_bus
include/linux/phy.h +1 -0
@@ -387,6 +387,7 @@ static inline struct mii_bus *mdiobus_alloc(void)return mdiobus_alloc_size (0 ); } +int fwnode_mdiobus_register (struct mii_bus *mdio,struct fwnode_handle *fwnode);int __mdiobus_register (struct mii_bus *bus,struct module *owner);int __devm_mdiobus_register (struct device *dev,struct mii_bus *bus,struct module *owner);
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v5 12/15 net/fsl: Use fwnode_mdiobus_register()
In reply to Calvin Johnsonfwnode_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.
---
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 | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/net/ethernet/freescale/xgmac_mdio.c +7 -4
@@ -2,6 +2,7 @@* QorIQ 10G MDIO Controller * * Copyright 2012 Freescale Semiconductor, Inc. +* Copyright 2021 NXP * * Authors: Andy Fleming <[email protected]> * Timur Tabi <[email protected]>
@@ -243,10 +244,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 +279,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;
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v5 13/15 phylink: introduce phylink_fwnode_phy_connect()
In reply to Calvin JohnsonDefine phylink_fwnode_phy_connect() to connect phy specified by a fwnode to a phylink instance.
---
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 | 56 +++++++++++++++++++++++++++++++++++++++ include/linux/phylink.h | 3 +++ 2 files changed, 59 insertions(+)
drivers/net/phy/phylink.c +56 -0
@@ -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>
@@ -1120,6 +1121,61 @@ 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; + +if (is_of_node (fwnode)) { +/* 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.
include/linux/phylink.h +3 -0
@@ -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);
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Russell King - ARM Linux admin
maintainerRe: [net-next PATCH v5 13/15] phylink: introduce phylink_fwnode_phy_connect()
Quoted 4 lines · Calvin Johnson
drivers/net/phy/phylink.c +4
-0+int phylink_fwnode_phy_connect (struct phylink *pl, +struct fwnode_handle *fwnode, +u32 flags) +{
drivers/net/phy/phylink.c int phylink_of_phy_connect(struct phylink *pl, struct device_node *dn, · line 1148
Quoted 10 lines
drivers/net/phy/phylink.c +10
-0+struct fwnode_handle *phy_fwnode; +struct phy_device *phy_dev; +int ret; + +if (is_of_node (fwnode)) { +/* 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 ;
This difference between ACPI and DT really needs to be described in the commit description.
For example, why is it acceptable to have a PHY in fixed-link mode if we're using ACPI, and not DT?
If we look at the phylink code, accepting a PHY when in fixed-link mode is basically not supported... so why should ACPI allow this?
Signature · 7 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last! _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [net-next PATCH v5 13/15] phylink: introduce phylink_fwnode_phy_connect()
Re: [net-next PATCH v5 13/15] phylink: introduce phylink_fwnode_phy_connect()
In reply to Russell King - ARM Linux adminQuoted 19 lines · Russell King - ARM Linux admin
Quoted 4 lines · Calvin Johnson
drivers/net/phy/phylink.c +4
-0+int phylink_fwnode_phy_connect (struct phylink *pl, +struct fwnode_handle *fwnode, +u32 flags) +{drivers/net/phy/phylink.c int phylink_of_phy_connect(struct phylink *pl, struct device_node *dn, · line 1148
Quoted 10 lines
drivers/net/phy/phylink.c +10
-0+struct fwnode_handle *phy_fwnode; +struct phy_device *phy_dev; +int ret; + +if (is_of_node (fwnode)) { +/* 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 ;This difference between ACPI and DT really needs to be described in the commit description.
Quoted 5 lines
For example, why is it acceptable to have a PHY in fixed-link mode if we're using ACPI, and not DT?
If we look at the phylink code, accepting a PHY when in fixed-link mode is basically not supported... so why should ACPI allow this?
DT and ACPI should handle fixed-link in similar manner. I'll remove the OF check.
Thanks
Calvin
Russell King - ARM Linux admin
maintainerRe: [net-next PATCH v5 13/15] phylink: introduce phylink_fwnode_phy_connect()
In reply to Calvin JohnsonQuoted 4 lines · Calvin Johnson
Define
phylink_fwnode_phy_connect()to connect phy specified by a fwnode to a phylink instance.Signed-off-by Calvin Johnson <[email protected]>
Also, the subject line should be "net: phylink: ..." Consistency is really appreciated.
Thanks.
Signature · 7 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last! _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v5 14/15 net: phylink: Refactor phylink_of_phy_connect()
In reply to Calvin JohnsonRefactor phylink_of_phy_connect() to use phylink_fwnode_phy_connect().
---
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(-)
drivers/net/phy/phylink.c +1 -38
@@ -1080,44 +1080,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);
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v5 15/15 net: dpaa2-mac: Add ACPI support for DPAA2 MAC driver
In reply to Calvin JohnsonModify dpaa2_mac_connect() to support ACPI along with DT. Modify dpaa2_mac_get_node() to get the dpmac fwnode from either DT or ACPI.
Replace of_get_phy_mode with fwnode_get_phy_mode to get phy-mode for a dpmac_node.
Use helper function phylink_fwnode_phy_connect() to find phy_dev and connect to mac->phylink.
---
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 | 91 +++++++++++-------- 1 file changed, 54 insertions(+), 37 deletions(-)
drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c +54 -37
@@ -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 *parent, *child =NULL ; +struct device_node *dpmacs =NULL ;int err; +u32 id; - dpmacs =of_find_node_by_name (NULL ,"dpmacs" ); -if (!dpmacs) -return NULL ; +if (is_of_node (dev->parent->fwnode)) { + dpmacs =of_find_node_by_name (NULL ,"dpmacs" ); +if (!dpmacs) +return NULL ; + parent =of_fwnode_handle (dpmacs); + }else if (is_acpi_node (dev->parent->fwnode)) { + parent = dev->parent->fwnode; + } -while ((dpmac =of_get_next_child (dpmacs, dpmac)) !=NULL ) { - err =of_property_read_u32 (dpmac,"reg" , &id); -if (err) +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 ; + }else if (id == dpmac_id) { +if (is_of_node (dev->parent->fwnode)) +of_node_put (dpmacs); +return child; + } } - -of_node_put (dpmacs); - -return dpmac; +if (is_of_node (dev->parent->fwnode)) +of_node_put (dpmacs); +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 (!of_device_is_available (to_of_node (node))) {netdev_err (mac->net_dev,"pcs-handle node not available\n" ); -of_node_put (node); +of_node_put (to_of_node (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,12 @@ 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 +321,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 +342,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 +353,14 @@ 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); +if (is_of_node (dpmac_node)) +fwnode_handle_put (dpmac_node);return 0 ;
@@ -353,7 +369,8 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac) err_pcs_destroy:dpaa2_pcs_destroy (mac); err_put_node: -of_node_put (dpmac_node); +if (is_of_node (dpmac_node)) +fwnode_handle_put (dpmac_node);return err; }
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [net-next PATCH v5 15/15] net: dpaa2-mac: Add ACPI support for DPAA2 MAC driver
Quoted 10 lines · Calvin Johnson
Modify
dpaa2_mac_connect()to support ACPI along with DT. Modifydpaa2_mac_get_node()to get the dpmac fwnode from either DT or ACPI.Replace
of_get_phy_modewithfwnode_get_phy_modeto get phy-mode for adpmac_node.Use helper function
phylink_fwnode_phy_connect()to findphy_devand connect tomac->phylink.
...
drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c static int phy_mode(enum dpmac_eth_if eth_if, phy_interface_t *if_mode)
Quoted 8 lines
drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c +7
-0+if (is_of_node (dev->parent->fwnode)) { + dpmacs =of_find_node_by_name (NULL ,"dpmacs" ); +if (!dpmacs) +return NULL ; + parent =of_fwnode_handle (dpmacs); + }else if (is_acpi_node (dev->parent->fwnode)) { + parent = dev->parent->fwnode;
dev_fwnode(dev->parent) ?
Quoted 1 line
+ }
...
drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c static int phy_mode(enum dpmac_eth_if eth_if, phy_interface_t *if_mode)
Quoted 4 lines
drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c +2
-0+if (err) {continue ; + }else if (id == dpmac_id) {
Useless 'else'
Quoted 1 line
+ if (
is_of_node(dev->parent->fwnode))
dev_fwnode() ?
Quoted 3 lines
drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c +3
-0+of_node_put (dpmacs); +return child; + }
...
Quoted 1 line
+ if (
is_of_node(dev->parent->fwnode))
Ditto ?
Quoted 1 line
+
of_node_put(dpmacs);
--
With Best Regards,
Andy Shevchenko
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Russell King - ARM Linux admin
maintainerRe: [net-next PATCH v5 15/15] net: dpaa2-mac: Add ACPI support for DPAA2 MAC driver
In reply to Calvin JohnsonQuoted 11 lines · Calvin Johnson
Modify
dpaa2_mac_connect()to support ACPI along with DT. Modifydpaa2_mac_get_node()to get the dpmac fwnode from either DT or ACPI.Replace
of_get_phy_modewithfwnode_get_phy_modeto get phy-mode for adpmac_node.Use helper function
phylink_fwnode_phy_connect()to findphy_devand connect tomac->phylink.Signed-off-by Calvin Johnson <[email protected]>
I don't think this does the full job.
Quoted 10 lines
static int dpaa2_pcs_create(struct
dpaa2_mac*mac,drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c +3
-3- 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 );
drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c static const struct phylink_mac_ops dpaa2_mac_phylink_ops = { · line 266
Quoted 10 lines
drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c +3
-2-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 (!of_device_is_available (to_of_node (node))) {
If "node" is an ACPI node, then to_of_node() returns NULL, and of_device_is_available(NULL) is false. So, if we're using ACPI and we enter this path, we will always hit the error below:
drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c int dpaa2_mac_connect(struct dpaa2_mac *mac) · line 324
Quoted 12 lines
drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c +2
-2netdev_err (mac->net_dev,"pcs-handle node not available\n" ); -of_node_put (node); +of_node_put (to_of_node (node));return -ENODEV ; }@@ -306,7 +321,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)) &&
If "dpmac_node" is an ACPI node, to_of_node() will return NULL, and of_phy_is_fixed_link() will oops.
Signature · 7 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last! _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [net-next PATCH v5 15/15] net: dpaa2-mac: Add ACPI support for DPAA2 MAC driver
Quoted 46 lines · Russell King - ARM Linux admin
Quoted 11 lines · Calvin Johnson
Modify
dpaa2_mac_connect()to support ACPI along with DT. Modifydpaa2_mac_get_node()to get the dpmac fwnode from either DT or ACPI.Replace
of_get_phy_modewithfwnode_get_phy_modeto get phy-mode for adpmac_node.Use helper function
phylink_fwnode_phy_connect()to findphy_devand connect tomac->phylink.Signed-off-by Calvin Johnson <[email protected]>I don't think this does the full job.
Quoted 10 lines
static int dpaa2_pcs_create(struct
dpaa2_mac*mac,(quoted diff) +3
-3- 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);Review
Quoted 10 lines
(quoted diff) +3
-2- 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 (!of_device_is_available(to_of_node(node))) {If "node" is an ACPI node, then
to_of_node()returns NULL, andof_device_is_available(NULL)is false. So, if we're using ACPI and we enter this path, we will always hit the error below:Quoted 5 lines
(quoted diff) +1
-1netdev_err(mac->net_dev, "pcs-handle node not available\n"); - of_node_put(node); + of_node_put(to_of_node(node)); return -ENODEV; }
Quoted 9 lines
Review int dpaa2_mac_connect(struct dpaa2_mac *mac) · line 324
Quoted 6 lines
(quoted diff) +1
-1@@ -306,7 +321,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)) &&If "
dpmac_node" is an ACPI node,to_of_node()will return NULL, andof_phy_is_fixed_link()will oops.
I think of_phy_is_fixed_link() needs to be fixed. I'll add below fix.
drivers/net/mdio/of_mdio.c +3 -0
@@ -439,6 +439,9 @@ bool of_phy_is_fixed_link(struct device_node *np)int len, err;const char *managed; +if (!np) +return false; +/* New binding */ dn =of_get_child_by_name (np,"fixed-link" );if (dn) {
Regards
Calvin
Re: [net-next PATCH v5 15/15] net: dpaa2-mac: Add ACPI support for DPAA2 MAC driver
Quoted 1 line · Calvin Johnson
On Mon, Feb 08, 2021 at 04:28:31PM +0000, Russell King - ARM Linux admin wrote:
...
drivers/net/mdio/of_mdio.c bool of_phy_is_fixed_link(struct device_node *np) · line 443
Quoted 10 lines
I think
of_phy_is_fixed_link()needs to be fixed. I'll add below fix.drivers/net/mdio/of_mdio.c +2
-0@@ -439,6 +439,9 @@ bool of_phy_is_fixed_link(struct device_node *np)int len, err;const char *managed; +if (!np) +return false;
AFAICS this doesn't add anything: all of the of_* APIs should handle OF nodes being NULL below.
Quoted 3 lines
drivers/net/mdio/of_mdio.c +0
-0/* New binding */ dn =of_get_child_by_name (np,"fixed-link" );if (dn) {
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [net-next PATCH v5 15/15] net: dpaa2-mac: Add ACPI support for DPAA2 MAC driver
Quoted 15 lines · Andy Shevchenko
Quoted 1 line · Calvin Johnson
On Mon, Feb 08, 2021 at 04:28:31PM +0000, Russell King - ARM Linux admin wrote:
...
Quoted 8 lines
I think
of_phy_is_fixed_link()needs to be fixed. I'll add below fix.drivers/net/mdio/of_mdio.c +0
-0@@ -439,6 +439,9 @@ bool of_phy_is_fixed_link(struct device_node *np)int len, err;const char *managed;
Quoted 9 lines
drivers/net/mdio/of_mdio.c bool of_phy_is_fixed_link(struct device_node *np) · line 443
Quoted 2 lines
drivers/net/mdio/of_mdio.c +2
-0+if (!np) +return false;AFAICS this doesn't add anything: all of the of_* APIs should handle OF nodes being NULL below.
Quoted 3 lines
drivers/net/mdio/of_mdio.c +0
-0/* New binding */ dn =of_get_child_by_name (np,"fixed-link" );if (dn) {
Yes, of_get_next_child() and of_get_property() are NULL aware.
So, the check is redundant.
Signature · 7 lines
With Best Regards, Andy Shevchenko _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [net-next PATCH v5 15/15] net: dpaa2-mac: Add ACPI support for DPAA2 MAC driver
Quoted 23 lines · Andy Shevchenko
Quoted 21 lines · Andy Shevchenko
Quoted 1 line · Calvin Johnson
On Mon, Feb 08, 2021 at 04:28:31PM +0000, Russell King - ARM Linux admin wrote:
...
drivers/net/mdio/of_mdio.c bool of_phy_is_fixed_link(struct device_node *np) · line 443
Quoted 10 lines
I think
of_phy_is_fixed_link()needs to be fixed. I'll add below fix.drivers/net/mdio/of_mdio.c +2
-0@@ -439,6 +439,9 @@ bool of_phy_is_fixed_link(struct device_node *np)int len, err;const char *managed; +if (!np) +return false;AFAICS this doesn't add anything: all of the of_* APIs should handle OF nodes being NULL below.
Quoted 7 lines
Quoted 3 lines
drivers/net/mdio/of_mdio.c bool of_phy_is_fixed_link(struct device_node *np) · line 447
Quoted 3 lines
drivers/net/mdio/of_mdio.c +0
-0/* New binding */ dn =of_get_child_by_name (np,"fixed-link" );if (dn) {Yes,
of_get_next_child()andof_get_property()are NULL aware.So, the check is redundant.
Yes, all the function calls in of_phy_is_fixed_link() handles NULL properly. I don't see any way this function can oops.
Regards
Calvin