lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d093fed9-dede-93dc-2990-80769d0d4439@codeaurora.org>
Date:   Thu, 2 Jul 2020 14:02:21 -0700
From:   Mike Tipton <mdtipton@...eaurora.org>
To:     Georgi Djakov <georgi.djakov@...aro.org>
Cc:     bjorn.andersson@...aro.org, agross@...nel.org,
        linux-pm@...r.kernel.org, linux-arm-msm@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 4/4] interconnect: qcom: Fix small BW votes being
 truncated to zero

On 7/2/2020 4:11 AM, Georgi Djakov wrote:
> Hi Mike,
> 
> On 6/23/20 07:08, Mike Tipton wrote:
>> 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 <mdtipton@...eaurora.org>
>> ---
>>   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 a68c858ca6b7..9e2612fe7fad 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, u64 base)
>> +{
>> +	/* Ensure that small votes aren't lost. */
>> +	if (num && num < base)
>> +		return 1;
>> +
>> +	do_div(num, base);
> 
> do_div() does a 64-by-32 division, which will truncate these to 32-bit.
I can change base to a u32. It doesn't need anything more than that.

> 
>> +
>> +	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 rest looks good.
> 
> Thanks,
> Georgi
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