All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC net-next 1/2] net: phy: allow mdio bus to probe for c45 devices before c22
@ 2021-05-25  5:58 Wong Vee Khee
  2021-05-25  7:54 ` kernel test robot
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Wong Vee Khee @ 2021-05-25  5:58 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit, Russell King; +Cc: netdev, linux-kernel

Some MAC controllers that is able to pair with  external PHY devices
such as the Synopsys MAC Controller (STMMAC) support both Clause-22 and
Clause-45 access.

When paired with PHY devices that only accessible via Clause-45, such as
the Marvell 88E2110, any attempts to access the PHY devices via
Clause-22 will get a PHY ID of all zeroes.

To fix this, we introduce MDIOBUS_C45_C22 which the MAC controller will
try with Clause-45 access before going to Clause-22.

Signed-off-by: Wong Vee Khee <vee.khee.wong@linux.intel.com>
---
 include/linux/phy.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/phy.h b/include/linux/phy.h
index 60d2b26026a2..9b0e2c76e19b 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -368,6 +368,7 @@ struct mii_bus {
 		MDIOBUS_C22,
 		MDIOBUS_C45,
 		MDIOBUS_C22_C45,
+		MDIOBUS_C45_C22,
 	} probe_capabilities;
 
 	/** @shared_lock: protect access to the shared element */
-- 
2.25.1


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

* Re: [RFC net-next 1/2] net: phy: allow mdio bus to probe for c45 devices before c22
  2021-05-25  5:58 [RFC net-next 1/2] net: phy: allow mdio bus to probe for c45 devices before c22 Wong Vee Khee
@ 2021-05-25  7:54 ` kernel test robot
  2021-05-25  8:31 ` Russell King (Oracle)
  2021-05-25 10:50 ` kernel test robot
  2 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2021-05-25  7:54 UTC (permalink / raw)
  To: kbuild-all

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

Hi Wong,

