summaryrefslogtreecommitdiff
path: root/sound/virtio/virtio_card.c
diff options
context:
space:
mode:
authorAnton Yakovlev <anton.yakovlev@opensynergy.com>2021-03-02 17:47:03 +0100
committerTakashi Iwai <tiwai@suse.de>2021-03-07 09:07:27 +0100
commit9d45e514da88ff74fc24ffb34e7d6eb92576440b (patch)
treeead065f865cded879f5e93de8530f4dd39f6c330 /sound/virtio/virtio_card.c
parentde3a9980d8c34b2479173e809afa820473db676a (diff)
ALSA: virtio: handling control messages
The control queue can be used by different parts of the driver to send commands to the device. Control messages can be either synchronous or asynchronous. The lifetime of a message is controlled by a reference count. Introduce a module parameter to set the message completion timeout: msg_timeout_ms [=1000] Signed-off-by: Anton Yakovlev <anton.yakovlev@opensynergy.com> Link: https://lore.kernel.org/r/20210302164709.3142702-4-anton.yakovlev@opensynergy.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/virtio/virtio_card.c')
-rw-r--r--sound/virtio/virtio_card.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/sound/virtio/virtio_card.c b/sound/virtio/virtio_card.c
index 5a37056858e9..b757b2444078 100644
--- a/sound/virtio/virtio_card.c
+++ b/sound/virtio/virtio_card.c
@@ -11,6 +11,10 @@
#include "virtio_card.h"
+u32 virtsnd_msg_timeout_ms = MSEC_PER_SEC;
+module_param_named(msg_timeout_ms, virtsnd_msg_timeout_ms, uint, 0644);
+MODULE_PARM_DESC(msg_timeout_ms, "Message completion timeout in milliseconds");
+
static void virtsnd_remove(struct virtio_device *vdev);
/**
@@ -96,9 +100,11 @@ static int virtsnd_find_vqs(struct virtio_snd *snd)
{
struct virtio_device *vdev = snd->vdev;
static vq_callback_t *callbacks[VIRTIO_SND_VQ_MAX] = {
+ [VIRTIO_SND_VQ_CONTROL] = virtsnd_ctl_notify_cb,
[VIRTIO_SND_VQ_EVENT] = virtsnd_event_notify_cb
};
static const char *names[VIRTIO_SND_VQ_MAX] = {
+ [VIRTIO_SND_VQ_CONTROL] = "virtsnd-ctl",
[VIRTIO_SND_VQ_EVENT] = "virtsnd-event"
};
struct virtqueue *vqs[VIRTIO_SND_VQ_MAX] = { 0 };
@@ -226,6 +232,11 @@ static int virtsnd_validate(struct virtio_device *vdev)
return -EINVAL;
}
+ if (!virtsnd_msg_timeout_ms) {
+ dev_err(&vdev->dev, "msg_timeout_ms value cannot be zero\n");
+ return -EINVAL;
+ }
+
return 0;
}
@@ -247,6 +258,7 @@ static int virtsnd_probe(struct virtio_device *vdev)
return -ENOMEM;
snd->vdev = vdev;
+ INIT_LIST_HEAD(&snd->ctl_msgs);
vdev->priv = snd;
@@ -283,6 +295,7 @@ static void virtsnd_remove(struct virtio_device *vdev)
struct virtio_snd *snd = vdev->priv;
virtsnd_disable_event_vq(snd);
+ virtsnd_ctl_msg_cancel_all(snd);
if (snd->card)
snd_card_free(snd->card);