[PATCH] Bluetooth: hci_vhci: Report write readiness with queued input

From: raoxu

Date: Thu Nov 12 2026 - 03:52:40 EST


From: Xu Rao <raoxu@xxxxxxxxxxxxx>

vhci_poll() returns only EPOLLIN and EPOLLRDNORM when readq is nonempty,
dropping the write readiness bits it reports when the queue is empty.
However, vhci_write() does not wait for readq to drain: incoming frames
are handled independently by vhci_get_user().

As a result, userspace polling only for write readiness can time out or
remain asleep while input is queued, even though it could submit a
frame. Applications that drain input before waiting to write avoid this
case.

Always include EPOLLOUT and EPOLLWRNORM in the readiness mask, and add
EPOLLIN and EPOLLRDNORM when readq contains data. Keep the existing wait
queue registration and empty-queue behavior unchanged.

Signed-off-by: Xu Rao <raoxu@xxxxxxxxxxxxx>
---
drivers/bluetooth/hci_vhci.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c
index 771ad9893c44..0b427c65ce59 100644
--- a/drivers/bluetooth/hci_vhci.c
+++ b/drivers/bluetooth/hci_vhci.c
@@ -636,13 +636,14 @@ static ssize_t vhci_write(struct kiocb *iocb, struct iov_iter *from)
static __poll_t vhci_poll(struct file *file, poll_table *wait)
{
struct vhci_data *data = file->private_data;
+ __poll_t mask = EPOLLOUT | EPOLLWRNORM;

poll_wait(file, &data->read_wait, wait);

if (!skb_queue_empty(&data->readq))
- return EPOLLIN | EPOLLRDNORM;
+ mask |= EPOLLIN | EPOLLRDNORM;

- return EPOLLOUT | EPOLLWRNORM;
+ return mask;
}

static void vhci_open_timeout(struct work_struct *work)
--
2.50.1