Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1156174rwl; Wed, 5 Apr 2023 12:38:14 -0700 (PDT) X-Google-Smtp-Source: AKy350YdHSBTlQN/3BLvEEnriHEHItYepdU6y7pVbMzWZSYrPPWNE5dk0fCY1r/cGO5a80p3GWcP X-Received: by 2002:a17:902:e84f:b0:1a1:953b:9559 with SMTP id t15-20020a170902e84f00b001a1953b9559mr9458406plg.3.1680723494059; Wed, 05 Apr 2023 12:38:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680723494; cv=none; d=google.com; s=arc-20160816; b=EtLMr/zWfI9XCvlyKUHAhIwOE+KDTo1SLjp361mOGf3e3GOvdZwycr7cHnA3u8JfHu wY2WXAY53jG1/a32PoEWpMvx7qBT5hkwKAxMCygpzliTZXb4paFnuHLAQtTRXCdIRU/x zEQTbWdy4OfljGdzsN1zAfdacNoao2vQdRWiOBOcvJ+7mbVsSDp1csDOPcPFdGb91jf6 x2FMQrFSFzz3NJs0MXKMKMARJkLzhQwOPLq6H+NcmLPC9jlOGSPkYQIsSF1/ROzstF3O GdVTwgBoj7Ur2Dozfxdam+FSSmaC0iTVzBgzOsjmenhOIBQC1ubpnS4BsLogKdi18nSj z01w== 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=GJLiNwhsL8BaZ9KZ/zH+hWXBLPuylC9ipjO8vXLfsjw=; b=Z4XRODPxgMTj2NrlQzizDgb8fo8zgSZYJYkxRQ55Yl7UKwMhhHRdxihLU40+bEtoOH OTE3sj6ROsBYhGcUFwjzrWWT0qLZRy94HZPOuzOldbZeG8k2/KUJdEPj6gIMswiJ1l8F nxDC2lAlVl1FxuIPrkKdR/2gGRwfy2C+lIegmntK1f6sLCvMXrThvfn6bEYHB5/aM2uV EJ6ewNTWm3dnnYrs1prRsJxKwUEp7uSMkB4RMWh6D4f69GKuvOmeNEz47c/MGpewjm2A ZAMxuRxwSZWjIfN8NZG5L4E4Qy9RfRhIi/Y75aFvM6xnOu53iZe9/tM6hOgp0m/w16l4 DplQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=xaJkJYJM; 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 202-20020a6301d3000000b004e018302ac3si12794197pgb.612.2023.04.05.12.38.02; Wed, 05 Apr 2023 12:38:14 -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=xaJkJYJM; 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 S229446AbjDETfn (ORCPT + 99 others); Wed, 5 Apr 2023 15:35:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230396AbjDETfm (ORCPT ); Wed, 5 Apr 2023 15:35:42 -0400 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A930D5FE1; Wed, 5 Apr 2023 12:35:41 -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=GJLiNwhsL8BaZ9KZ/zH+hWXBLPuylC9ipjO8vXLfsjw=; b=xaJkJYJMmcRDgsC5EpE9PRIgAQ HYv4+O2SHOJNB4PRH5kk8ZEsg5rvoIEsUC2FDG1gtqjCW2CRKPBLLrpsD6a+ZJV/znHN7muxtUtsT yBtbpPOYuABPPh1etdclBxinSgqEt/2mGDjmNaZas/9XQKGVlIKbAY40aBlw5RIJNzVw=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1pk8up-009YP9-2g; Wed, 05 Apr 2023 21:35:31 +0200 Date: Wed, 5 Apr 2023 21:35:31 +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] net: sfp: initialize sfp->i2c_block_size at sfp allocation Message-ID: <19d7ef3c-de9d-4a44-92e9-16ac14b663d9@lunn.ch> References: <20230405153900.747-1-i.bornyakov@metrotek.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230405153900.747-1-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 Wed, Apr 05, 2023 at 06:39:00PM +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 not inserted > since boot, ethtool -m leads to 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 Do i understand you correct in that this is when the SFP cage has always been empty? The I2C transaction is going to fail whatever the length is. > If SFP module was plugged then removed at least once, > sfp->i2c_block_size will be initialized and ethtool -m will fail with > different error > > # ethtool -m xge0 > Cannot get Module EEPROM data: Remote I/O error So again, the SFP cage is empty? I wonder if a better fix is to use sfp->state & SFP_F_PRESENT in sfp_module_eeprom() and sfp_module_eeprom_by_page() and don't even do the I2C read if there is no module in the cage? Andrew