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 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 5485BC433F5 for ; Fri, 31 Dec 2021 07:39:59 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3C30980F7A; Fri, 31 Dec 2021 08:39:57 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="GPBjfhtL"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id ABE5580F9C; Fri, 31 Dec 2021 08:39:55 +0100 (CET) Received: from mail-ua1-x935.google.com (mail-ua1-x935.google.com [IPv6:2607:f8b0:4864:20::935]) (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 2132980379 for ; Fri, 31 Dec 2021 08:39:52 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pbrobinson@gmail.com Received: by mail-ua1-x935.google.com with SMTP id r15so46184072uao.3 for ; Thu, 30 Dec 2021 23:39:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=drBecTzJRP2SrWvF5vx6QrbWY99kfnkB1yAn6/27BY8=; b=GPBjfhtLw8/GjrSSGFddFGdv4DfSjWs+0n0vaMmQpua7UkBuVa4A3PO4WfvEwvw5mG D+Nom1BeWHgFCrJDPTk/yyh0HJECaFZgRJI6T9AiFFCe651z2Fs+T74ycpWUqfNC9Cw3 pGDUOT7V966oXE2Ps+K+y5thZXA6m2kHiAAl2aAVt+0HbpW0u8INM/VAD9wHlxdt0A/y puBeiYkVrYtXE9BnfZ0IRMPZd14rSaSrTGsgtod+m2YBILSaoN0aqrh8x7elleHQ0EJS frbmDpbXxacTobioHA+r5j7l79hnrcZ73XLg2d4fdNULO8Nu0nw/x9rO8XaikqP39v+x w5+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=drBecTzJRP2SrWvF5vx6QrbWY99kfnkB1yAn6/27BY8=; b=2Ue58v/hx7cw6F5bTit4Lr1Oc0W2Kn0T9yww7bOELfcN3ehKdd+ZAWJnxUjMoPtLRC FUip/OK9Ixqr/+S9dAdT6h/avL3MnhojZ8O96dpQh0DtlvWWl0mqi0UAQLk+3dA3xzlZ G8XsnuF3MqQzH6IuHhi8vt4chg89ztyvu4d0eSjh72OjYWL0PXXPkCZx2SgH2jcrWa9N GM3oQ/OT9ppuA08bmtdkEP7Ci+cFLnyjTLU4iJC0KZuTkGur+zZzPR+PCKcmLtQmZLN8 uWxeJmF2OeosnsAsSP0kKm+RAEdeoAFHLHbhnMLAyD7Jhn6ygep0+C6WAyrPWUFCZhKo sBwQ== X-Gm-Message-State: AOAM533GKRL7zv6UKyKBmNnPN4sC4ndbopjlYmKAzQNFiVQhOPUz05Au 2cM+dwXVzPJPQdzUK2dT9b9DvovxAh/YvOlD2b0= X-Google-Smtp-Source: ABdhPJxVKB7hQMlumPdySeStHW0Z6N50pt8YYnofX7/kT3u9b1CsvSUw/YZDso2N6rISO35Exe6WAQGe9iM+PEkYxSI= X-Received: by 2002:a05:6102:c0a:: with SMTP id x10mr11021554vss.19.1640936390747; Thu, 30 Dec 2021 23:39:50 -0800 (PST) MIME-Version: 1.0 References: <20211224130549.20276-1-alpernebiyasak@gmail.com> <20211228125524.GG2773246@bill-the-cat> In-Reply-To: <20211228125524.GG2773246@bill-the-cat> From: Peter Robinson Date: Fri, 31 Dec 2021 07:39:33 +0000 Message-ID: Subject: Re: [PATCH v2] phy: Track power-on and init counts in uclass To: Tom Rini Cc: Simon Glass , Alper Nebi Yasak , U-Boot Mailing List , Neil Armstrong , Frank Wang , Grant Likely , Patrick Delaunay , Icenowy Zheng , Jagan Teki , Andre Przywara , Grant Likely , Joe Hershberger Content-Type: text/plain; charset="UTF-8" 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 On Tue, Dec 28, 2021 at 12:55 PM Tom Rini wrote: > > On Tue, Dec 28, 2021 at 01:34:18AM -0700, Simon Glass wrote: > > Hi Alper, > > > > 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.19226-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(-) > > > > Reviewed-by: Simon Glass > > > > Should add comments for the struct > > > > 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? We've had a number of queries each release around this problem so it maybe worthwhile to include, I think that most distros that pre-build things for users are aware of it enough that they've had local patches for some time so personally for me I'm OK either way. Peter