[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Wong-Vee-Khee/Introduce-MDIO-probe-order-C45-over-C22/20210525-135807
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git c1eaf3c09c54bdc0886f8ecd6532803ab9d82454
config: i386-randconfig-s002-20210525 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.3-341-g8af24329-dirty
        # https://github.com/0day-ci/linux/commit/668af7da7b7552ffdb84b8b68f11f437c92eedbe
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Wong-Vee-Khee/Introduce-MDIO-probe-order-C45-over-C22/20210525-135807
        git checkout 668af7da7b7552ffdb84b8b68f11f437c92eedbe
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' W=1 ARCH=i386 

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/phy/mdio_bus.c: In function 'mdiobus_scan':
>> drivers/net/phy/mdio_bus.c:673:2: warning: enumeration value 'MDIOBUS_C45_C22' not handled in switch [-Wswitch]
     673 |  switch (bus->probe_capabilities) {
         |  ^~~~~~


vim +/MDIOBUS_C45_C22 +673 drivers/net/phy/mdio_bus.c

298cf9beb96795 Lennert Buytenhek 2008-10-08  655  
f89df3f381f1e1 Andrew Lunn       2016-01-06  656  /**
f89df3f381f1e1 Andrew Lunn       2016-01-06  657   * mdiobus_scan - scan a bus for MDIO devices.
f89df3f381f1e1 Andrew Lunn       2016-01-06  658   * @bus: mii_bus to scan
f89df3f381f1e1 Andrew Lunn       2016-01-06  659   * @addr: address on bus to scan
f89df3f381f1e1 Andrew Lunn       2016-01-06  660   *
f89df3f381f1e1 Andrew Lunn       2016-01-06  661   * This function scans the MDIO bus, looking for devices which can be
f89df3f381f1e1 Andrew Lunn       2016-01-06  662   * identified using a vendor/product ID in registers 2 and 3. Not all
f89df3f381f1e1 Andrew Lunn       2016-01-06  663   * MDIO devices have such registers, but PHY devices typically
f89df3f381f1e1 Andrew Lunn       2016-01-06  664   * do. Hence this function assumes anything found is a PHY, or can be
f89df3f381f1e1 Andrew Lunn       2016-01-06  665   * treated as a PHY. Other MDIO devices, such as switches, will
f89df3f381f1e1 Andrew Lunn       2016-01-06  666   * probably not be found during the scan.
f89df3f381f1e1 Andrew Lunn       2016-01-06  667   */
4fd5f812c23c7d Lennert Buytenhek 2008-08-26  668  struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr)
4fd5f812c23c7d Lennert Buytenhek 2008-08-26  669  {
0cc8fecf041d3e Jeremy Linton     2020-06-22  670  	struct phy_device *phydev = ERR_PTR(-ENODEV);
4fd5f812c23c7d Lennert Buytenhek 2008-08-26  671  	int err;
4fd5f812c23c7d Lennert Buytenhek 2008-08-26  672  
0cc8fecf041d3e Jeremy Linton     2020-06-22 @673  	switch (bus->probe_capabilities) {
0cc8fecf041d3e Jeremy Linton     2020-06-22  674  	case MDIOBUS_NO_CAP:
0cc8fecf041d3e Jeremy Linton     2020-06-22  675  	case MDIOBUS_C22:
0cc8fecf041d3e Jeremy Linton     2020-06-22  676  		phydev = get_phy_device(bus, addr, false);
0cc8fecf041d3e Jeremy Linton     2020-06-22  677  		break;
0cc8fecf041d3e Jeremy Linton     2020-06-22  678  	case MDIOBUS_C45:
0cc8fecf041d3e Jeremy Linton     2020-06-22  679  		phydev = get_phy_device(bus, addr, true);
0cc8fecf041d3e Jeremy Linton     2020-06-22  680  		break;
0cc8fecf041d3e Jeremy Linton     2020-06-22  681  	case MDIOBUS_C22_C45:
ac28b9f8cd66d6 David Daney       2012-06-27  682  		phydev = get_phy_device(bus, addr, false);
0cc8fecf041d3e Jeremy Linton     2020-06-22  683  		if (IS_ERR(phydev))
0cc8fecf041d3e Jeremy Linton     2020-06-22  684  			phydev = get_phy_device(bus, addr, true);
0cc8fecf041d3e Jeremy Linton     2020-06-22  685  		break;
0cc8fecf041d3e Jeremy Linton     2020-06-22  686  	}
0cc8fecf041d3e Jeremy Linton     2020-06-22  687  
66c239e71adee6 Sergei Shtylyov   2016-04-24  688  	if (IS_ERR(phydev))
4fd5f812c23c7d Lennert Buytenhek 2008-08-26  689  		return phydev;
e13934563db047 Andy Fleming      2005-08-24  690  
86f6cf41272de9 Daniel Mack       2014-05-24  691  	/*
86f6cf41272de9 Daniel Mack       2014-05-24  692  	 * For DT, see if the auto-probed phy has a correspoding child
86f6cf41272de9 Daniel Mack       2014-05-24  693  	 * in the bus node, and set the of_node pointer in this case.
86f6cf41272de9 Daniel Mack       2014-05-24  694  	 */
f03bc4ae552f30 Andrew Lunn       2016-01-06  695  	of_mdiobus_link_mdiodev(bus, &phydev->mdio);
86f6cf41272de9 Daniel Mack       2014-05-24  696  
4dea547fef1ba2 Grant Likely      2009-04-25  697  	err = phy_device_register(phydev);
6f4a7f4183bdbd Anton Vorontsov   2007-12-04  698  	if (err) {
6f4a7f4183bdbd Anton Vorontsov   2007-12-04  699  		phy_device_free(phydev);
e98a3aabf85f60 Sergei Shtylyov   2016-05-03  700  		return ERR_PTR(-ENODEV);
6f4a7f4183bdbd Anton Vorontsov   2007-12-04  701  	}
e13934563db047 Andy Fleming      2005-08-24  702  
4fd5f812c23c7d Lennert Buytenhek 2008-08-26  703  	return phydev;
e13934563db047 Andy Fleming      2005-08-24  704  }
4fd5f812c23c7d Lennert Buytenhek 2008-08-26  705  EXPORT_SYMBOL(mdiobus_scan);
e13934563db047 Andy Fleming      2005-08-24  706  

---
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: 31121 bytes --]

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

