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 F0DEEC433F5 for ; Tue, 28 Dec 2021 13:09:16 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 45315837A7; Tue, 28 Dec 2021 14:09:14 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="JFepScQL"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 46E478380B; Tue, 28 Dec 2021 14:09:12 +0100 (CET) Received: from mail-ua1-x933.google.com (mail-ua1-x933.google.com [IPv6:2607:f8b0:4864:20::933]) (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 2306083790 for ; Tue, 28 Dec 2021 14:09:08 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@google.com Received: by mail-ua1-x933.google.com with SMTP id p2so31751132uad.11 for ; Tue, 28 Dec 2021 05:09:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ycZeN5o9XrcAOEsiEa9Zy6ZF0ViFRbQib6uZB4rSEiQ=; b=JFepScQLBnAmNuhoBLCzRo5jaMwerOdy3xJz5hMQt2cwGGqy6YR4wcVErL8KpD/Man j0ymDTV4mea8HJf1tDPTmo5kQS7C2hu0ISUAgpdkG1r3ZPXvjP+wOyhqIiT8ZojvO0KW V6ege185fXa1D7nAKoThzdLtH9Pkqn1d/YPXE= 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=ycZeN5o9XrcAOEsiEa9Zy6ZF0ViFRbQib6uZB4rSEiQ=; b=FQpnc0OHGmQOxpWnZ/ONC1/1i+kPoVFKqTyhQ61no7iWw5SxcSLWUPyH11Dl8xnmDR KpTd5ybU/C8ghblROlUHCyrMg7abSTIvVJYQKrZM4z2nbh8Ya3owIP0/BLVxPqWzfYeP GFudnqWbDsYkSqX78U304LvqBtvxzZCAUT5rhT5myJ4n8QtAcfwc08/nAHaKkvOO2K00 HSYEeQtoc+Gby4nRAQu/CZwVgBfvP8c9mHbORaUVcChpORd4omVAGt37KsiX+jmoYVs7 PSHzjGx6+QTM89k7iuQVpTfNTgxDAb6qGsu/QqYAhQ0THaWq3q9G0OD2TWzw2PWgW8fn AYFg== X-Gm-Message-State: AOAM532a4CZ0RhLv81JLn7JeZUV/s771/GeVAPLxbLrujGCwrVWuIdjZ 7oLK9ZY8BHpNzewajyBaTXmgCb9koeuQeCc+67ysHQ== X-Google-Smtp-Source: ABdhPJyFy9x1gZY0lgG+xuBn84RE1mP1a8y7taSlPGYhyFKiwXp9K4PgVECbZpUIGbTDkcq2k1/4OSviffz85kNhw7A= X-Received: by 2002:a67:ce0b:: with SMTP id s11mr6478335vsl.38.1640696946544; Tue, 28 Dec 2021 05:09:06 -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: Simon Glass Date: Tue, 28 Dec 2021 06:08:55 -0700 Message-ID: Subject: Re: [PATCH v2] phy: Track power-on and init counts in uclass To: Tom Rini 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 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 Hi Tom, On Tue, 28 Dec 2021 at 05:55, 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? It looks safe to me and it has a test. If there are boards destined for this release that need it, then I have no objection. Regards, Simon