All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andi Shyti <andi.shyti@linux.intel.com>
To: "Murthy, Arun R" <arun.r.murthy@intel.com>
Cc: Andi Shyti <andi.shyti@linux.intel.com>,
	Jani Nikula <jani.nikula@linux.intel.com>,
	"intel-gfx@lists.freedesktop.org"
	<intel-gfx@lists.freedesktop.org>,
	"intel-xe@lists.freedesktop.org" <intel-xe@lists.freedesktop.org>
Subject: Re: [PATCHv2] drm/xe/display: check for error on drmm_mutex_init
Date: Thu, 28 Mar 2024 12:07:59 +0100	[thread overview]
Message-ID: <ZgVPj8wHbjj2Oyu_@ashyti-mobl2.lan> (raw)
In-Reply-To: <IA0PR11MB730702DC9B3DBCAFB8396B33BA3B2@IA0PR11MB7307.namprd11.prod.outlook.com>

Hi Arun,

> > On Thu, Mar 28, 2024 at 12:33:09PM +0200, Jani Nikula wrote:
> > > On Thu, 28 Mar 2024, Andi Shyti <andi.shyti@linux.intel.com> wrote:
> > > >> -	drmm_mutex_init(&xe->drm, &xe->sb_lock);
> > > >> -	drmm_mutex_init(&xe->drm, &xe->display.backlight.lock);
> > > >> -	drmm_mutex_init(&xe->drm, &xe->display.audio.mutex);
> > > >> -	drmm_mutex_init(&xe->drm, &xe->display.wm.wm_mutex);
> > > >> -	drmm_mutex_init(&xe->drm, &xe->display.pps.mutex);
> > > >> -	drmm_mutex_init(&xe->drm, &xe->display.hdcp.hdcp_mutex);
> > > >> +	if (drmm_mutex_init(&xe->drm, &xe->sb_lock) ||
> > > >> +	    drmm_mutex_init(&xe->drm, &xe->display.backlight.lock) ||
> > > >> +	    drmm_mutex_init(&xe->drm, &xe->display.audio.mutex) ||
> > > >> +	    drmm_mutex_init(&xe->drm, &xe->display.wm.wm_mutex) ||
> > > >> +	    drmm_mutex_init(&xe->drm, &xe->display.pps.mutex) ||
> > > >> +	    drmm_mutex_init(&xe->drm, &xe->display.hdcp.hdcp_mutex))
> > > >> +		return -ENOMEM;
> > > >
> > > > why not extract the value from drmm_mutex_init()? it would make the
> > > > code a bit more complex, but better than forcing a -ENOMEM return.
> > > >
> > > > 	err = drmm_mutex_init(...)
> > > > 	if (err)
> > > > 		return err;
> > > >
> > > > 	err = drmm_mutex_init(...)
> > > > 	if (err)
> > > > 		return err;
> > > >
> > > > 	err = drmm_mutex_init(...)
> > > > 	if (err)
> > > > 		return err;
> > > >
> > > > 	...
> > > >
> > > > On the other hand drmm_mutex_init(), as of now returns only -ENOMEM,
> 
> The function is also returning -ENOMEM and there is no other error code returned from the error.

yes, but it's wrong to assume this will always be true.

> > > > but it's a bad practice to assume it will always do. I'd rather
> > > > prefer not to check the error value at all.
> > >
> > > And round and round we go. This is exactly what v1 was [1], but it's
> > > not clear because the patch doesn't have a changelog.
> > 
> > ha! funny! I missed v1.
> > 
> > > This is all utterly ridiculous compared to *why* we even have or use
> > > drmm_mutex_init(). Managed initialization causes more trouble here
> > > than it gains us. Gah.
> > 
> > As I wrote here:
> > 
> > > > I'd rather prefer not to check the error value at all.
> > 
> > we could rather drop this patch. Checking the error value is always good, but
> > checking implausible errors with this price is not really worth it.
> 
> This is reported as error from Coverity. My suggestion was also to discard this error from Coverity but the same API used in other places in our driver is considering the return value.

Strictly speaking, coverity is right and if I have to choose, I'd
prefer your v1. v2, in my opinion, is wrong, even if it's more
nice and readable.

Thanks,
Andi

  reply	other threads:[~2024-03-28 11:08 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-28  8:00 [PATCHv2] drm/xe/display: check for error on drmm_mutex_init Arun R Murthy
2024-03-28  8:15 ` ✓ CI.Patch_applied: success for drm/xe/display: check for error on drmm_mutex_init (rev3) Patchwork
2024-03-28  8:15 ` ✓ CI.checkpatch: " Patchwork
2024-03-28  8:16 ` ✓ CI.KUnit: " Patchwork
2024-03-28  8:31 ` [PATCHv2] drm/xe/display: check for error on drmm_mutex_init Andi Shyti
2024-03-28 10:33   ` Jani Nikula
2024-03-28 10:45     ` Andi Shyti
2024-03-28 10:55       ` Murthy, Arun R
2024-03-28 11:07         ` Andi Shyti [this message]
2024-03-30 12:05           ` Murthy, Arun R
2024-04-03 15:32     ` Lucas De Marchi
2024-03-28  8:34 ` ✓ CI.Build: success for drm/xe/display: check for error on drmm_mutex_init (rev3) Patchwork
2024-03-28  8:37 ` ✓ CI.Hooks: " Patchwork
2024-03-28  8:38 ` ✓ CI.checksparse: " Patchwork
2024-03-28  9:22 ` ✓ CI.BAT: " Patchwork
2024-03-28 15:23 ` ✓ Fi.CI.BAT: " Patchwork
2024-03-28 17:48 ` ✓ Fi.CI.IGT: " Patchwork
2024-03-28 22:46 ` ✗ Fi.CI.IGT: failure " 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=ZgVPj8wHbjj2Oyu_@ashyti-mobl2.lan \
    --to=andi.shyti@linux.intel.com \
    --cc=arun.r.murthy@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jani.nikula@linux.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.