Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp173874ybt; Thu, 9 Jul 2020 18:59:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNQ/dW16KSrfgUNoKO+C7I4KJ1gE6tInhnsKMOVB5C92m/x9i5njceAJxgn+/4D0NEB8op X-Received: by 2002:a50:8fc4:: with SMTP id y62mr22155478edy.170.1594346398349; Thu, 09 Jul 2020 18:59:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594346398; cv=none; d=google.com; s=arc-20160816; b=qywZNETH+e34xhVswGH2GIKY4rwdOoaZL3CGot+qF3T+i2K7w3e/Oj0xm33hQCfgud 0p6vYupxatcCMSJtG/vr2MACwMrMQgMuVg0YjrVtFm0uh7INkyg4nZWx0Vn9+zDPoX1W yZEj9CehjGyE3UyjqPUqGpSEFjo0b81F9vzQhU12sNDBQLKtYXpz3unf7JqXy1TqlRge NuBeTsAZxAYqEaejxFlqzrfYJ3wrLdQKtNYoBM0CNGKYgIhxNdeL9JUz+dl59JhN94bg F4oTxhVkyt8QkSn0FLFy2fDKeBUJEwiglXM40c69FcsnMedOU8bHxgKsrWLCuNeLozsk 3iaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dmarc-filter:dkim-signature; bh=4F33MECp3PLMA5dVQe508bFwLJi13Gd+zPp0VmPVuUU=; b=JlZQUwcMyZC5wsQN9oni00tlJiOu3NOc0JVjhPCMcbTHno9tOTAutrNWDHLIWr8KBu yjM7UAuLUDaw6n1c9QE+ujYmni1hZXtWZG/O7OxbSJWbOUlCxWe2EVqmDv/iQLMsiSNN PPC1wFsOxBquW/wJruRQqARVMwMANBYvN4s34huzoY03+Mvo/V+4+bBheTDXtWvhmFJY HMwTNpvXLukHCpluUQAUDhFZj43jU/fBwsg5ksmJPo34fof19lH3pBcSmrWHEuZobfod Z86bNvEKJVgcECrGwDFvTb7lAOWlvPL2fc5jr2XHf3lkWKTuRIr4TydE5iEwEfmyaEo8 PAZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=fgDuotmK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 1si3181430ejo.509.2020.07.09.18.59.35; Thu, 09 Jul 2020 18:59:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=fgDuotmK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726934AbgGJB5T (ORCPT + 99 others); Thu, 9 Jul 2020 21:57:19 -0400 Received: from mail29.static.mailgun.info ([104.130.122.29]:33725 "EHLO mail29.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726789AbgGJB5S (ORCPT ); Thu, 9 Jul 2020 21:57:18 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1594346237; h=Content-Transfer-Encoding: MIME-Version: References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=4F33MECp3PLMA5dVQe508bFwLJi13Gd+zPp0VmPVuUU=; b=fgDuotmKBb4w4c8PJEEkZCfp1zlBVE8DJvhkOFgG3bDt+EC2GIp2DfnWrL44EFtjoSkUc3Oe tzyzFXW+JmSyCu/9p2CQzHSWmFIRiZDVT+7tMokPXb9ijxEct/LcXpgaLYO85dilcsZa2oFe cZAyUddaDekrwsv795qpz/2CB14= X-Mailgun-Sending-Ip: 104.130.122.29 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n14.prod.us-east-1.postgun.com with SMTP id 5f07caf69f03943e5ca7efe1 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Fri, 10 Jul 2020 01:57:10 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 265A8C433CA; Fri, 10 Jul 2020 01:57:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mdtipton-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mdtipton) by smtp.codeaurora.org (Postfix) with ESMTPSA id CA6FBC433CB; Fri, 10 Jul 2020 01:57:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org CA6FBC433CB Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=mdtipton@codeaurora.org From: Mike Tipton To: georgi.djakov@linaro.org Cc: bjorn.andersson@linaro.org, agross@kernel.org, linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Mike Tipton Subject: [PATCH v2 6/6] interconnect: qcom: Fix small BW votes being truncated to zero Date: Thu, 9 Jul 2020 18:56:52 -0700 Message-Id: <20200710015652.19206-7-mdtipton@codeaurora.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200710015652.19206-1-mdtipton@codeaurora.org> References: <20200710015652.19206-1-mdtipton@codeaurora.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Small BW votes that translate to less than a single BCM unit are currently truncated to zero. Ensure that non-zero BW requests always result in at least a vote of 1 to BCM. Fixes: 976daac4a1c5 ("interconnect: qcom: Consolidate interconnect RPMh support") Signed-off-by: Mike Tipton --- drivers/interconnect/qcom/bcm-voter.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/drivers/interconnect/qcom/bcm-voter.c b/drivers/interconnect/qcom/bcm-voter.c index be7660b95ccc..887d13721e52 100644 --- a/drivers/interconnect/qcom/bcm-voter.c +++ b/drivers/interconnect/qcom/bcm-voter.c @@ -54,8 +54,20 @@ static int cmp_vcd(void *priv, struct list_head *a, struct list_head *b) return 1; } +static u64 bcm_div(u64 num, u32 base) +{ + /* Ensure that small votes aren't lost. */ + if (num && num < base) + return 1; + + do_div(num, base); + + return num; +} + static void bcm_aggregate(struct qcom_icc_bcm *bcm) { + struct qcom_icc_node *node; size_t i, bucket; u64 agg_avg[QCOM_ICC_NUM_BUCKETS] = {0}; u64 agg_peak[QCOM_ICC_NUM_BUCKETS] = {0}; @@ -63,22 +75,21 @@ static void bcm_aggregate(struct qcom_icc_bcm *bcm) for (bucket = 0; bucket < QCOM_ICC_NUM_BUCKETS; bucket++) { for (i = 0; i < bcm->num_nodes; i++) { - temp = bcm->nodes[i]->sum_avg[bucket] * bcm->aux_data.width; - do_div(temp, bcm->nodes[i]->buswidth * bcm->nodes[i]->channels); + node = bcm->nodes[i]; + temp = bcm_div(node->sum_avg[bucket] * bcm->aux_data.width, + node->buswidth * node->channels); agg_avg[bucket] = max(agg_avg[bucket], temp); - temp = bcm->nodes[i]->max_peak[bucket] * bcm->aux_data.width; - do_div(temp, bcm->nodes[i]->buswidth); + temp = bcm_div(node->max_peak[bucket] * bcm->aux_data.width, + node->buswidth); agg_peak[bucket] = max(agg_peak[bucket], temp); } temp = agg_avg[bucket] * bcm->vote_scale; - do_div(temp, bcm->aux_data.unit); - bcm->vote_x[bucket] = temp; + bcm->vote_x[bucket] = bcm_div(temp, bcm->aux_data.unit); temp = agg_peak[bucket] * bcm->vote_scale; - do_div(temp, bcm->aux_data.unit); - bcm->vote_y[bucket] = temp; + bcm->vote_y[bucket] = bcm_div(temp, bcm->aux_data.unit); } if (bcm->keepalive && bcm->vote_x[QCOM_ICC_BUCKET_AMC] == 0 && -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project