Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5437015rdb; Wed, 13 Dec 2023 08:35:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IGOADfIz0B3JCWlMLTYsJlY812W7TM1hcpU2tt96snXgcErKK2Z5X0vpqtZ7QMPomNLIL7a X-Received: by 2002:a05:6a20:7d86:b0:18f:f86f:bcdb with SMTP id v6-20020a056a207d8600b0018ff86fbcdbmr10188282pzj.93.1702485342355; Wed, 13 Dec 2023 08:35:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702485342; cv=none; d=google.com; s=arc-20160816; b=KEl4c2vzyT3eWg0+4AcSDDs77YHxW5x28prGPjJixFksYZApUxYuNqrsiqFarKra2G UUWlwqJMscmlQunM6H+g5zQRJTp0ubUNEBnT6RcmQF0mCRozKRj88zook4BlTQ0LOfO0 GZIuRuo9rLQB0BLAJTwHfPJqlnz5RBVuGX6WlkE6g0rniBHCy9CszwjKE+pWkZk+mAFJ /GYmIFw/Sp/2FG4QG9AdSB8Ov6BICMWSb4347Z5olcufQaA0LRuG8eH12gXh4FmjGioE n8dPvpAIKL096l+qkunxJ0LoI4355YHxbH4L2TJ4fgsw4+xAalruaxWd7bqGeCOi1xJr iMwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=8Rz0Hd4GHebEk04ieni7Igt9GqSHOkY56E1iGl+TH3g=; fh=ZUIGhA6eww0lpdXy5u6KSD0KEo5uW3E3cR6Ghf4MiIE=; b=HTPcF2HFASe6uOpsOo57IuNLcSRy/8N6pryg6Bl8P9KzSeoq8eYXux4evXPGBGeYvS BL2IQaAUyktrFU+cQIazCHMGsqhMqQiGGKQMpSzeZkTIwrU6lcGrDdshcMcrFxKZUegc kkLdhw6NfaQGzlfyr204ySmDgbkgyDwhmVfIabaCxhQD29gwVbxWoSwCc4qgYLRHv0Ep JQs+Le+KYKu/gvypJiWvy7qANBnBk9wK1FBd/UZCGIuUn25v6pn6GfBbGhRMWMGPIb8V uPBwQfhtPqkXHcR+aRuZG60Hg1/CoCrj0qJmY+vxCzByf20Rdbb3t3h/F0JWPnvynIaE o0eQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=HhTNMn2z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id o9-20020a655209000000b005c67e10f23bsi9981921pgp.362.2023.12.13.08.35.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 08:35:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=HhTNMn2z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 26DA580764AA; Wed, 13 Dec 2023 08:35:26 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235219AbjLMQfC (ORCPT + 99 others); Wed, 13 Dec 2023 11:35:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233438AbjLMQe5 (ORCPT ); Wed, 13 Dec 2023 11:34:57 -0500 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E6EB134; Wed, 13 Dec 2023 08:34:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=8Rz0Hd4GHebEk04ieni7Igt9GqSHOkY56E1iGl+TH3g=; b=HhTNMn2zzCcbcLo4rK6OhTBKdI JRzY3ih3wjCvsBt99HBVNYjBY3pbJCCC31gHvb0hpbIPBXLa226D1sFzW0ZbvfqLNFfaQf6bGf+Pt 9qD5JSQGk9L5twNvMyWSlr+zyEnoYd8ZeWiVl60I7ePhCMKdCPRDw34sk8j+IEXfH4DNVqx6XmNig 6zVHVDD2MXDQFykTMnpVPsuaTdezA2VmbBtJ3u8o9NGbGjk1QMz4F5wicDeAfe/PW1EzD43aF73SV V0px6EytF81VS1Pi2kKbj9xDDw1m9fhsXJ1IDxNvwiL77CALxqb83KCguiYjl6Rb/Vi/+oQQoqYDq p/PvYgvg==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:55264) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rDSC8-0000Hm-2E; Wed, 13 Dec 2023 16:34:49 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1rDSCA-0001eb-I9; Wed, 13 Dec 2023 16:34:50 +0000 Date: Wed, 13 Dec 2023 16:34:50 +0000 From: "Russell King (Oracle)" To: Christian Marangi Cc: Florian Fainelli , Broadcom internal kernel review list , Andrew Lunn , Heiner Kallweit , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vladimir Oltean , David Epping , Harini Katakam , Simon Horman , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [net-next PATCH v6 1/3] net: phy: extend PHY package API to support multiple global address Message-ID: References: <20231213105730.1731-1-ansuelsmth@gmail.com> <6579d2cc.050a0220.e6ea.d8cf@mx.google.com> <6579dab5.050a0220.8552a.d827@mx.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6579dab5.050a0220.8552a.d827@mx.google.com> Sender: Russell King (Oracle) X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 13 Dec 2023 08:35:26 -0800 (PST) On Wed, Dec 13, 2023 at 05:24:18PM +0100, Christian Marangi wrote: > On Wed, Dec 13, 2023 at 04:12:24PM +0000, Russell King (Oracle) wrote: > > On Wed, Dec 13, 2023 at 04:50:33PM +0100, Christian Marangi wrote: > > > On Wed, Dec 13, 2023 at 03:45:24PM +0000, Russell King (Oracle) wrote: > > > > On Wed, Dec 13, 2023 at 11:57:28AM +0100, Christian Marangi wrote: > > > > > -static inline int phy_package_read(struct phy_device *phydev, u32 regnum) > > > > > +static inline int phy_package_read(struct phy_device *phydev, > > > > > + unsigned int addr_offset, u32 regnum) > > > > > { > > > > > struct phy_package_shared *shared = phydev->shared; > > > > > + int addr = shared->base_addr + addr_offset; > > > > > > > > > > - if (!shared) > > > > > + if (addr >= PHY_MAX_ADDR) > > > > > return -EIO; > > > > > > > > If we're going to check the address, I think we should check it > > > > properly, which means also checking whether it's become negative. > > > > > > > > Alternatively, we could consider making "addr" and "base_addr" > > > > unsigned types, since they should never be negative. However, > > > > that probably should be done as a separate patch before this one. > > > > > > > > > > Maybe I'm confused but isn't already like that? > > > On phy_package_join base_addr is already checked if it's negative (and > > > rejected) > > > > > > addr_offset is unsigned so it can't be negative. > > > > True, but with base_addr being an int, addr_offset being unsigned int, > > and addr being an int, if addr_offset is a very large number, > > 2-complement arithmetic will have the effect of treating it as a > > negative number. > > > > So, base_addr=0, addr_offset=~0 results in addr being -1. > > > > If "addr" were unsigned int, and as we've already established, > > "base_addr" can't be less than zero because of the checks already done > > (thus it can also be unsigned int) then we'll end up with the checks > > you're adding automatically doing the right thing, because... > > > > base_addr=0, addr_offset=~0 results in addr being ~0 (a large > > positive unsigned number). > > > > Oh ok... now it makes sense. So I guess I should change "addr" to > unsigned. > > Considering I'm changing addr in phy_package_shared to base_addr would > it be ok to change that also to unsigned (doesn't make sense to have > that int) in this patch? Or should I create first a small patch before > this to change addr type? What I said when I mooted the use of unsigned was: "Alternatively, we could consider making "addr" and "base_addr" unsigned types, since they should never be negative. However, that probably should be done as a separate patch before this one." so my thoughts are that it should be a separate small patch - it's a single logical change. Thanks. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!