From patchwork Thu Nov 23 17:03:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 169050 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp588313vqx; Thu, 23 Nov 2023 09:06:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IF49v9kZCdfUvD/hhNnFLo2AvemDH83UTE1DHC28tsRXXb9Y9dKGJ4j+rkeWCcbXmmIIiLc X-Received: by 2002:a05:6808:6284:b0:3b8:33cc:329a with SMTP id du4-20020a056808628400b003b833cc329amr6869643oib.22.1700759162770; Thu, 23 Nov 2023 09:06:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700759162; cv=none; d=google.com; s=arc-20160816; b=a2Fp0rTdNCfL19g70bfEJ5WqrfCEqUtb5tB8anJmqj0n9Rfg8yNaj5hdCUMMzlNuO1 qo+0XdL6tyyGJ26fGNJ0oraVU8T41bpUjaXOo+YacYvE+MFEGRhRD+75UwbFAqQzOter vomnqP0IBZnBELWPBJFyRHu+GCFZpFNw3P8PwljRM13KLCEg93UPIbbDEPVQktgnfhj6 QWfrANsJwaecgu2xqIilV/lwR93paJx3yeY8TEdnAYr/3x3t+4TJYg2ud9xtYtwSPMBo r+iP+IAdBAsHzQCY8Q8zlcSWdmYPV9a95pVbUezDH0ql0ru0OAxD2WJuCDH9wZMQeFrD 5Qdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=TyWn2sWxlTw7Q4m48/J6zzoO/2iT3h6vpulSOl0sgCs=; fh=+21+21gNft/7To99MfcGJu9QkWyyZ7J1aCqrKBAZjFw=; b=n/sRSsFAlJbiBXWpbfZvS7/ujly9f2QlChADTSAi+fuizO2FUk41EZVGy2kp4O8MHP JZKnf1FWss4LmhtO3b+rm333XSQ6BNx/TF5EEy97VP0RN3VsR7mvoqGo+cw0262SXEXW bn4+r+qgbpfbryYvEDUP9Gcu7W3SZTC2go4Mqnqb53yosVgD2kd8kFDvOcXQSyLjioK5 RUTfMs9Xgq4tTSFSzQvodt9VCH9IfxyvLnJePvdc+66L/109gLAov2WWMT4vlp9hreDv pz20k4xk2uiMppxQrkZ05gfKFDuQvQbeCrV+AibDpzV+Xk/c8v7wAS2CyQV1N1TOjCB0 Wm4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YJtdT+Ym; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id d4-20020a05680813c400b003af867236fcsi632942oiw.8.2023.11.23.09.06.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 09:06:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YJtdT+Ym; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 41C9980408E3; Thu, 23 Nov 2023 09:03:30 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345350AbjKWRDN (ORCPT + 99 others); Thu, 23 Nov 2023 12:03:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345250AbjKWRDG (ORCPT ); Thu, 23 Nov 2023 12:03:06 -0500 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82CB2D67 for ; Thu, 23 Nov 2023 09:03:10 -0800 (PST) Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-331733acbacso709815f8f.1 for ; Thu, 23 Nov 2023 09:03:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700758989; x=1701363789; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=TyWn2sWxlTw7Q4m48/J6zzoO/2iT3h6vpulSOl0sgCs=; b=YJtdT+YmXnIhouHywAi4cBznt6yjyWiPPYUu8LLOytzVHFRkQLo21hGIdMLF6cd4Rv 8DMx1EqGOPNSJjI8UIw9qFC3iy8w9Ntl4eEOOFJKJolGaK0wbsXGqAP+7sFb8k2A7ON6 lvYVdKeCUe62WHWeSb0Z977Xkpg2sJ8UVH+kiJdUtI4dxtk6YXZeA785q84JbcCtdObr cquuS5LNARySxQOpa5novOdDhl34/j4vI2oDrjfyG4cnwMqGaTvT+G9WkMXY49SDJDBL cactSPX+yE6ZIq4CWNQW/pUdtsLN4NU+K4GT65aHtxVbjdKQi4JRJka6n4NXxYm+RQuF HBuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700758989; x=1701363789; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TyWn2sWxlTw7Q4m48/J6zzoO/2iT3h6vpulSOl0sgCs=; b=ObNRfZjevrlL/FnmJLPB+9CEbjj1dSk/qRXFghiTD1dEOengmLyLU5D6Ds6bDSgMO5 8gMjPiJJrx34JLLc0LzAzcQAkj/zS0Ve+J8HRnDWYeSXCohJofshrcxopj31LFxitL3s 502p3DGJzMfqBSJM2dvjpZ+VvIn4PqnyewW5c65FNCjAr6hAfHV9Vjf2Vlv27sep1pb5 qFcC66fRnkeecvRH9+kzTlQCFwEcwS3poEHh1vCmcd/beBhGAEhgDLhMQP/lDRflwsGa 4ZqbI+E14BTaRQZPal9w/hnEd5sJ59WEHjLKuBPscAbvT6uQQ6Neo4AZ8lS79qAGTobx LZTw== X-Gm-Message-State: AOJu0YyR3KA/B4IyggOTCqmTp06vz5/KypJZD4c65YThsEHYLH1FJ+Gb EXFMmySvpfzhDXC5MJD2zS6U2w== X-Received: by 2002:a5d:640e:0:b0:332:c9e7:3d16 with SMTP id z14-20020a5d640e000000b00332c9e73d16mr36403wru.54.1700758988995; Thu, 23 Nov 2023 09:03:08 -0800 (PST) Received: from [127.0.0.1] ([37.228.218.3]) by smtp.gmail.com with ESMTPSA id f9-20020a0560001b0900b0032196c508e3sm2172585wrz.53.2023.11.23.09.03.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 09:03:07 -0800 (PST) From: Bryan O'Donoghue Date: Thu, 23 Nov 2023 17:03:03 +0000 Subject: [PATCH v6 4/8] media: qcom: camss: Move VFE power-domain specifics into vfe.c MIME-Version: 1.0 Message-Id: <20231123-b4-camss-named-power-domains-v6-4-3ec2fd9e8e36@linaro.org> References: <20231123-b4-camss-named-power-domains-v6-0-3ec2fd9e8e36@linaro.org> In-Reply-To: <20231123-b4-camss-named-power-domains-v6-0-3ec2fd9e8e36@linaro.org> To: hverkuil-cisco@xs4all.nl, laurent.pinchart@ideasonboard.com, Robert Foss , Todor Tomov , Bryan O'Donoghue , 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 X-Mailer: b4 0.13-dev-26615 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 23 Nov 2023 09:03:30 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783375239868302612 X-GMAIL-MSGID: 1783375239868302612 Moving the location of the hooks to VFE power domains has several advantages. 1. Separation of concerns and functional decomposition. vfe.c should be responsible for and know best how manage power-domains for a VFE, excising from camss.c follows this principle. 2. Embedding a pointer to genpd in struct camss_vfe{} meas that we can dispense with a bunch of kmalloc array inside of camss.c. 3. Splitting up titan top gdsc from vfe/ife gdsc provides a base for breaking up magic indexes in dtsi. Suggested-by: Matti Lehtimäki Tested-by: Matti Lehtimäki Signed-off-by: Bryan O'Donoghue Reviewed-by: Konrad Dybcio Reviewed-by: Konrad Dybcio --- drivers/media/platform/qcom/camss/camss-vfe.c | 21 ++++++++- drivers/media/platform/qcom/camss/camss-vfe.h | 2 + drivers/media/platform/qcom/camss/camss.c | 67 ++++++++++++++------------- drivers/media/platform/qcom/camss/camss.h | 4 +- 4 files changed, 59 insertions(+), 35 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c index 5172eb5612a1c..60c4730e7c9d1 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.c +++ b/drivers/media/platform/qcom/camss/camss-vfe.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -1381,8 +1382,11 @@ int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe, if (!res->line_num) return -EINVAL; - if (res->has_pd) - vfe->genpd = camss->genpd[id]; + if (res->has_pd) { + vfe->genpd = dev_pm_domain_attach_by_id(camss->dev, id); + if (IS_ERR(vfe->genpd)) + return PTR_ERR(vfe->genpd); + } vfe->line_num = res->line_num; vfe->ops->subdev_init(dev, vfe); @@ -1506,6 +1510,19 @@ int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe, return 0; } +/* + * msm_vfe_genpd_cleanup - Cleanup VFE genpd linkages + * @vfe: VFE device + */ +void msm_vfe_genpd_cleanup(struct vfe_device *vfe) +{ + if (vfe->genpd_link) + device_link_del(vfe->genpd_link); + + if (vfe->genpd) + dev_pm_domain_detach(vfe->genpd, true); +} + /* * vfe_link_setup - Setup VFE connections * @entity: Pointer to media entity structure diff --git a/drivers/media/platform/qcom/camss/camss-vfe.h b/drivers/media/platform/qcom/camss/camss-vfe.h index 992a2103ec44c..cdbe59d8d437e 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.h +++ b/drivers/media/platform/qcom/camss/camss-vfe.h @@ -159,6 +159,8 @@ struct camss_subdev_resources; int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe, const struct camss_subdev_resources *res, u8 id); +void msm_vfe_genpd_cleanup(struct vfe_device *vfe); + int msm_vfe_register_entities(struct vfe_device *vfe, struct v4l2_device *v4l2_dev); diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c index ed01a3ac7a38e..35918cf837bdd 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -1486,7 +1486,9 @@ static const struct media_device_ops camss_media_ops = { static int camss_configure_pd(struct camss *camss) { + const struct camss_resources *res = camss->res; struct device *dev = camss->dev; + int vfepd_num; int i; int ret; @@ -1506,45 +1508,41 @@ static int camss_configure_pd(struct camss *camss) if (camss->genpd_num == 1) return 0; - camss->genpd = devm_kmalloc_array(dev, camss->genpd_num, - sizeof(*camss->genpd), GFP_KERNEL); - if (!camss->genpd) - return -ENOMEM; + /* count the # of VFEs which have flagged power-domain */ + for (vfepd_num = i = 0; i < camss->vfe_total_num; i++) { + if (res->vfe_res[i].has_pd) + vfepd_num++; + } - camss->genpd_link = devm_kmalloc_array(dev, camss->genpd_num, - sizeof(*camss->genpd_link), - GFP_KERNEL); - if (!camss->genpd_link) - return -ENOMEM; + /* + * If the number of power-domains is greater than the number of VFEs + * then the additional power-domain is for the entire CAMSS block. + */ + if (!(camss->genpd_num > vfepd_num)) + 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. */ - for (i = 0; i < camss->genpd_num; i++) { - camss->genpd[i] = dev_pm_domain_attach_by_id(camss->dev, i); - if (IS_ERR(camss->genpd[i])) { - ret = PTR_ERR(camss->genpd[i]); - goto fail_pm; - } + camss->genpd = dev_pm_domain_attach_by_id(camss->dev, camss->genpd_num - 1); + if (IS_ERR(camss->genpd)) { + ret = PTR_ERR(camss->genpd); + goto fail_pm; } - - if (i > camss->res->vfe_num) { - camss->genpd_link[i - 1] = device_link_add(camss->dev, camss->genpd[i - 1], - DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME | - DL_FLAG_RPM_ACTIVE); - if (!camss->genpd_link[i - 1]) { - ret = -EINVAL; - goto fail_pm; - } + camss->genpd_link = device_link_add(camss->dev, camss->genpd, + DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME | + DL_FLAG_RPM_ACTIVE); + if (!camss->genpd_link) { + ret = -EINVAL; + goto fail_pm; } return 0; fail_pm: - for (--i ; i >= 0; i--) - dev_pm_domain_detach(camss->genpd[i], true); + dev_pm_domain_detach(camss->genpd, true); return ret; } @@ -1566,18 +1564,25 @@ static int camss_icc_get(struct camss *camss) return 0; } -static void camss_genpd_cleanup(struct camss *camss) +static void camss_genpd_subdevice_cleanup(struct camss *camss) { int i; + for (i = 0; i < camss->vfe_total_num; i++) + msm_vfe_genpd_cleanup(&camss->vfe[i]); +} + +static void camss_genpd_cleanup(struct camss *camss) +{ if (camss->genpd_num == 1) return; - if (camss->genpd_num > camss->res->vfe_num) - device_link_del(camss->genpd_link[camss->genpd_num - 1]); + camss_genpd_subdevice_cleanup(camss); + + if (camss->genpd_link) + device_link_del(camss->genpd_link); - for (i = 0; i < camss->genpd_num; i++) - dev_pm_domain_detach(camss->genpd[i], true); + dev_pm_domain_detach(camss->genpd, true); } /* diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/platform/qcom/camss/camss.h index b854cff1774d4..1ba824a2cb76c 100644 --- a/drivers/media/platform/qcom/camss/camss.h +++ b/drivers/media/platform/qcom/camss/camss.h @@ -107,8 +107,8 @@ struct camss { struct vfe_device *vfe; atomic_t ref_count; int genpd_num; - struct device **genpd; - struct device_link **genpd_link; + struct device *genpd; + struct device_link *genpd_link; struct icc_path *icc_path[ICC_SM8250_COUNT]; const struct camss_resources *res; unsigned int vfe_total_num;