From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14B95C00140 for ; Thu, 11 Aug 2022 00:30:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231804AbiHKAao (ORCPT ); Wed, 10 Aug 2022 20:30:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229488AbiHKAam (ORCPT ); Wed, 10 Aug 2022 20:30:42 -0400 Received: from vps0.lunn.ch (vps0.lunn.ch [185.16.172.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5382466A70; Wed, 10 Aug 2022 17:30: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=cVnlVnJwObO86ULdSvAwM695LLQEVtnRb++QK0jLVRA=; b=vt0L8vjYEJ9MWh3HBefr68tO81 BEfNLfx963mhY0aqpHZnD9Bhl/KkdiiTMmf5tWA06mHQln6FyGgcg1ROqXVZO2J1VtesjykJIDU9j UNfZd4ya/x74mPo8i1zAHZUypQoVnwGqtQ+9HDm+jlD08etlCYI4CkQgWRE8txurb+ec=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1oLw5k-00CyZr-5a; Thu, 11 Aug 2022 02:30:28 +0200 Date: Thu, 11 Aug 2022 02:30:28 +0200 From: Andrew Lunn To: Ravi Gunasekaran Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux-omap@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kishon@ti.com, vigneshr@ti.com Subject: Re: [PATCH v2 net-next] net: ethernet: ti: davinci_mdio: Add workaround for errata i2329 Message-ID: References: <20220810111345.31200-1-r-gunasekaran@ti.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220810111345.31200-1-r-gunasekaran@ti.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > +static int davinci_mdiobb_read(struct mii_bus *bus, int phy, int reg) > +{ > + int ret; > + struct mdiobb_ctrl *ctrl = bus->priv; > + struct davinci_mdio_data *data; > + > + data = container_of(ctrl, struct davinci_mdio_data, bb_ctrl); > + > + if (phy & ~PHY_REG_MASK || reg & ~PHY_ID_MASK) > + return -EINVAL; You don't need this. Leave it up to the bit banging code to do the validation. This also breaks C45, which the bit banging code can do, and it looks like the hardware cannot. > + > + ret = pm_runtime_resume_and_get(data->dev); > + if (ret < 0) > + return ret; > + > + ret = mdiobb_read(bus, phy, reg); > + > + pm_runtime_mark_last_busy(data->dev); > + pm_runtime_put_autosuspend(data->dev); Once you take the validation out, this function then all becomes about runtime power management. Should the bit banging core actually be doing this? It seems like it is something which could be useful for other devices. struct mii_bus has a parent member. If set, you could apply these run time PM functions to that. Please add a patch to modify the core bit banging code, and then you should be able to remove these helpers. > static int davinci_mdio_probe(struct platform_device *pdev) > { > struct mdio_platform_data *pdata = dev_get_platdata(&pdev->dev); > @@ -340,12 +535,30 @@ static int davinci_mdio_probe(struct platform_device *pdev) > struct phy_device *phy; > int ret, addr; > int autosuspend_delay_ms = -1; > + const struct soc_device_attribute *soc_match_data; netdev uses reverse christmas tree. Variables should be sorted longest first, shortest last. Andrew From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 853B0C00140 for ; Thu, 11 Aug 2022 00:32:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4zEjinbyKzBxi2KynDh9nAswgtBVQ6V8T9a68Omci1w=; b=xtvcg5EIslFgK3 dqTenywKhM0j+UxEd1mEZPPvL1Y+GpabLikkd+YvbfxovYjwJYTUypYpmpEh1L1FeCcCyWzkRrSwV hW8MThs1sTOgkJqAbCJlylwut0n0ZsJA8gXbXZ0fkFGW7XTCuqngcRNr/eYWqbpLTu45JwnZVskNI uzhx57pOav9KGJw5wWgYE0J5zSVKUQHvWG7kaWfSbl+gZyrOQZXId5v4GUeHUw/Z47B32lXGpqjqw 5/tNE9QY6C8AsWnpQwrDlzhHUVNdGBxE+ohHSpo1IAhiwKo5e/hlTKlKztRKtxMgaMii0sVs52rob Pqo4Rx4tIqCFKOCMrE2w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oLw69-000Leb-RE; Thu, 11 Aug 2022 00:30:53 +0000 Received: from vps0.lunn.ch ([185.16.172.187]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oLw65-000LVG-QH for linux-arm-kernel@lists.infradead.org; Thu, 11 Aug 2022 00:30:51 +0000 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=cVnlVnJwObO86ULdSvAwM695LLQEVtnRb++QK0jLVRA=; b=vt0L8vjYEJ9MWh3HBefr68tO81 BEfNLfx963mhY0aqpHZnD9Bhl/KkdiiTMmf5tWA06mHQln6FyGgcg1ROqXVZO2J1VtesjykJIDU9j UNfZd4ya/x74mPo8i1zAHZUypQoVnwGqtQ+9HDm+jlD08etlCYI4CkQgWRE8txurb+ec=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1oLw5k-00CyZr-5a; Thu, 11 Aug 2022 02:30:28 +0200 Date: Thu, 11 Aug 2022 02:30:28 +0200 From: Andrew Lunn To: Ravi Gunasekaran Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux-omap@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kishon@ti.com, vigneshr@ti.com Subject: Re: [PATCH v2 net-next] net: ethernet: ti: davinci_mdio: Add workaround for errata i2329 Message-ID: References: <20220810111345.31200-1-r-gunasekaran@ti.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220810111345.31200-1-r-gunasekaran@ti.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220810_173049_876859_0374730C X-CRM114-Status: GOOD ( 16.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org > +static int davinci_mdiobb_read(struct mii_bus *bus, int phy, int reg) > +{ > + int ret; > + struct mdiobb_ctrl *ctrl = bus->priv; > + struct davinci_mdio_data *data; > + > + data = container_of(ctrl, struct davinci_mdio_data, bb_ctrl); > + > + if (phy & ~PHY_REG_MASK || reg & ~PHY_ID_MASK) > + return -EINVAL; You don't need this. Leave it up to the bit banging code to do the validation. This also breaks C45, which the bit banging code can do, and it looks like the hardware cannot. > + > + ret = pm_runtime_resume_and_get(data->dev); > + if (ret < 0) > + return ret; > + > + ret = mdiobb_read(bus, phy, reg); > + > + pm_runtime_mark_last_busy(data->dev); > + pm_runtime_put_autosuspend(data->dev); Once you take the validation out, this function then all becomes about runtime power management. Should the bit banging core actually be doing this? It seems like it is something which could be useful for other devices. struct mii_bus has a parent member. If set, you could apply these run time PM functions to that. Please add a patch to modify the core bit banging code, and then you should be able to remove these helpers. > static int davinci_mdio_probe(struct platform_device *pdev) > { > struct mdio_platform_data *pdata = dev_get_platdata(&pdev->dev); > @@ -340,12 +535,30 @@ static int davinci_mdio_probe(struct platform_device *pdev) > struct phy_device *phy; > int ret, addr; > int autosuspend_delay_ms = -1; > + const struct soc_device_attribute *soc_match_data; netdev uses reverse christmas tree. Variables should be sorted longest first, shortest last. Andrew _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel