[PATCH rtems-libbsd v2 1/2] freebsd/if_cgem: Fail probe for unterminated MII
Kinsey Moore
kinsey.moore at oarcorp.com
Mon Jul 12 12:57:45 UTC 2021
On 7/11/2021 19:47, Chris Johns wrote:
> On 10/7/21 12:53 am, Kinsey Moore wrote:
>> When the MII bus is unterminated on unused interfaces, it results in PHY
>> read timeouts which manifest as spurious PHYs during the attach call.
>> Detect these timeouts during the probe so the device can be ignored.
>> ---
>> freebsd/sys/dev/cadence/if_cgem.c | 18 ++++++++++++++++++
>> 1 file changed, 18 insertions(+)
>>
>> diff --git a/freebsd/sys/dev/cadence/if_cgem.c b/freebsd/sys/dev/cadence/if_cgem.c
>> index 34df7ac7..51e0bd6d 100644
>> --- a/freebsd/sys/dev/cadence/if_cgem.c
>> +++ b/freebsd/sys/dev/cadence/if_cgem.c
>> @@ -1955,6 +1955,24 @@ cgem_probe(device_t dev)
>> return (ENXIO);
>> #endif /* __rtems__ */
>>
>> + struct cgem_softc *sc = device_get_softc(dev);
>> + int val, rid = 0;
>> +
>> + /* Check for PHY read timeouts which indicate an unterminated MII bus */
>> + sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
>> + RF_ACTIVE);
>> +
>> + val = cgem_miibus_readreg(dev, 0, MII_BMSR);
>> + if (val == -1) {
>> + bus_release_resource(dev, SYS_RES_MEMORY, &rid,
>> + sc->mem_res);
>> + sc->mem_res = NULL;
>> + return (ENXIO);
>> + }
>> + bus_release_resource(dev, SYS_RES_MEMORY, &rid,
>> + sc->mem_res);
>> + sc->mem_res = NULL;
> Should this change be in an "#else /* __rtems__ */" section until merged upstream?
>
> Otherwise this change is looking good.
>
> Chris
>
>> +
>> device_set_desc(dev, "Cadence CGEM Gigabit Ethernet Interface");
>> return (0);
>> }
I'll wrap it in the #else block before commit, thanks.
Kinsey
More information about the devel
mailing list