All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] intel: Add support for overriding the PCI ID via an environment variable
@ 2012-02-21 20:59 Kenneth Graunke
  2012-02-21 20:59 ` [PATCH 2/2] intel: Remove Ironlake from IS_GEN4 macro Kenneth Graunke
  2012-02-21 21:11 ` [PATCH 1/2] intel: Add support for overriding the PCI ID via an environment variable Chris Wilson
  0 siblings, 2 replies; 10+ messages in thread
From: Kenneth Graunke @ 2012-02-21 20:59 UTC (permalink / raw)
  To: intel-gfx

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.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
---
 intel/intel_bufmgr_gem.c |   43 ++++++++++++++++++++++++++++++++++---------
 1 files changed, 34 insertions(+), 9 deletions(-)

diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c
index 0f33b71..fcb4764 100644
--- a/intel/intel_bufmgr_gem.c
+++ b/intel/intel_bufmgr_gem.c
@@ -1788,7 +1788,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 +1829,9 @@ drm_intel_gem_bo_mrb_exec2(drm_intel_bo *bo, int used,
 	execbuf.rsvd1 = 0;
 	execbuf.rsvd2 = 0;
 
+	if (getenv("INTEL_DEVID_OVERRIDE"))
+		goto skip_execution;
+
 	ret = drmIoctl(bufmgr_gem->fd,
 		       DRM_IOCTL_I915_GEM_EXECBUFFER2,
 		       &execbuf);
@@ -1845,6 +1849,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 +2320,33 @@ 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;
+
+	devid_override = getenv("INTEL_DEVID_OVERRIDE");
+	if (devid_override)
+		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;
+}
+
+/**
  * Initializes the GEM buffer manager, which uses the kernel to allocate, map,
  * and manage map buffer objections.
  *
@@ -2356,14 +2388,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.7.6

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/2] intel: Remove Ironlake from IS_GEN4 macro.
  2012-02-21 20:59 [PATCH 1/2] intel: Add support for overriding the PCI ID via an environment variable Kenneth Graunke
@ 2012-02-21 20:59 ` Kenneth Graunke
  2012-02-21 21:08   ` Chris Wilson
  2012-02-21 21:11 ` [PATCH 1/2] intel: Add support for overriding the PCI ID via an environment variable Chris Wilson
  1 sibling, 1 reply; 10+ messages in thread
From: Kenneth Graunke @ 2012-02-21 20:59 UTC (permalink / raw)
  To: intel-gfx

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
---
 intel/intel_chipset.h |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/intel/intel_chipset.h b/intel/intel_chipset.h
index e3a30fc..1b6e357 100644
--- a/intel/intel_chipset.h
+++ b/intel/intel_chipset.h
@@ -96,8 +96,6 @@
 		      dev == 0x2E22 ||	\
 		      dev == 0x2E32 ||	\
 		      dev == 0x2E42 ||	\
-		      dev == 0x0042 ||	\
-		      dev == 0x0046 ||	\
 		      IS_I965GM(dev) || \
 		      IS_G4X(dev))
 
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] intel: Remove Ironlake from IS_GEN4 macro.
  2012-02-21 20:59 ` [PATCH 2/2] intel: Remove Ironlake from IS_GEN4 macro Kenneth Graunke
@ 2012-02-21 21:08   ` Chris Wilson
  2012-02-21 22:24     ` Kenneth Graunke
  0 siblings, 1 reply; 10+ messages in thread
From: Chris Wilson @ 2012-02-21 21:08 UTC (permalink / raw)
  To: Kenneth Graunke, intel-gfx

On Tue, 21 Feb 2012 12:59:38 -0800, Kenneth Graunke <kenneth@whitecape.org> wrote:
> Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>

A task for a rainy afternoon would be to rigorously use the verbose
PCI_ID_* names rather than the raw values.

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>

> ---
>  intel/intel_chipset.h |    2 --
>  1 files changed, 0 insertions(+), 2 deletions(-)
> 
> diff --git a/intel/intel_chipset.h b/intel/intel_chipset.h
> index e3a30fc..1b6e357 100644
> --- a/intel/intel_chipset.h
> +++ b/intel/intel_chipset.h
> @@ -96,8 +96,6 @@
>  		      dev == 0x2E22 ||	\
>  		      dev == 0x2E32 ||	\
>  		      dev == 0x2E42 ||	\
Note that these 5 IDs are part of IS_G4X, can you kill them as well (in
another patch).
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] intel: Add support for overriding the PCI ID via an environment variable
  2012-02-21 20:59 [PATCH 1/2] intel: Add support for overriding the PCI ID via an environment variable Kenneth Graunke
  2012-02-21 20:59 ` [PATCH 2/2] intel: Remove Ironlake from IS_GEN4 macro Kenneth Graunke
@ 2012-02-21 21:11 ` Chris Wilson
  2012-02-21 22:42   ` Kenneth Graunke
                     ` (2 more replies)
  1 sibling, 3 replies; 10+ messages in thread
From: Chris Wilson @ 2012-02-21 21:11 UTC (permalink / raw)
  To: Kenneth Graunke, intel-gfx

On Tue, 21 Feb 2012 12:59:37 -0800, Kenneth Graunke <kenneth@whitecape.org> wrote:
> @@ -1828,6 +1829,9 @@ drm_intel_gem_bo_mrb_exec2(drm_intel_bo *bo, int used,
>  	execbuf.rsvd1 = 0;
>  	execbuf.rsvd2 = 0;
>  
> +	if (getenv("INTEL_DEVID_OVERRIDE"))
> +		goto skip_execution;

I'm not thrilled about calling getenv() for every execbuffer. And what
about the original execbuffer path?
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] intel: Remove Ironlake from IS_GEN4 macro.
  2012-02-21 21:08   ` Chris Wilson
@ 2012-02-21 22:24     ` Kenneth Graunke
  0 siblings, 0 replies; 10+ messages in thread
From: Kenneth Graunke @ 2012-02-21 22:24 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

On 02/21/2012 01:08 PM, Chris Wilson wrote:
> On Tue, 21 Feb 2012 12:59:38 -0800, Kenneth Graunke<kenneth@whitecape.org>  wrote:
>> Signed-off-by: Kenneth Graunke<kenneth@whitecape.org>
>
> A task for a rainy afternoon would be to rigorously use the verbose
> PCI_ID_* names rather than the raw values.
>
> Reviewed-by: Chris Wilson<chris@chris-wilson.co.uk>
>
>> ---
>>   intel/intel_chipset.h |    2 --
>>   1 files changed, 0 insertions(+), 2 deletions(-)
>>
>> diff --git a/intel/intel_chipset.h b/intel/intel_chipset.h
>> index e3a30fc..1b6e357 100644
>> --- a/intel/intel_chipset.h
>> +++ b/intel/intel_chipset.h
>> @@ -96,8 +96,6 @@
>>   		      dev == 0x2E22 ||	\
>>   		      dev == 0x2E32 ||	\
>>   		      dev == 0x2E42 ||	\
> Note that these 5 IDs are part of IS_G4X, can you kill them as well (in
> another patch).
> -Chris

Hm.  I guess I consider G4X to be part of GEN4.  At least in Mesa, G4X 
is explicitly included:

#define IS_GEN4(devid) (devid == ... || ... || IS_G4X(devid))

Using that instead of hardcoding the IDs would be cleaner, though.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] intel: Add support for overriding the PCI ID via an environment variable
  2012-02-21 21:11 ` [PATCH 1/2] intel: Add support for overriding the PCI ID via an environment variable Chris Wilson
@ 2012-02-21 22:42   ` Kenneth Graunke
  2012-02-22  8:05     ` Daniel Vetter
  2012-02-21 22:43   ` Ben Widawsky
  2012-03-03 15:22   ` Julien Cristau
  2 siblings, 1 reply; 10+ messages in thread
From: Kenneth Graunke @ 2012-02-21 22:42 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

On 02/21/2012 01:11 PM, Chris Wilson wrote:
> On Tue, 21 Feb 2012 12:59:37 -0800, Kenneth Graunke<kenneth@whitecape.org>  wrote:
>> @@ -1828,6 +1829,9 @@ drm_intel_gem_bo_mrb_exec2(drm_intel_bo *bo, int used,
>>   	execbuf.rsvd1 = 0;
>>   	execbuf.rsvd2 = 0;
>>
>> +	if (getenv("INTEL_DEVID_OVERRIDE"))
>> +		goto skip_execution;
>
> I'm not thrilled about calling getenv() for every execbuffer.

Good point.  I'll have to fix that.

> And what about the original execbuffer path?
> -Chris

Does anybody care?  I'm not even sure how I'd test it.

A little bit of background: this is a stepping stone on the way to 
simulator support.

When INTEL_DEVID_OVERRIDE is set, Mesa will generate code/batches for 
that system, rather than the current machine.  It also implicitly sets 
INTEL_NO_HW=1, which makes it avoid calling execbuf2.  This at least 
allows INTEL_DEBUG=vs,wm,bat style dumps, which is handy.

However, our .aub trace file support is in libdrm, so I need Mesa to 
execbuf, or I don't get aub file dumps.  But I don't want libdrm to 
-actually- exec it.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] intel: Add support for overriding the PCI ID via an environment variable
  2012-02-21 21:11 ` [PATCH 1/2] intel: Add support for overriding the PCI ID via an environment variable Chris Wilson
  2012-02-21 22:42   ` Kenneth Graunke
@ 2012-02-21 22:43   ` Ben Widawsky
  2012-03-03 15:22   ` Julien Cristau
  2 siblings, 0 replies; 10+ messages in thread
From: Ben Widawsky @ 2012-02-21 22:43 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

On Tue, 21 Feb 2012 21:11:07 +0000
Chris Wilson <chris@chris-wilson.co.uk> wrote:

> On Tue, 21 Feb 2012 12:59:37 -0800, Kenneth Graunke <kenneth@whitecape.org> wrote:
> > @@ -1828,6 +1829,9 @@ drm_intel_gem_bo_mrb_exec2(drm_intel_bo *bo, int used,
> >  	execbuf.rsvd1 = 0;
> >  	execbuf.rsvd2 = 0;
> >  
> > +	if (getenv("INTEL_DEVID_OVERRIDE"))
> > +		goto skip_execution;
> 
> I'm not thrilled about calling getenv() for every execbuffer. And what
> about the original execbuffer path?
> -Chris
> 

I agree. I think the right way to do this is if the environment variable is
set, you can override the function pointer in drm_intel_bufmgr_gem_init or
something like that.

Also, I think it's a bit misleading that the effect of overriding the
devid is to not emit batches. If nothing else because we may actually
want to override the devid and have it do something in the future, and
expecting the override to not emit could be bad.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] intel: Add support for overriding the PCI ID via an environment variable
  2012-02-21 22:42   ` Kenneth Graunke
@ 2012-02-22  8:05     ` Daniel Vetter
  0 siblings, 0 replies; 10+ messages in thread
From: Daniel Vetter @ 2012-02-22  8:05 UTC (permalink / raw)
  To: Kenneth Graunke; +Cc: intel-gfx

On Tue, Feb 21, 2012 at 02:42:37PM -0800, Kenneth Graunke wrote:
> On 02/21/2012 01:11 PM, Chris Wilson wrote:
> >On Tue, 21 Feb 2012 12:59:37 -0800, Kenneth Graunke<kenneth@whitecape.org>  wrote:
> >>@@ -1828,6 +1829,9 @@ drm_intel_gem_bo_mrb_exec2(drm_intel_bo *bo, int used,
> >>  	execbuf.rsvd1 = 0;
> >>  	execbuf.rsvd2 = 0;
> >>
> >>+	if (getenv("INTEL_DEVID_OVERRIDE"))
> >>+		goto skip_execution;
> >
> >I'm not thrilled about calling getenv() for every execbuffer.
> 
> Good point.  I'll have to fix that.
> 
> >And what about the original execbuffer path?
> >-Chris
> 
> Does anybody care?  I'm not even sure how I'd test it.
> 
> A little bit of background: this is a stepping stone on the way to
> simulator support.
> 
> When INTEL_DEVID_OVERRIDE is set, Mesa will generate code/batches
> for that system, rather than the current machine.  It also
> implicitly sets INTEL_NO_HW=1, which makes it avoid calling
> execbuf2.  This at least allows INTEL_DEBUG=vs,wm,bat style dumps,
> which is handy.
> 
> However, our .aub trace file support is in libdrm, so I need Mesa to
> execbuf, or I don't get aub file dumps.  But I don't want libdrm to
> -actually- exec it.

What about adding a function to libdrm to stop all execbuf calls from
actually calling the kernel ioctl? Something like
drm_intel_gem_bufmgr_enable_no_hw() ... Maybe combine it right away with
the aub-trace grabbing code.
-Daniel
-- 
Daniel Vetter
Mail: daniel@ffwll.ch
Mobile: +41 (0)79 365 57 48

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] intel: Add support for overriding the PCI ID via an environment variable
  2012-02-21 21:11 ` [PATCH 1/2] intel: Add support for overriding the PCI ID via an environment variable Chris Wilson
  2012-02-21 22:42   ` Kenneth Graunke
  2012-02-21 22:43   ` Ben Widawsky
@ 2012-03-03 15:22   ` Julien Cristau
  2012-03-05 23:18     ` Eric Anholt
  2 siblings, 1 reply; 10+ messages in thread
From: Julien Cristau @ 2012-03-03 15:22 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

On Tue, Feb 21, 2012 at 21:11:07 +0000, Chris Wilson wrote:

> On Tue, 21 Feb 2012 12:59:37 -0800, Kenneth Graunke <kenneth@whitecape.org> wrote:
> > @@ -1828,6 +1829,9 @@ drm_intel_gem_bo_mrb_exec2(drm_intel_bo *bo, int used,
> >  	execbuf.rsvd1 = 0;
> >  	execbuf.rsvd2 = 0;
> >  
> > +	if (getenv("INTEL_DEVID_OVERRIDE"))
> > +		goto skip_execution;
> 
> I'm not thrilled about calling getenv() for every execbuffer. And what
> about the original execbuffer path?

I'm not thrilled about allowing the user to modify X server behaviour
with an env variable.  This is setuid root after all.  I guess this also
applies to the existing calls to getenv in the dri driver.

Cheers,
Julien

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] intel: Add support for overriding the PCI ID via an environment variable
  2012-03-03 15:22   ` Julien Cristau
@ 2012-03-05 23:18     ` Eric Anholt
  0 siblings, 0 replies; 10+ messages in thread
From: Eric Anholt @ 2012-03-05 23:18 UTC (permalink / raw)
  To: Julien Cristau, Chris Wilson; +Cc: intel-gfx


[-- Attachment #1.1: Type: text/plain, Size: 967 bytes --]

On Sat, 3 Mar 2012 16:22:45 +0100, Julien Cristau <jcristau@debian.org> wrote:
> On Tue, Feb 21, 2012 at 21:11:07 +0000, Chris Wilson wrote:
> 
> > On Tue, 21 Feb 2012 12:59:37 -0800, Kenneth Graunke <kenneth@whitecape.org> wrote:
> > > @@ -1828,6 +1829,9 @@ drm_intel_gem_bo_mrb_exec2(drm_intel_bo *bo, int used,
> > >  	execbuf.rsvd1 = 0;
> > >  	execbuf.rsvd2 = 0;
> > >  
> > > +	if (getenv("INTEL_DEVID_OVERRIDE"))
> > > +		goto skip_execution;
> > 
> > I'm not thrilled about calling getenv() for every execbuffer. And what
> > about the original execbuffer path?
> 
> I'm not thrilled about allowing the user to modify X server behaviour
> with an env variable.  This is setuid root after all.  I guess this also
> applies to the existing calls to getenv in the dri driver.

Yeah, this seems roughly of the same class as the many environment
variables we've always had.  I'm going to take a shot at disabling a
bunch under setuid, though.

[-- Attachment #1.2: Type: application/pgp-signature, Size: 197 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2012-03-05 23:18 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-21 20:59 [PATCH 1/2] intel: Add support for overriding the PCI ID via an environment variable Kenneth Graunke
2012-02-21 20:59 ` [PATCH 2/2] intel: Remove Ironlake from IS_GEN4 macro Kenneth Graunke
2012-02-21 21:08   ` Chris Wilson
2012-02-21 22:24     ` Kenneth Graunke
2012-02-21 21:11 ` [PATCH 1/2] intel: Add support for overriding the PCI ID via an environment variable Chris Wilson
2012-02-21 22:42   ` Kenneth Graunke
2012-02-22  8:05     ` Daniel Vetter
2012-02-21 22:43   ` Ben Widawsky
2012-03-03 15:22   ` Julien Cristau
2012-03-05 23:18     ` Eric Anholt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.