All of lore.kernel.org
 help / color / mirror / Atom feed
From: Utkarsh Verma <utkarshverma294@gmail.com>
To: Greg KH <greg@kroah.com>
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kernel-mentees@lists.linuxfoundation.org,
	Bjorn Helgaas <bhelgaas@google.com>,
	Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH] PCI: Remove duplicate #ifdef in pci_try_set_mwi()
Date: Thu, 12 Aug 2021 16:25:37 +0530	[thread overview]
Message-ID: <20210812105537.GA9541@uver-laptop> (raw)
In-Reply-To: <YRTEcd0S2/2XlL7p@kroah.com>

On Thu, Aug 12, 2021 at 08:49:21AM +0200, Greg KH wrote:
> On Thu, Aug 12, 2021 at 05:16:01AM +0530, Utkarsh Verma wrote:
> > Remove the unnecessary #ifdef PCI_DISABLE_MWI, because pci_set_mwi()
> > performs the same check.
> > 
> > Signed-off-by: Utkarsh Verma <utkarshverma294@gmail.com>
> > ---
> >  drivers/pci/pci.c | 4 ----
> >  1 file changed, 4 deletions(-)
> > 
> > diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> > index aacf575c15cf..7d4c7c294ef2 100644
> > --- a/drivers/pci/pci.c
> > +++ b/drivers/pci/pci.c
> > @@ -4456,11 +4456,7 @@ EXPORT_SYMBOL(pcim_set_mwi);
> >   */
> >  int pci_try_set_mwi(struct pci_dev *dev)
> >  {
> > -#ifdef PCI_DISABLE_MWI
> > -	return 0;
> > -#else
> >  	return pci_set_mwi(dev);
> > -#endif
> >  }
> >  EXPORT_SYMBOL(pci_try_set_mwi);
> 
> If this is the case, why do we even need pci_try_set_mwi()?  Why not
> just replace it with calls to pci_set_mwi() and then delete this one?

The only difference between the pci_set_mwi() and pci_try_set_mwi() is
that, pci_set_mwi() is declared as __must_check which forces return
value checking.

The reason why pci_try_set_mwi() was introduced in the first place was
because it gives the drivers both options:
(1) most of the drivers don't require checking the return value, and
they can safely ignore the errors values returned if any, so
pci_try_set_mwi() can be used.
(2) But for some of the drivers it is nice to check the return values,
and generate proper warnings for error handling. By using the
pci_set_mwi(), we force the driver for proper error checking.

So both the functions are similar but have different purposes, and it
seems a more appropriate design.
The whole argument about adding this function:
https://lore.kernel.org/linux-ide/20070404213704.224128ec.randy.dunlap@oracle.com/

Also earlier there was a patch that removed the pci_try_set_mwi() and
__must_check attribute from pci_set_mwi(), just like you wanted,
https://lore.kernel.org/linux-pci/4d535d35-6c8c-2bd8-812b-2b53194ce0ec@gmail.com/
But it was not accepted because Bjorn wasn't convinced and he also gave
the above argument and that we should not break something in the name of
cleaning it up.

But it is safe to only remove the duplicate #ifdef block inside the
pci_try_set_mwi().


Best Regards,
Utkarsh Verma

WARNING: multiple messages have this Message-ID (diff)
From: Utkarsh Verma <utkarshverma294@gmail.com>
To: Greg KH <greg@kroah.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
	linux-pci@vger.kernel.org,
	linux-kernel-mentees@lists.linuxfoundation.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] PCI: Remove duplicate #ifdef in pci_try_set_mwi()
Date: Thu, 12 Aug 2021 16:25:37 +0530	[thread overview]
Message-ID: <20210812105537.GA9541@uver-laptop> (raw)
In-Reply-To: <YRTEcd0S2/2XlL7p@kroah.com>

On Thu, Aug 12, 2021 at 08:49:21AM +0200, Greg KH wrote:
> On Thu, Aug 12, 2021 at 05:16:01AM +0530, Utkarsh Verma wrote:
> > Remove the unnecessary #ifdef PCI_DISABLE_MWI, because pci_set_mwi()
> > performs the same check.
> > 
> > Signed-off-by: Utkarsh Verma <utkarshverma294@gmail.com>
> > ---
> >  drivers/pci/pci.c | 4 ----
> >  1 file changed, 4 deletions(-)
> > 
> > diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> > index aacf575c15cf..7d4c7c294ef2 100644
> > --- a/drivers/pci/pci.c
> > +++ b/drivers/pci/pci.c
> > @@ -4456,11 +4456,7 @@ EXPORT_SYMBOL(pcim_set_mwi);
> >   */
> >  int pci_try_set_mwi(struct pci_dev *dev)
> >  {
> > -#ifdef PCI_DISABLE_MWI
> > -	return 0;
> > -#else
> >  	return pci_set_mwi(dev);
> > -#endif
> >  }
> >  EXPORT_SYMBOL(pci_try_set_mwi);
> 
> If this is the case, why do we even need pci_try_set_mwi()?  Why not
> just replace it with calls to pci_set_mwi() and then delete this one?

The only difference between the pci_set_mwi() and pci_try_set_mwi() is
that, pci_set_mwi() is declared as __must_check which forces return
value checking.

The reason why pci_try_set_mwi() was introduced in the first place was
because it gives the drivers both options:
(1) most of the drivers don't require checking the return value, and
they can safely ignore the errors values returned if any, so
pci_try_set_mwi() can be used.
(2) But for some of the drivers it is nice to check the return values,
and generate proper warnings for error handling. By using the
pci_set_mwi(), we force the driver for proper error checking.

So both the functions are similar but have different purposes, and it
seems a more appropriate design.
The whole argument about adding this function:
https://lore.kernel.org/linux-ide/20070404213704.224128ec.randy.dunlap@oracle.com/

Also earlier there was a patch that removed the pci_try_set_mwi() and
__must_check attribute from pci_set_mwi(), just like you wanted,
https://lore.kernel.org/linux-pci/4d535d35-6c8c-2bd8-812b-2b53194ce0ec@gmail.com/
But it was not accepted because Bjorn wasn't convinced and he also gave
the above argument and that we should not break something in the name of
cleaning it up.

But it is safe to only remove the duplicate #ifdef block inside the
pci_try_set_mwi().


Best Regards,
Utkarsh Verma
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

  reply	other threads:[~2021-08-12 10:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-11 23:46 [PATCH] PCI: Remove duplicate #ifdef in pci_try_set_mwi() Utkarsh Verma
2021-08-11 23:46 ` Utkarsh Verma
2021-08-12  6:49 ` Greg KH
2021-08-12  6:49   ` Greg KH
2021-08-12 10:55   ` Utkarsh Verma [this message]
2021-08-12 10:55     ` Utkarsh Verma

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=20210812105537.GA9541@uver-laptop \
    --to=utkarshverma294@gmail.com \
    --cc=bhelgaas@google.com \
    --cc=greg@kroah.com \
    --cc=linux-kernel-mentees@lists.linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=skhan@linuxfoundation.org \
    /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.