Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1935307pxb; Fri, 29 Jan 2021 08:47:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJxvWqmH5cLo0yCT+2r/xm3mRiDykh1RSWVolKMUiBUprAB1Sqc4kYiB/b7PMF3mq9d1kpds X-Received: by 2002:a17:906:c295:: with SMTP id r21mr5745174ejz.235.1611938832509; Fri, 29 Jan 2021 08:47:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611938832; cv=none; d=google.com; s=arc-20160816; b=IM1Nn7TSxsBcpke+w/2/vUZszYYqx4Fv7XooCVRw6pOEGIJNWHmcCabI1Mr2sreA8W BMOLW1kuSH/Z1Fp3DZxamk4WojosxaYWJt2LT9d5YWmh1sw7OmSuCGD8IMARBVaPY1YE 59bKvt2ygGmwCB8F1BN1x+ybzFSeO3PxYPmmEx+5BI1XkF7iUeh9ybsHAAcVYAi+Dqk7 fQO9FXL9Id394BjMdSlCZ+wAGVfneMtsJDV3ZVgc+X5KOrh9rRF+UKWtp+e/2TkYcRDx USwHHRlcQeMrfNFJyVVQ1rI+BI8nxAJqL5InIVFtE0AWAnnhBZvZ8y+d1ohtlZEC5u3m AbAg== 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=wXYCYG1YS0k8rhoZPgZy+Y6qwlRnkfqKgder3/wzP7U=; b=FEFTPjB+gQcPfyEUillENKoqXpTBXeDlT8gAFSdbboYfBTdnPrX9OCRlBsLbFgGrGH HB6VUVT7Ob/ga81C6EzpbridkQoLtA+1HRbYLyo/lgC5DFhNpAekyfOhIWPtx9uwv3mZ h/z5G0/iXE+aICpF51glnHVvIOcdlKrQp9mS5Pj85nnTRmVSmSI7P38DiGiZYF3MiI3l irtbWiD4LoO4aiFn65mY7M2JPJoyjqkSjswbMKbs992NbObC6JZE+VD77pGCiY/ziL5c TBfbqu3JBPgTQFLbpXm2jYRCCqgm6s8jOFNrk5DrZXU013jlPI8BuN3jRTFJ7Mv6Cy5z YqLQ== 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 f17si5552281edv.498.2021.01.29.08.46.46; Fri, 29 Jan 2021 08:47:12 -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 S231596AbhA2QpU (ORCPT + 99 others); Fri, 29 Jan 2021 11:45:20 -0500 Received: from mail-ot1-f44.google.com ([209.85.210.44]:43783 "EHLO mail-ot1-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230249AbhA2QpR (ORCPT ); Fri, 29 Jan 2021 11:45:17 -0500 Received: by mail-ot1-f44.google.com with SMTP id v1so9170195ott.10; Fri, 29 Jan 2021 08:45:01 -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=wXYCYG1YS0k8rhoZPgZy+Y6qwlRnkfqKgder3/wzP7U=; b=XfqxDzR/CH/5tGp1poAfxzX1wd3Ob+TJf39GIgXTses6t4Yrn5xDb7x7DrPb0vUYMW 1CuCH2WHJOEJndgw6ouToUesspjIBg6ZPyIwjWvNTEJVNka687RhPgsb0INz+8hFn25P tmltiVW85hErCSnc4meLJMpY9Eqml3rdOQ1D4OE0xp9I8k7d5HbEaSKQqapQ/cflYb3G tpsbvGZJxjX7LJH0ebyPXR2JZDYRzqLfYc0XWyesazT0ZDPwSktqd9eGFqAcECs23P1N X/Njx1EJUS+kE8cuXDFvEPc46oeAGeTO6OGRa97tpfoPIbpLs7rIwY6qKy9sTB+LZx8j Db4w== X-Gm-Message-State: AOAM533d3jzsp6+If939TJX38a39O3NHSNRMDwZ3bKuLTSJp1Uy8Apvo 7gqnbeaE6Z4hgMhwbN7YNK7Zg5BOamq6/6l1Vrc= X-Received: by 2002:a9d:7a4a:: with SMTP id z10mr3532404otm.206.1611938675763; Fri, 29 Jan 2021 08:44:35 -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: From: "Rafael J. Wysocki" Date: Fri, 29 Jan 2021 17:44:24 +0100 Message-ID: Subject: Re: [net-next PATCH v4 01/15] Documentation: ACPI: DSD: Document MDIO PHY To: Calvin Johnson Cc: 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 5:37 PM Rafael J. Wysocki wrote: > > 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. BTW, you may not need the fwnode_get_local_addr() at all then, just evaluate either the "reg" property for OF or acpi_get_local_address() for ACPI in the "caller" code directly. A common helper doing this can be added later. > > > > #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; > > }