Lines Matching defs:vcdev
77 static inline unsigned long *indicators(struct virtio_ccw_device *vcdev)
79 return &vcdev->dma_area->indicators;
82 static inline unsigned long *indicators2(struct virtio_ccw_device *vcdev)
84 return &vcdev->dma_area->indicators2;
298 static void virtio_ccw_drop_indicators(struct virtio_ccw_device *vcdev)
302 if (!vcdev->airq_info)
304 list_for_each_entry(info, &vcdev->virtqueues, node)
305 drop_airq_indicator(info->vq, vcdev->airq_info);
308 static int doing_io(struct virtio_ccw_device *vcdev, __u32 flag)
313 spin_lock_irqsave(get_ccwdev_lock(vcdev->cdev), flags);
314 if (vcdev->err)
317 ret = vcdev->curr_io & flag;
318 spin_unlock_irqrestore(get_ccwdev_lock(vcdev->cdev), flags);
322 static int ccw_io_helper(struct virtio_ccw_device *vcdev,
329 mutex_lock(&vcdev->io_lock);
331 spin_lock_irqsave(get_ccwdev_lock(vcdev->cdev), flags);
332 ret = ccw_device_start(vcdev->cdev, ccw, intparm, 0, 0);
334 if (!vcdev->curr_io)
335 vcdev->err = 0;
336 vcdev->curr_io |= flag;
338 spin_unlock_irqrestore(get_ccwdev_lock(vcdev->cdev), flags);
341 wait_event(vcdev->wait_q, doing_io(vcdev, flag) == 0);
342 ret = ret ? ret : vcdev->err;
343 mutex_unlock(&vcdev->io_lock);
347 static void virtio_ccw_drop_indicator(struct virtio_ccw_device *vcdev,
353 struct airq_info *airq_info = vcdev->airq_info;
355 if (vcdev->is_thinint) {
356 thinint_area = ccw_device_dma_zalloc(vcdev->cdev,
368 indicatorp = ccw_device_dma_zalloc(vcdev->cdev,
369 sizeof(indicators(vcdev)));
374 ccw->count = sizeof(indicators(vcdev));
378 *indicators(vcdev) = 0;
380 ret = ccw_io_helper(vcdev, ccw,
381 vcdev->is_thinint ?
385 dev_info(&vcdev->cdev->dev,
387 else if (vcdev->is_thinint)
388 virtio_ccw_drop_indicators(vcdev);
389 ccw_device_dma_free(vcdev->cdev, indicatorp, sizeof(indicators(vcdev)));
390 ccw_device_dma_free(vcdev->cdev, thinint_area, sizeof(*thinint_area));
396 struct virtio_ccw_device *vcdev;
399 vcdev = to_vc_device(info->vq->vdev);
400 ccw_device_get_schid(vcdev->cdev, &schid);
420 static int virtio_ccw_read_vq_conf(struct virtio_ccw_device *vcdev,
425 vcdev->dma_area->config_block.index = index;
429 ccw->cda = (__u32)virt_to_phys(&vcdev->dma_area->config_block);
430 ret = ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_READ_VQ_CONF);
433 return vcdev->dma_area->config_block.num ?: -ENOENT;
438 struct virtio_ccw_device *vcdev = to_vc_device(vq->vdev);
445 spin_lock_irqsave(&vcdev->lock, flags);
447 spin_unlock_irqrestore(&vcdev->lock, flags);
450 if (vcdev->revision == 0) {
467 ret = ccw_io_helper(vcdev, ccw,
478 ccw_device_dma_free(vcdev->cdev, info->info_block,
487 struct virtio_ccw_device *vcdev = to_vc_device(vdev);
489 ccw = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*ccw));
493 virtio_ccw_drop_indicator(vcdev, ccw);
498 ccw_device_dma_free(vcdev->cdev, ccw, sizeof(*ccw));
506 struct virtio_ccw_device *vcdev = to_vc_device(vdev);
523 dev_warn(&vcdev->cdev->dev, "no info\n");
527 info->info_block = ccw_device_dma_zalloc(vcdev->cdev,
530 dev_warn(&vcdev->cdev->dev, "no info block\n");
534 info->num = virtio_ccw_read_vq_conf(vcdev, ccw, i);
539 may_reduce = vcdev->revision > 0;
546 dev_warn(&vcdev->cdev->dev, "no vq\n");
558 if (vcdev->revision == 0) {
575 err = ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_SET_VQ | i);
577 dev_warn(&vcdev->cdev->dev, "SET_VQ failed\n");
585 spin_lock_irqsave(&vcdev->lock, flags);
586 list_add(&info->node, &vcdev->virtqueues);
587 spin_unlock_irqrestore(&vcdev->lock, flags);
595 ccw_device_dma_free(vcdev->cdev, info->info_block,
602 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);
626 info = vcdev->airq_info;
634 ret = ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_SET_IND_ADAPTER);
644 dev_warn(&vcdev->cdev->dev,
646 virtio_ccw_drop_indicators(vcdev);
649 ccw_device_dma_free(vcdev->cdev, thinint_area, sizeof(*thinint_area));
660 struct virtio_ccw_device *vcdev = to_vc_device(vdev);
665 ccw = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*ccw));
689 indicatorp = ccw_device_dma_zalloc(vcdev->cdev,
690 sizeof(indicators(vcdev)));
693 *indicatorp = (unsigned long) indicators(vcdev);
694 if (vcdev->is_thinint) {
695 ret = virtio_ccw_register_adapter_ind(vcdev, vqs, nvqs, ccw);
698 vcdev->is_thinint = false;
700 if (!vcdev->is_thinint) {
702 *indicators(vcdev) = 0;
705 ccw->count = sizeof(indicators(vcdev));
707 ret = ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_SET_IND);
712 *indicatorp = (unsigned long) indicators2(vcdev);
713 *indicators2(vcdev) = 0;
716 ccw->count = sizeof(indicators2(vcdev));
718 ret = ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_SET_CONF_IND);
723 ccw_device_dma_free(vcdev->cdev, indicatorp,
724 sizeof(indicators(vcdev)));
725 ccw_device_dma_free(vcdev->cdev, ccw, sizeof(*ccw));
729 ccw_device_dma_free(vcdev->cdev, indicatorp,
730 sizeof(indicators(vcdev)));
731 ccw_device_dma_free(vcdev->cdev, ccw, sizeof(*ccw));
738 struct virtio_ccw_device *vcdev = to_vc_device(vdev);
741 ccw = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*ccw));
746 vcdev->dma_area->status = 0;
753 ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_RESET);
754 ccw_device_dma_free(vcdev->cdev, ccw, sizeof(*ccw));
759 struct virtio_ccw_device *vcdev = to_vc_device(vdev);
765 ccw = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*ccw));
769 features = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*features));
780 ret = ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_READ_FEAT);
788 if (vcdev->revision == 0)
797 ret = ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_READ_FEAT);
802 ccw_device_dma_free(vcdev->cdev, features, sizeof(*features));
803 ccw_device_dma_free(vcdev->cdev, ccw, sizeof(*ccw));
816 struct virtio_ccw_device *vcdev = to_vc_device(vdev);
821 if (vcdev->revision >= 1 &&
828 ccw = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*ccw));
832 features = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*features));
850 ret = ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_WRITE_FEAT);
854 if (vcdev->revision == 0)
864 ret = ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_WRITE_FEAT);
867 ccw_device_dma_free(vcdev->cdev, features, sizeof(*features));
868 ccw_device_dma_free(vcdev->cdev, ccw, sizeof(*ccw));
876 struct virtio_ccw_device *vcdev = to_vc_device(vdev);
882 ccw = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*ccw));
886 config_area = ccw_device_dma_zalloc(vcdev->cdev,
896 ret = ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_READ_CONFIG);
900 spin_lock_irqsave(&vcdev->lock, flags);
901 memcpy(vcdev->config, config_area, offset + len);
902 if (vcdev->config_ready < offset + len)
903 vcdev->config_ready = offset + len;
904 spin_unlock_irqrestore(&vcdev->lock, flags);
909 ccw_device_dma_free(vcdev->cdev, config_area, VIRTIO_CCW_CONFIG_SIZE);
910 ccw_device_dma_free(vcdev->cdev, ccw, sizeof(*ccw));
917 struct virtio_ccw_device *vcdev = to_vc_device(vdev);
922 ccw = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*ccw));
926 config_area = ccw_device_dma_zalloc(vcdev->cdev,
932 if (vcdev->config_ready < offset)
934 spin_lock_irqsave(&vcdev->lock, flags);
935 memcpy(&vcdev->config[offset], buf, len);
937 memcpy(config_area, vcdev->config, sizeof(vcdev->config));
938 spin_unlock_irqrestore(&vcdev->lock, flags);
943 ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_WRITE_CONFIG);
946 ccw_device_dma_free(vcdev->cdev, config_area, VIRTIO_CCW_CONFIG_SIZE);
947 ccw_device_dma_free(vcdev->cdev, ccw, sizeof(*ccw));
952 struct virtio_ccw_device *vcdev = to_vc_device(vdev);
953 u8 old_status = vcdev->dma_area->status;
956 if (vcdev->revision < 2)
957 return vcdev->dma_area->status;
959 ccw = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*ccw));
965 ccw->count = sizeof(vcdev->dma_area->status);
966 ccw->cda = (__u32)virt_to_phys(&vcdev->dma_area->status);
967 ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_READ_STATUS);
971 * handler anyway), vcdev->dma_area->status was not overwritten and we just
974 ccw_device_dma_free(vcdev->cdev, ccw, sizeof(*ccw));
976 return vcdev->dma_area->status;
981 struct virtio_ccw_device *vcdev = to_vc_device(vdev);
982 u8 old_status = vcdev->dma_area->status;
986 ccw = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*ccw));
991 vcdev->dma_area->status = status;
995 ccw->cda = (__u32)virt_to_phys(&vcdev->dma_area->status);
1000 ret = ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_WRITE_STATUS);
1003 vcdev->dma_area->status = old_status;
1004 ccw_device_dma_free(vcdev->cdev, ccw, sizeof(*ccw));
1009 struct virtio_ccw_device *vcdev = to_vc_device(vdev);
1011 return dev_name(&vcdev->cdev->dev);
1016 struct virtio_ccw_device *vcdev = to_vc_device(vdev);
1017 struct airq_info *info = vcdev->airq_info;
1033 write_lock_irq(&vcdev->irq_lock);
1034 write_unlock_irq(&vcdev->irq_lock);
1060 struct virtio_ccw_device *vcdev = to_vc_device(dev);
1062 ccw_device_dma_free(vcdev->cdev, vcdev->dma_area,
1063 sizeof(*vcdev->dma_area));
1064 kfree(vcdev);
1078 static struct virtqueue *virtio_ccw_vq_by_ind(struct virtio_ccw_device *vcdev,
1086 spin_lock_irqsave(&vcdev->lock, flags);
1087 list_for_each_entry(info, &vcdev->virtqueues, node) {
1093 spin_unlock_irqrestore(&vcdev->lock, flags);
1097 static void virtio_ccw_check_activity(struct virtio_ccw_device *vcdev,
1100 if (vcdev->curr_io & activity) {
1115 vcdev->curr_io &= ~activity;
1116 wake_up(&vcdev->wait_q);
1120 dev_warn(&vcdev->cdev->dev,
1133 struct virtio_ccw_device *vcdev = dev_get_drvdata(&cdev->dev);
1137 if (!vcdev)
1140 vcdev->err = PTR_ERR(irb);
1141 virtio_ccw_check_activity(vcdev, activity);
1155 vcdev->err = -EOPNOTSUPP;
1158 vcdev->err = -EIO;
1160 virtio_ccw_check_activity(vcdev, activity);
1166 read_lock(&vcdev->irq_lock);
1168 for_each_set_bit(i, indicators(vcdev),
1169 sizeof(*indicators(vcdev)) * BITS_PER_BYTE) {
1171 clear_bit(i, indicators(vcdev));
1173 vq = virtio_ccw_vq_by_ind(vcdev, i);
1177 read_unlock(&vcdev->irq_lock);
1179 if (test_bit(0, indicators2(vcdev))) {
1180 virtio_config_changed(&vcdev->vdev);
1181 clear_bit(0, indicators2(vcdev));
1230 struct virtio_ccw_device *vcdev;
1233 vcdev = dev_get_drvdata(&cdev->dev);
1234 if (!vcdev || vcdev->going_away) {
1238 vcdev->going_away = true;
1240 return vcdev;
1246 struct virtio_ccw_device *vcdev = virtio_grab_drvdata(cdev);
1248 if (vcdev && cdev->online) {
1249 if (vcdev->device_lost)
1250 virtio_break_device(&vcdev->vdev);
1251 unregister_virtio_device(&vcdev->vdev);
1262 struct virtio_ccw_device *vcdev = virtio_grab_drvdata(cdev);
1264 if (!vcdev)
1266 if (vcdev->device_lost)
1267 virtio_break_device(&vcdev->vdev);
1268 unregister_virtio_device(&vcdev->vdev);
1275 static int virtio_ccw_set_transport_rev(struct virtio_ccw_device *vcdev)
1281 ccw = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*ccw));
1284 rev = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*rev));
1286 ccw_device_dma_free(vcdev->cdev, ccw, sizeof(*ccw));
1296 vcdev->revision = VIRTIO_CCW_REV_MAX;
1298 rev->revision = vcdev->revision;
1301 ret = ccw_io_helper(vcdev, ccw,
1304 if (vcdev->revision == 0)
1312 vcdev->revision--;
1316 ccw_device_dma_free(vcdev->cdev, ccw, sizeof(*ccw));
1317 ccw_device_dma_free(vcdev->cdev, rev, sizeof(*rev));
1324 struct virtio_ccw_device *vcdev;
1327 vcdev = kzalloc(sizeof(*vcdev), GFP_KERNEL);
1328 if (!vcdev) {
1333 vcdev->vdev.dev.parent = &cdev->dev;
1334 vcdev->cdev = cdev;
1335 vcdev->dma_area = ccw_device_dma_zalloc(vcdev->cdev,
1336 sizeof(*vcdev->dma_area));
1337 if (!vcdev->dma_area) {
1342 vcdev->is_thinint = virtio_ccw_use_airq; /* at least try */
1344 vcdev->vdev.dev.release = virtio_ccw_release_dev;
1345 vcdev->vdev.config = &virtio_ccw_config_ops;
1346 init_waitqueue_head(&vcdev->wait_q);
1347 INIT_LIST_HEAD(&vcdev->virtqueues);
1348 spin_lock_init(&vcdev->lock);
1349 rwlock_init(&vcdev->irq_lock);
1350 mutex_init(&vcdev->io_lock);
1353 dev_set_drvdata(&cdev->dev, vcdev);
1355 vcdev->vdev.id.vendor = cdev->id.cu_type;
1356 vcdev->vdev.id.device = cdev->id.cu_model;
1358 ret = virtio_ccw_set_transport_rev(vcdev);
1362 ret = register_virtio_device(&vcdev->vdev);
1373 put_device(&vcdev->vdev.dev);
1376 if (vcdev) {
1377 ccw_device_dma_free(vcdev->cdev, vcdev->dma_area,
1378 sizeof(*vcdev->dma_area));
1380 kfree(vcdev);
1387 struct virtio_ccw_device *vcdev = dev_get_drvdata(&cdev->dev);
1390 * Make sure vcdev is set
1393 if (!vcdev)
1398 vcdev->device_lost = true;