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 4DDBCC77B7E for ; Tue, 2 May 2023 10:53:20 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 444EA846F5; Tue, 2 May 2023 12:53:18 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1683024798; bh=VYJbcTBSbteRwmHGW+E0X/yXf0r9wD5UCHu46XyUgZs=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=NcYP/kB3pkh414tkqm7HQyAB2ZVPydJ9LXWiBYH57lP9n5XaXXKsNjPa78yp18BYQ urYKY9fdXaUgESE2Dgzp1uEWxATY1vhRgrCbxN+t6nZUadwsUDq9DcKrebxJu1lx9h JDekRBFWzMY73RicJzJCUn0ktty+lQLCVuYcZP595QS1GxgTyXghxUawj6016zVjYX NcipCv0D+NXa2TRXEEGYWl5uD7ZNmZJU7B5RBXy3Lxe6UQ5QXf9nPxKO3+5eqahRrp O+OTwf5X4i4ji9Amz5wUJTSTMsHiDwJdB4xmNOfFxKBVJp80R1aryfVvgeIK1aJ86D UMRylwlhckRnw== Received: from [127.0.0.1] (p578adb1c.dip0.t-ipconnect.de [87.138.219.28]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id C128882075; Tue, 2 May 2023 12:53:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1683024796; bh=VYJbcTBSbteRwmHGW+E0X/yXf0r9wD5UCHu46XyUgZs=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=BCw9FN9Z6qNy0HV+sejkj0pJ4E9V0/H9XAHAUV7kdaPRMFv+MNxUuXFmRfikF9lna le52WN2w9Bi+mLTKIc7hetjElfYYwo6hc+GqfaOdsUZrtVZUKze5kCCOP3EKClLt+G exB2fflPQj/199D1NTIJIxYnzY7CGJX3cSotr6KD6bjiD0ZemGoPv8mQ5kraJF5Ro8 NQoPK+WtuCTOsrkZqIuB7vVYj/OWiY/0i2VZmWGyFyZtIq4amKEsG5N+3IWdcnxhGZ epsADjNSwT1JZUbjYQVPDVTsyDmpFP5WP1cuFEUQTK3OoFnTy0YRoJ5SHeoezkD5oG boNbECdaQPqNg== Message-ID: <477daa1f-a42c-6c88-4e7c-7d67dd8a13f3@denx.de> Date: Tue, 2 May 2023 12:53:15 +0200 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: Eugen Hristev , u-boot@lists.denx.de, tharvey@gateworks.com Cc: sjg@chromium.org References: <20230502065104.32242-1-eugen.hristev@collabora.com> <76acce9d-e61c-814a-5dd4-1c54c1417cf1@collabora.com> From: Marek Vasut In-Reply-To: <76acce9d-e61c-814a-5dd4-1c54c1417cf1@collabora.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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/2/23 12:41, Eugen Hristev wrote: > On 5/2/23 12:18, Marek Vasut wrote: >> On 5/2/23 08:51, 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. >> >> Can that ever happen for Vbus supply (the 5V coming out of USB port) ? >> Can you elaborate how ? > > > Hi Marek, Hi, > Recently I developed a series of patches to add a reference counter for > regulators : > > https://marc.info/?l=u-boot&m=168191189309879&w=2 Ah yes, this is super cool stuff, thanks ! > But with this series, having a regulator already enabled or already > disabled results in an error returned by regulator_set_enable > > Hence, one option is to replace calls with regulator_set_enable_if_allowed > > There is a discussion ongoing here: > > https://marc.info/?l=u-boot&m=168295920316621&w=2 Pardon my ignorance, but uh ... how does Linux deal with regulators which are enabled by prior stage, like U-Boot ? Does it set their enable refcount to =1 or =0 ?