Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp26910pxk; Tue, 15 Sep 2020 16:46:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwDecsIjsD44ibbot4TpAFCAnNJkVTLFdSuNFkUs+8aOQ18GuJz73E/Ng3DK6TV8AprXAl X-Received: by 2002:aa7:c444:: with SMTP id n4mr25146549edr.200.1600213609115; Tue, 15 Sep 2020 16:46:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600213609; cv=none; d=google.com; s=arc-20160816; b=S47GlcDjq5pS8jIfwbkPRKg6iXtm4RATGbCrtGNEZqTx5rosYk+iJLGI5XTq4YSz0T aGzKNZ7XTxJAdXZWAtF8NM4zGHVOVAn29NmiH+JjU4jTfeTfUD/pbf91fA1cScY5q0ZK XUcEfz95x/hRIMIy/wEDFt2BctLukXn7y9jmqaW2NVnF1ng6VF326ghQct5UIxPsn4oi dgnkC3H0BPqx2UX7Z7d4QYalVmmlVF/9UO/st2BmPLSsNOEO/KxEo0esPdibc7hJtcz8 oxdBNzvxBUZCJaa4B6QpeR8ZN7HP+34n/ENslSe8/xq8/ukj+o6ml9/apMbLfPsX0mtD PmsA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=iJoCCiJiTSbct019ShFqvvWlsQQgQebMcB+fwVz8uDs=; b=CUW/r0GwAZ/g5Dhsris9mykH96L1uw+stL8B7Ufm7lvdNr0lr86kSRvKf3+ux5EZjC OchQ0X4QOe16Jf25odv6obt7TzmJ2QhYOOzqJGHhGKuBX+cme8U+SFj6regkgt8iT6rc ozYqZY9wDMgmBSmYtxb0pTzJCgU/R5KQ5GgFJZ01vUyLVAoirq7Qzd1RT2HgfxCyl+YY pRmQN3p0RUKKXx6IHFxNcsNYKwPFBV4t2WxAyTmIx7b24j+WE/FOq3i9s/5nMxMGVP6n 59AvQPR4aXmQ56CEopBZZ8pvULU8huksNJLPvrbJYfvUdnNpVz9VgHvwzu0A32zmwUt9 gEHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uD93Wc+8; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u20si9761298ejt.14.2020.09.15.16.46.26; Tue, 15 Sep 2020 16:46:49 -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=pass header.i=@kernel.org header.s=default header.b=uD93Wc+8; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726505AbgIOXnt (ORCPT + 99 others); Tue, 15 Sep 2020 19:43:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:47670 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727018AbgIOOd4 (ORCPT ); Tue, 15 Sep 2020 10:33:56 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7ED5123C16; Tue, 15 Sep 2020 14:25:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600179916; bh=j7uRp6sr73vaznyqfi4Pv4VW7OB/bwPYX9PJlQsWRQE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uD93Wc+8sMhFIWMwLLBwF/48IXXmVROyvIk4zTolgY3l6ef8qfZHyZ55GkDSNR7j1 Ck3qlN6Vh4QN2VjHqNxxNfLm6z+BSAk2zJU/V92qhLOFJbMQOQw9wHTXdMWbiaNbOG gvGE26q0xZlMvwY9FnD3mItyiolzB7t5Eu4q5WR8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mike Tipton , Georgi Djakov , Sasha Levin Subject: [PATCH 5.8 036/177] interconnect: qcom: Fix small BW votes being truncated to zero Date: Tue, 15 Sep 2020 16:11:47 +0200 Message-Id: <20200915140655.369889622@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200915140653.610388773@linuxfoundation.org> References: <20200915140653.610388773@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mike Tipton [ Upstream commit 91e045b93db79a2ef66e045ad0d1f8f9d348e1f4 ] 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 Link: https://lore.kernel.org/r/20200903192149.30385-2-mdtipton@codeaurora.org Signed-off-by: Georgi Djakov Signed-off-by: Sasha Levin --- 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 2a11a63e7217a..b360dc34c90c7 100644 --- a/drivers/interconnect/qcom/bcm-voter.c +++ b/drivers/interconnect/qcom/bcm-voter.c @@ -52,8 +52,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}; @@ -61,22 +73,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] * 1000ULL; - 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] * 1000ULL; - 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 && -- 2.25.1