Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: "Gustavo Sousa" <gustavo.sousa@intel.com>,
	"Jouni Högander" <jouni.hogander@intel.com>,
	intel-gfx@lists.freedesktop.org
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Subject: Re: [Intel-gfx] [PATCH v2] drm/i915: Warn on if set frontbuffer return value is not NULL on release
Date: Mon, 02 Oct 2023 10:08:40 +0300	[thread overview]
Message-ID: <877co5ijrb.fsf@intel.com> (raw)
In-Reply-To: <169599418712.1718.2462102342426764863@gjsousa-mobl2>

On Fri, 29 Sep 2023, Gustavo Sousa <gustavo.sousa@intel.com> wrote:
> Quoting Jani Nikula (2023-09-28 04:43:13-03:00)
>>On Thu, 28 Sep 2023, Jouni Högander <jouni.hogander@intel.com> wrote:
>>> i915_gem_object_set_frontbuffer returns set frontbuffer pointer.  When we
>>> are releasing frontbuffer we are clearing the pointer from the object. Warn
>>> on if return value is not null.
>>>
>>> v2: Instead of ignoring do drm_WARN_ON
>>>
>>> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
>>>
>>> Signed-off-by: Jouni Högander <jouni.hogander@intel.com>
>>> ---
>>>  drivers/gpu/drm/i915/display/intel_frontbuffer.c | 3 ++-
>>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/gpu/drm/i915/display/intel_frontbuffer.c b/drivers/gpu/drm/i915/display/intel_frontbuffer.c
>>> index d5540c739404..95319301cf2b 100644
>>> --- a/drivers/gpu/drm/i915/display/intel_frontbuffer.c
>>> +++ b/drivers/gpu/drm/i915/display/intel_frontbuffer.c
>>> @@ -259,7 +259,8 @@ static void frontbuffer_release(struct kref *ref)
>>>  
>>>          i915_ggtt_clear_scanout(obj);
>>>  
>>> -        i915_gem_object_set_frontbuffer(obj, NULL);
>>> +        drm_WARN_ON(&intel_bo_to_i915(obj)->drm,
>>> +                    i915_gem_object_set_frontbuffer(obj, NULL) != NULL);
>>
>>I'm in the camp that says drm_WARN_ON() and friends should not contain
>>any functional actions, and it should just be for checks. I.e. if you
>>removed all the warns, things would still work, and lines that do stuff
>>stand out and aren't hidden in WARN parameters.
>
> Good rationale.
>
> Here is a command for finding places where a fix might be applicable :-)
>
>     spatch --very-quiet --sp 'drm_WARN_ON(..., <+... E(...) ...+>)' drivers/gpu/drm/i915

Good hints, but also a *lot* of false positives!

BR,
Jani.

>
> --
> Gustavo Sousa
>
>>
>>Like so:
>>
>>        ret = i915_gem_object_set_frontbuffer(obj, NULL);
>>        drm_WARN_ON(&intel_bo_to_i915(obj)->drm, ret);
>>
>>BR,
>>Jani.
>>
>>>          spin_unlock(&intel_bo_to_i915(obj)->display.fb_tracking.lock);
>>>  
>>>          i915_active_fini(&front->write);
>>
>>-- 
>>Jani Nikula, Intel

-- 
Jani Nikula, Intel

  reply	other threads:[~2023-10-02  7:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-28  6:52 [Intel-gfx] [PATCH v2] drm/i915: Warn on if set frontbuffer return value is not NULL on release Jouni Högander
2023-09-28  7:32 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for " Patchwork
2023-09-28  7:43 ` [Intel-gfx] [PATCH v2] " Jani Nikula
2023-09-28  8:31   ` Hogander, Jouni
2023-09-29 13:29   ` Gustavo Sousa
2023-10-02  7:08     ` Jani Nikula [this message]
2023-10-02 12:28       ` Gustavo Sousa
2023-09-28  7:46 ` [Intel-gfx] ✓ Fi.CI.BAT: success for " Patchwork

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=877co5ijrb.fsf@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=gustavo.sousa@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jouni.hogander@intel.com \
    --cc=rodrigo.vivi@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