diff mbox series

[06/19] drm/i915/stolen: pass the allocation flags

Message ID 20210412090526.30547-7-matthew.auld@intel.com (mailing list archive)
State New, archived
Headers show
Series More DG1 enabling | expand

Commit Message

Matthew Auld April 12, 2021, 9:05 a.m. UTC
From: CQ Tang <cq.tang@intel.com>

Stolen memory is always allocated as physically contiguous pages, mark
the object flags as such.

Signed-off-by: CQ Tang <cq.tang@intel.com>
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_stolen.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Tvrtko Ursulin April 14, 2021, 3:09 p.m. UTC | #1
On 12/04/2021 10:05, Matthew Auld wrote:
> From: CQ Tang <cq.tang@intel.com>
> 
> Stolen memory is always allocated as physically contiguous pages, mark
> the object flags as such.
> 
> Signed-off-by: CQ Tang <cq.tang@intel.com>
> Signed-off-by: Matthew Auld <matthew.auld@intel.com>
> ---
>   drivers/gpu/drm/i915/gem/i915_gem_stolen.c | 10 ++++++----
>   1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_stolen.c b/drivers/gpu/drm/i915/gem/i915_gem_stolen.c
> index f713eabb7671..49a2dfcc8ba7 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_stolen.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_stolen.c
> @@ -633,14 +633,15 @@ static const struct drm_i915_gem_object_ops i915_gem_object_stolen_ops = {
>   
>   static int __i915_gem_object_create_stolen(struct intel_memory_region *mem,
>   					   struct drm_i915_gem_object *obj,
> -					   struct drm_mm_node *stolen)
> +					   struct drm_mm_node *stolen,
> +					   unsigned int flags)
>   {
>   	static struct lock_class_key lock_class;
>   	unsigned int cache_level;
>   	int err;
>   
>   	drm_gem_private_object_init(&mem->i915->drm, &obj->base, stolen->size);
> -	i915_gem_object_init(obj, &i915_gem_object_stolen_ops, &lock_class, 0);
> +	i915_gem_object_init(obj, &i915_gem_object_stolen_ops, &lock_class, flags);
>   
>   	obj->stolen = stolen;
>   	obj->read_domains = I915_GEM_DOMAIN_CPU | I915_GEM_DOMAIN_GTT;
> @@ -682,7 +683,7 @@ static int _i915_gem_object_stolen_init(struct intel_memory_region *mem,
>   	if (ret)
>   		goto err_free;
>   
> -	ret = __i915_gem_object_create_stolen(mem, obj, stolen);
> +	ret = __i915_gem_object_create_stolen(mem, obj, stolen, flags);
>   	if (ret)
>   		goto err_remove;
>   
> @@ -840,7 +841,8 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_i915_private *i915,
>   		goto err_stolen;
>   	}
>   
> -	ret = __i915_gem_object_create_stolen(mem, obj, stolen);
> +	ret = __i915_gem_object_create_stolen(mem, obj, stolen,
> +					      I915_BO_ALLOC_CONTIGUOUS);
>   	if (ret)
>   		goto err_object_free;
>   
> 

Are all stolen objects always contiguous or only ones allocated by 
i915_gem_object_create_stolen_for_preallocated? If former should 
__i915_gem_object_create_stolen just set the flag without the need to 
pass it in?

Regards,

Tvrtko
Matthew Auld April 16, 2021, 1:53 p.m. UTC | #2
On 14/04/2021 16:09, Tvrtko Ursulin wrote:
> 
> On 12/04/2021 10:05, Matthew Auld wrote:
>> From: CQ Tang <cq.tang@intel.com>
>>
>> Stolen memory is always allocated as physically contiguous pages, mark
>> the object flags as such.
>>
>> Signed-off-by: CQ Tang <cq.tang@intel.com>
>> Signed-off-by: Matthew Auld <matthew.auld@intel.com>
>> ---
>>   drivers/gpu/drm/i915/gem/i915_gem_stolen.c | 10 ++++++----
>>   1 file changed, 6 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_stolen.c 
>> b/drivers/gpu/drm/i915/gem/i915_gem_stolen.c
>> index f713eabb7671..49a2dfcc8ba7 100644
>> --- a/drivers/gpu/drm/i915/gem/i915_gem_stolen.c
>> +++ b/drivers/gpu/drm/i915/gem/i915_gem_stolen.c
>> @@ -633,14 +633,15 @@ static const struct drm_i915_gem_object_ops 
>> i915_gem_object_stolen_ops = {
>>   static int __i915_gem_object_create_stolen(struct 
>> intel_memory_region *mem,
>>                          struct drm_i915_gem_object *obj,
>> -                       struct drm_mm_node *stolen)
>> +                       struct drm_mm_node *stolen,
>> +                       unsigned int flags)
>>   {
>>       static struct lock_class_key lock_class;
>>       unsigned int cache_level;
>>       int err;
>>       drm_gem_private_object_init(&mem->i915->drm, &obj->base, 
>> stolen->size);
>> -    i915_gem_object_init(obj, &i915_gem_object_stolen_ops, 
>> &lock_class, 0);
>> +    i915_gem_object_init(obj, &i915_gem_object_stolen_ops, 
>> &lock_class, flags);
>>       obj->stolen = stolen;
>>       obj->read_domains = I915_GEM_DOMAIN_CPU | I915_GEM_DOMAIN_GTT;
>> @@ -682,7 +683,7 @@ static int _i915_gem_object_stolen_init(struct 
>> intel_memory_region *mem,
>>       if (ret)
>>           goto err_free;
>> -    ret = __i915_gem_object_create_stolen(mem, obj, stolen);
>> +    ret = __i915_gem_object_create_stolen(mem, obj, stolen, flags);
>>       if (ret)
>>           goto err_remove;
>> @@ -840,7 +841,8 @@ 
>> i915_gem_object_create_stolen_for_preallocated(struct drm_i915_private 
>> *i915,
>>           goto err_stolen;
>>       }
>> -    ret = __i915_gem_object_create_stolen(mem, obj, stolen);
>> +    ret = __i915_gem_object_create_stolen(mem, obj, stolen,
>> +                          I915_BO_ALLOC_CONTIGUOUS);
>>       if (ret)
>>           goto err_object_free;
>>
> 
> Are all stolen objects always contiguous or only ones allocated by 
> i915_gem_object_create_stolen_for_preallocated? If former should 
> __i915_gem_object_create_stolen just set the flag without the need to 
> pass it in?

Yes, all stolen object are physically contiguous. Agreed, moving the 
I915_BO_ALLOC_CONTIGUOUS into __i915_gem_object_create_stolen() makes 
more sense here.

> 
> Regards,
> 
> Tvrtko
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_stolen.c b/drivers/gpu/drm/i915/gem/i915_gem_stolen.c
index f713eabb7671..49a2dfcc8ba7 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_stolen.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_stolen.c
@@ -633,14 +633,15 @@  static const struct drm_i915_gem_object_ops i915_gem_object_stolen_ops = {
 
 static int __i915_gem_object_create_stolen(struct intel_memory_region *mem,
 					   struct drm_i915_gem_object *obj,
-					   struct drm_mm_node *stolen)
+					   struct drm_mm_node *stolen,
+					   unsigned int flags)
 {
 	static struct lock_class_key lock_class;
 	unsigned int cache_level;
 	int err;
 
 	drm_gem_private_object_init(&mem->i915->drm, &obj->base, stolen->size);
-	i915_gem_object_init(obj, &i915_gem_object_stolen_ops, &lock_class, 0);
+	i915_gem_object_init(obj, &i915_gem_object_stolen_ops, &lock_class, flags);
 
 	obj->stolen = stolen;
 	obj->read_domains = I915_GEM_DOMAIN_CPU | I915_GEM_DOMAIN_GTT;
@@ -682,7 +683,7 @@  static int _i915_gem_object_stolen_init(struct intel_memory_region *mem,
 	if (ret)
 		goto err_free;
 
-	ret = __i915_gem_object_create_stolen(mem, obj, stolen);
+	ret = __i915_gem_object_create_stolen(mem, obj, stolen, flags);
 	if (ret)
 		goto err_remove;
 
@@ -840,7 +841,8 @@  i915_gem_object_create_stolen_for_preallocated(struct drm_i915_private *i915,
 		goto err_stolen;
 	}
 
-	ret = __i915_gem_object_create_stolen(mem, obj, stolen);
+	ret = __i915_gem_object_create_stolen(mem, obj, stolen,
+					      I915_BO_ALLOC_CONTIGUOUS);
 	if (ret)
 		goto err_object_free;