Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1168298rwl; Wed, 5 Apr 2023 12:49:14 -0700 (PDT) X-Google-Smtp-Source: AKy350a/m/EJ1UGDm5y/pO0ap+QCR+UtutXJebpi+XP3HjDdeKqcIle/S8LMOanIqdUvP7zGZHKb X-Received: by 2002:a05:6402:31f7:b0:4bb:e80c:5667 with SMTP id dy23-20020a05640231f700b004bbe80c5667mr3388840edb.10.1680724154384; Wed, 05 Apr 2023 12:49:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680724154; cv=none; d=google.com; s=arc-20160816; b=tTfgnRPv67TxDMkTjOO7pJq4kxiJBimjPJP1Ul6Qp58QNdltmOO88Chbzo9Zd8Qvop RssuTZ6S46+/79j9Ty9qn5N9DnfTQvbD1vwyLFYp5+YQDbziCbfRPl2VxSI8eMLI9pZr iqnG/044zc4jbOtCS8oz8K+xjoOKziX6GHYDzMtSXfupnmM4+B22AxVHY7f0xc31GYek rvRYbLBAXtQs26EFsz8IAkW6VoSTEz3ducdPK4Dcx8EyTB/Ykrzn8t6lprSTxoMS5mj9 mu/VWNp3eRSOHePpX9s8qiSUxPijO/rdkVV/u98Bs2EeQX9bxyQJ2HtbiseV9goZYHkC 65Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=Ge/8GC/qyH4X1UWyYUrvE2IrYDf9oNSVI76d7u9KbqU=; b=qBY1PhpIrnFNjMkOudFTTUqKItPARkNfrc8Sq95N/ptN7kN+CKUkD84RpXgFYz3Ibq 7k9HLSFqSr87b1bmtFue6Ux6p2ypstvcrXqrxPq8ocRWsgdsKQaM9Atk8XSkgkCzZ6I4 qXdXXr7ZRfw5uawwSRApMjTtwDWmpknRcYraN9pZrXyrEdSck91fCYS3cAFnx7R7Glua HdJA/rjfAnnzdrZGTiWzWBQZpDCsk4kSPHwMt4mxQvYm8Onun7A1REJQkBFXYgELelLO P/PU5hpE/TsNl64fMPgyikMZFdSamuf8n7950FNg4yAsRhhI+mG9ZzMLNo0xEsgVuVwO L7IA== ARC-Authentication-Results: i=1; mx.google.com; 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 bf16-20020a0564021a5000b004c3d75da1a0si1406326edb.154.2023.04.05.12.48.49; Wed, 05 Apr 2023 12:49:14 -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; 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 S229473AbjDETog (ORCPT + 99 others); Wed, 5 Apr 2023 15:44:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231564AbjDETod (ORCPT ); Wed, 5 Apr 2023 15:44:33 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57779E44 for ; Wed, 5 Apr 2023 12:44:30 -0700 (PDT) Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pk930-00087L-Th; Wed, 05 Apr 2023 21:43:58 +0200 Received: from mfe by ptx.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1pk92v-0005ZW-QA; Wed, 05 Apr 2023 21:43:53 +0200 Date: Wed, 5 Apr 2023 21:43:53 +0200 From: Marco Felsch To: Andrew Lunn 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: <20230405194353.pwuk7e6rxnha3uqi@pengutronix.de> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: mfe@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED, SPF_HELO_NONE,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 23-04-05, Andrew Lunn wrote: > > The current fwnode_mdio.c don't provide the proper helper functions yet. > > Instead the parsing is spread between fwnode_mdiobus_register_phy() and > > fwnode_mdiobus_phy_device_register(). Of course these can be extracted > > and exported but I don't see the benefit. IMHO it just cause jumping > > around files and since fwnode is a proper firmware abstraction we could > > use is directly wihin core/lib files. > > No, assuming fwnode is the proper firmware abstraction is wrong. You > need to be very careful any time you convert of_ to fwnode_ and look > at the history of every property. Look at the number of deprecated OF > properties in Documentation/devicetree/bindings. They should never be > moved to fwnode_ because then you are moving deprecated properties to > ACPI, which never had them in the first place! The handling of deprecated properties is always a pain. Drivers handling deprecated properties correctly for of_ should handle it correctly for fwnode_ too. IMHO it would be driver bug if not existing deprecated properties cause an error. Of course there will be properties which need special attention for ACPI case but I don't see a problem for deprecated properties since those must be handled correctly for of_ case too. > You cannot assume DT and ACPI are the same thing, have the same > binding. And the same is true, in theory, in the opposite direction. > We don't want the DT properties polluted with ACPI only properties. > Not that anybody takes ACPI seriously in networking. My assumption was that ACPI is becoming more closer to OF and the fwnode/device abstraction is the abstraction to have one driver interacting correctly with OF and ACPI. As I said above there will be some corner-cases which need special attention of course :/ Also while answering this mail, I noticed that there are already some 'small' fwnode/device_ helpers within phy_device.c. So why not bundling everything within phy_device.c? > > I know and I thought about adding the firmware parsing helpers first but > > than I went this way. I can split this of course to make the patch > > smaller. > > Please do. Also, i read your commit message thinking it was a straight > copy of the code, and hence i did not need to review the code. But in > fact it is new code. So i need to take a close look at it. > > But what i think is most important for this patchset is the > justification for not fixing the current API. Why is it broken beyond > repair? 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(). fwnode_mdiobus_register_phy(): 1st) calls get_phy_device() in case of autodection or c45. If phy_id is provided and !c45 case phy_device_create() is called to get a 'struct phy_device' - The autodection/c45 case try to access the PHYID registers which is not possible, please see above. 2nd) call fwnode_mdiobus_phy_device_register() or phy_device_register() directly. - phy_device_register() is the first time we taking the possible hardware reset line into account, which is far to late. fwnode_mdiobus_phy_device_register(): - takes a 'struct phy_device' as parameter, again this have to come from somewhere. - calls phy_device_register() which is taken the possibel hardware reset into account, again to late. Why do I need the autodection? Because PHYs can be changed due to EOL, cheaper device, ... I don't wanna have a new devicetree/firmware for the updated product, just let the magic happen :) Why do I introduce a new API? 1st) There are working users of get_phy_device() and I don't wanna break their systems, so I left this logic untouched. 2nd) The fwnode API is replaced by this new one, since it is broken (please see above). 3rd) IMHO the 'phy request/phy create' handling is far to complex therefore I introduced a single API which: - intialize all structures and states - prepare the device for interaction by using fwnode - initialize/detect the device and requests the coorect phy module - applies the fixups - add the device to the kernel - finally return the 'struct phy_device' to the user, so the driver can do $stuff. 4th) The new 'struct phy_device_config' makes it easier to adapt/extend the API. Thanks a lot for your fast response and feedback :) Regards, Marco