Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] drm/xe: use devm_add_action_or_reset() helper
@ 2024-09-07  6:51 He Lugang
  2024-09-07  7:26 ` HeLuang
  2024-09-07  7:36 ` HeLuang
  0 siblings, 2 replies; 6+ messages in thread
From: He Lugang @ 2024-09-07  6:51 UTC (permalink / raw)
  To: lucas.demarchi, thomas.hellstrom, rodrigo.vivi, maarten.lankhorst,
	mripard, tzimmermann, airlied, simona
  Cc: intel-xe, dri-devel, He Lugang

Use devm_add_action_or_reset() to release resources in case of failure,
because the cleanup function will be automatically called.

Signed-off-by: He Lugang <helugang@uniontech.com>
---
 drivers/gpu/drm/xe/xe_gt_freq.c  | 2 +-
 drivers/gpu/drm/xe/xe_gt_sysfs.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_gt_freq.c b/drivers/gpu/drm/xe/xe_gt_freq.c
index 68a5778b4319..71bcd60d0866 100644
--- a/drivers/gpu/drm/xe/xe_gt_freq.c
+++ b/drivers/gpu/drm/xe/xe_gt_freq.c
@@ -237,7 +237,7 @@ int xe_gt_freq_init(struct xe_gt *gt)
 	if (!gt->freq)
 		return -ENOMEM;
 
-	err = devm_add_action(xe->drm.dev, freq_fini, gt->freq);
+	err = devm_add_action_or_reset(xe->drm.dev, freq_fini, gt->freq);
 	if (err)
 		return err;
 
diff --git a/drivers/gpu/drm/xe/xe_gt_sysfs.c b/drivers/gpu/drm/xe/xe_gt_sysfs.c
index a05c3699e8b9..ec2b8246204b 100644
--- a/drivers/gpu/drm/xe/xe_gt_sysfs.c
+++ b/drivers/gpu/drm/xe/xe_gt_sysfs.c
@@ -51,5 +51,5 @@ int xe_gt_sysfs_init(struct xe_gt *gt)
 
 	gt->sysfs = &kg->base;
 
