diff mbox series

[v5,3/7] drm/i915/gt: add gt_is_root() helper

Message ID 20220217144158.21555-4-andi.shyti@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series Introduce multitile support | expand

Commit Message

Andi Shyti Feb. 17, 2022, 2:41 p.m. UTC
The "gt_is_root(struct intel_gt *gt)" helper return true if the
gt is the root gt, which means that its id is 0. Return false
otherwise.

Suggested-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
---
 drivers/gpu/drm/i915/gt/intel_gt.h | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Michal Wajdeczko Feb. 28, 2022, 8:02 p.m. UTC | #1
On 17.02.2022 15:41, Andi Shyti wrote:
> The "gt_is_root(struct intel_gt *gt)" helper return true if the
> gt is the root gt, which means that its id is 0. Return false
> otherwise.
> 
> Suggested-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/gt/intel_gt.h | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/gt/intel_gt.h b/drivers/gpu/drm/i915/gt/intel_gt.h
> index 915d6192079b..f17f51e2d394 100644
> --- a/drivers/gpu/drm/i915/gt/intel_gt.h
> +++ b/drivers/gpu/drm/i915/gt/intel_gt.h
> @@ -19,6 +19,11 @@ struct drm_printer;
>  		  ##__VA_ARGS__);					\
>  } while (0)
>  
> +static inline bool gt_is_root(struct intel_gt *gt)
> +{
> +	return !gt->info.id;
> +}
> +

we could squash this patch with prev one, where it can be used in:

 intel_gt_tile_cleanup(struct intel_gt *gt)
 {
 	intel_uncore_cleanup_mmio(gt->uncore);

-	if (gt->info.id) {
+	if (!gt_is_root(gt)) {
 		kfree(gt->uncore);
 		kfree(gt);
 	}
 }

or just use it this way in this patch, with that:

Reviewed-by: Michal Wajdeczko <michal.wajdeczko@intel.com>

>  static inline struct intel_gt *uc_to_gt(struct intel_uc *uc)
>  {
>  	return container_of(uc, struct intel_gt, uc);
Andrzej Hajda March 1, 2022, 3:25 p.m. UTC | #2
On 28.02.2022 21:02, Michal Wajdeczko wrote:
>
> On 17.02.2022 15:41, Andi Shyti wrote:
>> The "gt_is_root(struct intel_gt *gt)" helper return true if the
>> gt is the root gt, which means that its id is 0. Return false
>> otherwise.
>>
>> Suggested-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
>> Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
>> ---
>>   drivers/gpu/drm/i915/gt/intel_gt.h | 5 +++++
>>   1 file changed, 5 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/i915/gt/intel_gt.h b/drivers/gpu/drm/i915/gt/intel_gt.h
>> index 915d6192079b..f17f51e2d394 100644
>> --- a/drivers/gpu/drm/i915/gt/intel_gt.h
>> +++ b/drivers/gpu/drm/i915/gt/intel_gt.h
>> @@ -19,6 +19,11 @@ struct drm_printer;
>>   		  ##__VA_ARGS__);					\
>>   } while (0)
>>   
>> +static inline bool gt_is_root(struct intel_gt *gt)
>> +{
>> +	return !gt->info.id;
>> +}
>> +
> we could squash this patch with prev one, where it can be used in:
>
>   intel_gt_tile_cleanup(struct intel_gt *gt)
>   {
>   	intel_uncore_cleanup_mmio(gt->uncore);
>
> -	if (gt->info.id) {
> +	if (!gt_is_root(gt)) {
>   		kfree(gt->uncore);
>   		kfree(gt);
>   	}
>   }

It can be used in intel_gt_tile_setup as well, and then you can remove 
id var.

>
> or just use it this way in this patch, with that:
>
> Reviewed-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Accordingly:

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

Regards
Andrzej

>
>>   static inline struct intel_gt *uc_to_gt(struct intel_uc *uc)
>>   {
>>   	return container_of(uc, struct intel_gt, uc);
Andi Shyti March 6, 2022, 7:23 p.m. UTC | #3
Hi Andrzej and Michal,

> > > The "gt_is_root(struct intel_gt *gt)" helper return true if the
> > > gt is the root gt, which means that its id is 0. Return false
> > > otherwise.
> > > 
> > > Suggested-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
> > > Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
> > > ---
> > >   drivers/gpu/drm/i915/gt/intel_gt.h | 5 +++++
> > >   1 file changed, 5 insertions(+)
> > > 
> > > diff --git a/drivers/gpu/drm/i915/gt/intel_gt.h b/drivers/gpu/drm/i915/gt/intel_gt.h
> > > index 915d6192079b..f17f51e2d394 100644
> > > --- a/drivers/gpu/drm/i915/gt/intel_gt.h
> > > +++ b/drivers/gpu/drm/i915/gt/intel_gt.h
> > > @@ -19,6 +19,11 @@ struct drm_printer;
> > >   		  ##__VA_ARGS__);					\
> > >   } while (0)
> > > +static inline bool gt_is_root(struct intel_gt *gt)
> > > +{
> > > +	return !gt->info.id;
> > > +}
> > > +
> > we could squash this patch with prev one, where it can be used in:
> > 
> >   intel_gt_tile_cleanup(struct intel_gt *gt)
> >   {
> >   	intel_uncore_cleanup_mmio(gt->uncore);
> > 
> > -	if (gt->info.id) {
> > +	if (!gt_is_root(gt)) {
> >   		kfree(gt->uncore);
> >   		kfree(gt);
> >   	}
> >   }
> 
> It can be used in intel_gt_tile_setup as well, and then you can remove id
> var.

I will move this before, then before patch 2 and use it where you
suggested, as well.

> > 
> > or just use it this way in this patch, with that:
> > 
> > Reviewed-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Accordingly:
> 
> Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>

Thank you!

Andi
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gt/intel_gt.h b/drivers/gpu/drm/i915/gt/intel_gt.h
index 915d6192079b..f17f51e2d394 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt.h
+++ b/drivers/gpu/drm/i915/gt/intel_gt.h
@@ -19,6 +19,11 @@  struct drm_printer;
 		  ##__VA_ARGS__);					\
 } while (0)
 
+static inline bool gt_is_root(struct intel_gt *gt)
+{
+	return !gt->info.id;
+}
+
 static inline struct intel_gt *uc_to_gt(struct intel_uc *uc)
 {
 	return container_of(uc, struct intel_gt, uc);