linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
Cc: "Bjorn Helgaas" <helgaas@kernel.org>,
	linux-pci@vger.kernel.org, "Krzysztof Wilczyński" <kw@linux.com>,
	"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	"Bjorn Helgaas" <bhelgaas@google.com>
Subject: Re: [PATCH 06/10] PCI/DPC: Use FIELD_GET()
Date: Wed, 11 Oct 2023 14:13:47 +0300 (EEST)	[thread overview]
Message-ID: <f6c43aea-8e30-c3df-8318-3e9f79aaf6c@linux.intel.com> (raw)
In-Reply-To: <20231011120739.00005d7d@Huawei.com>

On Wed, 11 Oct 2023, Jonathan Cameron wrote:

> On Tue, 10 Oct 2023 15:44:32 -0500
> Bjorn Helgaas <helgaas@kernel.org> wrote:
> 
> > From: Bjorn Helgaas <bhelgaas@google.com>
> > 
> > Use FIELD_GET() to remove dependences on the field position, i.e., the
> > shift value.  No functional change intended.
> > 
> > Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> A question about what 'rules' you are applying for using these macros
> vs choosing not not do so. Personally I prefer using them even for
> flag fields mostly because it makes the code more consistent and
> the compiler should remove any unnecessary shifts that result.
> 
> > ---
> 
> > diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
> > index eeec1d6f9023..a9fdc2e3f110 100644
> > --- a/drivers/pci/quirks.c
> > +++ b/drivers/pci/quirks.c
> > @@ -6154,7 +6154,7 @@ static void dpc_log_size(struct pci_dev *dev)
> >  	if (!(val & PCI_EXP_DPC_CAP_RP_EXT))
> 
> This is what I'm commenting on below.
> 
> >  		return;
> >  
> > -	if (!((val & PCI_EXP_DPC_RP_PIO_LOG_SIZE) >> 8)) {
> > +	if (FIELD_GET(PCI_EXP_DPC_RP_PIO_LOG_SIZE, val) == 0) {
> 
> Why do this one and not the one just above?
> In both cases extracting a field then comparing it to 0, I'm not sure
> it makes sense to care if that field is 1 bit or multiple bit.

I cannot speak for Bjorn but at least I've left flag checks untouched
(but when pulling the flag into a variable, I've made it with FIELD_GET()).

In anycase, that seems minor issue though compared with defined values of 
the field being incompatible with the FIELD_GET()ed value (when the shift 
is non-zero). I wish there would be good solution to that but so far I've 
not come up anything that would be short and simple enough.

-- 
 i.


  reply	other threads:[~2023-10-11 11:14 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-10 20:44 [PATCH 00/10] PCI: Use FIELD_GET() and FIELD_PREP() Bjorn Helgaas
2023-10-10 20:44 ` [PATCH 01/10] PCI: Use FIELD_GET() Bjorn Helgaas
2023-10-11 10:50   ` Jonathan Cameron
2023-10-11 11:24   ` Ilpo Järvinen
2023-10-10 20:44 ` [PATCH 02/10] PCI: Use FIELD_GET() in Sapphire RX 5600 XT Pulse quirk Bjorn Helgaas
2023-10-11 10:59   ` Jonathan Cameron
2023-10-11 11:31   ` Ilpo Järvinen
2023-10-10 20:44 ` [PATCH 03/10] PCI/ASPM: Use FIELD_GET() Bjorn Helgaas
2023-10-10 21:07   ` Bjorn Helgaas
2023-10-10 20:44 ` [PATCH 04/10] PCI/ATS: Show PASID Capability register width in bitmasks Bjorn Helgaas
2023-10-11 11:00   ` Jonathan Cameron
2023-10-11 11:31   ` Ilpo Järvinen
2023-10-10 20:44 ` [PATCH 05/10] PCI/ATS: Use FIELD_GET() Bjorn Helgaas
2023-10-11 11:02   ` Jonathan Cameron
2023-10-11 11:20   ` Ilpo Järvinen
2023-10-10 20:44 ` [PATCH 06/10] PCI/DPC: " Bjorn Helgaas
2023-10-11 11:01   ` Ilpo Järvinen
2023-10-13 11:23     ` Ilpo Järvinen
2023-10-13 20:02     ` Bjorn Helgaas
2023-10-16 12:55       ` Ilpo Järvinen
2023-10-16 15:10         ` Ilpo Järvinen
2023-10-16 15:14           ` Ilpo Järvinen
2023-10-11 11:07   ` Jonathan Cameron
2023-10-11 11:13     ` Ilpo Järvinen [this message]
2023-10-10 20:44 ` [PATCH 07/10] PCI/PME: " Bjorn Helgaas
2023-10-11 11:10   ` Jonathan Cameron
2023-10-11 11:38   ` Ilpo Järvinen
2023-10-10 20:44 ` [PATCH 08/10] PCI/PTM: " Bjorn Helgaas
2023-10-11 11:11   ` Jonathan Cameron
2023-10-11 11:15   ` Ilpo Järvinen
2023-10-10 20:44 ` [PATCH 09/10] PCI/VC: " Bjorn Helgaas
2023-10-11 11:13   ` Jonathan Cameron
2023-10-11 11:39   ` Ilpo Järvinen
2023-10-10 20:44 ` [PATCH 10/10] PCI/portdrv: " Bjorn Helgaas
2023-10-11 11:14   ` Jonathan Cameron
2023-10-11 11:40   ` Ilpo Järvinen
2023-10-11 14:50 ` [PATCH 00/10] PCI: Use FIELD_GET() and FIELD_PREP() Kuppuswamy Sathyanarayanan
2023-10-18 21:00 ` Bjorn Helgaas

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=f6c43aea-8e30-c3df-8318-3e9f79aaf6c@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=Jonathan.Cameron@Huawei.com \
    --cc=bhelgaas@google.com \
    --cc=helgaas@kernel.org \
    --cc=kw@linux.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lpieralisi@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).