Quoting kevin.rogo...@intel.com (2018-01-09 12:21:29) > From: Kevin Rogovin <kevin.rogo...@intel.com> > > Signed-off-by: Kevin Rogovin <kevin.rogo...@intel.com> > --- > +bool > +brw_bo_padding_is_good(struct brw_bo *bo) > +{ > + if (bo->padding_size > 0) { > + struct drm_i915_gem_mmap mmap_arg = { > + .handle = bo->gem_handle, > + .offset = bo->size, > + .size = bo->padding_size, > + .flags = 0, > + }; > + uint8_t *mapped; > + int ret; > + uint8_t expected_value; > + > + /* We cannot use brw_bo_map() because it maps precisely the range > + * [0, bo->size) and we wish to map the range of the padding which > + * is [bo->size, bo->size + bo->pading_size) > + */ > + ret = drmIoctl(bo->bufmgr->fd, DRM_IOCTL_I915_GEM_MMAP, &mmap_arg); > + if (ret != 0) { > + DBG("Unable to map mapping buffer %d (%s) buffer for pad > checking.\n", > + bo->gem_handle, bo->name); > + return false; > + } > + > + mapped = (uint8_t*) (uintptr_t) mmap_arg.addr_ptr; > + /* bah-humbug, we need to see the latest contents and > + * if the bo is not cache coherent we likely need to > + * invalidate the cache lines to get it. > + */ > + if (!bo->cache_coherent && !bo->bufmgr->has_llc) { > + gen_invalidate_range(mapped, bo->padding_size); > + } > + > + expected_value = bo->gem_handle & 0xFF; > + for (uint32_t i = 0; i < bo->padding_size; ++i) { > + if (expected_value != mapped[i]) { > + drm_munmap(mapped, bo->padding_size); > + return false; > + } > + expected_value = next_noise_value(expected_value); > + } > + drm_munmap(mapped, bo->padding_size); > + } > + return true; > +}
Looks good from the uabi pov and interaction with brw_bo. Reviewed-by: Chris Wilson <ch...@chris-wilson.co.uk> I've a few stylistic nitpicks, but that's better handled by Kenneth and/or Ian, as I very rarely get the mesa coding style right myself :) -Chris _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev