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 F3D5FC25B78 for ; Tue, 28 May 2024 16:57:52 +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:Cc:To:Subject:From:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=lbSiY6rV4KO/UoO2XbTjPxhAn8NLfplWO7eTIFDKsi8=; b=AJMqNpPnI0lxVU DRLJACSeSttXtY9ZbhtxewxxGat59xLvTjBrW8ys+S5ggPa2dzqG6PoETR5qsJdSA02BsL1Nb82Cl +BC5SL5XGE6FWTLP/4++ki5JwAa7vXMxgvAdIZmpRfAU557ms7Uo+Rjxln9AFdmdO2yNj2PfvlL6l 3HS6yg2PR7Tb5rVFa7Nw+U5fnCzBOpj6b12hjmxKeqnF98T1TTaP9vou2LmYQaPZzzgiFCXugXhcZ 1AYUj51V98j05yp9anLSuRLxJkLf/RpvQC85pc9JQAbW602EEjtW1sRqkLT2OA9yszKXXlGjPk40T J2yMAyOrMqaeKENKFABA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sC08m-00000001UFr-3yTN; Tue, 28 May 2024 16:57:36 +0000 Received: from out-170.mta0.migadu.com ([91.218.175.170]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sC08j-00000001UFD-1LAI for linux-arm-kernel@lists.infradead.org; Tue, 28 May 2024 16:57:35 +0000 X-Envelope-To: andrew@lunn.ch DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1716915449; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=jNceAp37GB1si/9T0wIzhGZuQRX1PlheHnoihJOZ330=; b=FMaIWg8ZBt2go1CkaZdykQtMyRQWLzUq8vG5dX1s/BuhqoUK8kYWDN//VMNuJzplplQ8KU UotCwJMPUUHD+HUaf9QEb2kc1h/ThDL6i7kDh6wJxiHjxpl2L3ogNkU2MsEjKKGVo61l9D gfJpYBIKAlfY//vWE3msD2JkVLYGo3c= X-Envelope-To: linux@armlinux.org.uk X-Envelope-To: andi.shyti@kernel.org X-Envelope-To: netdev@vger.kernel.org X-Envelope-To: linux-i2c@vger.kernel.org X-Envelope-To: michal.simek@amd.com X-Envelope-To: hkallweit1@gmail.com X-Envelope-To: linux-arm-kernel@lists.infradead.org X-Envelope-To: linux-kernel@vger.kernel.org Message-ID: Date: Tue, 28 May 2024 12:57:25 -0400 MIME-Version: 1.0 Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Sean Anderson Subject: [BUG] SFP I2C timeout forces link down with PHY_ERROR To: Andrew Lunn , Russell King , Andi Shyti , "netdev@vger.kernel.org" , linux-i2c@vger.kernel.org Cc: Michal Simek , Heiner Kallweit , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240528_095733_817385_51188988 X-CRM114-Status: GOOD ( 13.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi, I saw the following warning [1] twice when testing 1000Base-T SFP modules: [ 1481.682501] cdns-i2c ff030000.i2c: timeout waiting on completion [ 1481.692010] Marvell 88E1111 i2c:sfp-ge3:16: Master/Slave resolution failed [ 1481.699910] ------------[ cut here ]------------ [ 1481.705459] phy_check_link_status+0x0/0xe8: returned: -67 [ 1481.711448] WARNING: CPU: 2 PID: 67 at drivers/net/phy/phy.c:1233 phy_state_machine+0xac/0x2ec [ 1481.904544] macb ff0c0000.ethernet net1: Link is Down and a second time with some other errors too: [ 64.972751] cdns-i2c ff030000.i2c: xfer_size reg rollover. xfer aborted! [ 64.979478] cdns-i2c ff030000.i2c: xfer_size reg rollover. xfer aborted! [ 65.998108] cdns-i2c ff030000.i2c: timeout waiting on completion [ 66.010558] Marvell 88E1111 i2c:sfp-ge3:16: Master/Slave resolution failed [ 66.017856] ------------[ cut here ]------------ [ 66.022786] phy_check_link_status+0x0/0xcc: returned: -67 [ 66.028255] WARNING: CPU: 0 PID: 70 at drivers/net/phy/phy.c:1233 phy_state_machine+0xa4/0x2b8 [ 66.339533] macb ff0c0000.ethernet net1: Link is Down The chain of events is: - The I2C transaction times out for some reason (in the latter case due to a known hardware bug). - mdio-i2c converts the error response to a 0xffff return value - genphy_read_lpa sees that LPA_1000MSFAIL is set in MII_STAT1000 and returns -ENOLINK. This propagates up the calls stack. - phy_check_link_status returns -ENOLINK - phy_error_precise forces the link down with state = PHY_ERROR. The problem with this is that although the register read fails due to a temporary condition, the link goes down permanently (or at least until the admin cycles the interface state). I think some part of the stack should implement a retry mechanism, but I'm not sure which part. One idea could be to have mdio-i2c propagate negative errors instead of converting them to successful reads of 0xffff. But we would still need to handle that in the phy driver or in phy_state_machine. - Are I2C bus drivers supposed to be flaky like this? That is, are callers of i2c_transfer expected to handle the occasional spurious error? - Similarly, are MDIO bus drivers allowed to be flaky? - Is ETIMEDOUT even supposed to be recoverable? Maybe we should have cdns-i2c return EAGAIN instead so it gets retried by the bus arbitration logic in __i2c_transfer. - ENOLINK really seems like something which we could recover from by resetting the phy (or even just waiting a bit). Maybe we should have the phy state machine just switch to PHY_NOLINK? Of course, the best option would be to fix cdns-i2c to not be buggy, but the hardware itself is buggy in at least one of the above cases so that may not be practical. --Sean _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel