Re: [PATCH] net: phy: micrel: Fix detection of ksz87xx switch

From: Steve Bennett
Date: Fri Jul 30 2021 - 18:19:56 EST


> On 31 Jul 2021, at 2:59 am, Jakub Kicinski <kuba@xxxxxxxxxx> wrote:
>
> Please extend the CC list to the maintainers, and people who
> worked on this driver in the past, especially Marek.

Sure, I can do that in a v2 of the patch along with the more detailed
explanation below.

>
> On Fri, 30 Jul 2021 20:51:20 +1000 Steve Bennett wrote:
>> The previous logic was wrong such that the ksz87xx
>> switch was not identified correctly.
>
> Any more details of what is happening? Which extact device do you see
> this problem on?

I have a ksz8795 switch.

Without the patch:

ksz8795-switch spi3.1 ade1 (uninitialized): PHY [dsa-0.1:03] driver [Generic PHY]
ksz8795-switch spi3.1 ade2 (uninitialized): PHY [dsa-0.1:04] driver [Generic PHY]

With the patch:

ksz8795-switch spi3.1 ade1 (uninitialized): PHY [dsa-0.1:03] driver [Micrel KSZ87XX Switch]
ksz8795-switch spi3.1 ade2 (uninitialized): PHY [dsa-0.1:04] driver [Micrel KSZ87XX Switch]

>
> I presume ksz87xx devices used to work and gotten broken - would you
> mind clarifying and adding a Fixes tag to help backporting to the
> correct stable branches?

I looked at the original commit 8b95599c55ed24b36cf44a4720067cfe67edbcb4, but
it couldn't ever have worked.

ksz8051_ksz8795_match_phy_device() uses the parameter ksz_phy_id to discriminate
whether it was called from ksz8051_match_phy_device() or from ksz8795_match_phy_device()
but since PHY_ID_KSZ87XX is the same value as PHY_ID_KSZ8051, this doesn't do anything.

Need to pass a different value to discriminate.

>
>> diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
>> index 4d53886f7d51..a4acec02c8cb 100644
>> --- a/drivers/net/phy/micrel.c
>> +++ b/drivers/net/phy/micrel.c
>> @@ -401,11 +401,11 @@ static int ksz8041_config_aneg(struct phy_device *phydev)
>> }
>>
>> static int ksz8051_ksz8795_match_phy_device(struct phy_device *phydev,
>> - const u32 ksz_phy_id)
>> + const u32 ksz_8051)
>
> bool and use true/false in the callers?

Sure.