summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-01-14 13:50:50 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2012-01-14 18:13:48 +0000
commitb64751dbdb1b88b91ad97aaf995b4261876cf860 (patch)
tree5d1e5346174c9ae00ab75f82d79750b468a31246
parent295a22d2709b2442b5254968437f897dac22a0ec (diff)
sna: Be more lenient wrt switching rings if the kernel supports semaphores
If the kernel uses GPU semaphores for its coherency mechanism between rings rather than CPU waits, allow the ring to be chosen on the basis of the subsequent operation following a submission of batch. (However, since batches are likely to be submitted in the middle of a draw, then the likelihood is for ddx to remain on one ring until forced to switch for an operation or idle, which is the same situation as before and so the difference is miniscule.) Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/kgem.c30
-rw-r--r--src/sna/kgem.h1
2 files changed, 30 insertions, 1 deletions
diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index 55034842..43feadb7 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -85,6 +85,7 @@ static inline void list_replace(struct list *old,
#define DBG_NO_HW 0
#define DBG_NO_TILING 0
#define DBG_NO_VMAP 0
+#define DBG_NO_SEMAPHORES 0
#define DBG_NO_MADV 0
#define DBG_NO_MAP_UPLOAD 0
#define DBG_NO_RELAXED_FENCING 0
@@ -531,6 +532,25 @@ static int gem_param(struct kgem *kgem, int name)
return v;
}
+static bool semaphores_enabled(void)
+{
+ FILE *file;
+ bool detected = false;
+
+ if (DBG_NO_SEMAPHORES)
+ return false;
+
+ file = fopen("/sys/module/i915/parameters/semaphores", "r");
+ if (file) {
+ int value;
+ if (fscanf(file, "%d", &value) == 1)
+ detected = value > 0;
+ fclose(file);
+ }
+
+ return detected;
+}
+
void kgem_init(struct kgem *kgem, int fd, struct pci_device *dev, int gen)
{
struct drm_i915_gem_get_aperture aperture;
@@ -579,9 +599,15 @@ void kgem_init(struct kgem *kgem, int fd, struct pci_device *dev, int gen)
}
} else
kgem->has_relaxed_fencing = 1;
- DBG(("%s: has relaxed fencing=%d\n", __FUNCTION__,
+ DBG(("%s: has relaxed fencing? %d\n", __FUNCTION__,
kgem->has_relaxed_fencing));
+ kgem->has_semaphores = false;
+ if (gen >= 60 && semaphores_enabled())
+ kgem->has_semaphores = true;
+ DBG(("%s: semaphores enabled? %d\n", __FUNCTION__,
+ kgem->has_semaphores));
+
VG_CLEAR(aperture);
aperture.aper_size = 64*1024*1024;
(void)drmIoctl(fd, DRM_IOCTL_I915_GEM_GET_APERTURE, &aperture);
@@ -1380,6 +1406,8 @@ void kgem_reset(struct kgem *kgem)
kgem->nbatch = 0;
kgem->surface = kgem->max_batch_size;
kgem->mode = KGEM_NONE;
+ if (kgem->has_semaphores)
+ kgem->ring = KGEM_NONE;
kgem->flush = 0;
kgem->scanout = 0;
diff --git a/src/sna/kgem.h b/src/sna/kgem.h
index 363c7f99..d9fdd68f 100644
--- a/src/sna/kgem.h
+++ b/src/sna/kgem.h
@@ -143,6 +143,7 @@ struct kgem {
uint32_t has_vmap :1;
uint32_t has_relaxed_fencing :1;
+ uint32_t has_semaphores :1;
uint16_t fence_max;
uint16_t half_cpu_cache_pages;