From patchwork Thu Oct 26 15:50:38 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: 158601 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp774875vqb; Thu, 26 Oct 2023 08:51:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEY++AeSAUBgRZWjHaY+gaGEwzOxdLEWuQK6MnmxYGNixlIdZ8Bk71BkCWJyiQXA3Pm5Trj X-Received: by 2002:a9d:4d93:0:b0:6ce:26ba:324 with SMTP id u19-20020a9d4d93000000b006ce26ba0324mr16944947otk.15.1698335509275; Thu, 26 Oct 2023 08:51:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698335509; cv=none; d=google.com; s=arc-20160816; b=c9Om5fEGiwb2S27t4Jn3WgBPGoJBozAXuC1qqps9VJvRVbr9xTfaTxwlwJXfz4igzz 8dD1AsPwo2YeypaNpYw2VCi0Qy7RwcDefO4+Sj+Zz3wFMtj/ysswZBfiv/AnmYI4cvu1 UCkkGfaH+K4fd2jBUCt8RC7rwJhg5eAqKaoEQf0GFxDIKGlof5mPVKdP4J9D5xK0ZvVY TxLlGzwV2JwUXrb4fFgWyUGNy0Cg8EsSf/YAFsnlKr3TI+d20FA/0ghbRu/buejkXV+p 19LTpzVSgMB82QmrlnsNaEbjROaTOhnQy10ZXf8jecqjP6sQM/Ld6YJ4GVRihAsOznis 4OZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=I4eTVZcrGQlOPNYTx/N/Kit5wvfICmRRRsyBtCJrWm8=; fh=EDIpuMICZLR0WVxMad9x0w3NcC1c7tvexkVv5l4gf40=; b=zsfyBllsCj77/cN4pQX/qV1Y1dZs7qaRWswWNC1YlfERpfUuddrQ4/+KSguq08ueIy 83TW3keflzCPXeoh9qXnOYgSYxFzQEEe95i2z9vztYUArD4yJqqj7pyP2G9BkVseEEgh 9L6r/wjNr293JwjSSO2xBYNAYNPXCm76LkKBf2x9yLH2N+XCYf/Lh0H7vdaTlYfVt2BK l551JQqGGPgYyoittmno8cEzJGMKeeRHXQMw2TCMhFGff3SeIqFvo0EMRpGqHuu2aihE qYPJml47Hqpw0BEhHypPWtNpfWeIUTdoxzCzZa3H1L0aLMdGy/t36sUaEwrsIVjvWZZK udTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Xj6EAYZX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id d68-20020a0df447000000b00583d1c30b04si13758388ywf.550.2023.10.26.08.51.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 08:51:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Xj6EAYZX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id 6A844809C121; Thu, 26 Oct 2023 08:51:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345516AbjJZPu4 (ORCPT + 26 others); Thu, 26 Oct 2023 11:50:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345487AbjJZPuv (ORCPT ); Thu, 26 Oct 2023 11:50:51 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83B1F1AA for ; Thu, 26 Oct 2023 08:50:48 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-507cee17b00so1560447e87.2 for ; Thu, 26 Oct 2023 08:50:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698335446; x=1698940246; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=I4eTVZcrGQlOPNYTx/N/Kit5wvfICmRRRsyBtCJrWm8=; b=Xj6EAYZXmi5cT5Kx6cgnF6v2izByFzNGMYFGIYmNeMidy9MesNJv50iH4JWu8t3yTk IQJUoLICAxHqtvKvgVnmOC8ZEXS8PrVashDS2mq6Qk4l4nSh4hC5jKf5F9AeMX1b0wdg l5Pgs3a++tJb0yix+jSmeSRcuwFIrGE31YfpEx0kL4ChMI5xQil/glIekgyD5j0qhiya Lh9sSgRCSXyUcGuHZWTlamLe024JZzJhD/MDLiQa1mS0G4RAhu/L4d6TwFhIptozNhIO Jk/qZKvMKeGUmTFRYfjZD3Yojc+JOr0416l3NL3QwSPZ71BVIvN2pvgQwWtySEBQlYpR MoAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698335447; x=1698940247; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=I4eTVZcrGQlOPNYTx/N/Kit5wvfICmRRRsyBtCJrWm8=; b=UR8Cdhk36RK/IIBgsuyCVDL29FZaJKQ864Ya9T4xGWmoeiL/AnidT0Ams7fmlTLPq2 R8fQSbRuJ/rdccLQRnctsjS8jbZtLf/V0xdBX1ktO/YIuoKG8szoHr557Rq6P8mPhDMC 3bFw86vBRyP/tKL9byZleuy4qtcr2wbkNmuv1qXAQPCcA1pWstFG7N6wYDE0jhNLF3hD 1iOHbwar9Q3s9QqdJNSibMkU6dt6uOIpGI0fqGvX4Do1no4W8JCI9XUSA+9MUT4A7U9P apODbL8sH2EacejYVXlkK+zL6NbD2Vs/DI6hjJRCzsiQS8ddQG35dQI/qdt89ci+80nX VNnQ== X-Gm-Message-State: AOJu0Yxj0yyTDemkS1DTEEw9WJt2OT/4BvarUrxqrtyU0IorE8JqMD8H QAG9RS5ohqA3V2VNAr19mcmE2w== X-Received: by 2002:a05:6512:3da8:b0:508:11c3:c8d9 with SMTP id k40-20020a0565123da800b0050811c3c8d9mr6637976lfv.52.1698335446670; Thu, 26 Oct 2023 08:50:46 -0700 (PDT) Received: from sagittarius-a.nxsw.local ([37.228.218.3]) by smtp.gmail.com with ESMTPSA id m28-20020a05600c3b1c00b003feae747ff2sm2938289wms.35.2023.10.26.08.50.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 08:50:46 -0700 (PDT) From: Bryan O'Donoghue To: hverkuil-cisco@xs4all.nl, laurent.pinchart@ideasonboard.com, rfoss@kernel.org, todor.too@gmail.com, andersson@kernel.org, konrad.dybcio@linaro.org, mchehab@kernel.org Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, bryan.odonoghue@linaro.org Subject: [PATCH v2 1/5] media: qcom: camss: Flag which VFEs require a power-domain Date: Thu, 26 Oct 2023 16:50:38 +0100 Message-ID: <20231026155042.551731-2-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231026155042.551731-1-bryan.odonoghue@linaro.org> References: <20231026155042.551731-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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]); Thu, 26 Oct 2023 08:51:34 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780833854873508336 X-GMAIL-MSGID: 1780833854873508336 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. Add the flag and populate the resources. Subsequent patches will disjunct on the bool. Signed-off-by: Bryan O'Donoghue Reviewed-by: Konrad Dybcio --- 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 Thu Oct 26 15:50:39 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: 158602 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp774893vqb; Thu, 26 Oct 2023 08:51:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGrD+D9lHST1eChEUYk/eAip9ibkHN14tk/44AWfn5H1uhge9j+BQQW4Ahv+JVjXH3Vp1fI X-Received: by 2002:a05:6808:291:b0:3a5:a78b:f773 with SMTP id z17-20020a056808029100b003a5a78bf773mr19925808oic.6.1698335511169; Thu, 26 Oct 2023 08:51:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698335511; cv=none; d=google.com; s=arc-20160816; b=Tj3+gL5K3LiClqLESNXTtLDYQe9/rt7oy2CJEZA/vIVK1apRMigoh65NWFnXnEk+XG b0DyeC1KnVE/XSdm8ee0LtPgF35top8cAlX61U7Kljy1w+feGd040jtBNPKPBpzV44Wm KNAM/x3XCaCvYNm7gLlhmoN+/0Xjpp7D5xhobw3qzl4MEvMoh9uwk7d1Y2kJYyFYdlI8 NM6T5XhRBZWpVie3jAVfyN9NDr3b+gKZ/qA2fD0LF54J0Vf80i8LE2oeak3I6FJT+LhV fTYNpgcbfUY2WdVoGaiLExdhssc8vpXcktxKdQBfqkR+oJdFC+4izCor4kPVIQvj4BII PzTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4YU00avEttChWoKTeHCnTvaWaEc1lCuq+WqQjs5hraA=; fh=EDIpuMICZLR0WVxMad9x0w3NcC1c7tvexkVv5l4gf40=; b=NmlIjTDw4SRPh15/fA1dV0Dodu6Mzn5Z1fIP7//E4WHS/6VWKtYEv9RmKFIYpgqKca KLY3eS5gKu+m88aLsiR6PPiCgCOJ4SxJTNp0MNHDgFyXEHcPFtblIJBs0W/dQpQxpWnp hi65OOEVHrzmZYvBapbVuFxoWma/d79GTUtkVO1Hicok+nRfHZ2GFFkCKjVYS38j3TH/ zClHC0Q+gNytsKrM7m+IcgZnwTZ6gq2Z3/aRn0qYE6ZcFScOQlPuKo0Uq/5pipz4vHNS vFpAaiPiM6grt0CasXNJypxqhSkWwLeP2GzTwuE7i6yJX2pE8sb79fDv3zVWIBUwxxXV F8Sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fsGsAYjw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id d31-20020a25361f000000b00d9a5221821bsi6542258yba.498.2023.10.26.08.51.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 08:51:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fsGsAYjw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id 94D3F80ECFBC; Thu, 26 Oct 2023 08:51:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345522AbjJZPvC (ORCPT + 26 others); Thu, 26 Oct 2023 11:51:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345491AbjJZPuw (ORCPT ); Thu, 26 Oct 2023 11:50:52 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B91C1AE for ; Thu, 26 Oct 2023 08:50:49 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4083740f92dso8654995e9.3 for ; Thu, 26 Oct 2023 08:50:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698335448; x=1698940248; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4YU00avEttChWoKTeHCnTvaWaEc1lCuq+WqQjs5hraA=; b=fsGsAYjw+UfsJK6wpUtA/VquQcFbKgsFkstuZW+7Qi9HutVg01IsTgTKiKNOy4OiVi JWAUd4f7+lIFzo+fMyoY+YkAp9uAvZjlcBFNkyYPxxRJa94gjiwQMUXpfL/WTMUjlniz KnPAv7L9jq9TI/P+AA9Bs5mRXvEuCL3A+EAZFG4ZkT4aoz4CxushTby7y36D6uahZhwl P1G/5OpPj4EUvHrrSyUOp9uzWzdiaEMxdHkschh8KyvD7g5XJKuLc95F4zEVwA1JuhDh bv0OP/M6a6wDPfBW47VzkGc5wQJFLVXD1Ya/v4v9APWgCdHlTO2OtpsTuqC152CDjgbA xZrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698335448; x=1698940248; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4YU00avEttChWoKTeHCnTvaWaEc1lCuq+WqQjs5hraA=; b=sMZweAeEcxx/VJFByzXjl6oyZtA82R69rso6QPfeHnrJN4ZJCMIwZvT/OxxrhwWj0e 6rVcDu0eotiXe7j25yCLJFrK73YuJ47EzQ4XbCSLi2Foyy8JDxpo+J+4L1yuPeqQOXmF UQh+Z93c0a68hLuKgchZJATD8E5EOrGn4zbKcA6ItM/T4AaVXsuOzfb3MWY+K0Yp7yZr sw/WGSxiTV0qcUbWy1XqwFNRUNHDfRusFfR+vAtvy880Aqg0FAH3QDz3+s2ZtemxtWlr dRMT8qLhP2cD2Dh4XUNTeDd0m0/Vs06lYOv+pxSOy3+b7xFmj2e1QYiE0rC0LORJY9U0 IxHA== X-Gm-Message-State: AOJu0YwaAUaP1b6w0ezBc+hOW3XxZfUhO1tXWyqDXkBbexUcX0fpbfBt 3V3L96C1x0RAOpvjnt2IxLX8kw== X-Received: by 2002:a05:600c:1c93:b0:408:3c8a:65ec with SMTP id k19-20020a05600c1c9300b004083c8a65ecmr189703wms.8.1698335447649; Thu, 26 Oct 2023 08:50:47 -0700 (PDT) Received: from sagittarius-a.nxsw.local ([37.228.218.3]) by smtp.gmail.com with ESMTPSA id m28-20020a05600c3b1c00b003feae747ff2sm2938289wms.35.2023.10.26.08.50.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 08:50:47 -0700 (PDT) From: Bryan O'Donoghue To: hverkuil-cisco@xs4all.nl, laurent.pinchart@ideasonboard.com, rfoss@kernel.org, todor.too@gmail.com, andersson@kernel.org, konrad.dybcio@linaro.org, mchehab@kernel.org Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, bryan.odonoghue@linaro.org Subject: [PATCH v2 2/5] media: qcom: camss: Convert to per-VFE pointer for power-domain linkages Date: Thu, 26 Oct 2023 16:50:39 +0100 Message-ID: <20231026155042.551731-3-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231026155042.551731-1-bryan.odonoghue@linaro.org> References: <20231026155042.551731-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.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 (howler.vger.email [0.0.0.0]); Thu, 26 Oct 2023 08:51:39 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780833857337692218 X-GMAIL-MSGID: 1780833857337692218 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. Signed-off-by: Bryan O'Donoghue Reviewed-by: Konrad Dybcio --- 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 Thu Oct 26 15:50:40 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: 158600 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp774841vqb; Thu, 26 Oct 2023 08:51:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHT/w8SKGlnuXBIMZD1sdshZMtvbjRsVJZfQdeMIGelYInulXknexE4OjHqsEDVKcsXovrM X-Received: by 2002:a05:690c:81:b0:5a8:dd5f:dbf with SMTP id be1-20020a05690c008100b005a8dd5f0dbfmr22252981ywb.34.1698335504955; Thu, 26 Oct 2023 08:51:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698335504; cv=none; d=google.com; s=arc-20160816; b=Fwzq+hT2W1LRbs6l3b2lsgbHH6NXB6FzsBoDYIU498qRdXOQz6KuUKOV56XHQiRpjM Qf4+8FyArZGwLa2G6bkfyonSKN2r5ruu+cctQZxDOD0/04h7gYcYzlsKEenhpjoikpxH /Mt2RFnRNgj176ClilpKNCrM0FxkQsVlETLH4FuZSZiXH5NRbvyy7C9u3Vo65zsiEo4N MSFFFML34yptv3YcQK4t2d+dAH+SabJabgKZzBBeApChCt5m8yLGvM4eAf1hdsD09qsK i5nskp8HaKniF7u39lGv28iFrgcWfPl1qscwwTdD/ikXciDhcTo53WiZPUl9YD80U2gx U1mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5tg3pNzu9GGZkIp555oWCbdMkPug26qMvCCiasLz7nk=; fh=EDIpuMICZLR0WVxMad9x0w3NcC1c7tvexkVv5l4gf40=; b=xXEnOxLJ2QpNrM1blT0zjv4iejEF4dCSnL75fKlm8a4DjGE92fCADD5lwUEwmDbYx7 1rmmh6dc+0dMi+q+GU+z8GICimGkoLXsV64NtACpIPivvTYzSystu0wIE87+nLAnXAsr CG0Ejkmy66GYmTF4h1KthQCMusdOvtJFHYu8STIWYTanKpKPxYAxiAHhoFApdi4cHYv0 exRDpmw6i03lBD95Ma5EuinXxjBfkVPP9f6YU2QkeNJt0lDjfbiAGmOGeWs4oetUAzJ/ im7UZ0BWVwpF31pCfoJhAq8k+ugmn20hTJ7BvpCKP95xHc0y5vU/M6C/d4Vuyc7SxbEq J9Ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=D6b+9IQx; 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 w6-20020a814906000000b0059f7cd152besi14973434ywa.90.2023.10.26.08.51.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 08:51:44 -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=D6b+9IQx; 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 8FA24804C66A; Thu, 26 Oct 2023 08:51:39 -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 S1345491AbjJZPvE (ORCPT + 26 others); Thu, 26 Oct 2023 11:51:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345502AbjJZPuy (ORCPT ); Thu, 26 Oct 2023 11:50:54 -0400 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7D18196 for ; Thu, 26 Oct 2023 08:50:50 -0700 (PDT) Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-2c509f2c46cso15057261fa.1 for ; Thu, 26 Oct 2023 08:50:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698335449; x=1698940249; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5tg3pNzu9GGZkIp555oWCbdMkPug26qMvCCiasLz7nk=; b=D6b+9IQxumT7r94I2f1HW5dCZkH43MY/cTB9kQva4NbfQbvlgvu3hyTr1Na7VZBgZn mkfO3St7oI0x3XD0f88uwpndcMNGtaKWc0qEz3ivutdTchBn9ldMiCBrmfe5hhgxHea/ tFdlvkcBHMpEA63fZ9Ou/Ff/xaPspvB86KPF24fal5NYZK0MHvnAwfoqGyjkRLfDp7hT icOqNdMOkT0EgTGabuZPIk07DaULr0uqRjkjl9O1E4FZpipMhjN+YOQL7eiL04N6j3oG aLZ12WscNJWji8anKj2brpOssojjMvdOsmYqgdoMBtPRCXzLBdcrQW8/OKZrVCvhdktC zLsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698335449; x=1698940249; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5tg3pNzu9GGZkIp555oWCbdMkPug26qMvCCiasLz7nk=; b=UG7pBh8YiNNWr4CUTG4TNQqtzQz6CQjfuog9+WmqlSdiEQwN80fjxfoFnpJCyXpDYv 6zoY+xHObjs8AqQKFzbvLt8OFYxK76/mjLL+7st5mLFx5g/xQscJ/pDVYctvuE+GANHk 5pPQzXnNL55BobSkncMKBteeikiuPAlggeGAmJ6p1O8YTqDtiY5qM6cPPgSFy6v6iTrr AVENzUVikaIFnTjUcvRqPFETDsH81DE9+j7YwF487tCedm3fLpsty+9VGhypz4D9GHSH Nne2D69UHcVKJl1DQv8v/VTErsQE2B1kWbJy/e/vZ19JaEQr/FoKRMjHlVac8t9o40e9 caOg== X-Gm-Message-State: AOJu0YyAK/fMTMwoTfHDTIrc8lpGBbz1+xHYqx1xdJ86MyL7cgvKGapq Ka5QaSSIbgoMEnReZBICYM2BoA== X-Received: by 2002:a05:651c:1038:b0:2c5:1bd9:f95c with SMTP id w24-20020a05651c103800b002c51bd9f95cmr12484896ljm.53.1698335448987; Thu, 26 Oct 2023 08:50:48 -0700 (PDT) Received: from sagittarius-a.nxsw.local ([37.228.218.3]) by smtp.gmail.com with ESMTPSA id m28-20020a05600c3b1c00b003feae747ff2sm2938289wms.35.2023.10.26.08.50.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 08:50:48 -0700 (PDT) From: Bryan O'Donoghue To: hverkuil-cisco@xs4all.nl, laurent.pinchart@ideasonboard.com, rfoss@kernel.org, todor.too@gmail.com, andersson@kernel.org, konrad.dybcio@linaro.org, mchehab@kernel.org Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, bryan.odonoghue@linaro.org Subject: [PATCH v2 3/5] media: qcom: camss: Use common VFE pm_domain_on/pm_domain_off where applicable Date: Thu, 26 Oct 2023 16:50:40 +0100 Message-ID: <20231026155042.551731-4-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231026155042.551731-1-bryan.odonoghue@linaro.org> References: <20231026155042.551731-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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]); Thu, 26 Oct 2023 08:51:39 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780833850423967199 X-GMAIL-MSGID: 1780833850423967199 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 Signed-off-by: Bryan O'Donoghue --- .../media/platform/qcom/camss/camss-vfe-170.c | 35 ------------------- .../media/platform/qcom/camss/camss-vfe-4-1.c | 8 ++--- .../media/platform/qcom/camss/camss-vfe-4-7.c | 31 ---------------- .../media/platform/qcom/camss/camss-vfe-4-8.c | 28 --------------- .../media/platform/qcom/camss/camss-vfe-480.c | 35 ------------------- drivers/media/platform/qcom/camss/camss-vfe.c | 33 +++++++++++++++++ drivers/media/platform/qcom/camss/camss-vfe.h | 12 +++++++ 7 files changed, 49 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..d6799408a8c78 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.c +++ b/drivers/media/platform/qcom/camss/camss-vfe.c @@ -474,6 +474,39 @@ 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_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 Thu Oct 26 15:50:41 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: 158599 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp774767vqb; Thu, 26 Oct 2023 08:51:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHZOjXFXmHTrWBVH/SHptk+3JzkY0yey8d1lMTNvtPRLy4D0W1zAA935lnRVnGxOqexIH51 X-Received: by 2002:a05:6870:4d09:b0:1e9:d261:cc84 with SMTP id pn9-20020a0568704d0900b001e9d261cc84mr21390703oab.19.1698335498341; Thu, 26 Oct 2023 08:51:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698335498; cv=none; d=google.com; s=arc-20160816; b=ZGLp9j28WFpibJ9ezjWREjmbxWoiddyDtDslJjb2Lz0wSqmteQS+1u9Ldmrqe03a/c KzRciRGFeT4jeXs0isun7XyPxSsGSSTgcJMOhDQn9yJu5nUuZ3V8EQKIlXAUn+4Yi1eK QD/3zWc/ENXO97qlhNNTXoPvjPG16OpnHuSmUQ5Gt1ZzJHoKP9dyeIMMUwSjLTVtrwTO PB+ScePNr34hdOCLdC7kDy6RWxhYCuvFZWOASQ8bn44hOgR+ugASATfGcN3QkckGEFpb ZqIdABfcSrk1slkOcfarUqdTPr/nbDIMxJys7yoN5ohP99QzoAIiRdPCplcqcD36zZZw HZ/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9BGTy9+RBMTpz8R8glCyLf29usc0ebnkTXjb8EDj74U=; fh=EDIpuMICZLR0WVxMad9x0w3NcC1c7tvexkVv5l4gf40=; b=NMzx1BLzYnFJOrAiswakdtRxkJwUC7ROmYkGAJrVvw02vqXva68xTpOJzohpfYbWdp yi+Wy3H51xdCRWSacaQGgZSO1TFdnEZEAHN5cTFJ4r0BemuW8ER1uOFUBCUlGUuYH88I c1H81nTefcg/QwmeuTtGPMTY97CotLPB3sROiFy00a8CFTWOrfYDW5MNd/14x4wywR/m QLl4mrzMOeeEzT7XOkdezCbcnOkT3hbjMHD8J9JK1+d8vlA7K7Q66EITlOPeMNKcL7TU EoK64a5zRpIvW08F+x9f7+t23j9JTsrBE7cAZRQWGF2Ah9gQCRDLZWPI0wIFGI4R34fe tO6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PEOZ7tZh; 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 b187-20020a2534c4000000b00da0c6adef1esi887407yba.421.2023.10.26.08.51.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 08:51:38 -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=PEOZ7tZh; 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 0D93480DE606; Thu, 26 Oct 2023 08:51:33 -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 S1345554AbjJZPvH (ORCPT + 26 others); Thu, 26 Oct 2023 11:51:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345507AbjJZPuz (ORCPT ); Thu, 26 Oct 2023 11:50:55 -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 3BC5E1AB for ; Thu, 26 Oct 2023 08:50:52 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-40839652b97so7991735e9.3 for ; Thu, 26 Oct 2023 08:50:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698335450; x=1698940250; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9BGTy9+RBMTpz8R8glCyLf29usc0ebnkTXjb8EDj74U=; b=PEOZ7tZhFftt/fLeEaLjCSVqOMs5D4/CB3wI2xlqapPq9cEzkshIQDXwqzJ+7PFVrC pjRJ9f3/yeFY7Q3CKOO00xfXijWRS31PPoMybZeTvF50AayrUnzZx684aYg88Ms15wE3 EqkZpP8s2Pxst/DK6gKi+liqhS6103Mqgp0IerzFAPBp7sUtzZsiJ8GR/eHhx/6FN6Tf rggCwaTXWO8Dg9nHhrZ6KT4I2Dm/lEEjN/ospU/HMdM23IAQzBb/VvDn/YvbA2JZTVP1 G4ihyJbAJMxlOSsS7dzkoNO1n6w4VZ2oX2937qCkFu4QBGIRWxWNJoQvjKNtGOkcn+wP 8zFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698335450; x=1698940250; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9BGTy9+RBMTpz8R8glCyLf29usc0ebnkTXjb8EDj74U=; b=JgZNl1oX9yp2Ia0/ObC0syV+ZcDulVil+ZUSl1nCJCZbsiYLxQBdC3ptrs/9l6Bx1q UWU5m7Y0+Twj6fnH+mLzTZiKWduCy7xzBZcWh7InofrpxaKuR3PvqneOhoazo6x4K1fi fF0YPRyUKEK4mc0xhmWVEgW0KvmNbMegKzRBuRVF0JG/yrYZeJxIQpMtBXx2brUkznds vQHfCn1AT0w3z4QYTBRXklV900V9hcnEe4mLjx2yQEKYzdYpF48CjZK1y+Aifs/8pZb8 URfXHYgkptA2D4IuL7Y/ZFKfSSvEe/JYLwZcriHKYatXIroKNOYvB+kEbHvWisy9KNeO shOQ== X-Gm-Message-State: AOJu0Yx8XfuzL+o/60HOSMlNMRuB57TtdS9dt0zFHT0xDkLQMrDRgJcT k513M7xpPeRhOY0XyfbwJrPI7w== X-Received: by 2002:a05:600c:524a:b0:407:8459:2ef9 with SMTP id fc10-20020a05600c524a00b0040784592ef9mr166240wmb.21.1698335450474; Thu, 26 Oct 2023 08:50:50 -0700 (PDT) Received: from sagittarius-a.nxsw.local ([37.228.218.3]) by smtp.gmail.com with ESMTPSA id m28-20020a05600c3b1c00b003feae747ff2sm2938289wms.35.2023.10.26.08.50.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 08:50:49 -0700 (PDT) From: Bryan O'Donoghue To: hverkuil-cisco@xs4all.nl, laurent.pinchart@ideasonboard.com, rfoss@kernel.org, todor.too@gmail.com, andersson@kernel.org, konrad.dybcio@linaro.org, mchehab@kernel.org Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, bryan.odonoghue@linaro.org Subject: [PATCH v2 4/5] media: qcom: camss: Move VFE power-domain specifics into vfe.c Date: Thu, 26 Oct 2023 16:50:41 +0100 Message-ID: <20231026155042.551731-5-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231026155042.551731-1-bryan.odonoghue@linaro.org> References: <20231026155042.551731-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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]); Thu, 26 Oct 2023 08:51:33 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780833843517911930 X-GMAIL-MSGID: 1780833843517911930 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. Embeddeding 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. Signed-off-by: Bryan O'Donoghue --- drivers/media/platform/qcom/camss/camss-vfe.c | 23 ++++++- 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, 55 insertions(+), 37 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c index d6799408a8c78..ebd5da6ad3f2f 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 @@ -1380,8 +1381,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); @@ -1505,6 +1511,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); + + 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..03e955c7a7e4c 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 greather 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 Thu Oct 26 15:50:42 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: 158598 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp774736vqb; Thu, 26 Oct 2023 08:51:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFJktyLVJ6K6KDFa5P0mrjRff29wdnIU4gZxM4Bq6kEjXcv0Yrf/UwTa1IgX1ZQCSO8Cbil X-Received: by 2002:a81:65c2:0:b0:583:3c54:6d89 with SMTP id z185-20020a8165c2000000b005833c546d89mr17667801ywb.44.1698335495442; Thu, 26 Oct 2023 08:51:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698335495; cv=none; d=google.com; s=arc-20160816; b=uNUha3cbmqoRrlogDLecaTQOxsQUKpqdUxTtoUGYJ41K05JNb85pvevE6h9Mo3IErq K2coDHNBTY7Yq1Q6TkvPZ1Xr9Tr308s6+SfK4xPrTz0Nr5ovFXZnc/ikX/gAyyozE8zT S69WiLBqNT2Dhm4aM7nEDuGiIQzGHQPrOA5CXFbc3r4PCejnq8+qeY6mtwjqaxeYhcH0 4yqNHfwe/RYlyK7PqwuVV/xFQJvEW+o+8TWFmPiAsL9NlsNNM9gFAFIZBoBmykv0zRt4 NHrji0seUtJ+LlsHmvCOBFVsP2ibpxb9FYl177w9X7re8tDPs5zVAQwPDPEhxylP0OMn mKZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=o/0Zzd2h9fLzU2CXuGA1RcrpOhxB8m/Gh7+HlmkqAUw=; fh=EDIpuMICZLR0WVxMad9x0w3NcC1c7tvexkVv5l4gf40=; b=JB/LDWYKrSqLVwNUIPbU6EoVHVnNrdL+L4A2rGIzwEDXVfxOkDSnbjpyzH/s//0+q/ 3LJEUsbmX++2kCfoMTcEyF5YwS/MpZ1+97SGmCb+1/bwCD45zsrJJGn4Cqeg85Q/jhZl NSIZejXs0RCxYftCoY2nGaLvth9omIQSLeT9cj1MpiWoMHos/KZ3KRvQ1Ox7X4YAYk+j yFImyFjOVU0D29idD3sQn9X03gtx4aNuuCn8Pc3i1mV67+9CJCIvJHymwu40dC1exIDl 1EG+5gtNIc7UpW9wO4naRo/O9NSty22+g+huBNqdwo+dQjiBBilRfNMU5yWXzCJRtT8T zJpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NPXqt8Y6; 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 i65-20020a0df844000000b0055a8c5444f5si14324538ywf.558.2023.10.26.08.51.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 08:51:35 -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=NPXqt8Y6; 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 A0EA5813551D; Thu, 26 Oct 2023 08:51:29 -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 S1345562AbjJZPvL (ORCPT + 26 others); Thu, 26 Oct 2023 11:51:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345513AbjJZPu4 (ORCPT ); Thu, 26 Oct 2023 11:50:56 -0400 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93E731B2 for ; Thu, 26 Oct 2023 08:50:53 -0700 (PDT) Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2c503dbe50dso16034301fa.1 for ; Thu, 26 Oct 2023 08:50:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698335452; x=1698940252; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=o/0Zzd2h9fLzU2CXuGA1RcrpOhxB8m/Gh7+HlmkqAUw=; b=NPXqt8Y67wLU1OHLO4XkIQXhhYEM+klnvmqAdAnTlijYCKsUWZBcsGC0sG7TOqCzgI DKCfO8yhsGQaJsrrLBLBvFjA4/RngM/O7ndVcxMh3f3IEidKrJ5wMFO5JdRknUvHhgwW 9O+LXS19jYFJhIbmPkucmngjJUexNf9BvrpJRN9jsc+VNn15K1F3lL8LQz1pLaUV3AcG Rz9NfAyhu0y8njVBSvK0eYhKmZVUo67DQYoGnGF8m3N75dpplJjVdDTVP+676fgDhoP0 XWa67fNHhH2G3Vn+AtDaOF8XNmVIvaOlGZ2lBchzpP4sFUWkgMQYzzak7iYmzMrVhoT1 gdLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698335452; x=1698940252; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=o/0Zzd2h9fLzU2CXuGA1RcrpOhxB8m/Gh7+HlmkqAUw=; b=T83vA8R2zwLpnFdPTDYjLXr7/Veu2eLie6amUXqFIwFG7C0bq4MP+F1/JOICOMWyv9 b0MZ3Ns6a7eHbHO/BJJHQmBrcn8+Kgy2lpIRs56Ijm7XeZpVMAHZBC57Y8EGybgH8Gju ZjmkQ+HO68hcxZcdj4wPk91JPN+vKMlzLuDD0I63lNmsK2lGUslZjGYijMNM2lnJQdPu T6gobTnBSsw42Ab46P6ml1ZBdKo+XTd2MvZPx3sX+b11Z/jE1F9VPh7Z4VqTvA0wuD55 6661tt7c/chEiD4GiLA2EiLq1jwAZpzExGOd3fKc48ie063iaY7FeahGwYie4iBhutSf g7iw== X-Gm-Message-State: AOJu0YznYBD2gUubYhfPQ0ORGFjHySaTRHfn9Lrr7TiMpfoAKr6aQowO 66faX9EqpruopZIpBqAkufSbjQ== X-Received: by 2002:a05:651c:11ca:b0:2be:3ca8:bdc9 with SMTP id z10-20020a05651c11ca00b002be3ca8bdc9mr11517838ljo.49.1698335451864; Thu, 26 Oct 2023 08:50:51 -0700 (PDT) Received: from sagittarius-a.nxsw.local ([37.228.218.3]) by smtp.gmail.com with ESMTPSA id m28-20020a05600c3b1c00b003feae747ff2sm2938289wms.35.2023.10.26.08.50.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 08:50:51 -0700 (PDT) From: Bryan O'Donoghue To: hverkuil-cisco@xs4all.nl, laurent.pinchart@ideasonboard.com, rfoss@kernel.org, todor.too@gmail.com, andersson@kernel.org, konrad.dybcio@linaro.org, mchehab@kernel.org Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, bryan.odonoghue@linaro.org Subject: [PATCH v2 5/5] media: qcom: camss: Add support for named power-domains Date: Thu, 26 Oct 2023 16:50:42 +0100 Message-ID: <20231026155042.551731-6-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231026155042.551731-1-bryan.odonoghue@linaro.org> References: <20231026155042.551731-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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]); Thu, 26 Oct 2023 08:51:29 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780833840458936863 X-GMAIL-MSGID: 1780833840458936863 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 declration 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 ebd5da6ad3f2f..cb48723efd8a0 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.c +++ b/drivers/media/platform/qcom/camss/camss-vfe.c @@ -1381,7 +1381,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 03e955c7a7e4c..837bab28d40e2 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;