* Re: [RFC net-next 1/2] net: phy: allow mdio bus to probe for c45 devices before c22
  2021-05-25  5:58 [RFC net-next 1/2] net: phy: allow mdio bus to probe for c45 devices before c22 Wong Vee Khee
  2021-05-25  7:54 ` kernel test robot
@ 2021-05-25  8:31 ` Russell King (Oracle)
  2021-06-01 10:52   ` Wong Vee Khee
  2021-05-25 10:50 ` kernel test robot
  2 siblings, 1 reply; 5+ messages in thread
From: Russell King (Oracle) @ 2021-05-25  8:31 UTC (permalink / raw)
  To: Wong Vee Khee; +Cc: Andrew Lunn, Heiner Kallweit, netdev, linux-kernel

On Tue, May 25, 2021 at 01:58:39PM +0800, Wong Vee Khee wrote:
> Some MAC controllers that is able to pair with  external PHY devices
> such as the Synopsys MAC Controller (STMMAC) support both Clause-22 and
> Clause-45 access.
> 
> When paired with PHY devices that only accessible via Clause-45, such as
> the Marvell 88E2110, any attempts to access the PHY devices via
> Clause-22 will get a PHY ID of all zeroes.
> 
> To fix this, we introduce MDIOBUS_C45_C22 which the MAC controller will
> try with Clause-45 access before going to Clause-22.
> 
> Signed-off-by: Wong Vee Khee <vee.khee.wong@linux.intel.com>
> ---
>  include/linux/phy.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/include/linux/phy.h b/include/linux/phy.h
> index 60d2b26026a2..9b0e2c76e19b 100644
> --- a/include/linux/phy.h
> +++ b/include/linux/phy.h
> @@ -368,6 +368,7 @@ struct mii_bus {
>  		MDIOBUS_C22,
>  		MDIOBUS_C45,
>  		MDIOBUS_C22_C45,
> +		MDIOBUS_C45_C22,
>  	} probe_capabilities;
>  
>  	/** @shared_lock: protect access to the shared element */

The new definition doesn't seem to be used anywhere, so this patch
merely adds the definition. It doesn't do what it says in the subject
line. Any driver that sets the capabilities to MDIOBUS_C45_C22 will
end up not doing any probing of the PHY.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

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

* Re: [RFC net-next 1/2] net: phy: allow mdio bus to probe for c45 devices before c22
  2021-05-25  5:58 [RFC net-next 1/2] net: phy: allow mdio bus to probe for c45 devices before c22 Wong Vee Khee
  2021-05-25  7:54 ` kernel test robot
  2021-05-25  8:31 ` Russell King (Oracle)
