summaryrefslogtreecommitdiff
path: root/src/sna/kgem.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2013-10-21 15:31:44 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2013-10-21 15:35:27 +0100
commit8c562bac64d2ce80667c686a732d0f9cda6277ca (patch)
treebd930d103dadabb862b3ebf93746b17eec08503b /src/sna/kgem.c
parent11211cd7c06a80c2dbbe07360857486b5b0d3094 (diff)
sna: Tweak opportunistic flushing to reduce power consumption
When trying to conserve power, reduce the number of small batches we emit - trying to maximise GPU efficacy and minimise CPU overhead. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/sna/kgem.c')
-rw-r--r--src/sna/kgem.c56
1 files changed, 26 insertions, 30 deletions
diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index 9eb0fa59..f959875d 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -4647,6 +4647,20 @@ static bool aperture_check(struct kgem *kgem, unsigned num_pages)
return false;
}
+static inline bool kgem_flush(struct kgem *kgem, bool flush)
+{
+ if (kgem->nreloc == 0)
+ return false;
+
+ if (container_of(kgem, struct sna, kgem)->flags & SNA_POWERSAVE)
+ return false;
+
+ if (kgem->flush == flush && kgem->aperture < kgem->aperture_low)
+ return false;
+
+ return kgem_ring_is_idle(kgem, kgem->ring);
+}
+
bool kgem_check_bo(struct kgem *kgem, ...)
{
va_list ap;
@@ -4680,14 +4694,14 @@ bool kgem_check_bo(struct kgem *kgem, ...)
if (!num_pages)
return true;
- if (kgem_flush(kgem, flush)) {
- DBG(("%s: opportunistic flushing\n", __FUNCTION__));
+ if (kgem->nexec + num_exec >= KGEM_EXEC_SIZE(kgem)) {
+ DBG(("%s: out of exec slots (%d + %d / %d)\n", __FUNCTION__,
+ kgem->nexec, num_exec, KGEM_EXEC_SIZE(kgem)));
return false;
}
- if (kgem->aperture > kgem->aperture_low &&
- kgem_ring_is_idle(kgem, kgem->ring)) {
- DBG(("%s: current aperture usage (%d) is greater than low water mark (%d)\n",
+ if (kgem_flush(kgem, flush)) {
+ DBG(("%s: opportunistic flushing, aperture %d/%d\n",
__FUNCTION__, kgem->aperture, kgem->aperture_low));
return false;
}
@@ -4698,12 +4712,6 @@ bool kgem_check_bo(struct kgem *kgem, ...)
return aperture_check(kgem, num_pages);
}
- if (kgem->nexec + num_exec >= KGEM_EXEC_SIZE(kgem)) {
- DBG(("%s: out of exec slots (%d + %d / %d)\n", __FUNCTION__,
- kgem->nexec, num_exec, KGEM_EXEC_SIZE(kgem)));
- return false;
- }
-
return true;
}
@@ -4736,22 +4744,16 @@ bool kgem_check_bo_fenced(struct kgem *kgem, struct kgem_bo *bo)
return true;
}
+ if (kgem->nexec >= KGEM_EXEC_SIZE(kgem) - 1)
+ return false;
+
if (needs_semaphore(kgem, bo)) {
DBG(("%s: flushing for required semaphore\n", __FUNCTION__));
return false;
}
if (kgem_flush(kgem, bo->flush)) {
- DBG(("%s: opportunistic flushing\n", __FUNCTION__));
- return false;
- }
-
- if (kgem->nexec >= KGEM_EXEC_SIZE(kgem) - 1)
- return false;
-
- if (kgem->aperture > kgem->aperture_low &&
- kgem_ring_is_idle(kgem, kgem->ring)) {
- DBG(("%s: current aperture usage (%d) is greater than low water mark (%d)\n",
+ DBG(("%s: opportunistic flushing, aperture %d/%d\n",
__FUNCTION__, kgem->aperture, kgem->aperture_low));
return false;
}
@@ -4838,14 +4840,11 @@ bool kgem_check_many_bo_fenced(struct kgem *kgem, ...)
}
if (num_pages) {
- if (kgem_flush(kgem, flush)) {
- DBG(("%s: opportunistic flushing\n", __FUNCTION__));
+ if (kgem->nexec + num_exec >= KGEM_EXEC_SIZE(kgem))
return false;
- }
- if (kgem->aperture > kgem->aperture_low &&
- kgem_ring_is_idle(kgem, kgem->ring)) {
- DBG(("%s: current aperture usage (%d) is greater than low water mark (%d)\n",
+ if (kgem_flush(kgem, flush)) {
+ DBG(("%s: opportunistic flushing, aperture %d/%d\n",
__FUNCTION__, kgem->aperture, kgem->aperture_low));
return false;
}
@@ -4855,9 +4854,6 @@ bool kgem_check_many_bo_fenced(struct kgem *kgem, ...)
__FUNCTION__, num_pages + kgem->aperture, kgem->aperture_high));
return aperture_check(kgem, num_pages);
}
-
- if (kgem->nexec + num_exec >= KGEM_EXEC_SIZE(kgem))
- return false;
}
return true;