Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1750114rda; Tue, 24 Oct 2023 01:58:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH6oMIVT8Zd9PLP/sJsCPVfdDSldWH0cXp4JORRFgvohg64vC/IPYX61+AAt5uOadNduUSR X-Received: by 2002:a17:902:ca0b:b0:1c1:d4f4:cd3c with SMTP id w11-20020a170902ca0b00b001c1d4f4cd3cmr7287010pld.31.1698137889349; Tue, 24 Oct 2023 01:58:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698137889; cv=none; d=google.com; s=arc-20160816; b=gOWCgzVyPVZlRxzMMQ64iTvfG4lydYwvBy5bmw2pkBsk0C+23+4B1606yhsfT5Bc25 dFOKEEfNPfyDi04/LM+9uOg+N/HWAXti5ILsIP17C/v0YCtq7DD+iOiK4uzwPkE/Y31v SvWi9SV4szTNCiWinc4kjwcIKpIKkJt0FDDypbrqrN7+fHWbpxVhVophvXBju1tRiJmy b6FhKHdNWIEzDSfwcGA/DH+wx/wKYfO1g3U+FXoeUSQfv+/wHZJQ77ZYVWAmVqVV1fRn c0chP7eG6TZiRVWaTEQXf0UpgFwmgVUrnUlGPKZJKDUy//0zTAcjwxWEAwqWV+/CMKJB 8Yow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Uk5O71GDx72WXdUblzMnR+VVcl72M4KhBs4KQ0VulsE=; fh=qIFLT/rw9szntj1u3tpRJuB0ZPLNUmmcoIfKgKiKdyc=; b=FgWlbfxGJewySUhZPqsFd5MZ2sjcfKNxNUCGXiP26Et2fKcoT3dzaCCHY+NXNQ5gB+ lH4VhMCTyLmq3t5uTCCYkIy0wYhXGdPemLuNMikuuuJciI7sILBkteKz4mcix17qiKqk mVjqmBhABR8fwgyJsQVPWGkZfRnXV5LzrFA5uJVd2Y35mKJTSkqLvM7eXSt+mxHce6oV IJTDGOZNDey8CxlyJeBNijOVlNbwXCcSutKiKn7Q4AstSxDMobW4D2PsCHrnrcufXLcv uxpDe1pLP7zuAIppl+NYStkWzHm6RZGYzK5zN63fSUEMC/mvxnBWlVNvwgA7PqN46n2a 9uxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernkonzept.com header.s=mx1 header.b=i69p3ITx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernkonzept.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id k15-20020a170902c40f00b001a6ef92d441si8716509plk.599.2023.10.24.01.58.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 01:58:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@kernkonzept.com header.s=mx1 header.b=i69p3ITx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernkonzept.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 8D57680BB1E4; Tue, 24 Oct 2023 01:58:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233942AbjJXI5y (ORCPT + 99 others); Tue, 24 Oct 2023 04:57:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233903AbjJXI5x (ORCPT ); Tue, 24 Oct 2023 04:57:53 -0400 Received: from mx.kernkonzept.com (serv1.kernkonzept.com [IPv6:2a01:4f8:1c1c:b490::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D09CAAC; Tue, 24 Oct 2023 01:57:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kernkonzept.com; s=mx1; h=In-Reply-To:Content-Type:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Content-Transfer-Encoding:Reply-To: Content-ID:Content-Description; bh=Uk5O71GDx72WXdUblzMnR+VVcl72M4KhBs4KQ0VulsE=; b=i69p3ITxAqu1CLZFHv8iB+el7V BhuDUjSZlAXc/kX4+RvjR0IBupPGEEdxj4aieR8knlCHyImJHQHuauSCEW+tnoBHyUIzJ0ItkCGsD D9AIcKCtlVRclMAlBHmrleCy7cbxYeK2TMAML5GUe5m21nA4XNAMlZ1vZ3rA9O8Y8uG01tOvqa5h1 o6MtRe0zY1LEzGPehXSEIJ6hUxU8/DJdWwlqEkqI3lubs76hIDfP0BfaqPwgnwFYgxwaof43nQD4E z3inVnOtC5UoVG12bUb/bTBJOPKnaNby3hEyslCHRV95LZ7GuRbxbbKeexuJA3raNtpwozgFYXCyj IdGsUhLw==; Received: from [10.22.3.24] (helo=kernkonzept.com) by mx.kernkonzept.com with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) id 1qvDEN-000hTc-32; Tue, 24 Oct 2023 10:57:43 +0200 Date: Tue, 24 Oct 2023 10:57:38 +0200 From: Stephan Gerhold To: Mark Brown Cc: Liam Girdwood , Andy Gross , Bjorn Andersson , Konrad Dybcio , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Stephan Gerhold Subject: Re: [PATCH RFC 1/2] regulator: core: Disable unused regulators with unknown status Message-ID: References: <20231004-reg-smd-unused-v1-0-5d682493d555@kernkonzept.com> <20231004-reg-smd-unused-v1-1-5d682493d555@kernkonzept.com> <80307316-f55e-4540-9c5f-655844c3b3f4@sirena.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <80307316-f55e-4540-9c5f-655844c3b3f4@sirena.org.uk> X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 24 Oct 2023 01:58:06 -0700 (PDT) On Mon, Oct 23, 2023 at 01:09:11PM +0100, Mark Brown wrote: > On Wed, Oct 04, 2023 at 04:17:17PM +0200, Stephan Gerhold wrote: > > > Instead of -EINVAL we could also use a different return code to indicate > > the initial status is unknown. Or maybe there is some other option that > > would be easier? This is working for me but I'm sending it as RFC to get > > more feedback. :) > > The more normal thing here would be -EBUSY I think - -EINVAL kind of > indicates that the operation will never work while in reality it could > possibly work in future. Though for the RPMH it's not really the case > that it ever supports readback, what it does is have it's own reference > counting in the driver. Rather than doing this we should probably have > logic in the core which sees that the driver has a write operation but > no read operation and implements appropriate behaviour. Yep, I agree that it would be nicer to handle this case in the core, rather than duplicating the logic in all the RPM-related drivers. I think it does not change much for this patch, though. Even when implemented in the core we still need to represent this situation somehow for regulator_is_enabled(). Simply returning 0 (disabled) or 1 (enabled) would be wrong. Do you think returning -EBUSY would be appropriate for that? The second challenge I see on a quick look is that both qcom_smd-regulator.c and qcom-rpmh-regulator.c use their reference counter internally in other function (e.g. to decide if a voltage change should be sent, see "vreg->enabled" checks). I think we would also need to add some rdev_is_enabled() function that would expose the core reference counter to the driver? Tracking the enable state in the driver (the way it is right now) is not that much code, so I'm not entirely sure if we might actually end up with more code/complexity when moving this to the core. Thanks, -- Stephan Gerhold Kernkonzept GmbH at Dresden, Germany, HRB 31129, CEO Dr.-Ing. Michael Hohmuth