@ 2021-05-25 10:50 ` kernel test robot
  2 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2021-05-25 10:50 UTC (permalink / raw)
  To: kbuild-all

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

Hi Wong,

[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Wong-Vee-Khee/Introduce-MDIO-probe-order-C45-over-C22/20210525-135807
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git c1eaf3c09c54bdc0886f8ecd6532803ab9d82454
config: x86_64-randconfig-a006-20210525 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 99155e913e9bad5f7f8a247f8bb3a3ff3da74af1)
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/668af7da7b7552ffdb84b8b68f11f437c92eedbe
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Wong-Vee-Khee/Introduce-MDIO-probe-order-C45-over-C22/20210525-135807
        git checkout 668af7da7b7552ffdb84b8b68f11f437c92eedbe
        # 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/phy/mdio_bus.c:673:10: warning: enumeration value 'MDIOBUS_C45_C22' not handled in switch [-Wswitch]
           switch (bus->probe_capabilities) {
                   ^
   1 warning generated.


vim +/MDIOBUS_C45_C22 +673 drivers/net/phy/mdio_bus.c

298cf9beb96795 Lennert Buytenhek 2008-10-08  655  
f89df3f381f1e1 Andrew Lunn       2016-01-06  656  /**
f89df3f381f1e1 Andrew Lunn       2016-01-06  657   * mdiobus_scan - scan a bus for MDIO devices.
f89df3f381f1e1 Andrew Lunn       2016-01-06  658   * @bus: mii_bus to scan
f89df3f381f1e1 Andrew Lunn       2016-01-06  659   * @addr: address on bus to scan
f89df3f381f1e1 Andrew Lunn       2016-01-06  660   *
f89df3f381f1e1 Andrew Lunn       2016-01-06  661   * This function scans the MDIO bus, looking for devices which can be
f89df3f381f1e1 Andrew Lunn       2016-01-06  662   * identified using a vendor/product ID in registers 2 and 3. Not all
f89df3f381f1e1 Andrew Lunn       2016-01-06  663   * MDIO devices have such registers, but PHY devices typically
f89df3f381f1e1 Andrew Lunn       2016-01-06  664   * do. Hence this function assumes anything found is a PHY, or can be
f89df3f381f1e1 Andrew Lunn       2016-01-06  665   * treated as a PHY. Other MDIO devices, such as switches, will
f89df3f381f1e1 Andrew Lunn       2016-01-06  666   * probably not be found during the scan.
f89df3f381f1e1 Andrew Lunn       2016-01-06  667   */
4fd5f812c23c7d Lennert Buytenhek 2008-08-26  668  struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr)
4fd5f812c23c7d Lennert Buytenhek 2008-08-26  669  {
0cc8fecf041d3e Jeremy Linton     2020-06-22  670  	struct phy_device *phydev = ERR_PTR(-ENODEV);
4fd5f812c23c7d Lennert Buytenhek 2008-08-26  671  	int err;
4fd5f812c23c7d Lennert Buytenhek 2008-08-26  672  
0cc8fecf041d3e Jeremy Linton     2020-06-22 @673  	switch (bus->probe_capabilities) {
0cc8fecf041d3e Jeremy Linton     2020-06-22  674  	case MDIOBUS_NO_CAP:
0cc8fecf041d3e Jeremy Linton     2020-06-22  675  	case MDIOBUS_C22:
0cc8fecf041d3e Jeremy Linton     2020-06-22  676  		phydev = get_phy_device(bus, addr, false);
0cc8fecf041d3e Jeremy Linton     2020-06-22  677  		break;
0cc8fecf041d3e Jeremy Linton     2020-06-22  678  	case MDIOBUS_C45:
0cc8fecf041d3e Jeremy Linton     2020-06-22  679  		phydev = get_phy_device(bus, addr, true);
0cc8fecf041d3e Jeremy Linton     2020-06-22  680  		break;
0cc8fecf041d3e Jeremy Linton     2020-06-22  681  	case MDIOBUS_C22_C45:
ac28b9f8cd66d6 David Daney       2012-06-27  682  		phydev = get_phy_device(bus, addr, false);
0cc8fecf041d3e Jeremy Linton     2020-06-22  683  		if (IS_ERR(phydev))
0cc8fecf041d3e Jeremy Linton     2020-06-22  684  			phydev = get_phy_device(bus, addr, true);
0cc8fecf041d3e Jeremy Linton     2020-06-22  685  		break;
0cc8fecf041d3e Jeremy Linton     2020-06-22  686  	}
0cc8fecf041d3e Jeremy Linton     2020-06-22  687  
66c239e71adee6 Sergei Shtylyov   2016-04-24  688  	if (IS_ERR(phydev))
4fd5f812c23c7d Lennert Buytenhek 2008-08-26  689  		return phydev;
e13934563db047 Andy Fleming      2005-08-24  690  
86f6cf41272de9 Daniel Mack       2014-05-24  691  	/*
86f6cf41272de9 Daniel Mack       2014-05-24  692  	 * For DT, see if the auto-probed phy has a correspoding child
86f6cf41272de9 Daniel Mack       2014-05-24  693  	 * in the bus node, and set the of_node pointer in this case.
86f6cf41272de9 Daniel Mack       2014-05-24  694  	 */
f03bc4ae552f30 Andrew Lunn       2016-01-06  695  	of_mdiobus_link_mdiodev(bus, &phydev->mdio);
86f6cf41272de9 Daniel Mack       2014-05-24  696  
4dea547fef1ba2 Grant Likely      2009-04-25  697  	err = phy_device_register(phydev);
6f4a7f4183bdbd Anton Vorontsov   2007-12-04  698  	if (err) {
6f4a7f4183bdbd Anton Vorontsov   2007-12-04  699  		phy_device_free(phydev);
e98a3aabf85f60 Sergei Shtylyov   2016-05-03  700  		return ERR_PTR(-ENODEV);
6f4a7f4183bdbd Anton Vorontsov   2007-12-04  701  	}
e13934563db047 Andy Fleming      2005-08-24  702  
4fd5f812c23c7d Lennert Buytenhek 2008-08-26  703  	return phydev;
e13934563db047 Andy Fleming      2005-08-24  704  }
4fd5f812c23c7d Lennert Buytenhek 2008-08-26  705  EXPORT_SYMBOL(mdiobus_scan);
e13934563db047 Andy Fleming      2005-08-24  706  

---
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: 32577 bytes --]

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

* Re: [RFC net-next 1/2] net: phy: allow mdio bus to probe for c45 devices before c22
  2021-05-25  8:31 ` Russell King (Oracle)
