* [Intel-gfx] [PATCH 26/26] drm/i915/gt: Remove #ifdef guards for PM related functions
[not found] ` <20221107175510.361051-1-paul@crapouillou.net>
@ 2022-11-07 17:55 ` Paul Cercueil
2022-11-07 20:31 ` Rodrigo Vivi
0 siblings, 1 reply; 3+ messages in thread
From: Paul Cercueil @ 2022-11-07 17:55 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Daniel Vetter
Cc: intel-gfx, linux-kernel, Paul Cercueil, dri-devel, Rodrigo Vivi
Instead of defining two versions of intel_sysfs_rc6_init(), one for each
value of CONFIG_PM, add a check on !IS_ENABLED(CONFIG_PM) early in the
function. This will allow the compiler to automatically drop the dead
code when CONFIG_PM is disabled, without having to use #ifdef guards.
This has the advantage of always compiling these functions in,
independently of any Kconfig option. Thanks to that, bugs and other
regressions are subsequently easier to catch.
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org
---
drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c b/drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c
index 2b5f05b31187..decf892a4508 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c
+++ b/drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c
@@ -164,7 +164,6 @@ sysfs_gt_attribute_r_func(struct kobject *kobj, struct attribute *attr,
NULL); \
INTEL_GT_ATTR_RO(_name)
-#ifdef CONFIG_PM
static u32 get_residency(struct intel_gt *gt, i915_reg_t reg)
{
intel_wakeref_t wakeref;
@@ -300,7 +299,7 @@ static void intel_sysfs_rc6_init(struct intel_gt *gt, struct kobject *kobj)
{
int ret;
- if (!HAS_RC6(gt->i915))
+ if (!IS_ENABLED(CONFIG_PM) || !HAS_RC6(gt->i915))
return;
ret = __intel_gt_sysfs_create_group(kobj, rc6_attr_group);
@@ -329,11 +328,6 @@ static void intel_sysfs_rc6_init(struct intel_gt *gt, struct kobject *kobj)
gt->info.id, ERR_PTR(ret));
}
}
-#else
-static void intel_sysfs_rc6_init(struct intel_gt *gt, struct kobject *kobj)
-{
-}
-#endif /* CONFIG_PM */
static u32 __act_freq_mhz_show(struct intel_gt *gt)
{
--
2.35.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Intel-gfx] [PATCH 26/26] drm/i915/gt: Remove #ifdef guards for PM related functions
2022-11-07 17:55 ` [Intel-gfx] [PATCH 26/26] drm/i915/gt: Remove #ifdef guards for PM related functions Paul Cercueil
@ 2022-11-07 20:31 ` Rodrigo Vivi
2022-11-07 20:59 ` Paul Cercueil
0 siblings, 1 reply; 3+ messages in thread
From: Rodrigo Vivi @ 2022-11-07 20:31 UTC (permalink / raw)
To: Paul Cercueil
Cc: Thomas Zimmermann, intel-gfx, linux-kernel, Maxime Ripard,
dri-devel, Daniel Vetter, David Airlie
On Mon, Nov 07, 2022 at 05:55:10PM +0000, Paul Cercueil wrote:
> Instead of defining two versions of intel_sysfs_rc6_init(), one for each
> value of CONFIG_PM, add a check on !IS_ENABLED(CONFIG_PM) early in the
> function. This will allow the compiler to automatically drop the dead
> code when CONFIG_PM is disabled, without having to use #ifdef guards.
Making the RC6 to depend on the CONFIG_PM is probably an historical
mistake and probably the right solution is simply to remove that
dependency.
>
> This has the advantage of always compiling these functions in,
> independently of any Kconfig option. Thanks to that, bugs and other
> regressions are subsequently easier to catch.
>
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> ---
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
> Cc: intel-gfx@lists.freedesktop.org
> ---
> drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c | 8 +-------
> 1 file changed, 1 insertion(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c b/drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c
> index 2b5f05b31187..decf892a4508 100644
> --- a/drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c
> +++ b/drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c
> @@ -164,7 +164,6 @@ sysfs_gt_attribute_r_func(struct kobject *kobj, struct attribute *attr,
> NULL); \
> INTEL_GT_ATTR_RO(_name)
>
> -#ifdef CONFIG_PM
> static u32 get_residency(struct intel_gt *gt, i915_reg_t reg)
> {
> intel_wakeref_t wakeref;
> @@ -300,7 +299,7 @@ static void intel_sysfs_rc6_init(struct intel_gt *gt, struct kobject *kobj)
> {
> int ret;
>
> - if (!HAS_RC6(gt->i915))
> + if (!IS_ENABLED(CONFIG_PM) || !HAS_RC6(gt->i915))
> return;
>
> ret = __intel_gt_sysfs_create_group(kobj, rc6_attr_group);
> @@ -329,11 +328,6 @@ static void intel_sysfs_rc6_init(struct intel_gt *gt, struct kobject *kobj)
> gt->info.id, ERR_PTR(ret));
> }
> }
> -#else
> -static void intel_sysfs_rc6_init(struct intel_gt *gt, struct kobject *kobj)
> -{
> -}
> -#endif /* CONFIG_PM */
>
> static u32 __act_freq_mhz_show(struct intel_gt *gt)
> {
> --
> 2.35.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Intel-gfx] [PATCH 26/26] drm/i915/gt: Remove #ifdef guards for PM related functions
2022-11-07 20:31 ` Rodrigo Vivi
@ 2022-11-07 20:59 ` Paul Cercueil
0 siblings, 0 replies; 3+ messages in thread
From: Paul Cercueil @ 2022-11-07 20:59 UTC (permalink / raw)
To: Rodrigo Vivi
Cc: Thomas Zimmermann, intel-gfx, linux-kernel, Maxime Ripard,
dri-devel, Daniel Vetter, David Airlie
Hi Rodrigo,
Le lun. 7 nov. 2022 à 15:31:49 -0500, Rodrigo Vivi
<rodrigo.vivi@intel.com> a écrit :
> On Mon, Nov 07, 2022 at 05:55:10PM +0000, Paul Cercueil wrote:
>> Instead of defining two versions of intel_sysfs_rc6_init(), one for
>> each
>> value of CONFIG_PM, add a check on !IS_ENABLED(CONFIG_PM) early in
>> the
>> function. This will allow the compiler to automatically drop the
>> dead
>> code when CONFIG_PM is disabled, without having to use #ifdef
>> guards.
>
> Making the RC6 to depend on the CONFIG_PM is probably an historical
> mistake and probably the right solution is simply to remove that
> dependency.
I don't know anything about i915, so the best I can do is update the
code without changing the functionality.
Then someone with a better understanding can send a patch to remove the
check on CONFIG_PM.
Cheers,
-Paul
>>
>> This has the advantage of always compiling these functions in,
>> independently of any Kconfig option. Thanks to that, bugs and other
>> regressions are subsequently easier to catch.
>>
>> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
>> ---
>> Cc: Jani Nikula <jani.nikula@linux.intel.com>
>> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
>> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
>> Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
>> Cc: intel-gfx@lists.freedesktop.org
>> ---
>> drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c | 8 +-------
>> 1 file changed, 1 insertion(+), 7 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c
>> b/drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c
>> index 2b5f05b31187..decf892a4508 100644
>> --- a/drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c
>> +++ b/drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c
>> @@ -164,7 +164,6 @@ sysfs_gt_attribute_r_func(struct kobject *kobj,
>> struct attribute *attr,
>> NULL); \
>> INTEL_GT_ATTR_RO(_name)
>>
>> -#ifdef CONFIG_PM
>> static u32 get_residency(struct intel_gt *gt, i915_reg_t reg)
>> {
>> intel_wakeref_t wakeref;
>> @@ -300,7 +299,7 @@ static void intel_sysfs_rc6_init(struct
>> intel_gt *gt, struct kobject *kobj)
>> {
>> int ret;
>>
>> - if (!HAS_RC6(gt->i915))
>> + if (!IS_ENABLED(CONFIG_PM) || !HAS_RC6(gt->i915))
>> return;
>>
>> ret = __intel_gt_sysfs_create_group(kobj, rc6_attr_group);
>> @@ -329,11 +328,6 @@ static void intel_sysfs_rc6_init(struct
>> intel_gt *gt, struct kobject *kobj)
>> gt->info.id, ERR_PTR(ret));
>> }
>> }
>> -#else
>> -static void intel_sysfs_rc6_init(struct intel_gt *gt, struct
>> kobject *kobj)
>> -{
>> -}
>> -#endif /* CONFIG_PM */
>>
>> static u32 __act_freq_mhz_show(struct intel_gt *gt)
>> {
>> --
>> 2.35.1
>>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-11-21 15:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20221107175106.360578-1-paul@crapouillou.net>
[not found] ` <20221107175510.361051-1-paul@crapouillou.net>
2022-11-07 17:55 ` [Intel-gfx] [PATCH 26/26] drm/i915/gt: Remove #ifdef guards for PM related functions Paul Cercueil
2022-11-07 20:31 ` Rodrigo Vivi
2022-11-07 20:59 ` Paul Cercueil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox