[PATCH v2] net: usb: lan78xx: scan all MDIO addresses on LAN7801

Martin Pålsson posted 1 patch 1 month, 2 weeks ago
There is a newer version of this series
drivers/net/usb/lan78xx.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH v2] net: usb: lan78xx: scan all MDIO addresses on LAN7801
Posted by Martin Pålsson 1 month, 2 weeks ago
The LAN7801 is designed exclusively for external PHYs (unlike the
LAN7800/LAN7850 which have internal PHYs), but lan78xx_mdio_init()
restricts PHY scanning to MDIO addresses 0-7 by setting phy_mask to
~(0xFF). This prevents discovery of external PHYs wired to addresses
outside that range.

One such case is the DP83TC814 100BASE-T1 PHY, which is typically
configured at MDIO address 10 via PHYAD bootstrap pins and goes
undetected with the current mask.

Set phy_mask to 0 for the LAN7801 so that all 32 MDIO addresses are
scanned during bus registration, allowing any external PHY to be
discovered regardless of its address.

Fixes: 02dc1f3d613d ("lan78xx: add LAN7801 MAC only support")

Signed-off-by: Martin Pålsson <martin@poleshift.se>
---
Changes in v2:
- Added Fixes: tag
- Link to v1: https://lore.kernel.org/r/20260214-lan78xx-phy-mask-fix-v1-1-3baa100861e4@poleshift.se
---
 drivers/net/usb/lan78xx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index 00397a807393..9d8f1ff7028d 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -2094,8 +2094,8 @@ static int lan78xx_mdio_init(struct lan78xx_net *dev)
 		dev->mdiobus->phy_mask = ~(1 << 1);
 		break;
 	case ID_REV_CHIP_ID_7801_:
-		/* scan thru PHYAD[2..0] */
-		dev->mdiobus->phy_mask = ~(0xFF);
+		/* scan all 32 MDIO addresses for external PHYs */
+		dev->mdiobus->phy_mask = 0;
 		break;
 	}
 

---
base-commit: ee5492fd88cfc079c19fbeac78e9e53b7f6c04f3
change-id: 20260214-lan78xx-phy-mask-fix-a4260de15a4c

Best regards,
-- 
Martin Pålsson <martin@poleshift.se>

Re: [PATCH v2] net: usb: lan78xx: scan all MDIO addresses on LAN7801
Posted by Maxime Chevallier 1 month, 2 weeks ago
Hi Martin,

On 16/02/2026 06:09, Martin Pålsson wrote:
> The LAN7801 is designed exclusively for external PHYs (unlike the
> LAN7800/LAN7850 which have internal PHYs), but lan78xx_mdio_init()
> restricts PHY scanning to MDIO addresses 0-7 by setting phy_mask to
> ~(0xFF). This prevents discovery of external PHYs wired to addresses
> outside that range.
> 
> One such case is the DP83TC814 100BASE-T1 PHY, which is typically
> configured at MDIO address 10 via PHYAD bootstrap pins and goes
> undetected with the current mask.
> 
> Set phy_mask to 0 for the LAN7801 so that all 32 MDIO addresses are
> scanned during bus registration, allowing any external PHY to be
> discovered regardless of its address.
> 
> Fixes: 02dc1f3d613d ("lan78xx: add LAN7801 MAC only support")
> 
> Signed-off-by: Martin Pålsson <martin@poleshift.se>
> ---
> Changes in v2:
> - Added Fixes: tag
> - Link to v1: https://lore.kernel.org/r/20260214-lan78xx-phy-mask-fix-v1-1-3baa100861e4@poleshift.se
> ---
>  drivers/net/usb/lan78xx.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
> index 00397a807393..9d8f1ff7028d 100644
> --- a/drivers/net/usb/lan78xx.c
> +++ b/drivers/net/usb/lan78xx.c
> @@ -2094,8 +2094,8 @@ static int lan78xx_mdio_init(struct lan78xx_net *dev)
>  		dev->mdiobus->phy_mask = ~(1 << 1);
>  		break;
>  	case ID_REV_CHIP_ID_7801_:
> -		/* scan thru PHYAD[2..0] */
> -		dev->mdiobus->phy_mask = ~(0xFF);
> +		/* scan all 32 MDIO addresses for external PHYs */
> +		dev->mdiobus->phy_mask = 0;

As this is the default behaviour for mdio bus controllers, and the
default value for the mask is 0, I think you can simply discard that
assignment.

I don't even think we need a comment, as the other cases for 7800/7850
already have a comment explaining why they are special cases.

Maxime

Re: [PATCH v2] net: usb: lan78xx: scan all MDIO addresses on LAN7801
Posted by Martin Pålsson 1 month, 1 week ago
Hi Maxime,

Thanks for pointing that out. Ran a quick test with the assignment 
removed and the module behaves as desired. A third version of the patch 
coming in a few moments.

Best regards

Martin

