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 E4BCBC7EE21 for ; Thu, 4 May 2023 11:51:56 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D4E7584592; Thu, 4 May 2023 13:51:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=collabora.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=collabora.com header.i=@collabora.com header.b="GPIobKjy"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4032F847C4; Thu, 4 May 2023 13:51:54 +0200 (CEST) Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E1BCA84F47 for ; Thu, 4 May 2023 13:51:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=eugen.hristev@collabora.com Received: from [192.168.0.125] (unknown [82.76.24.202]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: ehristev) by madras.collabora.co.uk (Postfix) with ESMTPSA id 20EDD66031D7; Thu, 4 May 2023 12:51:51 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1683201111; bh=f27e6zIeuFG4GtHPA2iZYw8Ql6tBXrHtzCmtf4UDkOg=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=GPIobKjy8Vc481+Z1fJyJFPzuG2ON1hWU9skh3qQyLbNyOj9NKTEvU7RxboOUuN7a CxTuQeiplAJwma+o0oHJmi/nDHPTJTT2F/SRiQG+JE0jy24R0sMtVwRw1oBQ9ysFP9 xtihXhz0one3Z6qJbX8lXIHQp+6IAFCbbQdGI1wIBhaeKPSJZ2wcWggkQfp5ocEHcH ByFXXiYf3Nyu7yNvX52+wnJ0VI9/yDJYg+8DqFmi5fBwGpAnOfyypxDEatHA1hr2cG bAOLdQ2+VJ82Asj1iKejyfVNSkuZfVXanJhIRTfLuhkd1MsQLbhK4DCv/TmJ385mnm jIPbzoGNhuEyQ== Message-ID: <2bd1431c-6bdb-518c-cf31-c1eb3868e4c7@collabora.com> Date: Thu, 4 May 2023 14:51:48 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH] usb: ehci-mx6: replace regulator_set_enable with *_if_allowed Content-Language: en-US To: Marek Vasut , Tim Harvey Cc: u-boot@lists.denx.de, sjg@chromium.org References: <20230502065104.32242-1-eugen.hristev@collabora.com> <9078dafd-1c8a-499c-fdf8-02adabe36e8c@denx.de> <46133094-779e-feb5-60bb-f160fb4975cb@collabora.com> From: Eugen Hristev In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.8 at phobos.denx.de X-Virus-Status: Clean On 5/4/23 14:41, Marek Vasut wrote: > On 5/4/23 10:12, Eugen Hristev wrote: >> On 5/4/23 00:52, Marek Vasut wrote: >>> On 5/2/23 18:13, Tim Harvey wrote: >>>> On Mon, May 1, 2023 at 11:51 PM Eugen Hristev >>>> wrote: >>>>> >>>>> regulator_set_enable_if_allowed already handles cases when the >>>>> regulator is already enabled, or already disabled, and does not >>>>> treat these as errors. >>>>> With this change, the driver can work correctly even if the regulator >>>>> is already taken or already disabled by another consumer. >>>>> >>>>> Signed-off-by: Eugen Hristev >>>>> --- >>>>> Hi Tim, >>>>> >>>>> I have not tested this as I do not have a mx6 board. can you please >>>>> try it ? >>>>> >>>>> Thanks, >>>>> Eugen >>>> >>>> Eugen, >>>> >>>> This does resolve the issue that occurs after your refcount series [1]. >>>> >>>> However after thinking about this more and seeing Marek's responses >>>> this wasn't an issue of multiple consumers sharing the same regulator. >>>> Instead this particular issue was that the vbus regulator is getting >>>> enabled twice without being disabled. >> >> This kind of issues can be uncovered when we add the refcounter :) > > Yeah, and that's a good thing. The refcounter is much appreciated (am I > repeating myself?) > >> On one hand I am happy to uncover such bugs. >> However, this leads me to wonder, even without a refcount, even >> without my series, enabling a regulator that is already enabled should >> return -EALREADY > > I don't that so, you can have regulators which supply multiple things > and which are claimed by multiple driver instances, at which point they > will each enable the regulator (refcount++) and that shouldn't end up > returning -EALREADY . Right ? That was my thought. And I was returning success if regulator was already enabled. Then Simon asked me to return error codes on each path (review on the v2 of the patches): https://marc.info/?l=u-boot&m=168012024923488&w=2 > > One such example is buck regulator supplying e.g. SD and eMMC Vcc . > >> On the other hand, it appears it will take longer to get the refcount >> applied though. > > I think we need to sort out the fallout, but that's probably still fine.