Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2202408rwl; Thu, 6 Apr 2023 07:11:51 -0700 (PDT) X-Google-Smtp-Source: AKy350axR55qen+0bbCPI+MhGg5PyjgKcvjxZ1WOGJuUNyc3oJQK0s0duabjx/1psPdu4yIyEeeq X-Received: by 2002:a17:906:cb8c:b0:92f:efdc:610e with SMTP id mf12-20020a170906cb8c00b0092fefdc610emr7003800ejb.66.1680790311648; Thu, 06 Apr 2023 07:11:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680790311; cv=none; d=google.com; s=arc-20160816; b=B77l1jhfih7pLtxxO/0/JXUWgC0ACL+89e8v5/xLIbgLcClvsyIoVrI8+eTpIAuSec 0sKOX3dv2Yj4PcyqJmx/j0R+7FAFS24Q7qH0nYniRMKxotqJ4R1OqEsPv/D9ko2YSEGL 3WCy7Mq3Xml1URV18T6UAM5yrrj/9yP44VJSHa+L+2+evVRmo/a02aq4cWb1e/EQ7Ei8 TWADSZv1ExhdmjJqu6LIbLumlznttN75eSkCNn8yTFJmU46ed25IAcYZos9K7sWmTFFC Co4EnJrEz8xMrkUNSNEVIh1APMWO350wxtkNhfxFMkgiCcYPjnp0UCU5kuYkQS8rS/// 85Gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=8oDZ3kRs6FRgfVq+RBtRMhtbWqUsbcDXqJPAfMNttQ4=; b=ewhrf39I1Nk79YALLY4SVkzqmuggomn4gYjaQ/+ou31UyzZH1cUWNLRpU/rEJxDWe1 Cl4edlobwQi4MiwSF6p4D/4Zhgeg31gFhlXTFgAJkZPTYc3NZW4hZIEcsEiX4TZSrA0f o3Cio3RHZeil+j7x9EKc4IVzNUb5oNP9hv9Xhhkmn9zqypPNhnSM11hpL+znmBevDqLl 8iwP+kszG3wbeMLlf4G2f3qdUiyGrvs6hedROmPloCOcSFFiX8hB51tK87k1LUyWhCsL NPJrJxRJLnPtiQEc5caZPJWAdyjVVVhfVSpw4oazoWQJDyo4/qbflhqBwvammG4fBU50 IW+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=WGrifdM0; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id tc17-20020a1709078d1100b009311b97abe3si1222533ejc.112.2023.04.06.07.11.25; Thu, 06 Apr 2023 07:11:51 -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; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=WGrifdM0; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238989AbjDFOGa (ORCPT + 99 others); Thu, 6 Apr 2023 10:06:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236342AbjDFOGX (ORCPT ); Thu, 6 Apr 2023 10:06:23 -0400 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0AB039EC6; Thu, 6 Apr 2023 07:05:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=8oDZ3kRs6FRgfVq+RBtRMhtbWqUsbcDXqJPAfMNttQ4=; b=WGrifdM0YVtMczLeufRhUKtMzt +ve7ArrD/aGxPprJyRkQ8xa5CeYqhtKGRxT8IWAB05VpX8QNzrw1+IM1iRCwwBbJ6A8u2Y33MCStS KtZH0Hu6mhqZudtEJAG8i3gxaOcCvix9pPQeJnwCyHsIVzGYWojQYtbRRM7bjN6Cv84M=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1pkQF8-009dMn-Er; Thu, 06 Apr 2023 16:05:38 +0200 Date: Thu, 6 Apr 2023 16:05:38 +0200 From: Andrew Lunn To: Ivan Bornyakov Cc: netdev@vger.kernel.org, linux@armlinux.org.uk, hkallweit1@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux-kernel@vger.kernel.org, system@metrotek.ru, stable@vger.kernel.org Subject: Re: [PATCH net v2 1/2] net: sfp: initialize sfp->i2c_block_size at sfp allocation Message-ID: <8e34fb09-87e0-4bab-bfd8-dd35b76eac53@lunn.ch> References: <20230406130833.32160-1-i.bornyakov@metrotek.ru> <20230406130833.32160-2-i.bornyakov@metrotek.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230406130833.32160-2-i.bornyakov@metrotek.ru> X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=unavailable 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 On Thu, Apr 06, 2023 at 04:08:32PM +0300, Ivan Bornyakov wrote: > sfp->i2c_block_size is initialized at SFP module insertion in > sfp_sm_mod_probe(). Because of that, if SFP module was never inserted > since boot, sfp_read() call will lead to zero-length I2C read attempt, > and not all I2C controllers are happy with zero-length reads. > > One way to issue sfp_read() on empty SFP cage is to execute ethtool -m. > If SFP module was never plugged since boot, there will be a zero-length > I2C read attempt. > > # ethtool -m xge0 > i2c i2c-3: adapter quirk: no zero length (addr 0x0050, size 0, read) > Cannot get Module EEPROM data: Operation not supported > > If SFP module was plugged then removed at least once, > sfp->i2c_block_size will be initialized and ethtool -m will fail with > different exit code and without I2C error > > # ethtool -m xge0 > Cannot get Module EEPROM data: Remote I/O error > > Fix this by initializing sfp->i2_block_size at struct sfp allocation > stage so no wild sfp_read() could issue zero-length I2C read. > > Signed-off-by: Ivan Bornyakov > Fixes: 0d035bed2a4a ("net: sfp: VSOL V2801F / CarlitoxxPro CPGOS03-0490 v2.0 workaround") > Cc: stable@vger.kernel.org Reviewed-by: Andrew Lunn Andrew