Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp4344rwb; Wed, 10 Aug 2022 18:01:35 -0700 (PDT) X-Google-Smtp-Source: AA6agR7VXtn5GI7HUy2DO8eVksIWG+IA2Nn2PjA4gWZ6rsLJLiaqCYwBSExXfyXtq5zrfjn6Pafl X-Received: by 2002:a17:907:6eac:b0:730:a07f:38bb with SMTP id sh44-20020a1709076eac00b00730a07f38bbmr23065830ejc.750.1660179695720; Wed, 10 Aug 2022 18:01:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660179695; cv=none; d=google.com; s=arc-20160816; b=W9J/e5wy7E4NCJlpEKpxRYIxAKqmEt4JfKK9DXbkGa/VAqQC6FynAEWn+exqldsKxQ jX0YXXefYcFmY/lyrZpCaJx0NfluR0UtJXzwdVPDFhGeFI75FVrVa3UQJkTbq5+cUxsX CYYdV5FEcLAIISOPTQUk884TEyw6fAPq5iT0DNpgg8X/IImAMVtM4CYF5I0KwN4xIWI1 VYR+jGkizy7fYmePogdzH8QeyZj6FE54xJMcms3XjZsj8IOF8brVGs0kOOCErgJVwJQ5 gyz2Rjrad+l8bUbYAKweuF66n1NKuZmlVRJf7Wi6Awp1BtEEb+zZtc35iW1Mb876z53H LVZA== 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=cVnlVnJwObO86ULdSvAwM695LLQEVtnRb++QK0jLVRA=; b=1BVrReBhUw6pA+0NeOLeNxR23AGdt4Ng5Da8WjWLFhDxshiRvtJ+0D9bFbyoLgsxI8 4T33BTDumqmvtymzYCnfq4kSrVt9Cb04op+k24fpJtzjTp7uBcXkTR0GLvkV8mrKecl+ /+ZejH2gthvSihWg7usZS4IUj7mWgt4ZF89K1tu00FqSd9wdM5FBJ3Cv8piRu5s+pqp2 9yXvG4dw5vTLhBsR9HdgW/rt4kpb3Lr3YMyhJmlwyg1TrPCqSj3hKBYk0nNICZ4x0Xx5 zZt9LnxwFEZhRCuuxEYYt1H1JghRcemPw3kj9YejmCmmW/iIxdxOtgevEPh42vo8OiIf Hoqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=vt0L8vjY; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qb6-20020a1709077e8600b00730726b348fsi6172568ejc.196.2022.08.10.18.01.09; Wed, 10 Aug 2022 18:01:35 -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=vt0L8vjY; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231424AbiHKAao (ORCPT + 99 others); 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> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 > +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