[net-next PATCH v5 15/15] net: dpaa2-mac: Add ACPI support for DPAA2 MAC driver
Calvin Johnson
calvin.johnson at oss.nxp.com
Mon Feb 15 07:33:09 EST 2021
On Mon, Feb 08, 2021 at 04:28:31PM +0000, Russell King - ARM Linux admin wrote:
> On Mon, Feb 08, 2021 at 08:42:44PM +0530, Calvin Johnson wrote:
> > Modify 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.
> >
> > Signed-off-by: Calvin Johnson <calvin.johnson at oss.nxp.com>
>
> I don't think this does the full job.
>
> > 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))) {
>
> 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:
>
> > netdev_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.
I think of_phy_is_fixed_link() needs to be fixed. I'll add below fix.
--- a/drivers/net/mdio/of_mdio.c
+++ b/drivers/net/mdio/of_mdio.c
@@ -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
More information about the linux-arm-kernel
mailing list