Displaying 20 results from an estimated 113 matches for "have_data".
2014 Apr 25
1
[PATCH] virtio-rng: support multiple virtio-rng devices
....c
index 2ce0e22..12e242b 100644
--- a/drivers/char/hw_random/virtio-rng.c
+++ b/drivers/char/hw_random/virtio-rng.c
@@ -25,88 +25,108 @@
#include <linux/virtio_rng.h>
#include <linux/module.h>
-static struct virtqueue *vq;
-static unsigned int data_avail;
-static DECLARE_COMPLETION(have_data);
-static bool busy;
+
+struct virtrng_info {
+ struct virtio_device *vdev;
+ struct hwrng hwrng;
+ struct virtqueue *vq;
+ unsigned int data_avail;
+ struct completion have_data;
+ bool busy;
+};
static void random_recv_done(struct virtqueue *vq)
{
+ struct virtrng_info *vi = vq->vdev->p...
2014 Apr 25
1
[PATCH] virtio-rng: support multiple virtio-rng devices
....c
index 2ce0e22..12e242b 100644
--- a/drivers/char/hw_random/virtio-rng.c
+++ b/drivers/char/hw_random/virtio-rng.c
@@ -25,88 +25,108 @@
#include <linux/virtio_rng.h>
#include <linux/module.h>
-static struct virtqueue *vq;
-static unsigned int data_avail;
-static DECLARE_COMPLETION(have_data);
-static bool busy;
+
+struct virtrng_info {
+ struct virtio_device *vdev;
+ struct hwrng hwrng;
+ struct virtqueue *vq;
+ unsigned int data_avail;
+ struct completion have_data;
+ bool busy;
+};
static void random_recv_done(struct virtqueue *vq)
{
+ struct virtrng_info *vi = vq->vdev->p...
2014 Aug 05
2
[PATCH] virtio-rng: complete have_data completion in removing device
When we try to hot-remove a busy virtio-rng device from QEMU monitor,
the device can't be hot-removed. Because virtio-rng driver hangs at
wait_for_completion_killable().
This patch fixed the hang by completing have_data completion before
unregistering a virtio-rng device.
Signed-off-by: Amos Kong <akong at redhat.com>
Cc: stable at vger.kernel.org
---
drivers/char/hw_random/virtio-rng.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/char/hw_random/virtio-rng.c b/drivers/char/hw_random/virtio-r...
2014 Aug 05
2
[PATCH] virtio-rng: complete have_data completion in removing device
When we try to hot-remove a busy virtio-rng device from QEMU monitor,
the device can't be hot-removed. Because virtio-rng driver hangs at
wait_for_completion_killable().
This patch fixed the hang by completing have_data completion before
unregistering a virtio-rng device.
Signed-off-by: Amos Kong <akong at redhat.com>
Cc: stable at vger.kernel.org
---
drivers/char/hw_random/virtio-rng.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/char/hw_random/virtio-rng.c b/drivers/char/hw_random/virtio-r...
2014 Sep 08
0
[PATCH] virtio-rng: complete have_data completion in removing device
...ng wrote:
> > > When we try to hot-remove a busy virtio-rng device from QEMU monitor,
> > > the device can't be hot-removed. Because virtio-rng driver hangs at
> > > wait_for_completion_killable().
> > >
> > > This patch fixed the hang by completing have_data completion before
> > > unregistering a virtio-rng device.
> >
> > Hi Amit,
> >
> > Before applying this patch, it's blocking insider wait_for_completion_killable()
> > Applied this patch, wait_for_completion_killable() returns 0,
&g...
2014 Aug 06
2
[PATCH] virtio-rng: complete have_data completion in removing device
...01:35:15AM +0800, Amos Kong wrote:
> > When we try to hot-remove a busy virtio-rng device from QEMU monitor,
> > the device can't be hot-removed. Because virtio-rng driver hangs at
> > wait_for_completion_killable().
> >
> > This patch fixed the hang by completing have_data completion before
> > unregistering a virtio-rng device.
>
> Hi Amit,
>
> Before applying this patch, it's blocking insider wait_for_completion_killable()
> Applied this patch, wait_for_completion_killable() returns 0,
> and vi->data_avail becom...
2014 Aug 06
2
[PATCH] virtio-rng: complete have_data completion in removing device
...01:35:15AM +0800, Amos Kong wrote:
> > When we try to hot-remove a busy virtio-rng device from QEMU monitor,
> > the device can't be hot-removed. Because virtio-rng driver hangs at
> > wait_for_completion_killable().
> >
> > This patch fixed the hang by completing have_data completion before
> > unregistering a virtio-rng device.
>
> Hi Amit,
>
> Before applying this patch, it's blocking insider wait_for_completion_killable()
> Applied this patch, wait_for_completion_killable() returns 0,
> and vi->data_avail becom...
2014 Aug 06
0
[PATCH] virtio-rng: complete have_data completion in removing device
On Wed, Aug 06, 2014 at 01:35:15AM +0800, Amos Kong wrote:
> When we try to hot-remove a busy virtio-rng device from QEMU monitor,
> the device can't be hot-removed. Because virtio-rng driver hangs at
> wait_for_completion_killable().
>
> This patch fixed the hang by completing have_data completion before
> unregistering a virtio-rng device.
Hi Amit,
Before applying this patch, it's blocking insider wait_for_completion_killable()
Applied this patch, wait_for_completion_killable() returns 0,
and vi->data_avail becomes 0, then rng_get_date() will retu...
2014 Sep 10
4
[PATCH v3 0/2] virtio-rng: fix hotunplug
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1121540
When we try to hot-unplugging a busy virtio-rng device, the device
can't be removed. And the reading process in guest gets stuck.
Those two patches fixed this issue by completing have_data completion
and preventing invalid reading.
Thanks for the help of Amit.
Cc: stable at vger.kernel.org
V2: reset data_avail (Amit)
adjust unregister order
V3: split patch, update commitlog
Amos Kong (2):
virtio-rng: fix stuck of hot-unplugging busy device
virtio-rng: skip reading when we...
2014 Sep 10
4
[PATCH v3 0/2] virtio-rng: fix hotunplug
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1121540
When we try to hot-unplugging a busy virtio-rng device, the device
can't be removed. And the reading process in guest gets stuck.
Those two patches fixed this issue by completing have_data completion
and preventing invalid reading.
Thanks for the help of Amit.
Cc: stable at vger.kernel.org
V2: reset data_avail (Amit)
adjust unregister order
V3: split patch, update commitlog
Amos Kong (2):
virtio-rng: fix stuck of hot-unplugging busy device
virtio-rng: skip reading when we...
2014 Sep 09
2
[PATCH v2] virtio-rng: fix stuck of hot-unplugging busy device
When we try to hot-remove a busy virtio-rng device from QEMU monitor,
the device can't be hot-removed. Because virtio-rng driver hangs at
wait_for_completion_killable().
This patch exits the waiting by completing have_data completion before
unregistering, resets data_avail to avoid the hwrng core use wrong
buffer bytes. Before real unregistering we should return -ENODEV for
reading.
When we hot-unplug the device, dd process in guest will exit.
$ dd if=/dev/hwrng of=/dev/null
dd: error reading ?/dev/hwrng?: No su...
2014 Sep 09
2
[PATCH v2] virtio-rng: fix stuck of hot-unplugging busy device
When we try to hot-remove a busy virtio-rng device from QEMU monitor,
the device can't be hot-removed. Because virtio-rng driver hangs at
wait_for_completion_killable().
This patch exits the waiting by completing have_data completion before
unregistering, resets data_avail to avoid the hwrng core use wrong
buffer bytes. Before real unregistering we should return -ENODEV for
reading.
When we hot-unplug the device, dd process in guest will exit.
$ dd if=/dev/hwrng of=/dev/null
dd: error reading ?/dev/hwrng?: No su...
2020 Aug 11
0
[PATCH v2] virtio-rng: return available data with O_NONBLOCK
...)
>>>> return -ENODEV;
>>>>
>>>> + /*
>>>> + * If the previous call was non-blocking, we may have got some
>>>> + * randomness already.
>>>> + */
>>>> + if (vi->busy && completion_done(&vi->have_data)) {
>>>> + unsigned int len;
>>>> +
>>>> + vi->busy = false;
>>>> + len = vi->data_avail > size ? size : vi->data_avail;
>>>> + vi->data_avail -= len;
>>
>> You don't need to modify data_avail. As busy is...
2019 Dec 12
4
[PATCH] virtio-blk: remove VIRTIO_BLK_F_SCSI support
...a segment with the scsi command block, and before
- * the normal inhdr we put the sense data and the inhdr with additional status
- * information.
- */
-#ifdef CONFIG_VIRTIO_BLK_SCSI
-static int virtblk_add_req_scsi(struct virtqueue *vq, struct virtblk_req *vbr,
- struct scatterlist *data_sg, bool have_data)
-{
- struct scatterlist hdr, status, cmd, sense, inhdr, *sgs[6];
- unsigned int num_out = 0, num_in = 0;
-
- sg_init_one(&hdr, &vbr->out_hdr, sizeof(vbr->out_hdr));
- sgs[num_out++] = &hdr;
- sg_init_one(&cmd, vbr->sreq.cmd, vbr->sreq.cmd_len);
- sgs[num_out++] = &c...
2007 Dec 21
0
[kvm-devel] [Virtio-for-kvm] [PATCH 2/13] [Mostly resend] virtio additions
...02110-1301 USA
+ */
+#include <linux/err.h>
+#include <linux/hw_random.h>
+#include <linux/scatterlist.h>
+#include <linux/spinlock.h>
+#include <linux/virtio.h>
+#include <linux/virtio_rng.h>
+
+static struct virtqueue *vq;
+static u32 random_data;
+static bool have_data;
+
+static bool random_recv_done(struct virtqueue *vq)
+{
+ have_data = true;
+
+ /* Don't suppress callbacks: there can't be any more since we
+ * have used up the only buffer. */
+ return true;
+}
+
+static void register_buffer(void)
+{
+ struct scatterlist sg;
+
+ sg_i...
2007 Dec 21
0
[kvm-devel] [Virtio-for-kvm] [PATCH 2/13] [Mostly resend] virtio additions
...02110-1301 USA
+ */
+#include <linux/err.h>
+#include <linux/hw_random.h>
+#include <linux/scatterlist.h>
+#include <linux/spinlock.h>
+#include <linux/virtio.h>
+#include <linux/virtio_rng.h>
+
+static struct virtqueue *vq;
+static u32 random_data;
+static bool have_data;
+
+static bool random_recv_done(struct virtqueue *vq)
+{
+ have_data = true;
+
+ /* Don't suppress callbacks: there can't be any more since we
+ * have used up the only buffer. */
+ return true;
+}
+
+static void register_buffer(void)
+{
+ struct scatterlist sg;
+
+ sg_i...
2014 Oct 10
5
[3.16 stable PATCH 0/2] virtio-rng: two backports to fix stuck
I received two mails about faile to apply patches to 3.16-stable tree:
FAILED: patch "[PATCH] virtio-rng: skip reading when we start to remove the device" failed to apply to 3.16-stable tree
FAILED: patch "[PATCH] virtio-rng: fix stuck of hot-unplugging busy device" failed to apply to 3.16-stable tree
Amit already backported two patches for 3.16-stable, then cherry-pick
of my
2014 Oct 10
5
[3.16 stable PATCH 0/2] virtio-rng: two backports to fix stuck
I received two mails about faile to apply patches to 3.16-stable tree:
FAILED: patch "[PATCH] virtio-rng: skip reading when we start to remove the device" failed to apply to 3.16-stable tree
FAILED: patch "[PATCH] virtio-rng: fix stuck of hot-unplugging busy device" failed to apply to 3.16-stable tree
Amit already backported two patches for 3.16-stable, then cherry-pick
of my
2020 Aug 11
3
[PATCH v3] virtio-rng: return available data with O_NONBLOCK
...w_random/virtio-rng.c
> +++ b/drivers/char/hw_random/virtio-rng.c
> @@ -65,7 +65,7 @@ static int virtio_read(struct hwrng *rng, void *buf, size_t size, bool wait)
> register_buffer(vi, buf, size);
> }
>
> - if (!wait)
> + if (!wait && !completion_done(&vi->have_data))
> return 0;
>
> ret = wait_for_completion_killable(&vi->have_data);
> @@ -74,7 +74,7 @@ static int virtio_read(struct hwrng *rng, void *buf, size_t size, bool wait)
>
> vi->busy = false;
>
> - return vi->data_avail;
> + return min_t(size_t, siz...
2020 Aug 11
3
[PATCH v3] virtio-rng: return available data with O_NONBLOCK
...w_random/virtio-rng.c
> +++ b/drivers/char/hw_random/virtio-rng.c
> @@ -65,7 +65,7 @@ static int virtio_read(struct hwrng *rng, void *buf, size_t size, bool wait)
> register_buffer(vi, buf, size);
> }
>
> - if (!wait)
> + if (!wait && !completion_done(&vi->have_data))
> return 0;
>
> ret = wait_for_completion_killable(&vi->have_data);
> @@ -74,7 +74,7 @@ static int virtio_read(struct hwrng *rng, void *buf, size_t size, bool wait)
>
> vi->busy = false;
>
> - return vi->data_avail;
> + return min_t(size_t, siz...