Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3972107pxb; Tue, 25 Jan 2022 00:19:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJwXnhCXyL3fY0JLqRh4XhK7E7WVGH5jrtUZjCM/Q7NOdPmjcw3pM/6jjIu7hKefy1RvrI/Q X-Received: by 2002:aa7:cb08:: with SMTP id s8mr19507544edt.57.1643098678700; Tue, 25 Jan 2022 00:17:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643098678; cv=none; d=google.com; s=arc-20160816; b=WCkmsn9aDG4ftpy/GuIVmv7HI9yo/4k9Ar6Pq0N1nx0v/7cEl827WziCO9i+q0vFWA lyPVDHM65cqr6MJJngyKOJNx9wrFdWZirmW2etV7ABApLvjLLXkwVz5UFeQSo5O3Y8iA ZLJh2/0Id/5sw30cZtp1Bu5vXzVNNNu+TQJXHArOzId5oGPmgePh6ZBLxG59HpEa5UGV jXjACMT30guQ3QwNYjG3z5yR80gAPBGYlfeK1xUoneDNJTVT2evj7g41G554jC6yQPOP G2+/XKLgdr2OVJVg3F5j0AsuvFqsphMIXSRl6l8ub+CvyYYCQ97Fm6q6vjlnOC5eDj/b QBIg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=AQmIt790G/Ub7Tk7U0eSpwkffD/jURZQRurhxbNfhlg=; b=pkAgMG6DnFaooeKsypb+iOssBM9v+2kNsa+3z/tdd5h0pTQHmiC8u4LkTrfFRLqPlx 4dkZyvCEKzvLIqzy15qI1znrbMZJieCpRJBJ/fLwdvzldHKsDIpY539Btv7j1qae2JxY EKBv44Hlq+Psv4nmvDTR2P4b9ZAiYbPIE5btDWdCo+46DVAqR47akQ3hBRymRxNTJfFW zM56LDbjAB3x75TErvojEhJ+MCgpWb53RzSpNHZqOTqb8kQwq257LLXz2XxMg5crTwZ8 HXHfS566GzC6s74cun6A1wFks7E8+gDnk6vKRBS2OYhNfTIGYzWxciWqTIhp8igCMMOY z6XQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TCWDIm27; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dp8si4535670ejc.716.2022.01.25.00.17.27; Tue, 25 Jan 2022 00:17:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TCWDIm27; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S3412646AbiAYAhY (ORCPT + 99 others); Mon, 24 Jan 2022 19:37:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2366247AbiAXXwd (ORCPT ); Mon, 24 Jan 2022 18:52:33 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67A39C047CFE; Mon, 24 Jan 2022 13:45:39 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 24814B8119E; Mon, 24 Jan 2022 21:45:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46C03C340E4; Mon, 24 Jan 2022 21:45:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643060736; bh=b9l0gqvoTDt6A/0QvDZYMLVha/WUwb9rjfjzdWEXvYg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TCWDIm27rgeqmYEuIs4j5I57MelnxAAxMujpSo9DvFgoU6jMi85H5xGHkEu+FPiMR 4JHhGC6R99mu7TXD9v0+8uaz464nuGsLOT2Agv6H1Qsh5u3WrraLSr7RCBe1C2YBcj oLwzaBdE36NXoaOSm2sRCWuIEIFgCjRyZ06DbVn8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?=E7=85=A7=E5=B1=B1=E5=91=A8=E4=B8=80=E9=83=8E?= , "Russell King (Oracle)" , "David S. Miller" Subject: [PATCH 5.16 1018/1039] net: sfp: fix high power modules without diagnostic monitoring Date: Mon, 24 Jan 2022 19:46:47 +0100 Message-Id: <20220124184159.511708556@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Russell King (Oracle) commit 5765cee119bf5a36c94d20eceb37c445508934be upstream. Commit 7cfa9c92d0a3 ("net: sfp: avoid power switch on address-change modules") unintetionally changed the semantics for high power modules without the digital diagnostics monitoring. We repeatedly attempt to read the power status from the non-existing 0xa2 address in a futile hope this failure is temporary: [ 8.856051] sfp sfp-eth3: module NTT 0000000000000000 rev 0000 sn 0000000000000000 dc 160408 [ 8.865843] mvpp2 f4000000.ethernet eth3: switched to inband/1000base-x link mode [ 8.873469] sfp sfp-eth3: Failed to read EEPROM: -5 [ 8.983251] sfp sfp-eth3: Failed to read EEPROM: -5 [ 9.103250] sfp sfp-eth3: Failed to read EEPROM: -5 We previosuly assumed such modules were powered up in the correct mode, continuing without further configuration as long as the required power class was supported by the host. Restore this behaviour, while preserving the intent of subsequent patches to avoid the "Address Change Sequence not supported" warning if we are not going to be accessing the DDM address. Fixes: 7cfa9c92d0a3 ("net: sfp: avoid power switch on address-change modules") Reported-by: 照山周一郎 Tested-by: 照山周一郎 Signed-off-by: Russell King (Oracle) Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/phy/sfp.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) --- a/drivers/net/phy/sfp.c +++ b/drivers/net/phy/sfp.c @@ -1641,17 +1641,20 @@ static int sfp_sm_probe_for_phy(struct s static int sfp_module_parse_power(struct sfp *sfp) { u32 power_mW = 1000; + bool supports_a2; if (sfp->id.ext.options & cpu_to_be16(SFP_OPTIONS_POWER_DECL)) power_mW = 1500; if (sfp->id.ext.options & cpu_to_be16(SFP_OPTIONS_HIGH_POWER_LEVEL)) power_mW = 2000; + supports_a2 = sfp->id.ext.sff8472_compliance != + SFP_SFF8472_COMPLIANCE_NONE || + sfp->id.ext.diagmon & SFP_DIAGMON_DDM; + if (power_mW > sfp->max_power_mW) { /* Module power specification exceeds the allowed maximum. */ - if (sfp->id.ext.sff8472_compliance == - SFP_SFF8472_COMPLIANCE_NONE && - !(sfp->id.ext.diagmon & SFP_DIAGMON_DDM)) { + if (!supports_a2) { /* The module appears not to implement bus address * 0xa2, so assume that the module powers up in the * indicated mode. @@ -1668,11 +1671,25 @@ static int sfp_module_parse_power(struct } } + if (power_mW <= 1000) { + /* Modules below 1W do not require a power change sequence */ + sfp->module_power_mW = power_mW; + return 0; + } + + if (!supports_a2) { + /* The module power level is below the host maximum and the + * module appears not to implement bus address 0xa2, so assume + * that the module powers up in the indicated mode. + */ + return 0; + } + /* If the module requires a higher power mode, but also requires * an address change sequence, warn the user that the module may * not be functional. */ - if (sfp->id.ext.diagmon & SFP_DIAGMON_ADDRMODE && power_mW > 1000) { + if (sfp->id.ext.diagmon & SFP_DIAGMON_ADDRMODE) { dev_warn(sfp->dev, "Address Change Sequence not supported but module requires %u.%uW, module may not be functional\n", power_mW / 1000, (power_mW / 100) % 10);