diff mbox

drm/i915: Optimize the i915_gem_gtt_finish_object function

Message ID 1405099208-4085-2-git-send-email-armin.c.reese@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Reese, Armin C July 11, 2014, 5:20 p.m. UTC
From: Armin Reese <armin.c.reese@intel.com>

Signed-off-by: Armin Reese <armin.c.reese@intel.com>
---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

Comments

Ben Widawsky July 17, 2014, 11:16 p.m. UTC | #1
On Fri, Jul 11, 2014 at 10:20:08AM -0700, armin.c.reese@intel.com wrote:
> From: Armin Reese <armin.c.reese@intel.com>
> 
> Signed-off-by: Armin Reese <armin.c.reese@intel.com>
> ---
>  drivers/gpu/drm/i915/i915_gem_gtt.c | 13 ++++++-------
>  1 file changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
> index afd4eef..7e2190e 100644
> --- a/drivers/gpu/drm/i915/i915_gem_gtt.c
> +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
> @@ -1624,18 +1624,17 @@ static void ggtt_unbind_vma(struct i915_vma *vma)
>  
>  void i915_gem_gtt_finish_object(struct drm_i915_gem_object *obj)
>  {
> -	struct drm_device *dev = obj->base.dev;
> -	struct drm_i915_private *dev_priv = dev->dev_private;
> -	bool interruptible;
> -
> -	interruptible = do_idling(dev_priv);
> +	if (!obj->has_dma_mapping) {
> +		struct drm_device *dev = obj->base.dev;
> +		struct drm_i915_private *dev_priv = dev->dev_private;
> +		bool interruptible = do_idling(dev_priv);
>  
> -	if (!obj->has_dma_mapping)
>  		dma_unmap_sg(&dev->pdev->dev,
>  			     obj->pages->sgl, obj->pages->nents,
>  			     PCI_DMA_BIDIRECTIONAL);
>  
> -	undo_idling(dev_priv, interruptible);
> +		undo_idling(dev_priv, interruptible);
> +	}
>  }
>  
>  static void i915_gtt_color_adjust(struct drm_mm_node *node,

Note that this doesn't do much on platforms you care about.
Daniel Vetter July 18, 2014, 12:05 p.m. UTC | #2
On Fri, Jul 18, 2014 at 1:16 AM, Ben Widawsky <ben@bwidawsk.net> wrote:
> On Fri, Jul 11, 2014 at 10:20:08AM -0700, armin.c.reese@intel.com wrote:
>> From: Armin Reese <armin.c.reese@intel.com>
>>
>> Signed-off-by: Armin Reese <armin.c.reese@intel.com>
>> ---
>>  drivers/gpu/drm/i915/i915_gem_gtt.c | 13 ++++++-------
>>  1 file changed, 6 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
>> index afd4eef..7e2190e 100644
>> --- a/drivers/gpu/drm/i915/i915_gem_gtt.c
>> +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
>> @@ -1624,18 +1624,17 @@ static void ggtt_unbind_vma(struct i915_vma *vma)
>>
>>  void i915_gem_gtt_finish_object(struct drm_i915_gem_object *obj)
>>  {
>> -     struct drm_device *dev = obj->base.dev;
>> -     struct drm_i915_private *dev_priv = dev->dev_private;
>> -     bool interruptible;
>> -
>> -     interruptible = do_idling(dev_priv);
>> +     if (!obj->has_dma_mapping) {
>> +             struct drm_device *dev = obj->base.dev;
>> +             struct drm_i915_private *dev_priv = dev->dev_private;
>> +             bool interruptible = do_idling(dev_priv);
>>
>> -     if (!obj->has_dma_mapping)
>>               dma_unmap_sg(&dev->pdev->dev,
>>                            obj->pages->sgl, obj->pages->nents,
>>                            PCI_DMA_BIDIRECTIONAL);
>>
>> -     undo_idling(dev_priv, interruptible);
>> +             undo_idling(dev_priv, interruptible);
>> +     }
>>  }
>>
>>  static void i915_gtt_color_adjust(struct drm_mm_node *node,
>
> Note that this doesn't do much on platforms you care about.

To elaborate: This w/a is _only_ used on ironlake when the iommu is
enabled. Also the performance impact of it is so disastrous that any
kind of optimization is pointless.
-Daniel
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index afd4eef..7e2190e 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -1624,18 +1624,17 @@  static void ggtt_unbind_vma(struct i915_vma *vma)
 
 void i915_gem_gtt_finish_object(struct drm_i915_gem_object *obj)
 {
-	struct drm_device *dev = obj->base.dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-	bool interruptible;
-
-	interruptible = do_idling(dev_priv);
+	if (!obj->has_dma_mapping) {
+		struct drm_device *dev = obj->base.dev;
+		struct drm_i915_private *dev_priv = dev->dev_private;
+		bool interruptible = do_idling(dev_priv);
 
-	if (!obj->has_dma_mapping)
 		dma_unmap_sg(&dev->pdev->dev,
 			     obj->pages->sgl, obj->pages->nents,
 			     PCI_DMA_BIDIRECTIONAL);
 
-	undo_idling(dev_priv, interruptible);
+		undo_idling(dev_priv, interruptible);
+	}
 }
 
 static void i915_gtt_color_adjust(struct drm_mm_node *node,