Lines Matching refs:chan
122 struct virtio_chan *chan = client->trans; in p9_virtio_close() local
125 if (chan) in p9_virtio_close()
126 chan->inuse = false; in p9_virtio_close()
145 struct virtio_chan *chan = vq->vdev->priv; in req_done() local
154 spin_lock_irqsave(&chan->lock, flags); in req_done()
155 rc = virtqueue_get_buf(chan->vq, &len); in req_done()
157 spin_unlock_irqrestore(&chan->lock, flags); in req_done()
160 chan->ring_bufs_avail = 1; in req_done()
161 spin_unlock_irqrestore(&chan->lock, flags); in req_done()
163 wake_up(chan->vc_wq); in req_done()
166 req = p9_tag_lookup(chan->client, rc->tag); in req_done()
167 p9_client_cb(chan->client, req, REQ_STATUS_RCVD); in req_done()
266 struct virtio_chan *chan = client->trans; in p9_virtio_request() local
273 spin_lock_irqsave(&chan->lock, flags); in p9_virtio_request()
277 out = pack_sg_list(chan->sg, 0, in p9_virtio_request()
280 sgs[out_sgs++] = chan->sg; in p9_virtio_request()
282 in = pack_sg_list(chan->sg, out, in p9_virtio_request()
285 sgs[out_sgs + in_sgs++] = chan->sg + out; in p9_virtio_request()
287 err = virtqueue_add_sgs(chan->vq, sgs, out_sgs, in_sgs, req->tc, in p9_virtio_request()
291 chan->ring_bufs_avail = 0; in p9_virtio_request()
292 spin_unlock_irqrestore(&chan->lock, flags); in p9_virtio_request()
293 err = wait_event_interruptible(*chan->vc_wq, in p9_virtio_request()
294 chan->ring_bufs_avail); in p9_virtio_request()
301 spin_unlock_irqrestore(&chan->lock, flags); in p9_virtio_request()
307 virtqueue_kick(chan->vq); in p9_virtio_request()
308 spin_unlock_irqrestore(&chan->lock, flags); in p9_virtio_request()
314 static int p9_get_mapped_pages(struct virtio_chan *chan, in p9_get_mapped_pages() argument
333 if (atomic_read(&vp_pinned) >= chan->p9_max_pages) { in p9_get_mapped_pages()
335 (atomic_read(&vp_pinned) < chan->p9_max_pages)); in p9_get_mapped_pages()
404 struct virtio_chan *chan = client->trans; in p9_virtio_zc_request() local
412 int n = p9_get_mapped_pages(chan, &out_pages, uodata, in p9_virtio_zc_request()
423 int n = p9_get_mapped_pages(chan, &in_pages, uidata, in p9_virtio_zc_request()
436 spin_lock_irqsave(&chan->lock, flags); in p9_virtio_zc_request()
441 out = pack_sg_list(chan->sg, 0, in p9_virtio_zc_request()
445 sgs[out_sgs++] = chan->sg; in p9_virtio_zc_request()
448 sgs[out_sgs++] = chan->sg + out; in p9_virtio_zc_request()
449 out += pack_sg_list_p(chan->sg, out, VIRTQUEUE_NUM, in p9_virtio_zc_request()
460 in = pack_sg_list(chan->sg, out, in p9_virtio_zc_request()
463 sgs[out_sgs + in_sgs++] = chan->sg + out; in p9_virtio_zc_request()
466 sgs[out_sgs + in_sgs++] = chan->sg + out + in; in p9_virtio_zc_request()
467 in += pack_sg_list_p(chan->sg, out + in, VIRTQUEUE_NUM, in p9_virtio_zc_request()
472 err = virtqueue_add_sgs(chan->vq, sgs, out_sgs, in_sgs, req->tc, in p9_virtio_zc_request()
476 chan->ring_bufs_avail = 0; in p9_virtio_zc_request()
477 spin_unlock_irqrestore(&chan->lock, flags); in p9_virtio_zc_request()
478 err = wait_event_interruptible(*chan->vc_wq, in p9_virtio_zc_request()
479 chan->ring_bufs_avail); in p9_virtio_zc_request()
486 spin_unlock_irqrestore(&chan->lock, flags); in p9_virtio_zc_request()
493 virtqueue_kick(chan->vq); in p9_virtio_zc_request()
494 spin_unlock_irqrestore(&chan->lock, flags); in p9_virtio_zc_request()
522 struct virtio_chan *chan; in p9_mount_tag_show() local
526 chan = vdev->priv; in p9_mount_tag_show()
528 memcpy(buf, chan->tag, chan->tag_len); in p9_mount_tag_show()
529 buf[chan->tag_len] = 0; in p9_mount_tag_show()
531 return chan->tag_len + 1; in p9_mount_tag_show()
549 struct virtio_chan *chan; in p9_virtio_probe() local
557 chan = kmalloc(sizeof(struct virtio_chan), GFP_KERNEL); in p9_virtio_probe()
558 if (!chan) { in p9_virtio_probe()
564 chan->vdev = vdev; in p9_virtio_probe()
567 chan->vq = virtio_find_single_vq(vdev, req_done, "requests"); in p9_virtio_probe()
568 if (IS_ERR(chan->vq)) { in p9_virtio_probe()
569 err = PTR_ERR(chan->vq); in p9_virtio_probe()
572 chan->vq->vdev->priv = chan; in p9_virtio_probe()
573 spin_lock_init(&chan->lock); in p9_virtio_probe()
575 sg_init_table(chan->sg, VIRTQUEUE_NUM); in p9_virtio_probe()
577 chan->inuse = false; in p9_virtio_probe()
592 chan->tag = tag; in p9_virtio_probe()
593 chan->tag_len = tag_len; in p9_virtio_probe()
598 chan->vc_wq = kmalloc(sizeof(wait_queue_head_t), GFP_KERNEL); in p9_virtio_probe()
599 if (!chan->vc_wq) { in p9_virtio_probe()
603 init_waitqueue_head(chan->vc_wq); in p9_virtio_probe()
604 chan->ring_bufs_avail = 1; in p9_virtio_probe()
606 chan->p9_max_pages = nr_free_buffer_pages()/4; in p9_virtio_probe()
611 list_add_tail(&chan->chan_list, &virtio_chan_list); in p9_virtio_probe()
623 kfree(chan); in p9_virtio_probe()
646 struct virtio_chan *chan; in p9_virtio_create() local
651 list_for_each_entry(chan, &virtio_chan_list, chan_list) { in p9_virtio_create()
652 if (!strncmp(devname, chan->tag, chan->tag_len) && in p9_virtio_create()
653 strlen(devname) == chan->tag_len) { in p9_virtio_create()
654 if (!chan->inuse) { in p9_virtio_create()
655 chan->inuse = true; in p9_virtio_create()
669 client->trans = (void *)chan; in p9_virtio_create()
671 chan->client = client; in p9_virtio_create()
684 struct virtio_chan *chan = vdev->priv; in p9_virtio_remove() local
690 list_del(&chan->chan_list); in p9_virtio_remove()
694 while (chan->inuse) { in p9_virtio_remove()
712 kfree(chan->tag); in p9_virtio_remove()
713 kfree(chan->vc_wq); in p9_virtio_remove()
714 kfree(chan); in p9_virtio_remove()