drm/i915: Require HW contexts (when possible)
Subsystems (2)
RFC PATCH 1/1 drm/i915: Require HW contexts (when possible)
From: Ben Widawsky <[email protected]>
Only compile tested
--- drivers/gpu/drm/i915/i915_drv.c | 5 +--- drivers/gpu/drm/i915/i915_drv.h | 3 +-- drivers/gpu/drm/i915/i915_gem.c | 7 +++++- drivers/gpu/drm/i915/i915_gem_context.c | 43 +++++++++++++++------------------ drivers/gpu/drm/i915/i915_sysfs.c | 6 ++--- 5 files changed, 31 insertions(+), 33 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +1 -4
@@ -750,14 +750,11 @@ int i915_reset(struct drm_device *dev)*/ if (drm_core_check_feature (dev,DRIVER_MODESET ) || !dev_priv->ums.mm_suspended) { -bool hw_contexts_disabled = dev_priv->hw_contexts_disabled; dev_priv->ums.mm_suspended =0 ; ret =i915_gem_init_hw (dev); -if (!hw_contexts_disabled && dev_priv->hw_contexts_disabled) -DRM_ERROR ("HW contexts didn't survive reset\n" ); -mutex_unlock (&dev->struct_mutex);if (ret) { +mutex_unlock (&dev->struct_mutex);DRM_ERROR ("Failed hw init on reset %d\n" , ret);return ret; }
drivers/gpu/drm/i915/i915_drv.h +1 -2
@@ -1411,7 +1411,6 @@ typedef struct drm_i915_private {struct drm_property *broadcast_rgb_property;struct drm_property *force_audio_property; -bool hw_contexts_disabled;uint32_t hw_context_size;struct list_head context_list;
@@ -2140,7 +2139,7 @@ i915_gem_obj_ggtt_pin(struct drm_i915_gem_object *obj, }/* i915_gem_context.c */ -void i915_gem_context_init (struct drm_device *dev); +int __must_check i915_gem_context_init (struct drm_device *dev);void i915_gem_context_fini (struct drm_device *dev);void i915_gem_context_close (struct drm_device *dev,struct drm_file *file); int i915_switch_context(struct intel_ring_buffer *ring,
drivers/gpu/drm/i915/i915_gem.c +6 -1
@@ -4463,7 +4463,12 @@ i915_gem_init_hw(struct drm_device *dev)* XXX: There was some w/a described somewhere suggesting loading * contexts before PPGTT. */ -i915_gem_context_init (dev); + ret =i915_gem_context_init (dev); +if (ret) { +DRM_ERROR ("Context initialization failed %d\n" , ret); +return ret; + } +if (dev_priv->mm.aliasing_ppgtt) { ret = dev_priv->mm.aliasing_ppgtt->enable (dev);if (ret) {
drivers/gpu/drm/i915/i915_gem_context.c +20 -23
100 lines not on this page · raw message
drivers/gpu/drm/i915/i915_sysfs.c +3 -3
@@ -183,13 +183,13 @@ i915_l3_write(struct file *filp, struct kobject *kobj,int slice = (int )(uintptr_t )attr->private;int ret; +if (!HAS_HW_CONTEXTS (drm_dev)) +return -ENXIO ; + ret =l3_access_valid (drm_dev, offset);if (ret)return ret; -if (dev_priv->hw_contexts_disabled) -return -ENXIO ; - ret =i915_mutex_lock_interruptible (drm_dev);if (ret)return ret;
Signature · 1 line
1.8.4.1
Quoted 6 lines · Ben Widawsky
From: Ben Widawsky <[email protected]>
Only compile tested
CC Kenneth Graunke <[email protected]>Signed-off-by Ben Widawsky <[email protected]>
The code looks good to me (but I didn't test it either). I'm in favor of this happening.
Quoted 21 lines · Ben Widawsky
From: Ben Widawsky <[email protected]>
Only compile tested
CC Kenneth Graunke <[email protected]>Signed-off-by Ben Widawsky <[email protected]>--- drivers/gpu/drm/i915/i915_drv.c | 5 +--- drivers/gpu/drm/i915/i915_drv.h | 3 +-- drivers/gpu/drm/i915/i915_gem.c | 7 +++++- drivers/gpu/drm/i915/i915_gem_context.c | 43 +++++++++++++++------------------ drivers/gpu/drm/i915/i915_sysfs.c | 6 ++--- 5 files changed, 31 insertions(+), 33 deletions(-)drivers/gpu/drm/i915/i915_drv.c +0
-0@@ -750,14 +750,11 @@ int i915_reset(struct drm_device *dev)*/ if (drm_core_check_feature(dev, DRIVER_MODESET) ||
drivers/gpu/drm/i915/i915_drv.c int i915_reset(struct drm_device *dev) · line 757
Quoted 10 lines
drivers/gpu/drm/i915/i915_drv.c +1
-4!dev_priv->ums.mm_suspended) { -bool hw_contexts_disabled = dev_priv->hw_contexts_disabled; dev_priv->ums.mm_suspended =0 ; ret =i915_gem_init_hw (dev); -if (!hw_contexts_disabled && dev_priv->hw_contexts_disabled) -DRM_ERROR ("HW contexts didn't survive reset\n" ); -mutex_unlock (&dev->struct_mutex);if (ret) { +mutex_unlock (&dev->struct_mutex);
Botched locking.
Quoted 29 lines
drivers/gpu/drm/i915/i915_drv.c +0
-0DRM_ERROR ("Failed hw init on reset %d\n" , ret);return ret; }drivers/gpu/drm/i915/i915_drv.h +1
-2@@ -1411,7 +1411,6 @@ typedef struct drm_i915_private {struct drm_property *broadcast_rgb_property;struct drm_property *force_audio_property; -bool hw_contexts_disabled;uint32_t hw_context_size;struct list_head context_list;@@ -2140,7 +2139,7 @@ i915_gem_obj_ggtt_pin(struct drm_i915_gem_object *obj, }/* i915_gem_context.c */ -void i915_gem_context_init (struct drm_device *dev); +int __must_check i915_gem_context_init (struct drm_device *dev);void i915_gem_context_fini (struct drm_device *dev);void i915_gem_context_close (struct drm_device *dev,struct drm_file *file); int i915_switch_context(struct intel_ring_buffer *ring,drivers/gpu/drm/i915/i915_gem.c +0
-0
drivers/gpu/drm/i915/i915_gem.c i915_gem_init_hw(struct drm_device *dev) · line 4467
Quoted 6 lines
drivers/gpu/drm/i915/i915_gem.c +2
-1@@ -4463,7 +4463,12 @@ i915_gem_init_hw(struct drm_device *dev)* XXX: There was some w/a described somewhere suggesting loading * contexts before PPGTT. */ -i915_gem_context_init (dev); + ret =i915_gem_context_init (dev); +if (ret) {
i915_gem_cleanup_ringbuffer() ?
Damn our error unwinding is hard to follow, which means it's probably broken somewhere. From i915_load_modeset_init() we call i915_gem_init() which does some stuff directly and then calls i915_gem_init_hw(). And if we get some error later in i915_load_modeset_init(), we manually unwind all the stuff that i915_gem_init() and i915_gem_init_hw() supposedly did. This could sure use some i915_gem_fini() and i915_gem_fini_hw() to keep the do+undo code close together.
Quoted 145 lines
drivers/gpu/drm/i915/i915_gem.c +4
-0+DRM_ERROR ("Context initialization failed %d\n" , ret); +return ret; + } +if (dev_priv->mm.aliasing_ppgtt) { ret = dev_priv->mm.aliasing_ppgtt->enable (dev);if (ret) {drivers/gpu/drm/i915/i915_gem_context.c +20
-23@@ -244,36 +244,34 @@ err_destroy:return ret; } -void i915_gem_context_init (struct drm_device *dev) +int i915_gem_context_init (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; +int ret; -if (!HAS_HW_CONTEXTS (dev)) { - dev_priv->hw_contexts_disabled = true; -DRM_DEBUG_DRIVER ("Disabling HW Contexts; old hardware\n" ); -return ; - } +if (!HAS_HW_CONTEXTS (dev)) +return 0 ;/* If called from reset, or thaw... we've been here already */ -if (dev_priv->hw_contexts_disabled || - dev_priv->ring[RCS ].default_context) -return ; +if (dev_priv->ring[RCS ].default_context) +return 0 ; dev_priv->hw_context_size =round_up (get_context_size (dev),4096 );if (dev_priv->hw_context_size > (1 <<20 )) { - dev_priv->hw_contexts_disabled = true;DRM_DEBUG_DRIVER ("Disabling HW Contexts; invalid size\n" ); -return ; +return -E2BIG ; } -if (create_default_context (dev_priv)) { - dev_priv->hw_contexts_disabled = true; -DRM_DEBUG_DRIVER ("Disabling HW Contexts; create failed\n" ); -return ; + ret =create_default_context (dev_priv); +if (ret) { +DRM_DEBUG_DRIVER ("Disabling HW Contexts; create failed %d\n" , + ret); +return ret; }DRM_DEBUG_DRIVER ("HW context support initialized\n" ); +return 0 ; }void i915_gem_context_fini (struct drm_device *dev)@@ -281,7 +279,7 @@ void i915_gem_context_fini(struct drm_device *dev)struct drm_i915_private *dev_priv = dev->dev_private;struct i915_hw_context *dctx = dev_priv->ring[RCS ].default_context; -if (dev_priv->hw_contexts_disabled) +if (!HAS_HW_CONTEXTS (dev))return ;/* The only known way to stop the gpu from accessing the hw context is @@ -324,16 +322,16 @@ i915_gem_context_get_hang_stats(struct drm_device *dev, struct drm_file *file, u32 id) { -struct drm_i915_private *dev_priv = dev->dev_private;struct drm_i915_file_private *file_priv = file->driver_priv;struct i915_hw_context *ctx;if (id ==DEFAULT_CONTEXT_ID )return &file_priv->hang_stats; - ctx =NULL ; -if (!dev_priv->hw_contexts_disabled) - ctx =i915_gem_context_get (file->driver_priv, id); +if (!HAS_HW_CONTEXTS (dev)) +return ERR_PTR (-ENOENT ); + + ctx =i915_gem_context_get (file->driver_priv, id);if (ctx ==NULL )return ERR_PTR (-ENOENT );@@ -506,7 +504,7 @@ int i915_switch_context(struct intel_ring_buffer *ring,struct drm_i915_private *dev_priv = ring->dev->dev_private;struct i915_hw_context *to; -if (dev_priv->hw_contexts_disabled) +if (!HAS_HW_CONTEXTS (ring->dev))return 0 ;WARN_ON (!mutex_is_locked (&dev_priv->dev->struct_mutex));@@ -531,7 +529,6 @@ int i915_switch_context(struct intel_ring_buffer *ring,int i915_gem_context_create_ioctl (struct drm_device *dev,void *data,struct drm_file *file) { -struct drm_i915_private *dev_priv = dev->dev_private;struct drm_i915_gem_context_create *args = data;struct drm_i915_file_private *file_priv = file->driver_priv;struct i915_hw_context *ctx;@@ -540,7 +537,7 @@ int i915_gem_context_create_ioctl(struct drm_device *dev, void *data,if (!(dev->driver->driver_features &DRIVER_GEM ))return -ENODEV ; -if (dev_priv->hw_contexts_disabled) +if (!HAS_HW_CONTEXTS (dev))return -ENODEV ; ret =i915_mutex_lock_interruptible (dev);drivers/gpu/drm/i915/i915_sysfs.c +3
-3@@ -183,13 +183,13 @@ i915_l3_write(struct file *filp, struct kobject *kobj,int slice = (int )(uintptr_t )attr->private;int ret; +if (!HAS_HW_CONTEXTS (drm_dev)) +return -ENXIO ; + ret =l3_access_valid (drm_dev, offset);if (ret)return ret; -if (dev_priv->hw_contexts_disabled) -return -ENXIO ; - ret =i915_mutex_lock_interruptible (drm_dev);if (ret)return ret;Signature · 6 lines
1.8.4.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 2 lines
Ville Syrjälä Intel OTC
Quoted 26 lines · Ville Syrjälä
Quoted 25 lines · Ben Widawsky
From: Ben Widawsky <[email protected]>
Only compile tested
CC Kenneth Graunke <[email protected]>Signed-off-by Ben Widawsky <[email protected]>--- drivers/gpu/drm/i915/i915_drv.c | 5 +--- drivers/gpu/drm/i915/i915_drv.h | 3 +-- drivers/gpu/drm/i915/i915_gem.c | 7 +++++- drivers/gpu/drm/i915/i915_gem_context.c | 43 +++++++++++++++------------------ drivers/gpu/drm/i915/i915_sysfs.c | 6 ++--- 5 files changed, 31 insertions(+), 33 deletions(-)drivers/gpu/drm/i915/i915_drv.c +0
-1@@ -750,14 +750,11 @@ int i915_reset(struct drm_device *dev)*/ if (drm_core_check_feature (dev,DRIVER_MODESET ) || !dev_priv->ums.mm_suspended) { -bool hw_contexts_disabled = dev_priv->hw_contexts_disabled; dev_priv->ums.mm_suspended =0 ;
Quoted 8 lines
drivers/gpu/drm/i915/i915_drv.c int i915_reset(struct drm_device *dev) · line 757
Quoted 6 lines
drivers/gpu/drm/i915/i915_drv.c +1
-3ret =i915_gem_init_hw (dev); -if (!hw_contexts_disabled && dev_priv->hw_contexts_disabled) -DRM_ERROR ("HW contexts didn't survive reset\n" ); -mutex_unlock (&dev->struct_mutex);if (ret) { +mutex_unlock (&dev->struct_mutex);Botched locking.
My mistake was intentional at least, and not the usual copy/paste. Somehow this looked right to me earlier.
Thanks.
Quoted 39 lines
Quoted 30 lines
drivers/gpu/drm/i915/i915_drv.c +0
-0DRM_ERROR ("Failed hw init on reset %d\n" , ret);return ret; }drivers/gpu/drm/i915/i915_drv.h +1
-2@@ -1411,7 +1411,6 @@ typedef struct drm_i915_private {struct drm_property *broadcast_rgb_property;struct drm_property *force_audio_property; -bool hw_contexts_disabled;uint32_t hw_context_size;struct list_head context_list;@@ -2140,7 +2139,7 @@ i915_gem_obj_ggtt_pin(struct drm_i915_gem_object *obj, }/* i915_gem_context.c */ -void i915_gem_context_init (struct drm_device *dev); +int __must_check i915_gem_context_init (struct drm_device *dev);void i915_gem_context_fini (struct drm_device *dev);void i915_gem_context_close (struct drm_device *dev,struct drm_file *file); int i915_switch_context(struct intel_ring_buffer *ring,drivers/gpu/drm/i915/i915_gem.c +0
-0drivers/gpu/drm/i915/i915_gem.c i915_gem_init_hw(struct drm_device *dev) · line 4467
Quoted 6 lines
drivers/gpu/drm/i915/i915_gem.c +2
-1@@ -4463,7 +4463,12 @@ i915_gem_init_hw(struct drm_device *dev)* XXX: There was some w/a described somewhere suggesting loading * contexts before PPGTT. */ -i915_gem_context_init (dev); + ret =i915_gem_context_init (dev); +if (ret) {
i915_gem_cleanup_ringbuffer()?
Quoted 8 lines
Damn our error unwinding is hard to follow, which means it's probably broken somewhere. From
i915_load_modeset_init()we calli915_gem_init()which does some stuff directly and then callsi915_gem_init_hw(). And if we get some error later ini915_load_modeset_init(), we manually unwind all the stuff thati915_gem_init()andi915_gem_init_hw()supposedly did. This could sure use somei915_gem_fini()andi915_gem_fini_hw()to keep the do+undo code close together.
It's definitely a mess. TBF, it's been changing a lot more recently than it had in the past.
But yeah this is missing. I wonder if I missed this last time I wrote the patch too...? Thanks.
Quoted 132 lines
Quoted 132 lines
drivers/gpu/drm/i915/i915_gem.c +4
-0+DRM_ERROR ("Context initialization failed %d\n" , ret); +return ret; + } +if (dev_priv->mm.aliasing_ppgtt) { ret = dev_priv->mm.aliasing_ppgtt->enable (dev);if (ret) {drivers/gpu/drm/i915/i915_gem_context.c +20
-23@@ -244,36 +244,34 @@ err_destroy:return ret; } -void i915_gem_context_init (struct drm_device *dev) +int i915_gem_context_init (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; +int ret; -if (!HAS_HW_CONTEXTS (dev)) { - dev_priv->hw_contexts_disabled = true; -DRM_DEBUG_DRIVER ("Disabling HW Contexts; old hardware\n" ); -return ; - } +if (!HAS_HW_CONTEXTS (dev)) +return 0 ;/* If called from reset, or thaw... we've been here already */ -if (dev_priv->hw_contexts_disabled || - dev_priv->ring[RCS ].default_context) -return ; +if (dev_priv->ring[RCS ].default_context) +return 0 ; dev_priv->hw_context_size =round_up (get_context_size (dev),4096 );if (dev_priv->hw_context_size > (1 <<20 )) { - dev_priv->hw_contexts_disabled = true;DRM_DEBUG_DRIVER ("Disabling HW Contexts; invalid size\n" ); -return ; +return -E2BIG ; } -if (create_default_context (dev_priv)) { - dev_priv->hw_contexts_disabled = true; -DRM_DEBUG_DRIVER ("Disabling HW Contexts; create failed\n" ); -return ; + ret =create_default_context (dev_priv); +if (ret) { +DRM_DEBUG_DRIVER ("Disabling HW Contexts; create failed %d\n" , + ret); +return ret; }DRM_DEBUG_DRIVER ("HW context support initialized\n" ); +return 0 ; }void i915_gem_context_fini (struct drm_device *dev)@@ -281,7 +279,7 @@ void i915_gem_context_fini(struct drm_device *dev)struct drm_i915_private *dev_priv = dev->dev_private;struct i915_hw_context *dctx = dev_priv->ring[RCS ].default_context; -if (dev_priv->hw_contexts_disabled) +if (!HAS_HW_CONTEXTS (dev))return ;/* The only known way to stop the gpu from accessing the hw context is @@ -324,16 +322,16 @@ i915_gem_context_get_hang_stats(struct drm_device *dev, struct drm_file *file, u32 id) { -struct drm_i915_private *dev_priv = dev->dev_private;struct drm_i915_file_private *file_priv = file->driver_priv;struct i915_hw_context *ctx;if (id ==DEFAULT_CONTEXT_ID )return &file_priv->hang_stats; - ctx =NULL ; -if (!dev_priv->hw_contexts_disabled) - ctx =i915_gem_context_get (file->driver_priv, id); +if (!HAS_HW_CONTEXTS (dev)) +return ERR_PTR (-ENOENT ); + + ctx =i915_gem_context_get (file->driver_priv, id);if (ctx ==NULL )return ERR_PTR (-ENOENT );@@ -506,7 +504,7 @@ int i915_switch_context(struct intel_ring_buffer *ring,struct drm_i915_private *dev_priv = ring->dev->dev_private;struct i915_hw_context *to; -if (dev_priv->hw_contexts_disabled) +if (!HAS_HW_CONTEXTS (ring->dev))return 0 ;WARN_ON (!mutex_is_locked (&dev_priv->dev->struct_mutex));@@ -531,7 +529,6 @@ int i915_switch_context(struct intel_ring_buffer *ring,int i915_gem_context_create_ioctl (struct drm_device *dev,void *data,struct drm_file *file) { -struct drm_i915_private *dev_priv = dev->dev_private;struct drm_i915_gem_context_create *args = data;struct drm_i915_file_private *file_priv = file->driver_priv;struct i915_hw_context *ctx;@@ -540,7 +537,7 @@ int i915_gem_context_create_ioctl(struct drm_device *dev, void *data,if (!(dev->driver->driver_features &DRIVER_GEM ))return -ENODEV ; -if (dev_priv->hw_contexts_disabled) +if (!HAS_HW_CONTEXTS (dev))return -ENODEV ; ret =i915_mutex_lock_interruptible (dev);drivers/gpu/drm/i915/i915_sysfs.c +3
-0@@ -183,13 +183,13 @@ i915_l3_write(struct file *filp, struct kobject *kobj,int slice = (int )(uintptr_t )attr->private;int ret; +if (!HAS_HW_CONTEXTS (drm_dev)) +return -ENXIO ; + ret =l3_access_valid (drm_dev, offset);if (ret)return ret;
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/i915/i915_sysfs.c +0
-3-if (dev_priv->hw_contexts_disabled) -return -ENXIO ; - ret =i915_mutex_lock_interruptible (drm_dev);if (ret)return ret;Signature · 1 line
1.8.4.1
Nobody is commenting on whether or not this is okay, which is what I was really interesting.
Signature · 5 lines
Ben Widawsky, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 1/1 drm/i915: Require HW contexts (when possible)
In reply to Ville Syrjäläv2: Fixed the botched locking on init_hw failure in i915_reset (Ville) Call cleanup_ringbuffer on failed context create in init_hw (Ville)
--- drivers/gpu/drm/i915/i915_drv.c | 3 --- drivers/gpu/drm/i915/i915_drv.h | 3 +-- drivers/gpu/drm/i915/i915_gem.c | 8 +++++- drivers/gpu/drm/i915/i915_gem_context.c | 43 +++++++++++++++------------------ drivers/gpu/drm/i915/i915_sysfs.c | 6 ++--- 5 files changed, 31 insertions(+), 32 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +0 -3
@@ -750,12 +750,9 @@ int i915_reset(struct drm_device *dev)*/ if (drm_core_check_feature (dev,DRIVER_MODESET ) || !dev_priv->ums.mm_suspended) { -bool hw_contexts_disabled = dev_priv->hw_contexts_disabled; dev_priv->ums.mm_suspended =0 ; ret =i915_gem_init_hw (dev); -if (!hw_contexts_disabled && dev_priv->hw_contexts_disabled) -DRM_ERROR ("HW contexts didn't survive reset\n" );mutex_unlock (&dev->struct_mutex);if (ret) {DRM_ERROR ("Failed hw init on reset %d\n" , ret);
drivers/gpu/drm/i915/i915_drv.h +1 -2
@@ -1411,7 +1411,6 @@ typedef struct drm_i915_private {struct drm_property *broadcast_rgb_property;struct drm_property *force_audio_property; -bool hw_contexts_disabled;uint32_t hw_context_size;struct list_head context_list;
@@ -2140,7 +2139,7 @@ i915_gem_obj_ggtt_pin(struct drm_i915_gem_object *obj, }/* i915_gem_context.c */ -void i915_gem_context_init (struct drm_device *dev); +int __must_check i915_gem_context_init (struct drm_device *dev);void i915_gem_context_fini (struct drm_device *dev);void i915_gem_context_close (struct drm_device *dev,struct drm_file *file); int i915_switch_context(struct intel_ring_buffer *ring,
drivers/gpu/drm/i915/i915_gem.c +7 -1
@@ -4463,7 +4463,13 @@ i915_gem_init_hw(struct drm_device *dev)* XXX: There was some w/a described somewhere suggesting loading * contexts before PPGTT. */ -i915_gem_context_init (dev); + ret =i915_gem_context_init (dev); +if (ret) { +i915_gem_cleanup_ringbuffer (); +DRM_ERROR ("Context initialization failed %d\n" , ret); +return ret; + } +if (dev_priv->mm.aliasing_ppgtt) { ret = dev_priv->mm.aliasing_ppgtt->enable (dev);if (ret) {
drivers/gpu/drm/i915/i915_gem_context.c +20 -23
100 lines not on this page · raw message
drivers/gpu/drm/i915/i915_sysfs.c +3 -3
@@ -183,13 +183,13 @@ i915_l3_write(struct file *filp, struct kobject *kobj,int slice = (int )(uintptr_t )attr->private;int ret; +if (!HAS_HW_CONTEXTS (drm_dev)) +return -ENXIO ; + ret =l3_access_valid (drm_dev, offset);if (ret)return ret; -if (dev_priv->hw_contexts_disabled) -return -ENXIO ; - ret =i915_mutex_lock_interruptible (drm_dev);if (ret)return ret;
Signature · 1 line
1.8.4.1
Quoted 57 lines · Ben Widawsky
v2: Fixed the botched locking on
init_hwfailure ini915_reset(Ville) Callcleanup_ringbufferon failed context create ininit_hw(Ville)Reviewed-by Kenneth Graunke <[email protected]>Signed-off-by Ben Widawsky <[email protected]>--- drivers/gpu/drm/i915/i915_drv.c | 3 --- drivers/gpu/drm/i915/i915_drv.h | 3 +-- drivers/gpu/drm/i915/i915_gem.c | 8 +++++- drivers/gpu/drm/i915/i915_gem_context.c | 43 +++++++++++++++------------------ drivers/gpu/drm/i915/i915_sysfs.c | 6 ++--- 5 files changed, 31 insertions(+), 32 deletions(-)drivers/gpu/drm/i915/i915_drv.c +0
-3@@ -750,12 +750,9 @@ int i915_reset(struct drm_device *dev)*/ if (drm_core_check_feature (dev,DRIVER_MODESET ) || !dev_priv->ums.mm_suspended) { -bool hw_contexts_disabled = dev_priv->hw_contexts_disabled; dev_priv->ums.mm_suspended =0 ; ret =i915_gem_init_hw (dev); -if (!hw_contexts_disabled && dev_priv->hw_contexts_disabled) -DRM_ERROR ("HW contexts didn't survive reset\n" );mutex_unlock (&dev->struct_mutex);if (ret) {DRM_ERROR ("Failed hw init on reset %d\n" , ret);drivers/gpu/drm/i915/i915_drv.h +1
-2@@ -1411,7 +1411,6 @@ typedef struct drm_i915_private {struct drm_property *broadcast_rgb_property;struct drm_property *force_audio_property; -bool hw_contexts_disabled;uint32_t hw_context_size;struct list_head context_list;@@ -2140,7 +2139,7 @@ i915_gem_obj_ggtt_pin(struct drm_i915_gem_object *obj, }/* i915_gem_context.c */ -void i915_gem_context_init (struct drm_device *dev); +int __must_check i915_gem_context_init (struct drm_device *dev);void i915_gem_context_fini (struct drm_device *dev);void i915_gem_context_close (struct drm_device *dev,struct drm_file *file); int i915_switch_context(struct intel_ring_buffer *ring,drivers/gpu/drm/i915/i915_gem.c +0
-0@@ -4463,7 +4463,13 @@ i915_gem_init_hw(struct drm_device *dev)* XXX: There was some w/a described somewhere suggesting loading
drivers/gpu/drm/i915/i915_gem.c i915_gem_init_hw(struct drm_device *dev) · line 4472
Quoted 10 lines
drivers/gpu/drm/i915/i915_gem.c +7
-1* contexts before PPGTT. */ -i915_gem_context_init (dev); + ret =i915_gem_context_init (dev); +if (ret) { +i915_gem_cleanup_ringbuffer (); +DRM_ERROR ("Context initialization failed %d\n" , ret); +return ret; + } +
Oops. I clearly didn't build this. Will resend.
Quoted 137 lines
drivers/gpu/drm/i915/i915_gem.c +0
-0if (dev_priv->mm.aliasing_ppgtt) { ret = dev_priv->mm.aliasing_ppgtt->enable (dev);if (ret) {drivers/gpu/drm/i915/i915_gem_context.c +20
-23@@ -244,36 +244,34 @@ err_destroy:return ret; } -void i915_gem_context_init (struct drm_device *dev) +int i915_gem_context_init (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; +int ret; -if (!HAS_HW_CONTEXTS (dev)) { - dev_priv->hw_contexts_disabled = true; -DRM_DEBUG_DRIVER ("Disabling HW Contexts; old hardware\n" ); -return ; - } +if (!HAS_HW_CONTEXTS (dev)) +return 0 ;/* If called from reset, or thaw... we've been here already */ -if (dev_priv->hw_contexts_disabled || - dev_priv->ring[RCS ].default_context) -return ; +if (dev_priv->ring[RCS ].default_context) +return 0 ; dev_priv->hw_context_size =round_up (get_context_size (dev),4096 );if (dev_priv->hw_context_size > (1 <<20 )) { - dev_priv->hw_contexts_disabled = true;DRM_DEBUG_DRIVER ("Disabling HW Contexts; invalid size\n" ); -return ; +return -E2BIG ; } -if (create_default_context (dev_priv)) { - dev_priv->hw_contexts_disabled = true; -DRM_DEBUG_DRIVER ("Disabling HW Contexts; create failed\n" ); -return ; + ret =create_default_context (dev_priv); +if (ret) { +DRM_DEBUG_DRIVER ("Disabling HW Contexts; create failed %d\n" , + ret); +return ret; }DRM_DEBUG_DRIVER ("HW context support initialized\n" ); +return 0 ; }void i915_gem_context_fini (struct drm_device *dev)@@ -281,7 +279,7 @@ void i915_gem_context_fini(struct drm_device *dev)struct drm_i915_private *dev_priv = dev->dev_private;struct i915_hw_context *dctx = dev_priv->ring[RCS ].default_context; -if (dev_priv->hw_contexts_disabled) +if (!HAS_HW_CONTEXTS (dev))return ;/* The only known way to stop the gpu from accessing the hw context is @@ -324,16 +322,16 @@ i915_gem_context_get_hang_stats(struct drm_device *dev, struct drm_file *file, u32 id) { -struct drm_i915_private *dev_priv = dev->dev_private;struct drm_i915_file_private *file_priv = file->driver_priv;struct i915_hw_context *ctx;if (id ==DEFAULT_CONTEXT_ID )return &file_priv->hang_stats; - ctx =NULL ; -if (!dev_priv->hw_contexts_disabled) - ctx =i915_gem_context_get (file->driver_priv, id); +if (!HAS_HW_CONTEXTS (dev)) +return ERR_PTR (-ENOENT ); + + ctx =i915_gem_context_get (file->driver_priv, id);if (ctx ==NULL )return ERR_PTR (-ENOENT );@@ -506,7 +504,7 @@ int i915_switch_context(struct intel_ring_buffer *ring,struct drm_i915_private *dev_priv = ring->dev->dev_private;struct i915_hw_context *to; -if (dev_priv->hw_contexts_disabled) +if (!HAS_HW_CONTEXTS (ring->dev))return 0 ;WARN_ON (!mutex_is_locked (&dev_priv->dev->struct_mutex));@@ -531,7 +529,6 @@ int i915_switch_context(struct intel_ring_buffer *ring,int i915_gem_context_create_ioctl (struct drm_device *dev,void *data,struct drm_file *file) { -struct drm_i915_private *dev_priv = dev->dev_private;struct drm_i915_gem_context_create *args = data;struct drm_i915_file_private *file_priv = file->driver_priv;struct i915_hw_context *ctx;@@ -540,7 +537,7 @@ int i915_gem_context_create_ioctl(struct drm_device *dev, void *data,if (!(dev->driver->driver_features &DRIVER_GEM ))return -ENODEV ; -if (dev_priv->hw_contexts_disabled) +if (!HAS_HW_CONTEXTS (dev))return -ENODEV ; ret =i915_mutex_lock_interruptible (dev);drivers/gpu/drm/i915/i915_sysfs.c +3
-3@@ -183,13 +183,13 @@ i915_l3_write(struct file *filp, struct kobject *kobj,int slice = (int )(uintptr_t )attr->private;int ret; +if (!HAS_HW_CONTEXTS (drm_dev)) +return -ENXIO ; + ret =l3_access_valid (drm_dev, offset);if (ret)return ret; -if (dev_priv->hw_contexts_disabled) -return -ENXIO ; - ret =i915_mutex_lock_interruptible (drm_dev);if (ret)return ret;Signature · 1 line
1.8.4.1
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
PATCH v3 1/1 drm/i915: Require HW contexts (when possible)
In reply to Ben Widawskyv2: Fixed the botched locking on init_hw failure in i915_reset (Ville) Call cleanup_ringbuffer on failed context create in init_hw (Ville)
v3: Add dev argument ti clean_ringbuffer
--- drivers/gpu/drm/i915/i915_drv.c | 3 --- drivers/gpu/drm/i915/i915_drv.h | 3 +-- drivers/gpu/drm/i915/i915_gem.c | 8 +++++- drivers/gpu/drm/i915/i915_gem_context.c | 43 +++++++++++++++------------------ drivers/gpu/drm/i915/i915_sysfs.c | 6 ++--- 5 files changed, 31 insertions(+), 32 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +0 -3
@@ -750,12 +750,9 @@ int i915_reset(struct drm_device *dev)*/ if (drm_core_check_feature (dev,DRIVER_MODESET ) || !dev_priv->ums.mm_suspended) { -bool hw_contexts_disabled = dev_priv->hw_contexts_disabled; dev_priv->ums.mm_suspended =0 ; ret =i915_gem_init_hw (dev); -if (!hw_contexts_disabled && dev_priv->hw_contexts_disabled) -DRM_ERROR ("HW contexts didn't survive reset\n" );mutex_unlock (&dev->struct_mutex);if (ret) {DRM_ERROR ("Failed hw init on reset %d\n" , ret);
drivers/gpu/drm/i915/i915_drv.h +1 -2
@@ -1411,7 +1411,6 @@ typedef struct drm_i915_private {struct drm_property *broadcast_rgb_property;struct drm_property *force_audio_property; -bool hw_contexts_disabled;uint32_t hw_context_size;struct list_head context_list;
@@ -2140,7 +2139,7 @@ i915_gem_obj_ggtt_pin(struct drm_i915_gem_object *obj, }/* i915_gem_context.c */ -void i915_gem_context_init (struct drm_device *dev); +int __must_check i915_gem_context_init (struct drm_device *dev);void i915_gem_context_fini (struct drm_device *dev);void i915_gem_context_close (struct drm_device *dev,struct drm_file *file); int i915_switch_context(struct intel_ring_buffer *ring,
drivers/gpu/drm/i915/i915_gem.c +7 -1
@@ -4463,7 +4463,13 @@ i915_gem_init_hw(struct drm_device *dev)* XXX: There was some w/a described somewhere suggesting loading * contexts before PPGTT. */ -i915_gem_context_init (dev); + ret =i915_gem_context_init (dev); +if (ret) { +i915_gem_cleanup_ringbuffer (dev); +DRM_ERROR ("Context initialization failed %d\n" , ret); +return ret; + } +if (dev_priv->mm.aliasing_ppgtt) { ret = dev_priv->mm.aliasing_ppgtt->enable (dev);if (ret) {
drivers/gpu/drm/i915/i915_gem_context.c +20 -23
100 lines not on this page · raw message
drivers/gpu/drm/i915/i915_sysfs.c +3 -3
@@ -183,13 +183,13 @@ i915_l3_write(struct file *filp, struct kobject *kobj,int slice = (int )(uintptr_t )attr->private;int ret; +if (!HAS_HW_CONTEXTS (drm_dev)) +return -ENXIO ; + ret =l3_access_valid (drm_dev, offset);if (ret)return ret; -if (dev_priv->hw_contexts_disabled) -return -ENXIO ; - ret =i915_mutex_lock_interruptible (drm_dev);if (ret)return ret;
Signature · 1 line
1.8.4.1
Quoted 7 lines · Ben Widawsky
v2: Fixed the botched locking on
init_hwfailure ini915_reset(Ville) Callcleanup_ringbufferon failed context create ininit_hw(Ville)v3: Add dev argument ti
clean_ringbufferReviewed-by Kenneth Graunke <[email protected]>Signed-off-by Ben Widawsky <[email protected]>
Quoted 203 lines
--- drivers/gpu/drm/i915/i915_drv.c | 3 --- drivers/gpu/drm/i915/i915_drv.h | 3 +-- drivers/gpu/drm/i915/i915_gem.c | 8 +++++- drivers/gpu/drm/i915/i915_gem_context.c | 43 +++++++++++++++------------------ drivers/gpu/drm/i915/i915_sysfs.c | 6 ++--- 5 files changed, 31 insertions(+), 32 deletions(-)drivers/gpu/drm/i915/i915_drv.c +0
-3@@ -750,12 +750,9 @@ int i915_reset(struct drm_device *dev)*/ if (drm_core_check_feature (dev,DRIVER_MODESET ) || !dev_priv->ums.mm_suspended) { -bool hw_contexts_disabled = dev_priv->hw_contexts_disabled; dev_priv->ums.mm_suspended =0 ; ret =i915_gem_init_hw (dev); -if (!hw_contexts_disabled && dev_priv->hw_contexts_disabled) -DRM_ERROR ("HW contexts didn't survive reset\n" );mutex_unlock (&dev->struct_mutex);if (ret) {DRM_ERROR ("Failed hw init on reset %d\n" , ret);drivers/gpu/drm/i915/i915_drv.h +1
-2@@ -1411,7 +1411,6 @@ typedef struct drm_i915_private {struct drm_property *broadcast_rgb_property;struct drm_property *force_audio_property; -bool hw_contexts_disabled;uint32_t hw_context_size;struct list_head context_list;@@ -2140,7 +2139,7 @@ i915_gem_obj_ggtt_pin(struct drm_i915_gem_object *obj, }/* i915_gem_context.c */ -void i915_gem_context_init (struct drm_device *dev); +int __must_check i915_gem_context_init (struct drm_device *dev);void i915_gem_context_fini (struct drm_device *dev);void i915_gem_context_close (struct drm_device *dev,struct drm_file *file); int i915_switch_context(struct intel_ring_buffer *ring,drivers/gpu/drm/i915/i915_gem.c +7
-1@@ -4463,7 +4463,13 @@ i915_gem_init_hw(struct drm_device *dev)* XXX: There was some w/a described somewhere suggesting loading * contexts before PPGTT. */ -i915_gem_context_init (dev); + ret =i915_gem_context_init (dev); +if (ret) { +i915_gem_cleanup_ringbuffer (dev); +DRM_ERROR ("Context initialization failed %d\n" , ret); +return ret; + } +if (dev_priv->mm.aliasing_ppgtt) { ret = dev_priv->mm.aliasing_ppgtt->enable (dev);if (ret) {drivers/gpu/drm/i915/i915_gem_context.c +20
-23@@ -244,36 +244,34 @@ err_destroy:return ret; } -void i915_gem_context_init (struct drm_device *dev) +int i915_gem_context_init (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; +int ret; -if (!HAS_HW_CONTEXTS (dev)) { - dev_priv->hw_contexts_disabled = true; -DRM_DEBUG_DRIVER ("Disabling HW Contexts; old hardware\n" ); -return ; - } +if (!HAS_HW_CONTEXTS (dev)) +return 0 ;/* If called from reset, or thaw... we've been here already */ -if (dev_priv->hw_contexts_disabled || - dev_priv->ring[RCS ].default_context) -return ; +if (dev_priv->ring[RCS ].default_context) +return 0 ; dev_priv->hw_context_size =round_up (get_context_size (dev),4096 );if (dev_priv->hw_context_size > (1 <<20 )) { - dev_priv->hw_contexts_disabled = true;DRM_DEBUG_DRIVER ("Disabling HW Contexts; invalid size\n" ); -return ; +return -E2BIG ; } -if (create_default_context (dev_priv)) { - dev_priv->hw_contexts_disabled = true; -DRM_DEBUG_DRIVER ("Disabling HW Contexts; create failed\n" ); -return ; + ret =create_default_context (dev_priv); +if (ret) { +DRM_DEBUG_DRIVER ("Disabling HW Contexts; create failed %d\n" , + ret); +return ret; }DRM_DEBUG_DRIVER ("HW context support initialized\n" ); +return 0 ; }void i915_gem_context_fini (struct drm_device *dev)@@ -281,7 +279,7 @@ void i915_gem_context_fini(struct drm_device *dev)struct drm_i915_private *dev_priv = dev->dev_private;struct i915_hw_context *dctx = dev_priv->ring[RCS ].default_context; -if (dev_priv->hw_contexts_disabled) +if (!HAS_HW_CONTEXTS (dev))return ;/* The only known way to stop the gpu from accessing the hw context is @@ -324,16 +322,16 @@ i915_gem_context_get_hang_stats(struct drm_device *dev, struct drm_file *file, u32 id) { -struct drm_i915_private *dev_priv = dev->dev_private;struct drm_i915_file_private *file_priv = file->driver_priv;struct i915_hw_context *ctx;if (id ==DEFAULT_CONTEXT_ID )return &file_priv->hang_stats; - ctx =NULL ; -if (!dev_priv->hw_contexts_disabled) - ctx =i915_gem_context_get (file->driver_priv, id); +if (!HAS_HW_CONTEXTS (dev)) +return ERR_PTR (-ENOENT ); + + ctx =i915_gem_context_get (file->driver_priv, id);if (ctx ==NULL )return ERR_PTR (-ENOENT );@@ -506,7 +504,7 @@ int i915_switch_context(struct intel_ring_buffer *ring,struct drm_i915_private *dev_priv = ring->dev->dev_private;struct i915_hw_context *to; -if (dev_priv->hw_contexts_disabled) +if (!HAS_HW_CONTEXTS (ring->dev))return 0 ;WARN_ON (!mutex_is_locked (&dev_priv->dev->struct_mutex));@@ -531,7 +529,6 @@ int i915_switch_context(struct intel_ring_buffer *ring,int i915_gem_context_create_ioctl (struct drm_device *dev,void *data,struct drm_file *file) { -struct drm_i915_private *dev_priv = dev->dev_private;struct drm_i915_gem_context_create *args = data;struct drm_i915_file_private *file_priv = file->driver_priv;struct i915_hw_context *ctx;@@ -540,7 +537,7 @@ int i915_gem_context_create_ioctl(struct drm_device *dev, void *data,if (!(dev->driver->driver_features &DRIVER_GEM ))return -ENODEV ; -if (dev_priv->hw_contexts_disabled) +if (!HAS_HW_CONTEXTS (dev))return -ENODEV ; ret =i915_mutex_lock_interruptible (dev);drivers/gpu/drm/i915/i915_sysfs.c +3
-3@@ -183,13 +183,13 @@ i915_l3_write(struct file *filp, struct kobject *kobj,int slice = (int )(uintptr_t )attr->private;int ret; +if (!HAS_HW_CONTEXTS (drm_dev)) +return -ENXIO ; + ret =l3_access_valid (drm_dev, offset);if (ret)return ret; -if (dev_priv->hw_contexts_disabled) -return -ENXIO ; - ret =i915_mutex_lock_interruptible (drm_dev);if (ret)return ret;Signature · 6 lines
1.8.4.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 2 lines
Ville Syrjälä Intel OTC