* [net-next: PATCH 07/12] net: mdio: allow registering non-PHY devices in ACPI world
2022-06-20 15:02 [net-next: PATCH 00/12] ACPI support for DSA Marcin Wojtas
@ 2022-06-20 15:02 ` Marcin Wojtas
0 siblings, 0 replies; 2+ messages in thread
From: Marcin Wojtas @ 2022-06-20 15:02 UTC (permalink / raw)
To: linux-kernel, linux-acpi, netdev
Cc: rafael, andriy.shevchenko, lenb, andrew, vivien.didelot,
f.fainelli, olteanv, davem, edumazet, kuba, pabeni, linux,
hkallweit1, gjb, mw, jaz, tn, Samer.El-Haj-Mahmoud, upstream
This patch utilizes the newly added fwnode_mdiobus_register_device
function and enables registration of non-PHY MDIO devices.
For that purpose a helper routine is added, allowing to determine,
whether the device associated to ACPI node is a PHY.
In addition to that update, allow matching child devices' drivers
based on their ACPI ID.
Signed-off-by: Marcin Wojtas <mw@semihalf.com>
---
drivers/net/mdio/acpi_mdio.c | 40 +++++++++++++++++++-
drivers/net/phy/mdio_bus.c | 4 ++
2 files changed, 43 insertions(+), 1 deletion(-)
diff --git a/drivers/net/mdio/acpi_mdio.c b/drivers/net/mdio/acpi_mdio.c
index d77c987fda9c..b5d7404afc5e 100644
--- a/drivers/net/mdio/acpi_mdio.c
+++ b/drivers/net/mdio/acpi_mdio.c
@@ -17,6 +17,41 @@
MODULE_AUTHOR("Calvin Johnson <calvin.johnson@oss.nxp.com>");
MODULE_LICENSE("GPL");
+/**
+ * acpi_mdiobus_child_is_phy - check if device associated with fwnode is a PHY.
+ * @fwnode: pointer to MDIO bus child fwnode and is expected to represent ACPI
+ * device object.
+ *
+ * The function returns true if the child node is for a PHY.
+ * It must comprise either:
+ * o Compatible string of "ethernet-phy-idX.X"
+ * o Compatible string of "ethernet-phy-ieee802.3-c45"
+ * o Compatible string of "ethernet-phy-ieee802.3-c22"
+ * o No _HID or _CID fields.
+ */
+static bool acpi_mdiobus_child_is_phy(struct fwnode_handle *child)
+{
+ struct acpi_device *adev = to_acpi_device_node(child);
+ u32 phy_id;
+
+ if (fwnode_get_phy_id(child, &phy_id) != -EINVAL)
+ return true;
+
+ if (fwnode_property_match_string(child, "compatible",
+ "ethernet-phy-ieee802.3-c45") == 0)
+ return true;
+
+ if (fwnode_property_match_string(child, "compatible",
+ "ethernet-phy-ieee802.3-c22") == 0)
+ return true;
+
+ /* Default to PHY if no _HID or _CID found in the fwnode. */
+ if (list_empty(&adev->pnp.ids))
+ return true;
+
+ return false;
+}
+
/**
* acpi_mdiobus_register - Register mii_bus and create PHYs from the ACPI ASL.
* @mdio: pointer to mii_bus structure
@@ -47,7 +82,10 @@ int acpi_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode)
if (ret || addr >= PHY_MAX_ADDR)
continue;
- ret = fwnode_mdiobus_register_phy(mdio, child, addr);
+ if (acpi_mdiobus_child_is_phy(child))
+ ret = fwnode_mdiobus_register_phy(mdio, child, addr);
+ else
+ ret = fwnode_mdiobus_register_device(mdio, child, addr);
if (ret == -ENODEV)
dev_err(&mdio->dev,
"MDIO device at address %d is missing.\n",
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 8a2dbe849866..b3c2f966be4b 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -8,6 +8,7 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#include <linux/acpi.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/errno.h>
@@ -989,6 +990,9 @@ static int mdio_bus_match(struct device *dev, struct device_driver *drv)
if (of_driver_match_device(dev, drv))
return 1;
+ if (acpi_driver_match_device(dev, drv))
+ return 1;
+
if (mdio->bus_match)
return mdio->bus_match(dev, drv);
--
2.29.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [net-next: PATCH 07/12] net: mdio: allow registering non-PHY devices in ACPI world
@ 2022-06-21 4:37 kernel test robot
0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2022-06-21 4:37 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 16193 bytes --]
::::::
:::::: Manual check reason: "low confidence bisect report"
:::::: Manual check reason: "low confidence static check first_new_problem: include/asm-generic/rwonce.h:44:26: warning: dereference of NULL '<unknown>' [CWE-476] [-Wanalyzer-null-dereference]"
::::::
CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
In-Reply-To: <20220620150225.1307946-8-mw@semihalf.com>
References: <20220620150225.1307946-8-mw@semihalf.com>
TO: Marcin Wojtas <mw@semihalf.com>
TO: linux-kernel(a)vger.kernel.org
TO: linux-acpi(a)vger.kernel.org
TO: netdev(a)vger.kernel.org
CC: rafael(a)kernel.org
CC: andriy.shevchenko(a)linux.intel.com
CC: lenb(a)kernel.org
CC: andrew(a)lunn.ch
CC: vivien.didelot(a)gmail.com
CC: f.fainelli(a)gmail.com
CC: olteanv(a)gmail.com
CC: davem(a)davemloft.net
CC: edumazet(a)google.com
CC: kuba(a)kernel.org
CC: pabeni(a)redhat.com
CC: linux(a)armlinux.org.uk
CC: hkallweit1(a)gmail.com
CC: gjb(a)semihalf.com
CC: mw(a)semihalf.com
CC: jaz(a)semihalf.com
CC: tn(a)semihalf.com
CC: Samer.El-Haj-Mahmoud(a)arm.com
CC: upstream(a)semihalf.com
Hi Marcin,
I love your patch! Perhaps something to improve:
[auto build test WARNING on rafael-pm/linux-next]
[also build test WARNING on robh/for-next linus/master v5.19-rc2 next-20220617]
[cannot apply to horms-ipvs/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/intel-lab-lkp/linux/commits/Marcin-Wojtas/ACPI-support-for-DSA/20220620-231646
base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
:::::: branch date: 13 hours ago
:::::: commit date: 13 hours ago
config: i386-randconfig-c001 (https://download.01.org/0day-ci/archive/20220621/202206211240.eoGOEICS-lkp(a)intel.com/config)
compiler: gcc-11 (Debian 11.3.0-3) 11.3.0
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
# https://github.com/intel-lab-lkp/linux/commit/3971d5dc91ab6b9c21f20cc7c431aca0a8ea6740
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Marcin-Wojtas/ACPI-support-for-DSA/20220620-231646
git checkout 3971d5dc91ab6b9c21f20cc7c431aca0a8ea6740
# save the config file
ARCH=i386 KBUILD_USERCFLAGS='-fanalyzer -Wno-error'
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>
gcc-analyzer warnings: (new ones prefixed by >>)
| 65 | int acpi_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode)
| | ^~~~~~~~~~~~~~~~~~~~~
| | |
| | (1) entry to 'acpi_mdiobus_register.part.0'
|
'acpi_mdiobus_register.part.0': event 2
|
| 80 | fwnode_for_each_child_node(fwnode, child) {
| | ^~~~~
| | |
| | (2) following 'true' branch (when 'child' is non-NULL)...
include/linux/property.h:105:64: note: in definition of macro 'fwnode_for_each_child_node'
| 105 | for (child = fwnode_get_next_child_node(fwnode, NULL); child; \
| | ^~~~~
|
'acpi_mdiobus_register.part.0': event 3
|
|include/acpi/acpi_bus.h:421:17:
| 421 | is_acpi_device_node(__to_acpi_device_node_fwnode) ? \
| | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (3) ...to here
include/linux/acpi.h:48:52: note: in expansion of macro 'to_acpi_device_node'
| 48 | acpi_device_handle(to_acpi_device_node(fwnode))
| | ^~~~~~~~~~~~~~~~~~~
drivers/net/mdio/acpi_mdio.c:81:46: note: in expansion of macro 'ACPI_HANDLE_FWNODE'
| 81 | ret = acpi_get_local_address(ACPI_HANDLE_FWNODE(child), &addr);
| | ^~~~~~~~~~~~~~~~~~
|
'acpi_mdiobus_register.part.0': events 4-6
|
| 82 | if (ret || addr >= PHY_MAX_ADDR)
| | ^
| | |
| | (4) following 'false' branch...
|......
| 85 | if (acpi_mdiobus_child_is_phy(child))
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (5) ...to here
| | (6) calling 'acpi_mdiobus_child_is_phy' from 'acpi_mdiobus_register.part.0'
|
+--> 'acpi_mdiobus_child_is_phy': event 7
|
| 32 | static bool acpi_mdiobus_child_is_phy(struct fwnode_handle *child)
| | ^~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (7) entry to 'acpi_mdiobus_child_is_phy'
|
'acpi_mdiobus_child_is_phy': event 8
|
|include/acpi/acpi_bus.h:423:66:
| 423 | struct acpi_device, fwnode) : \
drivers/net/mdio/acpi_mdio.c:34:36: note: in expansion of macro 'to_acpi_device_node'
| 34 | struct acpi_device *adev = to_acpi_device_node(child);
| | ^~~~~~~~~~~~~~~~~~~
|
'acpi_mdiobus_child_is_phy': events 9-15
|
| 37 | if (fwnode_get_phy_id(child, &phy_id) != -EINVAL)
| | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | ||
| | |(9) ...to here
| | (10) following 'false' branch...
|......
| 40 | if (fwnode_property_match_string(child, "compatible",
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | ||
| | |(11) ...to here
| | (12) following 'false' branch...
| 41 | "ethernet-phy-ieee802.3-c45") == 0)
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|......
| 44 | if (fwnode_property_match_string(child, "compatible",
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | ||
| | |(13) ...to here
| | (14) following 'false' branch...
| 45 | "ethernet-phy-ieee802.3-c22") == 0)
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|......
| 49 | if (list_empty(&adev->pnp.ids))
| | ~~~~~~~~~~~~~~
| | |
| | (15) ...to here
|
'acpi_mdiobus_child_is_phy': event 16
|
|include/asm-generic/rwonce.h:44:26:
| 44 | #define __READ_ONCE(x) (*(const volatile __unqual_scalar_typeof(x) *)&(x))
| | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (16) dereference of NULL '<unknown>'
include/asm-generic/rwonce.h:50:9: note: in expansion of macro '__READ_ONCE'
| 50 | __READ_ONCE(x); \
| | ^~~~~~~~~~~
include/linux/list.h:292:16: note: in expansion of macro 'READ_ONCE'
| 292 | return READ_ONCE(head->next) == head;
| | ^~~~~~~~~
|
>> include/asm-generic/rwonce.h:44:26: warning: dereference of NULL '<unknown>' [CWE-476] [-Wanalyzer-null-dereference]
44 | #define __READ_ONCE(x) (*(const volatile __unqual_scalar_typeof(x) *)&(x))
| ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/asm-generic/rwonce.h:50:9: note: in expansion of macro '__READ_ONCE'
50 | __READ_ONCE(x); \
| ^~~~~~~~~~~
include/linux/list.h:292:16: note: in expansion of macro 'READ_ONCE'
292 | return READ_ONCE(head->next) == head;
| ^~~~~~~~~
'acpi_mdiobus_register.part.0': event 1
|
|drivers/net/mdio/acpi_mdio.c:65:5:
| 65 | int acpi_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode)
| | ^~~~~~~~~~~~~~~~~~~~~
| | |
| | (1) entry to 'acpi_mdiobus_register.part.0'
|
'acpi_mdiobus_register.part.0': event 2
|
| 80 | fwnode_for_each_child_node(fwnode, child) {
| | ^~~~~
| | |
| | (2) following 'true' branch (when 'child' is non-NULL)...
include/linux/property.h:105:64: note: in definition of macro 'fwnode_for_each_child_node'
| 105 | for (child = fwnode_get_next_child_node(fwnode, NULL); child; \
| | ^~~~~
|
'acpi_mdiobus_register.part.0': event 3
|
|include/acpi/acpi_bus.h:421:17:
| 421 | is_acpi_device_node(__to_acpi_device_node_fwnode) ? \
| | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (3) ...to here
include/linux/acpi.h:48:52: note: in expansion of macro 'to_acpi_device_node'
| 48 | acpi_device_handle(to_acpi_device_node(fwnode))
| | ^~~~~~~~~~~~~~~~~~~
drivers/net/mdio/acpi_mdio.c:81:46: note: in expansion of macro 'ACPI_HANDLE_FWNODE'
| 81 | ret = acpi_get_local_address(ACPI_HANDLE_FWNODE(child), &addr);
| | ^~~~~~~~~~~~~~~~~~
|
'acpi_mdiobus_register.part.0': event 4
|
|include/acpi/acpi_bus.h:423:66:
| 423 | struct acpi_device, fwnode) : \
include/linux/acpi.h:48:52: note: in expansion of macro 'to_acpi_device_node'
| 48 | acpi_device_handle(to_acpi_device_node(fwnode))
| | ^~~~~~~~~~~~~~~~~~~
drivers/net/mdio/acpi_mdio.c:81:46: note: in expansion of macro 'ACPI_HANDLE_FWNODE'
| 81 | ret = acpi_get_local_address(ACPI_HANDLE_FWNODE(child), &addr);
| | ^~~~~~~~~~~~~~~~~~
|
'acpi_mdiobus_register.part.0': event 5
|
|include/linux/container_of.h:22:10:
| 22 | ((type *)(__mptr - offsetof(type, member))); })
| | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (5) ...to here
include/acpi/acpi_bus.h:422:25: note: in expansion of macro 'container_of'
| 422 | container_of(__to_acpi_device_node_fwnode, \
| | ^~~~~~~~~~~~
include/linux/acpi.h:48:52: note: in expansion of macro 'to_acpi_device_node'
| 48 | acpi_device_handle(to_acpi_device_node(fwnode))
| | ^~~~~~~~~~~~~~~~~~~
drivers/net/mdio/acpi_mdio.c:81:46: note: in expansion of macro 'ACPI_HANDLE_FWNODE'
| 81 | ret = acpi_get_local_address(ACPI_HANDLE_FWNODE(child), &addr);
| | ^~~~~~~~~~~~~~~~~~
|
'acpi_mdiobus_register.part.0': event 6
|
|include/linux/acpi.h:40:36:
| 40 | return adev ? adev->handle : NULL;
|
'acpi_mdiobus_register.part.0': events 7-10
|
|drivers/net/mdio/acpi_mdio.c:81:23:
| 81 | ret = acpi_get_local_address(ACPI_HANDLE_FWNODE(child), &addr);
| | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (7) ...to here
| 82 | if (ret || addr >= PHY_MAX_ADDR)
| | ~
| | |
| | (8) following 'false' branch...
|......
| 85 | if (acpi_mdiobus_child_is_phy(child))
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (9) ...to here
| | (10) calling 'acpi_mdiobus_child_is_phy' from 'acpi_mdiobus_register.part.0'
|
+--> 'acpi_mdiobus_child_is_phy': event 11
|
| 32 | static bool acpi_mdiobus_child_is_phy(struct fwnode_handle *child)
| | ^~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (11) entry to 'acpi_mdiobus_child_is_phy'
|
'acpi_mdiobus_child_is_phy': event 12
|
vim +44 include/asm-generic/rwonce.h
e506ea451254ab Will Deacon 2019-10-15 28
e506ea451254ab Will Deacon 2019-10-15 29 /*
e506ea451254ab Will Deacon 2019-10-15 30 * Yes, this permits 64-bit accesses on 32-bit architectures. These will
e506ea451254ab Will Deacon 2019-10-15 31 * actually be atomic in some cases (namely Armv7 + LPAE), but for others we
e506ea451254ab Will Deacon 2019-10-15 32 * rely on the access being split into 2x32-bit accesses for a 32-bit quantity
e506ea451254ab Will Deacon 2019-10-15 33 * (e.g. a virtual address) and a strong prevailing wind.
e506ea451254ab Will Deacon 2019-10-15 34 */
e506ea451254ab Will Deacon 2019-10-15 35 #define compiletime_assert_rwonce_type(t) \
e506ea451254ab Will Deacon 2019-10-15 36 compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \
e506ea451254ab Will Deacon 2019-10-15 37 "Unsupported access size for {READ,WRITE}_ONCE().")
e506ea451254ab Will Deacon 2019-10-15 38
e506ea451254ab Will Deacon 2019-10-15 39 /*
e506ea451254ab Will Deacon 2019-10-15 40 * Use __READ_ONCE() instead of READ_ONCE() if you do not require any
3c9184109e78ea Will Deacon 2019-10-30 41 * atomicity. Note that this may result in tears!
e506ea451254ab Will Deacon 2019-10-15 42 */
b78b331a3f5c07 Will Deacon 2019-10-15 43 #ifndef __READ_ONCE
e506ea451254ab Will Deacon 2019-10-15 @44 #define __READ_ONCE(x) (*(const volatile __unqual_scalar_typeof(x) *)&(x))
b78b331a3f5c07 Will Deacon 2019-10-15 45 #endif
e506ea451254ab Will Deacon 2019-10-15 46
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-06-21 4:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-21 4:37 [net-next: PATCH 07/12] net: mdio: allow registering non-PHY devices in ACPI world kernel test robot
-- strict thread matches above, loose matches on Subject: below --
2022-06-20 15:02 [net-next: PATCH 00/12] ACPI support for DSA Marcin Wojtas
2022-06-20 15:02 ` [net-next: PATCH 07/12] net: mdio: allow registering non-PHY devices in ACPI world Marcin Wojtas
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.