diff mbox series

[v2] drm/i915: Use helper func to find out map type

Message ID 20221219112933.21417-1-nirmoy.das@intel.com (mailing list archive)
State New, archived
Headers show
Series [v2] drm/i915: Use helper func to find out map type | expand

Commit Message

Nirmoy Das Dec. 19, 2022, 11:29 a.m. UTC
Use i915_coherent_map_type() function to find out
map_type of the shmem obj.

v2: handle non-llc platform(Matt)

Signed-off-by: Nirmoy Das <nirmoy.das@intel.com>
---
 drivers/gpu/drm/i915/gt/shmem_utils.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Andrzej Hajda Dec. 19, 2022, 6:04 p.m. UTC | #1
On 19.12.2022 12:29, Nirmoy Das wrote:
> Use i915_coherent_map_type() function to find out
> map_type of the shmem obj.
> 
> v2: handle non-llc platform(Matt)
> 
> Signed-off-by: Nirmoy Das <nirmoy.das@intel.com>
> ---
>   drivers/gpu/drm/i915/gt/shmem_utils.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gt/shmem_utils.c b/drivers/gpu/drm/i915/gt/shmem_utils.c
> index 402f085f3a02..449c9ed44382 100644
> --- a/drivers/gpu/drm/i915/gt/shmem_utils.c
> +++ b/drivers/gpu/drm/i915/gt/shmem_utils.c
> @@ -8,6 +8,7 @@
>   #include <linux/pagemap.h>
>   #include <linux/shmem_fs.h>
>   
> +#include "i915_drv.h"
>   #include "gem/i915_gem_object.h"
>   #include "gem/i915_gem_lmem.h"
>   #include "shmem_utils.h"
> @@ -32,6 +33,8 @@ struct file *shmem_create_from_data(const char *name, void *data, size_t len)
>   
>   struct file *shmem_create_from_object(struct drm_i915_gem_object *obj)
>   {
> +	struct drm_i915_private *i915 = to_i915(obj->base.dev);
> +	enum i915_map_type map_type;
>   	struct file *file;
>   	void *ptr;
>   
> @@ -41,8 +44,8 @@ struct file *shmem_create_from_object(struct drm_i915_gem_object *obj)
>   		return file;
>   	}
>   
> -	ptr = i915_gem_object_pin_map_unlocked(obj, i915_gem_object_is_lmem(obj) ?
> -						I915_MAP_WC : I915_MAP_WB);
> +	map_type = i915_coherent_map_type(i915, obj, true);
> +	ptr = i915_gem_object_pin_map_unlocked(obj, map_type);


More lines, but less branches, some gain :)

Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>

Regards
Andrzej

>   	if (IS_ERR(ptr))
>   		return ERR_CAST(ptr);
>
Nirmoy Das Dec. 20, 2022, 10:33 a.m. UTC | #2
On 12/19/2022 8:04 PM, Andrzej Hajda wrote:
> On 19.12.2022 12:29, Nirmoy Das wrote:
>> Use i915_coherent_map_type() function to find out
>> map_type of the shmem obj.
>>
>> v2: handle non-llc platform(Matt)
>>
>> Signed-off-by: Nirmoy Das <nirmoy.das@intel.com>
>> ---
>>   drivers/gpu/drm/i915/gt/shmem_utils.c | 7 +++++--
>>   1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/gt/shmem_utils.c 
>> b/drivers/gpu/drm/i915/gt/shmem_utils.c
>> index 402f085f3a02..449c9ed44382 100644
>> --- a/drivers/gpu/drm/i915/gt/shmem_utils.c
>> +++ b/drivers/gpu/drm/i915/gt/shmem_utils.c
>> @@ -8,6 +8,7 @@
>>   #include <linux/pagemap.h>
>>   #include <linux/shmem_fs.h>
>>   +#include "i915_drv.h"
>>   #include "gem/i915_gem_object.h"
>>   #include "gem/i915_gem_lmem.h"
>>   #include "shmem_utils.h"
>> @@ -32,6 +33,8 @@ struct file *shmem_create_from_data(const char 
>> *name, void *data, size_t len)
>>     struct file *shmem_create_from_object(struct drm_i915_gem_object 
>> *obj)
>>   {
>> +    struct drm_i915_private *i915 = to_i915(obj->base.dev);
>> +    enum i915_map_type map_type;
>>       struct file *file;
>>       void *ptr;
>>   @@ -41,8 +44,8 @@ struct file *shmem_create_from_object(struct 
>> drm_i915_gem_object *obj)
>>           return file;
>>       }
>>   -    ptr = i915_gem_object_pin_map_unlocked(obj, 
>> i915_gem_object_is_lmem(obj) ?
>> -                        I915_MAP_WC : I915_MAP_WB);
>> +    map_type = i915_coherent_map_type(i915, obj, true);
>> +    ptr = i915_gem_object_pin_map_unlocked(obj, map_type);
>
>
> More lines, but less branches, some gain :)
>

Yes and I am more behind the idea of unifying finding map_type with this 
helper.


> Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>


Thanks!

Nirmoy

>
> Regards
> Andrzej
>
>>       if (IS_ERR(ptr))
>>           return ERR_CAST(ptr);
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gt/shmem_utils.c b/drivers/gpu/drm/i915/gt/shmem_utils.c
index 402f085f3a02..449c9ed44382 100644
--- a/drivers/gpu/drm/i915/gt/shmem_utils.c
+++ b/drivers/gpu/drm/i915/gt/shmem_utils.c
@@ -8,6 +8,7 @@ 
 #include <linux/pagemap.h>
 #include <linux/shmem_fs.h>
 
+#include "i915_drv.h"
 #include "gem/i915_gem_object.h"
 #include "gem/i915_gem_lmem.h"
 #include "shmem_utils.h"
@@ -32,6 +33,8 @@  struct file *shmem_create_from_data(const char *name, void *data, size_t len)
 
 struct file *shmem_create_from_object(struct drm_i915_gem_object *obj)
 {
+	struct drm_i915_private *i915 = to_i915(obj->base.dev);
+	enum i915_map_type map_type;
 	struct file *file;
 	void *ptr;
 
@@ -41,8 +44,8 @@  struct file *shmem_create_from_object(struct drm_i915_gem_object *obj)
 		return file;
 	}
 
-	ptr = i915_gem_object_pin_map_unlocked(obj, i915_gem_object_is_lmem(obj) ?
-						I915_MAP_WC : I915_MAP_WB);
+	map_type = i915_coherent_map_type(i915, obj, true);
+	ptr = i915_gem_object_pin_map_unlocked(obj, map_type);
 	if (IS_ERR(ptr))
 		return ERR_CAST(ptr);