From patchwork Mon Feb 12 12:32:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Marussi X-Patchwork-Id: 199736 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2407591dyd; Mon, 12 Feb 2024 05:00:06 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU1dVnxx+XqGR/OgFNrJzLg6e3cWDVlFRU+V/dbymc45wj8cIITf2KZQp06CaCkCwYdc7sp85pjKrc4y/Ry25emb/ZJww== X-Google-Smtp-Source: AGHT+IFo4LYUZ+i28+gXmtJCkK3NWtPvshjlKXlBKTcbN6Xcf250DHUCrlekElkTX2GW85TSkAmF X-Received: by 2002:a17:903:1250:b0:1d9:8bb5:7497 with SMTP id u16-20020a170903125000b001d98bb57497mr10216356plh.40.1707742806158; Mon, 12 Feb 2024 05:00:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707742806; cv=pass; d=google.com; s=arc-20160816; b=LEnAa2qa7fkUJadVkEKSOHCaM5sy/ZI+i6bre8FYpRV9NdJNVjmYBZZU6pvSM1YVpt YCBl1Jlwr6hWFvfr3NcvUQBZXiS1KIOXItmv+dudqPdFrt0tcQ5yFn2q/ruj1i0qzJB3 DGcT4EIRWRXF+5K+DjvZ3mPMqAXk9Ms192OJFsy7zHyaAYY51MwIkNJOMG313ggU5egG RX99zttdyy+lzUw53V2j9sbZ1zvGMoG8pCcuBxRQgYYXfUWiikk2oH55WdEvoa65+uGk 7D8316R9EoPWQlrBvKivdz9YXdE3sxvceF63q+tPJzqBzRo5Ai8Q6CjJX2n+VMvOoAl5 YUIA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=/5hHFSue9LLilvSYJyUEMABesIVy5lV4lvQcwiDdYos=; fh=wdz5rw4SylrR6H5yYZWyb4g0f6WgTEs9UhDNfoJkguw=; b=lSDkShHpC4cXLH1eKj0yAWT1wSCg4GmXlg7H8ISwL0vAK6C1tekno2LeDhtMipImzw jJjeqyvj2551fAhCklPOAxC+RKq1o+QFbtkqVM4BJniVZ8TsOE/lG/gb1J3MMN5oAw2B ZgswDeEIyn3PipwJynXBlGZI9aqnje+PgnNAgj3Ldjj+mmuLf3+vo7Ma7LffkxjXL4WD bkt9WlIJiHfTNaVGSbPW39E6k9BDy2XH3fUitrUC7uvV5HzpOLaBo9AOjvGqcaRnBTwi po/lS2izp60uw0pbwtVcSkuk/Os6xV0ER7DJ70cLq/A8k7UNmFapcFYRbcngjTae3AxR +gAQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-61557-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61557-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=2; AJvYcCXy7HtPy8McgX6jGERW2jaAHVsjibMwvR57PuVDysULUvrxMLa5mBJDPnAjwvkf+ckM6WyFvCIa+YS/nKyxGFMtf3hB9Q== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id mf6-20020a170902fc8600b001d7313028e5si214830plb.430.2024.02.12.05.00.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 05:00:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61557-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-61557-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61557-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 5ABDAB25247 for ; Mon, 12 Feb 2024 12:35:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D59803CF45; Mon, 12 Feb 2024 12:33:21 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B8A973C470 for ; Mon, 12 Feb 2024 12:33:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707741200; cv=none; b=Y5FH2vpzstC+8DvPfOeeJ4KSQ7kqF617LY1FbB/lu8dZ3xF5fJh17m+mnlA4Xc4Uywi58GIYCXTSbUbRt5Re7gQcW2oAayPFXL4qB2hUfBfDv2kzYo4kIR2wYXc8ZH/Oulw1esJEZyNP8uOsXO9ZoP09KZ2mj/JBfV07YQfFhNo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707741200; c=relaxed/simple; bh=yXhEbCbYSCQ4YzJa83bk7mpJs0n/q8sL94l7OJKG/SM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KDF7m+LjsXC/x19HoxEqhUJ/SXJ/zjCe5Cv+zssHaE5RLXcEr8A/xiFj9uaGe+IQenyjF6COuW1kqLbt4qUp/cvOvkwS5wowPmf5wMOAVLRGtkWItvpnJm0AIfiVpTXGqZ3R4E1d+1NPNJ8o14uFSDC7MsFUqESY0NODYza/RJ0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7ACBC1063; Mon, 12 Feb 2024 04:33:59 -0800 (PST) Received: from pluto.fritz.box (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AD85F3F7BD; Mon, 12 Feb 2024 04:33:16 -0800 (PST) From: Cristian Marussi To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: sudeep.holla@arm.com, vincent.guittot@linaro.org, peng.fan@oss.nxp.com, michal.simek@amd.com, quic_sibis@quicinc.com, quic_nkela@quicinc.com, souvik.chakravarty@arm.com, Cristian Marussi Subject: [PATCH 10/11] firmware: arm_scmi: Use opps_by_lvl to store opps Date: Mon, 12 Feb 2024 12:32:32 +0000 Message-ID: <20240212123233.1230090-11-cristian.marussi@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240212123233.1230090-1-cristian.marussi@arm.com> References: <20240212123233.1230090-1-cristian.marussi@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790698121004887284 X-GMAIL-MSGID: 1790698121004887284 Store all the discovered OPPs into the XArray opps_by_lvl even when level_indexing mode is not used, since it comes handy to easily retrieve OPPs by level. Signed-off-by: Cristian Marussi --- drivers/firmware/arm_scmi/perf.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c index 2627ace5b07f..e20d137a92f6 100644 --- a/drivers/firmware/arm_scmi/perf.c +++ b/drivers/firmware/arm_scmi/perf.c @@ -326,9 +326,9 @@ scmi_perf_domain_attributes_get(const struct scmi_protocol_handle *ph, dom_info->id, NULL, dom_info->info.name, SCMI_MAX_STR_SIZE); + xa_init(&dom_info->opps_by_lvl); if (dom_info->level_indexing_mode) { xa_init(&dom_info->opps_by_idx); - xa_init(&dom_info->opps_by_lvl); hash_init(dom_info->opps_by_freq); } @@ -371,13 +371,21 @@ static int iter_perf_levels_update_state(struct scmi_iterator_state *st, } static inline void -process_response_opp(struct scmi_opp *opp, unsigned int loop_idx, +process_response_opp(struct device *dev, struct perf_dom_info *dom, + struct scmi_opp *opp, unsigned int loop_idx, const struct scmi_msg_resp_perf_describe_levels *r) { + int ret; + opp->perf = le32_to_cpu(r->opp[loop_idx].perf_val); opp->power = le32_to_cpu(r->opp[loop_idx].power); opp->trans_latency_us = le16_to_cpu(r->opp[loop_idx].transition_latency_us); + + ret = xa_insert(&dom->opps_by_lvl, opp->perf, opp, GFP_KERNEL); + if (ret) + dev_warn(dev, "Failed to add opps_by_lvl at %d - ret:%d\n", + opp->perf, ret); } static inline void @@ -385,16 +393,21 @@ process_response_opp_v4(struct device *dev, struct perf_dom_info *dom, struct scmi_opp *opp, unsigned int loop_idx, const struct scmi_msg_resp_perf_describe_levels_v4 *r) { + int ret; + opp->perf = le32_to_cpu(r->opp[loop_idx].perf_val); opp->power = le32_to_cpu(r->opp[loop_idx].power); opp->trans_latency_us = le16_to_cpu(r->opp[loop_idx].transition_latency_us); + ret = xa_insert(&dom->opps_by_lvl, opp->perf, opp, GFP_KERNEL); + if (ret) + dev_warn(dev, "Failed to add opps_by_lvl at %d - ret:%d\n", + opp->perf, ret); + /* Note that PERF v4 reports always five 32-bit words */ opp->indicative_freq = le32_to_cpu(r->opp[loop_idx].indicative_freq); if (dom->level_indexing_mode) { - int ret; - opp->level_index = le32_to_cpu(r->opp[loop_idx].level_index); ret = xa_insert(&dom->opps_by_idx, opp->level_index, opp, @@ -404,12 +417,6 @@ process_response_opp_v4(struct device *dev, struct perf_dom_info *dom, "Failed to add opps_by_idx at %d - ret:%d\n", opp->level_index, ret); - ret = xa_insert(&dom->opps_by_lvl, opp->perf, opp, GFP_KERNEL); - if (ret) - dev_warn(dev, - "Failed to add opps_by_lvl at %d - ret:%d\n", - opp->perf, ret); - hash_add(dom->opps_by_freq, &opp->hash, opp->indicative_freq); } } @@ -424,7 +431,8 @@ iter_perf_levels_process_response(const struct scmi_protocol_handle *ph, opp = &p->perf_dom->opp[st->desc_index + st->loop_idx]; if (PROTOCOL_REV_MAJOR(p->version) <= 0x3) - process_response_opp(opp, st->loop_idx, response); + process_response_opp(ph->dev, p->perf_dom, opp, st->loop_idx, + response); else process_response_opp_v4(ph->dev, p->perf_dom, opp, st->loop_idx, response);