• Home
  • Raw
  • Download

Lines Matching refs:vi

40 	struct virtrng_info *vi = vq->vdev->priv;  in random_recv_done()  local
44 if (!virtqueue_get_buf(vi->vq, &len)) in random_recv_done()
47 smp_store_release(&vi->data_avail, len); in random_recv_done()
48 complete(&vi->have_data); in random_recv_done()
51 static void request_entropy(struct virtrng_info *vi) in request_entropy() argument
55 reinit_completion(&vi->have_data); in request_entropy()
56 vi->data_idx = 0; in request_entropy()
58 sg_init_one(&sg, vi->data, sizeof(vi->data)); in request_entropy()
61 virtqueue_add_inbuf(vi->vq, &sg, 1, vi->data, GFP_KERNEL); in request_entropy()
63 virtqueue_kick(vi->vq); in request_entropy()
66 static unsigned int copy_data(struct virtrng_info *vi, void *buf, in copy_data() argument
69 size = min_t(unsigned int, size, vi->data_avail); in copy_data()
70 memcpy(buf, vi->data + vi->data_idx, size); in copy_data()
71 vi->data_idx += size; in copy_data()
72 vi->data_avail -= size; in copy_data()
73 if (vi->data_avail == 0) in copy_data()
74 request_entropy(vi); in copy_data()
81 struct virtrng_info *vi = (struct virtrng_info *)rng->priv; in virtio_read() local
85 if (vi->hwrng_removed) in virtio_read()
91 if (smp_load_acquire(&vi->data_avail)) { in virtio_read()
92 chunk = copy_data(vi, buf, size); in virtio_read()
105 ret = wait_for_completion_killable(&vi->have_data); in virtio_read()
111 if (vi->data_avail == 0) in virtio_read()
114 chunk = copy_data(vi, buf + read, size); in virtio_read()
124 struct virtrng_info *vi = (struct virtrng_info *)rng->priv; in virtio_cleanup() local
126 complete(&vi->have_data); in virtio_cleanup()
132 struct virtrng_info *vi = NULL; in probe_common() local
134 vi = kzalloc(sizeof(struct virtrng_info), GFP_KERNEL); in probe_common()
135 if (!vi) in probe_common()
138 vi->index = index = ida_simple_get(&rng_index_ida, 0, 0, GFP_KERNEL); in probe_common()
143 sprintf(vi->name, "virtio_rng.%d", index); in probe_common()
144 init_completion(&vi->have_data); in probe_common()
146 vi->hwrng = (struct hwrng) { in probe_common()
149 .priv = (unsigned long)vi, in probe_common()
150 .name = vi->name, in probe_common()
152 vdev->priv = vi; in probe_common()
155 vi->vq = virtio_find_single_vq(vdev, random_recv_done, "input"); in probe_common()
156 if (IS_ERR(vi->vq)) { in probe_common()
157 err = PTR_ERR(vi->vq); in probe_common()
164 request_entropy(vi); in probe_common()
171 kfree(vi); in probe_common()
177 struct virtrng_info *vi = vdev->priv; in remove_common() local
179 vi->hwrng_removed = true; in remove_common()
180 vi->data_avail = 0; in remove_common()
181 vi->data_idx = 0; in remove_common()
182 complete(&vi->have_data); in remove_common()
183 if (vi->hwrng_register_done) in remove_common()
184 hwrng_unregister(&vi->hwrng); in remove_common()
187 ida_simple_remove(&rng_index_ida, vi->index); in remove_common()
188 kfree(vi); in remove_common()
203 struct virtrng_info *vi = vdev->priv; in virtrng_scan() local
206 err = hwrng_register(&vi->hwrng); in virtrng_scan()
208 vi->hwrng_register_done = true; in virtrng_scan()
224 struct virtrng_info *vi = vdev->priv; in virtrng_restore() local
231 vi->hwrng_removed = true; in virtrng_restore()
232 err = hwrng_register(&vi->hwrng); in virtrng_restore()
234 vi->hwrng_register_done = true; in virtrng_restore()
235 vi->hwrng_removed = false; in virtrng_restore()