On 2/16/26 11:34 AM, Maxime Chevallier wrote:
> Hi Martin,
>
> On 16/02/2026 06:09, Martin Pålsson wrote:
>> The LAN7801 is designed exclusively for external PHYs (unlike the
>> LAN7800/LAN7850 which have internal PHYs), but lan78xx_mdio_init()
>> restricts PHY scanning to MDIO addresses 0-7 by setting phy_mask to
>> ~(0xFF). This prevents discovery of external PHYs wired to addresses
>> outside that range.
>>
>> One such case is the DP83TC814 100BASE-T1 PHY, which is typically
>> configured at MDIO address 10 via PHYAD bootstrap pins and goes
>> undetected with the current mask.
>>
>> Set phy_mask to 0 for the LAN7801 so that all 32 MDIO addresses are
>> scanned during bus registration, allowing any external PHY to be
>> discovered regardless of its address.
>>
>> Fixes: 02dc1f3d613d ("lan78xx: add LAN7801 MAC only support")
>>
>> Signed-off-by: Martin Pålsson <martin@poleshift.se>
>> ---
>> Changes in v2:
>> - Added Fixes: tag
>> - Link to v1: https://lore.kernel.org/r/20260214-lan78xx-phy-mask-fix-v1-1-3baa100861e4@poleshift.se
>> ---
>>   drivers/net/usb/lan78xx.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
>> index 00397a807393..9d8f1ff7028d 100644
>> --- a/drivers/net/usb/lan78xx.c
>> +++ b/drivers/net/usb/lan78xx.c
>> @@ -2094,8 +2094,8 @@ static int lan78xx_mdio_init(struct lan78xx_net *dev)
>>   		dev->mdiobus->phy_mask = ~(1 << 1);
>>   		break;
>>   	case ID_REV_CHIP_ID_7801_:
>> -		/* scan thru PHYAD[2..0] */
>> -		dev->mdiobus->phy_mask = ~(0xFF);
>> +		/* scan all 32 MDIO addresses for external PHYs */
>> +		dev->mdiobus->phy_mask = 0;
> As this is the default behaviour for mdio bus controllers, and the
> default value for the mask is 0, I think you can simply discard that
> assignment.
>
> I don't even think we need a comment, as the other cases for 7800/7850
> already have a comment explaining why they are special cases.
>
> Maxime
>
-- 
Best regards / Bästa hälsningar / Mit freundlichen Grüßen

Martin Pålsson
Poleshift AB - Local Automotive Ethernet Solutions
+46 706 26 49 90
martin@poleshift.se

Re: [PATCH v2] net: usb: lan78xx: scan all MDIO addresses on LAN7801
Posted by Greg KH 1 month, 2 weeks ago
On Mon, Feb 16, 2026 at 05:09:09AM +0000, Martin Pålsson wrote:
> The LAN7801 is designed exclusively for external PHYs (unlike the
> LAN7800/LAN7850 which have internal PHYs), but lan78xx_mdio_init()
> restricts PHY scanning to MDIO addresses 0-7 by setting phy_mask to
> ~(0xFF). This prevents discovery of external PHYs wired to addresses
> outside that range.
> 
> One such case is the DP83TC814 100BASE-T1 PHY, which is typically
> configured at MDIO address 10 via PHYAD bootstrap pins and goes
> undetected with the current mask.
> 
> Set phy_mask to 0 for the LAN7801 so that all 32 MDIO addresses are
> scanned during bus registration, allowing any external PHY to be
> discovered regardless of its address.
> 
> Fixes: 02dc1f3d613d ("lan78xx: add LAN7801 MAC only support")
> 
> Signed-off-by: Martin Pålsson <martin@poleshift.se>
> ---
> Changes in v2:
> - Added Fixes: tag
> - Link to v1: https://lore.kernel.org/r/20260214-lan78xx-phy-mask-fix-v1-1-3baa100861e4@poleshift.se
> ---
>  drivers/net/usb/lan78xx.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
> index 00397a807393..9d8f1ff7028d 100644
> --- a/drivers/net/usb/lan78xx.c
> +++ b/drivers/net/usb/lan78xx.c
> @@ -2094,8 +2094,8 @@ static int lan78xx_mdio_init(struct lan78xx_net *dev)
>  		dev->mdiobus->phy_mask = ~(1 << 1);
>  		break;
>  	case ID_REV_CHIP_ID_7801_:
> -		/* scan thru PHYAD[2..0] */
> -		dev->mdiobus->phy_mask = ~(0xFF);
> +		/* scan all 32 MDIO addresses for external PHYs */
> +		dev->mdiobus->phy_mask = 0;
>  		break;
>  	}
>  
> 
> ---
> base-commit: ee5492fd88cfc079c19fbeac78e9e53b7f6c04f3
> change-id: 20260214-lan78xx-phy-mask-fix-a4260de15a4c
> 
> Best regards,
> -- 
> Martin Pålsson <martin@poleshift.se>
> 
> 

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- You have marked a patch with a "Fixes:" tag for a commit that is in an
  older released kernel, yet you do not have a cc: stable line in the
  signed-off-by area at all, which means that the patch will not be
  applied to any older kernel releases.  To properly fix this, please
  follow the documented rules in the
  Documentation/process/stable-kernel-rules.rst file for how to resolve
  this.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot