From: Alex Williamson <alex.williamson@redhat.com>
To: Max Gurtovoy <mgurtovoy@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>, <cohuck@redhat.com>,
<kvm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<aviadye@nvidia.com>, <oren@nvidia.com>, <shahafs@nvidia.com>,
<parav@nvidia.com>, <artemp@nvidia.com>, <kwankhede@nvidia.com>,
<ACurrid@nvidia.com>, <cjia@nvidia.com>, <yishaih@nvidia.com>,
<kevin.tian@intel.com>, <hch@infradead.org>,
<targupta@nvidia.com>, <shameerali.kolothum.thodi@huawei.com>,
<liulongfang@huawei.com>, <yan.y.zhao@intel.com>
Subject: Re: [PATCH 09/11] PCI: add matching checks for driver_override binding
Date: Mon, 14 Jun 2021 12:42:50 -0600 [thread overview]
Message-ID: <20210614124250.0d32537c.alex.williamson@redhat.com> (raw)
In-Reply-To: <117a5e68-d16e-c146-6d37-fcbfe49cb4f8@nvidia.com>
On Sun, 13 Jun 2021 11:19:46 +0300
Max Gurtovoy <mgurtovoy@nvidia.com> wrote:
> On 6/9/2021 4:27 AM, Alex Williamson wrote:
> > On Tue, 8 Jun 2021 19:45:17 -0300
> > Jason Gunthorpe <jgg@nvidia.com> wrote:
> >
> >> On Tue, Jun 08, 2021 at 03:26:43PM -0600, Alex Williamson wrote:
> >>>> drivers that specifically opt into this feature and the driver now has
> >>>> the opportunity to provide a proper match table that indicates what HW
> >>>> it can properly support. vfio-pci continues to support everything.
> >>> In doing so, this also breaks the new_id method for vfio-pci.
> >> Does it? How? The driver_override flag is per match entry not for the
> >> entire device so new_id added things will work the same as before as
> >> their new match entry's flags will be zero.
> > Hmm, that might have been a testing issue; combining driverctl with
> > manual new_id testing might have left a driver_override in place.
> >
> >>> Sorry, with so many userspace regressions, crippling the
> >>> driver_override interface with an assumption of such a narrow focus,
> >>> creating a vfio specific match flag, I don't see where this can go.
> >>> Thanks,
> >> On the other hand it overcomes all the objections from the last go
> >> round: how userspace figures out which driver to use with
> >> driver_override and integrating the universal driver into the scheme.
> >>
> >> pci_stub could be delt with by marking it for driver_override like
> >> vfio_pci.
> > By marking it a "vfio driver override"? :-\
> >
> >> But driverctl as a general tool working with any module is not really
> >> addressable.
> >>
> >> Is the only issue the blocking of the arbitary binding? That is not a
> >> critical peice of this, IIRC
> > We can't break userspace, which means new_id and driver_override need
> > to work as they do now. There are scads of driver binding scripts in
> > the wild, for vfio-pci and other drivers. We can't assume such a
> > narrow scope. Thanks,
>
> what about the following code ?
>
> @@ -152,12 +152,28 @@ static const struct pci_device_id
> *pci_match_device(struct pci_driver *drv,
> }
> spin_unlock(&drv->dynids.lock);
>
> - if (!found_id)
> - found_id = pci_match_id(drv->id_table, dev);
> + if (found_id)
> + return found_id;
a) A dynamic ID match always works regardless of driver override...
>
> - /* driver_override will always match, send a dummy id */
> - if (!found_id && dev->driver_override)
> + found_id = pci_match_id(drv->id_table, dev);
> + if (found_id) {
> + /*
> + * if we found id in the static table, we must fulfill the
> + * matching flags (i.e. if PCI_ID_F_DRIVER_OVERRIDE flag is
> + * set, driver_override should be provided).
> + */
> + bool is_driver_override =
> + (found_id->flags & PCI_ID_F_DRIVER_OVERRIDE) != 0;
> + if ((is_driver_override && !dev->driver_override) ||
b) A static ID match fails if the driver provides an override flag and
the device does not have an override set, or...
> + (dev->driver_override && !is_driver_override))
c) The device has an override set and the driver does not support the
override flag.
> + return NULL;
> + } else if (dev->driver_override) {
> + /*
> + * if we didn't find suitable id in the static table,
> + * driver_override will still , send a dummy id
> + */
> found_id = &pci_device_id_any;
> + }
>
> return found_id;
> }
>
>
> dynamic ids (new_id) works as before.
>
> Old driver_override works as before.
This is deceptively complicated, but no, I don't believe it does. By
my understanding of c) an "old" driver can no longer use
driver_override for binding a known device. It seems that if we have a
static ID match, then we cannot have a driver_override set for the
device in such a case. This is a userspace regression.
> For "new" driver_override we must fulfill the new rules.
For override'able drivers, the static table is almost useless other
than using it for modules.alias support and potentially to provide
driver_data. As above, I find this all pretty confusing and I'd advise
trying to write a concise set of rules outlining the behavior of
driver_override vs dynamic IDs vs static IDs vs "override'able" driver
flags. I tried, I can't, it's convoluted and full of exceptions.
Thanks,
Alex
next prev parent reply other threads:[~2021-06-14 18:42 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-03 16:07 [RFC PATCH v4 00/11] Introduce vfio-pci-core subsystem Max Gurtovoy
2021-06-03 16:07 ` [PATCH 01/11] vfio-pci: rename vfio_pci.c to vfio_pci_core.c Max Gurtovoy
2021-06-03 16:08 ` [PATCH 02/11] vfio-pci: rename vfio_pci_private.h to vfio_pci_core.h Max Gurtovoy
2021-06-03 16:08 ` [PATCH 03/11] vfio-pci: rename vfio_pci_device to vfio_pci_core_device Max Gurtovoy
2021-06-03 16:08 ` [PATCH 04/11] vfio-pci: rename ops functions to fit core namings Max Gurtovoy
2021-06-03 16:08 ` [PATCH 05/11] vfio-pci: include vfio header in vfio_pci_core.h Max Gurtovoy
2021-06-03 16:08 ` [PATCH 06/11] vfio-pci: introduce vfio_pci.c Max Gurtovoy
2021-06-03 16:08 ` [PATCH 07/11] vfio-pci: move igd initialization to vfio_pci.c Max Gurtovoy
2021-06-03 16:08 ` [PATCH 08/11] PCI: add flags field to pci_device_id structure Max Gurtovoy
2021-06-03 16:08 ` [PATCH 09/11] PCI: add matching checks for driver_override binding Max Gurtovoy
2021-06-08 21:26 ` Alex Williamson
2021-06-08 22:45 ` Jason Gunthorpe
2021-06-09 1:27 ` Alex Williamson
2021-06-09 9:26 ` Max Gurtovoy
2021-06-13 8:19 ` Max Gurtovoy
2021-06-14 5:40 ` Christoph Hellwig
2021-06-14 8:18 ` Max Gurtovoy
2021-06-14 15:27 ` Christoph Hellwig
2021-06-14 16:01 ` Jason Gunthorpe
2021-06-14 16:15 ` Christoph Hellwig
2021-06-14 16:33 ` Jason Gunthorpe
2021-06-14 18:42 ` Alex Williamson [this message]
2021-06-14 23:12 ` Max Gurtovoy
2021-06-15 15:00 ` Alex Williamson
2021-06-15 15:04 ` Jason Gunthorpe
2021-06-15 16:20 ` Alex Williamson
2021-06-15 20:42 ` Jason Gunthorpe
2021-06-15 21:59 ` Alex Williamson
2021-06-15 23:00 ` Jason Gunthorpe
2021-06-15 23:22 ` Alex Williamson
2021-06-15 23:32 ` Jason Gunthorpe
2021-06-16 0:22 ` Alex Williamson
2021-06-16 0:34 ` Jason Gunthorpe
2021-06-16 23:28 ` Max Gurtovoy
2021-06-16 23:33 ` Jason Gunthorpe
2021-06-16 23:42 ` Max Gurtovoy
2021-06-16 23:44 ` Jason Gunthorpe
2021-06-16 23:51 ` Max Gurtovoy
2021-06-16 23:56 ` Jason Gunthorpe
2021-06-20 14:46 ` Max Gurtovoy
2021-06-03 16:08 ` [PATCH 10/11] vfio-pci: introduce vfio_pci_core subsystem driver Max Gurtovoy
2021-06-08 21:26 ` Alex Williamson
2021-06-09 9:29 ` Max Gurtovoy
2021-06-03 16:08 ` [PATCH 11/11] mlx5-vfio-pci: add new vfio_pci driver for mlx5 devices Max Gurtovoy
2021-07-30 7:53 ` [RFC PATCH v4 00/11] Introduce vfio-pci-core subsystem Shameerali Kolothum Thodi
2021-07-30 11:55 ` Jason Gunthorpe
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=20210614124250.0d32537c.alex.williamson@redhat.com \
--to=alex.williamson@redhat.com \
--cc=ACurrid@nvidia.com \
--cc=artemp@nvidia.com \
--cc=aviadye@nvidia.com \
--cc=cjia@nvidia.com \
--cc=cohuck@redhat.com \
--cc=hch@infradead.org \
--cc=jgg@nvidia.com \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=kwankhede@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=liulongfang@huawei.com \
--cc=mgurtovoy@nvidia.com \
--cc=oren@nvidia.com \
--cc=parav@nvidia.com \
--cc=shahafs@nvidia.com \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=targupta@nvidia.com \
--cc=yan.y.zhao@intel.com \
--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).