Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp108832lqb; Tue, 28 May 2024 10:05:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXX8TDMN7FDZ7saxC3UTfYyJIGujLd6z3OGjdxLq3Z+k14ZICu4I7ncGBXEikdl3zxI8GG9Fuq0Z5pCP1MhA58A59mwyYmeLAzMbHMQQA== X-Google-Smtp-Source: AGHT+IHo1sGuGLLpBMRhDBnaLDf2ELNYnsufEmzOEnt2jUWnIDOrs338tHsaBGTdqJtizAGbaxO2 X-Received: by 2002:a05:6a00:3388:b0:6f3:ecdc:220e with SMTP id d2e1a72fcca58-6f8f3f9fed5mr15416385b3a.24.1716915926902; Tue, 28 May 2024 10:05:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716915926; cv=pass; d=google.com; s=arc-20160816; b=MKjttQGIk0lMs+68MHR9w0HVuSL1Tbo+mtD6ogdhGOEYfn1kFkAYQatz/of9kRxa/f LblX5iYoDMFBz/PNoI5Mpa1PFeXmSImNxmXN1ETd/hWGMdCI0omOoWFvDdgoI+cf4I6l CEKrLSaBC1km0o/EjlugYU9Xu10Am+jJtxw0p0OO8Cd1uzSTvz+Qg2v2DqzjEVjyFz69 gKYisWgu4f6UbmW65F7UK6TSaZtppT3BO5lb67pwxDjamdCLcwliflIGIpHocCSpjiEC UNSYipijdZCzOAverPPMmqH5GgNFVuM/y66n9B7btMGbycfdmu5BvVigy7Lq5Q1Os7h9 qDfA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:from:content-language :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :date:message-id:dkim-signature; bh=jNceAp37GB1si/9T0wIzhGZuQRX1PlheHnoihJOZ330=; fh=Ayms+/meQUyy5Zaiedxc5xNPxFWh6e8fQlWQSF2NdLs=; b=Eon0d3JdL943+9vQthMzOuWRMI8k8gygmvMLC3/DSYh9E78Q01WAyRRHz1RpGCVOUP bWcwe/CGQ+80AH/ZTb7gPHtznuZB3584BUKaZk55WeDE4FYN0UG8n/lU2FgIDGgHBHDk VJy6wkEJTHnSXSPj+trwI5FqnS4aQiVMSL0yJQ24J1YJeTq0XSN5sw+Z4R6xHB3U2WHk 5lRpbVJ4M0FpotYlKw1Uz9gATLuuYyWoXN6/PN5zFsNhun1KqSe+BwcruRisnarulgrM teVclfwSqBBpu6adqe+Z+ggo68a7fQB2kAn8lLOtvPTc7f5YuuL6Z11ESFpQehBBITZO RwRg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=FMaIWg8Z; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-192787-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192787-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6822ae582e2si8439801a12.827.2024.05.28.10.05.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 10:05:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-192787-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=FMaIWg8Z; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-192787-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192787-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 3557AB2240F for ; Tue, 28 May 2024 16:57:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DB84B173347; Tue, 28 May 2024 16:57:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="FMaIWg8Z" Received: from out-170.mta0.migadu.com (out-170.mta0.migadu.com [91.218.175.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B370172BAE for ; Tue, 28 May 2024 16:57:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716915454; cv=none; b=Ajr+ckIr+ylFy2eXLT4awhPh7LwKLrqDHnm9IDZKzDNEq4zUjaSv/5oWbO9Tg4cmPXLXb6ER5W4QUQAw9PJQCAiBHwbGRBZ5gnUHuEpmMJ4x2hQbChEMnt5rsT6BlqVK7+T+iPlPPveUJaecu8T+itdyPbsYZ3WF172L8eCmyhw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716915454; c=relaxed/simple; bh=20lWxuyncauYpRPdcIP2qeiyq8Pn90Gk/tUHOS/51sw=; h=Message-ID:Date:MIME-Version:From:Subject:To:Cc:Content-Type; b=A5296ofB4zzW8OUGFuT9DOhYGiQ+nEUNmTjYBA1uU1c86K3o+68yY2dGmQtT1zz2OiaWdm+NgoQlKF+lIZDNQTFwM2PABuVTJ/AEmuHON2qZnLeb3d82yyYZYWH2N9uRhZbHwVvVQxdPnBkDeqxgPoYQgQ/xiEit9zIU05ZfBnw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=FMaIWg8Z; arc=none smtp.client-ip=91.218.175.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT 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