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: 690447 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82657C77B7A for ; Wed, 7 Jun 2023 12:47:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240830AbjFGMrC (ORCPT ); Wed, 7 Jun 2023 08:47:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240591AbjFGMrA (ORCPT ); Wed, 7 Jun 2023 08:47:00 -0400 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D7E61BD4 for ; Wed, 7 Jun 2023 05:46:57 -0700 (PDT) Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-4f4b384c09fso8859325e87.3 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=F3XSw6eTq/qeBDGsiCi7DxUSUHzzxPdFxqCB6T1U6Ee4ToYClni0PYz9gBi0YpnArw kSxAm0/lV6y6vGoIjN+yEv9nAGhqx1Mm7Qa5uHNR8EoCrmi7KVuBhruMB6Vn59GTyRT2 nqPAH11JNuEEqGuTuyI29tq9U2+8vI/jR80uvf3wWv9YBHxfECf7cbhYYy3CgxzUdI4C Bg1DIn5dVbcdb8wqBryuw+hqdfqDC01/9b4PzvChLYRvO8ketDwmEgZi3bJsGyT6tOy1 +ho8eBBbhXcwfsmWSC8H9U8ORv/1hesc2OK3GZDSCoKFI8Baul1yJ+AwEoud+FdkMqGy mH8A== X-Gm-Message-State: AC+VfDz7tsg2QOlpsMYSqt9PgJHPsmNtiUiMa2URnfTYoQ1DhFvgF0jp gj41onHBj/PVs/8Mo+AwyiwXCA== 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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.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: 690778 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 165B0C7EE23 for ; Wed, 7 Jun 2023 12:47:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240952AbjFGMrD (ORCPT ); Wed, 7 Jun 2023 08:47:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240743AbjFGMrA (ORCPT ); Wed, 7 Jun 2023 08:47:00 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F310173A for ; Wed, 7 Jun 2023 05:46:58 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-4f6454a21a9so524512e87.3 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=WFAmrZ92wzP7Puo9D+zyt0cigbXiih2bnx0tLehpCdiNsoZD6uJAUYVk5CUg9dOB48 1ujZjmq+z3mQv7Qh7u/XRwX1LJuKxE0MSmkfRlJW3HSEvg0WTMNUU4gDdFeQvxDxWVAE +gytUy8R4c7HnFj2v/jVOpDa7SLu4IXXx1DXh1OJopqsve/lLdcc75LGUDoD/qzqQ9o3 sNhe4Fp8sUkFZP0oy8fuDe3boJWPCBzIKaJfDjqoY4mu1JqGrx9I5N1WorIsrqoCRxeO bRbXA1wXjRd8BgIxcCTOfUVsEyEweg8u/jf9k85KwW4GpPAbzLqiFYYnE7ffuGPtYjF6 FztQ== X-Gm-Message-State: AC+VfDxOzMPxEm/D1pdYm1uKNB9wTV1YyPQdz88RYuxBx/pAO9zvtNmC VAfIcvXn/T4ghZYeOM4gFtv3mQ== 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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.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: 690446 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43A13C77B7A for ; Wed, 7 Jun 2023 12:47:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240259AbjFGMrD (ORCPT ); Wed, 7 Jun 2023 08:47:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240754AbjFGMrB (ORCPT ); Wed, 7 Jun 2023 08:47:01 -0400 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E363510D2 for ; Wed, 7 Jun 2023 05:46:59 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-4f6148f9679so6776543e87.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=DeE4pZe37hokwrQ+W+TjhkpIE+M/1pX4Pq+ng8U0XSv+dLJtzOJ7EKkhbvhbLuJfGA mR3lZMz4d4XTfugOHOIKDPCyE6PzbQisWjbDjsrffEFWWDLD1i75QvFOMKP17AV0FPOL 24IraYwQShT9kwYgPp7OoGmP5cofpitq+9gxIQ0TYLNi89a7tOGxxw05eSbSGdf+JcSr Wd8nuT4dvwuKA3oG5Cf4W8XnDTlF9Q3wDnIFHYl10VNp24BgnDj7gnHSy8cX98sGVKb7 5uw2HPG2tI3T2p/ebtIS6FfhG/MVYEjxM+8FW8YZjc753m+wE+NZpLhYDJPjbkt5eayI iZPA== X-Gm-Message-State: AC+VfDyUptdqj/msDXU3Rv1SFLTjnEVHzl86mdkd23KEFE0wTN2+OIg0 GuUIZ2m1UsUw7hmEqVajVIz0+w== 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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.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: 690777 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D899C7EE29 for ; Wed, 7 Jun 2023 12:47:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241001AbjFGMrF (ORCPT ); Wed, 7 Jun 2023 08:47:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240926AbjFGMrC (ORCPT ); Wed, 7 Jun 2023 08:47:02 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 531E31993 for ; Wed, 7 Jun 2023 05:47:01 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-4f62d93f38aso3948894e87.0 for ; Wed, 07 Jun 2023 05:47:01 -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=AB/NIwAZuSXQRO6GNT/OarYruSHonkJ4W0QlwJ+4hAmiz39KbMP8b9xzGvVs4IzMOF xGbGRZaIi17x2O0/kfKBwXQZrZjFK5qKLwXCE6N0Ws8GIktQEPtU8O+qRg9K1z6p6Occ Rr/2iaHBBrviptxyUqrV84GMN/elNK9OaS60SyjUv+v7jDqrUicsV2/Tox7GqkfqnEyX sOilZvv2LbCwyBbvkGUGFxFhMjTHqrm/ddiyT/oNz71W1JZP+6qgiZO90I+GVwkZnUQW 9HG/qY9Wf4lHKrOc2KpK3llR2o1WUj6Ot75w8pISvhF+gM4K2Jp1aMU5CHOuG063v0ZB IVqg== X-Gm-Message-State: AC+VfDyPbDsAsiTxPEAvAXaWzmXb+t1N1Cope2+RnfVWMzPOqDofkHPR rUhojs+q2Ur0yZRTceiGhZFPRA== 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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.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: 690445 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7B19C7EE23 for ; Wed, 7 Jun 2023 12:47:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241032AbjFGMrG (ORCPT ); Wed, 7 Jun 2023 08:47:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240883AbjFGMrE (ORCPT ); Wed, 7 Jun 2023 08:47:04 -0400 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0D8A10DE for ; Wed, 7 Jun 2023 05:47:02 -0700 (PDT) Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2b1c5a6129eso45126901fa.2 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=SnjPpIBoWdJaV4JYitsT6uFoPh1oqDrqut5mb3p6caLYgfjL9QQOZyeirtPBl4KfqN 0PSJsAaK7lOdaJRJRFzDgf8ZnNo73j8hoAz1RSx4yzm0uoBvy0kIYtZTAyXIen8K+tME icNdkChvW5GVPxuQOpnhnbEEGnTNd713mz0YwZHKFySdUgXUXOigg1STuzCmHLNqLX1Q 3fsofuej8WxaqeCUGEYPEC5exp5xsoUaWzxxo74qMeKG0c9q1rhDuZYb/+WUuFJXwoHn Jq2obdwJfTfCfCqVG9H+OScSTxi8bfbgEyGQcygWhBEZqrUCAykWR7Y+61IoCoCRNLc2 5HZg== X-Gm-Message-State: AC+VfDytCRZtw8ZR8aIRsghsBsOnFYhaTMOwoWWDGaRwI0ueuU8FIooh YT1/3p+aFPziI48zu+JrDL717A== 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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.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: 690776 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F0EAC7EE23 for ; Wed, 7 Jun 2023 12:47:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241062AbjFGMrZ (ORCPT ); Wed, 7 Jun 2023 08:47:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240997AbjFGMrF (ORCPT ); Wed, 7 Jun 2023 08:47:05 -0400 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49A2F1993 for ; Wed, 7 Jun 2023 05:47:04 -0700 (PDT) Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-4f62b552751so4169302e87.3 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=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=WTfHO+fI0fc9c3uED7HEphr3iq3PPWzEMYQWDh2zIFOt2NBDQtFaP2k2z3q+0BsXI/ lKOSx/q/27kMFnuy0OLDN/2lDkKVD9adHmpVxleUmXYgdxAZ4CjsrOe5i6WHh+xfMhD4 rP4tkTLgQTN7/haPNrsyhRCUYdu4TkSPbObHJejc9RrsWRPcMDeK/uExFhVVe/kPsZf3 1YUDy3byeLE/Q2loZv8wG6BtdsqJbCBPWtZ+GqVH+d3ZoxP6oP3IPGtG+Q5yJTPF1Tij pFQqVQ0Cr+pr3WeQXwuBy+qcZM6KwzrYc0u81y89rMTUQU+cOeVc6OZeoaby3Q322tzZ DIBA== X-Gm-Message-State: AC+VfDzcA2rRnDiW66GkZrkB4JHaq1PIlR5h+w+aVyYoc10EGzyU5qgw rh4qTRbQWl6pTSdSEYuYRULZIg== 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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.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: 690444 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4EED0C7EE29 for ; Wed, 7 Jun 2023 12:47:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241071AbjFGMrZ (ORCPT ); Wed, 7 Jun 2023 08:47:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241038AbjFGMrH (ORCPT ); Wed, 7 Jun 2023 08:47:07 -0400 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4834D19AC for ; Wed, 7 Jun 2023 05:47:05 -0700 (PDT) Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2b1badb8f9bso54841451fa.1 for ; Wed, 07 Jun 2023 05:47:05 -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=Rb7I7XZjsvcH0guV4RsPKkws53ySrUVwO6GITwhXzlIfhNdrm8+GVrUllpCefGdTsw u++eL82EfusBtaJPbOSO+uUNuKahS28+uaouONwO/Jl8wTEFavzqOEhjY+VN+OqUVG9H RCrQHApiav2SWilMUiv/OAwBYXOtsXPfIB5hmbXs4fs4kjvf3WXVix89vGH1OBu2BokQ S292tgRaNqk1bFD6vy7KwzCirO5ysMVpwGy1/RKPAuuPf1NewyHzy3ODH7t7VbegUZtx k0eTgMdrg0g2eG21mUiU2jrQjzR9qx9KIT3Bm5Vn+AfGD7GxHjFAMotORl2itMxpxoRQ NaKg== X-Gm-Message-State: AC+VfDxyqI1iYigngN8uAkL4pn/uZ2k8d83L7jNw9xL+2CytaIhKisLI 7YkCJu4F0B5GlngdifDQ2IYAEw== 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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.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: 690442 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 052BDC83005 for ; Wed, 7 Jun 2023 12:47:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235852AbjFGMra (ORCPT ); Wed, 7 Jun 2023 08:47:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235396AbjFGMrJ (ORCPT ); Wed, 7 Jun 2023 08:47:09 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC4821BD6 for ; Wed, 7 Jun 2023 05:47:06 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-4f60a27c4a2so8475902e87.2 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=eJY+2SmoqhyLFBkgW0A8rqEJaQ6PGexmpBe/FU5jTp3UbJo/9Z6vXm+9uLzfh7rud3 LsOzMZEuU7goXJ7bRHC1NFAwisa6ZqBFiRK2nguZSstTrBNHqoyfd8NS6orCbJ5ApeJd bcVvlOUbbpjaaKq992YUIthS3BC3ju6oOG+8678OP/20o7oID3cg6g+EgZmMKHah0fXl LbAvdpJN75LxBdWhDp9P5q32CVFciztIKBTL8xAal/jRwYWUSqDbPJuVtN8Ys1+zOy/U 4Q4HyQRDmJsgFfVsNnWdaV01JTbqaN/cmZxFfY6AkcDw8udxOENiRE7XuNKHi9A50DDv Ui7g== X-Gm-Message-State: AC+VfDwX+DmJbxDWLwg6vsQ+ugXNKf1eaOs69fbs5ozV57MBB+JOq5Mo kv/UlnbvNoxsPuBLr8DjHjoqShbu45yx2142WUA= 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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.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: 690443 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D588C77B7A for ; Wed, 7 Jun 2023 12:47:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241065AbjFGMr3 (ORCPT ); Wed, 7 Jun 2023 08:47:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240931AbjFGMrN (ORCPT ); Wed, 7 Jun 2023 08:47:13 -0400 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4ECA31BE2 for ; Wed, 7 Jun 2023 05:47:08 -0700 (PDT) Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-4f6454a21a9so524706e87.3 for ; Wed, 07 Jun 2023 05:47:08 -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=PyNXZXIRCbHWBb47jYkTd9n7KwHc3L4pl3VmRsceX75OR2RA4CE56f/HYhbik5Nhrw B28CrM8j975IfFg0ZgBQn8tVVtGA4f1s4qdiMjmNcoKbiyf1SA7Q38+sWoKzwzXUEL01 6vm4NHreEEfkjvPcELq0M2OEXDWixGJeOr289np8rzMSwvwBLcrvzpE8U2c9BT6xZEtw 5ljFZgOf2f6gh1uGDHvoxaVqPVMxmfUciqcAhsEV1M22JAq5iytitkfUyByfaMOUWo5Y brJv2iBnZST24vd2UUg5SyCEzHm+u3uAA5xb35GZYBXnIC2pWc0liBNoB7oYzXQ32AVu REGQ== X-Gm-Message-State: AC+VfDw8ziPwFvbxC5WwlTpau1p9jcd5XoZyyxHnAX46PWWVDK8MpBEW Jz/AqEgRvZKCRUr7BUeAFSGs2g== 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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.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: 690774 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4CA5C7EE2F for ; Wed, 7 Jun 2023 12:47:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241030AbjFGMrb (ORCPT ); Wed, 7 Jun 2023 08:47:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239432AbjFGMrY (ORCPT ); Wed, 7 Jun 2023 08:47:24 -0400 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 818221BE5 for ; Wed, 7 Jun 2023 05:47:08 -0700 (PDT) Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-4f4b384c09fso8859631e87.3 for ; Wed, 07 Jun 2023 05:47:08 -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=eOU5kBfQ6NnLR3ch82D1pQSa4CUXahF7a0WfUO+detNI63UtH/rQEyeJft8nv+L3nk CAJRakIqAGFBxvhQfv+uIfNsW+dqyMVqm3GNqUiAB4cZ68Qk0duMm4KEtJ/KAkNFqW7D LKfUPi5RhTw84rG2YtpmVg/GC0Ih5Rc2IZxY4pl/OmUTWJq/F0qvJkThbSPqZ8n23GBg lmonPOlalcDZxPQ+xTi/2tDQzxuQqfPJfd3Le0FePCqkwPsEWLzMKzeVgG7fD6hDr+74 5kaLNVju4ZdUJYlvzQ9GtI2qX/+JmA9RrVJ+JYDoeXaPGPcTo45d6VotCfg15VMmIX3k qecw== X-Gm-Message-State: AC+VfDyPiC4/FbfquQta+tf76yFvyATQLZqzog/KfEgi6PTQG37Uij99 vm1KIdE1Z8Khd/+leqwiXgaZFj1kbYPGzaFY5ZQ= 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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.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: 690775 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6202DC7EE29 for ; Wed, 7 Jun 2023 12:47:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241090AbjFGMr2 (ORCPT ); Wed, 7 Jun 2023 08:47:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241065AbjFGMrZ (ORCPT ); Wed, 7 Jun 2023 08:47:25 -0400 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C9371FC0 for ; Wed, 7 Jun 2023 05:47:10 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-4f122ff663eso9008576e87.2 for ; Wed, 07 Jun 2023 05:47:10 -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=KoD81Cewk10XDlV7WSTp9N6dtY09DtbBSXmR7TFRyGbO7Mxv3keQ10VJAE1XZU5m9R FltQNOC9+6QT8G9YYbNj/DOSymQrP24C6Wchb/S0EVSpHyXCRaXKwXeCBYwn77QZofIt 2jcc78GLQkLwm0mGEFjP1W1iQERKioLxipDZI9oZdlmyb2FLnXo8dxoLbIjFvJJ2EvdU qQjP3tlXJNLvV2NC37+6d/ySu7h6JJXZr4aK4AkcRBbAXbjBWPl5uqlYeME7P6GkBrg/ mJSqjqXKanoqnA7X+EnQF3QHTCB+jPlDhf4zqVA9I4prXvSOQNApMJtTOc0TV4D8voSe e5Jg== X-Gm-Message-State: AC+VfDyVt4X2E0Sr85jlUK9eIpf/jOQGxULAjHs/YxDSX4WMrRWMdR4I EGCobThDvQ7kqzz0cLmSFT9iZGJhMfvRK9AfjvQ= 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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.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: 690773 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 099F3C8300C for ; Wed, 7 Jun 2023 12:47:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241100AbjFGMrc (ORCPT ); Wed, 7 Jun 2023 08:47:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240997AbjFGMrZ (ORCPT ); Wed, 7 Jun 2023 08:47:25 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 955511FC8 for ; Wed, 7 Jun 2023 05:47:11 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-4f62d93f38aso3949146e87.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=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=BftH6cnuULivX/QAkqT5HBlame7r2Wtm/g2rhZ4nU7il6JmM6HmzivBTPqXNeAkKkP QuHpsJDQBy4LhrD4D7ZwPP8MoRi4DeoT+NhbrfEzCdMnNmrd+O1+y3juCobJEW+R+czk Yz5ZmX4TPdMgtTiFumFg13tPKTqvLf+ozWMq5GA/UDpz5Ap5qL94YwdT2yNeyu7WP8y/ K7xjGRtApisCBfoYCaQzRSAfJBIL8lysOfq/VAtEXtzvLvGH5vBwOCmtYL3B/Y2Zfrql QU2tV7BxWsWSELrYhjUfOPADJZAjqHf7c8UiVhFV5AQmET3r70OgOZiFJu4AyuETSiCM ijYQ== X-Gm-Message-State: AC+VfDwBBGBVxlniFFsRh3xjpxriwugCpEmaHScTJz13T1r8bwK6peHz aIlRk5owVTXESzRH1yNjeVJyPA== 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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.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: 690441 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4BEBC77B7A for ; Wed, 7 Jun 2023 12:47:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241106AbjFGMrl (ORCPT ); Wed, 7 Jun 2023 08:47:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241038AbjFGMr0 (ORCPT ); Wed, 7 Jun 2023 08:47:26 -0400 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06C1F1FDC for ; Wed, 7 Jun 2023 05:47:14 -0700 (PDT) Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-4f62cf9755eso3783540e87.1 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=T0Yt71WSfoaa3Z6Xf/xjexCCFEivA5aWj9FAFsPL0AUkwnRIDlqG2x6+4GaYGwihvY nQD/jZQ8yTaJJ1+g1uer20PSDxRfIA2aU6qDf6Cz2k3NDoA4QRT1F5LcG5QSZb7GkfKt 6GnxAuDtgOfQxZpaTl4IXjAagwc0z2cpisk27m22OEx6maukM9x86q2uURfngMhi/1eC 645hKwKDfdpTeW5joluQ+NMIVgx0qVdRJv61aQTuQOE5Mk+u8xGePDCf6MDcvlguP5vK 6OENTwKx81uZFAZuhEtnAHzJCw+bfJamvrX9GEzAsMa7kvVb7DIGF990KBrtNE16R5Q9 8Dqg== X-Gm-Message-State: AC+VfDz0W1c5OEIXTmYojcAPz5y98yKB4Tk8fH0z1lqrFXLHLkxNYrb8 BVljI7eLWoQzVvMFTAPYWw3I7Q== 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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.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: 690772 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB553C7EE29 for ; Wed, 7 Jun 2023 12:47:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238604AbjFGMr6 (ORCPT ); Wed, 7 Jun 2023 08:47:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240754AbjFGMr2 (ORCPT ); Wed, 7 Jun 2023 08:47:28 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C44F1FF9 for ; Wed, 7 Jun 2023 05:47:15 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-4f505aace48so9204413e87.0 for ; Wed, 07 Jun 2023 05:47:15 -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=D/r88lSxFwZjmM/1BumXGjTM+8a2hvQAUQg2CegT7pdsHReCuCOOCKODju5lbbzw/u 4F9Uyv4cRdv1wGbEF7mkCiVCjZe44AVcIObMUsu7Nlpdi5F2tcmtddZV8rC4mTHfhkQA ZCLrzAlNY0LGLwNCFBSvA5EFzPOkRO5+nJf560xbI6gan4Us7QlGKQDx0fmFjuRWZSIh 8SdZlKElj2NllypF3MDbn5x4rMKq3Y9ItXgRhHoZiYjpwse8RoNiDHWlBVFK302ybFeK KrIactOvh5uCSvl835aXcodGdJso60clxhEMO+YPYHWDzILnTU/vjAOgwbhQhWnsjMwz 5Nsg== X-Gm-Message-State: AC+VfDxopaMxn1X3eYieksxhRICqEw9wN15kD25SvBUS4EK4pIk4I+Bf 3lqWB2LYdtsQczhwiRO4XND5aA== 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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.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: 690771 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C6B7C7EE23 for ; Wed, 7 Jun 2023 12:48:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236481AbjFGMsE (ORCPT ); Wed, 7 Jun 2023 08:48:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240196AbjFGMrc (ORCPT ); Wed, 7 Jun 2023 08:47:32 -0400 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B2C8210D for ; Wed, 7 Jun 2023 05:47:16 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-4f004cc54f4so9090029e87.3 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=SFOqO0iRwy3yjJnCsqhPF22+xjBdcMu/vnghczwquXJK7etLzd95QSsXE1PaZvnZCA Nuro3xJygtt3PV5OEEz7oUCwqQDpRn1SHgNtHRfD2PN0xE/OTRNK0SMVm0WLz/8AuUCo kf39IxpXepfkkZ+zcvHB7Y5T4jF6VxV2qyN8AzCBDl9TAZIcVGkYWJupr8TskKlHUPWu SWW0270jfx1EDD3Oo/bENx25/MVqXW1I9gt3S+26l6YcNooQoujmA5x+WApnHRBtCh9l zRLNPdY36rx4XEMQiNgeyM09mOKGt9b7CqZ1dT0+odtNE/CqGK8LWW9BuwRSIUHTmGAp f/Ug== X-Gm-Message-State: AC+VfDyoiBtF3F+Tw68H9Z7qARj3knkty5he5Dgsh0BaWYDQgvOBtezI MKsQDUYN8KjQSOWFXi6oT12ANw== 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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.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: 690440 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5122C77B7A for ; Wed, 7 Jun 2023 12:48:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239726AbjFGMsO (ORCPT ); Wed, 7 Jun 2023 08:48:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241099AbjFGMrc (ORCPT ); Wed, 7 Jun 2023 08:47:32 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AA6C173B for ; Wed, 7 Jun 2023 05:47:18 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-4f63a2e1c5fso2093952e87.2 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=U0ufSWH+hAVM3Ru+nPihiRltB06HKU2qgUnn6C2tomyCtejrRT25YF8dFtt4us9k8k yFbmF7fYzLo63tCYg1fBGUL532/Dya8XW1QG32FGdNv871F8sVdD/Md4v73f2U5xe7FJ EpnAjkeIrwhvB6N0DnvDtkq7gda08MiKLv9gUb96Dbp06Dj61tIZRR1L+7jFxcl81pQ9 K1o0Tq+VA1GsaD7cDiUKbIFX8z3fM8dTgRaBvBiygVH2aHzHpzwnPiMl5qyDRTim1GCt QteT9eKJJIc6xiqyHhdWoiES0x1xc5x6DorbdvvITUlKYSrNXhoFLJYcbwbD6LeSICwp q7iQ== X-Gm-Message-State: AC+VfDx/ziMRd3n2ao84RxDmk+LfBSA7EWma2HCSBhElhwx/Ef1EVIzt x/KXyS8LHpxW3PByqrvpD3xbbw== 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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.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) {