Lines Matching defs:vcdev

75 static inline unsigned long *indicators(struct virtio_ccw_device *vcdev)
77 return &vcdev->dma_area->indicators;
80 static inline unsigned long *indicators2(struct virtio_ccw_device *vcdev)
82 return &vcdev->dma_area->indicators2;
296 static void virtio_ccw_drop_indicators(struct virtio_ccw_device *vcdev)
300 if (!vcdev->airq_info)
302 list_for_each_entry(info, &vcdev->virtqueues, node)
303 drop_airq_indicator(info->vq, vcdev->airq_info);
306 static int doing_io(struct virtio_ccw_device *vcdev, __u32 flag)
311 spin_lock_irqsave(get_ccwdev_lock(vcdev->cdev), flags);
312 if (vcdev->err)
315 ret = vcdev->curr_io & flag;
316 spin_unlock_irqrestore(get_ccwdev_lock(vcdev->cdev), flags);
320 static int ccw_io_helper(struct virtio_ccw_device *vcdev,
327 mutex_lock(&vcdev->io_lock);
329 spin_lock_irqsave(get_ccwdev_lock(vcdev->cdev), flags);
330 ret = ccw_device_start(vcdev->cdev, ccw, intparm, 0, 0);
332 if (!vcdev->curr_io)
333 vcdev->err = 0;
334 vcdev->curr_io |= flag;
336 spin_unlock_irqrestore(get_ccwdev_lock(vcdev->cdev), flags);
339 wait_event(vcdev->wait_q, doing_io(vcdev, flag) == 0);
340 ret = ret ? ret : vcdev->err;
341 mutex_unlock(&vcdev->io_lock);
345 static void virtio_ccw_drop_indicator(struct virtio_ccw_device *vcdev,
351 struct airq_info *airq_info = vcdev->airq_info;
353 if (vcdev->is_thinint) {
354 thinint_area = ccw_device_dma_zalloc(vcdev->cdev,
366 indicatorp = ccw_device_dma_zalloc(vcdev->cdev,
367 sizeof(indicators(vcdev)));
372 ccw->count = sizeof(indicators(vcdev));
376 *indicators(vcdev) = 0;
378 ret = ccw_io_helper(vcdev, ccw,
379 vcdev->is_thinint ?
383 dev_info(&vcdev->cdev->dev,
385 else if (vcdev->is_thinint)
386 virtio_ccw_drop_indicators(vcdev);
387 ccw_device_dma_free(vcdev->cdev, indicatorp, sizeof(indicators(vcdev)));
388 ccw_device_dma_free(vcdev->cdev, thinint_area, sizeof(*thinint_area));
419 struct virtio_ccw_device *vcdev;
422 vcdev = to_vc_device(info->vq->vdev);
423 ccw_device_get_schid(vcdev->cdev, &schid);
430 static int virtio_ccw_read_vq_conf(struct virtio_ccw_device *vcdev,
435 vcdev->dma_area->config_block.index = index;
439 ccw->cda = (__u32)(unsigned long)(&vcdev->dma_area->config_block);
440 ret = ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_READ_VQ_CONF);
443 return vcdev->dma_area->config_block.num ?: -ENOENT;
448 struct virtio_ccw_device *vcdev = to_vc_device(vq->vdev);
455 spin_lock_irqsave(&vcdev->lock, flags);
457 spin_unlock_irqrestore(&vcdev->lock, flags);
460 if (vcdev->revision == 0) {
477 ret = ccw_io_helper(vcdev, ccw,
488 ccw_device_dma_free(vcdev->cdev, info->info_block,
497 struct virtio_ccw_device *vcdev = to_vc_device(vdev);
499 ccw = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*ccw));
503 virtio_ccw_drop_indicator(vcdev, ccw);
508 ccw_device_dma_free(vcdev->cdev, ccw, sizeof(*ccw));
516 struct virtio_ccw_device *vcdev = to_vc_device(vdev);
527 dev_warn(&vcdev->cdev->dev, "no info\n");
531 info->info_block = ccw_device_dma_zalloc(vcdev->cdev,
534 dev_warn(&vcdev->cdev->dev, "no info block\n");
538 info->num = virtio_ccw_read_vq_conf(vcdev, ccw, i);
543 may_reduce = vcdev->revision > 0;
550 dev_warn(&vcdev->cdev->dev, "no vq\n");
559 if (vcdev->revision == 0) {
576 err = ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_SET_VQ | i);
578 dev_warn(&vcdev->cdev->dev, "SET_VQ failed\n");
586 spin_lock_irqsave(&vcdev->lock, flags);
587 list_add(&info->node, &vcdev->virtqueues);
588 spin_unlock_irqrestore(&vcdev->lock, flags);
596 ccw_device_dma_free(vcdev->cdev, info->info_block,
603 static int virtio_ccw_register_adapter_ind(struct virtio_ccw_device *vcdev,
611 thinint_area = ccw_device_dma_zalloc(vcdev->cdev,
620 &vcdev->airq_info);
625 info = vcdev->airq_info;
633 ret = ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_SET_IND_ADAPTER);
643 dev_warn(&vcdev->cdev->dev,
645 virtio_ccw_drop_indicators(vcdev);
648 ccw_device_dma_free(vcdev->cdev, thinint_area, sizeof(*thinint_area));
659 struct virtio_ccw_device *vcdev = to_vc_device(vdev);
664 ccw = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*ccw));
688 indicatorp = ccw_device_dma_zalloc(vcdev->cdev,
689 sizeof(indicators(vcdev)));
692 *indicatorp = (unsigned long) indicators(vcdev);
693 if (vcdev->is_thinint) {
694 ret = virtio_ccw_register_adapter_ind(vcdev, vqs, nvqs, ccw);
697 vcdev->is_thinint = false;
699 if (!vcdev->is_thinint) {
701 *indicators(vcdev) = 0;
704 ccw->count = sizeof(indicators(vcdev));
706 ret = ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_SET_IND);
711 *indicatorp = (unsigned long) indicators2(vcdev);
712 *indicators2(vcdev) = 0;
715 ccw->count = sizeof(indicators2(vcdev));
717 ret = ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_SET_CONF_IND);
722 ccw_device_dma_free(vcdev->cdev, indicatorp,
723 sizeof(indicators(vcdev)));
724 ccw_device_dma_free(vcdev->cdev, ccw, sizeof(*ccw));
728 ccw_device_dma_free(vcdev->cdev, indicatorp,
729 sizeof(indicators(vcdev)));
730 ccw_device_dma_free(vcdev->cdev, ccw, sizeof(*ccw));
737 struct virtio_ccw_device *vcdev = to_vc_device(vdev);
740 ccw = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*ccw));
745 vcdev->dma_area->status = 0;
752 ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_RESET);
753 ccw_device_dma_free(vcdev->cdev, ccw, sizeof(*ccw));
758 struct virtio_ccw_device *vcdev = to_vc_device(vdev);
764 ccw = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*ccw));
768 features = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*features));
779 ret = ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_READ_FEAT);
787 if (vcdev->revision == 0)
796 ret = ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_READ_FEAT);
801 ccw_device_dma_free(vcdev->cdev, features, sizeof(*features));
802 ccw_device_dma_free(vcdev->cdev, ccw, sizeof(*ccw));
815 struct virtio_ccw_device *vcdev = to_vc_device(vdev);
820 if (vcdev->revision >= 1 &&
827 ccw = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*ccw));
831 features = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*features));
849 ret = ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_WRITE_FEAT);
853 if (vcdev->revision == 0)
863 ret = ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_WRITE_FEAT);
866 ccw_device_dma_free(vcdev->cdev, features, sizeof(*features));
867 ccw_device_dma_free(vcdev->cdev, ccw, sizeof(*ccw));
875 struct virtio_ccw_device *vcdev = to_vc_device(vdev);
881 ccw = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*ccw));
885 config_area = ccw_device_dma_zalloc(vcdev->cdev,
895 ret = ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_READ_CONFIG);
899 spin_lock_irqsave(&vcdev->lock, flags);
900 memcpy(vcdev->config, config_area, offset + len);
901 if (vcdev->config_ready < offset + len)
902 vcdev->config_ready = offset + len;
903 spin_unlock_irqrestore(&vcdev->lock, flags);
908 ccw_device_dma_free(vcdev->cdev, config_area, VIRTIO_CCW_CONFIG_SIZE);
909 ccw_device_dma_free(vcdev->cdev, ccw, sizeof(*ccw));
916 struct virtio_ccw_device *vcdev = to_vc_device(vdev);
921 ccw = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*ccw));
925 config_area = ccw_device_dma_zalloc(vcdev->cdev,
931 if (vcdev->config_ready < offset)
933 spin_lock_irqsave(&vcdev->lock, flags);
934 memcpy(&vcdev->config[offset], buf, len);
936 memcpy(config_area, vcdev->config, sizeof(vcdev->config));
937 spin_unlock_irqrestore(&vcdev->lock, flags);
942 ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_WRITE_CONFIG);
945 ccw_device_dma_free(vcdev->cdev, config_area, VIRTIO_CCW_CONFIG_SIZE);
946 ccw_device_dma_free(vcdev->cdev, ccw, sizeof(*ccw));
951 struct virtio_ccw_device *vcdev = to_vc_device(vdev);
952 u8 old_status = vcdev->dma_area->status;
955 if (vcdev->revision < 2)
956 return vcdev->dma_area->status;
958 ccw = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*ccw));
964 ccw->count = sizeof(vcdev->dma_area->status);
965 ccw->cda = (__u32)(unsigned long)&vcdev->dma_area->status;
966 ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_READ_STATUS);
970 * handler anyway), vcdev->dma_area->status was not overwritten and we just
973 ccw_device_dma_free(vcdev->cdev, ccw, sizeof(*ccw));
975 return vcdev->dma_area->status;
980 struct virtio_ccw_device *vcdev = to_vc_device(vdev);
981 u8 old_status = vcdev->dma_area->status;
985 ccw = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*ccw));
990 vcdev->dma_area->status = status;
994 ccw->cda = (__u32)(unsigned long)&vcdev->dma_area->status;
995 ret = ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_WRITE_STATUS);
998 vcdev->dma_area->status = old_status;
999 ccw_device_dma_free(vcdev->cdev, ccw, sizeof(*ccw));
1004 struct virtio_ccw_device *vcdev = to_vc_device(vdev);
1006 return dev_name(&vcdev->cdev->dev);
1030 struct virtio_ccw_device *vcdev = to_vc_device(dev);
1032 ccw_device_dma_free(vcdev->cdev, vcdev->dma_area,
1033 sizeof(*vcdev->dma_area));
1034 kfree(vcdev);
1048 static struct virtqueue *virtio_ccw_vq_by_ind(struct virtio_ccw_device *vcdev,
1056 spin_lock_irqsave(&vcdev->lock, flags);
1057 list_for_each_entry(info, &vcdev->virtqueues, node) {
1063 spin_unlock_irqrestore(&vcdev->lock, flags);
1067 static void virtio_ccw_check_activity(struct virtio_ccw_device *vcdev,
1070 if (vcdev->curr_io & activity) {
1085 vcdev->curr_io &= ~activity;
1086 wake_up(&vcdev->wait_q);
1090 dev_warn(&vcdev->cdev->dev,
1103 struct virtio_ccw_device *vcdev = dev_get_drvdata(&cdev->dev);
1107 if (!vcdev)
1110 vcdev->err = PTR_ERR(irb);
1111 virtio_ccw_check_activity(vcdev, activity);
1125 vcdev->err = -EOPNOTSUPP;
1128 vcdev->err = -EIO;
1130 virtio_ccw_check_activity(vcdev, activity);
1131 for_each_set_bit(i, indicators(vcdev),
1132 sizeof(*indicators(vcdev)) * BITS_PER_BYTE) {
1134 clear_bit(i, indicators(vcdev));
1136 vq = virtio_ccw_vq_by_ind(vcdev, i);
1139 if (test_bit(0, indicators2(vcdev))) {
1140 virtio_config_changed(&vcdev->vdev);
1141 clear_bit(0, indicators2(vcdev));
1190 struct virtio_ccw_device *vcdev;
1193 vcdev = dev_get_drvdata(&cdev->dev);
1194 if (!vcdev || vcdev->going_away) {
1198 vcdev->going_away = true;
1200 return vcdev;
1206 struct virtio_ccw_device *vcdev = virtio_grab_drvdata(cdev);
1208 if (vcdev && cdev->online) {
1209 if (vcdev->device_lost)
1210 virtio_break_device(&vcdev->vdev);
1211 unregister_virtio_device(&vcdev->vdev);
1222 struct virtio_ccw_device *vcdev = virtio_grab_drvdata(cdev);
1224 if (!vcdev)
1226 if (vcdev->device_lost)
1227 virtio_break_device(&vcdev->vdev);
1228 unregister_virtio_device(&vcdev->vdev);
1235 static int virtio_ccw_set_transport_rev(struct virtio_ccw_device *vcdev)
1241 ccw = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*ccw));
1244 rev = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*rev));
1246 ccw_device_dma_free(vcdev->cdev, ccw, sizeof(*ccw));
1256 vcdev->revision = VIRTIO_CCW_REV_MAX;
1258 rev->revision = vcdev->revision;
1261 ret = ccw_io_helper(vcdev, ccw,
1264 if (vcdev->revision == 0)
1272 vcdev->revision--;
1276 ccw_device_dma_free(vcdev->cdev, ccw, sizeof(*ccw));
1277 ccw_device_dma_free(vcdev->cdev, rev, sizeof(*rev));
1284 struct virtio_ccw_device *vcdev;
1287 vcdev = kzalloc(sizeof(*vcdev), GFP_KERNEL);
1288 if (!vcdev) {
1293 vcdev->vdev.dev.parent = &cdev->dev;
1294 vcdev->cdev = cdev;
1295 vcdev->dma_area = ccw_device_dma_zalloc(vcdev->cdev,
1296 sizeof(*vcdev->dma_area));
1297 if (!vcdev->dma_area) {
1302 vcdev->is_thinint = virtio_ccw_use_airq; /* at least try */
1304 vcdev->vdev.dev.release = virtio_ccw_release_dev;
1305 vcdev->vdev.config = &virtio_ccw_config_ops;
1306 init_waitqueue_head(&vcdev->wait_q);
1307 INIT_LIST_HEAD(&vcdev->virtqueues);
1308 spin_lock_init(&vcdev->lock);
1309 mutex_init(&vcdev->io_lock);
1312 dev_set_drvdata(&cdev->dev, vcdev);
1314 vcdev->vdev.id.vendor = cdev->id.cu_type;
1315 vcdev->vdev.id.device = cdev->id.cu_model;
1317 ret = virtio_ccw_set_transport_rev(vcdev);
1321 ret = register_virtio_device(&vcdev->vdev);
1332 put_device(&vcdev->vdev.dev);
1335 if (vcdev) {
1336 ccw_device_dma_free(vcdev->cdev, vcdev->dma_area,
1337 sizeof(*vcdev->dma_area));
1339 kfree(vcdev);
1346 struct virtio_ccw_device *vcdev = dev_get_drvdata(&cdev->dev);
1349 * Make sure vcdev is set
1352 if (!vcdev)
1357 vcdev->device_lost = true;