From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4954DC61DD6 for ; Tue, 1 Sep 2026 15:03:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=EkGhOCFzvgzXqCWrbjYquoub1cfKneInWxWRysEiDys=; b=2hnInSJc0/qw5t LQv/zPMZHPmREqdsS/uGU5BPEvT6LA9hZfJfjORUmKKCpJR0EC/V82Cmm08hgSgPNTsp88JLMcjj/ B2pkALCfG2lB/YQ/lqjwYHYB41bNSWfQsPa7KQqIPrbH+BS6ixzfVVJ7ope/NTHp4Kppbb56JER8A YozVLlQyP0d7oZFgFOSfxh7Sh4n4nQZHrQVlRGZx+bH8E9bFQHfFVn+0VUan1st3zxu8oiqCFFwoc R1xDaxvDc0llBxFTSI2PjBEvlZXJg1vEvFcF+0zWJWcNaitXvBzCzteabbDPWFuHmY/F03MMLX/cb /WbmimeF5nyiY46sjrnw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1x1Q0u-0000000CPsI-49QX; Tue, 01 Sep 2026 15:03:04 +0000 Received: from mail-pz2-x02.google.com ([2607:f8b0:4864:3b::2]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1x1Q0q-0000000CPnZ-3ILW for linux-phy@lists.infradead.org; Tue, 01 Sep 2026 15:03:03 +0000 Received: by mail-pz2-x02.google.com with SMTP id 41be03b00d2f7-cc1c753b1bbso1220993a12.1 for ; Tue, 01 Sep 2026 08:03:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788274980; x=1788879780; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=7inwahIcNU1aV9djAHi258zSUQz0eW0dslHEgzobBAI=; b=d2gREqKo0lfb8VyXKMbI2RQxOylcy9fOyBXo93yvSprdqWzAFJw2p2xTHBtA5FcQyR PUnk/AOhLz3FoCFxP0poCT35ndljecYU7NfPrk4Ifv8lIsHaNihV5YgT3gh1SGU03g3k 7l0HeLk6RAufy4ueiZP8il1GMsfhF0T73tAbOPdJXcwQsnnyJV+deppEwVN9vlUFc/AW lEQa0XjrY+FaXeptQOOVCYrrbHiU1dM3k7MbXPETLuD+B8NP6K5yzpCqLsIBt9pEYCEh OI2OmAXx9Or9eZJfkPnLt+j7ykYgqq9JDSDzPLQFgJ3PFRvwSSE/xtoFUV+cxusSTECo dxYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788274980; x=1788879780; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=7inwahIcNU1aV9djAHi258zSUQz0eW0dslHEgzobBAI=; b=EnMKHYaglHvQpGOPka0peh9NSliDDqJnePCWr2IS9i7uQkpfydGFUbhx6TJsIU7lP+ WPI6geleHoTaMuVVKUV2DO8zrIx9GitBWipQaoxwUWcN2m9mXakdnltdHRG/dGRxyYUY 2nipnMuwWwRcYjAppTAIlwpbjhPl4N28eKH7EGd7Uco2jxHaYlNBT1q1PO66/I2IuynV 7vMx+NrfX0IqtVGrUiyiv29gq3V/6KjFoKY+G8LpTlEOG+kEF9YWDQoay+7ZmOD+SOas 4QEIsE/tpn3h6OsfOfl462ltZmyKtaLFLsE0A3SbuwHvaAJ4EadNgrCNZq/0m3ZdOU4h QfHw== X-Forwarded-Encrypted: i=1; AHgh+RrM6JKocwRfdjMzLYnGvZXPFgj+03JbFsHbNt0zPXRuiyDFCQPZrcVmryluGQGSNe5yH6oBZ73IJ24=@lists.infradead.org X-Gm-Message-State: AFuF++nMrHRdjVgxsdcO1y9kJF8CaWWLai1GBHgYvjHhrz2rx8xQkeae iZskFtKv2TETIiSyaNIvmiw0Oay520giRiROwuynOAwKHBezz84PNGVO X-Gm-Gg: AR+sD11HV5KliS7L4IVF1EodMqPpy3FcYhFirgCc9Yyj2f+ZWnySUCWe0JkkEa3ewVT nv4Oi5eIDbFm8dpDffQzW1p1mgCTOtq8xvjjLzWNPHtHYQKO2trOaFLMimHVxZ5E5Mkfj3bRXiW Yi3rtuRBRXdAKgRJuwmakHowsnX7lMAKJD4RPE7sgbQ1Q64P7Fa0ziHRt+FumE540tRaPkFJ7SI QyFAEi2K3O26hYuTyldZ7XJkf0PBUDvTIDpS5igtxrsw50ewE5yWAlDY52BFD79LLnS8yB5s9is v58Oj/haCbxKkueYim98JJiazdG6uhF5/DEwcmRvwcbjmsPZ3269qUHeKzVVOUPMiQ17zYqgYY7 F9iHx/e8dhcW3WLUwYAi85BECXnKlH1AutmudUXwYxKGM13elzyozN5h29RVQLZcaBS5Ujwn4SB cpj6idw6jsFzypCp1zGy37fdy08u5RFXS0ZT8BYobnyQpz0xZd7gFNnasxlv4= X-Received: by 2002:a05:6a00:3d0a:b0:848:417a:d1a6 with SMTP id d2e1a72fcca58-85b5b321d25mr11818840b3a.15.1788274979663; Tue, 01 Sep 2026 08:02:59 -0700 (PDT) Received: from server.lan ([150.230.217.250]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-85dc0716846sm27914b3a.45.2026.09.01.08.02.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2026 08:02:58 -0700 (PDT) From: Coia Prant To: Andrew Lunn , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heiko Stuebner , Vinod Koul , Maxime Chevallier , Maxime Coquelin , Alexandre Torgue , Lad Prabhakar , Romain Gantois , Heiner Kallweit , Coia Prant Cc: Neil Armstrong , Russell King , Shawn Lin , David Heidelberg , netdev@vger.kernel.org, linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, linux-renesas-soc@vger.kernel.org, Jiawen Wu Subject: [PATCH net-next v3 06/10] net: pcs: xpcs: add ANRESTART support for SGMII link recovery Date: Tue, 1 Sep 2026 23:01:06 +0800 Message-ID: <20260901150111.141037-7-coiaprant@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260901150111.141037-1-coiaprant@gmail.com> References: <20260901150111.141037-1-coiaprant@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260901_080300_828365_6F5E245C X-CRM114-Status: GOOD ( 16.18 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org On some hardware using the DesignWare XPCS IP (e.g., RK3568 MAC side SGMII), the PCS does not automatically restart auto-negotiation when the link goes down and comes back up. Without an explicit ANRESTART, the link stays down forever. Add BMCR_ANRESTART in two places: 1. In xpcs_config_aneg_c37_sgmii(), when starting AN, set ANRESTART alongside ANENABLE to initiate a fresh negotiation. 2. In xpcs_get_state_c37_sgmii(), when link is down and AN completion is detected, clear the interrupt and trigger ANRESTART to restart the negotiation process. Tested-by: Jiawen Wu Tested-by: Maxime Chevallier Signed-off-by: Coia Prant --- drivers/net/pcs/pcs-xpcs.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index 0337e2bcc0125..50b9cdf94fdaa 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -816,9 +816,14 @@ static int xpcs_config_aneg_c37_sgmii(struct dw_xpcs *xpcs, if (ret < 0) return ret; + /* Clear CL37 AN complete status */ + ret = xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_INTR_STS, 0); + if (ret < 0) + return ret; + if (neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED) ret = xpcs_write(xpcs, MDIO_MMD_VEND2, MII_BMCR, - mdio_ctrl | BMCR_ANENABLE); + mdio_ctrl | BMCR_ANENABLE | BMCR_ANRESTART); return ret; } @@ -1093,10 +1098,15 @@ static int xpcs_get_state_c37_sgmii(struct dw_xpcs *xpcs, return 0; } - /* Clear AN complete status or interrupt */ - if (state->an_complete) + if (state->an_complete) { + /* Clear AN complete status or interrupt */ xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_INTR_STS, 0); + /* Initiate the next round of AN */ + xpcs_modify(xpcs, MDIO_MMD_VEND2, MII_BMCR, BMCR_ANRESTART, + BMCR_ANRESTART); + } + return 0; } -- 2.47.3 -- linux-phy mailing list linux-phy@lists.infradead.org https://lists.infradead.org/mailman/listinfo/linux-phy From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pz2-f9.google.com (mail-pz2-f9.google.com [74.125.228.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A06F41D201 for ; Tue, 1 Sep 2026 15:03:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.228.9 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788274982; cv=none; b=cUhhmjpVx6fb0DuTb1JGfXMsCoKbvOIWryfyobxRu5U02OLcWzirjmPqrzxZSJjKc+z5/xRp2zi6emsa36FyQQnEYFc4G4Af751qVc63TkgDbd/2db4elQFUJnxbsvPmgf/xWtK7gOvSwrkLDEQXxFdOObtxI6tIxflwVKTZHoA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788274982; c=relaxed/simple; bh=iCQafZpFqsdcijM7wQ/VBsqWEiby6qk8Gp6Xz65rtD8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W3aP0OEnelLEwbKmyJL0IhPpMRLP5viq1Zp4psD+VUgLJFmZc1CebJqmQJJtdGjPXoLIU+WBWv0M44Ab+uZYm9fp4pvDT+5/+zxK+ofLJQzfM0NwSA4VjMS5jsAAYZK+oNlsYMSsL2247WNizNZ+u8rKUw0nxnpvZPZMTm7H+/M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=rkktWk4S; arc=none smtp.client-ip=74.125.228.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rkktWk4S" Received: by mail-pz2-f9.google.com with SMTP id 41be03b00d2f7-cc150711112so775496a12.0 for ; Tue, 01 Sep 2026 08:03:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788274980; x=1788879780; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=7inwahIcNU1aV9djAHi258zSUQz0eW0dslHEgzobBAI=; b=rkktWk4SfofP6WnpAL5ws1bWPxRUKhfc1yDrgKLcjuibn4VjzSdmuTsdpUVs5Vkrl9 aFZohe9LfrVWYyNiW7yWYapLl9W/3KhGA6I5ubzudlBMgUeyTRhhcB+jjH/6b5nTTgFz wmUcz2W7UJQRpnoGI2xAGfnJ0pmuHlkrGcP11+Axk4ofyvpB5fTJGcnT+XaqgLooCl3q Qr81TNjne90RGvlUN5NeP3RmbgKi6DhQHeRwwCfS4E8rgRDBX6i6VsYsxg8ya8JAReVU A7TsaK4tjgk66McWdiM1i7p/JPHrOo4THDXLt2rHiuIQqDwUhOXN/Y+usZAxx38ZzZvQ gihg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788274980; x=1788879780; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=7inwahIcNU1aV9djAHi258zSUQz0eW0dslHEgzobBAI=; b=PLMh26VTAufmu043kW+H3IczDB7UKqFZ0L79PolB+LeS7/Z/iXbKg5gSwZSW87e7VA lxK0uDcqAxsY+hS0yd7duEofeyBMLa/2+xifQkMclhMM0bC5i0atrMjcOaUDJVEKC48g +ijsNeVbwsFnDZUJgjqcTyPemu7DVnZpRuwa8EWuq2RE/St2/ZpGwfpuVezclOBvo+Zb dbIVcZrbv7bW89Hjte++huDxyf44UZ/WYBTepRhqCJfI2LYQdPdG86fonP1h+HHkyTpO CRknw6zdXu/k4/lZ5x61pPUvPzuGMWrdtdz2Cw4CHyfoL9AZhTGp6VwZ7XchlNS0Hhzi g6dA== X-Forwarded-Encrypted: i=1; AHgh+RqzMhMCFuRlFhpqcQ/q8z/UOC8RgsJbZ/AOY0Uv/0cXaevvmtW7IQxs95qu/zuu82BdaU56AmaTtHSF@vger.kernel.org X-Gm-Message-State: AFuF++lREiHmyU0hTx+JAQ2+8wc8+/uyTXppJaKi4qM1PPA7urbw6BY3 2x1k7YKg84VZvlFvOl8pTq1/g56JSYez8BmsNmdp6o9NIFdBaaj8JmNg X-Gm-Gg: AR+sD137+bCaFRVk07gaI3daPQj1XPlTPctWrEKsVaLWuWJ8GZwb2RwJmELO5167GBN bEOC3AEax6Yvqxt3WsVOTjueXHqFF1L3qfZxyPeyBslOz7cYS/LJFt9hEsS4hhjFTOGaF0v0n7j vdqZVGFWTumOfrE+c330TCP59+UPR7DB1gh1qciSt+gnyweFgo+h7N9a2Shdg/cu8cWg9omDBcr M6JVUkp7yPX9ZJ1p/rHXYQpalxOhWy96Y1ytMrTT0W0t1WzZlF6WeybpUKnchEq5CYM5ws42Msr fcON8JPkjo918gV0+fxuNKZT0+KsP5xx3PQsLOLL+Oo8UGNFIZP4MjhDhwtGkU8dESFAQ1cVq5Z kKe1KEoRX6t/i26C9nIwkziyhwzHYR0G005HjZB11rAXIOzXvm2vaUcZP7LLqwB9I6IEwnpF8Gi om+85/O6Twg2DKJXF3wZyPnrlLHm/nx9+rq5u+IcBZkIILEtgVyCtz2/droEo= X-Received: by 2002:a05:6a00:3d0a:b0:848:417a:d1a6 with SMTP id d2e1a72fcca58-85b5b321d25mr11818840b3a.15.1788274979663; Tue, 01 Sep 2026 08:02:59 -0700 (PDT) Received: from server.lan ([150.230.217.250]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-85dc0716846sm27914b3a.45.2026.09.01.08.02.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2026 08:02:58 -0700 (PDT) From: Coia Prant To: Andrew Lunn , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heiko Stuebner , Vinod Koul , Maxime Chevallier , Maxime Coquelin , Alexandre Torgue , Lad Prabhakar , Romain Gantois , Heiner Kallweit , Coia Prant Cc: Neil Armstrong , Russell King , Shawn Lin , David Heidelberg , netdev@vger.kernel.org, linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, linux-renesas-soc@vger.kernel.org, Jiawen Wu Subject: [PATCH net-next v3 06/10] net: pcs: xpcs: add ANRESTART support for SGMII link recovery Date: Tue, 1 Sep 2026 23:01:06 +0800 Message-ID: <20260901150111.141037-7-coiaprant@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260901150111.141037-1-coiaprant@gmail.com> References: <20260901150111.141037-1-coiaprant@gmail.com> Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On some hardware using the DesignWare XPCS IP (e.g., RK3568 MAC side SGMII), the PCS does not automatically restart auto-negotiation when the link goes down and comes back up. Without an explicit ANRESTART, the link stays down forever. Add BMCR_ANRESTART in two places: 1. In xpcs_config_aneg_c37_sgmii(), when starting AN, set ANRESTART alongside ANENABLE to initiate a fresh negotiation. 2. In xpcs_get_state_c37_sgmii(), when link is down and AN completion is detected, clear the interrupt and trigger ANRESTART to restart the negotiation process. Tested-by: Jiawen Wu Tested-by: Maxime Chevallier Signed-off-by: Coia Prant --- drivers/net/pcs/pcs-xpcs.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index 0337e2bcc0125..50b9cdf94fdaa 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -816,9 +816,14 @@ static int xpcs_config_aneg_c37_sgmii(struct dw_xpcs *xpcs, if (ret < 0) return ret; + /* Clear CL37 AN complete status */ + ret = xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_INTR_STS, 0); + if (ret < 0) + return ret; + if (neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED) ret = xpcs_write(xpcs, MDIO_MMD_VEND2, MII_BMCR, - mdio_ctrl | BMCR_ANENABLE); + mdio_ctrl | BMCR_ANENABLE | BMCR_ANRESTART); return ret; } @@ -1093,10 +1098,15 @@ static int xpcs_get_state_c37_sgmii(struct dw_xpcs *xpcs, return 0; } - /* Clear AN complete status or interrupt */ - if (state->an_complete) + if (state->an_complete) { + /* Clear AN complete status or interrupt */ xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_INTR_STS, 0); + /* Initiate the next round of AN */ + xpcs_modify(xpcs, MDIO_MMD_VEND2, MII_BMCR, BMCR_ANRESTART, + BMCR_ANRESTART); + } + return 0; } -- 2.47.3 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1A888C61DD3 for ; Tue, 1 Sep 2026 15:03:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/LhoxFg5G5n7yzemV0549APMVAdfyfd81JwCK+Ymk6s=; b=D3B+So66dKU449 99xwiEh/Bxbg4i5Ac4eHIGjMbxmttMarb6rZfdJnopNLmCjBQCGaHUruJDmyunYzr93+PsNWRgfVK KaZ0YRVaUU8cDmquHjw8RfCOHzur1Td7AjJtQpesaX4XTTC8cdB/BoMPy7sY7S7Q1ZkCKIytSrR7d mWIkdSdSmJ07q2vnAfdOKSfZb/56+j8W7dE9Tszv41LQ9SdF1kAWEDuDCINPKAjM7EYwzHyBQZJL2 zf+z9BJoXcdWFd9+kvsuTka93q0AJYbjJuhEgQpUQdYq0YGNhuhj6YxK6xeP3hftfjK5FrMYq3QhO oO9eWFvf3hN0uZpNNiiA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1x1Q0t-0000000CPqt-3rq8; Tue, 01 Sep 2026 15:03:03 +0000 Received: from mail-pz2-x0b.google.com ([2607:f8b0:4864:3b::b]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1x1Q0q-0000000CPna-1uyR for linux-rockchip@lists.infradead.org; Tue, 01 Sep 2026 15:03:02 +0000 Received: by mail-pz2-x0b.google.com with SMTP id 41be03b00d2f7-cc150711112so775497a12.0 for ; Tue, 01 Sep 2026 08:03:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788274980; x=1788879780; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=7inwahIcNU1aV9djAHi258zSUQz0eW0dslHEgzobBAI=; b=d2gREqKo0lfb8VyXKMbI2RQxOylcy9fOyBXo93yvSprdqWzAFJw2p2xTHBtA5FcQyR PUnk/AOhLz3FoCFxP0poCT35ndljecYU7NfPrk4Ifv8lIsHaNihV5YgT3gh1SGU03g3k 7l0HeLk6RAufy4ueiZP8il1GMsfhF0T73tAbOPdJXcwQsnnyJV+deppEwVN9vlUFc/AW lEQa0XjrY+FaXeptQOOVCYrrbHiU1dM3k7MbXPETLuD+B8NP6K5yzpCqLsIBt9pEYCEh OI2OmAXx9Or9eZJfkPnLt+j7ykYgqq9JDSDzPLQFgJ3PFRvwSSE/xtoFUV+cxusSTECo dxYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788274980; x=1788879780; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=7inwahIcNU1aV9djAHi258zSUQz0eW0dslHEgzobBAI=; b=VSlOsHqkkyc3yP5XpDi/rfl88DYdjBk4sTi8KQs1j6TNw6AG8M94P9xZS881WHB24c Y/1C/5HH4wew0Bc7lr2WQRvG8mRBQz4YyCZ3Ehi4h0mzgvjxmsATnE3tDhnNoQLKvL8q nQebNZPF9oGdjIFmzdK18AAztXx2Z4p5qKv2L+uwXqeedAJuTpZi7Wi0qluJL4Uo79MR f+vTS+F7G5PvajxIb+V/oFpvTCviICsyi+8f8bPWqwnx0q+3mGUvpaU6RHi1qIC2b5o0 6IerfgacsNbfbhX1ehUma0MODan8tsuAgsnmHw0j42v6cKBVT8/ZxbBtPInC5M3Xoi03 ToFg== X-Forwarded-Encrypted: i=1; AHgh+Ro926fjyJb4bzdPrqirJ0hXgc37VH6460APN6WXI/6ztQtlJuFknQXN11e9Fuiz/eyPQZ+pFOJcYG2jRReh+Q==@lists.infradead.org X-Gm-Message-State: AFuF++k6VswBra0w3FunxDCcTyd95SOazc3Gvqi5opopZLXJaAhFqA8c +YXTPQ77WkFNKVk7g8VA4uEYY93d29FgPu/iliHsS7fZd8C4FhaJqU5v X-Gm-Gg: AR+sD11qTfT/y8Lrmewi4hdW3ocX/XS6uPTiHHre4YG3xXEiUkqggEjSPuskPmKidve ntNaUkYH/sy0VrjM0HmRw5/j4r4xzx8yJOo73yOYiGc6TMpdX4jrXx5OexcDpNvTO1E2+XFHPQS Uzr2kdzhpgKCVViJXYDHyqTnXh3NDyB57WCOr4TlUOwbGsjQdu8cwLWNjzoyK5hLcsxf29X1csc xiLI1k60ig3j5Ltpe0/cTYnPJMltxsI8Z9c49yzChI585AJUzpwciuxGiom/RPKeV2es+Y1dM+8 roHlBB5p4OOBumfjFLPTqbMF2P+j1xMJRVNqpXMeY4InDKXSBqDKNGIBAZqE6KlM3AMCiQW5748 Cmxbbg+khJrCbjHqh2mFQmlpcK4fIsrO8poZEU3X3CDU5uII2Eti2W2pwCx44G7JHs2dNuNe2l0 hkIvc5cDUBqWUMHkCX7GnipS3Gyu48brcUdriEMP7w02dnOnRMA7i+3JOgQag= X-Received: by 2002:a05:6a00:3d0a:b0:848:417a:d1a6 with SMTP id d2e1a72fcca58-85b5b321d25mr11818840b3a.15.1788274979663; Tue, 01 Sep 2026 08:02:59 -0700 (PDT) Received: from server.lan ([150.230.217.250]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-85dc0716846sm27914b3a.45.2026.09.01.08.02.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2026 08:02:58 -0700 (PDT) From: Coia Prant To: Andrew Lunn , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heiko Stuebner , Vinod Koul , Maxime Chevallier , Maxime Coquelin , Alexandre Torgue , Lad Prabhakar , Romain Gantois , Heiner Kallweit , Coia Prant Cc: Neil Armstrong , Russell King , Shawn Lin , David Heidelberg , netdev@vger.kernel.org, linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, linux-renesas-soc@vger.kernel.org, Jiawen Wu Subject: [PATCH net-next v3 06/10] net: pcs: xpcs: add ANRESTART support for SGMII link recovery Date: Tue, 1 Sep 2026 23:01:06 +0800 Message-ID: <20260901150111.141037-7-coiaprant@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260901150111.141037-1-coiaprant@gmail.com> References: <20260901150111.141037-1-coiaprant@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260901_080300_521390_AE517DB7 X-CRM114-Status: GOOD ( 16.40 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org On some hardware using the DesignWare XPCS IP (e.g., RK3568 MAC side SGMII), the PCS does not automatically restart auto-negotiation when the link goes down and comes back up. Without an explicit ANRESTART, the link stays down forever. Add BMCR_ANRESTART in two places: 1. In xpcs_config_aneg_c37_sgmii(), when starting AN, set ANRESTART alongside ANENABLE to initiate a fresh negotiation. 2. In xpcs_get_state_c37_sgmii(), when link is down and AN completion is detected, clear the interrupt and trigger ANRESTART to restart the negotiation process. Tested-by: Jiawen Wu Tested-by: Maxime Chevallier Signed-off-by: Coia Prant --- drivers/net/pcs/pcs-xpcs.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index 0337e2bcc0125..50b9cdf94fdaa 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -816,9 +816,14 @@ static int xpcs_config_aneg_c37_sgmii(struct dw_xpcs *xpcs, if (ret < 0) return ret; + /* Clear CL37 AN complete status */ + ret = xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_INTR_STS, 0); + if (ret < 0) + return ret; + if (neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED) ret = xpcs_write(xpcs, MDIO_MMD_VEND2, MII_BMCR, - mdio_ctrl | BMCR_ANENABLE); + mdio_ctrl | BMCR_ANENABLE | BMCR_ANRESTART); return ret; } @@ -1093,10 +1098,15 @@ static int xpcs_get_state_c37_sgmii(struct dw_xpcs *xpcs, return 0; } - /* Clear AN complete status or interrupt */ - if (state->an_complete) + if (state->an_complete) { + /* Clear AN complete status or interrupt */ xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_INTR_STS, 0); + /* Initiate the next round of AN */ + xpcs_modify(xpcs, MDIO_MMD_VEND2, MII_BMCR, BMCR_ANRESTART, + BMCR_ANRESTART); + } + return 0; } -- 2.47.3 _______________________________________________ Linux-rockchip mailing list Linux-rockchip@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-rockchip