Skip to content

Commit 2bd2974

Browse files
committed
Merge branch 'net-fec-fix-temporary-rmii-clock-reset-on-link-up'
Laurent Badel says: ==================== net: fec: Fix temporary RMII clock reset on link up v2: fixed a compilation warning The FEC drivers performs a "hardware reset" of the MAC module when the link is reported to be up. This causes a short glitch in the RMII clock due to the hardware reset clearing the receive control register which controls the MII mode. It seems that some link partners do not tolerate this glitch, and invalidate the link, which leads to a never-ending loop of negotiation-link up-link down events. This was observed with the iMX28 Soc and LAN8720/LAN8742 PHYs, with two Intel adapters I218-LM and X722-DA2 as link partners, though a number of other link partners do not seem to mind the clock glitch. Changing the hardware reset to a software reset (clearing bit 1 of the ECR register) cured the issue. Attempts to optimize fec_restart() in order to minimize the duration of the glitch were unsuccessful. Furthermore manually producing the glitch by setting MII mode and then back to RMII in two consecutive instructions, resulting in a clock glitch <10us in duration, was enough to cause the partner to invalidate the link. This strongly suggests that the root cause of the link being dropped is indeed the change in clock frequency. In an effort to minimize changes to driver, the patch proposes to use soft reset only for tested SoCs (iMX28) and only if the link is up. This preserves hardware reset in other situations, which might be required for proper setup of the MAC. ==================== Link: https://lore.kernel.org/r/20210125100745.5090-1-laurentbadel@eaton.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents b491e6a + c730ab4 commit 2bd2974

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

‎drivers/net/ethernet/freescale/fec.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,11 @@ struct bufdesc_ex {
462462
*/
463463
#define FEC_QUIRK_CLEAR_SETUP_MII (1 << 17)
464464

465+
/* Some link partners do not tolerate the momentary reset of the REF_CLK
466+
* frequency when the RNCTL register is cleared by hardware reset.
467+
*/
468+
#define FEC_QUIRK_NO_HARD_RESET (1 << 18)
469+
465470
struct bufdesc_prop {
466471
int qid;
467472
/* Address of Rx and Tx buffers */

‎drivers/net/ethernet/freescale/fec_main.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ static const struct fec_devinfo fec_imx27_info = {
100100
static const struct fec_devinfo fec_imx28_info = {
101101
.quirks = FEC_QUIRK_ENET_MAC | FEC_QUIRK_SWAP_FRAME |
102102
FEC_QUIRK_SINGLE_MDIO | FEC_QUIRK_HAS_RACC |
103-
FEC_QUIRK_HAS_FRREG | FEC_QUIRK_CLEAR_SETUP_MII,
103+
FEC_QUIRK_HAS_FRREG | FEC_QUIRK_CLEAR_SETUP_MII |
104+
FEC_QUIRK_NO_HARD_RESET,
104105
};
105106

106107
static const struct fec_devinfo fec_imx6q_info = {
@@ -953,7 +954,8 @@ fec_restart(struct net_device *ndev)
953954
* For i.MX6SX SOC, enet use AXI bus, we use disable MAC
954955
* instead of reset MAC itself.
955956
*/
956-
if (fep->quirks & FEC_QUIRK_HAS_AVB) {
957+
if (fep->quirks & FEC_QUIRK_HAS_AVB ||
958+
((fep->quirks & FEC_QUIRK_NO_HARD_RESET) && fep->link)) {
957959
writel(0, fep->hwp + FEC_ECNTRL);
958960
} else {
959961
writel(1, fep->hwp + FEC_ECNTRL);

0 commit comments

Comments
 (0)