Lines Matching refs:vrp

212 static struct rpmsg_endpoint *__rpmsg_create_ept(struct virtproc_info *vrp,  in __rpmsg_create_ept()  argument
218 struct device *dev = rpdev ? &rpdev->dev : &vrp->vdev->dev; in __rpmsg_create_ept()
220 if (!idr_pre_get(&vrp->endpoints, GFP_KERNEL)) in __rpmsg_create_ept()
239 mutex_lock(&vrp->endpoints_lock); in __rpmsg_create_ept()
242 err = idr_get_new_above(&vrp->endpoints, ept, request, &tmpaddr); in __rpmsg_create_ept()
256 mutex_unlock(&vrp->endpoints_lock); in __rpmsg_create_ept()
261 idr_remove(&vrp->endpoints, request); in __rpmsg_create_ept()
263 mutex_unlock(&vrp->endpoints_lock); in __rpmsg_create_ept()
311 return __rpmsg_create_ept(rpdev->vrp, rpdev, cb, priv, addr); in rpmsg_create_ept()
326 __rpmsg_destroy_ept(struct virtproc_info *vrp, struct rpmsg_endpoint *ept) in __rpmsg_destroy_ept() argument
329 mutex_lock(&vrp->endpoints_lock); in __rpmsg_destroy_ept()
330 idr_remove(&vrp->endpoints, ept->addr); in __rpmsg_destroy_ept()
331 mutex_unlock(&vrp->endpoints_lock); in __rpmsg_destroy_ept()
350 __rpmsg_destroy_ept(ept->rpdev->vrp, ept); in rpmsg_destroy_ept()
366 struct virtproc_info *vrp = rpdev->vrp; in rpmsg_dev_probe() local
389 virtio_has_feature(vrp->vdev, VIRTIO_RPMSG_F_NS)) { in rpmsg_dev_probe()
409 struct virtproc_info *vrp = rpdev->vrp; in rpmsg_dev_remove() local
414 virtio_has_feature(vrp->vdev, VIRTIO_RPMSG_F_NS)) { in rpmsg_dev_remove()
502 static struct rpmsg_channel *rpmsg_create_channel(struct virtproc_info *vrp, in rpmsg_create_channel() argument
506 struct device *tmp, *dev = &vrp->vdev->dev; in rpmsg_create_channel()
525 rpdev->vrp = vrp; in rpmsg_create_channel()
540 rpdev->dev.parent = &vrp->vdev->dev; in rpmsg_create_channel()
558 static int rpmsg_destroy_channel(struct virtproc_info *vrp, in rpmsg_destroy_channel() argument
561 struct virtio_device *vdev = vrp->vdev; in rpmsg_destroy_channel()
576 static void *get_a_tx_buf(struct virtproc_info *vrp) in get_a_tx_buf() argument
582 mutex_lock(&vrp->tx_lock); in get_a_tx_buf()
588 if (vrp->last_sbuf < RPMSG_NUM_BUFS / 2) in get_a_tx_buf()
589 ret = vrp->sbufs + RPMSG_BUF_SIZE * vrp->last_sbuf++; in get_a_tx_buf()
592 ret = virtqueue_get_buf(vrp->svq, &len); in get_a_tx_buf()
594 mutex_unlock(&vrp->tx_lock); in get_a_tx_buf()
615 static void rpmsg_upref_sleepers(struct virtproc_info *vrp) in rpmsg_upref_sleepers() argument
618 mutex_lock(&vrp->tx_lock); in rpmsg_upref_sleepers()
621 if (atomic_inc_return(&vrp->sleepers) == 1) in rpmsg_upref_sleepers()
623 virtqueue_enable_cb(vrp->svq); in rpmsg_upref_sleepers()
625 mutex_unlock(&vrp->tx_lock); in rpmsg_upref_sleepers()
642 static void rpmsg_downref_sleepers(struct virtproc_info *vrp) in rpmsg_downref_sleepers() argument
645 mutex_lock(&vrp->tx_lock); in rpmsg_downref_sleepers()
648 if (atomic_dec_and_test(&vrp->sleepers)) in rpmsg_downref_sleepers()
650 virtqueue_disable_cb(vrp->svq); in rpmsg_downref_sleepers()
652 mutex_unlock(&vrp->tx_lock); in rpmsg_downref_sleepers()
692 struct virtproc_info *vrp = rpdev->vrp; in rpmsg_send_offchannel_raw() local
719 msg = get_a_tx_buf(vrp); in rpmsg_send_offchannel_raw()
726 rpmsg_upref_sleepers(vrp); in rpmsg_send_offchannel_raw()
734 err = wait_event_interruptible_timeout(vrp->sendq, in rpmsg_send_offchannel_raw()
735 (msg = get_a_tx_buf(vrp)), in rpmsg_send_offchannel_raw()
739 rpmsg_downref_sleepers(vrp); in rpmsg_send_offchannel_raw()
763 mutex_lock(&vrp->tx_lock); in rpmsg_send_offchannel_raw()
766 err = virtqueue_add_buf(vrp->svq, &sg, 1, 0, msg, GFP_KERNEL); in rpmsg_send_offchannel_raw()
778 virtqueue_kick(vrp->svq); in rpmsg_send_offchannel_raw()
782 mutex_unlock(&vrp->tx_lock); in rpmsg_send_offchannel_raw()
794 struct virtproc_info *vrp = rvq->vdev->priv; in rpmsg_recv_done() local
821 mutex_lock(&vrp->endpoints_lock); in rpmsg_recv_done()
823 ept = idr_find(&vrp->endpoints, msg->dst); in rpmsg_recv_done()
829 mutex_unlock(&vrp->endpoints_lock); in rpmsg_recv_done()
850 err = virtqueue_add_buf(vrp->rvq, &sg, 0, 1, msg, GFP_KERNEL); in rpmsg_recv_done()
857 virtqueue_kick(vrp->rvq); in rpmsg_recv_done()
869 struct virtproc_info *vrp = svq->vdev->priv; in rpmsg_xmit_done() local
874 wake_up_interruptible(&vrp->sendq); in rpmsg_xmit_done()
884 struct virtproc_info *vrp = priv; in rpmsg_ns_cb() local
885 struct device *dev = &vrp->vdev->dev; in rpmsg_ns_cb()
920 ret = rpmsg_destroy_channel(vrp, &chinfo); in rpmsg_ns_cb()
924 newch = rpmsg_create_channel(vrp, &chinfo); in rpmsg_ns_cb()
935 struct virtproc_info *vrp; in rpmsg_probe() local
939 vrp = kzalloc(sizeof(*vrp), GFP_KERNEL); in rpmsg_probe()
940 if (!vrp) in rpmsg_probe()
943 vrp->vdev = vdev; in rpmsg_probe()
945 idr_init(&vrp->endpoints); in rpmsg_probe()
946 mutex_init(&vrp->endpoints_lock); in rpmsg_probe()
947 mutex_init(&vrp->tx_lock); in rpmsg_probe()
948 init_waitqueue_head(&vrp->sendq); in rpmsg_probe()
955 vrp->rvq = vqs[0]; in rpmsg_probe()
956 vrp->svq = vqs[1]; in rpmsg_probe()
960 &vrp->bufs_dma, GFP_KERNEL); in rpmsg_probe()
965 (unsigned long long)vrp->bufs_dma); in rpmsg_probe()
968 vrp->rbufs = bufs_va; in rpmsg_probe()
971 vrp->sbufs = bufs_va + RPMSG_TOTAL_BUF_SPACE / 2; in rpmsg_probe()
976 void *cpu_addr = vrp->rbufs + i * RPMSG_BUF_SIZE; in rpmsg_probe()
980 err = virtqueue_add_buf(vrp->rvq, &sg, 0, 1, cpu_addr, in rpmsg_probe()
986 virtqueue_disable_cb(vrp->svq); in rpmsg_probe()
988 vdev->priv = vrp; in rpmsg_probe()
993 vrp->ns_ept = __rpmsg_create_ept(vrp, NULL, rpmsg_ns_cb, in rpmsg_probe()
994 vrp, RPMSG_NS_ADDR); in rpmsg_probe()
995 if (!vrp->ns_ept) { in rpmsg_probe()
1003 virtqueue_kick(vrp->rvq); in rpmsg_probe()
1011 vrp->bufs_dma); in rpmsg_probe()
1013 vdev->config->del_vqs(vrp->vdev); in rpmsg_probe()
1015 kfree(vrp); in rpmsg_probe()
1028 struct virtproc_info *vrp = vdev->priv; in rpmsg_remove() local
1037 if (vrp->ns_ept) in rpmsg_remove()
1038 __rpmsg_destroy_ept(vrp, vrp->ns_ept); in rpmsg_remove()
1040 idr_remove_all(&vrp->endpoints); in rpmsg_remove()
1041 idr_destroy(&vrp->endpoints); in rpmsg_remove()
1043 vdev->config->del_vqs(vrp->vdev); in rpmsg_remove()
1046 vrp->rbufs, vrp->bufs_dma); in rpmsg_remove()
1048 kfree(vrp); in rpmsg_remove()