From: Stephen Hemminger <stephen@networkplumber.org>
To: "Michael Kelley (EOSG)" <Michael.H.Kelley@microsoft.com>
Cc: KY Srinivasan <kys@microsoft.com>,
"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"devel@linuxdriverproject.org" <devel@linuxdriverproject.org>,
"olaf@aepfle.de" <olaf@aepfle.de>,
"apw@canonical.com" <apw@canonical.com>,
"jasowang@redhat.com" <jasowang@redhat.com>,
Stephen Hemminger <sthemmin@microsoft.com>,
"vkuznets@redhat.com" <vkuznets@redhat.com>
Subject: Re: [PATCH 2/5] vmbus: add driver_override support
Date: Mon, 13 Aug 2018 12:56:57 -0700 [thread overview]
Message-ID: <20180813125657.739a1465@xeon-e3> (raw)
In-Reply-To: <CY4PR21MB07739595C31B9B9349604C0ADC390@CY4PR21MB0773.namprd21.prod.outlook.com>
On Mon, 13 Aug 2018 19:30:50 +0000
"Michael Kelley (EOSG)" <Michael.H.Kelley@microsoft.com> wrote:
> From: kys@linuxonhyperv.com <kys@linuxonhyperv.com> Sent: Friday, August 10, 2018 4:06 PM
>
> > From: Stephen Hemminger <stephen@networkplumber.org>
> >
> > Add support for overriding the default driver for a VMBus device
> > in the same way that it can be done for PCI devices. This patch
> > adds the /sys/bus/vmbus/devices/.../driver_override file
> > and the logic for matching.
> >
> > This is used by driverctl tool to do driver override.
> > https://gitlab.com/driverctl/driverctl
> >
> > Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
> > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> > ---
> > diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
> > index b1b548a21f91..e6d8fdac6d8b 100644
> > --- a/drivers/hv/vmbus_drv.c
> > +++ b/drivers/hv/vmbus_drv.c
> > @@ -498,6 +498,54 @@ static ssize_t device_show(struct device *dev,
> > }
> > static DEVICE_ATTR_RO(device);
> >
> > +static ssize_t driver_override_store(struct device *dev,
> > + struct device_attribute *attr,
> > + const char *buf, size_t count)
> > +{
> > + struct hv_device *hv_dev = device_to_hv_device(dev);
> > + char *driver_override, *old, *cp;
> > +
> > + /* We need to keep extra room for a newline */
> > + if (count >= (PAGE_SIZE - 1))
> > + return -EINVAL;
>
> Does 'count' actually have a relationship to PAGE_SIZE, or
> is PAGE_SIZE just used as an arbitrary size limit? I'm
> wondering what happens on ARM64 with a 64K page size,
> for example. If it's just arbitrary, coding such a constant
> would be better.
This comes from original code how sysfs works.
Sysfs uses PAGE_SIZE for string buffers on store. This code
snippet was cloned from PCI version of same thing.
> > +/*
> > + * Return a matching hv_vmbus_device_id pointer.
> > + * If there is no match, return NULL.
> > + */
> > +static const struct hv_vmbus_device_id *hv_vmbus_get_id(struct hv_driver *drv,
> > + struct hv_device *dev)
> > +{
> > + const uuid_le *guid = &dev->dev_type;
> > + const struct hv_vmbus_device_id *id;
> >
> > - return NULL;
> > + /* When driver_override is set, only bind to the matching driver */
> > + if (dev->driver_override && strcmp(dev->driver_override, drv->name))
> > + return NULL;
>
> This function needs to be covered by the device lock, so that
> dev->driver_override can't be set to NULL and the memory freed
> during the above 'if' statement. When called from vmbus_probe(),
> the device lock is held, so it's good. But when called from
> vmbus_match(), the device lock may not be held: consider the path
> __driver_attach() -> driver_match_device() -> vmbus_match().
The patch clones existing locking model from PCI.
So either both are broken, or somehow vmbus is behaving differently.
I will investigate.
next prev parent reply other threads:[~2018-08-13 19:57 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-10 23:05 [PATCH 0/5] Miscellaneous fixes/enhancements kys
2018-08-10 23:06 ` [PATCH 1/5] Tools: hv: Fix a bug in the key delete code kys
2018-08-10 23:06 ` [PATCH 2/5] vmbus: add driver_override support kys
2018-08-13 19:30 ` Michael Kelley (EOSG)
2018-08-13 19:40 ` gregkh
2018-08-13 19:56 ` Stephen Hemminger [this message]
2018-08-14 16:35 ` Stephen Hemminger
2018-08-14 19:13 ` Michael Kelley (EOSG)
2018-08-10 23:06 ` [PATCH 3/5] uio_hv_generic: increase size of receive and send buffers kys
2018-08-10 23:06 ` [PATCH 4/5] uio_hv_generic: drop #ifdef DEBUG kys
2018-08-10 23:06 ` [PATCH 5/5] Drivers: hv: vmbus: Fix synic per-cpu context initialization kys
2018-08-13 16:41 ` [PATCH 1/5] Tools: hv: Fix a bug in the key delete code Michael Kelley (EOSG)
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=20180813125657.739a1465@xeon-e3 \
--to=stephen@networkplumber.org \
--cc=Michael.H.Kelley@microsoft.com \
--cc=apw@canonical.com \
--cc=devel@linuxdriverproject.org \
--cc=gregkh@linuxfoundation.org \
--cc=jasowang@redhat.com \
--cc=kys@microsoft.com \
--cc=linux-kernel@vger.kernel.org \
--cc=olaf@aepfle.de \
--cc=sthemmin@microsoft.com \
--cc=vkuznets@redhat.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.