Patch "net: phy: broadcom: Fix brcm_fet_config_init()" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    net: phy: broadcom: Fix brcm_fet_config_init()

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     net-phy-broadcom-fix-brcm_fet_config_init.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 1fac48966402cb74e7fb1a426c518e87c996aedf
Author: Florian Fainelli <f.fainelli@xxxxxxxxx>
Date:   Thu Mar 24 16:24:38 2022 -0700

    net: phy: broadcom: Fix brcm_fet_config_init()
    
    [ Upstream commit bf8bfc4336f7a34e48b3bbd19b1542bf085bdc3d ]
    
    A Broadcom AC201 PHY (same entry as 5241) would be flagged by the
    Broadcom UniMAC MDIO controller as not completing the turn around
    properly since the PHY expects 65 MDC clock cycles to complete a write
    cycle, and the MDIO controller was only sending 64 MDC clock cycles as
    determined by looking at a scope shot.
    
    This would make the subsequent read fail with the UniMAC MDIO controller
    command field having MDIO_READ_FAIL set and we would abort the
    brcm_fet_config_init() function and thus not probe the PHY at all.
    
    After issuing a software reset, wait for at least 1ms which is well
    above the 1us reset delay advertised by the datasheet and issue a dummy
    read to let the PHY turn around the line properly. This read
    specifically ignores -EIO which would be returned by MDIO controllers
    checking for the line being turned around.
    
    If we have a genuine reaad failure, the next read of the interrupt
    status register would pick it up anyway.
    
    Fixes: d7a2ed9248a3 ("broadcom: Add AC131 phy support")
    Signed-off-by: Florian Fainelli <f.fainelli@xxxxxxxxx>
    Link: https://lore.kernel.org/r/20220324232438.1156812-1-f.fainelli@xxxxxxxxx
    Signed-off-by: Jakub Kicinski <kuba@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c
index db26ff8ce7db..b330efb98209 100644
--- a/drivers/net/phy/broadcom.c
+++ b/drivers/net/phy/broadcom.c
@@ -11,6 +11,7 @@
  */
 
 #include "bcm-phy-lib.h"
+#include <linux/delay.h>
 #include <linux/module.h>
 #include <linux/phy.h>
 #include <linux/brcmphy.h>
@@ -553,6 +554,26 @@ static int brcm_fet_config_init(struct phy_device *phydev)
 	if (err < 0)
 		return err;
 
+	/* The datasheet indicates the PHY needs up to 1us to complete a reset,
+	 * build some slack here.
+	 */
+	usleep_range(1000, 2000);
+
+	/* The PHY requires 65 MDC clock cycles to complete a write operation
+	 * and turnaround the line properly.
+	 *
+	 * We ignore -EIO here as the MDIO controller (e.g.: mdio-bcm-unimac)
+	 * may flag the lack of turn-around as a read failure. This is
+	 * particularly true with this combination since the MDIO controller
+	 * only used 64 MDC cycles. This is not a critical failure in this
+	 * specific case and it has no functional impact otherwise, so we let
+	 * that one go through. If there is a genuine bus error, the next read
+	 * of MII_BRCM_FET_INTREG will error out.
+	 */
+	err = phy_read(phydev, MII_BMCR);
+	if (err < 0 && err != -EIO)
+		return err;
+
 	reg = phy_read(phydev, MII_BRCM_FET_INTREG);
 	if (reg < 0)
 		return reg;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux