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 BD871C76188 for ; Wed, 5 Apr 2023 20:35:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232578AbjDEUfI (ORCPT ); Wed, 5 Apr 2023 16:35:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233076AbjDEUeu (ORCPT ); Wed, 5 Apr 2023 16:34:50 -0400 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 067455249; Wed, 5 Apr 2023 13:34: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=ir96PDQ5DPUpeJhDM1v4BrKeIYiu1Z8SXvc8ylqyxe8=; b=APgRQZvMhXqYui/jKYMbnzPcry LwxJoMiLuXafar1R6r/+lEB3JLt42me4gaqh6MGXxrXsQ6JG3htDZ3ri3it2ZFxJD0F8SqAGkxhGt bfKq52f5ibdbLODUbWeZf3ogeFu8emiFcDv2gGhCOEdfH2DoKuMoP6K0+I0YvK45vtrU=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1pk9po-009Yke-Nq; Wed, 05 Apr 2023 22:34:24 +0200 Date: Wed, 5 Apr 2023 22:34:24 +0200 From: Andrew Lunn To: Marco Felsch Cc: Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Florian Fainelli , Broadcom internal kernel review list , Richard Cochran , Radu Pirea , Shyam Sundar S K , Yisen Zhuang , Salil Mehta , Jassi Brar , Ilias Apalodimas , Iyappan Subramanian , Keyur Chudgar , Quan Nguyen , "Rafael J. Wysocki" , Len Brown , Rob Herring , Frank Rowand , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, devicetree@vger.kernel.org, kernel@pengutronix.de Subject: Re: [PATCH 06/12] net: phy: add phy_device_atomic_register helper Message-ID: <34e22343-fb11-4a85-bade-492fcbcfb436@lunn.ch> References: <20230405-net-next-topic-net-phy-reset-v1-0-7e5329f08002@pengutronix.de> <20230405-net-next-topic-net-phy-reset-v1-6-7e5329f08002@pengutronix.de> <20230405152225.tu3wmbcvchuugs5u@pengutronix.de> <20230405194353.pwuk7e6rxnha3uqi@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230405194353.pwuk7e6rxnha3uqi@pengutronix.de> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > Currently we have one API which creates/allocates the 'struct > phy_device' and intialize the state which is: > - phy_device_create() > > This function requests a driver based on the phy_id/c45_ids. The ID have > to come from somewhere if autodection is used. For autodetection case > - get_phy_device() > > is called. This function try to access the phy without taken possible > hardware dependencies into account. These dependecies can be reset-lines > (in my case), clocks, supplies, ... > > For taking fwnode (and possible dependencies) into account fwnode_mdio.c > was written which provides two helpers: > - fwnode_mdiobus_register_phy() > - fwnode_mdiobus_phy_device_register(). > > The of_mdio.c and of_mdiobus_register_phy() is just a wrapper around > fwnode_mdiobus_register_phy(). It seems to me that the real problem is that mdio_device_reset() takes an mdio_device. mdiobus_register_gpiod() and mdiobus_register_reset() also take an mdio_device. These are the functions you want to call before calling of_mdiobus_register_phy() in __of_mdiobus_register() to ensure the PHY is out of reset. But you don't have an mdio_device yet. So i think a better solution is to refactor this code. Move the resources into a structure of their own, and make that a member of mdio_device. You can create a stack version of this resource structure in __of_mdiobus_register(), parse DT to fill it out by calling mdiobus_register_gpiod() and mdiobus_register_reset() taking this new structure, take it out of reset by calling mdio_device_reset(), and then call of_mdiobus_register_phy(). If a PHY is found, copy the values in the resulting mdio_device. If not, release the resources. Doing it like this means there is no API change. Andrew