linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: Yishai Hadas <yishaih@nvidia.com>,
	bhelgaas@google.com, corbet@lwn.net, diana.craciun@oss.nxp.com,
	kwankhede@nvidia.com, eric.auger@redhat.com,
	masahiroy@kernel.org, michal.lkml@markovi.net,
	linux-pci@vger.kernel.org, linux-doc@vger.kernel.org,
	kvm@vger.kernel.org, linux-s390@vger.kernel.org,
	linux-kbuild@vger.kernel.org, mgurtovoy@nvidia.com,
	maorg@nvidia.com, leonro@nvidia.com
Subject: Re: [PATCH V4 10/13] PCI / VFIO: Add 'override_only' support for VFIO PCI sub system
Date: Wed, 25 Aug 2021 16:33:38 -0600	[thread overview]
Message-ID: <20210825163338.68ad5a4d.alex.williamson@redhat.com> (raw)
In-Reply-To: <20210825222443.GN1721383@nvidia.com>

On Wed, 25 Aug 2021 19:24:43 -0300
Jason Gunthorpe <jgg@nvidia.com> wrote:

> On Wed, Aug 25, 2021 at 04:05:46PM -0600, Alex Williamson wrote:
> > On Wed, 25 Aug 2021 16:51:36 +0300
> > Yishai Hadas <yishaih@nvidia.com> wrote:  
> > > diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
> > > index 7c97fa8e36bc..c3edbf73157e 100644
> > > +++ b/scripts/mod/file2alias.c
> > > @@ -426,7 +426,7 @@ static int do_ieee1394_entry(const char *filename,
> > >  	return 1;
> > >  }
> > >  
> > > -/* Looks like: pci:vNdNsvNsdNbcNscNiN. */
> > > +/* Looks like: pci:vNdNsvNsdNbcNscNiN or <prefix>_pci:vNdNsvNsdNbcNscNiN. */
> > >  static int do_pci_entry(const char *filename,
> > >  			void *symval, char *alias)
> > >  {
> > > @@ -440,8 +440,12 @@ static int do_pci_entry(const char *filename,
> > >  	DEF_FIELD(symval, pci_device_id, subdevice);
> > >  	DEF_FIELD(symval, pci_device_id, class);
> > >  	DEF_FIELD(symval, pci_device_id, class_mask);
> > > +	DEF_FIELD(symval, pci_device_id, override_only);
> > >  
> > > -	strcpy(alias, "pci:");
> > > +	if (override_only & PCI_ID_F_VFIO_DRIVER_OVERRIDE)
> > > +		strcpy(alias, "vfio_pci:");
> > > +	else
> > > +		strcpy(alias, "pci:");  
> > 
> > I'm a little concerned that we're allowing unknown, non-zero
> > override_only values to fall through to create "pci:" alias matches.
> > Should this be something like:
> > 
> > 	if (override_only & PCI_ID_F_VFIO_DRIVER_OVERRIDE) {  
> 
> Should probably be == not &, since in this new arrangement it is
> really more of an enum than a bit flags... A switch would be OK here
> too
> 
> > 		strcpy(alias, "vfio_pci:");
> > 	} else if (override_only) {
> > 		warn("Unknown PCI driver_override alias %08X\n",
> > 			driver_override);
> > 		return 0;
> > 	} else {
> > 		strcpy(alias, "pci:");
> > 	}  
> 
> It seems reasonable to me to throw a warn, it signals to a future
> developer that kbuild is not working right.
> 
> > And then if we can only have a single bit set in override_only (I
> > can't think of a use case for a single entry to have multiple
> > override options), should PCI_DEVICE_DRIVER_OVERRIDE() be defined to
> > take a "driver_override_shift" value where .driver_override is assigned
> > (1 << driver_override_shift)?  That would encode the semantics in the
> > prototypes a little better.    
> 
> I think it is just an enum of overrides, no reason to make it one hot
> encoded. Previously when it was flags the bit encode had a certain
> amount of logic, but no longer.

Yeah, a switch statement handling pci:/vfio_pci:/warn rather than
testing bits would clear things up for me.  Thanks,

Alex


  reply	other threads:[~2021-08-25 22:33 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-25 13:51 [PATCH V4 00/13] Introduce vfio_pci_core subsystem Yishai Hadas
2021-08-25 13:51 ` [PATCH V4 01/13] vfio/pci: Rename vfio_pci.c to vfio_pci_core.c Yishai Hadas
2021-08-26  9:15   ` Christoph Hellwig
2021-08-25 13:51 ` [PATCH V4 02/13] vfio/pci: Rename vfio_pci_private.h to vfio_pci_core.h Yishai Hadas
2021-08-26  9:17   ` Christoph Hellwig
2021-08-25 13:51 ` [PATCH V4 03/13] vfio/pci: Rename vfio_pci_device to vfio_pci_core_device Yishai Hadas
2021-08-26  9:22   ` Christoph Hellwig
2021-08-25 13:51 ` [PATCH V4 04/13] vfio/pci: Rename ops functions to fit core namings Yishai Hadas
2021-08-26  9:25   ` Christoph Hellwig
2021-08-25 13:51 ` [PATCH V4 05/13] vfio/pci: Include vfio header in vfio_pci_core.h Yishai Hadas
2021-08-26  9:27   ` Christoph Hellwig
2021-08-25 13:51 ` [PATCH V4 06/13] vfio/pci: Split the pci_driver code out of vfio_pci_core.c Yishai Hadas
2021-08-26  9:31   ` Christoph Hellwig
2021-08-25 13:51 ` [PATCH V4 07/13] vfio/pci: Move igd initialization to vfio_pci.c Yishai Hadas
2021-08-26  9:34   ` Christoph Hellwig
2021-08-25 13:51 ` [PATCH V4 08/13] vfio/pci: Move module parameters " Yishai Hadas
2021-08-26  9:36   ` Christoph Hellwig
2021-08-25 13:51 ` [PATCH V4 09/13] PCI: Add 'override_only' field to struct pci_device_id Yishai Hadas
2021-08-25 15:54   ` Bjorn Helgaas
2021-08-25 21:25     ` Alex Williamson
2021-08-25 13:51 ` [PATCH V4 10/13] PCI / VFIO: Add 'override_only' support for VFIO PCI sub system Yishai Hadas
2021-08-25 15:55   ` Bjorn Helgaas
2021-08-25 22:05   ` Alex Williamson
2021-08-25 22:24     ` Jason Gunthorpe
2021-08-25 22:33       ` Alex Williamson [this message]
2021-08-25 13:51 ` [PATCH V4 11/13] vfio: Use select for eventfd Yishai Hadas
2021-08-26  9:06   ` Christoph Hellwig
2021-08-25 13:51 ` [PATCH V4 12/13] vfio: Use kconfig if XX/endif blocks instead of repeating 'depends on' Yishai Hadas
2021-08-26  9:09   ` Christoph Hellwig
2021-08-25 13:51 ` [PATCH V4 13/13] vfio/pci: Introduce vfio_pci_core.ko Yishai Hadas
2021-08-26  9:12   ` Christoph Hellwig

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=20210825163338.68ad5a4d.alex.williamson@redhat.com \
    --to=alex.williamson@redhat.com \
    --cc=bhelgaas@google.com \
    --cc=corbet@lwn.net \
    --cc=diana.craciun@oss.nxp.com \
    --cc=eric.auger@redhat.com \
    --cc=jgg@nvidia.com \
    --cc=kvm@vger.kernel.org \
    --cc=kwankhede@nvidia.com \
    --cc=leonro@nvidia.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=maorg@nvidia.com \
    --cc=masahiroy@kernel.org \
    --cc=mgurtovoy@nvidia.com \
    --cc=michal.lkml@markovi.net \
    --cc=yishaih@nvidia.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;
as well as URLs for NNTP newsgroup(s).