Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5994991rwb; Mon, 14 Nov 2022 12:36:08 -0800 (PST) X-Google-Smtp-Source: AA0mqf7WkYcBEhb/6yp99gdcic34uasQLyQTyVoJMwafvfZTLy41I8VCVCVH9+2BJdqkC76f1w5x X-Received: by 2002:a17:90a:4503:b0:200:2069:7702 with SMTP id u3-20020a17090a450300b0020020697702mr15481680pjg.239.1668458168574; Mon, 14 Nov 2022 12:36:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668458168; cv=none; d=google.com; s=arc-20160816; b=b8SXiJCjL/2nbk9AQWutVzifMI0iKm6EK+eScmrJV5pE6xRGBb5slCBeSgYMqbzskS j8bLMRoGw5GQrr02v7aMY67qTqQYBeTWjmyYNwm+eRlLQbQOceVNhkH6/QvnWRPqDaQ1 gLtIRNnXPnN9O94T3/0S/C4haN2gXr4HtEadUmaScBn+jcs6nkPnu/wNrOOcrvKTE6Gj r9rW5SCMBd9ujMkZMUqVkf6Ydr8H7O89euLM8uwaPlw830om2DMHFd6ePxbazZxJX0Md MlDh0rNMz5/a93hh2aExz43AXoJEC1rmO7B1nANqWOxUq78ht35cWlEBF5dj6HxYEXwb pszQ== 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=F8YJKTEaSjeWZUEi+lCVZoSmHdKaA45O5/BX7Jv9leE=; b=o3z4SFtX5BMfmGJo8kUeEMXmPc4U0r0iRtEJcqBwrWqIosRqpC2XbVb6h4dEPec7Ld Yx2fsBYBpjJTWXAeRzGCjyXQpRl4KYSKZlXBF+m+wX7knJ0aptbgjk9xkmLo/umKx2EN DldlQe2VRzpePx2SNAJ2oXBaT/A0bxt6qjpZdb5G7HXWH3S98jcqSXNaXSDuAV12DmS7 gbpQsRnRQl6VSo0XUXoRFzPiVnqeoRa5ZUCULS/pZsjr+mNj8CpA5BFmFGESsdinSqIy gyQtvFt+9ZpR6Eqvx4gYz+RrncQpaWsZHflR+iXWcGEI/oh6t1rROvIQyDUdOdDdwoLh ksvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Bo4ud/9w"; 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=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ng15-20020a17090b1a8f00b0020b15fcac76si18070701pjb.4.2022.11.14.12.35.56; Mon, 14 Nov 2022 12:36:08 -0800 (PST) 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=@linaro.org header.s=google header.b="Bo4ud/9w"; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237511AbiKNUMW (ORCPT + 88 others); Mon, 14 Nov 2022 15:12:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237578AbiKNUL4 (ORCPT ); Mon, 14 Nov 2022 15:11:56 -0500 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 226FF1D33D for ; Mon, 14 Nov 2022 12:11:53 -0800 (PST) Received: by mail-pj1-x1032.google.com with SMTP id d13-20020a17090a3b0d00b00213519dfe4aso11815914pjc.2 for ; Mon, 14 Nov 2022 12:11:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=F8YJKTEaSjeWZUEi+lCVZoSmHdKaA45O5/BX7Jv9leE=; b=Bo4ud/9wy/hrzT1vvhDfzIZliKL3nHdYeO1xarp/GBtmeBMu1ebHsicCRbtzgA4VvD zhsCLmYqXAuFGyZ2iJDfrGzsRIfcQNJ7Y4Wg6aOgZKxatMr/2V88oS2o+LK3CFByBcAy wPb3b62Csfvpo/22qIFNqV1MXqzfNfF9PWmixTMiZGauBYITr61tA5ZtWXU0rBHMRt+H rygyifAQLrP0osA+HOHDhYKOu+XXlcDQhf9PYuaDl2rTJuKTkVqI1fM6Q/EJI0xF8DiD QAJzD0uRu4y39bHmuiGEqt4gnA0rEpUbR25D9M0CqdA/+2RCiSSO7Y43j5t+1rl9FcgD swGw== 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=F8YJKTEaSjeWZUEi+lCVZoSmHdKaA45O5/BX7Jv9leE=; b=oWFevNVdK4jjzorhl/e4n1iZZ3V7Iw3Zhr4CehPIwoI5LiHIprarW4XLa93SZPU3mC 4scNGl0RTrMk99FqFn9KCdJ0n+UWfbA9ufocYFRSIrdxSBVhVLPeUGFa0JmLRPg6nUNe 4msaTqoim6aiwI+rDNTTZE2SN856wqYjTW5KL63xmdJy4VTRKht1lDPibMhPTffTkmiY FS5pO81gMTLcZx/XfVSBElQkk9/LmSk6hhhrQ9GJQuVR9nUVKGAa96+Dhkp8goT61SL2 1B4NTjWbzOJEgPCqJ2ber963BEQ+8WYtQE+LfpH7ojraZDw0OBmQPbzY0yuKwabbs0iY autw== X-Gm-Message-State: ANoB5pkbptsZxA+8b+7btnJiiKU8Z5vOLvmfZxdHLEMiHqWA+EGjS8eR gaZhyFcc07XLTK/e3QYF8jAl/xGD9AsJjQXbow4lsg== X-Received: by 2002:a17:90a:e64b:b0:20d:b124:33b1 with SMTP id ep11-20020a17090ae64b00b0020db12433b1mr14918522pjb.202.1668456713336; Mon, 14 Nov 2022 12:11:53 -0800 (PST) MIME-Version: 1.0 References: <20221101233421.997149-1-swboyd@chromium.org> In-Reply-To: From: Ulf Hansson Date: Mon, 14 Nov 2022 21:11:16 +0100 Message-ID: Subject: Re: [PATCH] clk: qcom: gdsc: Remove direct runtime PM calls To: Stephen Boyd Cc: Doug Anderson , Michael Turquette , Stephen Boyd , linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, patches@lists.linux.dev, Andy Gross , Bjorn Andersson , Konrad Dybcio , linux-arm-msm@vger.kernel.org, Dmitry Baryshkov , Johan Hovold , Taniya Das , Satya Priya , Matthias Kaehlcke Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GUARANTEED_100_PERCENT, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=no 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 On Wed, 2 Nov 2022 at 04:16, Stephen Boyd wrote: > > Quoting Doug Anderson (2022-11-01 17:45:03) > > > > One small nit is that the kernel doc for "@dev" in "struct gdsc" is > > incorrect after your patch. It still says this even though we're not > > using it for pm_runtime calls anymore: > > > > * @dev: the device holding the GDSC, used for pm_runtime calls > > Good catch! I can remove the part after the comma. > > > > > Other than that, this seems OK to me. I don't feel like I have a lot > > of good intuition around PM Clocks and genpd and all the topics talked > > about here, but I tried to look at the diff from before all the > > "recent" patches to "drivers/clk/qcom/gdsc.c" till the state after > > your patch. In other words the combined diff of these 4 patches: > > > > clk: qcom: gdsc: Remove direct runtime PM calls > > clk: qcom: gdsc: add missing error handling > > clk: qcom: gdsc: Bump parent usage count when GDSC is found enabled > > clk: qcom: gdsc: enable optional power domain support > > > > That basically shows a combined change that does two things: > > > > a) Adds error handling if pm_genpd_init() returns an error. > > > > b) Says that if "scs[i]->parent" wasn't provided that we can imply a > > parent from "dev->pm_domain". > > > > That seems to make sense, but one thing I'm wondering about for "b)" > > is how you know that "dev->pm_domain" can be safely upcast to a genpd. > > In other words, I'm hesitant about the "pd_to_genpd(dev->pm_domain)" > > call. I'll assume that "dev->pm_domain" isn't 100% guaranteed to be a > > genpd or else (presumably) we would have stored a genpd. Is there > > something about the "dev" that's passed in with "struct gdsc_desc" > > that gives the stronger guarantee about this being a genpd? > > Not really any stronger guarantee. The guarantee is pretty strong > already though. You can look at the callers of dev_pm_domain_set() and > see that nothing is calling that really besides the genpd attachment > logic when a driver is bound to a device (follow dev_pm_domain_attach() > from platform_probe()). The dev->pm_domain is going to be assigned to a > genpd assuming the 'dev' pointer is a platform device and has > 'power-domains' in DT. > > It's not great, but it works for now. Certainly if we ever want to > replace the pm_domain with something that isn't a genpd then we'll be in > trouble. I'm not sure it will ever happen. Ulf, can you provide more > assurances here? I think the call to pd_to_genpd() should be considered as safe, as long as the call is made in a controlled way from within a genpd provider. However, in some cases, we want to pick up a genpd from the dev->pm_domain, that isn't a genpd provider. Internally in genpd we use dev_to_genpd_safe(). Is that something that would be valuable to use here? If so, I don't see any issues with exporting that as a new genpd helper function. [...] Kind regards Uffe