From patchwork Wed Jun 7 12:46:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13270657 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5976BC7EE23 for ; Wed, 7 Jun 2023 12:47:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tgxaWl11Uaj7eYnp1wbeJlbJr5TIJmMDaRMgeuPzYeQ=; b=zi01k8uSa5gLQ/ fjmUvpdxtEUWI0h4FTMam0IT0KOzGOG7S/dRHSph1YG6ofxweQAmQgY11xRWc8Qmtqj6mxyrAvIOL gBYsoQSL7qoKvPv0iCm6R94lFTkWvos4284BICIlei9jdR9IP1ls1lk2F1h3WKkFczF7I19UmsrXT 1ZnmlDMpQxwKZTTAZXoakv7fFoWpGP3LrBrFrCTW11ittx3LYbDanwmbLoe0Q8/BA8r313/rvj4QB GhHAQyJ59VUssFibK9FFV+t/2KJ2W1qDodiHeUlLqrRsDPLq45XNlSqmc1v2tQkXcO8HBOefzUlzg WfV6aaCpC1BK30SE5r2A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6sZ2-005wy7-2g; Wed, 07 Jun 2023 12:47:00 +0000 Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6sYz-005wwZ-0O for linux-arm-kernel@lists.infradead.org; Wed, 07 Jun 2023 12:46:58 +0000 Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-4f629ccb8ebso4280402e87.1 for ; Wed, 07 Jun 2023 05:46:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686142015; x=1688734015; 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=7vB+Qk0nYaVi1WO1VQhpSxexbfUtjHX4k0hpme2L5O4=; b=jdN7ywFxLhK8X6RqDS4B0s8KTU2HagkqP0C0NTT0QgNlR6AIqlo7dEneqXoIkus/O6 ulUaxe6WWr6nHZ0L3T+lJmhC2/MMKT8Zy9Qlb6ISkfrK5LHjgxi9Qjy3Ugv7xZ26br2W yTh1YC6M4SOSmTWfNgBiXl5/fL3sVISbT9cHRKUt1m5A5jgGW4o1mHxEyIenDhfabrwA eSlRbuWIt3DFLhXAGakzkKUQE/vcohN7w45XJ37kNYzCo8FXp7mIWb+P+1XJxHilF19t lLd0THGGA46ca1ZnR32tZ0LphWZmkJ/50icpq91ZS+1TehQBi8pg31CUgZr0qa7Tu5Ed OqIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686142015; x=1688734015; 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=7vB+Qk0nYaVi1WO1VQhpSxexbfUtjHX4k0hpme2L5O4=; b=gGp3ref3S5b8Vs1vP4Ua+R5eV+B8ufjuWsex9cV+3+KsCOgI5BZmnPrQL1clqw4Z1q cHJQwuMxZi04WyxbmIZXNQl5GTH5BnPR0vjMjjacr51nO9sCLT56leLNWuIj23LlgpRj BoAENu3czWWlZuenCma4cRHi2XcRkgxY8Y2+dOhwc8ryZ2U30WqnB0nFz+c9rwJ0lMkw tAMPsYdosmCvz1IOf6GHDtnk5CP/JL7fdEt52wHnzgRsYKLPkzbl6KnVpkejI+eLMzhF 8yZNX1yOnxNO9kApUW95jPIA/nY5UI/0ZagQ7tJwXldI75GdfsiDfSzO+XuwTIS/ymli izHA== X-Gm-Message-State: AC+VfDxRt3c5B1/Kadc0d1gXboXdEnzWunEIOI8kQSWFGiz8iLB0c4pI wInF0zTJcqipoYQb56ImeTl/ag== X-Google-Smtp-Source: ACHHUZ6D+C4NpbNoxCfgmPsZQ50kDR5QPp3pkMQp16akUThB15rGqbHji35tEVPV9lef0Imt0aUl7A== X-Received: by 2002:a19:f808:0:b0:4f1:4cdc:ec03 with SMTP id a8-20020a19f808000000b004f14cdcec03mr1867918lff.18.1686142015701; Wed, 07 Jun 2023 05:46:55 -0700 (PDT) Received: from uffe-tuxpro14.. (h-94-254-63-18.NA.cust.bahnhof.se. [94.254.63.18]) by smtp.gmail.com with ESMTPSA id z7-20020a19f707000000b004f4b3e9e0cesm1781708lfe.297.2023.06.07.05.46.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 05:46:55 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Cristian Marussi , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Nikunj Kela , Prasad Sodagudi , Alexandre Torgue , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 01/16] firmware: arm_scmi: Extend perf protocol ops to get number of domains Date: Wed, 7 Jun 2023 14:46:13 +0200 Message-Id: <20230607124628.157465-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230607124628.157465-1-ulf.hansson@linaro.org> References: <20230607124628.157465-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230607_054657_161353_FAFC029B X-CRM114-Status: GOOD ( 14.62 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Similar to other protocol ops, it's useful for an scmi module driver to get the number of supported performance domains, hence let's make this available by adding a new perf protocol callback. Note that, a user is being added from subsequent changes. Signed-off-by: Ulf Hansson --- drivers/firmware/arm_scmi/perf.c | 8 ++++++++ include/linux/scmi_protocol.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c index ecf5c4de851b..cf7f0de4d6db 100644 --- a/drivers/firmware/arm_scmi/perf.c +++ b/drivers/firmware/arm_scmi/perf.c @@ -333,6 +333,13 @@ scmi_perf_describe_levels_get(const struct scmi_protocol_handle *ph, u32 domain, return ret; } +static int scmi_perf_num_domains_get(const struct scmi_protocol_handle *ph) +{ + struct scmi_perf_info *pi = ph->get_priv(ph); + + return pi->num_domains; +} + static int scmi_perf_mb_limits_set(const struct scmi_protocol_handle *ph, u32 domain, u32 max_perf, u32 min_perf) { @@ -687,6 +694,7 @@ scmi_power_scale_get(const struct scmi_protocol_handle *ph) } static const struct scmi_perf_proto_ops perf_proto_ops = { + .num_domains_get = scmi_perf_num_domains_get, .limits_set = scmi_perf_limits_set, .limits_get = scmi_perf_limits_get, .level_set = scmi_perf_level_set, diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h index 0ce5746a4470..4e42274a68b7 100644 --- a/include/linux/scmi_protocol.h +++ b/include/linux/scmi_protocol.h @@ -101,6 +101,7 @@ struct scmi_clk_proto_ops { * struct scmi_perf_proto_ops - represents the various operations provided * by SCMI Performance Protocol * + * @num_domains_get: gets the number of supported performance domains * @limits_set: sets limits on the performance level of a domain * @limits_get: gets limits on the performance level of a domain * @level_set: sets the performance level of a domain @@ -120,6 +121,7 @@ struct scmi_clk_proto_ops { * or in some other (abstract) scale */ struct scmi_perf_proto_ops { + int (*num_domains_get)(const struct scmi_protocol_handle *ph); int (*limits_set)(const struct scmi_protocol_handle *ph, u32 domain, u32 max_perf, u32 min_perf); int (*limits_get)(const struct scmi_protocol_handle *ph, u32 domain, From patchwork Wed Jun 7 12:46:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13270658 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 29BCAC83005 for ; Wed, 7 Jun 2023 12:47:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=R7DXzX0gJbXaeKoPeCq/1IHXm3Yyx2yQo6c425k3Irw=; b=CdziYPRQRYbPc3 DBndzW1sufxZ437rhV9wiSNcFseORHatWE4OXJw/GhnpdrCm0BEwCSxJbCVQFkP4E5ti1aP040AuA vlQ+Obufj0v6dGLIlDOVFID2lk/bjTQmL8jzYavHiQpwY4zUk7YzJTpi0bXAXgS4qh5sVJ037ghrS Vuwkyuz2YtUfOQgi7+KVZvrcnosotXb3Agvp5Ypdcx/CzgKMYm/otHQLq338L8ucEERCeUnTdF9iP GcGKd4vyXUkMy4SbY4gvXzAyxVjIi0MMBiJ/tZWA5nCfeJVqx3RJ+dUbBlt+hsyaQ1GSozup7gwrM xcqhVmIdfLc0gD2Zamsg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6sZ7-005x0o-2a; Wed, 07 Jun 2023 12:47:05 +0000 Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6sZ1-005wxB-36 for linux-arm-kernel@lists.infradead.org; Wed, 07 Jun 2023 12:47:01 +0000 Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-4f642a24568so860564e87.2 for ; Wed, 07 Jun 2023 05:46:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686142017; x=1688734017; 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=ng6Pec8L+42si+rxccvj/qMWQEZv9/gf2sYIBEMRJp8=; b=KsUby3jo/lAKaMu0brunLhbLd8LBDe4b38OfBgFsNpozyVVbugfuGYblbeJnhwj8J5 wQPvwhO12mE2P9oURjZKZBmK8wy9ZrlPcBnxlPybOh5uGLEhL1iGLzAlf0CywkDIcxMc g7yIF7nGsrF5O1gtQxzUMT/RKHGWfxSFFMuHWcLlkzhVlxp6PNrja5TiRT8Q4AGhl2pb pqs7rYUXEvkYqew/9/vljDQDqc+dPJxmxCxcOux2i0gda+SrlLz1Yl/ekA8w0YivFSAa frBinLCoQqxdnlEKe8pacMYFvJGKwHSN+fcDiuN1XlOlO5UqPqEkefMGaRg1/U08600E zBXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686142017; x=1688734017; 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=ng6Pec8L+42si+rxccvj/qMWQEZv9/gf2sYIBEMRJp8=; b=XlM9w5AydLh9NXFAJHC7fz9bOVk3d4WfH8s69yDNVzbUHK6j3xeTfzewyF95mOXMfR 47z0360XVu3K0oBSFQnY4z3QwYTdQuMuxBFEu8t6ldmOxdoiefnIxp0SLjE8tp4EfA6z /56Yvp1KuMwJxcIz64wJEB5xb1hntyn6VJ4c5El9eU0ocObbqSEFfcT/ObCqzRyPPG/M w14KzdncZ0rHuMEMvvtMF5aokRD4ZizUzR7OEgbQn/ZYGtS53izqezOG5NnygqdCPoSw F76NKVD6SkmBCPYhtNjYm7nvgCJyO0rLVeDHbmiD1NrX5eH1R35DruJaA9+0lHSCRwIE zBqA== X-Gm-Message-State: AC+VfDwH3Lc2oJM3Im5bCvvQM+TZmpGMft8ijiYGV+4AV8aGOPTilHoL jUGnn9bjALUp9JDUpz7uyfORhA== X-Google-Smtp-Source: ACHHUZ5i6NoVxi/AqdIAXLDNJOeVXoGNxCPGbbzioHRt3xBQPRCtjgN7RkXDUIzR1O4KErWC/PtpFQ== X-Received: by 2002:ac2:514a:0:b0:4f2:5393:b7c with SMTP id q10-20020ac2514a000000b004f253930b7cmr1754364lfd.67.1686142016903; Wed, 07 Jun 2023 05:46:56 -0700 (PDT) Received: from uffe-tuxpro14.. (h-94-254-63-18.NA.cust.bahnhof.se. [94.254.63.18]) by smtp.gmail.com with ESMTPSA id z7-20020a19f707000000b004f4b3e9e0cesm1781708lfe.297.2023.06.07.05.46.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 05:46:56 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Cristian Marussi , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Nikunj Kela , Prasad Sodagudi , Alexandre Torgue , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 02/16] firmware: arm_scmi: Extend perf protocol ops to get the name of a domain Date: Wed, 7 Jun 2023 14:46:14 +0200 Message-Id: <20230607124628.157465-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230607124628.157465-1-ulf.hansson@linaro.org> References: <20230607124628.157465-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230607_054659_997533_3142930E X-CRM114-Status: GOOD ( 15.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Similar to other protocol ops, it's useful for an scmi module driver to get the name of a performance domain, hence let's make this available by adding a new perf protocol callback. Note that, a user is being added from subsequent changes. Signed-off-by: Ulf Hansson --- drivers/firmware/arm_scmi/perf.c | 10 ++++++++++ include/linux/scmi_protocol.h | 3 +++ 2 files changed, 13 insertions(+) diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c index cf7f0de4d6db..5a6ed42bfb55 100644 --- a/drivers/firmware/arm_scmi/perf.c +++ b/drivers/firmware/arm_scmi/perf.c @@ -340,6 +340,15 @@ static int scmi_perf_num_domains_get(const struct scmi_protocol_handle *ph) return pi->num_domains; } +static const char * +scmi_perf_name_get(const struct scmi_protocol_handle *ph, u32 domain) +{ + struct scmi_perf_info *pi = ph->get_priv(ph); + struct perf_dom_info *dom = pi->dom_info + domain; + + return dom->name; +} + static int scmi_perf_mb_limits_set(const struct scmi_protocol_handle *ph, u32 domain, u32 max_perf, u32 min_perf) { @@ -695,6 +704,7 @@ scmi_power_scale_get(const struct scmi_protocol_handle *ph) static const struct scmi_perf_proto_ops perf_proto_ops = { .num_domains_get = scmi_perf_num_domains_get, + .name_get = scmi_perf_name_get, .limits_set = scmi_perf_limits_set, .limits_get = scmi_perf_limits_get, .level_set = scmi_perf_level_set, diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h index 4e42274a68b7..07152a0baee3 100644 --- a/include/linux/scmi_protocol.h +++ b/include/linux/scmi_protocol.h @@ -102,6 +102,7 @@ struct scmi_clk_proto_ops { * by SCMI Performance Protocol * * @num_domains_get: gets the number of supported performance domains + * @name_get: gets the name of a performance domain * @limits_set: sets limits on the performance level of a domain * @limits_get: gets limits on the performance level of a domain * @level_set: sets the performance level of a domain @@ -122,6 +123,8 @@ struct scmi_clk_proto_ops { */ struct scmi_perf_proto_ops { int (*num_domains_get)(const struct scmi_protocol_handle *ph); + const char *(*name_get)(const struct scmi_protocol_handle *ph, + u32 domain); int (*limits_set)(const struct scmi_protocol_handle *ph, u32 domain, u32 max_perf, u32 min_perf); int (*limits_get)(const struct scmi_protocol_handle *ph, u32 domain, From patchwork Wed Jun 7 12:46:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13270659 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4696FC7EE29 for ; Wed, 7 Jun 2023 12:47:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WcBDurV5OEA2CgsuTBsM9g1/ssplSLANE8JCd1VXCD0=; b=mvlMuRz1e8hJe5 OX5ZV2Op1QKlXx2dtX44BD2VjQTmdFRMztTsPo65PkyEqJPyj+FeK1L2MUoNX1oCKW1HARCdaS7rQ 8RsuH+Q23FvRBzmxn5R5ciLaS/JKoEkIK+zo4Lst4KlDOZeUZNeJ1L7wNedsxmpo3JfpgErNgE8fn RinVThEkEZ0Lllx9NJ5dJKnR/LUw1X4WwUzkNWvd/JgMpYBVgjHNBBWlHI7HmD+R2dwS4zCCXBEkQ d0pHwScUY0CHyHVSbb9zjMH0je5gh5jc5Caw5LR3EYDlkDiZBvkf0MyTUCLz2y4r5qCkZkpgk6d15 excJNGZiFijS0IhOgVIw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6sZ7-005x09-0k; Wed, 07 Jun 2023 12:47:05 +0000 Received: from mail-lf1-x131.google.com ([2a00:1450:4864:20::131]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6sZ2-005wxN-0a for linux-arm-kernel@lists.infradead.org; Wed, 07 Jun 2023 12:47:01 +0000 Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-4f6148f9679so6776542e87.3 for ; Wed, 07 Jun 2023 05:46:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686142018; x=1688734018; 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=WT1gco3SixkDR/OziK3JosQemihuanLlknRMm9B1CS8=; b=i7i4/XQ2a6an/rgAvd96eO9/R9qJ16QRQxIAyqU//tp/p+4ptLtiF/GRaZWa8F5Ms8 sfsY51UWBXFbRQf4w/yJrgERsCiJWMaK3ue7f09ilyWHcp2ohVoj2lYvuyMIcEVYsdQD DWBt1K81UovndWUzvPlDTHJc9mv2CpWzMx3n5WkfF+v5nucFQYKe3BAEA66GMzCNLTjm 017he3Em1AkvxbdBWCXodi5shTK19rROLQgBLg7y2M1KGlzySoxIr3ZLMQL6wGHE7w5Z LDuN79gPUIUxoWxNSkmTSTLsFRvBDJ5+TaFVlNkrT0v6loTeyr74gxtncpR8MVYzI2gz 7gfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686142018; x=1688734018; 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=WT1gco3SixkDR/OziK3JosQemihuanLlknRMm9B1CS8=; b=RXs/8U7t/hjg5MjTbq2LDbwXu7DcGhCaNg/7O5kg+8xQiRvrC/0f1bVeRsdyHl7qtw 65jmF7EnuUUDVUTDZf9DyavXHFeLMYb1Vx2AiRYSEFignMIyl1mvuFY/iS21+vordG1K p2ms4GyIZKx9R6lagYn1Bh+aA4BjONnDTgVAwRY6wobrmqT0xMLJrIbjHzdHUmxhL1OI eDNPLmOVyQlGZyBJ0q1uU6/xLksJ7cP9xMQgcg4YqMkfjJ8iKXcZnPhC9jfxP0u7eqtz 5MnWHhEBSO1ZbIbjojuIT3UfViMqepNOdL6JEoPdecAD+hlzvb2zua2X5fS5gszzZyaU 4qug== X-Gm-Message-State: AC+VfDwCuUApVSUnGiXNAAye3WX0IzmVPRnG8NK9OdPgjk3c/96vdWvC IKvu3Lc3igSARxdFSmQ38Kgo9A== X-Google-Smtp-Source: ACHHUZ46s+CAtlnvjg/Pe4nAxStehloY+FWgmNeOggKS/r6wguvflGLIBjohnTHGZRMM8IbnFecjOw== X-Received: by 2002:a19:f806:0:b0:4ee:dafa:cb00 with SMTP id a6-20020a19f806000000b004eedafacb00mr2163873lff.60.1686142018272; Wed, 07 Jun 2023 05:46:58 -0700 (PDT) Received: from uffe-tuxpro14.. (h-94-254-63-18.NA.cust.bahnhof.se. [94.254.63.18]) by smtp.gmail.com with ESMTPSA id z7-20020a19f707000000b004f4b3e9e0cesm1781708lfe.297.2023.06.07.05.46.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 05:46:57 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Cristian Marussi , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Nikunj Kela , Prasad Sodagudi , Alexandre Torgue , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 03/16] firmware: arm_scmi: Extend perf protocol ops to inform of set level support Date: Wed, 7 Jun 2023 14:46:15 +0200 Message-Id: <20230607124628.157465-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230607124628.157465-1-ulf.hansson@linaro.org> References: <20230607124628.157465-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230607_054700_238387_EB3FB192 X-CRM114-Status: GOOD ( 14.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org As a subsequent change show, it's useful for an scmi module driver to know if a performance domain can support the set level operation, hence let's make this available by adding a new perf protocol callback. Signed-off-by: Ulf Hansson --- drivers/firmware/arm_scmi/perf.c | 10 ++++++++++ include/linux/scmi_protocol.h | 1 + 2 files changed, 11 insertions(+) diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c index 5a6ed42bfb55..216bcd68d549 100644 --- a/drivers/firmware/arm_scmi/perf.c +++ b/drivers/firmware/arm_scmi/perf.c @@ -440,6 +440,15 @@ static int scmi_perf_limits_get(const struct scmi_protocol_handle *ph, return scmi_perf_mb_limits_get(ph, domain, max_perf, min_perf); } +static bool +scmi_perf_can_level_set(const struct scmi_protocol_handle *ph, u32 domain) +{ + struct scmi_perf_info *pi = ph->get_priv(ph); + struct perf_dom_info *dom = pi->dom_info + domain; + + return dom->set_perf; +} + static int scmi_perf_mb_level_set(const struct scmi_protocol_handle *ph, u32 domain, u32 level, bool poll) { @@ -707,6 +716,7 @@ static const struct scmi_perf_proto_ops perf_proto_ops = { .name_get = scmi_perf_name_get, .limits_set = scmi_perf_limits_set, .limits_get = scmi_perf_limits_get, + .can_level_set = scmi_perf_can_level_set, .level_set = scmi_perf_level_set, .level_get = scmi_perf_level_get, .device_domain_id = scmi_dev_domain_id, diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h index 07152a0baee3..99c3e985c40f 100644 --- a/include/linux/scmi_protocol.h +++ b/include/linux/scmi_protocol.h @@ -129,6 +129,7 @@ struct scmi_perf_proto_ops { u32 max_perf, u32 min_perf); int (*limits_get)(const struct scmi_protocol_handle *ph, u32 domain, u32 *max_perf, u32 *min_perf); + bool (*can_level_set)(const struct scmi_protocol_handle *ph, u32 domain); int (*level_set)(const struct scmi_protocol_handle *ph, u32 domain, u32 level, bool poll); int (*level_get)(const struct scmi_protocol_handle *ph, u32 domain, From patchwork Wed Jun 7 12:46:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13270741 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 49AC3C77B7A for ; Wed, 7 Jun 2023 14:01:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jiVRHxMSO+d1y/OlvBMYDb+8okaVIHJmNz4I41CA7sQ=; b=zqkjunMhRB/HUs MKSwo3pld8wSlZd2/7BGvZoqhERMKJIlcsMeOsBUrWZ1ZRxul7W2YyTKV66zhCKUuaG1fsypB4+li XzJbA9oQ8Wx2iawr0hkLDlnvVGtHZOnTqMyGP8M5YWGblefe4R00Y4Qu6xNryKjAO8w6/i4QrVFkj 47eGy40R6yfZQPV5Z/4rJSDFLc3i3jg1DdAiPb8HgAMUQbBUVDOuiAOozmB+GNJ2YDqVuwk5nhi9e HexQG3rIg7VeJlzzXyM85YsVqvkWsAGgw5Pt1M7I2Nwmc1ZRIYA34qOy0DmSq9BHwX60HDct2pYpN 5lPgG4SG/v/AyxrYUZYQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6tiK-006B5D-2Y; Wed, 07 Jun 2023 14:00:40 +0000 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6sZ5-005wxc-26 for linux-arm-kernel@lists.infradead.org; Wed, 07 Jun 2023 12:47:05 +0000 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-4f642a24555so887795e87.3 for ; Wed, 07 Jun 2023 05:47:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686142019; x=1688734019; 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=eTRBYvWL0ZR20mIms3ANVdkUTRjCIM847wuOR+jiVEw=; b=UPwKH0tEs+HxkzN7zAPP+oUW7O3Xmnkqu2EdonIlsR674Hizqw1pKo+qRI2Mmh7Yed Sv/Uy5UbTUl0vMSbEcGSb4IxCPX6ZSLbvec24un6Ney98zSuBYLDoByxKlOQjWAWbFOf /snJha6Vbf8chEMZxOyL/kr1q/0V5dA2O40Ar4lSwdmL9xFzgY2HkLOe+u6g/6qCn3kI gR83/yyBTx9YDRCYDR8ifwlBqXwm3c92MF5CxgW2HIs+umZpzOTowepyZ2wx47Dd4m3C dIWu2rhEnDdEESg1zmIXaya7FVpf97fmb1tnJBsKiyC5Q+M3mgv4HqzGrOulkazf1kgj U5eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686142019; x=1688734019; 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=eTRBYvWL0ZR20mIms3ANVdkUTRjCIM847wuOR+jiVEw=; b=T7oCnk/ZHPa+Aptn+VFZ/hFksjsflYucLGYrfoHWvJgexBdPTgLv3+ebCw7IPXWcWo 5ha8yVMEZTiOlEJHgw5eB9U97FraOXoEH//A33NhDidOGeoCBvsXVmE9hwIvL66MAgv2 m77CtjkZA5S2UIWmBjlDLzeNFe+95jqTNQCm8oJ70EFHrHsezoR/mmL4uO8gGLSk3E4i Ck01+u7jwtt/utosXgsDShIcLvdq496ZsoKr6wQRPRnE2cJj1tK43lWzR6paPrMwAFxJ af1V7NGi7sI4XDCw3xSdWQEqW9NsmMxzVM6Q2W2QuGGQ+Q7ocqvLbLyor+U0vY2LNAAa E8qw== X-Gm-Message-State: AC+VfDwMuKOtM8gV3aJkrqiguhkfw/+tHm+gB/biTPdOEwYx7JGhkzHL nd4bjSJ4et9FybRa/Zj3nbV1SA== X-Google-Smtp-Source: ACHHUZ6OeWVc1a0pysopXFADIzRUnuwVtZGnnlXC6I3lDM3M7q6tNmNUt+le2s2yZte65V2isz4k/Q== X-Received: by 2002:a05:6512:243:b0:4f2:579d:6867 with SMTP id b3-20020a056512024300b004f2579d6867mr1934525lfo.20.1686142019556; Wed, 07 Jun 2023 05:46:59 -0700 (PDT) Received: from uffe-tuxpro14.. (h-94-254-63-18.NA.cust.bahnhof.se. [94.254.63.18]) by smtp.gmail.com with ESMTPSA id z7-20020a19f707000000b004f4b3e9e0cesm1781708lfe.297.2023.06.07.05.46.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 05:46:59 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Cristian Marussi , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Nikunj Kela , Prasad Sodagudi , Alexandre Torgue , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 04/16] cpufreq: scmi: Prepare to move OF parsing of domain-id to cpufreq Date: Wed, 7 Jun 2023 14:46:16 +0200 Message-Id: <20230607124628.157465-5-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230607124628.157465-1-ulf.hansson@linaro.org> References: <20230607124628.157465-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230607_054703_688946_4A7058CB X-CRM114-Status: GOOD ( 13.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The OF parsing of the clock domain specifier seems to better belong in the scmi cpufreq driver, rather than being implemented behind the generic ->device_domain_id() perf protocol ops. To prepare to remove the ->device_domain_id() ops, let's implement the OF parsing in the scmi cpufreq driver instead. Signed-off-by: Ulf Hansson --- drivers/cpufreq/scmi-cpufreq.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/cpufreq/scmi-cpufreq.c b/drivers/cpufreq/scmi-cpufreq.c index f34e6382a4c5..7d05d48c0337 100644 --- a/drivers/cpufreq/scmi-cpufreq.c +++ b/drivers/cpufreq/scmi-cpufreq.c @@ -70,13 +70,24 @@ static unsigned int scmi_cpufreq_fast_switch(struct cpufreq_policy *policy, return 0; } +static int scmi_cpu_domain_id(struct device *cpu_dev) +{ + struct of_phandle_args clkspec; + + if (of_parse_phandle_with_args(cpu_dev->of_node, "clocks", + "#clock-cells", 0, &clkspec)) + return -EINVAL; + + return clkspec.args[0]; +} + static int scmi_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask) { int cpu, domain, tdomain; struct device *tcpu_dev; - domain = perf_ops->device_domain_id(cpu_dev); + domain = scmi_cpu_domain_id(cpu_dev); if (domain < 0) return domain; @@ -88,7 +99,7 @@ scmi_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask) if (!tcpu_dev) continue; - tdomain = perf_ops->device_domain_id(tcpu_dev); + tdomain = scmi_cpu_domain_id(tcpu_dev); if (tdomain == domain) cpumask_set_cpu(cpu, cpumask); } @@ -104,7 +115,7 @@ scmi_get_cpu_power(struct device *cpu_dev, unsigned long *power, unsigned long Hz; int ret, domain; - domain = perf_ops->device_domain_id(cpu_dev); + domain = scmi_cpu_domain_id(cpu_dev); if (domain < 0) return domain; @@ -209,7 +220,7 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy) } priv->cpu_dev = cpu_dev; - priv->domain_id = perf_ops->device_domain_id(cpu_dev); + priv->domain_id = scmi_cpu_domain_id(cpu_dev); policy->driver_data = priv; policy->freq_table = freq_table; From patchwork Wed Jun 7 12:46:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13270740 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DF611C7EE23 for ; Wed, 7 Jun 2023 14:01:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=rakI3SDWvHKLs69TITh58jLJDyzCjw4KUIZw5dTJIaw=; b=dV3BNNzzJYN92E eqpdsjHBOHV7eWnM5B08/e0sbUWarskFf/9ovXTxKQoM2IPmik0Kl1eoN6lLnCIba6Etnr9dMOsLM /4CrD1ItMQcpPnh682dE1ynPi0+l8Bk1snLb7wqgFtG3ys+iNrKuIc0o3PffTiALo7+VhkFGgTCi9 FxvXbvc9YUvyID+IIzlKCENIjsQaGVbk5T1FTdWxbBsqifFa9F+7ydSc2oLJspUc5L3VKyKMKWKw7 pgCnhsP5JlQQhKNbd63oxOZybSgJupZUSrx/uggHvmmDgtNe99Z9bTTzaUtlve2Npgu/IwlHQ/ry3 ZRF3XgVLr29aB9McpABQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6tiL-006B5W-0z; Wed, 07 Jun 2023 14:00:41 +0000 Received: from mail-lj1-x231.google.com ([2a00:1450:4864:20::231]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6sZ6-005wyY-1n for linux-arm-kernel@lists.infradead.org; Wed, 07 Jun 2023 12:47:06 +0000 Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2b1fe3a1a73so8872611fa.1 for ; Wed, 07 Jun 2023 05:47:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686142021; x=1688734021; 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=Wnl75L/jIOZbJGtPwlZuWXFsaT9kJazt/NZQp8DGAaQ=; b=hNyP8cGDfve47KPEBrLpMy1p2yF0gXfx/ce73tAUU3dTRz3CZ1o5QRmrXqHQEuWxuI eHtocsXsILg7cyvCEuWsXqkcly82TD5pZ6oa8w0sMDjnQX2eXUJhqvaMjsWCIn5zEcPv Awi5PugG8WHXKONksbZ/RQtKbELk66GIR+Lw6fbMwINntkDBlVBr5XsTvMigpB0AOJNH Lpcgt/2AvVqhCoTAb0RqxZ065koVG+4H1BuZMANxEaMBmWw/7LmbyAtra8KQlulnmk72 A3dsQc4eu7LE5Efpghejkw/M1mAIEH4xioquHAOtjOgEOYRXCyv7+9Rt666kS7a+VR2m X9Ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686142021; x=1688734021; 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=Wnl75L/jIOZbJGtPwlZuWXFsaT9kJazt/NZQp8DGAaQ=; b=fbsqnv6o5dhFD5bABZ+k1ZmQxdexwXqR7y7Wr6tbka/N6VPbOio5B4CUvRoI5Bfz0E 3akfbABba+18xi7OODSCFFo+T8ydAreTJiYHe9cFxR6SRH1kp86J5Oh/XqsVJkPANupm SctyzILfhea4r2tIzR5qnNh0mQbANuqM3+KNd7T0Yij/DOHQeLMR38jLfgn08vD+snUd LXrE9T26NXVmjH0gmRvvXAe5LPxJ6JNJwfaAnK9Mm5YB0Ovu2JMTBTp/8B3ggHR0YXVM D2PZ75l8OtYjimnYtO4SXQM0H2cjlKH+1y7F8RYJE+9amW35cYnbsgrKODM1lC/dlCCS fI4w== X-Gm-Message-State: AC+VfDy0Y+74O2B6z/T+FC02zJRtCvUFmF/GEQgQJ+yJvXQn4w2GKpiz eyLkVWyh8DQc8sNQVlYNMEsp5w== X-Google-Smtp-Source: ACHHUZ7G70szt+FanJ5JBAKKK7ROhnMx8ok02Z1vo1w6BngcOT1BjrYwHTDc4iXjlzTSh1O7cM/U6Q== X-Received: by 2002:a2e:9616:0:b0:2b1:e5d8:d008 with SMTP id v22-20020a2e9616000000b002b1e5d8d008mr2008954ljh.37.1686142020968; Wed, 07 Jun 2023 05:47:00 -0700 (PDT) Received: from uffe-tuxpro14.. (h-94-254-63-18.NA.cust.bahnhof.se. [94.254.63.18]) by smtp.gmail.com with ESMTPSA id z7-20020a19f707000000b004f4b3e9e0cesm1781708lfe.297.2023.06.07.05.46.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 05:47:00 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Cristian Marussi , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Nikunj Kela , Prasad Sodagudi , Alexandre Torgue , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 05/16] firmware: arm_scmi: Align perf ops to use domain-id as in-parameter Date: Wed, 7 Jun 2023 14:46:17 +0200 Message-Id: <20230607124628.157465-6-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230607124628.157465-1-ulf.hansson@linaro.org> References: <20230607124628.157465-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230607_054704_592428_A84CAE0E X-CRM114-Status: GOOD ( 19.63 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Most scmi_perf_proto_ops are already using an "u32 domain" as an in-parameter to indicate what performance domain we shall operate upon. However, some of the ops are using a "struct device *dev", which means an an additional OF parsing is needed each time the perf ops gets called, to find the corresponding domain-id. To avoid a potential unnecessary OF parsing, but also to make the code more consistent, let's replace the in-parameter "struct device *dev" with an "u32 domain". Note that, this requires us to make some corresponding changes to the scmi cpufreq driver, so let's do that too. Signed-off-by: Ulf Hansson --- drivers/cpufreq/scmi-cpufreq.c | 14 +++++++++----- drivers/firmware/arm_scmi/perf.c | 18 +++++------------- include/linux/scmi_protocol.h | 6 +++--- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/drivers/cpufreq/scmi-cpufreq.c b/drivers/cpufreq/scmi-cpufreq.c index 7d05d48c0337..125e8a8421fb 100644 --- a/drivers/cpufreq/scmi-cpufreq.c +++ b/drivers/cpufreq/scmi-cpufreq.c @@ -137,7 +137,7 @@ scmi_get_cpu_power(struct device *cpu_dev, unsigned long *power, static int scmi_cpufreq_init(struct cpufreq_policy *policy) { - int ret, nr_opp; + int ret, nr_opp, domain; unsigned int latency; struct device *cpu_dev; struct scmi_data *priv; @@ -149,6 +149,10 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy) return -ENODEV; } + domain = scmi_cpu_domain_id(cpu_dev); + if (domain < 0) + return domain; + priv = kzalloc(sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; @@ -187,7 +191,7 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy) */ nr_opp = dev_pm_opp_get_opp_count(cpu_dev); if (nr_opp <= 0) { - ret = perf_ops->device_opps_add(ph, cpu_dev); + ret = perf_ops->device_opps_add(ph, cpu_dev, domain); if (ret) { dev_warn(cpu_dev, "failed to add opps to the device\n"); goto out_free_cpumask; @@ -220,7 +224,7 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy) } priv->cpu_dev = cpu_dev; - priv->domain_id = scmi_cpu_domain_id(cpu_dev); + priv->domain_id = domain; policy->driver_data = priv; policy->freq_table = freq_table; @@ -228,14 +232,14 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy) /* SCMI allows DVFS request for any domain from any CPU */ policy->dvfs_possible_from_any_cpu = true; - latency = perf_ops->transition_latency_get(ph, cpu_dev); + latency = perf_ops->transition_latency_get(ph, domain); if (!latency) latency = CPUFREQ_ETERNAL; policy->cpuinfo.transition_latency = latency; policy->fast_switch_possible = - perf_ops->fast_switch_possible(ph, cpu_dev); + perf_ops->fast_switch_possible(ph, domain); return 0; diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c index 216bcd68d549..563fa44b1a71 100644 --- a/drivers/firmware/arm_scmi/perf.c +++ b/drivers/firmware/arm_scmi/perf.c @@ -593,18 +593,14 @@ static int scmi_dev_domain_id(struct device *dev) } static int scmi_dvfs_device_opps_add(const struct scmi_protocol_handle *ph, - struct device *dev) + struct device *dev, u32 domain) { - int idx, ret, domain; + int idx, ret; unsigned long freq; struct scmi_opp *opp; struct perf_dom_info *dom; struct scmi_perf_info *pi = ph->get_priv(ph); - domain = scmi_dev_domain_id(dev); - if (domain < 0) - return domain; - dom = pi->dom_info + domain; for (opp = dom->opp, idx = 0; idx < dom->opp_count; idx++, opp++) { @@ -626,14 +622,10 @@ static int scmi_dvfs_device_opps_add(const struct scmi_protocol_handle *ph, static int scmi_dvfs_transition_latency_get(const struct scmi_protocol_handle *ph, - struct device *dev) + u32 domain) { struct perf_dom_info *dom; struct scmi_perf_info *pi = ph->get_priv(ph); - int domain = scmi_dev_domain_id(dev); - - if (domain < 0) - return domain; dom = pi->dom_info + domain; /* uS to nS */ @@ -693,12 +685,12 @@ static int scmi_dvfs_est_power_get(const struct scmi_protocol_handle *ph, } static bool scmi_fast_switch_possible(const struct scmi_protocol_handle *ph, - struct device *dev) + u32 domain) { struct perf_dom_info *dom; struct scmi_perf_info *pi = ph->get_priv(ph); - dom = pi->dom_info + scmi_dev_domain_id(dev); + dom = pi->dom_info + domain; return dom->fc_info && dom->fc_info[PERF_FC_LEVEL].set_addr; } diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h index 99c3e985c40f..34ecaeeb51bc 100644 --- a/include/linux/scmi_protocol.h +++ b/include/linux/scmi_protocol.h @@ -136,9 +136,9 @@ struct scmi_perf_proto_ops { u32 *level, bool poll); int (*device_domain_id)(struct device *dev); int (*transition_latency_get)(const struct scmi_protocol_handle *ph, - struct device *dev); + u32 domain); int (*device_opps_add)(const struct scmi_protocol_handle *ph, - struct device *dev); + struct device *dev, u32 domain); int (*freq_set)(const struct scmi_protocol_handle *ph, u32 domain, unsigned long rate, bool poll); int (*freq_get)(const struct scmi_protocol_handle *ph, u32 domain, @@ -146,7 +146,7 @@ struct scmi_perf_proto_ops { int (*est_power_get)(const struct scmi_protocol_handle *ph, u32 domain, unsigned long *rate, unsigned long *power); bool (*fast_switch_possible)(const struct scmi_protocol_handle *ph, - struct device *dev); + u32 domain); enum scmi_power_scale (*power_scale_get)(const struct scmi_protocol_handle *ph); }; From patchwork Wed Jun 7 12:46:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13270739 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E935DC7EE29 for ; Wed, 7 Jun 2023 14:01:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tU1TTCjrtxzUt7M+eUWxHQMSinIaUQIY6w/r4Lu1ULI=; b=Vyt0ccBaWemS6L +UR6J05sPG6O4roIObmNuEM2lFtlabbwfqxQs1I3gzwugBAaxJYcGNSS72v/bvw827cRHDOC32Nfw JwUhh9K+RYlQY1qlWwAV4H+V2QUhlHUY6aBv1NCUr1UfK/e6x6tfrzbccR2moW+rCDoxgqJmpwFaU bigsoTXn0Qo4RpZjMaRplxfcExBFo09w/4YZA/FzXIsDgKxNLw54HYvNzvaxfbfoeqZT+0574gXus 7GO3psFmzAyT6TuKxEBTUcl/x/MtXmRjI9g1byx8jEzxBvAivVG4P6yN8IUli/cfBwh74EfnQ2lEe abpUQLCdbJsjzQbovXSg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6tiL-006B61-2l; Wed, 07 Jun 2023 14:00:41 +0000 Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6sZ9-005wzF-1M for linux-arm-kernel@lists.infradead.org; Wed, 07 Jun 2023 12:47:08 +0000 Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-4f620583bc2so5164532e87.1 for ; Wed, 07 Jun 2023 05:47:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686142022; x=1688734022; 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=o5W7DSQz0XGzmUVAYDRU/7Hmd5AwjW0mpCMReAxukdE=; b=mLisO38cP2z5noWRWcLzOzp5YY32LvUp+JEhRltnTXAD5TBbox8aP89KUVN8s3fsR/ DwWY0uYoSa+nJQIzB7r2e+rf/KI2bFuH95ESITDpTx48nHfmHA9beT7WQtANyf+vrVSJ bHpXxH3oms+bkrCG34OXoGenW9T09xFUvu5grPmMzTCSwlIEdCCaL9L8CjwbITbX5UxW HRGWN6fu6RvRAqPm9CRpY1Pbnz5eidioS4YLshqVIC1zwVzHiLGGpNYIqjP6cUJNvbCi 0FKAxwYVhaugeILq7zV3Uvj/YsWOneb1cxLDBZYXtZYv18jjAvsa2Y8cyeIbWOGUqfNS 3mOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686142022; x=1688734022; 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=o5W7DSQz0XGzmUVAYDRU/7Hmd5AwjW0mpCMReAxukdE=; b=Vp9tBJovpCdBJiARBxmKLIOqRs1ZOaAsCDE5NvQyF7oCk7Z5zWaKOAH0CfhwMbmtPQ o/ccppxeAVoOpL12m+Hl1Baafww/P/dHKD7GC2Dh3zqdNbtzI9IMN+b+jDMxC6SDdLuj QdEa/Z7HKMJPuM6z9UPMT2fKi34vEvNKnFUlHyNEQvzGqPgCbDSlx58QiXgNf0Er6Es0 iVps4wUHa2egwFXJsYDwkR2jjuM6Cn/OjROrbWWtkV8uMPfu0edwuBFEizvpitqRNzNV nfB3YwI7239ezMZ6JwAcxAxf30UOKpHdrU84YkwTFIe5LXQ/8VNa/JT/uTCZMYXeWzaY e0ig== X-Gm-Message-State: AC+VfDwdWq1ibyC/4wtTWmE2zsz7ozPDUFmiDzuIYdsezy4wdNcV0xu0 KgZnt6SDrxw7GIi9DoelwJFdaw== X-Google-Smtp-Source: ACHHUZ7g1f70lwwKvVi9uQ9AnE07znTdJVmBmwg54LTiryfbtvg3r86goEy/WPUp84BpZGMefKd3FQ== X-Received: by 2002:ac2:59c8:0:b0:4f3:8196:80c8 with SMTP id x8-20020ac259c8000000b004f3819680c8mr1943174lfn.1.1686142022518; Wed, 07 Jun 2023 05:47:02 -0700 (PDT) Received: from uffe-tuxpro14.. (h-94-254-63-18.NA.cust.bahnhof.se. [94.254.63.18]) by smtp.gmail.com with ESMTPSA id z7-20020a19f707000000b004f4b3e9e0cesm1781708lfe.297.2023.06.07.05.47.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 05:47:02 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Cristian Marussi , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Nikunj Kela , Prasad Sodagudi , Alexandre Torgue , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/16] firmware: arm_scmi: Drop redundant ->device_domain_id() from perf ops Date: Wed, 7 Jun 2023 14:46:18 +0200 Message-Id: <20230607124628.157465-7-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230607124628.157465-1-ulf.hansson@linaro.org> References: <20230607124628.157465-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230607_054707_470776_B094B07D X-CRM114-Status: GOOD ( 13.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org There are no longer any users of the ->device_domain_id() ops in the scmi_perf_proto_ops, therefore let's remove it. Signed-off-by: Ulf Hansson --- drivers/firmware/arm_scmi/perf.c | 13 ------------- include/linux/scmi_protocol.h | 2 -- 2 files changed, 15 deletions(-) diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c index 563fa44b1a71..9c5340f590e4 100644 --- a/drivers/firmware/arm_scmi/perf.c +++ b/drivers/firmware/arm_scmi/perf.c @@ -580,18 +580,6 @@ static void scmi_perf_domain_init_fc(const struct scmi_protocol_handle *ph, *p_fc = fc; } -/* Device specific ops */ -static int scmi_dev_domain_id(struct device *dev) -{ - struct of_phandle_args clkspec; - - if (of_parse_phandle_with_args(dev->of_node, "clocks", "#clock-cells", - 0, &clkspec)) - return -EINVAL; - - return clkspec.args[0]; -} - static int scmi_dvfs_device_opps_add(const struct scmi_protocol_handle *ph, struct device *dev, u32 domain) { @@ -711,7 +699,6 @@ static const struct scmi_perf_proto_ops perf_proto_ops = { .can_level_set = scmi_perf_can_level_set, .level_set = scmi_perf_level_set, .level_get = scmi_perf_level_get, - .device_domain_id = scmi_dev_domain_id, .transition_latency_get = scmi_dvfs_transition_latency_get, .device_opps_add = scmi_dvfs_device_opps_add, .freq_set = scmi_dvfs_freq_set, diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h index 34ecaeeb51bc..21aea1b2a355 100644 --- a/include/linux/scmi_protocol.h +++ b/include/linux/scmi_protocol.h @@ -107,7 +107,6 @@ struct scmi_clk_proto_ops { * @limits_get: gets limits on the performance level of a domain * @level_set: sets the performance level of a domain * @level_get: gets the performance level of a domain - * @device_domain_id: gets the scmi domain id for a given device * @transition_latency_get: gets the DVFS transition latency for a given device * @device_opps_add: adds all the OPPs for a given device * @freq_set: sets the frequency for a given device using sustained frequency @@ -134,7 +133,6 @@ struct scmi_perf_proto_ops { u32 level, bool poll); int (*level_get)(const struct scmi_protocol_handle *ph, u32 domain, u32 *level, bool poll); - int (*device_domain_id)(struct device *dev); int (*transition_latency_get)(const struct scmi_protocol_handle *ph, u32 domain); int (*device_opps_add)(const struct scmi_protocol_handle *ph, From patchwork Wed Jun 7 12:46:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13270743 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6679EC83005 for ; Wed, 7 Jun 2023 14:01:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=5fy1ideoEMR98d4wNYkiukBoQgsp32V0rzcoaK66XQ4=; b=a36OKAP64vyaYG ocXdYJECCwezI2/xb1YX97gwt2I+XpYvqp8AbaQnp/v7iuKQQbY3kqSCnxet819mvEi4o7M1i44G9 k/125m8+DCWLVZZTY5zV9ItuRr2dQ022rHLhjvHB3Z5KM1891DElVtkQIJQJykXdc2tH0E4j/PNcD gIDJjyoSDcwCho9O7IEI/ZOWN/1XVRSlWCyNoUmTFuXHsRf/TrrtWgihhLyEBdvfprFhu6cS1YwnH BMp1NeZUnYTvOxjaGTwaL/ol2opIuwmjphSHxri4dz6tlzMJ1B5gg/mT+ZSfSciWiNxvOQP3oGZqa a+ovRW2g4352QA4Oo2ww==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6tiM-006B6Q-1J; Wed, 07 Jun 2023 14:00:42 +0000 Received: from mail-lj1-x232.google.com ([2a00:1450:4864:20::232]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6sZ9-005wzc-2I for linux-arm-kernel@lists.infradead.org; Wed, 07 Jun 2023 12:47:09 +0000 Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2b1badb8f9bso54841461fa.1 for ; Wed, 07 Jun 2023 05:47:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686142023; x=1688734023; 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=EcFIFzlxuaj95mrPekLslPaq6LF3WQagm1CvzdpttW8=; b=nHwwPnA9ljX4h2OItxC5R61hMDJGQXC4NQicB85qJzaiv/1PAEAmc+ZTqbh5R7iMIN G7Co+6il9T22wVppZZjlwyNyIyF6WuBIGpBM1EhvXchD89Z1rwJJTOb6+Fhd+EOnJ/Mw XiXg1ASLg7D+CAhIuEYdDSEfnYqHVu2Nhrg7FfaNbaJR4cUX5HFexxAsNdEEWXDczrJK x5GlxIUJZ9My4guxbqa4+WFr6KnSUwCRUGDOf0dZS+7SCJPAgguillYbg9wAqhJOUpJP ppm4t8fO1Wkkj/BLBzLf88LMENST/kfA/Mz5yhEOe2SQlZave+e+2ODJJgx9WPaqSFaR YWqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686142023; x=1688734023; 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=EcFIFzlxuaj95mrPekLslPaq6LF3WQagm1CvzdpttW8=; b=RaORKIBFwk8FVQT3yL67ztOeNvbNBMp0JG8LyDeOChx3kHbiUaoIq+2uemTJ9VP0QO 5A9nvvIsqj81aYZrUMV48ZTmZLB8josbnPtpUm80/mRKGofih+W1DaC8RhCqIFHyvP0S LXFvGmJ7JyQVj1Umg1TYcEYHL+0f1NdcvsFK6I/pR5rWLv1No+ayQSPb9XK/e4C8s/iz MLt/PXyBHfrWamJFGeqG4j6uWQgf2geNFDRwXT4aHmua4/2gdvY/Z8CbhJLD7Pg5Gmkr 8y7m1O8olGmVjuafuuhc8gUQSiAJxrWOyhcGfuTbMbsmaI8wCu4eFiwrtwx07YYLydmn nXYg== X-Gm-Message-State: AC+VfDwL3GShejuv6Y7JFxPxvQ4ixQ3QgH8/6wAI48qLGNXguFR9h3uU Y66EppepDfmZ0qVasFTnwiZafQ== X-Google-Smtp-Source: ACHHUZ7MfrKrmho6SvmAbt/n1doRuY4rUhqfbuKmIzQhUWTjjDOL4+dQPQ+ue8e0r5O4Q+P3ADMvkQ== X-Received: by 2002:a2e:3515:0:b0:2af:1844:6fdb with SMTP id z21-20020a2e3515000000b002af18446fdbmr2148166ljz.5.1686142023625; Wed, 07 Jun 2023 05:47:03 -0700 (PDT) Received: from uffe-tuxpro14.. (h-94-254-63-18.NA.cust.bahnhof.se. [94.254.63.18]) by smtp.gmail.com with ESMTPSA id z7-20020a19f707000000b004f4b3e9e0cesm1781708lfe.297.2023.06.07.05.47.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 05:47:03 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Cristian Marussi , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Nikunj Kela , Prasad Sodagudi , Alexandre Torgue , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 07/16] cpufreq: scmi: Avoid one OF parsing in scmi_get_sharing_cpus() Date: Wed, 7 Jun 2023 14:46:19 +0200 Message-Id: <20230607124628.157465-8-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230607124628.157465-1-ulf.hansson@linaro.org> References: <20230607124628.157465-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230607_054707_775190_6250C6D1 X-CRM114-Status: GOOD ( 12.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The domain-id for the cpu_dev has already been parsed at the point when scmi_get_sharing_cpus() is getting called. Let's pass it as an in-parameter to avoid the unnecessary OF parsing. Signed-off-by: Ulf Hansson --- drivers/cpufreq/scmi-cpufreq.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/cpufreq/scmi-cpufreq.c b/drivers/cpufreq/scmi-cpufreq.c index 125e8a8421fb..78f53e388094 100644 --- a/drivers/cpufreq/scmi-cpufreq.c +++ b/drivers/cpufreq/scmi-cpufreq.c @@ -82,15 +82,12 @@ static int scmi_cpu_domain_id(struct device *cpu_dev) } static int -scmi_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask) +scmi_get_sharing_cpus(struct device *cpu_dev, int domain, + struct cpumask *cpumask) { - int cpu, domain, tdomain; + int cpu, tdomain; struct device *tcpu_dev; - domain = scmi_cpu_domain_id(cpu_dev); - if (domain < 0) - return domain; - for_each_possible_cpu(cpu) { if (cpu == cpu_dev->id) continue; @@ -163,7 +160,7 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy) } /* Obtain CPUs that share SCMI performance controls */ - ret = scmi_get_sharing_cpus(cpu_dev, policy->cpus); + ret = scmi_get_sharing_cpus(cpu_dev, domain, policy->cpus); if (ret) { dev_warn(cpu_dev, "failed to get sharing cpumask\n"); goto out_free_cpumask; From patchwork Wed Jun 7 12:46:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13270742 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E4AECC8300C for ; Wed, 7 Jun 2023 14:01:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=MuK2CJpMpFqDHAVuZxSRcqSiapquogR5XtdWWBya7h0=; b=GXsk8mhUihdlvt 6F2YDKO9k9jMjshkzRSzX78+H7/TNDF7Mkyh2mDGZlg5+WsLPP4XGrVoJC0uFxeCsNBUq8AkuzSfn 5DtYvCLA19OuKljclf62NyR4i/qEu1ZCp/PGRx5+ZJ8Gx38kd0mgdkKCrUFqKoy6PwUjHxdP2yK2H qgJCD0bDjtT+lgfxbPviKXWihNqq5GuNExYJ7YFeeRcJ6RqxAHvJqnCyHqGFd3g/zyqJwJmzkQNW9 bmRS3U9ew87Br2Eoumf1EF4uG4x1yIg0yyW0KJ62JWD/sNcK1G9oJKSW+TsLpn1YD9pQSsrUG2DuK C5eppSFxGQd7K9lEk0MA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6tiN-006B7T-1x; Wed, 07 Jun 2023 14:00:43 +0000 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6sZ9-005x0n-2L for linux-arm-kernel@lists.infradead.org; Wed, 07 Jun 2023 12:47:10 +0000 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-4f63ea7bfb6so1308657e87.3 for ; Wed, 07 Jun 2023 05:47:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686142025; x=1688734025; 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=vlN3puumXl98HZqEEgwOfFzKMHFxb3yG/jJp+Fhyp4M=; b=tihrD1ZPx4XtIuP6jos1gyNcy2O0ErgPJVg/oRr6QlGzYhr1sZvo3Krr8HWxufoB/E bu7nG1I0VZvuCE+eR24HJzgCQ8hJZtgDAbKYUi22oGBxxCgAfu6MDHgvC0IzcNc113JD qj8We12FvXAT/7HGoEJDnySZYh6Iz9IwnULfOtkaSQGXdeQhBa23Tu9M87g9yqB+rENU i9uQ2pmFqnHO5Fzpc+Z+X4EEUCtNPGxLfM62w4dYrPIPFsCw4vEmxdUmT8lKMuNwzj/9 aDEBU6zFJdzpRQIgzsAbgtK0Joj4Y1jqc/sUuOGi71H+F9XJuu9mBIVz24Cu0iO7xVkZ FxkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686142025; x=1688734025; 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=vlN3puumXl98HZqEEgwOfFzKMHFxb3yG/jJp+Fhyp4M=; b=C4ozXv6KoxE6ndeUqzVKN5HXvOYchPlidTHrchvPw/44U9cQBnFASyTYuX8qEKdRE+ bJQHAo1EcDUdiYNiPiFSV+mCGAuZAue3OyBVuL/X6z6XVVSr9AAxL3dIOYEL5A9QsMND TE64OIBSZ/2P63Ty4JYGBJZUk53dzaH5i5XB+AwohsafHcwwECBhCZm0AHBgDNQd6vx6 lbo8uengPP9ZyucU+YAdIBawgHpjSPgTrii8AnX/tH9HHdu6ZsWqnw5qBnOPuyJ8DjRu X42Rdq/4ruy4bFZdfr4suXrT44VgQjuLrTaihVQbr0glNU9WWxx70YEn0O4mZ6/r1JWa CDlw== X-Gm-Message-State: AC+VfDy4Nq12pb2lCrs6Szu9ZtNFBLTAN/qrhGaUbN/y/v10OQNc0tWH iw+8Z6sFC/rsUDWa5fmDGmLR4g== X-Google-Smtp-Source: ACHHUZ6v8QXNHYkt2lFcE9klDUW8Xlnt5LZgbqYnNRFBjulymMuINKZ/K7uEZW1MgCAieIjxBaO4NA== X-Received: by 2002:a19:7402:0:b0:4f6:3677:552 with SMTP id v2-20020a197402000000b004f636770552mr1747794lfe.38.1686142025090; Wed, 07 Jun 2023 05:47:05 -0700 (PDT) Received: from uffe-tuxpro14.. (h-94-254-63-18.NA.cust.bahnhof.se. [94.254.63.18]) by smtp.gmail.com with ESMTPSA id z7-20020a19f707000000b004f4b3e9e0cesm1781708lfe.297.2023.06.07.05.47.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 05:47:04 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Cristian Marussi , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Nikunj Kela , Prasad Sodagudi , Alexandre Torgue , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 08/16] PM: domains: Allow genpd providers to manage OPP tables directly by its FW Date: Wed, 7 Jun 2023 14:46:20 +0200 Message-Id: <20230607124628.157465-9-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230607124628.157465-1-ulf.hansson@linaro.org> References: <20230607124628.157465-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230607_054707_769353_AC4D134E X-CRM114-Status: GOOD ( 16.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In some cases the OPP tables aren't specified in device tree, but rather encoded in the FW. To allow a genpd provider to specify them dynamically instead, let's add a new genpd flag, GENPD_FLAG_OPP_TABLE_FW. Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 11 ++++++----- include/linux/pm_domain.h | 5 +++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 32084e38b73d..cb35c040216a 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -130,6 +130,7 @@ static const struct genpd_lock_ops genpd_spin_ops = { #define genpd_is_active_wakeup(genpd) (genpd->flags & GENPD_FLAG_ACTIVE_WAKEUP) #define genpd_is_cpu_domain(genpd) (genpd->flags & GENPD_FLAG_CPU_DOMAIN) #define genpd_is_rpm_always_on(genpd) (genpd->flags & GENPD_FLAG_RPM_ALWAYS_ON) +#define genpd_is_opp_table_fw(genpd) (genpd->flags & GENPD_FLAG_OPP_TABLE_FW) static inline bool irq_safe_dev_in_sleep_domain(struct device *dev, const struct generic_pm_domain *genpd) @@ -2328,7 +2329,7 @@ int of_genpd_add_provider_simple(struct device_node *np, genpd->dev.of_node = np; /* Parse genpd OPP table */ - if (genpd->set_performance_state) { + if (!genpd_is_opp_table_fw(genpd) && genpd->set_performance_state) { ret = dev_pm_opp_of_add_table(&genpd->dev); if (ret) return dev_err_probe(&genpd->dev, ret, "Failed to add OPP table\n"); @@ -2343,7 +2344,7 @@ int of_genpd_add_provider_simple(struct device_node *np, ret = genpd_add_provider(np, genpd_xlate_simple, genpd); if (ret) { - if (genpd->set_performance_state) { + if (!genpd_is_opp_table_fw(genpd) && genpd->set_performance_state) { dev_pm_opp_put_opp_table(genpd->opp_table); dev_pm_opp_of_remove_table(&genpd->dev); } @@ -2387,7 +2388,7 @@ int of_genpd_add_provider_onecell(struct device_node *np, genpd->dev.of_node = np; /* Parse genpd OPP table */ - if (genpd->set_performance_state) { + if (!genpd_is_opp_table_fw(genpd) && genpd->set_performance_state) { ret = dev_pm_opp_of_add_table_indexed(&genpd->dev, i); if (ret) { dev_err_probe(&genpd->dev, ret, @@ -2423,7 +2424,7 @@ int of_genpd_add_provider_onecell(struct device_node *np, genpd->provider = NULL; genpd->has_provider = false; - if (genpd->set_performance_state) { + if (!genpd_is_opp_table_fw(genpd) && genpd->set_performance_state) { dev_pm_opp_put_opp_table(genpd->opp_table); dev_pm_opp_of_remove_table(&genpd->dev); } @@ -2455,7 +2456,7 @@ void of_genpd_del_provider(struct device_node *np) if (gpd->provider == &np->fwnode) { gpd->has_provider = false; - if (!gpd->set_performance_state) + if (genpd_is_opp_table_fw(gpd) || !gpd->set_performance_state) continue; dev_pm_opp_put_opp_table(gpd->opp_table); diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index f776fb93eaa0..05ad8cefdff1 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -61,6 +61,10 @@ * GENPD_FLAG_MIN_RESIDENCY: Enable the genpd governor to consider its * components' next wakeup when determining the * optimal idle state. + * + * GENPD_FLAG_OPP_TABLE_FW: The genpd provider supports performance states, + * but its corresponding OPP tables are not + * described in DT, but are given directly by FW. */ #define GENPD_FLAG_PM_CLK (1U << 0) #define GENPD_FLAG_IRQ_SAFE (1U << 1) @@ -69,6 +73,7 @@ #define GENPD_FLAG_CPU_DOMAIN (1U << 4) #define GENPD_FLAG_RPM_ALWAYS_ON (1U << 5) #define GENPD_FLAG_MIN_RESIDENCY (1U << 6) +#define GENPD_FLAG_OPP_TABLE_FW (1U << 7) enum gpd_status { GENPD_STATE_ON = 0, /* PM domain is on */ From patchwork Wed Jun 7 12:46:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13270744 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F044FC7EE2F for ; Wed, 7 Jun 2023 14:01:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hW+pN8GkTJZmAXTlstcPR5r8DmqjURDPLfUQ0PI1S8c=; b=ezq725r97TzuKy iw8geTscrr5cVS8tCTvRJJqGLAggj/ffDF2zwRaMuf4VEnLTyUFAQtQP2+h1pQAHETNCvLjL/Mf/m ZiyvHUu12BRHpBf6wlPCri+mD5EsqcGi6karU7Nkgr1gOGhfjzC739KT6xmFAXKtcutACSpJcmutq CnYZ9k/OsNp+PjbIhTFq44ue09jQXikUjOT3FFTKKc31Ozmu/SkzMdIN181Tz649me0B9xWDaJUXN tQ6JdXt7y//vAbVO7tUCnYlzL3uTk0di4T1DXzwIP9Q2gh9iLZZVmgU9lZFUkOymr+6cdcuBk+kyw rsPuoWLbQTKMN1jpJdNA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6tiO-006B8l-38; Wed, 07 Jun 2023 14:00:44 +0000 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6sZC-005x1e-2E for linux-arm-kernel@lists.infradead.org; Wed, 07 Jun 2023 12:47:12 +0000 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-4f6283d0d84so4504822e87.1 for ; Wed, 07 Jun 2023 05:47:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686142026; x=1688734026; 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=yEZ1VzAf/ewGDW/CO5YjzDFKyIheYAdlDwMj1VXqtFc=; b=nPt/QsfPsptDpzewzdY7leTqIaUAJpiotvO0q3HqPzfmRErlMhhkfRuG0nRMHSjLBO 8vmDV4DrC7wghEALhqJhenkRYBm34v31CKfmEpgJiwiIi7GfJf3cL/kE3o0RlgD/TDUx KcxT101ueVqqtxYh/wUrXE5us7BGYsrV4dO8K/ZyYDv5TmfZYumby23yLPpsi35zd/w3 YaUJoH9ZivYsDJ8dPmRiloUWxrAF2yVGnpoQJsnqrnE5G+Llf0CPgza1htQ37ekmWic2 xA1jjjIEwAG1d4WQsvi+lXv1itWcWXIMaoECCjoWdh0v0dj4x4bAMiQ9+UTNb6Ho1KcH 7r7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686142026; x=1688734026; 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=yEZ1VzAf/ewGDW/CO5YjzDFKyIheYAdlDwMj1VXqtFc=; b=DIriKfta4iw9KjbwhRxkTocYa8P1n0nVzAC1tuct21H3Dm5KhkjAmDmVtfu3tqmdYM +hvvsi2FVpw+i9IXZCwQNLN5C+LlLfEbDpDzpXV9rAXdqtRaWBvpwGDDZ3cGnrtnXk1U HHlKH2L/vkhI8PEQjpvdeavnQPKvfEqXiRDi6jxIKdYX/i7GW5H0R4ArJk7km0uTAou6 MG6Q6biTRQLQbc8EOHy1ppQnwJ8B4mtVrOYgr6Vbl8BDtQsJc8pQCM9T5N9chlFsBuge OAaPJcuuzRqW+xfB9xOVijVmlSj9CPrHH9S+DDH6RMGZARrmn+f9HXb15DcWKdMOS+52 HUQQ== X-Gm-Message-State: AC+VfDwonOHAIf2I4Dhdxd6sjXR00qRFWYPBRCLHsslJ+iXnYicNEnrq g0lZR/0kbO2NeZlpa+e1mUH70w== X-Google-Smtp-Source: ACHHUZ7oEGJSSteDCq7mlPuEP2JPf6TfeU0SKmori9ql3yVzxm5aBdyrwavRPyxl4ojjTJ0lwm1s7Q== X-Received: by 2002:a05:6512:14b:b0:4f6:171e:48e with SMTP id m11-20020a056512014b00b004f6171e048emr1979036lfo.22.1686142026612; Wed, 07 Jun 2023 05:47:06 -0700 (PDT) Received: from uffe-tuxpro14.. (h-94-254-63-18.NA.cust.bahnhof.se. [94.254.63.18]) by smtp.gmail.com with ESMTPSA id z7-20020a19f707000000b004f4b3e9e0cesm1781708lfe.297.2023.06.07.05.47.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 05:47:06 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Cristian Marussi , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Nikunj Kela , Prasad Sodagudi , Alexandre Torgue , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Rob Herring , Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org Subject: [PATCH 09/16] dt-bindings: firmware: arm,scmi: Extend bindings for protocol@13 Date: Wed, 7 Jun 2023 14:46:21 +0200 Message-Id: <20230607124628.157465-10-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230607124628.157465-1-ulf.hansson@linaro.org> References: <20230607124628.157465-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230607_054710_748586_51412D2D X-CRM114-Status: GOOD ( 12.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The protocol@13 node is describing the performance scaling option for the ARM SCMI interface, as a clock provider. This is unnecessary limiting, as performance scaling is in many cases not limited to switching a clock's frequency. Therefore, let's extend the binding so the interface can be modelled as a generic "performance domain" too. The common way to describe this, is to use the "power-domain" bindings, so let's use that. Cc: Rob Herring Cc: Krzysztof Kozlowski Cc: Conor Dooley Cc: devicetree@vger.kernel.org Signed-off-by: Ulf Hansson --- Documentation/devicetree/bindings/firmware/arm,scmi.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml index 5824c43e9893..cff9d1e4cea1 100644 --- a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml +++ b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml @@ -145,8 +145,8 @@ properties: '#clock-cells': const: 1 - required: - - '#clock-cells' + '#power-domain-cells': + const: 1 protocol@14: $ref: '#/$defs/protocol-node' From patchwork Wed Jun 7 12:46:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13270748 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B40D9C7EE2F for ; Wed, 7 Jun 2023 14:01:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=9WN2oLT2n+6m68LcB3TqxsHULVDeKfFJJ3OTrI4sk/I=; b=uhkmxcXXFIf4F0 6KibgWx7NfWhH+9pUFU0LMKMGdXU1oWBECIR+viRHkkrUI702d4di1YO6FJfh012S6GaqVKpjKzt0 0Yx1oSNOb+8BnBejvwObOzqtrV7sDAgBmMbpGhMIU2PC/ULzuen2XlEBP3uPCSIDg7w5FUt/CETMS neDUi8d5HuTAuIHzfxv/76ukkWtcilOClfuSqv6kj8eX5nyjrN7do9C5uRS1gKY12pJ5f1EXr6AJe AABRzHzyN6JSee3WOhmWRdP49U2as8afFVlFa3caLL88I8A311WzE6vv7E+ZZRfN/vcj5MZsBsEt1 ZLCIAZYBvama4HIyPRdA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6tiQ-006BA2-0K; Wed, 07 Jun 2023 14:00:46 +0000 Received: from mail-lf1-f46.google.com ([209.85.167.46]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6sZD-005x2u-1h for linux-arm-kernel@lists.infradead.org; Wed, 07 Jun 2023 12:47:14 +0000 Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-4f63ab1ac4aso1976899e87.0 for ; Wed, 07 Jun 2023 05:47:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686142028; x=1688734028; 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=W/gi1wYyuTGyxRPCnXy/W6dl0ztApfjNz5N46Tr334c=; b=iAk48snIpP5FAUcrOXKzaso2EfYDoBqaGWM3B8Qdt+hejNMFNiyGWiUY7ipuqdhcIG YkRLuIzAv35XMuOwamJpKqrl8yKzF7KvysKf8JPh3nYZ2AUeWurkxIAYvk40xMRLw1Py r/N02dBKTh2IPq5oDDSKk+8nakTeTFMVBBS5LnpjxlojC/1YvyBV73zW1ur7QkC162oo PlyMV34cjVQ11mvjWMdfYjItPVRo9di3kX2R/ee3FSob0LVlZpyBLuMqInEotACmxtiC IzY5yfSEQ3WodR5SirsXRXi4fWLkxZPObgIMk9GOCHyKy3xWZ5HdN5pwG2IBh7udVHQP abTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686142028; x=1688734028; 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=W/gi1wYyuTGyxRPCnXy/W6dl0ztApfjNz5N46Tr334c=; b=Q3IS+IiJWvgVuzhEVE65e5oQQBGg3DCWKiaMdddIj/Wb5kQNOLkzDcxwgz3zGfqLTF zMdHdcd0WNjbJ/eqrc/tAachpyc4foNoz5zlGeqYNdi5TEBF50HlqyLK2bOcmZ/qKlKn EH+UMPpCtkyzD0NUix9chwWQim4ciBHqgrHMQRyJvfch+5mlKEYUdt/tolzzGmX544ml 7m/Cc9Qr4xdYXZkuAAJIQn7DNT8PRvJf+3qOEuTaJuoPiI517a/6Tt+76pCkd11sTnAU 7RR1lcCfeytbTl5zWopQCzLPB5LPwJ5pf1w30oXc0LRhfufE6AWstb0GxBVMLcn8+kvF aj2A== X-Gm-Message-State: AC+VfDyzBPdm16EgY0CJ7hWr8cpV60ks1+hBOqvvp8xh6gKGxlc7/Kq3 aanAtmHNXv8F70Hj0TIwcR8XDg== X-Google-Smtp-Source: ACHHUZ6bmAujPPGUaE0p6wW6yTU2QtF+4D5UiiKNAqQSVwwLLD5tdqR7H3fNEKvFf2vmeP/ZqqmnYQ== X-Received: by 2002:ac2:59db:0:b0:4f3:aa29:b672 with SMTP id x27-20020ac259db000000b004f3aa29b672mr2008947lfn.30.1686142028046; Wed, 07 Jun 2023 05:47:08 -0700 (PDT) Received: from uffe-tuxpro14.. (h-94-254-63-18.NA.cust.bahnhof.se. [94.254.63.18]) by smtp.gmail.com with ESMTPSA id z7-20020a19f707000000b004f4b3e9e0cesm1781708lfe.297.2023.06.07.05.47.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 05:47:07 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Cristian Marussi , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Nikunj Kela , Prasad Sodagudi , Alexandre Torgue , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 10/16] firmware: arm_scmi: Add the SCMI performance domain Date: Wed, 7 Jun 2023 14:46:22 +0200 Message-Id: <20230607124628.157465-11-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230607124628.157465-1-ulf.hansson@linaro.org> References: <20230607124628.157465-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230607_054711_570383_3FD817BF X-CRM114-Status: GOOD ( 27.46 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org To enable support for performance scaling (DVFS) for generic devices with the SCMI performance protocol, let's add an SCMI performance domain. This is being modelled as a genpd provider, with support for performance scaling through genpd's ->set_performance_state() callback. Note that, this adds the initial support that allows consumer drivers for attached devices, to vote for a new performance state via calling the dev_pm_genpd_set_performance_state(). However, this should be avoided as it's in most cases preferred to use the OPP library to vote for a new OPP instead. The support using the OPP library is implemented from subsequent changes. Signed-off-by: Ulf Hansson --- drivers/firmware/arm_scmi/Kconfig | 12 ++ drivers/firmware/arm_scmi/Makefile | 1 + drivers/firmware/arm_scmi/scmi_perf_domain.c | 155 +++++++++++++++++++ 3 files changed, 168 insertions(+) create mode 100644 drivers/firmware/arm_scmi/scmi_perf_domain.c diff --git a/drivers/firmware/arm_scmi/Kconfig b/drivers/firmware/arm_scmi/Kconfig index ea0f5083ac47..706d1264d038 100644 --- a/drivers/firmware/arm_scmi/Kconfig +++ b/drivers/firmware/arm_scmi/Kconfig @@ -181,6 +181,18 @@ config ARM_SCMI_POWER_DOMAIN will be called scmi_pm_domain. Note this may needed early in boot before rootfs may be available. +config ARM_SCMI_PERF_DOMAIN + tristate "SCMI performance domain driver" + depends on ARM_SCMI_PROTOCOL || (COMPILE_TEST && OF) + default y + select PM_GENERIC_DOMAINS if PM + help + This enables support for the SCMI performance domains which can be + enabled or disabled via the SCP firmware. + + This driver can also be built as a module. If so, the module will be + called scmi_perf_domain. + config ARM_SCMI_POWER_CONTROL tristate "SCMI system power control driver" depends on ARM_SCMI_PROTOCOL || (COMPILE_TEST && OF) diff --git a/drivers/firmware/arm_scmi/Makefile b/drivers/firmware/arm_scmi/Makefile index b31d78fa66cc..afee66a65dcb 100644 --- a/drivers/firmware/arm_scmi/Makefile +++ b/drivers/firmware/arm_scmi/Makefile @@ -17,6 +17,7 @@ obj-$(CONFIG_ARM_SCMI_PROTOCOL) += scmi-core.o obj-$(CONFIG_ARM_SCMI_PROTOCOL) += scmi-module.o obj-$(CONFIG_ARM_SCMI_POWER_DOMAIN) += scmi_pm_domain.o +obj-$(CONFIG_ARM_SCMI_PERF_DOMAIN) += scmi_perf_domain.o obj-$(CONFIG_ARM_SCMI_POWER_CONTROL) += scmi_power_control.o ifeq ($(CONFIG_THUMB2_KERNEL)$(CONFIG_CC_IS_CLANG),yy) diff --git a/drivers/firmware/arm_scmi/scmi_perf_domain.c b/drivers/firmware/arm_scmi/scmi_perf_domain.c new file mode 100644 index 000000000000..9be90a7d94de --- /dev/null +++ b/drivers/firmware/arm_scmi/scmi_perf_domain.c @@ -0,0 +1,155 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * SCMI performance domain support. + * + * Copyright (C) 2023 Linaro Ltd. + */ + +#include +#include +#include +#include +#include +#include + +struct scmi_perf_domain { + struct generic_pm_domain genpd; + const struct scmi_perf_proto_ops *perf_ops; + const struct scmi_protocol_handle *ph; + u32 domain_id; + bool can_level_set; +}; + +#define to_scmi_pd(pd) container_of(pd, struct scmi_perf_domain, genpd) + +static int +scmi_pd_set_perf_state(struct generic_pm_domain *genpd, unsigned int state) +{ + struct scmi_perf_domain *pd = to_scmi_pd(genpd); + int ret; + + if (!pd->can_level_set) + return 0; + + ret = pd->perf_ops->level_set(pd->ph, pd->domain_id, state, true); + if (ret) + dev_warn(&genpd->dev, "Failed with %d when trying to set %d perf level", + ret, state); + + return ret; +} + +static int scmi_perf_domain_probe(struct scmi_device *sdev) +{ + struct device *dev = &sdev->dev; + const struct scmi_handle *handle = sdev->handle; + const struct scmi_perf_proto_ops *perf_ops; + struct scmi_protocol_handle *ph; + struct scmi_perf_domain *scmi_pd; + struct genpd_onecell_data *scmi_pd_data; + struct generic_pm_domain **domains; + int num_domains, i, ret = 0; + u32 perf_level; + + if (!handle) + return -ENODEV; + + /* The OF node must specify us as a power-domain provider. */ + if (!of_find_property(dev->of_node, "#power-domain-cells", NULL)) + return 0; + + perf_ops = handle->devm_protocol_get(sdev, SCMI_PROTOCOL_PERF, &ph); + if (IS_ERR(perf_ops)) + return PTR_ERR(perf_ops); + + num_domains = perf_ops->num_domains_get(ph); + if (num_domains < 0) { + dev_warn(dev, "Failed with %d when getting num perf domains\n", + num_domains); + return num_domains; + } else if (!num_domains) { + return 0; + } + + scmi_pd = devm_kcalloc(dev, num_domains, sizeof(*scmi_pd), GFP_KERNEL); + if (!scmi_pd) + return -ENOMEM; + + scmi_pd_data = devm_kzalloc(dev, sizeof(*scmi_pd_data), GFP_KERNEL); + if (!scmi_pd_data) + return -ENOMEM; + + domains = devm_kcalloc(dev, num_domains, sizeof(*domains), GFP_KERNEL); + if (!domains) + return -ENOMEM; + + for (i = 0; i < num_domains; i++, scmi_pd++) { + scmi_pd->domain_id = i; + scmi_pd->perf_ops = perf_ops; + scmi_pd->ph = ph; + scmi_pd->can_level_set = perf_ops->can_level_set(ph, i); + + scmi_pd->genpd.name = perf_ops->name_get(ph, i); + scmi_pd->genpd.flags = GENPD_FLAG_OPP_TABLE_FW; + scmi_pd->genpd.set_performance_state = scmi_pd_set_perf_state; + + ret = perf_ops->level_get(ph, i, &perf_level, false); + if (ret) { + dev_dbg(dev, "Failed to get perf level for %s", + scmi_pd->genpd.name); + perf_level = 0; + } + + /* Let the perf level indicate the power-state too. */ + ret = pm_genpd_init(&scmi_pd->genpd, NULL, perf_level == 0); + if (ret) + goto err; + + domains[i] = &scmi_pd->genpd; + } + + scmi_pd_data->domains = domains; + scmi_pd_data->num_domains = num_domains; + + ret = of_genpd_add_provider_onecell(dev->of_node, scmi_pd_data); + if (ret) + goto err; + + dev_set_drvdata(dev, scmi_pd_data); + dev_info(dev, "Initialized %d performance domains", num_domains); + return 0; +err: + for (i--; i >= 0; i--) + pm_genpd_remove(domains[i]); + return ret; +} + +static void scmi_perf_domain_remove(struct scmi_device *sdev) +{ + struct device *dev = &sdev->dev; + struct genpd_onecell_data *scmi_pd_data = dev_get_drvdata(dev); + int i; + + of_genpd_del_provider(dev->of_node); + + for (i = 0; i < scmi_pd_data->num_domains; i++) + pm_genpd_remove(scmi_pd_data->domains[i]); +} + +static const struct scmi_device_id scmi_id_table[] = { + { SCMI_PROTOCOL_PERF, "perf" }, + { }, +}; +MODULE_DEVICE_TABLE(scmi, scmi_id_table); + +static struct scmi_driver scmi_perf_domain_driver = { + .name = "scmi-perf-domain", + .probe = scmi_perf_domain_probe, + .remove = scmi_perf_domain_remove, + .id_table = scmi_id_table, +}; +module_scmi_driver(scmi_perf_domain_driver); + +MODULE_AUTHOR("Ulf Hansson "); +MODULE_DESCRIPTION("ARM SCMI perf domain driver"); +MODULE_LICENSE("GPL v2"); From patchwork Wed Jun 7 12:46:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13270722 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ED307C77B7A for ; Wed, 7 Jun 2023 13:49:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=GQHA6NvZboLNBjuJKea8IB2xGSJI92Ks36cHCUsSLs8=; b=Y5A1qcGXtMD2Y2 XM0fjDxqilwBXYDRdkaCrFe83ymo/9dN1siNprWWJMu1r/YLsWHMj7HVKknDSW25qtrUir+2YgjBj /r2RoaCBBUG81uNcm4Y1u2zgkyqw2M8jSQBL7w35B8VjugFXkxV1npX132YHIKXNu7DnFlTGBrRjI yKVY4RdZvi77NsCH5lsyEQMhL+h14tZi3a5YNljwRocrf9hXVAykavliRHye+u0rSwRW4ODlEF8bV sNzX+rW1xw3B3yy6nBvbxNy5lgoW969fAmXSBzKo70baXZ6v+I+HKVglT4CpVf3yTsoXqyncCYHWw ZvisXQP7Nt2F0sE7ZMSw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6tXB-0068uM-2V; Wed, 07 Jun 2023 13:49:09 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6tX9-0068sz-1f for linux-arm-kernel@bombadil.infradead.org; Wed, 07 Jun 2023 13:49:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=ZFOFaTdB/ZAJjZPTuGERS2BWBk3lHevQSrGw284LH/A=; b=EwVorLID5Hb37Nf/VDe4viE4jb 5I9uacSDyk69FNzJ/ck07QeYM4JQwpWdZgh/nbAHEOhH8atZ86SVTUnMT7KWkDUTFAN+H1vZota18 jMBJeiu7B7EYFqt9Igfngw2f0Yi/lcQk6YuFffJwcCYNK/E7csSfb428O47mnBrezaL/8go8/9MPF mwnxgPokCHrSSZ+Jp6b3ExD9rwrnLOlBdQBrxsnTrUqDa+8113SSxlw3cKemi9YoDmLEBVwz/QUI8 dZg4MkT+Ces7RCKZavqe06aK4MJjvp+0tsHo+cUCPGMA24KYay4LODsUO1dFTYJtisX5V+12I2oob Iz4Q8t3w==; Received: from mail-lf1-x131.google.com ([2a00:1450:4864:20::131]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6sZE-0059QW-2Z for linux-arm-kernel@lists.infradead.org; Wed, 07 Jun 2023 12:47:15 +0000 Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-4f6370ddd27so2424080e87.0 for ; Wed, 07 Jun 2023 05:47:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686142030; x=1688734030; 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=ZFOFaTdB/ZAJjZPTuGERS2BWBk3lHevQSrGw284LH/A=; b=VDnMswoWv3vXbGiOyeKlRwDyVh+DQTlDneRSvPwp7iemvODyTy+cM31LXX6NhCSYbA wTp4dDrlmRGPT4rHQejDkJL38iDAByWnVWHOYDsn6Z29FjXHNbLtjIcGlRPvSV8J7P0m bjIIl2WKPB2zY4LQlV/w4+wswycvn99VC2JJNz4COf/zUUPzxQ/TwHV5kjJPX1ODiGuc 23HhM4aGDRjmBGGjoKBDghYwVN7RGThmU66R2/MoS+gKsN0Me0hsrzrAnpOyBQej785l efeqj5qSS9SeXJPEm4g2001M65IDuIuO8Ao9+Dkoe+bMRwwYZPufT5nQKEP9U4jhUjDT VZmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686142030; x=1688734030; 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=ZFOFaTdB/ZAJjZPTuGERS2BWBk3lHevQSrGw284LH/A=; b=BNusd2N7GD2TrJ0jyWNWLEL53acjWcHJmha136ooEg9qt2FAvVXnUIov9WP336+rhQ HP4Js37boFREn/sKGN2DSJzX6AGg8pGRjDdORhYS9gyGB7PhTKBKnYRtej+vW3lPc7NM cTnzvqRSjH5UHozqNemH0HHXgTth7tX8fWjGnUm1DURX3xpA5QasVIXdPlCMUi4CtoxK qtmU5AFbaT/RgphQDEcMwUl/Et0XNMi06hcovIB2MG6E1k+UdIm+izgfT7ouxkPsBu+Z F6xR7+nFDObpg2ZGFi+FcgVuN6L+hlOSaSypMoVTVU+ZQEYYeF0srZUmE80uFLbVK5q6 5DyA== X-Gm-Message-State: AC+VfDwBJBX4P6bIzWh6jT4DbPzqY7YJMoHuyIKthPMdP6B/ik88dlMR sz7R3aH7YpO6Rm1Twzas+qT5/Q== X-Google-Smtp-Source: ACHHUZ5wwtUo78oY555XmA9CeIllwbLEbC2LxOMp8LF9LoXOjriV0ZXhcNiRJoFkEDLb/DqT8FOxkA== X-Received: by 2002:ac2:5108:0:b0:4f4:b592:74ab with SMTP id q8-20020ac25108000000b004f4b59274abmr1853886lfb.62.1686142029801; Wed, 07 Jun 2023 05:47:09 -0700 (PDT) Received: from uffe-tuxpro14.. (h-94-254-63-18.NA.cust.bahnhof.se. [94.254.63.18]) by smtp.gmail.com with ESMTPSA id z7-20020a19f707000000b004f4b3e9e0cesm1781708lfe.297.2023.06.07.05.47.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 05:47:09 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Cristian Marussi , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Nikunj Kela , Prasad Sodagudi , Alexandre Torgue , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 11/16] OPP: Add dev_pm_opp_add_dynamic() to allow more flexibility Date: Wed, 7 Jun 2023 14:46:23 +0200 Message-Id: <20230607124628.157465-12-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230607124628.157465-1-ulf.hansson@linaro.org> References: <20230607124628.157465-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230607_134713_090447_B817AB93 X-CRM114-Status: GOOD ( 19.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The dev_pm_opp_add() API is limited to add dynamic OPPs with a frequency and/or voltage level. To enable more flexibility, let's add a new dev_pm_opp_add_dynamic() API, that's takes a struct dev_pm_opp_data* instead of list of in-parameters. Signed-off-by: Ulf Hansson --- drivers/opp/core.c | 49 ++++++++++++++++++++++++++++++++---------- drivers/opp/of.c | 11 ++++++---- drivers/opp/opp.h | 2 +- include/linux/pm_opp.h | 18 ++++++++++++++++ 4 files changed, 64 insertions(+), 16 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 954c94865cf5..0e6ee2980f88 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -1921,8 +1921,7 @@ int _opp_add(struct device *dev, struct dev_pm_opp *new_opp, * _opp_add_v1() - Allocate a OPP based on v1 bindings. * @opp_table: OPP table * @dev: device for which we do this operation - * @freq: Frequency in Hz for this OPP - * @u_volt: Voltage in uVolts for this OPP + * @opp: The OPP to add * @dynamic: Dynamically added OPPs. * * This function adds an opp definition to the opp table and returns status. @@ -1940,10 +1939,10 @@ int _opp_add(struct device *dev, struct dev_pm_opp *new_opp, * -ENOMEM Memory allocation failure */ int _opp_add_v1(struct opp_table *opp_table, struct device *dev, - unsigned long freq, long u_volt, bool dynamic) + struct dev_pm_opp_data *opp, bool dynamic) { struct dev_pm_opp *new_opp; - unsigned long tol; + unsigned long tol, u_volt = opp->u_volt; int ret; if (!assert_single_clk(opp_table)) @@ -1954,7 +1953,7 @@ int _opp_add_v1(struct opp_table *opp_table, struct device *dev, return -ENOMEM; /* populate the opp table */ - new_opp->rates[0] = freq; + new_opp->rates[0] = opp->freq; tol = u_volt * opp_table->voltage_tolerance_v1 / 100; new_opp->supplies[0].u_volt = u_volt; new_opp->supplies[0].u_volt_min = u_volt - tol; @@ -2738,10 +2737,9 @@ int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, } /** - * dev_pm_opp_add() - Add an OPP table from a table definitions - * @dev: device for which we do this operation - * @freq: Frequency in Hz for this OPP - * @u_volt: Voltage in uVolts for this OPP + * dev_pm_opp_add_dynamic() - Add an OPP table from a table definitions + * @dev: The device for which we do this operation + * @opp: The OPP to be added * * This function adds an opp definition to the opp table and returns status. * The opp is made available by default and it can be controlled using @@ -2754,7 +2752,7 @@ int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, * Duplicate OPPs (both freq and volt are same) and !opp->available * -ENOMEM Memory allocation failure */ -int dev_pm_opp_add(struct device *dev, unsigned long freq, unsigned long u_volt) +int dev_pm_opp_add_dynamic(struct device *dev, struct dev_pm_opp_data *opp) { struct opp_table *opp_table; int ret; @@ -2766,12 +2764,41 @@ int dev_pm_opp_add(struct device *dev, unsigned long freq, unsigned long u_volt) /* Fix regulator count for dynamic OPPs */ opp_table->regulator_count = 1; - ret = _opp_add_v1(opp_table, dev, freq, u_volt, true); + ret = _opp_add_v1(opp_table, dev, opp, true); if (ret) dev_pm_opp_put_opp_table(opp_table); return ret; } +EXPORT_SYMBOL_GPL(dev_pm_opp_add_dynamic); + +/** + * dev_pm_opp_add() - Add an OPP table from a table definitions + * @dev: device for which we do this operation + * @freq: Frequency in Hz for this OPP + * @u_volt: Voltage in uVolts for this OPP + * + * This function adds an opp definition to the opp table and returns status. + * The opp is made available by default and it can be controlled using + * dev_pm_opp_enable/disable functions. + * + * Return: + * 0 On success OR + * Duplicate OPPs (both freq and volt are same) and opp->available + * -EEXIST Freq are same and volt are different OR + * Duplicate OPPs (both freq and volt are same) and !opp->available + * -ENOMEM Memory allocation failure + */ +int dev_pm_opp_add(struct device *dev, unsigned long freq, unsigned long u_volt) +{ + struct dev_pm_opp_data opp; + + memset(&opp, 0, sizeof(opp)); + opp.freq = freq; + opp.u_volt = u_volt; + + return dev_pm_opp_add_dynamic(dev, &opp); +} EXPORT_SYMBOL_GPL(dev_pm_opp_add); /** diff --git a/drivers/opp/of.c b/drivers/opp/of.c index 8246e9b7afe7..b96f6304f497 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -1079,13 +1079,16 @@ static int _of_add_opp_table_v1(struct device *dev, struct opp_table *opp_table) val = prop->value; while (nr) { - unsigned long freq = be32_to_cpup(val++) * 1000; - unsigned long volt = be32_to_cpup(val++); + struct dev_pm_opp_data opp; - ret = _opp_add_v1(opp_table, dev, freq, volt, false); + memset(&opp, 0, sizeof(opp)); + opp.freq = be32_to_cpup(val++) * 1000; + opp.u_volt = be32_to_cpup(val++); + + ret = _opp_add_v1(opp_table, dev, &opp, false); if (ret) { dev_err(dev, "%s: Failed to add OPP %ld (%d)\n", - __func__, freq, ret); + __func__, opp.freq, ret); goto remove_static_opp; } nr -= 2; diff --git a/drivers/opp/opp.h b/drivers/opp/opp.h index 2a057c42ddf4..b15770b2305e 100644 --- a/drivers/opp/opp.h +++ b/drivers/opp/opp.h @@ -255,7 +255,7 @@ struct dev_pm_opp *_opp_allocate(struct opp_table *opp_table); void _opp_free(struct dev_pm_opp *opp); int _opp_compare_key(struct opp_table *opp_table, struct dev_pm_opp *opp1, struct dev_pm_opp *opp2); int _opp_add(struct device *dev, struct dev_pm_opp *new_opp, struct opp_table *opp_table); -int _opp_add_v1(struct opp_table *opp_table, struct device *dev, unsigned long freq, long u_volt, bool dynamic); +int _opp_add_v1(struct opp_table *opp_table, struct device *dev, struct dev_pm_opp_data *opp, bool dynamic); void _dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask, int last_cpu); struct opp_table *_add_opp_table_indexed(struct device *dev, int index, bool getclk); void _put_opp_list_kref(struct opp_table *opp_table); diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index dc1fb5890792..305cd87b394c 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -92,6 +92,16 @@ struct dev_pm_opp_config { struct device ***virt_devs; }; +/** + * struct dev_pm_opp_data - The data to use to initialize an OPP. + * @freq: The clock rate in Hz for the OPP. + * @u_volt: The voltage in uV for the OPP. + */ +struct dev_pm_opp_data { + unsigned long freq; + unsigned long u_volt; +}; + #if defined(CONFIG_PM_OPP) struct opp_table *dev_pm_opp_get_opp_table(struct device *dev); @@ -142,6 +152,8 @@ void dev_pm_opp_put(struct dev_pm_opp *opp); int dev_pm_opp_add(struct device *dev, unsigned long freq, unsigned long u_volt); +int dev_pm_opp_add_dynamic(struct device *dev, struct dev_pm_opp_data *opp); + void dev_pm_opp_remove(struct device *dev, unsigned long freq); void dev_pm_opp_remove_all_dynamic(struct device *dev); @@ -297,6 +309,12 @@ static inline int dev_pm_opp_add(struct device *dev, unsigned long freq, return -EOPNOTSUPP; } +static inline int +dev_pm_opp_add_dynamic(struct device *dev, struct dev_pm_opp_data *opp) +{ + return -EOPNOTSUPP; +} + static inline void dev_pm_opp_remove(struct device *dev, unsigned long freq) { } From patchwork Wed Jun 7 12:46:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13270745 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C5870C7EE29 for ; Wed, 7 Jun 2023 14:01:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2gfBJfJxJVot9O6+pWtWOb3RoBSGnpa4DBMQ/1x2fpA=; b=c8d/DSxtW+wNqI uuQJUI3+s7yLVULhIDIb6R81FRMBkzJ4RCs7u+OwS+7IF7REL56EYgPeOG+0dp2Tviwi+7KTFXiOt aClWDs9PFdK+Lt9qXDXvE09DkcFb1wL2tsljYKPZneLDSqf0Pq+/7+onzeuNgaUae9de3QR5KP3S9 U2fa0qLRB4c81A0nC5gqmXfJS1TItfPbuogYOu95cI+/EGi5G1IW3e86LSWRR+5SCG8l0YN0kYRdW a5+YotjbU6ZoPPtU25iTvSv0qQ2zC0Z+hsSgeKIsLfAUaOxhf7aCcPBtbilfaV0NfbSgn5paivIhh X0NpiDGGQmAJGa2p0okw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6tiP-006B9I-1g; Wed, 07 Jun 2023 14:00:45 +0000 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6sZD-005wxc-2T for linux-arm-kernel@lists.infradead.org; Wed, 07 Jun 2023 12:47:13 +0000 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-4f642a24555so888042e87.3 for ; Wed, 07 Jun 2023 05:47:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686142031; x=1688734031; 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=soNRO/BUZIJbMO0tj7YT3q6ZRWzbCDnTXsUpvBRWu2A=; b=itpQPjGA5TElmgt1urTONLMv9mjtGtb7S9Z5uyIb+OWowKNKt7+MSj9qAl4FLFJJlP ifnyOMTir9GkU8jjOGGLXDEimE5gB5HKNFycDQMCCA6T0l/6qzFVaX7pO64y2MvJswiy w/ueTkJHOv1UbOsnFRcA5MrsDh0VldxAZ/ptP01UqLLfpjaK3URAiQ1N0vpG39S3v/f3 0ztubSa4eWOX6A+sJIYvnChwpDAA4wucYwcCemf71lEMjGE+6VgzNdkGZwv779uJ0Pxl cqdD0gdokH5LgttK4zcKO/B1LtKwtsdZq5SvRqpW5uRObXQwQdeNSrZdc7b8pBlFeCxa 6LGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686142031; x=1688734031; 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=soNRO/BUZIJbMO0tj7YT3q6ZRWzbCDnTXsUpvBRWu2A=; b=Giuz3yRQoJljtjeEL3tWkERo/GsC0wpDU8ZxKADjizY4TFuHbWIV13EErBUBkQ50kd Agozi1P2EIZnoZEzQ4HKsqLIbf35OB2vg8XHkZCVO3OKit2lsnkNoH0KsE9GSyvi9MCX THr6KTeCEGtDIZNa6J3XFgFJ8+foBcunGXDs2wKTVYL8wmvvpZpwVR/gUrRuLpMQIoHK V+czAeCWYziZdcxAUWVKV0wNSOHEe8UbSnlT6y7trWEHxW9xMHBT/gTh9cQep5cwQKsa IZc26zqgi018IcZ8vK0VHfpYUIa4ofK38RJxfso6LcEYKyNUctwB0YzQlp6b0by73PhK KCZg== X-Gm-Message-State: AC+VfDzKp6RnHFgOgYYuCZ2iPooiWqKldHvVkqcf1mYHrWQZ8qbkAzrx kX046Z7qvnTOPmEbpF9KqkBoVg== X-Google-Smtp-Source: ACHHUZ6vjXi6uoVZFASRdXD9Oxut2wR/L6LpmXTtwp68ccU9nq2Nc+wzn4DEFJH6wASf5v7NdQIk5A== X-Received: by 2002:ac2:4195:0:b0:4f4:c973:c97d with SMTP id z21-20020ac24195000000b004f4c973c97dmr1907711lfh.25.1686142031157; Wed, 07 Jun 2023 05:47:11 -0700 (PDT) Received: from uffe-tuxpro14.. (h-94-254-63-18.NA.cust.bahnhof.se. [94.254.63.18]) by smtp.gmail.com with ESMTPSA id z7-20020a19f707000000b004f4b3e9e0cesm1781708lfe.297.2023.06.07.05.47.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 05:47:10 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Cristian Marussi , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Nikunj Kela , Prasad Sodagudi , Alexandre Torgue , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 12/16] OPP: Extend dev_pm_opp_data with performance level Date: Wed, 7 Jun 2023 14:46:24 +0200 Message-Id: <20230607124628.157465-13-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230607124628.157465-1-ulf.hansson@linaro.org> References: <20230607124628.157465-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230607_054711_801945_7E99986E X-CRM114-Status: GOOD ( 12.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Let's extend the dev_pm_opp_data with a level variable, to allow users to specify a corresponding performance level for a dynamically added OPP. Signed-off-by: Ulf Hansson --- drivers/opp/core.c | 1 + include/linux/pm_opp.h | 2 ++ 2 files changed, 3 insertions(+) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 0e6ee2980f88..79b4b44ced3e 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -1954,6 +1954,7 @@ int _opp_add_v1(struct opp_table *opp_table, struct device *dev, /* populate the opp table */ new_opp->rates[0] = opp->freq; + new_opp->level = opp->level; tol = u_volt * opp_table->voltage_tolerance_v1 / 100; new_opp->supplies[0].u_volt = u_volt; new_opp->supplies[0].u_volt_min = u_volt - tol; diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 305cd87b394c..2c6f67736579 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -94,10 +94,12 @@ struct dev_pm_opp_config { /** * struct dev_pm_opp_data - The data to use to initialize an OPP. + * @level: The performance level for the OPP. * @freq: The clock rate in Hz for the OPP. * @u_volt: The voltage in uV for the OPP. */ struct dev_pm_opp_data { + unsigned int level; unsigned long freq; unsigned long u_volt; }; From patchwork Wed Jun 7 12:46:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13270721 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 87199C77B7A for ; Wed, 7 Jun 2023 13:49:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=BXCJOnCrP9ydL7+lfb4RwS7LpZb+XL+y54RY3R+5rK0=; b=E1QJU43VVDqUKw YrAde/Bhn1n3EBX+0IKT/LAx+TRhNy4xCAYbABrNhwD/qyAZClsBdikHl6dXY0gIlV5rlMYgHB7TC Wsm9nMVGQKdsqMBcRQLm4q4Rkmb0+aGNi6VHX9Cyv2+Sh4cJYsWqCXbVxB85ndK+kacU2aeBM3lyB trzvQbixfRtZ6q/bwAf4xnjzPHQksy6WK9Aqj88rbvL5rDB4ddTpyrmRmXxV8XRdM75/MtPxZEc/e WE99wVLtrQr4D7C4CFaVI8oth+K+nf3/C5SD+/GgRtMCxCjDvXWouZrfkJZAdjYiGvDP530oDDMEp zyED8DK4+2dWhhl+46eQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6tX8-0068sc-0G; Wed, 07 Jun 2023 13:49:06 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6tX6-0068qz-22 for linux-arm-kernel@bombadil.infradead.org; Wed, 07 Jun 2023 13:49:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=hmd8HT7dYpFwRTq0How6UAlKRFjjp2QQNX4mDltPGDc=; b=UTvHsmEvpEi3DsLsIoYSs8psEV H638Od1jsb+nUjSp5gvoJd1+jsJXsOuNC/F++7g26cIMUbExICQemWyL6+KHBrml51Qynp0CdRlni T6eIWBY19OGe+GNtpvcLqXaN9+D6rkTxvIfb6i4Rp5RcDQJOvaug9l4vX6uyJFC2fKGZNPOS7vEoA m4VV7NIjZBvQqnicUvobBtWGQV7PBuGFKVwB5Ht563N/F7U2RLsAn3pdXCn0BOv3LmnzXMk+chVtF LSa4A5U/zaA3Sh4GXV8+C49waDnpRjSR8nXoa5stATBCvQxdbIPB67nJPYqjXijYw9iC4aDQEDOOz 3gcqpXjA==; Received: from mail-lf1-x12b.google.com ([2a00:1450:4864:20::12b]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6sZG-0059Qo-1S for linux-arm-kernel@lists.infradead.org; Wed, 07 Jun 2023 12:47:16 +0000 Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-4f649db9b25so18154e87.0 for ; Wed, 07 Jun 2023 05:47:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686142032; x=1688734032; 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=hmd8HT7dYpFwRTq0How6UAlKRFjjp2QQNX4mDltPGDc=; b=HBg+TlFMgB3o6cTaUfYJew1Qay1qLLHcPyGSbprNVTSjMoblHCrw2ugrurnH+Kbw8l IwOFLfw+Qq9upy6zJyu5GVl0exUC0n2iozSCQiUmAKH96nQj4rAm4wIdzJHZqlbpU/8e LqmFvnXGNhsuiVg4HGdKAQpXz5dWxvV8MLeFIkdUfy8EnPHGpU/tZ3y8hRdySi4kI3Ni pyOAK730tqsq/MgHOezVmFrkrstPc4JQZGog3gMwuVwQa0BCnPNqNDEN6wgDZNsWN4uK DOSQZA8ClDAvkIx/j7qgtkhWH9ScHebJJVtbj08nli8fTLgSqfKP/EFhtNQsR3snjyIm UI3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686142032; x=1688734032; 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=hmd8HT7dYpFwRTq0How6UAlKRFjjp2QQNX4mDltPGDc=; b=BnMMakQ3n94q8src1vYqtkg0JY6CTNn/IbQqFLQ4fo9xK5ICaPCmxL7VUYuWc9faQs IUqb8i6a3PBWHYp4oyEKidHnai637VjAcD8QzaLr0z1BfD6N7PA5IKUBplDgQGx02r/p Zwbu/8c3tgLn3LCXrxpObWw2tTbgraDB9uG2TjRuRFspzMr4u6gOZqY+DaSGYpDgByWC 5oot4YyzwTWSvbIFpCjfO3Gq8BfbK7hIkLRV48ajWZVJImxiQSAyE8HGtBn7FY1Yssbx zUjCTPTXN2IrqPjK87P8PFb2GOE70Cekd4IELWhhGmvb741O5Das5WDKgnoJs60FIrRg cGGg== X-Gm-Message-State: AC+VfDzl/HX+HTUDs2Q53o0i3avLG5+9k29oA77FBo8fZDJ+LUxPwQmd jwu8JxWPMS//d9ldBo/bUPpydg== X-Google-Smtp-Source: ACHHUZ5yaVd7KzIOTDmEnIJmHTR8qnWHnno0l6A3omE0ob8X/gHt9eymtj/RgnH2H/2G007jrU6B/A== X-Received: by 2002:ac2:47eb:0:b0:4f3:87d7:f7a4 with SMTP id b11-20020ac247eb000000b004f387d7f7a4mr2294228lfp.62.1686142032391; Wed, 07 Jun 2023 05:47:12 -0700 (PDT) Received: from uffe-tuxpro14.. (h-94-254-63-18.NA.cust.bahnhof.se. [94.254.63.18]) by smtp.gmail.com with ESMTPSA id z7-20020a19f707000000b004f4b3e9e0cesm1781708lfe.297.2023.06.07.05.47.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 05:47:11 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Cristian Marussi , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Nikunj Kela , Prasad Sodagudi , Alexandre Torgue , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 13/16] OPP: Extend dev_pm_opp_data with OPP provider support Date: Wed, 7 Jun 2023 14:46:25 +0200 Message-Id: <20230607124628.157465-14-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230607124628.157465-1-ulf.hansson@linaro.org> References: <20230607124628.157465-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230607_134714_573617_9362AC49 X-CRM114-Status: GOOD ( 17.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org To allow a dynamically added OPP to be coupled with a specific OPP provider type, let's add a new enum variable in the struct dev_pm_opp_data. Moreover, let's add support for a DEV_PM_OPP_TYPE_GENPD type, corresponding to genpd's performance states support. More precisely, this allows a genpd provider to dynamically add OPPs when a device gets attached to it, that later can be used by a consumer driver when it needs to change the performance level for its corresponding device. Signed-off-by: Ulf Hansson --- drivers/opp/core.c | 19 +++++++++++++++++++ drivers/opp/opp.h | 1 + include/linux/pm_opp.h | 7 +++++++ 3 files changed, 27 insertions(+) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 79b4b44ced3e..81a3418e2eaf 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -1112,6 +1112,15 @@ static int _set_opp(struct device *dev, struct opp_table *opp_table, return ret; } + if (opp->provider == DEV_PM_OPP_TYPE_GENPD) { + ret = dev_pm_genpd_set_performance_state(dev, opp->level); + if (ret) { + dev_err(dev, "Failed to set performance level: %d\n", + ret); + return ret; + } + } + ret = _set_opp_bw(opp_table, opp, dev); if (ret) { dev_err(dev, "Failed to set bw: %d\n", ret); @@ -1155,6 +1164,15 @@ static int _set_opp(struct device *dev, struct opp_table *opp_table, return ret; } + if (opp->provider == DEV_PM_OPP_TYPE_GENPD) { + ret = dev_pm_genpd_set_performance_state(dev, opp->level); + if (ret) { + dev_err(dev, "Failed to set performance level: %d\n", + ret); + return ret; + } + } + ret = _set_required_opps(dev, opp_table, opp, false); if (ret) { dev_err(dev, "Failed to set required opps: %d\n", ret); @@ -1955,6 +1973,7 @@ int _opp_add_v1(struct opp_table *opp_table, struct device *dev, /* populate the opp table */ new_opp->rates[0] = opp->freq; new_opp->level = opp->level; + new_opp->provider = opp->provider; tol = u_volt * opp_table->voltage_tolerance_v1 / 100; new_opp->supplies[0].u_volt = u_volt; new_opp->supplies[0].u_volt_min = u_volt - tol; diff --git a/drivers/opp/opp.h b/drivers/opp/opp.h index b15770b2305e..ee2b3bd89213 100644 --- a/drivers/opp/opp.h +++ b/drivers/opp/opp.h @@ -104,6 +104,7 @@ struct dev_pm_opp { unsigned int pstate; unsigned long *rates; unsigned int level; + enum dev_pm_opp_provider_type provider; struct dev_pm_opp_supply *supplies; struct dev_pm_opp_icc_bw *bandwidth; diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 2c6f67736579..4c40199c7728 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -26,6 +26,11 @@ enum dev_pm_opp_event { OPP_EVENT_ADJUST_VOLTAGE, }; +enum dev_pm_opp_provider_type { + DEV_PM_OPP_TYPE_NONE = 0, + DEV_PM_OPP_TYPE_GENPD, +}; + /** * struct dev_pm_opp_supply - Power supply voltage/current values * @u_volt: Target voltage in microvolts corresponding to this OPP @@ -97,11 +102,13 @@ struct dev_pm_opp_config { * @level: The performance level for the OPP. * @freq: The clock rate in Hz for the OPP. * @u_volt: The voltage in uV for the OPP. + * @provider: The type of provider for the OPP. */ struct dev_pm_opp_data { unsigned int level; unsigned long freq; unsigned long u_volt; + enum dev_pm_opp_provider_type provider; }; #if defined(CONFIG_PM_OPP) From patchwork Wed Jun 7 12:46:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13270747 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DD183C77B7A for ; Wed, 7 Jun 2023 14:01:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8OdxKtNw9QJqOk0jmPlGp217q/y/5Oevba4iYx6qs6M=; b=s4USWNBHg5IiPt kAHPZ7rey4ZHSTLXysyZhXcQHRJv4rMaqObpCUr3BoDgJWrkxdB8Ji2pgDBK0vwfdUOhb9KQrJv+S bLCJibCAeRimroS5yDW8mX82fVA4r1IZ/0vRcf4+vqHwrTrHLKFEX97Ti+Rkpppl7ptzOary7exU0 FZhBe8M1Qy/P+ZE2u6B4cHe3BpODSUXFKnwvVf/40vSwl3/CPucQ5zbznPKbjPeJYQoCxhinOOOl5 AcnxjrwqpHrA6r6q84bB8Gws6LutXDVzXZzChw5otMvgzN5hwL04gcfqrJ23qk/qi1VDvJlSc3wkj 1S26h1EFHuZc19bsZkIA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6tiQ-006BAX-2A; Wed, 07 Jun 2023 14:00:46 +0000 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6sZH-005x6Y-0K for linux-arm-kernel@lists.infradead.org; Wed, 07 Jun 2023 12:47:16 +0000 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-4f611ac39c5so7240574e87.2 for ; Wed, 07 Jun 2023 05:47:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686142033; x=1688734033; 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=4b5Qrnd5i2zJnrU79sLpQmCBr/qGSSDn3CP8EHjD6U4=; b=XpdKTgk1cDCNQQWTJx9Ik39EP7iB/XP9x8fLotqVKs5E477dudxeo7Fsr2smRNd8+T xIYKUBjmq1dI7sWLCfrfhPLDSEoSUdIig2/ZWCafAOVvs9avBLCodWD/W6kc+9MNfo4Q p5FaAOor/pyoO4fd1HWKz1rMMRIQil0+8oNeVFXaoAgEDtgyj0xtVjDjfJjcuHf3BEvb nXZbmt3RkadgB8PHOSDl0q5p45JA+ZMqI+gSVLy9HwjIVlv+87yDk0vDIMsqkEQ+eD7E 5bPMSpYlkZXG8tibzBW8nrKec3MR+meotBXU985AI1YPcZ1rZfzCt6yOoGM8axVAApmC 0DHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686142033; x=1688734033; 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=4b5Qrnd5i2zJnrU79sLpQmCBr/qGSSDn3CP8EHjD6U4=; b=Lyz7hpJlEhbUAFwbBQVPPnNG20/ZkETikezrIXKBEtGv+WPmCvr2NUZe+YZp2z9TuS Uu1Uf7epQK8NqDFFjKQqADmkYS8HGNoT6OocCZVoQxuRI7AHkwEIdjUN9vRXX2epzp7e J06pPX/0b8KUM/PBAz4Kwvi3EuODotscSmT6h7p+9sDljRizVRA8q8zo0rIpLP2UgOro XJoZYRch+h2FW/CdFGc/f1EafsUQ8VpGLa+jZ+pPDOBU2vzoU+KzI9KmBFe/9IgzgI2w OdbqgPR3Z0ThQ/aKGOXlhuSVvFODzJFnCT7o2PVpzf9vi5k87nKq+sBckcYGXKCVOwIZ 1mHw== X-Gm-Message-State: AC+VfDw8SWBazGLfiOgiiQk1KNUuDTUvJA9dFZtopFM6B/J7btJaQW/s 04EgLRDcHTW0uKIsK2MLacxIIg== X-Google-Smtp-Source: ACHHUZ45w/pMhCdOU/CVe1mplFe8QafWFzLTdhmjb+KE2CxVl3xwpMAAlcS0iGJO0TlLTV/h13ehaA== X-Received: by 2002:a19:6756:0:b0:4f6:47a2:7bb4 with SMTP id e22-20020a196756000000b004f647a27bb4mr133291lfj.60.1686142033767; Wed, 07 Jun 2023 05:47:13 -0700 (PDT) Received: from uffe-tuxpro14.. (h-94-254-63-18.NA.cust.bahnhof.se. [94.254.63.18]) by smtp.gmail.com with ESMTPSA id z7-20020a19f707000000b004f4b3e9e0cesm1781708lfe.297.2023.06.07.05.47.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 05:47:13 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Cristian Marussi , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Nikunj Kela , Prasad Sodagudi , Alexandre Torgue , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 14/16] firmware: arm_scmi: Simplify error path in scmi_dvfs_device_opps_add() Date: Wed, 7 Jun 2023 14:46:26 +0200 Message-Id: <20230607124628.157465-15-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230607124628.157465-1-ulf.hansson@linaro.org> References: <20230607124628.157465-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230607_054715_138468_C9242977 X-CRM114-Status: GOOD ( 12.91 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Let's simplify the code in scmi_dvfs_device_opps_add() by using dev_pm_opp_remove_all_dynamic() in its error path. Signed-off-by: Ulf Hansson --- drivers/firmware/arm_scmi/perf.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c index 9c5340f590e4..03a496ccc603 100644 --- a/drivers/firmware/arm_scmi/perf.c +++ b/drivers/firmware/arm_scmi/perf.c @@ -585,23 +585,18 @@ static int scmi_dvfs_device_opps_add(const struct scmi_protocol_handle *ph, { int idx, ret; unsigned long freq; - struct scmi_opp *opp; struct perf_dom_info *dom; struct scmi_perf_info *pi = ph->get_priv(ph); dom = pi->dom_info + domain; - for (opp = dom->opp, idx = 0; idx < dom->opp_count; idx++, opp++) { - freq = opp->perf * dom->mult_factor; + for (idx = 0; idx < dom->opp_count; idx++) { + freq = dom->opp[idx].perf * dom->mult_factor; ret = dev_pm_opp_add(dev, freq, 0); if (ret) { dev_warn(dev, "failed to add opp %luHz\n", freq); - - while (idx-- > 0) { - freq = (--opp)->perf * dom->mult_factor; - dev_pm_opp_remove(dev, freq); - } + dev_pm_opp_remove_all_dynamic(dev); return ret; } } From patchwork Wed Jun 7 12:46:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13270746 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 448D2C7EE23 for ; Wed, 7 Jun 2023 14:01:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=us4WRv3we2mz17H8sMzDngCQyDbkH139xgLmeqBpACY=; b=CFkwHNhLTdUW+z rFHE8CgTKSugHAmLjI4DfPz38cCCp5TxscO52CYThtqVjE6U57fLA4Rnle9WTl6WSSLCKGCJO+swB aPIZDSwPm6HEw/WsjNHClFAD6Q6opcJFfNV+8nPgFViCXNxzIjMDNXKyITwUCFBSllUJVe2AlSyVO ApvGNA+5/Ixndl8DEKCPw1HrYOBQZHUokDgH3wzZuQfk8ioiR2AVgTpLh6HprjBHnioLjHlsUPYon eTfzI5yC0EYcssYA81pE9Zdn6d1TM+ovd9x7QGTJyb4Wnf6SOnDBVQJBwj0XDtw6gwG8R55r7/cB3 wUIxa6bgtgptBt/GbvDQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6tiR-006BBK-0u; Wed, 07 Jun 2023 14:00:47 +0000 Received: from mail-lf1-x12b.google.com ([2a00:1450:4864:20::12b]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6sZI-005x7R-31 for linux-arm-kernel@lists.infradead.org; Wed, 07 Jun 2023 12:47:18 +0000 Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-4f63006b4e3so3115120e87.1 for ; Wed, 07 Jun 2023 05:47:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686142035; x=1688734035; 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=U/Lsn91+ee3WkHkcIZxtEhxNatDc00drhhG6bof7lRA=; b=b88t5sq2oobU4xV66g5hQD7/yWbCE3+/kZV4AVkDBxs8BYhtS9SqZhGew6mJ39ScmZ UEfzMVzg2eOs1nm15ycXtIaTxTFCobvHCGqqfYBt2eG++tYgP+wLqJX3ezEz0PWwIiWe caJn4bnpQ3OwmXG6VPSkzTc/iRiFb0n81Fc776q3XBsmgKKLAeHTL56rx7AvAADaghDj AceOHOFeHGf0Mxpl/Uix5o+8bRPHlo5UIbYGSDzX7beL6EYaYpN59GNhyXh8ufhee7k+ sib9eQ2X0qXGziJIPmZlKGWKLpgeyL8BCSfqll2ToTGoQVs4NQOizC9HE5pUB4d38bWj CDxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686142035; x=1688734035; 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=U/Lsn91+ee3WkHkcIZxtEhxNatDc00drhhG6bof7lRA=; b=LvFDIRxWstF3swsGE+b3+sObKmX5csJRE7j1X6Ir0K91p7zdKfZzqNeg3teq8w0arg h9IJQxg1uB7hWNS3eQy6cgDTaclPDhOkCY8KXLew5i8zRV0S8l006bgHS9Xis80yN3k9 VS+dpSZKnRj9bwlge30cZq2RsPu4pp3tH9pxdZp+Az3fCmWPUISCibqHzWaoPTrTS79+ Z1ToeChN7GWUK2A/6SJbFN29brmhTfP4PhSK9baMMT2KkfKD3EI84671uc1BNQO6f/x8 sCSD0+1Pv+SUVRlwM8lLsxu2CjhEZ9ijwW56OQ8q+0+Aou5p+7+KqhvVx7fgz+ae7jgB tZqw== X-Gm-Message-State: AC+VfDyfSyKmdhhEnoZV164swSx/rkZ/ovhh37bGKTru4lDMHp/YeRxI 7ttKKPlikdV/jSLpJwtdYlnkxA== X-Google-Smtp-Source: ACHHUZ4PSgErdZ8NJTs0chVMfI9TMPT7A9df2ZIGBR9gdsMW36zPyxZu26pNz17IAR/DKjBDG06eBg== X-Received: by 2002:ac2:4a7c:0:b0:4f3:a99f:1ea7 with SMTP id q28-20020ac24a7c000000b004f3a99f1ea7mr1887107lfp.55.1686142035009; Wed, 07 Jun 2023 05:47:15 -0700 (PDT) Received: from uffe-tuxpro14.. (h-94-254-63-18.NA.cust.bahnhof.se. [94.254.63.18]) by smtp.gmail.com with ESMTPSA id z7-20020a19f707000000b004f4b3e9e0cesm1781708lfe.297.2023.06.07.05.47.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 05:47:14 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Cristian Marussi , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Nikunj Kela , Prasad Sodagudi , Alexandre Torgue , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 15/16] firmware: arm_scmi: Extend perf support with OPP from genpd providers Date: Wed, 7 Jun 2023 14:46:27 +0200 Message-Id: <20230607124628.157465-16-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230607124628.157465-1-ulf.hansson@linaro.org> References: <20230607124628.157465-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230607_054716_976494_E930E615 X-CRM114-Status: GOOD ( 14.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org To enable a genpd provider to add OPPs for its attached devices, let's convert into using the dev_pm_opp_add_dynamic() API, in favor of the current dev_pm_opp_add() API. This allows us to specify the frequency, the performance level and the OPP provider type for each OPP that it may be adding. Moreover, to let callers of the ->device_opps_add() ops, to specify the OPP provider let's add a new in-parameter to it. Signed-off-by: Ulf Hansson --- drivers/cpufreq/scmi-cpufreq.c | 2 +- drivers/firmware/arm_scmi/perf.c | 15 ++++++++++----- include/linux/scmi_protocol.h | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/cpufreq/scmi-cpufreq.c b/drivers/cpufreq/scmi-cpufreq.c index 78f53e388094..a3f89a4ca899 100644 --- a/drivers/cpufreq/scmi-cpufreq.c +++ b/drivers/cpufreq/scmi-cpufreq.c @@ -188,7 +188,7 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy) */ nr_opp = dev_pm_opp_get_opp_count(cpu_dev); if (nr_opp <= 0) { - ret = perf_ops->device_opps_add(ph, cpu_dev, domain); + ret = perf_ops->device_opps_add(ph, cpu_dev, domain, false); if (ret) { dev_warn(cpu_dev, "failed to add opps to the device\n"); goto out_free_cpumask; diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c index 03a496ccc603..b6cebe45fbc8 100644 --- a/drivers/firmware/arm_scmi/perf.c +++ b/drivers/firmware/arm_scmi/perf.c @@ -581,21 +581,26 @@ static void scmi_perf_domain_init_fc(const struct scmi_protocol_handle *ph, } static int scmi_dvfs_device_opps_add(const struct scmi_protocol_handle *ph, - struct device *dev, u32 domain) + struct device *dev, u32 domain, bool genpd) { int idx, ret; - unsigned long freq; + struct dev_pm_opp_data opp_data; struct perf_dom_info *dom; struct scmi_perf_info *pi = ph->get_priv(ph); dom = pi->dom_info + domain; for (idx = 0; idx < dom->opp_count; idx++) { - freq = dom->opp[idx].perf * dom->mult_factor; + memset(&opp_data, 0, sizeof(opp_data)); + opp_data.level = dom->opp[idx].perf; + opp_data.freq = dom->opp[idx].perf * dom->mult_factor; + opp_data.provider = genpd ? DEV_PM_OPP_TYPE_GENPD : + DEV_PM_OPP_TYPE_NONE; - ret = dev_pm_opp_add(dev, freq, 0); + ret = dev_pm_opp_add_dynamic(dev, &opp_data); if (ret) { - dev_warn(dev, "failed to add opp %luHz\n", freq); + dev_warn(dev, "failed to add opp %luHz\n", + opp_data.freq); dev_pm_opp_remove_all_dynamic(dev); return ret; } diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h index 21aea1b2a355..ec421107f94c 100644 --- a/include/linux/scmi_protocol.h +++ b/include/linux/scmi_protocol.h @@ -136,7 +136,7 @@ struct scmi_perf_proto_ops { int (*transition_latency_get)(const struct scmi_protocol_handle *ph, u32 domain); int (*device_opps_add)(const struct scmi_protocol_handle *ph, - struct device *dev, u32 domain); + struct device *dev, u32 domain, bool genpd); int (*freq_set)(const struct scmi_protocol_handle *ph, u32 domain, unsigned long rate, bool poll); int (*freq_get)(const struct scmi_protocol_handle *ph, u32 domain, From patchwork Wed Jun 7 12:46:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13270723 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3D5BAC77B7A for ; Wed, 7 Jun 2023 13:49:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=MVtBdlVcsdKinNQAIWUxbImK6EpdlMUrkRxmOiwn6HI=; b=jSRSdeQqyzfiOt tIrGxFm8Lh8SmQS/tq2/l218z5424V0WOqMZ8UoBmQfPMXibzjI+nlI96tHHuOuyoeawnWZxE/pBr uAg7eS2cLIcEdzA4sgMGlNxsJw5B18uKLN0RYXxqkGdU2ChhJJWjrnTKzrCypFXAli76EvTp5CZBd 1Pe5zudXbkAqf5nZYETVpwfBw3pPBYqX/ORYmmTSi7IKBmpEHtBDmyru2K5fAoBKJ/5RvmHdfbls0 OTG2wWNxZKJ4hQFhQwxkBPcAW8bUX5PtMiEg/jrTjWzYsrVXkorLKuQx8z2AYbKWbP2Vh0DzOGCxV 59/m6upohY7R3jXldzkA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6tXd-006944-2a; Wed, 07 Jun 2023 13:49:37 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6tXb-00692r-1w for linux-arm-kernel@bombadil.infradead.org; Wed, 07 Jun 2023 13:49:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=sGjeBJdPgpOaGz5axPE4yJTdC/ZTW7+SftWuRdijnGw=; b=eecBNxnll2tzVRKetWYhs4aWOO OsA+CWnCskKYND6tG26y9LCfHkiYjJkBMaqbxVRAW7hFFfWu3oqjrso+uANVEQGNfuu7Qc6NDN9qZ 9ek1XhTp/PzIaHzN9NAsvhIVpWDBomYr1L5yZ/ZT8hBDSicxxeQA/mWPYIdKzoHFBLS+Fdwft3jlb ZicFQnInAiX+32ZH2pAgREVeM3r13f1QvgtozMZ+7HjFXlZ+365E1FjnQm0VV0ceUWk5zJHG9j+2w uK+1Et9pZcpx7ltFsMqt7Z9lH3RF0Mvo2yBOeF2pZ+KR7laZ97Lk1p9UphS0q8ctxn/ZDtKWFhN5u joslBEKA==; Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6sZK-0059Rj-01 for linux-arm-kernel@lists.infradead.org; Wed, 07 Jun 2023 12:47:19 +0000 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-4f63006b4e3so3115153e87.1 for ; Wed, 07 Jun 2023 05:47:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686142036; x=1688734036; 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=sGjeBJdPgpOaGz5axPE4yJTdC/ZTW7+SftWuRdijnGw=; b=VhYSwRGwS2Sjs65Fop8qjr5mb66J9YNLa2a4RVeqznMNY8oO0QyaMsQCuzvqLszHNH +m+3Z2jKOhP8JcJry3+rXyqTJwH9JWmQ5P+HiZPCTfHMTkmGy+dnKDCQHQgLsemnl5B3 R1ZOy7rmwRXi+6NSUARdAclEsYiigmQA5dXPRTqwC9WawsqQxWNrzIEvt5e9mAp5FnGY Giliu/jZ0fun/02VZ81sjzagUR7E8YFJ2uuTBXJXS/dlWSd/GmKEQV520EUk5BDxtiC8 0exykeNw/LlLVWVwXf2patkeFJ8kk3m4CrnIZLeyNNbeQTcgIOu7AMhrUJ1zKH5zWWA+ il2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686142036; x=1688734036; 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=sGjeBJdPgpOaGz5axPE4yJTdC/ZTW7+SftWuRdijnGw=; b=FGNf+AqBRmvFoK1fzjL/YI+EaBkywh5k2lPqqT+52Rln/39iTLESNwKCq7n9FwDGBK SP9sCzwzWjjODBGeozRkQ+tGlQWc+keMCe3so50fJrpI/00AgwbAy1Mv4x1BhqvqwK0j zADtpVwCmch45URE1GQ/wRi3WO29lU9l7abLii57ezaiMB4hWtQVoKPLort97zJH57/L ZfYhUW4bGblzPt2zXwxH1BfYRdY/4VdOe4UY9XUpqJNtDepbdnal/vXRNFExZrFIPJSv lO6BbMsTmPdlbwKTZbR/7NNUU4GR0SGHSC8DvcvJEz9x/djp21znRQoPVZ47hJssxDWw B1QA== X-Gm-Message-State: AC+VfDyUZvSbb9Itri/MgB97XJ1ThvAN9wLvEIuxMxna38TiLdCMaHKQ 7pMmhoy0jrRLX8ELzN88XbBGoQ== X-Google-Smtp-Source: ACHHUZ5gTklOwjvOofwGZaihoVmls0o7/kAM9MgICb3wsd0mnMkP7hrhOgNnZgkaFaScq2dXEcyutw== X-Received: by 2002:ac2:5ded:0:b0:4f6:3000:4d4d with SMTP id z13-20020ac25ded000000b004f630004d4dmr2388353lfq.38.1686142036186; Wed, 07 Jun 2023 05:47:16 -0700 (PDT) Received: from uffe-tuxpro14.. (h-94-254-63-18.NA.cust.bahnhof.se. [94.254.63.18]) by smtp.gmail.com with ESMTPSA id z7-20020a19f707000000b004f4b3e9e0cesm1781708lfe.297.2023.06.07.05.47.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 05:47:15 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Cristian Marussi , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Nikunj Kela , Prasad Sodagudi , Alexandre Torgue , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 16/16] firmware: arm_scmi: Add generic OPP support to the SCMI performance domain Date: Wed, 7 Jun 2023 14:46:28 +0200 Message-Id: <20230607124628.157465-17-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230607124628.157465-1-ulf.hansson@linaro.org> References: <20230607124628.157465-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230607_134718_134292_9C92892D X-CRM114-Status: GOOD ( 17.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org To allow a consumer driver to use the generic OPP library to scale the performance for its device, let's dynamically add the OPP table when the device gets attached to the SCMI performance domain. Signed-off-by: Ulf Hansson --- drivers/firmware/arm_scmi/scmi_perf_domain.c | 34 ++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/firmware/arm_scmi/scmi_perf_domain.c b/drivers/firmware/arm_scmi/scmi_perf_domain.c index 9be90a7d94de..e9767ca1d34f 100644 --- a/drivers/firmware/arm_scmi/scmi_perf_domain.c +++ b/drivers/firmware/arm_scmi/scmi_perf_domain.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -39,6 +40,37 @@ scmi_pd_set_perf_state(struct generic_pm_domain *genpd, unsigned int state) return ret; } +static int +scmi_pd_attach_dev(struct generic_pm_domain *genpd, struct device *dev) +{ + struct scmi_perf_domain *pd = to_scmi_pd(genpd); + int ret; + + /* + * Allow the device to be attached, but don't add the OPP table unless + * the performance level can be changed. + */ + if (!pd->can_level_set) + return 0; + + ret = pd->perf_ops->device_opps_add(pd->ph, dev, pd->domain_id, true); + if (ret) + dev_warn(dev, "failed to add OPPs for the device\n"); + + return ret; +} + +static void +scmi_pd_detach_dev(struct generic_pm_domain *genpd, struct device *dev) +{ + struct scmi_perf_domain *pd = to_scmi_pd(genpd); + + if (!pd->can_level_set) + return; + + dev_pm_opp_remove_all_dynamic(dev); +} + static int scmi_perf_domain_probe(struct scmi_device *sdev) { struct device *dev = &sdev->dev; @@ -92,6 +124,8 @@ static int scmi_perf_domain_probe(struct scmi_device *sdev) scmi_pd->genpd.name = perf_ops->name_get(ph, i); scmi_pd->genpd.flags = GENPD_FLAG_OPP_TABLE_FW; scmi_pd->genpd.set_performance_state = scmi_pd_set_perf_state; + scmi_pd->genpd.attach_dev = scmi_pd_attach_dev; + scmi_pd->genpd.detach_dev = scmi_pd_detach_dev; ret = perf_ops->level_get(ph, i, &perf_level, false); if (ret) {