Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp7782863rwd; Tue, 20 Jun 2023 06:15:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5gpJQEMHr94d4+DAiX0TD0UTYWzPLTzanNvdAUu3ICwkVdGX9Fh8YLIHhjEyp1P/g1AIOu X-Received: by 2002:a05:6358:9f9f:b0:129:b8e9:b740 with SMTP id fy31-20020a0563589f9f00b00129b8e9b740mr1600228rwb.27.1687266948091; Tue, 20 Jun 2023 06:15:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687266948; cv=none; d=google.com; s=arc-20160816; b=GGes2YU6M1OvEj02w23yKz2CWF2MuDsCceLns7XS8LPTfYvDHW7iWbtIXejwaw7q3s wHgJuZQE/VPun3aMheQ7Y7sbOqdDhYJ8+a9FW64xzl3uUW38rdfLhSo0FkRbp/7AawWv zvhZrEGZBVruDhkOvgfpZuJTmUxG21MFQGUlynPIMwbslh2mMLH8Q8dryBhPgVDV3/9r X4kSjF3hNnlXDgIYeLlk7MMxRu7fxibE6Tjera3xOxUhK0l12iKt0MiVTvR1w2p/zwUc VVSW8tvAN4cM/NXlmYbpeyXgoCk6XGk74TfkoL7G5YvytjY1H/B+duHOClGYF8Ki1uuQ a9aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=AOs5PA1+vHhhge3uNF1xGJWvvGcHBSAcEHs/EXK8LWw=; b=GLKwESM5e9OL+uUlGhK+M9g4eMCwW0K6a/lIavoBLo0icnDRTMDnmA9zVxt2ZovGlr Ys7v7MMKMfKACLByoaY5CegS3DCn5Vh9quen6TcWBDNCs7yYA0FAhuVAyoNYJ/3E0H9Q vyEWGWfkkTok5AeLxyhfllcQR/+Eq7bGrcbvyRinkuj6SYeJSkCXKnPgwycUSff5sWpS MXoUm4BslklrSzM0tEm/UfFRQoRk0RZobGiC1wfiYtuZRgjHX0ylVw7A0CWmsyyaqdLr HVll53qEs6AwuV0/hLT2yh+DtxIF3AaZROUI7Ov92NTWTnUtboW3i+WNDL8w0C4z+zwh tDQA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e5-20020a636905000000b00553cb2037f6si1618308pgc.185.2023.06.20.06.15.33; Tue, 20 Jun 2023 06:15:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231425AbjFTMz2 (ORCPT + 99 others); Tue, 20 Jun 2023 08:55:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229933AbjFTMz1 (ORCPT ); Tue, 20 Jun 2023 08:55:27 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 424C510F8 for ; Tue, 20 Jun 2023 05:55:26 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qBat4-0005HR-Bi; Tue, 20 Jun 2023 14:55:10 +0200 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1qBat2-008nEH-SB; Tue, 20 Jun 2023 14:55:08 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1qBat2-00A50M-7A; Tue, 20 Jun 2023 14:55:08 +0200 From: Oleksij Rempel To: Andrew Lunn , Heiner Kallweit , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v1 1/1] net: phy: dp83td510: fix kernel stall during netboot in DP83TD510E PHY driver Date: Tue, 20 Jun 2023 14:55:05 +0200 Message-Id: <20230620125505.2402497-1-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix an issue where the kernel would stall during netboot, showing the "sched: RT throttling activated" message. This stall was triggered by the behavior of the mii_interrupt bit (Bit 7 - DP83TD510E_STS_MII_INT) in the DP83TD510E's PHY_STS Register (Address = 0x10). The DP83TD510E datasheet (2020) states that the bit clears on write, however, in practice, the bit clears on read. This discrepancy had significant implications on the driver's interrupt handling. The PHY_STS Register was used by handle_interrupt() to check for pending interrupts and by read_status() to get the current link status. The call to read_status() was unintentionally clearing the mii_interrupt status bit without deasserting the IRQ pin, causing handle_interrupt() to miss other pending interrupts. This issue was most apparent during netboot. The fix refrains from using the PHY_STS Register for interrupt handling. Instead, we now solely rely on the INTERRUPT_REG_1 Register (Address = 0x12) and INTERRUPT_REG_2 Register (Address = 0x13) for this purpose. These registers directly influence the IRQ pin state and are latched high until read. Note: The INTERRUPT_REG_2 Register (Address = 0x13) exists and can also be used for interrupt handling, specifically for "Aneg page received interrupt" and "Polarity change interrupt". However, these features are currently not supported by this driver. Fixes: 165cd04fe253 ("net: phy: dp83td510: Add support for the DP83TD510 Ethernet PHY") Signed-off-by: Oleksij Rempel --- drivers/net/phy/dp83td510.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/drivers/net/phy/dp83td510.c b/drivers/net/phy/dp83td510.c index 3cd9a77f9532..d7616b13c594 100644 --- a/drivers/net/phy/dp83td510.c +++ b/drivers/net/phy/dp83td510.c @@ -12,6 +12,11 @@ /* MDIO_MMD_VEND2 registers */ #define DP83TD510E_PHY_STS 0x10 +/* Bit 7 - mii_interrupt, active high. Clears on read. + * Note: Clearing does not necessarily deactivate IRQ pin if interrupts pending. + * This differs from the DP83TD510E datasheet (2020) which states this bit + * clears on write 0. + */ #define DP83TD510E_STS_MII_INT BIT(7) #define DP83TD510E_LINK_STATUS BIT(0) @@ -53,12 +58,6 @@ static int dp83td510_config_intr(struct phy_device *phydev) int ret; if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { - /* Clear any pending interrupts */ - ret = phy_write_mmd(phydev, MDIO_MMD_VEND2, DP83TD510E_PHY_STS, - 0x0); - if (ret) - return ret; - ret = phy_write_mmd(phydev, MDIO_MMD_VEND2, DP83TD510E_INTERRUPT_REG_1, DP83TD510E_INT1_LINK_EN); @@ -81,10 +80,6 @@ static int dp83td510_config_intr(struct phy_device *phydev) DP83TD510E_GENCFG_INT_EN); if (ret) return ret; - - /* Clear any pending interrupts */ - ret = phy_write_mmd(phydev, MDIO_MMD_VEND2, DP83TD510E_PHY_STS, - 0x0); } return ret; @@ -94,14 +89,6 @@ static irqreturn_t dp83td510_handle_interrupt(struct phy_device *phydev) { int ret; - ret = phy_read_mmd(phydev, MDIO_MMD_VEND2, DP83TD510E_PHY_STS); - if (ret < 0) { - phy_error(phydev); - return IRQ_NONE; - } else if (!(ret & DP83TD510E_STS_MII_INT)) { - return IRQ_NONE; - } - /* Read the current enabled interrupts */ ret = phy_read_mmd(phydev, MDIO_MMD_VEND2, DP83TD510E_INTERRUPT_REG_1); if (ret < 0) { -- 2.39.2