From: "Michael S. Tsirkin" <mst@redhat.com>
To: Eugenio Perez Martin <eperezma@redhat.com>
Cc: kvm@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org,
virtualization@lists.linux-foundation.org
Subject: Re: [PATCH] vdpa: reject F_ENABLE_AFTER_DRIVER_OK if backend does not support it
Date: Tue, 4 Jul 2023 06:38:35 -0400 [thread overview]
Message-ID: <20230704063646-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <CAJaqyWf2F_yBLBjj1RiPeJ92_zfq8BSMz8Pak2Vg6QinN8jS1Q@mail.gmail.com>
On Tue, Jul 04, 2023 at 12:25:32PM +0200, Eugenio Perez Martin wrote:
> On Mon, Jul 3, 2023 at 4:52 PM Michael S. Tsirkin <mst@redhat.com> wrote:
> >
> > On Mon, Jul 03, 2023 at 04:22:18PM +0200, Eugenio Pérez wrote:
> > > With the current code it is accepted as long as userland send it.
> > >
> > > Although userland should not set a feature flag that has not been
> > > offered to it with VHOST_GET_BACKEND_FEATURES, the current code will not
> > > complain for it.
> > >
> > > Since there is no specific reason for any parent to reject that backend
> > > feature bit when it has been proposed, let's control it at vdpa frontend
> > > level. Future patches may move this control to the parent driver.
> > >
> > > Fixes: 967800d2d52e ("vdpa: accept VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK backend feature")
> > > Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
> >
> > Please do send v3. And again, I don't want to send "after driver ok" hack
> > upstream at all, I merged it in next just to give it some testing.
> > We want RING_ACCESS_AFTER_KICK or some such.
> >
>
> Current devices do not support that semantic.
Which devices specifically access the ring after DRIVER_OK but before
a kick?
> My plan was to convert
> it in vp_vdpa if needed, and reuse the current vdpa ops. Sorry if I
> was not explicit enough.
>
> The only solution I can see to that is to trap & emulate in the vdpa
> (parent?) driver, as talked in virtio-comment. But that complicates
> the architecture:
> * Offer VHOST_BACKEND_F_RING_ACCESS_AFTER_KICK
> * Store vq enable state separately, at
> vdpa->config->set_vq_ready(true), but not transmit that enable to hw
> * Store the doorbell state separately, but do not configure it to the
> device directly.
>
> But how to recover if the device cannot configure them at kick time,
> for example?
>
> Maybe we can just fail if the parent driver does not support enabling
> the vq after DRIVER_OK? That way no new feature flag is needed.
>
> Thanks!
>
> >
> > > ---
> > > Sent with Fixes: tag pointing to git.kernel.org/pub/scm/linux/kernel/git/mst
> > > commit. Please let me know if I should send a v3 of [1] instead.
> > >
> > > [1] https://lore.kernel.org/lkml/20230609121244-mutt-send-email-mst@kernel.org/T/
> > > ---
> > > drivers/vhost/vdpa.c | 7 +++++--
> > > 1 file changed, 5 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
> > > index e1abf29fed5b..a7e554352351 100644
> > > --- a/drivers/vhost/vdpa.c
> > > +++ b/drivers/vhost/vdpa.c
> > > @@ -681,18 +681,21 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep,
> > > {
> > > struct vhost_vdpa *v = filep->private_data;
> > > struct vhost_dev *d = &v->vdev;
> > > + const struct vdpa_config_ops *ops = v->vdpa->config;
> > > void __user *argp = (void __user *)arg;
> > > u64 __user *featurep = argp;
> > > - u64 features;
> > > + u64 features, parent_features = 0;
> > > long r = 0;
> > >
> > > if (cmd == VHOST_SET_BACKEND_FEATURES) {
> > > if (copy_from_user(&features, featurep, sizeof(features)))
> > > return -EFAULT;
> > > + if (ops->get_backend_features)
> > > + parent_features = ops->get_backend_features(v->vdpa);
> > > if (features & ~(VHOST_VDPA_BACKEND_FEATURES |
> > > BIT_ULL(VHOST_BACKEND_F_SUSPEND) |
> > > BIT_ULL(VHOST_BACKEND_F_RESUME) |
> > > - BIT_ULL(VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK)))
> > > + parent_features))
> > > return -EOPNOTSUPP;
> > > if ((features & BIT_ULL(VHOST_BACKEND_F_SUSPEND)) &&
> > > !vhost_vdpa_can_suspend(v))
> > > --
> > > 2.39.3
> >
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
next prev parent reply other threads:[~2023-07-04 10:38 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20230703142218.362549-1-eperezma@redhat.com>
2023-07-03 14:52 ` [PATCH] vdpa: reject F_ENABLE_AFTER_DRIVER_OK if backend does not support it Michael S. Tsirkin
[not found] ` <CAJaqyWf2F_yBLBjj1RiPeJ92_zfq8BSMz8Pak2Vg6QinN8jS1Q@mail.gmail.com>
2023-07-04 10:38 ` Michael S. Tsirkin [this message]
[not found] ` <CAJaqyWfdPpkD5pY4tfzQdOscLBcrDBhBqzWjMbY_ZKsoyiqGdA@mail.gmail.com>
2023-07-04 15:45 ` Michael S. Tsirkin
2023-07-05 7:49 ` Jason Wang
2023-07-05 8:41 ` Michael S. Tsirkin
2023-07-06 1:55 ` Jason Wang
[not found] ` <CAJaqyWcqNkzJXxsoz_Lk_X0CvNW24Ay2Ki6q02EB8iR=qpwsfg@mail.gmail.com>
2023-07-06 7:55 ` Jason Wang
2023-07-06 8:03 ` Jason Wang
[not found] ` <CAJaqyWdv_DFdxghHQPoUE4KZ7pqmaR__=JyHFONRuard3KBtSQ@mail.gmail.com>
2023-07-07 7:57 ` Jason Wang
[not found] ` <CAJaqyWd0QC6x9WHBT0x9beZyC8ZrF2y=d9HvmT0+05RtGc8_og@mail.gmail.com>
2023-07-06 0:07 ` Shannon Nelson via Virtualization
2023-07-06 6:07 ` Michael S. Tsirkin
[not found] ` <CAJaqyWeCv6HhWni=c7xySTCyj9WAFfM3JhWL2e_mDKjHp3wPzQ@mail.gmail.com>
2023-07-06 6:39 ` Michael S. Tsirkin
2023-07-19 22:20 ` Si-Wei Liu
2023-07-19 22:26 ` Michael S. Tsirkin
2023-07-20 0:03 ` Si-Wei Liu
2023-07-05 7:55 ` Jason Wang
2023-07-05 8:42 ` Michael S. Tsirkin
2023-07-06 1:56 ` Jason Wang
2023-07-06 6:05 ` Michael S. Tsirkin
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=20230704063646-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=eperezma@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=virtualization@lists.linux-foundation.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).