summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2021-06-22 10:26:10 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2021-06-25 09:30:33 +0200
commit774edc56bf15143050d1002cf5d7fd89ce00135d (patch)
tree7ae963c432b3903ef291191216774d15cfdc43e8
parent30a5e60e7d23fba9c5c12ff93c022a6c236dd01f (diff)
downloadbarebox-774edc56bf15143050d1002cf5d7fd89ce00135d.tar.gz
barebox-774edc56bf15143050d1002cf5d7fd89ce00135d.tar.xz
input: virtio: poll from poller, not bthread
With the upcoming move of bthreads to be scheduled only in command context, long running tasks (i.e. bareDOOM) may no longer process VirtIO input in a timely manner. Move the input polling into a poller, so input can once again be processed between frames. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210622082617.18011-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--drivers/input/Kconfig3
-rw-r--r--drivers/input/virtio_input.c45
2 files changed, 22 insertions, 26 deletions
diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig
index ff3e9d33f6..ba9fa25a3d 100644
--- a/drivers/input/Kconfig
+++ b/drivers/input/Kconfig
@@ -73,7 +73,8 @@ config INPUT_SPECIALKEYS
config VIRTIO_INPUT
bool "Virtio input driver"
- depends on VIRTIO && BTHREAD
+ depends on VIRTIO
+ select POLLER
select INPUT
help
This driver supports virtio keyboard input devices.
diff --git a/drivers/input/virtio_input.c b/drivers/input/virtio_input.c
index 9c2e4d923f..b354933209 100644
--- a/drivers/input/virtio_input.c
+++ b/drivers/input/virtio_input.c
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
#include <common.h>
-#include <bthread.h>
+#include <poller.h>
#include <linux/virtio.h>
#include <linux/virtio_config.h>
#include <linux/virtio_ring.h>
@@ -17,7 +17,7 @@ struct virtio_input {
struct virtio_device *vdev;
struct virtqueue *evt, *sts;
struct virtio_input_event evts[64];
- struct bthread *bthread;
+ struct poller_struct poller;
struct sound_card beeper;
unsigned long sndbit[BITS_TO_LONGS(SND_CNT)];
};
@@ -100,21 +100,17 @@ static int virtinput_recv_status(struct virtio_input *vi)
return i;
}
-static int virtinput_poll_vqs(void *_vi)
+static void virtinput_poll_vqs(struct poller_struct *poller)
{
- struct virtio_input *vi = _vi;
+ struct virtio_input *vi = container_of(poller, struct virtio_input, poller);
- while (!bthread_should_stop()) {
- int bufs = 0;
+ int bufs = 0;
- bufs += virtinput_recv_events(vi);
- bufs += virtinput_recv_status(vi);
+ bufs += virtinput_recv_events(vi);
+ bufs += virtinput_recv_status(vi);
- if (bufs)
- virtqueue_kick(vi->evt);
- }
-
- return 0;
+ if (bufs)
+ virtqueue_kick(vi->evt);
}
static u8 virtinput_cfg_select(struct virtio_input *vi,
@@ -213,6 +209,8 @@ static int virtinput_probe(struct virtio_device *vdev)
name, min(size, sizeof(name)));
name[size] = '\0';
+ dev_info(&vdev->dev, "'%s' detected\n", name);
+
virtinput_cfg_bits(vi, VIRTIO_INPUT_CFG_EV_BITS, EV_SND,
vi->sndbit, SND_CNT);
@@ -224,12 +222,12 @@ static int virtinput_probe(struct virtio_device *vdev)
virtinput_fill_evt(vi);
- vi->bthread = bthread_run(virtinput_poll_vqs, vi,
- "%s/input0", dev_name(&vdev->dev));
- if (!vi->bthread) {
- err = -ENOMEM;
- goto err_bthread_run;
- }
+ vi->poller.func = virtinput_poll_vqs;
+ snprintf(name, sizeof(name), "%s/input0", dev_name(&vdev->dev));
+
+ err = poller_register(&vi->poller, name);
+ if (err)
+ goto err_poller_register;
if (IS_ENABLED(CONFIG_SOUND) &&
(vi->sndbit[0] & (BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE)))) {
@@ -246,12 +244,10 @@ static int virtinput_probe(struct virtio_device *vdev)
dev_info(&vdev->dev, "bell registered\n");
}
- dev_info(&vdev->dev, "'%s' probed\n", name);
-
return 0;
-err_bthread_run:
- bthread_free(vi->bthread);
+err_poller_register:
+ input_device_unregister(&vi->idev);
err_input_register:
vdev->config->del_vqs(vdev);
err_init_vq:
@@ -263,8 +259,7 @@ static void virtinput_remove(struct virtio_device *vdev)
{
struct virtio_input *vi = vdev->priv;
- bthread_stop(vi->bthread);
- bthread_free(vi->bthread);
+ poller_unregister(&vi->poller);
vdev->config->reset(vdev);
vdev->config->del_vqs(vdev);