-	return devm_add_action(xe->drm.dev, gt_sysfs_fini, gt);
+	return devm_add_action_or_reset(xe->drm.dev, gt_sysfs_fini, gt);
 }
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 1/3] drm/xe: use devm_add_action_or_reset() helper
@ 2024-09-07  6:54 He Lugang
  2024-09-10 18:57 ` Rodrigo Vivi
  0 siblings, 1 reply; 6+ messages in thread
From: He Lugang @ 2024-09-07  6:54 UTC (permalink / raw)
  To: lucas.demarchi, thomas.hellstrom, rodrigo.vivi, maarten.lankhorst,
	mripard, tzimmermann, airlied, simona
  Cc: intel-xe, dri-devel, He Lugang

Use devm_add_action_or_reset() to release resources in case of failure,
because the cleanup function will be automatically called.

Signed-off-by: He Lugang <helugang@uniontech.com>
---
 drivers/gpu/drm/xe/xe_gt_freq.c  | 2 +-
 drivers/gpu/drm/xe/xe_gt_sysfs.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_gt_freq.c b/drivers/gpu/drm/xe/xe_gt_freq.c
index 68a5778b4319..71bcd60d0866 100644
--- a/drivers/gpu/drm/xe/xe_gt_freq.c
+++ b/drivers/gpu/drm/xe/xe_gt_freq.c
@@ -237,7 +237,7 @@ int xe_gt_freq_init(struct xe_gt *gt)
 	if (!gt->freq)
 		return -ENOMEM;
 
-	err = devm_add_action(xe->drm.dev, freq_fini, gt->freq);
+	err = devm_add_action_or_reset(xe->drm.dev, freq_fini, gt->freq);
 	if (err)
 		return err;
 
diff --git a/drivers/gpu/drm/xe/xe_gt_sysfs.c b/drivers/gpu/drm/xe/xe_gt_sysfs.c
index a05c3699e8b9..ec2b8246204b 100644
--- a/drivers/gpu/drm/xe/xe_gt_sysfs.c
+++ b/drivers/gpu/drm/xe/xe_gt_sysfs.c
@@ -51,5 +51,5 @@ int xe_gt_sysfs_init(struct xe_gt *gt)
 
 	gt->sysfs = &kg->base;
 
-	return devm_add_action(xe->drm.dev, gt_sysfs_fini, gt);
+	return devm_add_action_or_reset(xe->drm.dev, gt_sysfs_fini, gt);
 }
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3] drm/xe: use devm_add_action_or_reset() helper
  2024-09-07  6:51 He Lugang
@ 2024-09-07  7:26 ` HeLuang
  2024-09-07  7:36 ` HeLuang
  1 sibling, 0 replies; 6+ messages in thread
From: HeLuang @ 2024-09-07  7:26 UTC (permalink / raw)
  To: lucas.demarchi, thomas.hellstrom, rodrigo.vivi, maarten.lankhorst,
	mripard, tzimmermann, airlied
  Cc: intel-xe, dri-devel

sorry, pls just pass over this email.

----
Best Regards,
Lugang
在 2024/9/7 14:51, He Lugang 写道:
> Use devm_add_action_or_reset() to release resources in case of failure,
> because the cleanup function will be automatically called.
> 
> Signed-off-by: He Lugang <helugang@uniontech.com>
> ---
>   drivers/gpu/drm/xe/xe_gt_freq.c  | 2 +-
>   drivers/gpu/drm/xe/xe_gt_sysfs.c | 2 +-
>   2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_gt_freq.c b/drivers/gpu/drm/xe/xe_gt_freq.c
> index 68a5778b4319..71bcd60d0866 100644
> --- a/drivers/gpu/drm/xe/xe_gt_freq.c
> +++ b/drivers/gpu/drm/xe/xe_gt_freq.c
> @@ -237,7 +237,7 @@ int xe_gt_freq_init(struct xe_gt *gt)
>   	if (!gt->freq)
>   		return -ENOMEM;
>   
> -	err = devm_add_action(xe->drm.dev, freq_fini, gt->freq);
> +	err = devm_add_action_or_reset(xe->drm.dev, freq_fini, gt->freq);
>   	if (err)
>   		return err;
>   
> diff --git a/drivers/gpu/drm/xe/xe_gt_sysfs.c b/drivers/gpu/drm/xe/xe_gt_sysfs.c
> index a05c3699e8b9..ec2b8246204b 100644
> --- a/drivers/gpu/drm/xe/xe_gt_sysfs.c
> +++ b/drivers/gpu/drm/xe/xe_gt_sysfs.c
> @@ -51,5 +51,5 @@ int xe_gt_sysfs_init(struct xe_gt *gt)
>   
>   	gt->sysfs = &kg->base;
>   
> -	return devm_add_action(xe->drm.dev, gt_sysfs_fini, gt);
> +	return devm_add_action_or_reset(xe->drm.dev, gt_sysfs_fini, gt);
>   }

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3] drm/xe: use devm_add_action_or_reset() helper
  2024-09-07  6:51 He Lugang
  2024-09-07  7:26 ` HeLuang
