Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1247902rwl; Wed, 5 Apr 2023 14:07:56 -0700 (PDT) X-Google-Smtp-Source: AKy350YJikxAx9kbucye50M0pa+2zypZ/pqwmnafc3x9aOq7jIBSVTtJ4UPhPZkKtwzfVHhMM8du X-Received: by 2002:a17:903:88d:b0:19a:98c9:8cea with SMTP id kt13-20020a170903088d00b0019a98c98ceamr6816808plb.39.1680728876467; Wed, 05 Apr 2023 14:07:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680728876; cv=none; d=google.com; s=arc-20160816; b=E76/I86nZckR593Z+DCVdKRCyYrAqkRXIjOGwEvutJj5wB2zN2Zj7cEbSEMuZZhh/x gyxPjsVQT+hxmFYNN0scsbPJpdEHWZOjC6QjdjY019XhCftb2jjPyPcNEx4+fYve5RRR Qu+9XZh35Eard+em+oG87iNOxF258A3R2GFFpzAobGQGmOTK8bbqSoFz5+x7/jlHQkam qKPlkRtdsZDkGi6QhKLokLtTXxlCIEVFWBZuaO84wjgArAiEc9TQIRSuJqKqJAMEz09R U1P2rQo4fUFJ3jVrGeVl1KEFvOfU/JVP9PjEZpcC+teZukax1vcLXBeJ2GMyVyjH+cI8 S/YA== 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=T0ZqhZPbtMhYu+1Kx5ah/vE20PZzo7j6dPZIhhV5F5Y=; b=xjY1Uj3JXApxD49/U95+/addg0rqMsiQnLMvWZkmitGAKP6EvubRiPSjz9Pn5SPWxQ 5Y66oDROrcMaRosq1YQzAQEeE70kD1m709YKDtCJRDb7aNn5Wi0h7Kn16H+LkjgdL3H2 Lr6AgqIOrD/LL4hsApg43vW7mELd+BwzgwBc6ITYeyuyZMJx1aQchTsfRvbMfBbLXqeR XXDMVD2Qo2/ivqT1zkP1rI4GwaODMy/fHafeXHr47k/NXXM29iRojfnF2cZoOHaCHMp/ 3uRaEN4sjrD5eixM1v5gZQ410o87zq8sYIZbchO1IJxow4bMxjkl6cFxpFREYL5rBgwY NNBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=GVtSmAU6; 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 u17-20020a17090341d100b0019f24b0388csi13517313ple.486.2023.04.05.14.07.43; Wed, 05 Apr 2023 14:07:56 -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=GVtSmAU6; 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 S233811AbjDEUvw (ORCPT + 99 others); Wed, 5 Apr 2023 16:51:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233303AbjDEUvu (ORCPT ); Wed, 5 Apr 2023 16:51:50 -0400 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C81DF10E7; Wed, 5 Apr 2023 13:51:48 -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=T0ZqhZPbtMhYu+1Kx5ah/vE20PZzo7j6dPZIhhV5F5Y=; b=GVtSmAU6q5VpbkZSqCNz3QAYj+ SicXbl7rMYwbG1R8W8chI10Tn1xGF54DybDWExFzVdVDbhC0euQ2vGo/ZcrFCQOI1muP4uE4BVUDD yjRy01GyQGNcx9nGIqJlq9P2+9D6IbhGNlCvq00xU98tE0pyNQu3zMGNqgNcu4fmiUFU=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1pkA6U-009Yut-1M; Wed, 05 Apr 2023 22:51:38 +0200 Date: Wed, 5 Apr 2023 22:51: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] net: sfp: initialize sfp->i2c_block_size at sfp allocation Message-ID: <4c78acf7-3c72-40c5-b6cf-ff6033b80e85@lunn.ch> References: <20230405153900.747-1-i.bornyakov@metrotek.ru> <19d7ef3c-de9d-4a44-92e9-16ac14b663d9@lunn.ch> <20230405204116.mo5j6klyjnuvenag@x260> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230405204116.mo5j6klyjnuvenag@x260> 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 11:41:16PM +0300, Ivan Bornyakov wrote: > On Wed, Apr 05, 2023 at 09:35:31PM +0200, Andrew Lunn wrote: > > 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. > > > > Yes, SFP cage is empty, I2C transaction will fail anyways, but not all > I2C controllers are happy about zero-length reads. > > > > 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? > > > > This is also worthy addition to sfp.c, but IMHO sfp->i2c_block_size > initialization still need to be fixed since > > $ grep -c "sfp_read(" drivers/net/phy/sfp.c > 31 > > and I can't vouch all of them are possible only after SFP module > insertion. Also for future proof reason. I think everything else should be safe. A lot of those reads are for the HWMON code. And the HWMON code only registers when the module is inserted. How about two patches, what you have here, plus checking sfp->state & SFP_F_PRESENT in the ethtool functions? Andrew