[Intel-gfx] [PATCH 1/2] intel: Add support for overriding the PCI ID via an environment variable
Yuanhan Liu
yuanhan.liu at linux.intel.com
Thu Mar 8 03:35:16 CET 2012
On Wed, Mar 07, 2012 at 11:21:06AM -0800, Eric Anholt wrote:
> From: Kenneth Graunke <kenneth at whitecape.org>
>
> For example:
>
> export INTEL_DEVID_OVERRIDE=0x162
>
> If this variable is set, don't actually submit the batchbuffer to the
> GPU, it probably contains commands for the wrong generation of hardware.
>
> v2: Introduce a getter for the overridden devid, and avoid getenv per exec.
>
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> Signed-off-by: Eric Anholt <eric at anholt.net>
Hi Eric and Kenneth,
Thank you very much for making the whole aub dump stuff in mainline!
Reviewed-by: Yuanhan Liu <yuanhan.liu at linux.intel.com>
(I have some comments about patch 2/2)
> ---
> intel/intel_bufmgr.h | 1 +
> intel/intel_bufmgr_gem.c | 56 ++++++++++++++++++++++++++++++++++++++-------
> 2 files changed, 48 insertions(+), 9 deletions(-)
>
> diff --git a/intel/intel_bufmgr.h b/intel/intel_bufmgr.h
> index 85da8b9..8036031 100644
> --- a/intel/intel_bufmgr.h
> +++ b/intel/intel_bufmgr.h
> @@ -157,6 +157,7 @@ void drm_intel_gem_bo_start_gtt_access(drm_intel_bo *bo, int write_enable);
> int drm_intel_get_pipe_from_crtc_id(drm_intel_bufmgr *bufmgr, int crtc_id);
>
> int drm_intel_get_aperture_sizes(int fd, size_t *mappable, size_t *total);
> +int drm_intel_bufmgr_gem_get_devid(drm_intel_bufmgr *bufmgr);
>
> /* drm_intel_bufmgr_fake.c */
> drm_intel_bufmgr *drm_intel_bufmgr_fake_init(int fd,
> diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c
> index 0f33b71..ba38e50 100644
> --- a/intel/intel_bufmgr_gem.c
> +++ b/intel/intel_bufmgr_gem.c
> @@ -119,6 +119,7 @@ typedef struct _drm_intel_bufmgr_gem {
> unsigned int has_relaxed_fencing : 1;
> unsigned int has_llc : 1;
> unsigned int bo_reuse : 1;
> + unsigned int no_exec : 1;
> bool fenced_relocs;
> } drm_intel_bufmgr_gem;
>
> @@ -1788,7 +1789,8 @@ drm_intel_gem_bo_mrb_exec2(drm_intel_bo *bo, int used,
> {
> drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *)bo->bufmgr;
> struct drm_i915_gem_execbuffer2 execbuf;
> - int ret, i;
> + int ret = 0;
> + int i;
>
> switch (flags & 0x7) {
> default:
> @@ -1828,6 +1830,9 @@ drm_intel_gem_bo_mrb_exec2(drm_intel_bo *bo, int used,
> execbuf.rsvd1 = 0;
> execbuf.rsvd2 = 0;
>
> + if (bufmgr_gem->no_exec)
> + goto skip_execution;
> +
> ret = drmIoctl(bufmgr_gem->fd,
> DRM_IOCTL_I915_GEM_EXECBUFFER2,
> &execbuf);
> @@ -1845,6 +1850,7 @@ drm_intel_gem_bo_mrb_exec2(drm_intel_bo *bo, int used,
> }
> drm_intel_update_buffer_offsets2(bufmgr_gem);
>
> +skip_execution:
> if (bufmgr_gem->bufmgr.debug)
> drm_intel_gem_dump_validation_list(bufmgr_gem);
>
> @@ -2315,6 +2321,45 @@ drm_intel_bufmgr_gem_set_vma_cache_size(drm_intel_bufmgr *bufmgr, int limit)
> }
>
> /**
> + * Get the PCI ID for the device. This can be overridden by setting the
> + * INTEL_DEVID_OVERRIDE environment variable to the desired ID.
> + */
> +static int
> +get_pci_device_id(drm_intel_bufmgr_gem *bufmgr_gem)
> +{
> + char *devid_override;
> + int devid;
> + int ret;
> + drm_i915_getparam_t gp;
> +
> + if (geteuid() == getuid()) {
> + devid_override = getenv("INTEL_DEVID_OVERRIDE");
> + if (devid_override) {
> + bufmgr_gem->no_exec = true;
> + return strtod(devid_override, NULL);
> + }
> + }
> +
> + VG_CLEAR(gp);
> + gp.param = I915_PARAM_CHIPSET_ID;
> + gp.value = &devid;
> + ret = drmIoctl(bufmgr_gem->fd, DRM_IOCTL_I915_GETPARAM, &gp);
> + if (ret) {
> + fprintf(stderr, "get chip id failed: %d [%d]\n", ret, errno);
> + fprintf(stderr, "param: %d, val: %d\n", gp.param, *gp.value);
> + }
> + return devid;
> +}
> +
> +int
> +drm_intel_bufmgr_gem_get_devid(drm_intel_bufmgr *bufmgr)
> +{
> + drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *)bufmgr;
> +
> + return bufmgr_gem->pci_device;
> +}
> +
> +/**
> * Initializes the GEM buffer manager, which uses the kernel to allocate, map,
> * and manage map buffer objections.
> *
> @@ -2356,14 +2401,7 @@ drm_intel_bufmgr_gem_init(int fd, int batch_size)
> (int)bufmgr_gem->gtt_size / 1024);
> }
>
> - VG_CLEAR(gp);
> - gp.param = I915_PARAM_CHIPSET_ID;
> - gp.value = &bufmgr_gem->pci_device;
> - ret = drmIoctl(bufmgr_gem->fd, DRM_IOCTL_I915_GETPARAM, &gp);
> - if (ret) {
> - fprintf(stderr, "get chip id failed: %d [%d]\n", ret, errno);
> - fprintf(stderr, "param: %d, val: %d\n", gp.param, *gp.value);
> - }
> + bufmgr_gem->pci_device = get_pci_device_id(bufmgr_gem);
>
> if (IS_GEN2(bufmgr_gem->pci_device))
> bufmgr_gem->gen = 2;
> --
> 1.7.9.1
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
More information about the Intel-gfx
mailing list