From: "Michael S. Tsirkin" <mst@redhat.com>
To: Marcel Holtmann <marcel@holtmann.org>
Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>,
virtualization@lists.linux-foundation.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
Johan Hedberg <johan.hedberg@gmail.com>
Subject: Re: [PATCH] Bluetooth: virtio_bt: fix device removal
Date: Thu, 25 Nov 2021 16:23:12 -0500 [thread overview]
Message-ID: <20211125161434-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <C8D84EA4-E9A8-44CC-918F-57640A05C81D@holtmann.org>
On Thu, Nov 25, 2021 at 10:01:25PM +0100, Marcel Holtmann wrote:
> Hi Michael,
>
> >>> Device removal is clearly out of virtio spec: it attempts to remove
> >>> unused buffers from a VQ before invoking device reset. To fix, make
> >>> open/close NOPs and do all cleanup/setup in probe/remove.
> >>
> >> so the virtbt_{open,close} as NOP is not really what a driver is suppose
> >> to be doing. These are transport enable/disable callbacks from the BT
> >> Core towards the driver. It maps to a device being enabled/disabled by
> >> something like bluetoothd for example. So if disabled, I expect that no
> >> resources/queues are in use.
> >>
> >> Maybe I misunderstand the virtio spec in that regard, but I would like
> >> to keep this fundamental concept of a Bluetooth driver. It does work
> >> with all other transports like USB, SDIO, UART etc.
> >>
> >>> The cost here is a single skb wasted on an unused bt device - which
> >>> seems modest.
> >>
> >> There should be no buffer used if the device is powered off. We also don’t
> >> have any USB URBs in-flight if the transport is not active.
> >>
> >>> NB: with this fix in place driver still suffers from a race condition if
> >>> an interrupt triggers while device is being reset. Work on a fix for
> >>> that issue is in progress.
> >>
> >> In the virtbt_close() callback we should deactivate all interrupts.
> >>
> >
> > If you want to do that then device has to be reset on close,
> > and fully reinitialized on open.
> > Can you work on a patch like that?
> > Given I don't have the device such a rework is probably more
> > than I can undertake.
>
> so you mean move virtio_find_vqs() into virtbt_open() and del_vqs() into
> virtbt_close()?
And reset before del_vqs.
> Or is there are way to set up the queues without starting them?
>
> However I am failing to understand your initial concern, we do reset()
> before del_vqs() in virtbt_remove(). Should we be doing something different
> in virtbt_close() other than virtqueue_detach_unused_buf(). Why would I
> keep buffers attached if they are not used.
>
> Regards
>
> Marcel
They are not used at that point but until device is reset can use them.
Also, if you then proceed to open without a reset, and kick,
device will start by processing the original buffers, crashing
or corrupting memory.
--
MST
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
next prev parent reply other threads:[~2021-11-25 21:23 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-25 17:44 [PATCH] Bluetooth: virtio_bt: fix device removal Michael S. Tsirkin
[not found] ` <F52F65FE-6A07-486B-8E84-684ED85709E9@holtmann.org>
2021-11-25 20:44 ` Michael S. Tsirkin
[not found] ` <C8D84EA4-E9A8-44CC-918F-57640A05C81D@holtmann.org>
2021-11-25 21:23 ` Michael S. Tsirkin [this message]
[not found] ` <2B9668C9-427B-4D8B-A393-AAB5E50763C5@holtmann.org>
2021-11-26 1:02 ` Michael S. Tsirkin
2021-12-09 21:22 ` Michael S. Tsirkin
2021-12-13 10:44 ` Michael S. Tsirkin
2021-12-13 23:57 ` Michael S. Tsirkin
[not found] ` <FF8BA713-6DD2-485B-9ADC-02006126BC60@holtmann.org>
2022-01-14 20:12 ` Michael S. Tsirkin
2022-06-13 6:58 ` Michael S. Tsirkin
2022-06-28 4:59 ` Michael S. Tsirkin
2022-08-09 21:26 ` Igor Skalkin
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=20211125161434-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=johan.hedberg@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.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).