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 phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 51AC5C433EF for ; Tue, 28 Dec 2021 12:55:39 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 71110837D6; Tue, 28 Dec 2021 13:55:36 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="DG9rd3Js"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D679C837A7; Tue, 28 Dec 2021 13:55:34 +0100 (CET) Received: from mail-qt1-x82b.google.com (mail-qt1-x82b.google.com [IPv6:2607:f8b0:4864:20::82b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0D2D2836C5 for ; Tue, 28 Dec 2021 13:55:31 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-qt1-x82b.google.com with SMTP id m25so16013148qtq.13 for ; Tue, 28 Dec 2021 04:55:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=iQ0bfVFRuBLsa3bdIHruxaaqqfD+Mpak4UDDpepJHEU=; b=DG9rd3JsHg0lJOnIwpcWBrC3oLDB3j9sqK2IXcaxnlq3QCAXl3LbrwKAPs3ZBbENK0 vA77vtjgNOrV0BRUlHQmg+6xqaj0dro8Y7e5MxpYTYHavMmYCWX/3Pzbd2XJMGjj37ne j+V0rt6RNN+lsmWa12q4hBHwKI8iavrurA7wk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=iQ0bfVFRuBLsa3bdIHruxaaqqfD+Mpak4UDDpepJHEU=; b=ouqG+3PFyqbykE91o+4TErQ0t08n9Q5FZsozfMr3Rj1DIiY8UIf2zJF2ulqjMWZOiy mV64Em0P48JJJfGEAGEtQrmB5EhsRTuPyspSFmHIh1SiqVCNGtNLm30MSU7MDYD6KCcU 6IYXr6DVptPf3PicgW+QR6ID0IdmVramgaWPk/Ljl53v3SXT34rdATri1VB3bXaAVN8j EkB8cTOWP49AASjrjKEi9hQ+45snSqRBbugNmhQ8sOkf8XY6DW5ozk/DF0g9MDygWNZ0 V0ICkPOwxQT3X1lMpmGNGUjKbgw0FuO6D8QI9HUBIy6zxL9Q8dFO+80iifaJvshTruRO S3Cw== X-Gm-Message-State: AOAM5320tLbZVzx+OUxCoGUYr+q3Ydk+Trtze1UwUcjXqcNV9bp2vkp4 u6yDfSPCDSYVU//6lQUBXJ4KZA== X-Google-Smtp-Source: ABdhPJworE4sDnc8zuBE+6IcPX6LgG1vVg4qlWsCUBchCUSpbI5ESMusR0LqB83Umc8CHpz8Dkm4sg== X-Received: by 2002:ac8:745:: with SMTP id k5mr18351760qth.208.1640696129744; Tue, 28 Dec 2021 04:55:29 -0800 (PST) Received: from bill-the-cat (2603-6081-7b01-cbda-28e1-62ad-aeb7-bfd0.res6.spectrum.com. [2603:6081:7b01:cbda:28e1:62ad:aeb7:bfd0]) by smtp.gmail.com with ESMTPSA id i11sm15960607qko.116.2021.12.28.04.55.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Dec 2021 04:55:28 -0800 (PST) Date: Tue, 28 Dec 2021 07:55:24 -0500 From: Tom Rini To: Simon Glass Cc: Alper Nebi Yasak , U-Boot Mailing List , Neil Armstrong , Frank Wang , Grant Likely , Patrick Delaunay , Icenowy Zheng , Jagan Teki , Andre Przywara , Grant Likely , Peter Robinson , Joe Hershberger Subject: Re: [PATCH v2] phy: Track power-on and init counts in uclass Message-ID: <20211228125524.GG2773246@bill-the-cat> References: <20211224130549.20276-1-alpernebiyasak@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="lh55S0yADJsuIVGW" Content-Disposition: inline In-Reply-To: X-Clacks-Overhead: GNU Terry Pratchett X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean --lh55S0yADJsuIVGW Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Dec 28, 2021 at 01:34:18AM -0700, Simon Glass wrote: > Hi Alper, >=20 > On Fri, 24 Dec 2021 at 06:06, Alper Nebi Yasak = wrote: > > > > On boards using the RK3399 SoC, the USB OHCI and EHCI controllers share > > the same PHY device instance. While these controllers are being stopped > > they both attempt to power-off and deinitialize it, but trying to > > power-off the deinitialized PHY device results in a hang. This usually > > happens just before booting an OS, and can be explicitly triggered by > > running "usb start; usb stop" in the U-Boot shell. > > > > Implement a uclass-wide counting mechanism for PHY initialization and > > power state change requests, so that we don't power-off/deinitialize a > > PHY instance until all of its users want it done. The Allwinner A10 USB > > PHY driver does this counting in-driver, remove those parts in favour of > > this in-uclass implementation. > > > > The sandbox PHY operations test needs some changes since the uclass will > > no longer call into the drivers for actions matching its tracked state > > (e.g. powering-off a powered-off PHY). Update that test, and add a new > > one which simulates multiple users of a single PHY. > > > > The major complication here is that PHY handles aren't deduplicated per > > instance, so the obvious idea of putting the counts in the PHY handles > > don't immediately work. It seems possible to bind a child udevice per > > PHY instance to the PHY provider and deduplicate the handles in each > > child's uclass-private areas, like in the CLK framework. An alternative > > approach could be to use those bound child udevices themselves as the > > PHY handles. Instead, to avoid the architectural changes those would > > require, this patch solves things by dynamically allocating a list of > > structs (one per instance) in the provider's uclass-private area. > > > > Signed-off-by: Alper Nebi Yasak > > --- > > > > Changes in v2: > > - Rename {phy_,}id_priv -> {phy_,}counts > > - Split phy_get_uclass_priv -> phy_{alloc,get}_counts > > - Allocate counts (or return error) in generic_phy_get_by_*() > > - Remove now-unnecessary null checks for counts of valid phy handles > > > > v1: https://patchwork.ozlabs.org/project/uboot/patch/20211210200124.192= 26-1-alpernebiyasak@gmail.com/ > > > > drivers/phy/allwinner/phy-sun4i-usb.c | 9 -- > > drivers/phy/phy-uclass.c | 120 ++++++++++++++++++++++++++ > > test/dm/phy.c | 83 ++++++++++++++++-- > > 3 files changed, 198 insertions(+), 14 deletions(-) >=20 > Reviewed-by: Simon Glass >=20 > Should add comments for the struct >=20 > Also I wonder if a simple fixed-length array might be possible instead > of the linked list? Thanks for the review Simon. Since I think this should unblock some common hardware, does everyone think this should be safe enough to pull in now, or no, I shouldn't bend the rules, and take this for v2021.04 instead? --=20 Tom --lh55S0yADJsuIVGW Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmHLCTUACgkQFHw5/5Y0 tyx1+gv/aQw8gU7qMPAYJXK2JlSrM8ol5yNaqwqFgvsneVgd2fmlskneF+gTm/oK gIuEefHbzw+Do0HzysXqx3BsV0NSh7nhTV8TACUx1xkrpccrRLkWqXsNUmvNEnms G+LOU/z9VrEdFujq/qcqKu3O3xb6/3zFgRdHuBBUP59QUcl6DFdJKWFleNDDplVz f3VznUmMCAsUwbbM24bZtK9OsLB/AKwf4N2DG//5KqhawTkqe8Lcko1mr9GH81Qw P0YDHbOuMHqoZTEPPoFdXKG4Sy+76RMOtcraI/078fRHJOcMhpqH7cg0/dRgUpH8 3DthB7GdSqERWpUUz+H3D/JHHygXrNICvEdXz9/eSfvoDj8nOGo9tPml1YUoLQoD 6VXa2evEkkUxeWnd1LamXQnI6sKadLLqWNWGL9VHEsIigQc9rsGWdkVqotte4aQE rwumHVH4DvQf7DsXpNW2NZN+wOG0/wrKNxr+w4zrSmhQBwrPQALdLeAzjmlkc5W8 2hkvDMiz =gU93 -----END PGP SIGNATURE----- --lh55S0yADJsuIVGW--