@ 2024-09-07  7:36 ` HeLuang
  1 sibling, 0 replies; 6+ messages in thread
From: HeLuang @ 2024-09-07  7:36 UTC (permalink / raw)
  To: lucas.demarchi, thomas.hellstrom, rodrigo.vivi, maarten.lankhorst,
	mripard, tzimmermann, airlied, simona
  Cc: intel-xe, dri-devel

sorry pls just pass over this email.

--
Sincerely,
Lugang

在 2024/9/7 14:51, He Lugang 写道:
> Use devm_add_action_or_reset() to release resources in case of failure,
> because the cleanup function will be automatically called.
> 
> Signed-off-by: He Lugang <helugang@uniontech.com>
> ---
>   drivers/gpu/drm/xe/xe_gt_freq.c  | 2 +-
>   drivers/gpu/drm/xe/xe_gt_sysfs.c | 2 +-
>   2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_gt_freq.c b/drivers/gpu/drm/xe/xe_gt_freq.c
> index 68a5778b4319..71bcd60d0866 100644
> --- a/drivers/gpu/drm/xe/xe_gt_freq.c
> +++ b/drivers/gpu/drm/xe/xe_gt_freq.c
> @@ -237,7 +237,7 @@ int xe_gt_freq_init(struct xe_gt *gt)
>   	if (!gt->freq)
>   		return -ENOMEM;
>   
> -	err = devm_add_action(xe->drm.dev, freq_fini, gt->freq);
> +	err = devm_add_action_or_reset(xe->drm.dev, freq_fini, gt->freq);
>   	if (err)
>   		return err;
>   
> diff --git a/drivers/gpu/drm/xe/xe_gt_sysfs.c b/drivers/gpu/drm/xe/xe_gt_sysfs.c
> index a05c3699e8b9..ec2b8246204b 100644
> --- a/drivers/gpu/drm/xe/xe_gt_sysfs.c
> +++ b/drivers/gpu/drm/xe/xe_gt_sysfs.c
> @@ -51,5 +51,5 @@ int xe_gt_sysfs_init(struct xe_gt *gt)
>   
>   	gt->sysfs = &kg->base;
>   
> -	return devm_add_action(xe->drm.dev, gt_sysfs_fini, gt);
> +	return devm_add_action_or_reset(xe->drm.dev, gt_sysfs_fini, gt);
>   }

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3] drm/xe: use devm_add_action_or_reset() helper
  2024-09-07  6:54 [PATCH 1/3] drm/xe: use devm_add_action_or_reset() helper He Lugang
@ 2024-09-10 18:57 ` Rodrigo Vivi
  2024-09-11  9:37   ` HeLuang
  0 siblings, 1 reply; 6+ messages in thread
From: Rodrigo Vivi @ 2024-09-10 18:57 UTC (permalink / raw)
  To: He Lugang
  Cc: lucas.demarchi, thomas.hellstrom, maarten.lankhorst, mripard,
	tzimmermann, airlied, simona, intel-xe, dri-devel

On Sat, Sep 07, 2024 at 02:54:39PM +0800, He Lugang wrote:
> Use devm_add_action_or_reset() to release resources in case of failure,
> because the cleanup function will be automatically called.
> 
> Signed-off-by: He Lugang <helugang@uniontech.com>
> ---
>  drivers/gpu/drm/xe/xe_gt_freq.c  | 2 +-
>  drivers/gpu/drm/xe/xe_gt_sysfs.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_gt_freq.c b/drivers/gpu/drm/xe/xe_gt_freq.c
> index 68a5778b4319..71bcd60d0866 100644
> --- a/drivers/gpu/drm/xe/xe_gt_freq.c
> +++ b/drivers/gpu/drm/xe/xe_gt_freq.c
> @@ -237,7 +237,7 @@ int xe_gt_freq_init(struct xe_gt *gt)
>  	if (!gt->freq)
>  		return -ENOMEM;
>  
> -	err = devm_add_action(xe->drm.dev, freq_fini, gt->freq);
> +	err = devm_add_action_or_reset(xe->drm.dev, freq_fini, gt->freq);

you need to move this to a lower point then...
otherwise fini function will try to remove the sysfs files that
hadn't been created.

>  	if (err)
>  		return err;
>  
> diff --git a/drivers/gpu/drm/xe/xe_gt_sysfs.c b/drivers/gpu/drm/xe/xe_gt_sysfs.c
> index a05c3699e8b9..ec2b8246204b 100644
> --- a/drivers/gpu/drm/xe/xe_gt_sysfs.c
> +++ b/drivers/gpu/drm/xe/xe_gt_sysfs.c
> @@ -51,5 +51,5 @@ int xe_gt_sysfs_init(struct xe_gt *gt)
>  
>  	gt->sysfs = &kg->base;
>  
> -	return devm_add_action(xe->drm.dev, gt_sysfs_fini, gt);
> +	return devm_add_action_or_reset(xe->drm.dev, gt_sysfs_fini, gt);

this one looks right indeed.

>  }
> -- 
> 2.45.2
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3] drm/xe: use devm_add_action_or_reset() helper
  2024-09-10 18:57 ` Rodrigo Vivi
