From patchwork Tue Feb 14 14:37:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 57049 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3011463wrn; Tue, 14 Feb 2023 06:38:41 -0800 (PST) X-Google-Smtp-Source: AK7set8UgmqwE2E6d2qPDBbtKpPnqTgFuVulBnLBxa+fTY4D0yKuMST0ex4K8UAyOd+LFHRFB3Na X-Received: by 2002:a05:6a20:4286:b0:bf:5d4e:1328 with SMTP id o6-20020a056a20428600b000bf5d4e1328mr2900100pzj.25.1676385521263; Tue, 14 Feb 2023 06:38:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676385521; cv=none; d=google.com; s=arc-20160816; b=Hqnu16ueTqqKiiOMVGNuQgswSJXMZF1BZA5zxT8NSWwEGeT3fDjLxPBqNDUBaPMCyx 78VNRIYz9otYVpY3XWOI6ZEIGzyGSsplG6nudLF9QzTTgC0RoQSBncaoZdBb956fcT4i 1tkGkgT9m+pVOYAlxlaCgl4pjGF+iGFtxPKGuj4yXiZB014vhX5y0QMtaHnOkAEe6+1N BzBflCqMojdhj0EjQz3NkRwJG3Zz0aiIZxGjutnQzXR681SqbY1AzETjJBw1vYwuomFC iTuR3bq0LmRIpO+EuVV21OysV+0aLlYToX+eaCFa46hhqClMFKNSfeGgyb24f1AYu3C8 kg2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=eCg1qb28rj+gFKZAL4LyzRFUv7U0u9J7xzWR97CVfk4=; b=p39RZJS/0QmGlJRnNJ2du6FPLgFtzJ+dKLbkZa+pvxWvPJeilqjjZjIFpesjG8K/fH 7QRwV+ELY5D+gYEtFTMVgtbOiLlE6QhvSrTUGjMjfsZl2gIGgdQ4CQh/pDo9I+tzYgNH ArbHklGyr6RfstemuWf30H2Pvo1Gh+D/Hs8oblC6ATat5WLIChZ6LkY93ZtRyiS0xS/x pBeiKZwuyJUudHj7VLedLNu4wrq2IU7KwT4g27QUEoFoiMoNdurcA6YE2MD4JC9WFMm4 6j2qSsLMJu5bL+83wjb/tXOjw2H3wkxpX2/1Zg8BguiZ7zC2xljl8Cg1KDqX/Tkq6upN pniA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Z3dvwBab; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y2-20020a623202000000b0059b98e82de3si14001942pfy.314.2023.02.14.06.38.28; Tue, 14 Feb 2023 06:38:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Z3dvwBab; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233035AbjBNOiE (ORCPT + 99 others); Tue, 14 Feb 2023 09:38:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229648AbjBNOiD (ORCPT ); Tue, 14 Feb 2023 09:38:03 -0500 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C06222782 for ; Tue, 14 Feb 2023 06:38:01 -0800 (PST) Received: by mail-ed1-x52a.google.com with SMTP id eq11so17681485edb.6 for ; Tue, 14 Feb 2023 06:38:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=eCg1qb28rj+gFKZAL4LyzRFUv7U0u9J7xzWR97CVfk4=; b=Z3dvwBabyJaQvCC1kbnr4v2nvDp/l7oYaIw8Wgbskb/3LrTPmcx/J90JqRdHMBWXHb lanZGKYBqLs8IrMWUUi5M7w90AXqv/iESKI/efJnvHF1og9ea/px5GQwjOXKgl2SUyBU FT0sDEbUzJMR/t/zuJMM2o+KwtyfnAVqnyegkTfNA7Rn46VO4d5bw0gQmmqAMMJ1mc3J 1bICs9a0Q4pQG4GF/ktHwpCGEyVAE7NhFfyQsvs9ewHQcoDJ42PTa5lFlGacMz2kH5qL 3smcmKyzOmAN4+S8lWorlOxCeyvv6zZrS82hzAt7YmQYiwvGpxv0Cpta29mNGyvRv7yu DHGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=eCg1qb28rj+gFKZAL4LyzRFUv7U0u9J7xzWR97CVfk4=; b=s8xnm7OboBddEZ3LsSAw+BKBL6YDo1UGnO+KAU/LCkYEbycucXgCl5tHbN6i65crPH wstHzxgKYqH8/o2UE9n7miHM1ZdCdbc5ShXJowphhE0VmrmOcc+M3/ewi5XeVyoNOv8n NgkkpPakrUtysLG+U7+Tpwgi6QNd9YkEiwQs0gsFKtG9n+NfPE8R4rwUTUXYJktS9k1L VYcbHMsjnI4POddL4cF0/ustOtJbVAGL7ynijZ/nK+TYqACPgae/z8l0jn0LnQmTrUfN Co66s+P8zbOYntqdU1zkkP+oTueFK0E+I6HML4x7rzPkYW/plhZi/k3/Wtvj6kjWDjTH tfOw== X-Gm-Message-State: AO0yUKUeu7W9U9bpd9c2o5wroDrnrIyKfixplfC5YQFRXIbzIownhcz2 FakVzF8Jj+GwSe0iYTT9kDeaGx4TVn1E5m/B X-Received: by 2002:a50:d5c2:0:b0:4ac:bdac:ce20 with SMTP id g2-20020a50d5c2000000b004acbdacce20mr2539297edj.35.1676385480174; Tue, 14 Feb 2023 06:38:00 -0800 (PST) Received: from localhost.localdomain (abxh117.neoplus.adsl.tpnet.pl. [83.9.1.117]) by smtp.gmail.com with ESMTPSA id eg21-20020a056402289500b004acb6189693sm5378052edb.83.2023.02.14.06.37.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Feb 2023 06:37:59 -0800 (PST) From: Konrad Dybcio To: linux-arm-msm@vger.kernel.org, andersson@kernel.org, agross@kernel.org Cc: marijn.suijten@somainline.org, Konrad Dybcio , Georgi Djakov , Evan Green , Jun Nie , Brian Masney , Greg Kroah-Hartman , Yassine Oudjana , Dmitry Baryshkov , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 01/12] interconnect: qcom: rpm: make QoS INVALID default, separate out driver data Date: Tue, 14 Feb 2023 15:37:09 +0100 Message-Id: <20230214143720.2416762-2-konrad.dybcio@linaro.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230214143720.2416762-1-konrad.dybcio@linaro.org> References: <20230214143720.2416762-1-konrad.dybcio@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757817624339254312?= X-GMAIL-MSGID: =?utf-8?q?1757817624339254312?= Currently, NOC_QOS_MODE_FIXED is defined as 0x0, which makes it the "default" option (as that's what uninitialized members of partially initialized structs are set to), which should really have been NOC_QOS_MODE_INVALID, and that's what people (wrongly) assumed was the case when .qos.qos_mode was not defined and what really makes the most sense.. That resulted in {port 0, prio 0, areq_prio 0, urg_fwd = false, rpm-voted} QoS being always voted for, because the code flow assumed "hey, it's fixed QoS, so let's just roll with whatever parameters are set" [again, set by partial struct initialization, as these fields were left unfilled by the developers]. That is of course incorrect, and on many of these platforms port 0 is MAS_APPS_PROC, which 9/10 times is supposed to be handled by the ap_owned path, not to mention the rest of the parameters may differ. Arguably, the APPS node is the most important one, next to EBI0.. The modes are defined as preprocessor constants. They are not used anywhere outside the driver or sent to any remote processor outside qcom_icc_set_noc_qos(), which is easily worked around. Separate the type specified in driver data from the value sent to msmbus. Make the former an enum for better mainainability. This is an implicit fix for every SMD RPM ICC driver that didn't explicitly specify NOC_QOS_MODE_INVALID on non-AP_owned nodes that don't have QoS settings. Fixes: 30c8fa3ec61a ("interconnect: qcom: Add MSM8916 interconnect provider driver") Fixes: 6c6fe5d3dc5e ("interconnect: qcom: Add MSM8939 interconnect provider driver") Fixes: 4e60a9568dc6 ("interconnect: qcom: add msm8974 driver") Fixes: 7add937f5222 ("interconnect: qcom: Add MSM8996 interconnect provider driver") Signed-off-by: Konrad Dybcio --- drivers/interconnect/qcom/icc-rpm.c | 22 ++++++++++++---------- drivers/interconnect/qcom/icc-rpm.h | 10 ++++++---- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/drivers/interconnect/qcom/icc-rpm.c b/drivers/interconnect/qcom/icc-rpm.c index df3196f72536..385a67c20956 100644 --- a/drivers/interconnect/qcom/icc-rpm.c +++ b/drivers/interconnect/qcom/icc-rpm.c @@ -48,6 +48,9 @@ #define NOC_QOS_MODEn_ADDR(n) (0xc + (n * 0x1000)) #define NOC_QOS_MODEn_MASK 0x3 +#define NOC_QOS_MODE_FIXED_VAL 0x0 +#define NOC_QOS_MODE_BYPASS_VAL 0x2 + static int qcom_icc_set_qnoc_qos(struct icc_node *src, u64 max_bw) { struct icc_provider *provider = src->provider; @@ -153,7 +156,7 @@ static int qcom_icc_set_noc_qos(struct icc_node *src, u64 max_bw) struct qcom_icc_provider *qp; struct qcom_icc_node *qn; struct icc_provider *provider; - u32 mode = NOC_QOS_MODE_BYPASS; + u32 mode = NOC_QOS_MODE_BYPASS_VAL; int rc = 0; qn = src->data; @@ -167,18 +170,17 @@ static int qcom_icc_set_noc_qos(struct icc_node *src, u64 max_bw) return 0; } - if (qn->qos.qos_mode != NOC_QOS_MODE_INVALID) - mode = qn->qos.qos_mode; - - if (mode == NOC_QOS_MODE_FIXED) { - dev_dbg(src->provider->dev, "NoC QoS: %s: Set Fixed mode\n", - qn->name); + if (qn->qos.qos_mode == NOC_QOS_MODE_FIXED) { + dev_dbg(src->provider->dev, "NoC QoS: %s: Set Fixed mode\n", qn->name); + mode = NOC_QOS_MODE_FIXED_VAL; rc = qcom_icc_noc_set_qos_priority(qp, &qn->qos); if (rc) return rc; - } else if (mode == NOC_QOS_MODE_BYPASS) { - dev_dbg(src->provider->dev, "NoC QoS: %s: Set Bypass mode\n", - qn->name); + } else if (qn->qos.qos_mode == NOC_QOS_MODE_BYPASS) { + dev_dbg(src->provider->dev, "NoC QoS: %s: Set Bypass mode\n", qn->name); + mode = NOC_QOS_MODE_BYPASS_VAL; + } else { + /* How did we get here? */ } return regmap_update_bits(qp->regmap, diff --git a/drivers/interconnect/qcom/icc-rpm.h b/drivers/interconnect/qcom/icc-rpm.h index a49af844ab13..8ba1918d7997 100644 --- a/drivers/interconnect/qcom/icc-rpm.h +++ b/drivers/interconnect/qcom/icc-rpm.h @@ -97,10 +97,12 @@ struct qcom_icc_desc { unsigned int qos_offset; }; -/* Valid for both NoC and BIMC */ -#define NOC_QOS_MODE_INVALID -1 -#define NOC_QOS_MODE_FIXED 0x0 -#define NOC_QOS_MODE_BYPASS 0x2 +/* Valid for all bus types */ +enum qos_mode { + NOC_QOS_MODE_INVALID = 0, + NOC_QOS_MODE_FIXED, + NOC_QOS_MODE_BYPASS, +}; int qnoc_probe(struct platform_device *pdev); int qnoc_remove(struct platform_device *pdev);