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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E408C61DA4 for ; Wed, 22 Feb 2023 03:14:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231244AbjBVDOV (ORCPT ); Tue, 21 Feb 2023 22:14:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230445AbjBVDOS (ORCPT ); Tue, 21 Feb 2023 22:14:18 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8CA33C30 for ; Tue, 21 Feb 2023 19:14:16 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id oe18-20020a17090b395200b00236a0d55d3aso7324307pjb.3 for ; Tue, 21 Feb 2023 19:14:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=jAyS6CEssyL2O/MQCLxRPme0Kdvtsn1ed2T3vpNQ+gU=; b=Eaidv/Lm+TFJ7SA6oPwzO/I72/6tfubWrfh4vDeIy6lh65hOXt5Wv3XYF2om11k15c dQW8o4gdS+LSpaqxPdehdmBFaRcj21zuJyRLRbC86IIx+yskh/5oeuMHrVR6lq+89lef cKvfSsSbtodx6w4JPpdW+ZJCtJ05dxopY0pzC+WETFgnuexKaNVeaANlijHHrkA8rZPp QpoS/2m4lS6yi0FBY1rc/wJ531dkEnCR1HNRF3fc7ggSOD3ZwtehLz/f5rhwsQEeVUJt R6FBKJEyv0A7w4/fbbSL/FN1xknxKXgNi41QFikEcbXHYX/hFtSEozxgrSZKAgZHa39Z aVIA== 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:subject:date:message-id :reply-to; bh=jAyS6CEssyL2O/MQCLxRPme0Kdvtsn1ed2T3vpNQ+gU=; b=aFixf5LGlHvskSTmvTJh5EfVgBOcx/znu15Iy2DHnYpuQl9AUqwVH6i4I/bMx2Y6pX NVZQ8vxU83aMso68Tq/8JVUmRezXqTYtKxZzY7e8u+BkVGdCl789OCx2XQ8cZLdk5ny/ tLUv9gnSPW04dBIECETnj2egTH1VMyU2j60PIVp5e0QSeW8HbIBWgSV5vP51layuWny1 Z1XRDZAuzSijDRnWymCshm6I0WAacdl/XbmtotxNdjZDGWxaYWpYtX60nHebuW8pUZ8B dJPPka0WST33ANSjtaE5RQTKlT5cwH9szXXoh5quzCgvN3wjWK/PI5N5NfY/igeTr1cb 9UDQ== X-Gm-Message-State: AO0yUKWgG6ryofaQ3FVU0wSe6V6zv+DTOBdKNQWXYsljv+9QbIiAS/LJ SREkAwGl4ZSkKRWM5Auc2zuUIVLbdTSSRLtoGmqqyw== X-Google-Smtp-Source: AK7set8t979gnqwj+sVUGVPrKyJM8PhOgL2X7XUZIC33hVlIdI94hkRRMzq6VIYYiJFm0dlW7MCewUh2h78USFa11fE= X-Received: by 2002:a17:903:449:b0:199:4830:5cc9 with SMTP id iw9-20020a170903044900b0019948305cc9mr856207plb.10.1677035655978; Tue, 21 Feb 2023 19:14:15 -0800 (PST) MIME-Version: 1.0 References: <20230218083252.2044423-1-saravanak@google.com> In-Reply-To: From: Saravana Kannan Date: Tue, 21 Feb 2023 19:13:39 -0800 Message-ID: Subject: Re: [RFC v1 0/4] Simplify regulator supply resolution code by offloading to driver core To: Mark Brown Cc: Marek Szyprowski , Liam Girdwood , Greg Kroah-Hartman , Geert Uytterhoeven , Bjorn Andersson , Sudeep Holla , Tony Lindgren , Doug Anderson , Guenter Roeck , Luca Weiss , kernel-team@android.com, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 21, 2023 at 2:52 PM Mark Brown wrote: > > On Tue, Feb 21, 2023 at 02:36:52PM -0800, Saravana Kannan wrote: > > > Thanks for testing it Marek! I don't want people to spend more time > > testing this before I hear Mark/Liam's thoughts. So, let's hold off > > for now. > > My main thought right now is that I'm not going to think about it > too hard if it doesn't work correctly... :( I'm not asking for a thorough code review. Just if you are okay with the idea/approach of pushing the ordering logic to driver core to avoid reimplementing what's already available and avoiding some races in the regulator code (stuff like, checking if some other thread resolved a supply while you were working on it). The patch at least works on my device and works for most regulators in Marek's devices. So, it's not a complete broken mess :) On a separate note, I have some questions about setting machine constraints during regulator_register(). Why do we even try to set machine constraints before a regulator's supply is resolved? None of the consumers can make any requests anyway. So what else is going to need those constraints? Wouldn't the regulator just be in whatever state the bootloader left it at? The current logic is something like: 1. Try to resolve supply if it's always on or a boot on regulator. 2. Set machine constraints -- this might fail for multiple reasons. One of them being unresolved supply. 3. If it failed due to unresolved supply, but it wasn't resolved in step 1. 3. a. Try to resolve supply, 3. b. If 3.a. didn't fail, try to set machine constraints. 3. c. If 3.b failed, fail registration. Why isn't this just: 1. Try to resolve supply (for all regulators). 2. If we are able to resolve supply set machine constraints. 3. If we weren't able to resolve supply, set machine constraints when we resolve supply in the future? Or if you need to set machine constraints without waiting for supply, then why not at least: 1. Try to resolve supply (for all regulators). 2. Set machine constraints. 3. When we resolve supply in the future, do whatever remaining bits that you need to do. Thanks, Saravana