@ 2021-06-01 10:52   ` Wong Vee Khee
  0 siblings, 0 replies; 5+ messages in thread
From: Wong Vee Khee @ 2021-06-01 10:52 UTC (permalink / raw)
  To: Russell King (Oracle); +Cc: Andrew Lunn, Heiner Kallweit, netdev, linux-kernel

On Tue, May 25, 2021 at 09:31:17AM +0100, Russell King (Oracle) wrote:
> On Tue, May 25, 2021 at 01:58:39PM +0800, Wong Vee Khee wrote:
> > Some MAC controllers that is able to pair with  external PHY devices
> > such as the Synopsys MAC Controller (STMMAC) support both Clause-22 and
> > Clause-45 access.
> > 
> > When paired with PHY devices that only accessible via Clause-45, such as
> > the Marvell 88E2110, any attempts to access the PHY devices via
> > Clause-22 will get a PHY ID of all zeroes.
> > 
> > To fix this, we introduce MDIOBUS_C45_C22 which the MAC controller will
> > try with Clause-45 access before going to Clause-22.
> > 
> > Signed-off-by: Wong Vee Khee <vee.khee.wong@linux.intel.com>
> > ---
> >  include/linux/phy.h | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/include/linux/phy.h b/include/linux/phy.h
> > index 60d2b26026a2..9b0e2c76e19b 100644
> > --- a/include/linux/phy.h
> > +++ b/include/linux/phy.h
> > @@ -368,6 +368,7 @@ struct mii_bus {
> >  		MDIOBUS_C22,
> >  		MDIOBUS_C45,
> >  		MDIOBUS_C22_C45,
> > +		MDIOBUS_C45_C22,
> >  	} probe_capabilities;
> >  
> >  	/** @shared_lock: protect access to the shared element */
> 
> The new definition doesn't seem to be used anywhere, so this patch
> merely adds the definition. It doesn't do what it says in the subject
> line. Any driver that sets the capabilities to MDIOBUS_C45_C22 will
> end up not doing any probing of the PHY.
>

You are right. I left out the required changes in drivers/net/mdio_bus.c:-

diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 6045ad3def12..fbf9b8f1f47c 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -684,6 +684,11 @@ struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr)
                if (IS_ERR(phydev))
                        phydev = get_phy_device(bus, addr, true);
                break;
+       case MDIOBUS_C45_C22:
+               phydev = get_phy_device(bus, addr, true);
+               if (IS_ERR(phydev))
+                       phydev = get_phy_device(bus, addr, false);
+               break;
        }

        if (IS_ERR(phydev))


VK 

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

end of thread, other threads:[~2021-06-01 10:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-25  5:58 [RFC net-next 1/2] net: phy: allow mdio bus to probe for c45 devices before c22 Wong Vee Khee
2021-05-25  7:54 ` kernel test robot
2021-05-25  8:31 ` Russell King (Oracle)
2021-06-01 10:52   ` Wong Vee Khee
2021-05-25 10:50 ` kernel test robot

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.