xf86-video-intel: 3 commits - src/intel_device.c src/sna/kgem.c src/sna/kgem.h src/sna/sna_accel.c src/sna/sna_display.c
Chris Wilson
ickle at kemper.freedesktop.org
Tue Oct 29 13:47:42 CET 2013
src/intel_device.c | 3 +
src/sna/kgem.c | 88 +++++++++++++++++++++++++++++++++++---------------
src/sna/kgem.h | 3 -
src/sna/sna_accel.c | 3 +
src/sna/sna_display.c | 10 +++++
5 files changed, 78 insertions(+), 29 deletions(-)
New commits:
commit 56e3761dec7ea3fc35bda90fbc8b477de70fd144
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Tue Oct 29 12:46:09 2013 +0000
sna: Don't attempt to move the GC back to the GPU before it is moved away
Fixes regression from
commit e3f15cbf39696edae9f716bdcfbb7032ec7d7e3f [2.99.905]
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Tue Oct 22 15:19:15 2013 +0100
sna: Move gc back to GPU after failure to move it to CPU
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index b7ee092..16d76a2 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -5065,7 +5065,7 @@ sna_self_copy_boxes(DrawablePtr src, DrawablePtr dst, GCPtr gc,
fallback:
DBG(("%s: fallback", __FUNCTION__));
if (!sna_pixmap_move_to_cpu(pixmap, MOVE_READ | MOVE_WRITE))
- goto out;
+ goto free_boxes;
if (alu == GXcopy && pixmap->drawable.bitsPerPixel >= 8) {
if (sigtrap_get() == 0) {
@@ -5105,6 +5105,7 @@ out:
}
}
+free_boxes:
if (box != RegionRects(region))
free(box);
}
commit 4f41bf3de059c4e0a03fb161fb2e78d94be69e3f
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Tue Oct 29 09:56:10 2013 +0000
sna: Try harder to complete writes
Expunge our caches if we fail to write into a bo (presuming that
allocation failure is the likely fixable cause).
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index 0f5b9ab..3d661ec 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -344,10 +344,8 @@ retry_gtt:
if (kgem_expire_cache(kgem))
goto retry_gtt;
- if (kgem->need_expire) {
- kgem_cleanup_cache(kgem);
+ if (kgem_cleanup_cache(kgem))
goto retry_gtt;
- }
ErrorF("%s: failed to retrieve GTT offset for handle=%d: %d\n",
__FUNCTION__, bo->handle, err);
@@ -365,10 +363,8 @@ retry_mmap:
if (__kgem_throttle_retire(kgem, 0))
goto retry_mmap;
- if (kgem->need_expire) {
- kgem_cleanup_cache(kgem);
+ if (kgem_cleanup_cache(kgem))
goto retry_mmap;
- }
ErrorF("%s: failed to mmap handle=%d, %d bytes, into GTT domain: %d\n",
__FUNCTION__, bo->handle, bytes(bo), err);
@@ -485,8 +481,23 @@ bool kgem_bo_write(struct kgem *kgem, struct kgem_bo *bo,
ASSERT_IDLE(kgem, bo->handle);
assert(length <= bytes(bo));
- if (gem_write(kgem->fd, bo->handle, 0, length, data))
+retry:
+ if (gem_write(kgem->fd, bo->handle, 0, length, data)) {
+ int err = errno;
+
+ assert(err != EINVAL);
+
+ (void)__kgem_throttle_retire(kgem, 0);
+ if (kgem_expire_cache(kgem))
+ goto retry;
+
+ if (kgem_cleanup_cache(kgem))
+ goto retry;
+
+ ErrorF("%s: failed to write %d bytes into BO handle=%d: %d\n",
+ __FUNCTION__, length, bo->handle, err);
return false;
+ }
DBG(("%s: flush=%d, domain=%d\n", __FUNCTION__, bo->flush, bo->domain));
if (bo->exec == NULL) {
@@ -2600,33 +2611,58 @@ static int kgem_batch_write(struct kgem *kgem, uint32_t handle, uint32_t size)
ASSERT_IDLE(kgem, handle);
+retry:
/* If there is no surface data, just upload the batch */
- if (kgem->surface == kgem->batch_size)
- return gem_write(kgem->fd, handle,
- 0, sizeof(uint32_t)*kgem->nbatch,
- kgem->batch);
+ if (kgem->surface == kgem->batch_size) {
+ if (gem_write(kgem->fd, handle,
+ 0, sizeof(uint32_t)*kgem->nbatch,
+ kgem->batch) == 0)
+ return 0;
+
+ goto expire;
+ }
/* Are the batch pages conjoint with the surface pages? */
if (kgem->surface < kgem->nbatch + PAGE_SIZE/sizeof(uint32_t)) {
assert(size == PAGE_ALIGN(kgem->batch_size*sizeof(uint32_t)));
- return gem_write(kgem->fd, handle,
- 0, kgem->batch_size*sizeof(uint32_t),
- kgem->batch);
+ if (gem_write(kgem->fd, handle,
+ 0, kgem->batch_size*sizeof(uint32_t),
+ kgem->batch) == 0)
+ return 0;
+
+ goto expire;
}
/* Disjoint surface/batch, upload separately */
- ret = gem_write(kgem->fd, handle,
+ if (gem_write(kgem->fd, handle,
0, sizeof(uint32_t)*kgem->nbatch,
- kgem->batch);
- if (ret)
- return ret;
+ kgem->batch))
+ goto expire;
ret = PAGE_ALIGN(sizeof(uint32_t) * kgem->batch_size);
ret -= sizeof(uint32_t) * kgem->surface;
assert(size-ret >= kgem->nbatch*sizeof(uint32_t));
- return __gem_write(kgem->fd, handle,
+ if (__gem_write(kgem->fd, handle,
size - ret, (kgem->batch_size - kgem->surface)*sizeof(uint32_t),
- kgem->batch + kgem->surface);
+ kgem->batch + kgem->surface))
+ goto expire;
+
+ return 0;
+
+expire:
+ ret = errno;
+ assert(ret != EINVAL);
+
+ (void)__kgem_throttle_retire(kgem, 0);
+ if (kgem_expire_cache(kgem))
+ goto retry;
+
+ if (kgem_cleanup_cache(kgem))
+ goto retry;
+
+ ErrorF("%s: failed to write batch (handle=%d): %d\n",
+ __FUNCTION__, handle, ret);
+ return ret;
}
void kgem_reset(struct kgem *kgem)
@@ -3015,7 +3051,7 @@ void kgem_throttle(struct kgem *kgem)
}
}
-void kgem_purge_cache(struct kgem *kgem)
+static void kgem_purge_cache(struct kgem *kgem)
{
struct kgem_bo *bo, *next;
int i;
@@ -3220,7 +3256,7 @@ bool kgem_expire_cache(struct kgem *kgem)
(void)size;
}
-void kgem_cleanup_cache(struct kgem *kgem)
+bool kgem_cleanup_cache(struct kgem *kgem)
{
unsigned int i;
int n;
@@ -3250,6 +3286,9 @@ void kgem_cleanup_cache(struct kgem *kgem)
kgem_retire(kgem);
kgem_cleanup(kgem);
+ if (!kgem->need_expire)
+ return false;
+
for (i = 0; i < ARRAY_SIZE(kgem->inactive); i++) {
while (!list_is_empty(&kgem->inactive[i]))
kgem_bo_free(kgem,
@@ -3273,6 +3312,7 @@ void kgem_cleanup_cache(struct kgem *kgem)
kgem->need_purge = false;
kgem->need_expire = false;
+ return true;
}
static struct kgem_bo *
@@ -5199,10 +5239,8 @@ retry:
if (__kgem_throttle_retire(kgem, 0))
goto retry;
- if (kgem->need_expire) {
- kgem_cleanup_cache(kgem);
+ if (kgem_cleanup_cache(kgem))
goto retry;
- }
ErrorF("%s: failed to mmap handle=%d, %d bytes, into CPU domain: %d\n",
__FUNCTION__, bo->handle, bytes(bo), err);
diff --git a/src/sna/kgem.h b/src/sna/kgem.h
index 8ccda55..77edfc8 100644
--- a/src/sna/kgem.h
+++ b/src/sna/kgem.h
@@ -713,8 +713,7 @@ void kgem_buffer_read_sync(struct kgem *kgem, struct kgem_bo *bo);
void kgem_throttle(struct kgem *kgem);
#define MAX_INACTIVE_TIME 10
bool kgem_expire_cache(struct kgem *kgem);
-void kgem_purge_cache(struct kgem *kgem);
-void kgem_cleanup_cache(struct kgem *kgem);
+bool kgem_cleanup_cache(struct kgem *kgem);
void kgem_clean_scanout_cache(struct kgem *kgem);
void kgem_clean_large_cache(struct kgem *kgem);
commit 76b14a90c16921426154be1d18307e3b12309eea
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Mon Oct 28 20:48:17 2013 +0000
sna: Quieten a couple of valgrind warnings about unknown ioctls
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
diff --git a/src/intel_device.c b/src/intel_device.c
index 0db65ca..4d08a6e 100644
--- a/src/intel_device.c
+++ b/src/intel_device.c
@@ -67,8 +67,9 @@ static int intel_device_key = -1;
static int __intel_get_device_id(int fd)
{
struct drm_i915_getparam gp;
- int devid;
+ int devid = 0;
+ memset(&gp, 0, sizeof(gp));
gp.param = I915_PARAM_CHIPSET_ID;
gp.value = &devid;
diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index 45d83f4..c797d52 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -63,6 +63,11 @@
#include <xf86drm.h>
+#ifdef HAVE_VALGRIND
+#include <valgrind.h>
+#include <memcheck.h>
+#endif
+
/* Minor discrepancy between 32-bit/64-bit ABI in old kernels */
union compat_mode_get_connector{
struct drm_mode_get_connector conn;
@@ -1752,6 +1757,8 @@ sna_crtc_find_plane(struct sna *sna, int pipe)
if (drmIoctl(sna->kgem.fd, DRM_IOCTL_MODE_GETPLANERESOURCES, &r))
r.count_planes = 0;
+ VG(VALGRIND_MAKE_MEM_DEFINED(planes, sizeof(uint32_t)*r.count_planes));
+
for (i = 0; i < r.count_planes; i++) {
struct drm_mode_get_plane p;
@@ -2704,6 +2711,8 @@ sna_output_init(ScrnInfoPtr scrn, struct sna_mode *mode, int num)
/* statically constructed property list */
assert(sna_output->num_props == compat_conn.conn.count_props);
+ VG(VALGRIND_MAKE_MEM_DEFINED(sna_output->prop_ids, sizeof(uint32_t)*sna_output->num_props));
+ VG(VALGRIND_MAKE_MEM_DEFINED(sna_output->prop_values, sizeof(uint64_t)*sna_output->num_props));
if (compat_conn.conn.connector_type < ARRAY_SIZE(output_names))
output_name = output_names[compat_conn.conn.connector_type];
@@ -3202,6 +3211,7 @@ static void crtc_init_gamma(xf86CrtcPtr crtc)
lut.green = (uintptr_t)(gamma + 256);
lut.blue = (uintptr_t)(gamma + 2 * 256);
if (drmIoctl(sna->kgem.fd, DRM_IOCTL_MODE_GETGAMMA, &lut) == 0) {
+ VG(VALGRIND_MAKE_MEM_DEFINED(gamma, 3*256*sizeof(gamma[0])));
gamma_set =
gamma[256 - 1] &&
gamma[2*256 - 1] &&
More information about the xorg-commit
mailing list