Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2022929rwb; Fri, 19 Aug 2022 13:45:28 -0700 (PDT) X-Google-Smtp-Source: AA6agR6e6AO86sc630J8qIaHiX80b4zFRIs7ByTzHVyvkz6RUA4uh9tDpet/f3pj7TSwkszg4w/K X-Received: by 2002:a17:907:1c87:b0:6f0:29ea:cc01 with SMTP id nb7-20020a1709071c8700b006f029eacc01mr6002657ejc.671.1660941928243; Fri, 19 Aug 2022 13:45:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660941928; cv=none; d=google.com; s=arc-20160816; b=gURXhnMDi4E1MYgc6v9dREuSiGVjpntbhu2SXpURNwj/HVoxcnf++hCzCR2LVk2nnP OsJXrVsNKUQTgTzxpWEbYiFjQrFzT82lkbXEq0gMjxFguuGtqpBz9y0RsJ2U8eRonUJh RT39XN8y5ubzl/skVb4pfb8FVc/8r7g9+1YjcVJYdsEmpBo3Ht1tpAO1Z7aSsEl4alLA oMvAjKNVwSiKbg6egdtkGwmbb8e3w/8e6X0+SxvfeFopq8o/ld4ZopCa1CfyoLPQInSO XiBM7+6q5ZinwwzQ44MNVWL0hXNzn2hjsMn8T5ghMQ+0UIeYc5Ngb/pxtVOXn9bFq5oh a9gQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=9n5RFn8TAV/PffgBuvz2HviY+YN6byWrm18eu2DfQto=; b=j75AowCwkgIfMeljeTdco1EkQrzdrRrNLdleNUEbeN9Lv9EPOuvIqKjccvXF9MHw8e RwnGgUGQ+YgVJKfRVscrYE9YOezEw5BLnWsuLXxUKhmNNYe2mVmWiImKZHDi/zrYwwQl 4/Na9xMB666RQOWww6HQbicLMaP2RDhgiWnqwV5hZ3nYB3tQ1y14AxxIczuUi7ygdNAh wjWqWuoUBAyPzf/wwQjBxQQk4RgD/pXFzBrNGN8Wi7ORIGqS6E+POBRYXFV27tEIqPxW Hvf0MgB0EJJoXV+03Iip/p98tX1gnZrAafuEw40hvt8uzi5rKqmhde5VYllpPi9En/51 Rrtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="Ip/Z93Lj"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f25-20020a170906495900b0072aeac5f74bsi3851645ejt.119.2022.08.19.13.45.02; Fri, 19 Aug 2022 13:45:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="Ip/Z93Lj"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351573AbiHSUDv (ORCPT + 99 others); Fri, 19 Aug 2022 16:03:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351558AbiHSUDs (ORCPT ); Fri, 19 Aug 2022 16:03:48 -0400 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 430EF40555 for ; Fri, 19 Aug 2022 13:03:47 -0700 (PDT) Received: by mail-ej1-x62a.google.com with SMTP id dc19so10669950ejb.12 for ; Fri, 19 Aug 2022 13:03:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=9n5RFn8TAV/PffgBuvz2HviY+YN6byWrm18eu2DfQto=; b=Ip/Z93LjOs20PVD0ORy+d2AlF7JTde7DigljJbgUklC8daxceXrlHlC+osry84FYst RhLGh7wZAKwAOM6Mv9UPKCwzkc1Sdwwl3EsKEpat05HMIhVvQx7Dm7h8pN3OoRSnIuir PlAV/67SwQQUcuotu1/3g6SFa6BGGnl+9Qp00= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=9n5RFn8TAV/PffgBuvz2HviY+YN6byWrm18eu2DfQto=; b=7CZRjvsUgVhlcQ6l+GEMo8dxL8jFKbvTvMyRRzTKAcSRmX4DjBfonq62M7mblwf4bu yq3+Y4DUl/07YzIERAS4L8pSlISIDSURYMYcPc+1Yn+JPb1gCA4DMiRPMCaKLM7chY97 wICbU9F+7HXT56ccMugDmEXne76EEENZt66ZoL99PRjzrIQMBRDcteXr/pZ8jxW5Y0zO Y9Z50nKozt0JTGpEEYN04AbATtcVxSEXxrH500rbnTYLDy6VNcdQGUnD8sX3IkrTNxv4 QXN9diIsSfNpUpU/GNWIqOttCcsekxuCxQFDzNbhnF6mkBr9PTdfR4+XaPa4fDYRyuYb mxmQ== X-Gm-Message-State: ACgBeo20GGdchrpEyL38N0SKyHlsKTUh00HrFcfEK26XNL0FhbGsmvI1 RAGeN4Q7UCP2oVoudWpxnF89nXi7YholP0KMwWQ= X-Received: by 2002:a17:907:7354:b0:73c:d528:94ae with SMTP id dq20-20020a170907735400b0073cd52894aemr3252331ejc.274.1660939425590; Fri, 19 Aug 2022 13:03:45 -0700 (PDT) Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com. [209.85.128.52]) by smtp.gmail.com with ESMTPSA id 25-20020a170906311900b0073a96816eb0sm1468739ejx.222.2022.08.19.13.03.44 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 19 Aug 2022 13:03:44 -0700 (PDT) Received: by mail-wm1-f52.google.com with SMTP id k6-20020a05600c1c8600b003a54ecc62f6so2971852wms.5 for ; Fri, 19 Aug 2022 13:03:44 -0700 (PDT) X-Received: by 2002:a05:600c:4e8b:b0:3a5:f5bf:9c5a with SMTP id f11-20020a05600c4e8b00b003a5f5bf9c5amr9034593wmq.85.1660939423911; Fri, 19 Aug 2022 13:03:43 -0700 (PDT) MIME-Version: 1.0 References: <20220819194336.382740-1-ahalaney@redhat.com> In-Reply-To: <20220819194336.382740-1-ahalaney@redhat.com> From: Doug Anderson Date: Fri, 19 Aug 2022 13:03:31 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] regulator: core: Clean up on enable failure To: Andrew Halaney Cc: Liam Girdwood , Mark Brown , LKML , bmasney@redhat.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Fri, Aug 19, 2022 at 12:44 PM Andrew Halaney wrote: > > If regulator_enable() fails, enable_count is incremented still. > A consumer, assuming no matching regulator_disable() is necessary on > failure, will then get this error message upon regulator_put() > since enable_count is non-zero: > > [ 1.277418] WARNING: CPU: 3 PID: 1 at drivers/regulator/core.c:2304 _regulator_put.part.0+0x168/0x170 > > The consumer could try to fix this in their driver by cleaning up on > error from regulator_enable() (i.e. call regulator_disable()), but that > results in the following since regulator_enable() failed and didn't > increment user_count: > > [ 1.258112] unbalanced disables for vreg_l17c > [ 1.262606] WARNING: CPU: 4 PID: 1 at drivers/regulator/core.c:2899 _regulator_disable+0xd4/0x190 > > Fix this by decrementing enable_count upon failure to enable. > > With this in place, just the reason for failure to enable is printed > as expected and developers can focus on the root cause of their issue > instead of thinking their usage of the regulator consumer api is > incorrect. For example, in my case: > > [ 1.240426] vreg_l17c: invalid input voltage found > > Fixes: 5451781dadf8 ("regulator: core: Only count load for enabled consumers") > Signed-off-by: Andrew Halaney > --- > > I'm new to using the regulator framework, but I _believe_ this is a > cosmetic bug that's fixed by this patch. I went down a bit of a rabbit > hole because of the original WARN() message, so I'm trying to prevent > others from doing the same :) > > Please let me know what you think, I tested on the misconfigured system > and on a working system and things seemed to work as expected. > > Thanks, > Andrew > > drivers/regulator/core.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) This looks right to me. Thanks! Reviewed-by: Douglas Anderson