From: Amit Shah <amit.shah@redhat.com>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: Amit Shah <amit.shah@redhat.com>,
Virtualization List <virtualization@lists.linux-foundation.org>
Subject: [PATCH 2/5] virtio: rng: allow tasks to be killed that are waiting for rng input
Date: Mon, 28 May 2012 12:18:40 +0530 [thread overview]
Message-ID: <f2cea033a2a2c5ea88f152e45345689cce7bdb2d.1338187342.git.amit.shah@redhat.com> (raw)
In-Reply-To: <cover.1338187342.git.amit.shah@redhat.com>
In-Reply-To: <cover.1338187342.git.amit.shah@redhat.com>
Use wait_for_completion_killable() instead of wait_for_completion() when
waiting for the host to send us entropy. Without this,
# cat /dev/hwrng
^C
just hangs.
Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
drivers/char/hw_random/virtio-rng.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/drivers/char/hw_random/virtio-rng.c b/drivers/char/hw_random/virtio-rng.c
index 723725b..c8a9350 100644
--- a/drivers/char/hw_random/virtio-rng.c
+++ b/drivers/char/hw_random/virtio-rng.c
@@ -55,6 +55,7 @@ static void register_buffer(u8 *buf, size_t size)
static int virtio_read(struct hwrng *rng, void *buf, size_t size, bool wait)
{
+ int ret;
if (!busy) {
busy = true;
@@ -65,7 +66,9 @@ static int virtio_read(struct hwrng *rng, void *buf, size_t size, bool wait)
if (!wait)
return 0;
- wait_for_completion(&have_data);
+ ret = wait_for_completion_killable(&have_data);
+ if (ret < 0)
+ return ret;
busy = false;
--
1.7.7.6
next prev parent reply other threads:[~2012-05-28 6:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-28 6:48 [PATCH 0/5] virtio: rng: fixes Amit Shah
2012-05-28 6:48 ` [PATCH 1/5] virtio ids: fix comment for virtio-rng Amit Shah
2012-05-28 6:48 ` Amit Shah [this message]
2012-05-28 6:48 ` [PATCH 3/5] virtio: rng: don't wait on host when module is going away Amit Shah
2012-05-28 6:48 ` [PATCH 4/5] virtio: rng: split out common code in probe / remove for s3/s4 ops Amit Shah
2012-05-28 6:48 ` [PATCH 5/5] virtio: rng: s3/s4 support Amit Shah
2012-05-28 8:24 ` [PATCH 0/5] virtio: rng: fixes Rusty Russell
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=f2cea033a2a2c5ea88f152e45345689cce7bdb2d.1338187342.git.amit.shah@redhat.com \
--to=amit.shah@redhat.com \
--cc=rusty@rustcorp.com.au \
--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).