[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2] virtio-rng: return available data with O_NONBLOCK
From: |
Martin Wilck |
Subject: |
Re: [PATCH v2] virtio-rng: return available data with O_NONBLOCK |
Date: |
Tue, 11 Aug 2020 14:07:23 +0200 |
User-agent: |
Evolution 3.36.4 |
On Tue, 2020-08-11 at 07:26 -0400, Michael S. Tsirkin wrote:
> On Wed, Jul 15, 2020 at 03:32:55PM +0200, mwilck@suse.com wrote:
> > drivers/char/hw_random/virtio-rng.c | 14 ++++++++++++++
> > 1 file changed, 14 insertions(+)
> >
> > diff --git a/drivers/char/hw_random/virtio-rng.c
> > b/drivers/char/hw_random/virtio-rng.c
> > index 79a6e47b5fbc..984713b35892 100644
> > --- a/drivers/char/hw_random/virtio-rng.c
> > +++ b/drivers/char/hw_random/virtio-rng.c
> > @@ -59,6 +59,20 @@ static int virtio_read(struct hwrng *rng, void
> > *buf, size_t size, bool wait)
> > if (vi->hwrng_removed)
> > 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;
>
> I wonder what purpose does this line serve: busy is false
> which basically means data_avail is invalid, right?
> A following non blocking call will not enter here.
Well, I thought this is just how reading data normally works. But
you're right, the remainder will not be used. I can remove the line, or
reset data_avail to 0 at this point. What do you prefer?
Regards,
Martin
- Re: [PATCH v2] virtio-rng: return available data with O_NONBLOCK, (continued)
- Re: [PATCH v2] virtio-rng: return available data with O_NONBLOCK, Martin Wilck, 2020/08/11
- Re: [PATCH v2] virtio-rng: return available data with O_NONBLOCK, Laurent Vivier, 2020/08/11
- Re: [PATCH v2] virtio-rng: return available data with O_NONBLOCK, Martin Wilck, 2020/08/11
- Re: [PATCH v2] virtio-rng: return available data with O_NONBLOCK, Laurent Vivier, 2020/08/11
- Re: [PATCH v2] virtio-rng: return available data with O_NONBLOCK, Michael S. Tsirkin, 2020/08/11
- Re: [PATCH v2] virtio-rng: return available data with O_NONBLOCK, Laurent Vivier, 2020/08/11
- Re: [PATCH v2] virtio-rng: return available data with O_NONBLOCK, Michael S. Tsirkin, 2020/08/11
- Re: [PATCH v2] virtio-rng: return available data with O_NONBLOCK, Laurent Vivier, 2020/08/11
- Re: [PATCH v2] virtio-rng: return available data with O_NONBLOCK, Martin Wilck, 2020/08/11
Re: [PATCH v2] virtio-rng: return available data with O_NONBLOCK, Michael S. Tsirkin, 2020/08/11
- Re: [PATCH v2] virtio-rng: return available data with O_NONBLOCK,
Martin Wilck <=