@ 2024-09-11  9:37   ` HeLuang
  0 siblings, 0 replies; 6+ messages in thread
From: HeLuang @ 2024-09-11  9:37 UTC (permalink / raw)
  To: Rodrigo Vivi
  Cc: lucas.demarchi, thomas.hellstrom, maarten.lankhorst, mripard,
	tzimmermann, airlied, simona, intel-xe, dri-devel



在 2024/9/11 02:57, Rodrigo Vivi 写道:
> On Sat, Sep 07, 2024 at 02:54:39PM +0800, He Lugang wrote:
>> Use devm_add_action_or_reset() to release resources in case of failure,
>> because the cleanup function will be automatically called.
>>
>> Signed-off-by: He Lugang <helugang@uniontech.com>
>> ---
>>   drivers/gpu/drm/xe/xe_gt_freq.c  | 2 +-
>>   drivers/gpu/drm/xe/xe_gt_sysfs.c | 2 +-
>>   2 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/xe/xe_gt_freq.c b/drivers/gpu/drm/xe/xe_gt_freq.c
>> index 68a5778b4319..71bcd60d0866 100644
>> --- a/drivers/gpu/drm/xe/xe_gt_freq.c
>> +++ b/drivers/gpu/drm/xe/xe_gt_freq.c
>> @@ -237,7 +237,7 @@ int xe_gt_freq_init(struct xe_gt *gt)
>>   	if (!gt->freq)
>>   		return -ENOMEM;
>>   
>> -	err = devm_add_action(xe->drm.dev, freq_fini, gt->freq);
>> +	err = devm_add_action_or_reset(xe->drm.dev, freq_fini, gt->freq);
> 
> you need to move this to a lower point then...
> otherwise fini function will try to remove the sysfs files that
> hadn't been created.
OK,thanks for your reply!
> 
>>   	if (err)
>>   		return err;
>>   
>> diff --git a/drivers/gpu/drm/xe/xe_gt_sysfs.c b/drivers/gpu/drm/xe/xe_gt_sysfs.c
>> index a05c3699e8b9..ec2b8246204b 100644
>> --- a/drivers/gpu/drm/xe/xe_gt_sysfs.c
>> +++ b/drivers/gpu/drm/xe/xe_gt_sysfs.c
>> @@ -51,5 +51,5 @@ int xe_gt_sysfs_init(struct xe_gt *gt)
>>   
>>   	gt->sysfs = &kg->base;
>>   
>> -	return devm_add_action(xe->drm.dev, gt_sysfs_fini, gt);
>> +	return devm_add_action_or_reset(xe->drm.dev, gt_sysfs_fini, gt);
> 
> this one looks right indeed.
> 
>>   }
>> -- 
>> 2.45.2
>>
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-09-13 21:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-07  6:54 [PATCH 1/3] drm/xe: use devm_add_action_or_reset() helper He Lugang
2024-09-10 18:57 ` Rodrigo Vivi
2024-09-11  9:37   ` HeLuang
  -- strict thread matches above, loose matches on Subject: below --
2024-09-07  6:51 He Lugang
2024-09-07  7:26 ` HeLuang
2024-09-07  7:36 ` HeLuang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox