summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/nouveau/nvc0
diff options
context:
space:
mode:
authorIlia Mirkin <[email protected]>2014-09-06 11:03:00 -0400
committerIlia Mirkin <[email protected]>2014-09-08 20:06:11 -0400
commitc02ac408377f62086cc5d6853f23281bb52dc0b2 (patch)
tree59498f34e6de87ed10f83ea3c6069970698461d4 /src/gallium/drivers/nouveau/nvc0
parent08f13ff43950a732cf3e7693565e4277feccf2e4 (diff)
nvc0: use 64-bit math when scaling the query results
Reported by Coverity. Signed-off-by: Ilia Mirkin <[email protected]>
Diffstat (limited to 'src/gallium/drivers/nouveau/nvc0')
-rw-r--r--src/gallium/drivers/nouveau/nvc0/nvc0_query.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c
index 007f8c47914..3a6df9dcf87 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c
@@ -1338,14 +1338,14 @@ nvc0_mp_pm_query_result(struct nvc0_context *nvc0, struct nvc0_query *q,
for (c = 0; c < cfg->num_counters; ++c)
for (p = 0; p < mp_count; ++p)
v |= count[p][c];
- value = (v * cfg->norm[0]) / cfg->norm[1];
+ value = ((uint64_t)v * cfg->norm[0]) / cfg->norm[1];
} else
if (cfg->op == NVC0_COUNTER_OPn_AND) {
uint32_t v = ~0;
for (c = 0; c < cfg->num_counters; ++c)
for (p = 0; p < mp_count; ++p)
v &= count[p][c];
- value = (v * cfg->norm[0]) / cfg->norm[1];
+ value = ((uint64_t)v * cfg->norm[0]) / cfg->norm[1];
} else
if (cfg->op == NVC0_COUNTER_OP2_REL_SUM_MM) {
uint64_t v[2] = { 0, 0 };
@@ -1370,7 +1370,7 @@ nvc0_mp_pm_query_result(struct nvc0_context *nvc0, struct nvc0_query *q,
if (count[p][1])
value += (count[p][0] * cfg->norm[0]) / count[p][1];
if (mp_used)
- value /= mp_used * cfg->norm[1];
+ value /= (uint64_t)mp_used * cfg->norm[1];
} else
if (cfg->op == NVC0_COUNTER_OP2_AVG_DIV_M0) {
unsigned mp_used = 0;
@@ -1378,7 +1378,7 @@ nvc0_mp_pm_query_result(struct nvc0_context *nvc0, struct nvc0_query *q,
value += count[p][0];
if (count[0][1] && mp_used) {
value *= cfg->norm[0];
- value /= count[0][1] * mp_used * cfg->norm[1];
+ value /= (uint64_t)count[0][1] * mp_used * cfg->norm[1];
} else {
value = 0;
}