Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp909381rdb; Wed, 6 Dec 2023 03:36:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IGii3vjzcnOfdurOuR2Gx8A9mvbC5gtHO7Bt+M9lfdGWU6Gf3YHUenG8RbGIMNFtaBIMXQn X-Received: by 2002:a05:6a00:2a08:b0:6ce:2732:1e06 with SMTP id ce8-20020a056a002a0800b006ce27321e06mr470913pfb.64.1701862570799; Wed, 06 Dec 2023 03:36:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701862570; cv=none; d=google.com; s=arc-20160816; b=pTBFAZe7XXIKd8piztnjlk+Ulp+7uIhFXz2V5xvc2mkwQ92/+jKDr0SdouScank+wz XddxQnbMkitc2gGCY6nR4+Rpbo/35IF3zNl/sGNUEkUvw8HlzJmKs5cLOZNmETurgl4o wtskm3V+U7eIBtqJUxtVJPkRjPKCFHgv0/XbgkMflf52H1RBxvrXotyw6hbPnDgge1VX Ui1EtvPN2aMUPPWAV/J+felqWMKj10nHGUMrpkfkwTgkiWXEFTKzpIYvZirdpyvjRWYf gOFZmryaDqfQTuht1hJ5xWfsUVKPCMX6oeJvh/s4IL1hVTODcEj+3lSXEEtVJ61tk8W1 ilhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=yTqiZeizWXvlOvrzcJc//rjjod60sYkk5t3nX7ba714=; fh=fCvhbdNdgO9vBHhp9ZkAwaZiXrHefeS52UuP+/F+QAU=; b=FjvkQjC3q5hRC/rW1ftBJS9DsFaS+8dyxqSq/i7TZugAofFd/EATSAkC6xMXXgVLYF SZVjGldYrDomlFDfVgJ5YDpzIhSTo4B9sXOIu9PoTi6RupzHyoT8Ew5tHoAJ19nfbDc6 dev8yJj8Wxw5Qs50N3yotyJnBCbkWTAnf3keFVek3zNBiq0uDHRNg4piHwCnMvICyMyy zN9WBEhkVMzDB+LQbwAi9WOmCIPWGrRKEsHa5HP9env48uGDEeTN3hIO5V1pTHpAoKyA oiVcf27Uud37myuNg+RC9VS8bNWJ7QTyOJTDwjbjXSI6QP5V3zMoRDF0Nbqhm545iFgE o9Iw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xs4all.nl Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id b14-20020a056a000a8e00b006cdc6987539si11565733pfl.266.2023.12.06.03.36.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 03:36:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xs4all.nl Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 1BA92818D52E; Wed, 6 Dec 2023 03:36:07 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377673AbjLFLfd (ORCPT + 99 others); Wed, 6 Dec 2023 06:35:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377628AbjLFLfa (ORCPT ); Wed, 6 Dec 2023 06:35:30 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FFADC9 for ; Wed, 6 Dec 2023 03:35:36 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A678C433C7; Wed, 6 Dec 2023 11:35:32 +0000 (UTC) Message-ID: <43621420-2482-4634-9c3e-1a3278481540@xs4all.nl> Date: Wed, 6 Dec 2023 12:35:31 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 5/8] media: qcom: camss: Add support for named power-domains Content-Language: en-US, nl To: Bryan O'Donoghue , laurent.pinchart@ideasonboard.com, Robert Foss , Todor Tomov , Andy Gross , Bjorn Andersson , Konrad Dybcio , Mauro Carvalho Chehab , matti.lehtimaki@gmail.com, quic_grosikop@quicinc.com Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20231123-b4-camss-named-power-domains-v6-0-3ec2fd9e8e36@linaro.org> <20231123-b4-camss-named-power-domains-v6-5-3ec2fd9e8e36@linaro.org> From: Hans Verkuil In-Reply-To: <20231123-b4-camss-named-power-domains-v6-5-3ec2fd9e8e36@linaro.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Wed, 06 Dec 2023 03:36:07 -0800 (PST) On 23/11/2023 18:03, Bryan O'Donoghue wrote: > Right now we use fixed indexes to assign power-domains, with a > requirement for the TOP GDSC to come last in the list. > > Adding support for named power-domains means the declaration in the dtsi > can come in any order. > > After this change we continue to support the old indexing - if a SoC > resource declaration or the in-use dtb doesn't declare power-domain names > we fall back to the default legacy indexing. > > From this point on though new SoC additions should contain named > power-domains, eventually we will drop support for legacy indexing. > > Tested-by: Matti Lehtimäki > Signed-off-by: Bryan O'Donoghue > --- > drivers/media/platform/qcom/camss/camss-vfe.c | 24 +++++++++++++++++++++++- > drivers/media/platform/qcom/camss/camss.c | 26 +++++++++++++++++++++----- > drivers/media/platform/qcom/camss/camss.h | 2 ++ > 3 files changed, 46 insertions(+), 6 deletions(-) > > diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c > index 60c4730e7c9d1..083d1445a6e25 100644 > --- a/drivers/media/platform/qcom/camss/camss-vfe.c > +++ b/drivers/media/platform/qcom/camss/camss-vfe.c > @@ -1382,7 +1382,29 @@ int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe, > if (!res->line_num) > return -EINVAL; > > - if (res->has_pd) { > + /* Power domain */ > + > + if (res->pd_name) { > + vfe->genpd = dev_pm_domain_attach_by_name(camss->dev, > + res->pd_name); > + if (IS_ERR(vfe->genpd)) { > + ret = PTR_ERR(vfe->genpd); > + return ret; > + } > + } > + > + if (!vfe->genpd && res->has_pd) { > + /* > + * Legacy magic index. > + * Requires > + * power-domain = , > + * , > + * > + * id must correspondng to the index of the VFE which must > + * come before the TOP GDSC. VFE Lite has no individually > + * collapasible domain which is why id < vfe_num is a valid > + * check. > + */ > vfe->genpd = dev_pm_domain_attach_by_id(camss->dev, id); > if (IS_ERR(vfe->genpd)) > return PTR_ERR(vfe->genpd); > diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c > index 35918cf837bdd..f2d2317c38b5b 100644 > --- a/drivers/media/platform/qcom/camss/camss.c > +++ b/drivers/media/platform/qcom/camss/camss.c > @@ -1522,12 +1522,28 @@ static int camss_configure_pd(struct camss *camss) > return 0; > > /* > - * VFE power domains are in the beginning of the list, and while all > - * power domains should be attached, only if TITAN_TOP power domain is > - * found in the list, it should be linked over here. > + * If a power-domain name is defined try to use it. > + * It is possible we are running a new kernel with an old dtb so > + * fallback to indexes even if a pd_name is defined but not found. > */ > - camss->genpd = dev_pm_domain_attach_by_id(camss->dev, camss->genpd_num - 1); > - if (IS_ERR(camss->genpd)) { > + if (camss->res->pd_name) { > + camss->genpd = dev_pm_domain_attach_by_name(camss->dev, > + camss->res->pd_name); > + if (IS_ERR(camss->genpd)) { > + ret = PTR_ERR(camss->genpd); > + goto fail_pm; > + } > + } > + > + if (!camss->genpd) { > + /* > + * Legacy magic index. TITAN_TOP GDSC must be the last > + * item in the power-domain list. > + */ > + camss->genpd = dev_pm_domain_attach_by_id(camss->dev, > + camss->genpd_num - 1); > + } > + if (IS_ERR_OR_NULL(camss->genpd)) { > ret = PTR_ERR(camss->genpd); I get this smatch warning here: drivers/media/platform/qcom/camss/camss.c:1555 camss_configure_pd() warn: passing zero to 'PTR_ERR' I'm not really sure what the intent is here. If the fix is small, then I can change it myself, otherwise I need an updated patch. Regards, Hans > goto fail_pm; > } > diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/platform/qcom/camss/camss.h > index 1ba824a2cb76c..cd8186fe1797b 100644 > --- a/drivers/media/platform/qcom/camss/camss.h > +++ b/drivers/media/platform/qcom/camss/camss.h > @@ -48,6 +48,7 @@ struct camss_subdev_resources { > u32 clock_rate[CAMSS_RES_MAX][CAMSS_RES_MAX]; > char *reg[CAMSS_RES_MAX]; > char *interrupt[CAMSS_RES_MAX]; > + char *pd_name; > u8 line_num; > bool has_pd; > const void *ops; > @@ -84,6 +85,7 @@ enum icc_count { > > struct camss_resources { > enum camss_version version; > + const char *pd_name; > const struct camss_subdev_resources *csiphy_res; > const struct camss_subdev_resources *csid_res; > const struct camss_subdev_resources *ispif_res; >