Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1930443pxb; Fri, 29 Jan 2021 08:39:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJzEuifKVBdHDg/cMJz/MhCY1Mo8S4IUWZi8RNOVXdC6VYnCQjw6Bl4EgV6agwa7tZhXkjUk X-Received: by 2002:a17:906:2617:: with SMTP id h23mr5509253ejc.168.1611938397783; Fri, 29 Jan 2021 08:39:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611938397; cv=none; d=google.com; s=arc-20160816; b=ejl2zvQ3qi4lt8j802a7hDq4oV/EkWibKhJikkQ7u/t2qO4r1zIfXUloY1BH3mPCPJ ftSenjqu7lSZLku3GER3PDcS3fAn41T36pv5qGjV13XMukcxIs1NQDqwXFr4G2fhhq2C ht6CCWbCR87X+n/TNcix1NjpToqLGzMJUENj+aLXfBy+NBw3MW50S56U6JJKjX3xiCC5 AU7sJyy1bD0Qfk39CLRElA43HjQVAeggrgqkmMhmr5/K+fGs9yfZlJqZfVUzX2X0Ly1K Dful0sOjkNC8ymtTEtBrn1vKQY7j6ErPb0Q+0+MIUWjzTsoToxx/c/YJI2/8+EWBXYYp OfMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=Yo+UnI3asEDx3wQagFoNSo48d6iNCcAeofFLaX+Rbpg=; b=xDeW+tzJSMOfRLknGPio/U2JBJbkMI8Vr3V6AOhKozcMjhijBXr+kUwpCOM87mhkai 3Kphja0v0V78bn3QFoVgn++IrTyRVcW70AdIWWIlxbBL//M3VC73jLOD/aNF3BET7o8k QpYDrmwslicveggQbWPh9Ns8RfT5fzpKMa6fdfXdZlWTs+QCRDj9y9iS5gYSivaE+WiP /NHCifklGzv/KGGnaOUKEv7vRB0Dnzh29zShPPMnkebjMKMuidNOoD8eh1ks9RkaGZRr YueviXpzufiFQ/G9G9phroLi8T1V5v2g3i5zENp51UPzaKMz7pY00CRNzC27G80PjZLM 76xA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l4si5071575eje.727.2021.01.29.08.39.32; Fri, 29 Jan 2021 08:39:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231699AbhA2Qi7 (ORCPT + 99 others); Fri, 29 Jan 2021 11:38:59 -0500 Received: from mail-ot1-f54.google.com ([209.85.210.54]:33549 "EHLO mail-ot1-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231631AbhA2Qij (ORCPT ); Fri, 29 Jan 2021 11:38:39 -0500 Received: by mail-ot1-f54.google.com with SMTP id 63so9183006oty.0; Fri, 29 Jan 2021 08:38:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Yo+UnI3asEDx3wQagFoNSo48d6iNCcAeofFLaX+Rbpg=; b=TxzIMabWlaXrADQOsnsptQ56TEse+jdaQyExn2LfuHtxGrwYBdVFG0vFSX7NbmR6qo eLAFrQnV+soNt2EV9vI7CrdcVFr3AwglMWkU6QdImG2WN78eaFMgIJaK5SpLWEgja8O3 ppMtZTRj+PGZvJG8LAUv2MeufQZfsz+UJSt1+f7yh/uXM7G7OeClKzWL0DOyCbKXlZZc zE+BIK4W5u+dKVnpOv9YnEsq+rnRvqKCHprOAxQnOT6bfZYov6P2lSVCR84ebwtf2gyY 9JPw3IFYUnfF6CbFvEv20fn9r2PE8cpvtR6J8qfNCO0f07p89wkwLzSmad82mqFXTMLQ tmow== X-Gm-Message-State: AOAM5307MNYRayJ2MSbpjLacWLmRzA+pPtltSudW4Yt/MA2CNrjcf29s Kn+LDKmhuq3WTwO5ZOIjA6NUGBOalk2l+fD1RkM= X-Received: by 2002:a05:6830:2313:: with SMTP id u19mr3479681ote.321.1611938276935; Fri, 29 Jan 2021 08:37:56 -0800 (PST) MIME-Version: 1.0 References: <20210122154300.7628-1-calvin.johnson@oss.nxp.com> <20210122154300.7628-2-calvin.johnson@oss.nxp.com> <20210128112729.GA28413@lsv03152.swis.in-blr01.nxp.com> <20210128131205.GA7882@lsv03152.swis.in-blr01.nxp.com> <20210129064739.GA24267@lsv03152.swis.in-blr01.nxp.com> In-Reply-To: <20210129064739.GA24267@lsv03152.swis.in-blr01.nxp.com> From: "Rafael J. Wysocki" Date: Fri, 29 Jan 2021 17:37:45 +0100 Message-ID: Subject: Re: [net-next PATCH v4 01/15] Documentation: ACPI: DSD: Document MDIO PHY To: Calvin Johnson Cc: "Rafael J. Wysocki" , Grant Likely , Jeremy Linton , Andrew Lunn , Andy Shevchenko , Florian Fainelli , Russell King - ARM Linux admin , Cristi Sovaiala , Florin Laurentiu Chiculita , Ioana Ciornei , Madalin Bucur , Heikki Krogerus , Marcin Wojtas , Pieter Jansen Van Vuuren , Jon , Saravana Kannan , Randy Dunlap , "linux.cj" , Diana Madalina Craciun , ACPI Devel Maling List , Linux ARM , Linux Kernel Mailing List , netdev , Laurentiu Tudor , Len Brown , "Rafael J. Wysocki" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 29, 2021 at 7:48 AM Calvin Johnson wrote: > > On Thu, Jan 28, 2021 at 02:27:00PM +0100, Rafael J. Wysocki wrote: > > On Thu, Jan 28, 2021 at 2:12 PM Calvin Johnson > > wrote: > > > > > > On Thu, Jan 28, 2021 at 01:00:40PM +0100, Rafael J. Wysocki wrote: > > > > On Thu, Jan 28, 2021 at 12:27 PM Calvin Johnson > > > > wrote: > > > > > > > > > > Hi Rafael, > > > > > > > > > > Thanks for the review. I'll work on all the comments. > > > > > > > > > > On Fri, Jan 22, 2021 at 08:22:21PM +0100, Rafael J. Wysocki wrote: > > > > > > On Fri, Jan 22, 2021 at 4:43 PM Calvin Johnson > > > > > > wrote: > > > > > > > > > > > > > > Introduce ACPI mechanism to get PHYs registered on a MDIO bus and > > > > > > > provide them to be connected to MAC. > > > > > > > > > > > > > > Describe properties "phy-handle" and "phy-mode". > > > > > > > > > > > > > > Signed-off-by: Calvin Johnson > > > > > > > --- > > > > > > > > > > > > > > Changes in v4: > > > > > > > - More cleanup > > > > > > > > > > > > This looks much better that the previous versions IMV, some nits below. > > > > > > > > > > > > > Changes in v3: None > > > > > > > Changes in v2: > > > > > > > - Updated with more description in document > > > > > > > > > > > > > > Documentation/firmware-guide/acpi/dsd/phy.rst | 129 ++++++++++++++++++ > > > > > > > 1 file changed, 129 insertions(+) > > > > > > > create mode 100644 Documentation/firmware-guide/acpi/dsd/phy.rst > > > > > > > > > > > > > > diff --git a/Documentation/firmware-guide/acpi/dsd/phy.rst b/Documentation/firmware-guide/acpi/dsd/phy.rst > > > > > > > new file mode 100644 > > > > > > > index 000000000000..76fca994bc99 > > > > > > > --- /dev/null > > > > > > > +++ b/Documentation/firmware-guide/acpi/dsd/phy.rst > > > > > > > @@ -0,0 +1,129 @@ > > > > > > > +.. SPDX-License-Identifier: GPL-2.0 > > > > > > > + > > > > > > > +========================= > > > > > > > +MDIO bus and PHYs in ACPI > > > > > > > +========================= > > > > > > > + > > > > > > > +The PHYs on an MDIO bus [1] are probed and registered using > > > > > > > +fwnode_mdiobus_register_phy(). > > > > > > > > > > > > Empty line here, please. > > > > > > > > > > > > > +Later, for connecting these PHYs to MAC, the PHYs registered on the > > > > > > > +MDIO bus have to be referenced. > > > > > > > + > > > > > > > +The UUID given below should be used as mentioned in the "Device Properties > > > > > > > +UUID For _DSD" [2] document. > > > > > > > + - UUID: daffd814-6eba-4d8c-8a91-bc9bbf4aa301 > > > > > > > > > > > > I would drop the above paragraph. > > > > > > > > > > > > > + > > > > > > > +This document introduces two _DSD properties that are to be used > > > > > > > +for PHYs on the MDIO bus.[3] > > > > > > > > > > > > I'd say "for connecting PHYs on the MDIO bus [3] to the MAC layer." > > > > > > above and add the following here: > > > > > > > > > > > > "These properties are defined in accordance with the "Device > > > > > > Properties UUID For _DSD" [2] document and the > > > > > > daffd814-6eba-4d8c-8a91-bc9bbf4aa301 UUID must be used in the Device > > > > > > Data Descriptors containing them." > > > > > > > > > > > > > + > > > > > > > +phy-handle > > > > > > > +---------- > > > > > > > +For each MAC node, a device property "phy-handle" is used to reference > > > > > > > +the PHY that is registered on an MDIO bus. This is mandatory for > > > > > > > +network interfaces that have PHYs connected to MAC via MDIO bus. > > > > > > > + > > > > > > > +During the MDIO bus driver initialization, PHYs on this bus are probed > > > > > > > +using the _ADR object as shown below and are registered on the MDIO bus. > > > > > > > > > > > > Do you want to mention the "reg" property here? I think it would be > > > > > > useful to do that. > > > > > > > > > > No. I think we should adhere to _ADR in MDIO case. The "reg" property for ACPI > > > > > may be useful for other use cases that Andy is aware of. > > > > > > > > The code should reflect this, then. I mean it sounds like you want to > > > > check the "reg" property only if this is a non-ACPI node. > > > > > > Right. For MDIO case, that is what is required. > > > "reg" for DT and "_ADR" for ACPI. > > > > > > However, Andy pointed out [1] that ACPI nodes can also hold reg property and > > > therefore, fwnode_get_id() need to be capable to handling that situation as > > > well. > > > > No, please don't confuse those two things. > > > > Yes, ACPI nodes can also hold a "reg" property, but the meaning of it > > depends on the binding which is exactly my point: _ADR is not a > > fallback replacement for "reg" in general and it is not so for MDIO > > too. The new function as proposed doesn't match the MDIO requirements > > and so it should not be used for MDIO. > > > > For MDIO, the exact flow mentioned above needs to be implemented (and > > if someone wants to use it for their use case too, fine). > > > > Otherwise the code wouldn't match the documentation. > > In that case, is this good? It would work, but I would introduce a wrapper around the _ADR evaluation, something like: int acpi_get_local_address(acpi_handle handle, u32 *addr) { unsigned long long adr; acpi_status status; status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &adr); if (ACPI_FAILURE(status)) return -ENODATA; *addr = (u32)adr; return 0; } in drivers/acpi/utils.c and add a static inline stub always returning -ENODEV for it for !CONFIG_ACPI. > /** > * fwnode_get_local_addr - Get the local address of fwnode. > * @fwnode: firmware node > * @addr: addr value contained in the fwnode > * > * For DT, retrieve the value of the "reg" property for @fwnode. > * > * In the ACPI case, evaluate the _ADR object located under the > * given node, if present, and provide its return value to the > * caller. > * > * Return 0 on success or a negative error code. > */ > int fwnode_get_local_addr(struct fwnode_handle *fwnode, u32 *addr) > { > int ret; > > if (is_of_node(fwnode)) > return of_property_read_u32(to_of_node(fwnode), "reg", addr); So you can write the below as if (is_acpi_device_node(fwnode)) return acpi_get_local_address(ACPI_HANDLE_FWNODE(fwnode), addr); return -EINVAL; and this should compile just fine if CONFIG_ACPI is unset, so you can avoid the whole #ifdeffery in this function. > > #ifdef CONFIG_ACPI > if (is_acpi_node(fwnode)) { > unsigned long long adr; > acpi_status status; > > status = acpi_evaluate_integer(ACPI_HANDLE_FWNODE(fwnode), > METHOD_NAME__ADR, NULL, &adr); > if (ACPI_FAILURE(status)) > return -ENODATA; > *addr = (u32)adr; > return 0; > } > #endif > return -EINVAL; > }