From patchwork Wed Nov 1 10:54:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 160515 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:abcd:0:b0:403:3b70:6f57 with SMTP id f13csp326227vqx; Wed, 1 Nov 2023 03:56:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEtH9ntCSIyvxOR3DTUKHLfnlWkURGE3odmOQYwHzW42dQMOg8COH24JAZi1BeeZUQUGDQ0 X-Received: by 2002:a05:6358:2608:b0:168:ef9b:6c0d with SMTP id l8-20020a056358260800b00168ef9b6c0dmr17363660rwc.32.1698836166483; Wed, 01 Nov 2023 03:56:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698836166; cv=none; d=google.com; s=arc-20160816; b=R2Sj6fPeR/BvH6ed2+JczOs2nBqWR2OwZNeHFQNb6bi+chNM/36mhlE+OAkD/ZO9Li BtpKxiU+HaU9azCfPav3dIJWogFhIpGUrRUAyEVD2wNmLYU2r8XqKotbMoEpDoRUuaPH rTZfHj1z+PhOomA3IIjtw9rxU6u4pooHUcKlXpuzKS1lUlsDwJT1HR4dARrysORIDwlH fjCp4ZvtISazW3ZhDBniTzn5lwWXG+36iUZctcrW8CcZsedZXGybA8yhUp/+43T3lcAA OSmEolIeSz7y1SNui0cAR9nzm5DBTrALkmLJyXTmoJ5dyLZVGhFkQyUb+ziwui77oxJS 8JFw== 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=NvP0vvsp5vu5AYTnNQV4NonQsJ7RGcpCDrLUFWm9/JI=; fh=i6Xq0IxPe+xfIAGis/HEEizm5QSFvbEDbWBJK8514h0=; b=wyylUC30WUOXVd43/nwLpSKcI03V/PZVIDKD4UnaCMKuqynyl38RqgBaov36p9ZIuq e1v5zV5rq6ZIUZEb+2fFVfKgmGIdIZLHr02xdTKHHEt5NsWbZ7jzqHteHCbERRlyCBPI ZeT1IZfX5+cI8dxDHkbv6uhwotuEO5pVZhtLZ0+PxyBRuPPmclhLdmG5FoWc/qhqkIQf F5UeSCBYBwKq3S3SABrZ2Uq3iA5Vkump9hwyjMD6k/Gr8OsnaV3uJflCDqpGThNtyIU8 YzRpr3+tH25CViaxpbDmSzFCm6u4mvcufBn/s7O8zWCbSuuYaY8/YCy5t7SrQBV90asB jsgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bTuwdaQi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id c136-20020a63358e000000b005b8f38f9976si2688574pga.765.2023.11.01.03.56.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 03:56:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bTuwdaQi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id AD6358051170; Wed, 1 Nov 2023 03:55:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234116AbjKAKzh (ORCPT + 35 others); Wed, 1 Nov 2023 06:55:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233221AbjKAKzd (ORCPT ); Wed, 1 Nov 2023 06:55:33 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BE85121 for ; Wed, 1 Nov 2023 03:55:26 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-32d849cc152so4517068f8f.1 for ; Wed, 01 Nov 2023 03:55:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698836124; x=1699440924; 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=NvP0vvsp5vu5AYTnNQV4NonQsJ7RGcpCDrLUFWm9/JI=; b=bTuwdaQiMzxqHcclom9+uyNS1qAUeKW/yw+o1VvskkpSAcZ8zVmnhoF6ae77SryQpy 6xgeYWvx/c1lK469dEdj7Y+4aiYOdqlYEM6HgJldJYLJa6hGS+gvnp6VUcmCnG8j+pTr pTZusntJf16BhpjA2ocizJmT0FnkjOqhAPcu6PiCfNd3oebOfxTTDSiDkr2snhKCbIRX CzZqE7IPR0Vm7PJlWS6A8DnFuRLzh83eE6qjNfTbFLvK43GP4dsvhvTleCp6W10Vcxf6 rMYtPRQQardHjoDk+Hlr/egb34DIv43EM+kvR3t03w2RGTcSWMH57Oa6DrQ0fo0NAH4m uK2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698836124; x=1699440924; 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=NvP0vvsp5vu5AYTnNQV4NonQsJ7RGcpCDrLUFWm9/JI=; b=Zg/z6iUjVE6vOTNPNb5faEQNP7BsrHUGh1gugKbfDzuPtJhPhPPPETtXmViGbpSzqA Q7pWtD3ZPp6mCmSjIN8S9JUiUkDMyaHcVtZg720goT/nZrO8722olTnw2erDZFOyEM6y Xq9qsP8nUZBgchOglw9/N7FVIVEtCAqnqvNcd0irtppllm67ckzHms+lWTRdyDT20WWB rnHmdgWKCulHnD5nbQHPF/DLrFm1/v4WytJ2AcpdROXCvQCJMdcQAi++QJ0fyZGjfVKF pdlKqtFsL/uvEgB4xoGMzxruP+RSh5ajzwhtvtDfMthNvp7mxIzUAL+SVLoDQ6osRGFh zmQA== X-Gm-Message-State: AOJu0YzDSgXc8I1XGRjQbt5eGr0L8px+M3YZYDPdQxb7/LVkPDYDBonL x/7+jZE6rkGADBzHmw2yze1t5g== X-Received: by 2002:a05:6000:1445:b0:32f:7a07:be0d with SMTP id v5-20020a056000144500b0032f7a07be0dmr12823221wrx.59.1698836124662; Wed, 01 Nov 2023 03:55:24 -0700 (PDT) Received: from [127.0.0.1] ([37.228.218.3]) by smtp.gmail.com with ESMTPSA id z2-20020a5d6542000000b0032d09f7a713sm3830948wrv.18.2023.11.01.03.55.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 03:55:23 -0700 (PDT) From: Bryan O'Donoghue Date: Wed, 01 Nov 2023 10:54:31 +0000 Subject: [PATCH v3 1/5] media: qcom: camss: Flag which VFEs require a power-domain MIME-Version: 1.0 Message-Id: <20231101-b4-camss-named-power-domains-v3-1-bbdf5f22462a@linaro.org> References: <20231101-b4-camss-named-power-domains-v3-0-bbdf5f22462a@linaro.org> In-Reply-To: <20231101-b4-camss-named-power-domains-v3-0-bbdf5f22462a@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 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=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, 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 agentk.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 (agentk.vger.email [0.0.0.0]); Wed, 01 Nov 2023 03:55:59 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781358832214844755 X-GMAIL-MSGID: 1781358832214844755 At the moment we have some complex code for determining if a VFE requires a power-domain attachment. Particularly discordant in this scheme is the subtle reliance on VFE and VFE Lite declaration ordering in our resources. VFE id is used to determine if a VFE is lite or not and consequently if a VFE requires power-domain attachment. VFE Lite though is not a correct delineation between power-domain and non power-domain state since early SoCs have neither VFE Lite nor power-domains attached to VFEs. Introduce has_pd to the VFE resource structure to allow the CAMSS code to understand if it needs to try to attach a power-domain for a given VFE. As a side-effect from this we no longer need to care about VFE Lite or non-Lite or the id number associated with either and which order the VFE/VFE Lite was declared in. Reviewed-by: Konrad Dybcio Signed-off-by: Bryan O'Donoghue --- drivers/media/platform/qcom/camss/camss.c | 8 ++++++++ drivers/media/platform/qcom/camss/camss.h | 1 + 2 files changed, 9 insertions(+) diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c index 8e78dd8d5961e..ed01a3ac7a38e 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -278,6 +278,7 @@ static const struct camss_subdev_resources vfe_res_8x96[] = { .reg = { "vfe0" }, .interrupt = { "vfe0" }, .line_num = 3, + .has_pd = true, .ops = &vfe_ops_4_7 }, @@ -298,6 +299,7 @@ static const struct camss_subdev_resources vfe_res_8x96[] = { .reg = { "vfe1" }, .interrupt = { "vfe1" }, .line_num = 3, + .has_pd = true, .ops = &vfe_ops_4_7 } }; @@ -468,6 +470,7 @@ static const struct camss_subdev_resources vfe_res_660[] = { .reg = { "vfe0" }, .interrupt = { "vfe0" }, .line_num = 3, + .has_pd = true, .ops = &vfe_ops_4_8 }, @@ -491,6 +494,7 @@ static const struct camss_subdev_resources vfe_res_660[] = { .reg = { "vfe1" }, .interrupt = { "vfe1" }, .line_num = 3, + .has_pd = true, .ops = &vfe_ops_4_8 } }; @@ -658,6 +662,7 @@ static const struct camss_subdev_resources vfe_res_845[] = { .reg = { "vfe0" }, .interrupt = { "vfe0" }, .line_num = 4, + .has_pd = true, .ops = &vfe_ops_170 }, @@ -680,6 +685,7 @@ static const struct camss_subdev_resources vfe_res_845[] = { .reg = { "vfe1" }, .interrupt = { "vfe1" }, .line_num = 4, + .has_pd = true, .ops = &vfe_ops_170 }, @@ -840,6 +846,7 @@ static const struct camss_subdev_resources vfe_res_8250[] = { .reg = { "vfe0" }, .interrupt = { "vfe0" }, .line_num = 3, + .has_pd = true, .ops = &vfe_ops_480 }, /* VFE1 */ @@ -860,6 +867,7 @@ static const struct camss_subdev_resources vfe_res_8250[] = { .reg = { "vfe1" }, .interrupt = { "vfe1" }, .line_num = 3, + .has_pd = true, .ops = &vfe_ops_480 }, /* VFE2 (lite) */ diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/platform/qcom/camss/camss.h index 8acad7321c09d..b854cff1774d4 100644 --- a/drivers/media/platform/qcom/camss/camss.h +++ b/drivers/media/platform/qcom/camss/camss.h @@ -49,6 +49,7 @@ struct camss_subdev_resources { char *reg[CAMSS_RES_MAX]; char *interrupt[CAMSS_RES_MAX]; u8 line_num; + bool has_pd; const void *ops; }; From patchwork Wed Nov 1 10:54:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 160516 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:abcd:0:b0:403:3b70:6f57 with SMTP id f13csp326457vqx; Wed, 1 Nov 2023 03:56:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH2YunDlj/2CPTqids22tsSO9NYK9Bi5luLxOsHC4ESHoWSfo1LvK5CRRM0bWpZ5yEz86dJ X-Received: by 2002:a17:902:da89:b0:1cc:449b:68ad with SMTP id j9-20020a170902da8900b001cc449b68admr9712367plx.44.1698836202796; Wed, 01 Nov 2023 03:56:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698836202; cv=none; d=google.com; s=arc-20160816; b=V87+HJncT2hMgGQg+nsYsAsEZNOxBZLJrnYMDpec3fwfX69k1/Mo7tzBPAAHHVIxwU 2EfWc6V0Mknz9LZpz8QroccNNSwt+56rxq/GOIrvGTCVfSZu6x2bw+TY95KMgyc2/7p4 SKw+XFSGNnowLeJJKXC9CZACzfpf/hcza9loDzTEV1G8Qd4Ja03tU/Rw0rwRLHr964zk GT/4yYOdTnayWgsp6nHHnZc+N4hdWu3RckwDYhtSdAyKBkF5nzpECoWPeqEZc4i8AT3c FSF78ig1bYe+PiWXvZC5ed6eMSEtC9l8K3Ew1lKjscWLgfUvvVsVVWXz9MaqRLSRyGXZ TOVw== 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=KlJhOk1olbtwYFeRGaUG/fycWPNssjNVpjbYTK7VamM=; fh=i6Xq0IxPe+xfIAGis/HEEizm5QSFvbEDbWBJK8514h0=; b=xu1bnAGgNYEGGmh9wAM9c0NkXl83ktLeRD/W/lGTFH8FeuKBJNl93/PwDdj5Bz0lQD +xoG4zK9/Hjo8fBkfCOjY9eLYC4a1F6DFkorZJ8db8pPzJSktOQ5pALJ1AJKoMlpWtRR 1meHAeJ+WpsaeI9bHO57KGEQ1SoYOijGkiPBGEBenNsMxvCk4JEc4ql4JDpcSRUgJNsr HB3AxRMIFrEOudi4cTARbT6T5P0it4MxpQgufHW70XYpwLgVQC4z8QHvrP79FTaKwdMk XlGqDhGREmbXTX1GKYtX5Ntam2ITJUpbXNXYJ0uLEy0XctpmmweuZmHXTxvScSgw40ph 9LIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="A3SWZz/u"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id jx3-20020a170903138300b001ca000e889bsi2786492plb.175.2023.11.01.03.56.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 03:56:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="A3SWZz/u"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 5FDBA8092230; Wed, 1 Nov 2023 03:55:49 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234697AbjKAKzl (ORCPT + 35 others); Wed, 1 Nov 2023 06:55:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233391AbjKAKzd (ORCPT ); Wed, 1 Nov 2023 06:55:33 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4ADA810C for ; Wed, 1 Nov 2023 03:55:27 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-507973f3b65so10074464e87.3 for ; Wed, 01 Nov 2023 03:55:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698836125; x=1699440925; 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=KlJhOk1olbtwYFeRGaUG/fycWPNssjNVpjbYTK7VamM=; b=A3SWZz/ufe84q/eoafTr+cNlOVdcvrupUqaVyt0pAg0+Om363qxPA7H0fHamfRI06Z G13bxH98H0abHIGTxRjzLWaZEvk7qnNaVTpa7MNUEEOc91wZxgJ1qR/tEisgth+K1xIp 9aR1mF7uh3ZIrR9BDXwGLN9DiLsKfRk0hd60iU6fIE4+Hi81Ul0xezO1oAeMVCgaRZj3 4AIaJo/qNOwyFAa6rJeVd8vzDIJO3DJ/HBG9VEzwVIFaXj9zt7nEaTw8ST9uFTJ/16e9 5w5+UFyPyEATQXpdAu6GEmnomzyfI+CC8DPT5eWObpWiwqp7o7hQedsFO+sE9EIS3UcJ 1AWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698836125; x=1699440925; 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=KlJhOk1olbtwYFeRGaUG/fycWPNssjNVpjbYTK7VamM=; b=MdTcfjyLsj+Enm87xjr2BKXKo/d1toAHjIeP34CD8+br1zVk00fPCR86Zh9joUDNYc 7XxXCcgOQsBrE9UtgnwDB8fZiHuod0OLVRKCD2aeZ8yZzp8AV54etZ5Pl4niUB2/K5Sl hJAjX4b9tNWQxZH02Yqkx0KoSlB90X54U6nqPzEZeYJqV97AOYIF4cjLOq9uK5EO/x3b 64vLM0fFTqr2W+q3Zal+mb/sMUkRc4DENUo/U6cjm4Jgc3Kov1uM1VSuJ2OhFBzm5wsY L+EvQc+kh1KqAygQkvZi7UVI1fsBgS1pLg0juKOaGjGaSvMgFwYKusI/nL0cC/FOo4Pf AiVA== X-Gm-Message-State: AOJu0YxTgePYpi073uk/62paeyzsH7uSIaj35fYyXGgQxdPGWYcH1qhs rDqUrG8a+oAeoDayVZwVnK//cg== X-Received: by 2002:a05:6512:e92:b0:504:7bb0:9d7e with SMTP id bi18-20020a0565120e9200b005047bb09d7emr13894660lfb.27.1698836125565; Wed, 01 Nov 2023 03:55:25 -0700 (PDT) Received: from [127.0.0.1] ([37.228.218.3]) by smtp.gmail.com with ESMTPSA id z2-20020a5d6542000000b0032d09f7a713sm3830948wrv.18.2023.11.01.03.55.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 03:55:25 -0700 (PDT) From: Bryan O'Donoghue Date: Wed, 01 Nov 2023 10:54:32 +0000 Subject: [PATCH v3 2/5] media: qcom: camss: Convert to per-VFE pointer for power-domain linkages MIME-Version: 1.0 Message-Id: <20231101-b4-camss-named-power-domains-v3-2-bbdf5f22462a@linaro.org> References: <20231101-b4-camss-named-power-domains-v3-0-bbdf5f22462a@linaro.org> In-Reply-To: <20231101-b4-camss-named-power-domains-v3-0-bbdf5f22462a@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 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=ham 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]); Wed, 01 Nov 2023 03:55:49 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781358870353281548 X-GMAIL-MSGID: 1781358870353281548 Right now we use the top-level camss structure to provide pointers via VFE id index back to genpd linkages. In effect this hard-codes VFE indexes to power-domain indexes in the dtsi and mandates a very particular ordering of power domains in the dtsi, which bears no relationship to a real hardware dependency. As a first step to rationalising the VFE power-domain code and breaking the magic indexing in dtsi use per-VFE pointers to genpd linkages. The top-level index in msm_vfe_subdev_init is still used to attain the initial so no functional or logical change arises from this change. Reviewed-by: Konrad Dybcio Signed-off-by: Bryan O'Donoghue --- drivers/media/platform/qcom/camss/camss-vfe-170.c | 15 +++++++-------- drivers/media/platform/qcom/camss/camss-vfe-4-7.c | 15 +++++---------- drivers/media/platform/qcom/camss/camss-vfe-4-8.c | 13 +++++-------- drivers/media/platform/qcom/camss/camss-vfe-480.c | 15 +++++++-------- drivers/media/platform/qcom/camss/camss-vfe.c | 3 +++ drivers/media/platform/qcom/camss/camss-vfe.h | 2 ++ 6 files changed, 29 insertions(+), 34 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-vfe-170.c b/drivers/media/platform/qcom/camss/camss-vfe-170.c index 0b211fed12760..7451484317cc3 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-170.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-170.c @@ -638,7 +638,7 @@ static void vfe_pm_domain_off(struct vfe_device *vfe) if (vfe->id >= camss->res->vfe_num) return; - device_link_del(camss->genpd_link[vfe->id]); + device_link_del(vfe->genpd_link); } /* @@ -648,16 +648,15 @@ static void vfe_pm_domain_off(struct vfe_device *vfe) static int vfe_pm_domain_on(struct vfe_device *vfe) { struct camss *camss = vfe->camss; - enum vfe_line_id id = vfe->id; - if (id >= camss->res->vfe_num) + if (vfe->id >= camss->res->vfe_num) return 0; - camss->genpd_link[id] = device_link_add(camss->dev, camss->genpd[id], - DL_FLAG_STATELESS | - DL_FLAG_PM_RUNTIME | - DL_FLAG_RPM_ACTIVE); - if (!camss->genpd_link[id]) + vfe->genpd_link = device_link_add(camss->dev, vfe->genpd, + DL_FLAG_STATELESS | + DL_FLAG_PM_RUNTIME | + DL_FLAG_RPM_ACTIVE); + if (!vfe->genpd_link) return -EINVAL; return 0; diff --git a/drivers/media/platform/qcom/camss/camss-vfe-4-7.c b/drivers/media/platform/qcom/camss/camss-vfe-4-7.c index b65ed0fef595e..2b4e7e039407b 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-4-7.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-4-7.c @@ -1109,14 +1109,10 @@ static void vfe_isr_read(struct vfe_device *vfe, u32 *value0, u32 *value1) */ static void vfe_pm_domain_off(struct vfe_device *vfe) { - struct camss *camss; - if (!vfe) return; - camss = vfe->camss; - - device_link_del(camss->genpd_link[vfe->id]); + device_link_del(vfe->genpd_link); } /* @@ -1126,13 +1122,12 @@ static void vfe_pm_domain_off(struct vfe_device *vfe) static int vfe_pm_domain_on(struct vfe_device *vfe) { struct camss *camss = vfe->camss; - enum vfe_line_id id = vfe->id; - camss->genpd_link[id] = device_link_add(camss->dev, camss->genpd[id], DL_FLAG_STATELESS | - DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE); + vfe->genpd_link = device_link_add(camss->dev, vfe->genpd, DL_FLAG_STATELESS | + DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE); - if (!camss->genpd_link[id]) { - dev_err(vfe->camss->dev, "Failed to add VFE#%d to power domain\n", id); + if (!vfe->genpd_link) { + dev_err(vfe->camss->dev, "Failed to add VFE#%d to power domain\n", vfe->id); return -EINVAL; } diff --git a/drivers/media/platform/qcom/camss/camss-vfe-4-8.c b/drivers/media/platform/qcom/camss/camss-vfe-4-8.c index 7b3805177f037..5e95343241304 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-4-8.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-4-8.c @@ -1099,9 +1099,7 @@ static void vfe_isr_read(struct vfe_device *vfe, u32 *value0, u32 *value1) */ static void vfe_pm_domain_off(struct vfe_device *vfe) { - struct camss *camss = vfe->camss; - - device_link_del(camss->genpd_link[vfe->id]); + device_link_del(vfe->genpd_link); } /* @@ -1111,13 +1109,12 @@ static void vfe_pm_domain_off(struct vfe_device *vfe) static int vfe_pm_domain_on(struct vfe_device *vfe) { struct camss *camss = vfe->camss; - enum vfe_line_id id = vfe->id; - camss->genpd_link[id] = device_link_add(camss->dev, camss->genpd[id], DL_FLAG_STATELESS | - DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE); + vfe->genpd_link = device_link_add(camss->dev, vfe->genpd, DL_FLAG_STATELESS | + DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE); - if (!camss->genpd_link[id]) { - dev_err(vfe->camss->dev, "Failed to add VFE#%d to power domain\n", id); + if (!vfe->genpd_link) { + dev_err(vfe->camss->dev, "Failed to add VFE#%d to power domain\n", vfe->id); return -EINVAL; } diff --git a/drivers/media/platform/qcom/camss/camss-vfe-480.c b/drivers/media/platform/qcom/camss/camss-vfe-480.c index f2368b77fc6d6..a70b8633bb3eb 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-480.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-480.c @@ -463,7 +463,7 @@ static void vfe_pm_domain_off(struct vfe_device *vfe) if (vfe->id >= camss->res->vfe_num) return; - device_link_del(camss->genpd_link[vfe->id]); + device_link_del(vfe->genpd_link); } /* @@ -473,16 +473,15 @@ static void vfe_pm_domain_off(struct vfe_device *vfe) static int vfe_pm_domain_on(struct vfe_device *vfe) { struct camss *camss = vfe->camss; - enum vfe_line_id id = vfe->id; - if (id >= camss->res->vfe_num) + if (vfe->id >= camss->res->vfe_num) return 0; - camss->genpd_link[id] = device_link_add(camss->dev, camss->genpd[id], - DL_FLAG_STATELESS | - DL_FLAG_PM_RUNTIME | - DL_FLAG_RPM_ACTIVE); - if (!camss->genpd_link[id]) + vfe->genpd_link = device_link_add(camss->dev, vfe->genpd, + DL_FLAG_STATELESS | + DL_FLAG_PM_RUNTIME | + DL_FLAG_RPM_ACTIVE); + if (!vfe->genpd_link) return -EINVAL; return 0; diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c index 4839e2cedfe58..94267b9974554 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.c +++ b/drivers/media/platform/qcom/camss/camss-vfe.c @@ -1347,6 +1347,9 @@ 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]; + vfe->line_num = res->line_num; vfe->ops->subdev_init(dev, vfe); diff --git a/drivers/media/platform/qcom/camss/camss-vfe.h b/drivers/media/platform/qcom/camss/camss-vfe.h index 09baded0dcdd6..c1c50023d4876 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.h +++ b/drivers/media/platform/qcom/camss/camss-vfe.h @@ -150,6 +150,8 @@ struct vfe_device { const struct vfe_hw_ops_gen1 *ops_gen1; struct vfe_isr_ops isr_ops; struct camss_video_ops video_ops; + struct device *genpd; + struct device_link *genpd_link; }; struct camss_subdev_resources; From patchwork Wed Nov 1 10:54:33 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: 160517 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:abcd:0:b0:403:3b70:6f57 with SMTP id f13csp326465vqx; Wed, 1 Nov 2023 03:56:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHQJiqcvOlQArsDm75SCFrpyHXqVcCL7Oi3bTvXIijAPaq7igPfx6v2cnbadlf7rsXtwZH1 X-Received: by 2002:a54:450b:0:b0:3b2:e577:7344 with SMTP id l11-20020a54450b000000b003b2e5777344mr15550975oil.38.1698836204685; Wed, 01 Nov 2023 03:56:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698836204; cv=none; d=google.com; s=arc-20160816; b=IltU4p04QkzHRnDY9wAE8VtXb97rMdHM9DVtYvwkz1QW31dYhhhmcrMi1hm016HI60 VrW9heZOkOjYusqV2XTqxL2Jl38iFJq42M6C88bCAnXp45bD3nqgrNpoYK6aPMofD0sh 5AvBQwDoLu5ypO3pZ9dh9J4Jj4aNktAWldrA3252NXqK/K0CoOfhwfaADnS1dg63jzgC innycpNwKQcb15vwNwfmByORf6SWpGIroANjDAZCv2j8VfsibpqZwv7sX8e27Jj7yVFQ m3eO4RmJv8W8LgRWNzZXjwLqi5g2MClf3KThmaRE9/OtVMfEictTgXx9DS0gdlTWrkjb NoPA== 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=vu58a9RQKxZJQ71kfZd1GrHrJotRzWNjVScFmiTpkL0=; fh=i6Xq0IxPe+xfIAGis/HEEizm5QSFvbEDbWBJK8514h0=; b=eOlgDa7ciridlQwVpRYOrFbNSkX/pRj9XLO850bDXTTcjf3NoDP9DoV+wWNEWBDJEt 5kXu/eyPsLAEVybNACeUDZnxiHoa2JFApiutUmH0yDT0mKa6MmGEq1qkQDnheMylOrhD lc4ohdRy6DB5lJyDKmamjpcUFibl8NEQRz+o78n5PYtQPHU+L1j96xh3Z0nza9N8T8Ys 96oCBzNPWkUDiiM20nOdxII6TtmXkTaJHjKBhuVbzeDPryytySr4zfWeBDBgqaP4VtZd TfypQzH9kOM5Pju1zDjEqt6HIMgHRUzX8SWLH7OxKcfheIh+wWosQGB+nnuQxuC11ekw CTvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vTC0ZaNA; 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 d17-20020aa797b1000000b00690a7aefa50si1313605pfq.325.2023.11.01.03.56.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 03:56:44 -0700 (PDT) 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=vTC0ZaNA; 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 54C8180615CE; Wed, 1 Nov 2023 03:55:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234822AbjKAKzo (ORCPT + 35 others); Wed, 1 Nov 2023 06:55:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233744AbjKAKze (ORCPT ); Wed, 1 Nov 2023 06:55:34 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61D04127 for ; Wed, 1 Nov 2023 03:55:28 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-32f7db21967so2995952f8f.1 for ; Wed, 01 Nov 2023 03:55:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698836127; x=1699440927; 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=vu58a9RQKxZJQ71kfZd1GrHrJotRzWNjVScFmiTpkL0=; b=vTC0ZaNApMM6bhIEPINSvU2XVkcsxILCwiTUArIpneL/GzxybFIvWtpZsT2zEcjcf8 Q0LlDTTJwE24Ca1LPrkh8tfGVFXCBEslc5FHQA108YpwlSimcco7pURjOerZaQ6NevZx rLnTYxcfJMgIu+z4Awx/tMHI1B8X98qLKH4cQDnVFKAXR6xvKIuanmG+L408kB3xEH1q fbLf5cV5dPOnS4DPX5SmSVbp0kMFoPuqiV754Zsjyk8Zl0V6/py360aJe96iiV4hhIC8 AUAloVsDKi3jI/+HhuZW41Ry8da5yJAw5Zg5eQrb/h65WSPiLIW9Y1M5AgLHjjPWc+aa fjkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698836127; x=1699440927; 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=vu58a9RQKxZJQ71kfZd1GrHrJotRzWNjVScFmiTpkL0=; b=xTRj7DuxUC3XPfLjXvSgB+yHDdoew4BkdXa7xKv9KWOy0oIcACKI+ml0oiqnSkx1Q7 7KfZQxLxgQKZrro2tDqQGWR/jAEcLiES7eYXwmdZ7kqF2XNtyc2PBd6nNU9FwX6MjDXJ lHJKJ74TFm2v7RZioX/NHceoU75VvH0lByTO1qfXl7aNDh7q0IHCNa8zOfvMerDs+4Lt N2QAB35MxTWp5v+EI75EBZ0UGjmYNtflhGMOzJvgwVJfkTQdHDmJ/FoQ2yoYLBPUANfL aIimkdbVXzn2wUR5/lrC0+keHegK22LCiSsaoD6+JzFwtmBaTRJ5YrAbT/BGZjVXJIKl 7XZw== X-Gm-Message-State: AOJu0YxPJQdMU5927ePdzn+hJK6ORtnIwMCut4ynJZ0Y06/AAco49hL3 n3aznS1ZVSjeKFIOREJ1CQI2+Q== X-Received: by 2002:a5d:47a9:0:b0:32f:96c6:8bb with SMTP id 9-20020a5d47a9000000b0032f96c608bbmr3560242wrb.7.1698836126759; Wed, 01 Nov 2023 03:55:26 -0700 (PDT) Received: from [127.0.0.1] ([37.228.218.3]) by smtp.gmail.com with ESMTPSA id z2-20020a5d6542000000b0032d09f7a713sm3830948wrv.18.2023.11.01.03.55.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 03:55:26 -0700 (PDT) From: Bryan O'Donoghue Date: Wed, 01 Nov 2023 10:54:33 +0000 Subject: [PATCH v3 3/5] media: qcom: camss: Use common VFE pm_domain_on/pm_domain_off where applicable MIME-Version: 1.0 Message-Id: <20231101-b4-camss-named-power-domains-v3-3-bbdf5f22462a@linaro.org> References: <20231101-b4-camss-named-power-domains-v3-0-bbdf5f22462a@linaro.org> In-Reply-To: <20231101-b4-camss-named-power-domains-v3-0-bbdf5f22462a@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 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]); Wed, 01 Nov 2023 03:55:58 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781358872064063625 X-GMAIL-MSGID: 1781358872064063625 For the various versions of VFE we have a boiler-plate pm_domain_on/pm_domain_off callback pair of the general form. - Error check. Not always done but applicable to all. - device_link_add (DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE); - Error check returning -EINVAL on error. - Return 0 Reduce the pattern down to a common callback. VFE 4.1 is a special case which to me also indicates that it is worthwhile maintaining an indirection for the vfe_pm_domain_{on|off} for now. Otherwise lets chuck out a bunch of needlessly replicated code. Reviewed-by: Konrad Dybcio Suggested-by: Matti Lehtimäki Signed-off-by: Bryan O'Donoghue --- drivers/media/platform/qcom/camss/camss-vfe-170.c | 35 ----------------------- drivers/media/platform/qcom/camss/camss-vfe-4-1.c | 8 +++--- drivers/media/platform/qcom/camss/camss-vfe-4-7.c | 31 -------------------- drivers/media/platform/qcom/camss/camss-vfe-4-8.c | 28 ------------------ drivers/media/platform/qcom/camss/camss-vfe-480.c | 35 ----------------------- drivers/media/platform/qcom/camss/camss-vfe.c | 34 ++++++++++++++++++++++ drivers/media/platform/qcom/camss/camss-vfe.h | 12 ++++++++ 7 files changed, 50 insertions(+), 133 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-vfe-170.c b/drivers/media/platform/qcom/camss/camss-vfe-170.c index 7451484317cc3..795ac3815339a 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-170.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-170.c @@ -627,41 +627,6 @@ static void vfe_isr_wm_done(struct vfe_device *vfe, u8 wm) spin_unlock_irqrestore(&vfe->output_lock, flags); } -/* - * vfe_pm_domain_off - Disable power domains specific to this VFE. - * @vfe: VFE Device - */ -static void vfe_pm_domain_off(struct vfe_device *vfe) -{ - struct camss *camss = vfe->camss; - - if (vfe->id >= camss->res->vfe_num) - return; - - device_link_del(vfe->genpd_link); -} - -/* - * vfe_pm_domain_on - Enable power domains specific to this VFE. - * @vfe: VFE Device - */ -static int vfe_pm_domain_on(struct vfe_device *vfe) -{ - struct camss *camss = vfe->camss; - - if (vfe->id >= camss->res->vfe_num) - return 0; - - vfe->genpd_link = device_link_add(camss->dev, vfe->genpd, - DL_FLAG_STATELESS | - DL_FLAG_PM_RUNTIME | - DL_FLAG_RPM_ACTIVE); - if (!vfe->genpd_link) - return -EINVAL; - - return 0; -} - /* * vfe_queue_buffer - Add empty buffer * @vid: Video device structure diff --git a/drivers/media/platform/qcom/camss/camss-vfe-4-1.c b/drivers/media/platform/qcom/camss/camss-vfe-4-1.c index 2911e4126e7ad..ef6b34c915df1 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-4-1.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-4-1.c @@ -936,7 +936,7 @@ static irqreturn_t vfe_isr(int irq, void *dev) * vfe_pm_domain_off - Disable power domains specific to this VFE. * @vfe: VFE Device */ -static void vfe_pm_domain_off(struct vfe_device *vfe) +static void vfe_4_1_pm_domain_off(struct vfe_device *vfe) { /* nop */ } @@ -945,7 +945,7 @@ static void vfe_pm_domain_off(struct vfe_device *vfe) * vfe_pm_domain_on - Enable power domains specific to this VFE. * @vfe: VFE Device */ -static int vfe_pm_domain_on(struct vfe_device *vfe) +static int vfe_4_1_pm_domain_on(struct vfe_device *vfe) { return 0; } @@ -999,8 +999,8 @@ const struct vfe_hw_ops vfe_ops_4_1 = { .hw_version = vfe_hw_version, .isr_read = vfe_isr_read, .isr = vfe_isr, - .pm_domain_off = vfe_pm_domain_off, - .pm_domain_on = vfe_pm_domain_on, + .pm_domain_off = vfe_4_1_pm_domain_off, + .pm_domain_on = vfe_4_1_pm_domain_on, .reg_update_clear = vfe_reg_update_clear, .reg_update = vfe_reg_update, .subdev_init = vfe_subdev_init, diff --git a/drivers/media/platform/qcom/camss/camss-vfe-4-7.c b/drivers/media/platform/qcom/camss/camss-vfe-4-7.c index 2b4e7e039407b..7655d22a9fda2 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-4-7.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-4-7.c @@ -1103,37 +1103,6 @@ static void vfe_isr_read(struct vfe_device *vfe, u32 *value0, u32 *value1) writel_relaxed(VFE_0_IRQ_CMD_GLOBAL_CLEAR, vfe->base + VFE_0_IRQ_CMD); } -/* - * vfe_pm_domain_off - Disable power domains specific to this VFE. - * @vfe: VFE Device - */ -static void vfe_pm_domain_off(struct vfe_device *vfe) -{ - if (!vfe) - return; - - device_link_del(vfe->genpd_link); -} - -/* - * vfe_pm_domain_on - Enable power domains specific to this VFE. - * @vfe: VFE Device - */ -static int vfe_pm_domain_on(struct vfe_device *vfe) -{ - struct camss *camss = vfe->camss; - - vfe->genpd_link = device_link_add(camss->dev, vfe->genpd, DL_FLAG_STATELESS | - DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE); - - if (!vfe->genpd_link) { - dev_err(vfe->camss->dev, "Failed to add VFE#%d to power domain\n", vfe->id); - return -EINVAL; - } - - return 0; -} - static void vfe_violation_read(struct vfe_device *vfe) { u32 violation = readl_relaxed(vfe->base + VFE_0_VIOLATION_STATUS); diff --git a/drivers/media/platform/qcom/camss/camss-vfe-4-8.c b/drivers/media/platform/qcom/camss/camss-vfe-4-8.c index 5e95343241304..f52fa30f3853e 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-4-8.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-4-8.c @@ -1093,34 +1093,6 @@ static void vfe_isr_read(struct vfe_device *vfe, u32 *value0, u32 *value1) writel_relaxed(VFE_0_IRQ_CMD_GLOBAL_CLEAR, vfe->base + VFE_0_IRQ_CMD); } -/* - * vfe_pm_domain_off - Disable power domains specific to this VFE. - * @vfe: VFE Device - */ -static void vfe_pm_domain_off(struct vfe_device *vfe) -{ - device_link_del(vfe->genpd_link); -} - -/* - * vfe_pm_domain_on - Enable power domains specific to this VFE. - * @vfe: VFE Device - */ -static int vfe_pm_domain_on(struct vfe_device *vfe) -{ - struct camss *camss = vfe->camss; - - vfe->genpd_link = device_link_add(camss->dev, vfe->genpd, DL_FLAG_STATELESS | - DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE); - - if (!vfe->genpd_link) { - dev_err(vfe->camss->dev, "Failed to add VFE#%d to power domain\n", vfe->id); - return -EINVAL; - } - - return 0; -} - static void vfe_violation_read(struct vfe_device *vfe) { u32 violation = readl_relaxed(vfe->base + VFE_0_VIOLATION_STATUS); diff --git a/drivers/media/platform/qcom/camss/camss-vfe-480.c b/drivers/media/platform/qcom/camss/camss-vfe-480.c index a70b8633bb3eb..4652e8b4cff58 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-480.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-480.c @@ -452,41 +452,6 @@ static void vfe_isr_wm_done(struct vfe_device *vfe, u8 wm) spin_unlock_irqrestore(&vfe->output_lock, flags); } -/* - * vfe_pm_domain_off - Disable power domains specific to this VFE. - * @vfe: VFE Device - */ -static void vfe_pm_domain_off(struct vfe_device *vfe) -{ - struct camss *camss = vfe->camss; - - if (vfe->id >= camss->res->vfe_num) - return; - - device_link_del(vfe->genpd_link); -} - -/* - * vfe_pm_domain_on - Enable power domains specific to this VFE. - * @vfe: VFE Device - */ -static int vfe_pm_domain_on(struct vfe_device *vfe) -{ - struct camss *camss = vfe->camss; - - if (vfe->id >= camss->res->vfe_num) - return 0; - - vfe->genpd_link = device_link_add(camss->dev, vfe->genpd, - DL_FLAG_STATELESS | - DL_FLAG_PM_RUNTIME | - DL_FLAG_RPM_ACTIVE); - if (!vfe->genpd_link) - return -EINVAL; - - return 0; -} - /* * vfe_queue_buffer - Add empty buffer * @vid: Video device structure diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c index 94267b9974554..5172eb5612a1c 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.c +++ b/drivers/media/platform/qcom/camss/camss-vfe.c @@ -474,6 +474,40 @@ void vfe_isr_reset_ack(struct vfe_device *vfe) complete(&vfe->reset_complete); } +/* + * vfe_pm_domain_off - Disable power domains specific to this VFE. + * @vfe: VFE Device + */ +void vfe_pm_domain_off(struct vfe_device *vfe) +{ + if (!vfe->genpd) + return; + + device_link_del(vfe->genpd_link); + vfe->genpd_link = NULL; +} + +/* + * vfe_pm_domain_on - Enable power domains specific to this VFE. + * @vfe: VFE Device + */ +int vfe_pm_domain_on(struct vfe_device *vfe) +{ + struct camss *camss = vfe->camss; + + if (!vfe->genpd) + return 0; + + vfe->genpd_link = device_link_add(camss->dev, vfe->genpd, + DL_FLAG_STATELESS | + DL_FLAG_PM_RUNTIME | + DL_FLAG_RPM_ACTIVE); + if (!vfe->genpd_link) + return -EINVAL; + + return 0; +} + static int vfe_match_clock_names(struct vfe_device *vfe, struct camss_clock *clock) { diff --git a/drivers/media/platform/qcom/camss/camss-vfe.h b/drivers/media/platform/qcom/camss/camss-vfe.h index c1c50023d4876..992a2103ec44c 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.h +++ b/drivers/media/platform/qcom/camss/camss-vfe.h @@ -203,6 +203,18 @@ int vfe_reset(struct vfe_device *vfe); */ int vfe_disable(struct vfe_line *line); +/* + * vfe_pm_domain_off - Disable power domains specific to this VFE. + * @vfe: VFE Device + */ +void vfe_pm_domain_off(struct vfe_device *vfe); + +/* + * vfe_pm_domain_on - Enable power domains specific to this VFE. + * @vfe: VFE Device + */ +int vfe_pm_domain_on(struct vfe_device *vfe); + extern const struct vfe_hw_ops vfe_ops_4_1; extern const struct vfe_hw_ops vfe_ops_4_7; extern const struct vfe_hw_ops vfe_ops_4_8; From patchwork Wed Nov 1 10:54:34 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: 160519 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:abcd:0:b0:403:3b70:6f57 with SMTP id f13csp326502vqx; Wed, 1 Nov 2023 03:56:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHckzkki4OptC/UIuN/BzTJOS9AYF7qB9Ast7c3rUsiwEmBny22KOVV6+hXnHn4e5y4m3WT X-Received: by 2002:a05:6358:5912:b0:168:e876:de46 with SMTP id g18-20020a056358591200b00168e876de46mr13346277rwf.27.1698836211470; Wed, 01 Nov 2023 03:56:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698836211; cv=none; d=google.com; s=arc-20160816; b=wLPHRU5JbbDgLwDKkC5yVdzo7yshk0/5xgBy4UqAWpLvmv8I9h+7DxVwoK5jokhE8U yvHAuTw+R8ZsVhjv7rqujkOfKyp9pcJ9wewbo6IibOZbyRYQgKIiDBfopKxMa7vhYteb s2zW7BUIVAXr6FBI3q1+a38niqDXjL2NS9s9Hl5rQs5gnpmLgZXlJKhefNq+qnGST1NJ RAl3cxiKT4VFPIvCx+R4fcHh6kCfiswtsOJnWBM9dqijm3/YIVlevhB8bi0EOBZ6/OWn EQhWjccv3Fzp4eqN7X9EbNFu7HF3YwPOFVPKUlmxrSY6AcwcE9hEjN4ql7y7VTAYpBhJ AlAQ== 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=fN35jdBut2R695pmfQNF8kcSJalU/FCNDBQnENZZob0=; fh=i6Xq0IxPe+xfIAGis/HEEizm5QSFvbEDbWBJK8514h0=; b=S4TPFJOjZxth99A9EQb2o6mzFF8LuV3is8Yqvhi7DOl2KdPzsU8xkN3rDoUN2WsbTm pox32zwKtpR6fD/j2moEQlNSFS0fTafXGAhUsG5z468OOvnZ1TrQmhe6q0kzYL514ccD LSm3PDAHXFibAsP6PY88Aj/l1/SEPTAYfZQgmpbmB0YuFGuyWFhzJZ93LVeECAL9VsvK tF+XGzvG8shsxpf+JU4wRbksAc5KakSOWK6DAML8CA+lD/xX3WG5UDqX5g5Qn02UWeNz ZuvfC3m2keoQA2DpPJJXTQk18VXjfGvR9b9zHq+phY1VgxQmCJMBOON1+8gVf3bKXHKO WeeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="nKvWW/pp"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id 143-20020a630195000000b005b9053cf6f2si2784411pgb.163.2023.11.01.03.56.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 03:56:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="nKvWW/pp"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id ADE2A809E22F; Wed, 1 Nov 2023 03:56:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233979AbjKAKz5 (ORCPT + 35 others); Wed, 1 Nov 2023 06:55:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229731AbjKAKzf (ORCPT ); Wed, 1 Nov 2023 06:55:35 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32616128 for ; Wed, 1 Nov 2023 03:55:29 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4081ccf69dcso4140225e9.0 for ; Wed, 01 Nov 2023 03:55:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698836127; x=1699440927; 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=fN35jdBut2R695pmfQNF8kcSJalU/FCNDBQnENZZob0=; b=nKvWW/ppiwtOciRoZIbCqSHwc30b4zljV+1prl/46+gd+6IDbtWdHAODpAYgc91U4Z rDBHx56CxuxAX+D3VXiHXVj8C1t+RYg4zIgevn7s2b8CJgeQxyBRF1LQtrUhb1dhpYT1 x0YnnXJNEFUHx2pW86RpYVxhSg+gUGFkNZOm3AGMS4B9WXIsBeUn00BaztlwF6UgYHMx LAFrT5H0exci6AkOaQTxceZ1jBBlO0JFnEyr6JFDzx0cVfITnADONhB0LltkI/kJyb8H xkFGswW8HPxJPQsrT7LnXrVh5HAx2RiSuONxpsgSrZSxSkMjUH5uhEt3nKPveA9RUdRb 912w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698836127; x=1699440927; 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=fN35jdBut2R695pmfQNF8kcSJalU/FCNDBQnENZZob0=; b=G4EeGzkRCLWYeuXclVNC96bqgj0ZrUA6ULT19m5ywrobgAYOK9dChcfTu6rI2Mj4Yr 4yK2A0SPtzAyLE8ZH7aC5z1HLYqLOk5YzjikkIjPu+Wee9Bcx0EY/g8pbJ42VbbGoVaj HM9Kzz3AJyp7qbId+T2paOL6ooVIC098h5tuCoUI0SBmezgMcFL2g2RCLleGrjHt/HQ4 QYzln0uMdOTpp0e2TlOFvzIxFXLL2mRjQlHdBSGNI01Pq7kpgcz8aFnPle4DnOk3f1uW ike2s98yqQYPk7Ojcn9q+1DxXJ9gEOu+hgEZZf36uALTa0K87ByYopVgk4SPsTEX3aaK 7oEw== X-Gm-Message-State: AOJu0Yz7MZpbZzs5Cm1PepiFARjZNmV2C39J0rFlsup/SEUxMHTA+E7m xsAoK2N6qMkrjppdhwh1kmu5LQ== X-Received: by 2002:a5d:64aa:0:b0:32d:ddb9:289f with SMTP id m10-20020a5d64aa000000b0032dddb9289fmr2973784wrp.34.1698836127649; Wed, 01 Nov 2023 03:55:27 -0700 (PDT) Received: from [127.0.0.1] ([37.228.218.3]) by smtp.gmail.com with ESMTPSA id z2-20020a5d6542000000b0032d09f7a713sm3830948wrv.18.2023.11.01.03.55.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 03:55:27 -0700 (PDT) From: Bryan O'Donoghue Date: Wed, 01 Nov 2023 10:54:34 +0000 Subject: [PATCH v3 4/5] media: qcom: camss: Move VFE power-domain specifics into vfe.c MIME-Version: 1.0 Message-Id: <20231101-b4-camss-named-power-domains-v3-4-bbdf5f22462a@linaro.org> References: <20231101-b4-camss-named-power-domains-v3-0-bbdf5f22462a@linaro.org> In-Reply-To: <20231101-b4-camss-named-power-domains-v3-0-bbdf5f22462a@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 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=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Wed, 01 Nov 2023 03:56:43 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781358879454692304 X-GMAIL-MSGID: 1781358879454692304 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 Signed-off-by: Bryan O'Donoghue --- drivers/media/platform/qcom/camss/camss-vfe.c | 24 +++++++++- drivers/media/platform/qcom/camss/camss-vfe.h | 2 + drivers/media/platform/qcom/camss/camss.c | 63 +++++++++++++-------------- drivers/media/platform/qcom/camss/camss.h | 4 +- 4 files changed, 56 insertions(+), 37 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c index 5172eb5612a1c..defff24f07ce3 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,13 @@ 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)) { + ret = PTR_ERR(vfe->genpd); + return ret; + } + } vfe->line_num = res->line_num; vfe->ops->subdev_init(dev, vfe); @@ -1506,6 +1512,20 @@ 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..415164bf00402 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -1487,7 +1487,6 @@ static const struct media_device_ops camss_media_ops = { static int camss_configure_pd(struct camss *camss) { struct device *dev = camss->dev; - int i; int ret; camss->genpd_num = of_count_phandle_with_args(dev->of_node, @@ -1506,45 +1505,36 @@ 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; - - 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 the + * 'top' power-domain. + */ + if (camss->genpd_num <= camss->res->vfe_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 +1556,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]); + if (camss->genpd_link) + device_link_del(camss->genpd_link); + + dev_pm_domain_detach(camss->genpd, true); - for (i = 0; i < camss->genpd_num; i++) - dev_pm_domain_detach(camss->genpd[i], true); + camss_genpd_subdevice_cleanup(camss); } /* 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; From patchwork Wed Nov 1 10:54:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 160518 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:abcd:0:b0:403:3b70:6f57 with SMTP id f13csp326489vqx; Wed, 1 Nov 2023 03:56:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFF7ezWlgYys+uT7IQARpX0bxxMiGDA888oCjZDpWCoQmjbV0/p6VNj7gzKsNm0hqHZGqqL X-Received: by 2002:a9d:6d8a:0:b0:6c6:1e39:e5c6 with SMTP id x10-20020a9d6d8a000000b006c61e39e5c6mr14404206otp.36.1698836209228; Wed, 01 Nov 2023 03:56:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698836209; cv=none; d=google.com; s=arc-20160816; b=BNnvY23fJF4qTJwhvwVj60rVT4lVCSbxSUwFM1DK0y6TUR2+TkVguksT3idI8psuzA 1CMSbXrz1SSiT9qtaTS2xy1yXDk6H96zVV0dJkpDVoZW8DWeqf8SW5Amiu1DzKDFoA56 n9uVW8lvnkG3Jmnvqmh3vSvqbu8o+1oeyYKj3gHRx43ZhpWjdSMltqOYOlOiN1LNTWkB PjimPpJpMPPp1nDNiY39Ykx1MOqYjKoxYRdsDZYtRR+3ilxyCg6C2kaNAIyCpT4c4u3Y IBjQnhvgKkiyBsrqq8Yc+DUcwrd4rO2fsbfvjvPKD114YtdSf3ptsbwaJrrw9BCdnKvs nwnA== 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=Tv2R/vFkv5aw1eD9VUmJogdPL3QNVlhIxcpLogPWtuI=; fh=i6Xq0IxPe+xfIAGis/HEEizm5QSFvbEDbWBJK8514h0=; b=v/Aq6E5O5G02Ohk8Tt6R3w9qYHrTOsrZWt6UE91LxpPOv4lFtC+J6LrGlUZo4ufkGl yQL6xMxREoQgaEgCQ3gQ14jQ2XS8sIRNOC/MmdGO2I4O6W8/sKh/j2pa3OBsw+hFsAFF dqhXzCxcRH6C9UMFvVpNnzTLpOiasM5zseR+81ofocmvDMNMq+HrIm7lFkkjeBUFCcZT th50+3nMXTWMxofGUPOeEM2f1CJ2QJLtGDpjgcuNEfhJqMfCFex16ptQPTIf3YRNIRN4 hbSVHrgD7qb2LDAmXqp5f2MlaTZzpo/UuBhlNJkmw59AIoo63HS+D3zqlfjhdJ81JkWy TDzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hJ6AUxL3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id r32-20020a63fc60000000b005ac8d44bad5si2751033pgk.7.2023.11.01.03.56.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 03:56:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hJ6AUxL3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 506AE8059E6C; Wed, 1 Nov 2023 03:56:07 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233861AbjKAK4B (ORCPT + 35 others); Wed, 1 Nov 2023 06:56:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234165AbjKAKzh (ORCPT ); Wed, 1 Nov 2023 06:55:37 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15D5511A for ; Wed, 1 Nov 2023 03:55:30 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-40907b82ab9so4017865e9.1 for ; Wed, 01 Nov 2023 03:55:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698836128; x=1699440928; 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=Tv2R/vFkv5aw1eD9VUmJogdPL3QNVlhIxcpLogPWtuI=; b=hJ6AUxL3rDPnxeV5To2ClhRPDOTkhpuYNfQY9EY0cV3sIasdFcCtlnDgiF7xD9fWrI tomu9Y8UkPGRl5uRDzQMscE8zPo0G+MktW5ielPlLeoN0TMSGPiPoY7cKGpjytXGzjWF 0hsrkY/UZiSucVsrOoAfLknkKu/CJvNU4z7xJ1p79VEm1LSOlfLPiVQwaz4GEBrzNlNL upcnCcdTzIb8eioOyRBMdmt4T4KFevOE3ZgH46/+tXSxH4pCBnwpfXnaB4VqpPRX1uGk xI2z/v8aAvanTs+Cs+19XYd3TovHYdEqRkG1PXJI65/lCPJY7ECz5MklhlhH2mXA2gm9 0c2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698836128; x=1699440928; 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=Tv2R/vFkv5aw1eD9VUmJogdPL3QNVlhIxcpLogPWtuI=; b=ZflR5CT2zg6Zblbb4Zs8XouWY7iF1l3uMZ8tLjaoXPps8ydFI6kSbVmt3A1cDsut8D OayaiL4OWnfy5MHOEiwHywAxZXqeqtaGA86gZsiamboXm6PRTGfqPtn6Jwim69XuW1cI yyP+GM2MzN0tlIONTicSbwCWpn1MdIj8EfXH1IQRTPNRoADzPMlq8XaO8tFpF1cAzZoB 7T8MwTPJMDuIOrNxSVjzfgxicRi66kZkdghOl6HkpTxgGEl5QK83whoTu0OMpnUxnwXy r1UGIK9HxO9P3jw8aLiGqy0wRzE7yxOxYHSyW74adUkQxyBn6kC5qQSHU9YYLew2VbNM QHQA== X-Gm-Message-State: AOJu0YwH4iqNayqHrcUiNUcXhmAR7MWmvpH1Qwszs5nKDaYMJKjPTsHW O6QxkRj+eJUcDjMy7uFVG7Dxfg== X-Received: by 2002:a5d:5847:0:b0:32f:7a22:8b42 with SMTP id i7-20020a5d5847000000b0032f7a228b42mr2576503wrf.23.1698836128599; Wed, 01 Nov 2023 03:55:28 -0700 (PDT) Received: from [127.0.0.1] ([37.228.218.3]) by smtp.gmail.com with ESMTPSA id z2-20020a5d6542000000b0032d09f7a713sm3830948wrv.18.2023.11.01.03.55.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 03:55:28 -0700 (PDT) From: Bryan O'Donoghue Date: Wed, 01 Nov 2023 10:54:35 +0000 Subject: [PATCH v3 5/5] media: qcom: camss: Add support for named power-domains MIME-Version: 1.0 Message-Id: <20231101-b4-camss-named-power-domains-v3-5-bbdf5f22462a@linaro.org> References: <20231101-b4-camss-named-power-domains-v3-0-bbdf5f22462a@linaro.org> In-Reply-To: <20231101-b4-camss-named-power-domains-v3-0-bbdf5f22462a@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 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=ham 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]); Wed, 01 Nov 2023 03:56:07 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781358876988056597 X-GMAIL-MSGID: 1781358876988056597 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. 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 defff24f07ce3..123e5ead7602d 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)) { ret = PTR_ERR(vfe->genpd); diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c index 415164bf00402..83c0c28a8c953 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -1514,12 +1514,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); 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;