Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>,
	intel-xe@lists.freedesktop.org
Cc: Tejas Upadhyay <tejas.upadhyay@intel.com>
Subject: Re: [PATCH] drm/xe: Always check force_wake_get return code
Date: Wed, 13 Mar 2024 16:56:38 +0200	[thread overview]
Message-ID: <875xxqrxi1.fsf@intel.com> (raw)
In-Reply-To: <76b70dd3-794b-45a1-994a-020525954d9f@intel.com>

On Wed, 13 Mar 2024, Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com> wrote:
> On 3/13/2024 1:31 AM, Jani Nikula wrote:
>> On Tue, 12 Mar 2024, Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com> wrote:
>>> diff --git a/drivers/gpu/drm/xe/xe_gsc.c b/drivers/gpu/drm/xe/xe_gsc.c
>>> index d9aa815a5bc2..902c52d95a8a 100644
>>> --- a/drivers/gpu/drm/xe/xe_gsc.c
>>> +++ b/drivers/gpu/drm/xe/xe_gsc.c
>>> @@ -287,7 +287,7 @@ static void gsc_work(struct work_struct *work)
>>>   	spin_unlock_irq(&gsc->lock);
>>>   
>>>   	xe_pm_runtime_get(xe);
>>> -	xe_force_wake_get(gt_to_fw(gt), XE_FW_GSC);
>>> +	XE_WARN_ON(xe_force_wake_get(gt_to_fw(gt), XE_FW_GSC));
>> Up to the xe maintainers to decide, but I'm really not a fan of hiding
>> functionality inside warn ons. My approach usually is, would it work if
>> all the warns were removed? If yes, it's good. If not, maybe reconsider.
>
> The code works even without the warns, they're only there so we know 
> that there was a forcewake issue if/when some other error crops up down 
> the line (which will be handled appropriately). There is nothing we can 
> do to actually handle the forcewake failure as it can only happen if the 
> HW is in a bad state.

My point is, I personally prefer:

	ret = do_stuff():

	WARN_ON(ret);

over:

	WARN_ON(do_stuff());

because in the former do_stuff() stands out as something we actually
want to do functionally, while in the latter the fact that we do
anything at all is hidden inside the WARN_ON().

I prefer WARN_ON()'s to only have stuff inside them that have no
side-effects:

	WARN_ON(check_stuff_but_dont_do_stuff());

Again, not my call to make here, just musing on style. ;)


BR,
Jani.


-- 
Jani Nikula, Intel

  reply	other threads:[~2024-03-13 14:56 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-12 19:42 [PATCH] drm/xe: Always check force_wake_get return code Daniele Ceraolo Spurio
2024-03-12 19:47 ` ✓ CI.Patch_applied: success for " Patchwork
2024-03-12 19:47 ` ✓ CI.checkpatch: " Patchwork
2024-03-12 19:48 ` ✓ CI.KUnit: " Patchwork
2024-03-12 19:59 ` ✓ CI.Build: " Patchwork
2024-03-12 20:02 ` ✓ CI.Hooks: " Patchwork
2024-03-12 20:03 ` ✓ CI.checksparse: " Patchwork
2024-03-12 20:22 ` ✓ CI.BAT: " Patchwork
2024-03-12 23:07 ` [PATCH] " Matt Roper
2024-03-13  8:31 ` Jani Nikula
2024-03-13 14:24   ` Daniele Ceraolo Spurio
2024-03-13 14:56     ` Jani Nikula [this message]
2024-03-13 17:35       ` Daniele Ceraolo Spurio
2024-03-14 10:58 ` Upadhyay, Tejas
2024-03-14 13:53   ` Daniele Ceraolo Spurio
2024-03-14 14:12     ` Upadhyay, Tejas
  -- strict thread matches above, loose matches on Subject: below --
2024-06-03 11:30 Tejas Upadhyay
2024-06-03 18:56 ` Daniele Ceraolo Spurio
2024-06-03 19:39   ` Lucas De Marchi
2024-06-04 18:31     ` Rodrigo Vivi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875xxqrxi1.fsf@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=daniele.ceraolospurio@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=tejas.upadhyay@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox