| .. | .. |
|---|
| 9 | 9 | |
|---|
| 10 | 10 | #include <linux/kernel_stat.h> |
|---|
| 11 | 11 | #include <linux/init.h> |
|---|
| 12 | | -#include <linux/bootmem.h> |
|---|
| 12 | +#include <linux/memblock.h> |
|---|
| 13 | 13 | #include <linux/err.h> |
|---|
| 14 | 14 | #include <linux/virtio.h> |
|---|
| 15 | 15 | #include <linux/virtio_config.h> |
|---|
| .. | .. |
|---|
| 46 | 46 | #define VIRTIO_CCW_CONFIG_SIZE 0x100 |
|---|
| 47 | 47 | /* same as PCI config space size, should be enough for all drivers */ |
|---|
| 48 | 48 | |
|---|
| 49 | +struct vcdev_dma_area { |
|---|
| 50 | + unsigned long indicators; |
|---|
| 51 | + unsigned long indicators2; |
|---|
| 52 | + struct vq_config_block config_block; |
|---|
| 53 | + __u8 status; |
|---|
| 54 | +}; |
|---|
| 55 | + |
|---|
| 49 | 56 | struct virtio_ccw_device { |
|---|
| 50 | 57 | struct virtio_device vdev; |
|---|
| 51 | | - __u8 *status; |
|---|
| 52 | 58 | __u8 config[VIRTIO_CCW_CONFIG_SIZE]; |
|---|
| 53 | 59 | struct ccw_device *cdev; |
|---|
| 54 | 60 | __u32 curr_io; |
|---|
| .. | .. |
|---|
| 58 | 64 | spinlock_t lock; |
|---|
| 59 | 65 | struct mutex io_lock; /* Serializes I/O requests */ |
|---|
| 60 | 66 | struct list_head virtqueues; |
|---|
| 61 | | - unsigned long indicators; |
|---|
| 62 | | - unsigned long indicators2; |
|---|
| 63 | | - struct vq_config_block *config_block; |
|---|
| 64 | 67 | bool is_thinint; |
|---|
| 65 | 68 | bool going_away; |
|---|
| 66 | 69 | bool device_lost; |
|---|
| 67 | 70 | unsigned int config_ready; |
|---|
| 68 | 71 | void *airq_info; |
|---|
| 72 | + struct vcdev_dma_area *dma_area; |
|---|
| 69 | 73 | }; |
|---|
| 74 | + |
|---|
| 75 | +static inline unsigned long *indicators(struct virtio_ccw_device *vcdev) |
|---|
| 76 | +{ |
|---|
| 77 | + return &vcdev->dma_area->indicators; |
|---|
| 78 | +} |
|---|
| 79 | + |
|---|
| 80 | +static inline unsigned long *indicators2(struct virtio_ccw_device *vcdev) |
|---|
| 81 | +{ |
|---|
| 82 | + return &vcdev->dma_area->indicators2; |
|---|
| 83 | +} |
|---|
| 70 | 84 | |
|---|
| 71 | 85 | struct vq_info_block_legacy { |
|---|
| 72 | 86 | __u64 queue; |
|---|
| .. | .. |
|---|
| 108 | 122 | struct virtio_ccw_vq_info { |
|---|
| 109 | 123 | struct virtqueue *vq; |
|---|
| 110 | 124 | int num; |
|---|
| 111 | | - void *queue; |
|---|
| 112 | 125 | union { |
|---|
| 113 | 126 | struct vq_info_block s; |
|---|
| 114 | 127 | struct vq_info_block_legacy l; |
|---|
| .. | .. |
|---|
| 127 | 140 | |
|---|
| 128 | 141 | struct airq_info { |
|---|
| 129 | 142 | rwlock_t lock; |
|---|
| 130 | | - u8 summary_indicator; |
|---|
| 143 | + u8 summary_indicator_idx; |
|---|
| 131 | 144 | struct airq_struct airq; |
|---|
| 132 | 145 | struct airq_iv *aiv; |
|---|
| 133 | 146 | }; |
|---|
| 134 | 147 | static struct airq_info *airq_areas[MAX_AIRQ_AREAS]; |
|---|
| 135 | 148 | static DEFINE_MUTEX(airq_areas_lock); |
|---|
| 149 | + |
|---|
| 150 | +static u8 *summary_indicators; |
|---|
| 151 | + |
|---|
| 152 | +static inline u8 *get_summary_indicator(struct airq_info *info) |
|---|
| 153 | +{ |
|---|
| 154 | + return summary_indicators + info->summary_indicator_idx; |
|---|
| 155 | +} |
|---|
| 136 | 156 | |
|---|
| 137 | 157 | #define CCW_CMD_SET_VQ 0x13 |
|---|
| 138 | 158 | #define CCW_CMD_VDEV_RESET 0x33 |
|---|
| .. | .. |
|---|
| 183 | 203 | write_unlock_irqrestore(&info->lock, flags); |
|---|
| 184 | 204 | } |
|---|
| 185 | 205 | |
|---|
| 186 | | -static void virtio_airq_handler(struct airq_struct *airq) |
|---|
| 206 | +static void virtio_airq_handler(struct airq_struct *airq, bool floating) |
|---|
| 187 | 207 | { |
|---|
| 188 | 208 | struct airq_info *info = container_of(airq, struct airq_info, airq); |
|---|
| 189 | 209 | unsigned long ai; |
|---|
| .. | .. |
|---|
| 197 | 217 | break; |
|---|
| 198 | 218 | vring_interrupt(0, (void *)airq_iv_get_ptr(info->aiv, ai)); |
|---|
| 199 | 219 | } |
|---|
| 200 | | - info->summary_indicator = 0; |
|---|
| 220 | + *(get_summary_indicator(info)) = 0; |
|---|
| 201 | 221 | smp_wmb(); |
|---|
| 202 | 222 | /* Walk through indicators field, summary indicator not active. */ |
|---|
| 203 | 223 | for (ai = 0;;) { |
|---|
| .. | .. |
|---|
| 209 | 229 | read_unlock(&info->lock); |
|---|
| 210 | 230 | } |
|---|
| 211 | 231 | |
|---|
| 212 | | -static struct airq_info *new_airq_info(void) |
|---|
| 232 | +static struct airq_info *new_airq_info(int index) |
|---|
| 213 | 233 | { |
|---|
| 214 | 234 | struct airq_info *info; |
|---|
| 215 | 235 | int rc; |
|---|
| .. | .. |
|---|
| 218 | 238 | if (!info) |
|---|
| 219 | 239 | return NULL; |
|---|
| 220 | 240 | rwlock_init(&info->lock); |
|---|
| 221 | | - info->aiv = airq_iv_create(VIRTIO_IV_BITS, AIRQ_IV_ALLOC | AIRQ_IV_PTR); |
|---|
| 241 | + info->aiv = airq_iv_create(VIRTIO_IV_BITS, AIRQ_IV_ALLOC | AIRQ_IV_PTR |
|---|
| 242 | + | AIRQ_IV_CACHELINE); |
|---|
| 222 | 243 | if (!info->aiv) { |
|---|
| 223 | 244 | kfree(info); |
|---|
| 224 | 245 | return NULL; |
|---|
| 225 | 246 | } |
|---|
| 226 | 247 | info->airq.handler = virtio_airq_handler; |
|---|
| 227 | | - info->airq.lsi_ptr = &info->summary_indicator; |
|---|
| 248 | + info->summary_indicator_idx = index; |
|---|
| 249 | + info->airq.lsi_ptr = get_summary_indicator(info); |
|---|
| 228 | 250 | info->airq.lsi_mask = 0xff; |
|---|
| 229 | 251 | info->airq.isc = VIRTIO_AIRQ_ISC; |
|---|
| 230 | 252 | rc = register_adapter_interrupt(&info->airq); |
|---|
| .. | .. |
|---|
| 247 | 269 | for (i = 0; i < MAX_AIRQ_AREAS && !indicator_addr; i++) { |
|---|
| 248 | 270 | mutex_lock(&airq_areas_lock); |
|---|
| 249 | 271 | if (!airq_areas[i]) |
|---|
| 250 | | - airq_areas[i] = new_airq_info(); |
|---|
| 272 | + airq_areas[i] = new_airq_info(i); |
|---|
| 251 | 273 | info = airq_areas[i]; |
|---|
| 252 | 274 | mutex_unlock(&airq_areas_lock); |
|---|
| 253 | 275 | if (!info) |
|---|
| .. | .. |
|---|
| 329 | 351 | struct airq_info *airq_info = vcdev->airq_info; |
|---|
| 330 | 352 | |
|---|
| 331 | 353 | if (vcdev->is_thinint) { |
|---|
| 332 | | - thinint_area = kzalloc(sizeof(*thinint_area), |
|---|
| 333 | | - GFP_DMA | GFP_KERNEL); |
|---|
| 354 | + thinint_area = ccw_device_dma_zalloc(vcdev->cdev, |
|---|
| 355 | + sizeof(*thinint_area)); |
|---|
| 334 | 356 | if (!thinint_area) |
|---|
| 335 | 357 | return; |
|---|
| 336 | 358 | thinint_area->summary_indicator = |
|---|
| 337 | | - (unsigned long) &airq_info->summary_indicator; |
|---|
| 359 | + (unsigned long) get_summary_indicator(airq_info); |
|---|
| 338 | 360 | thinint_area->isc = VIRTIO_AIRQ_ISC; |
|---|
| 339 | 361 | ccw->cmd_code = CCW_CMD_SET_IND_ADAPTER; |
|---|
| 340 | 362 | ccw->count = sizeof(*thinint_area); |
|---|
| 341 | 363 | ccw->cda = (__u32)(unsigned long) thinint_area; |
|---|
| 342 | 364 | } else { |
|---|
| 343 | 365 | /* payload is the address of the indicators */ |
|---|
| 344 | | - indicatorp = kmalloc(sizeof(&vcdev->indicators), |
|---|
| 345 | | - GFP_DMA | GFP_KERNEL); |
|---|
| 366 | + indicatorp = ccw_device_dma_zalloc(vcdev->cdev, |
|---|
| 367 | + sizeof(indicators(vcdev))); |
|---|
| 346 | 368 | if (!indicatorp) |
|---|
| 347 | 369 | return; |
|---|
| 348 | 370 | *indicatorp = 0; |
|---|
| 349 | 371 | ccw->cmd_code = CCW_CMD_SET_IND; |
|---|
| 350 | | - ccw->count = sizeof(&vcdev->indicators); |
|---|
| 372 | + ccw->count = sizeof(indicators(vcdev)); |
|---|
| 351 | 373 | ccw->cda = (__u32)(unsigned long) indicatorp; |
|---|
| 352 | 374 | } |
|---|
| 353 | 375 | /* Deregister indicators from host. */ |
|---|
| 354 | | - vcdev->indicators = 0; |
|---|
| 376 | + *indicators(vcdev) = 0; |
|---|
| 355 | 377 | ccw->flags = 0; |
|---|
| 356 | 378 | ret = ccw_io_helper(vcdev, ccw, |
|---|
| 357 | 379 | vcdev->is_thinint ? |
|---|
| .. | .. |
|---|
| 362 | 384 | "Failed to deregister indicators (%d)\n", ret); |
|---|
| 363 | 385 | else if (vcdev->is_thinint) |
|---|
| 364 | 386 | virtio_ccw_drop_indicators(vcdev); |
|---|
| 365 | | - kfree(indicatorp); |
|---|
| 366 | | - kfree(thinint_area); |
|---|
| 387 | + ccw_device_dma_free(vcdev->cdev, indicatorp, sizeof(indicators(vcdev))); |
|---|
| 388 | + ccw_device_dma_free(vcdev->cdev, thinint_area, sizeof(*thinint_area)); |
|---|
| 367 | 389 | } |
|---|
| 368 | 390 | |
|---|
| 369 | 391 | static inline long __do_kvm_notify(struct subchannel_id schid, |
|---|
| .. | .. |
|---|
| 410 | 432 | { |
|---|
| 411 | 433 | int ret; |
|---|
| 412 | 434 | |
|---|
| 413 | | - vcdev->config_block->index = index; |
|---|
| 435 | + vcdev->dma_area->config_block.index = index; |
|---|
| 414 | 436 | ccw->cmd_code = CCW_CMD_READ_VQ_CONF; |
|---|
| 415 | 437 | ccw->flags = 0; |
|---|
| 416 | 438 | ccw->count = sizeof(struct vq_config_block); |
|---|
| 417 | | - ccw->cda = (__u32)(unsigned long)(vcdev->config_block); |
|---|
| 439 | + ccw->cda = (__u32)(unsigned long)(&vcdev->dma_area->config_block); |
|---|
| 418 | 440 | ret = ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_READ_VQ_CONF); |
|---|
| 419 | 441 | if (ret) |
|---|
| 420 | 442 | return ret; |
|---|
| 421 | | - return vcdev->config_block->num ?: -ENOENT; |
|---|
| 443 | + return vcdev->dma_area->config_block.num ?: -ENOENT; |
|---|
| 422 | 444 | } |
|---|
| 423 | 445 | |
|---|
| 424 | 446 | static void virtio_ccw_del_vq(struct virtqueue *vq, struct ccw1 *ccw) |
|---|
| .. | .. |
|---|
| 426 | 448 | struct virtio_ccw_device *vcdev = to_vc_device(vq->vdev); |
|---|
| 427 | 449 | struct virtio_ccw_vq_info *info = vq->priv; |
|---|
| 428 | 450 | unsigned long flags; |
|---|
| 429 | | - unsigned long size; |
|---|
| 430 | 451 | int ret; |
|---|
| 431 | 452 | unsigned int index = vq->index; |
|---|
| 432 | 453 | |
|---|
| .. | .. |
|---|
| 464 | 485 | ret, index); |
|---|
| 465 | 486 | |
|---|
| 466 | 487 | vring_del_virtqueue(vq); |
|---|
| 467 | | - size = PAGE_ALIGN(vring_size(info->num, KVM_VIRTIO_CCW_RING_ALIGN)); |
|---|
| 468 | | - free_pages_exact(info->queue, size); |
|---|
| 469 | | - kfree(info->info_block); |
|---|
| 488 | + ccw_device_dma_free(vcdev->cdev, info->info_block, |
|---|
| 489 | + sizeof(*info->info_block)); |
|---|
| 470 | 490 | kfree(info); |
|---|
| 471 | 491 | } |
|---|
| 472 | 492 | |
|---|
| .. | .. |
|---|
| 476 | 496 | struct ccw1 *ccw; |
|---|
| 477 | 497 | struct virtio_ccw_device *vcdev = to_vc_device(vdev); |
|---|
| 478 | 498 | |
|---|
| 479 | | - ccw = kzalloc(sizeof(*ccw), GFP_DMA | GFP_KERNEL); |
|---|
| 499 | + ccw = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*ccw)); |
|---|
| 480 | 500 | if (!ccw) |
|---|
| 481 | 501 | return; |
|---|
| 482 | 502 | |
|---|
| .. | .. |
|---|
| 485 | 505 | list_for_each_entry_safe(vq, n, &vdev->vqs, list) |
|---|
| 486 | 506 | virtio_ccw_del_vq(vq, ccw); |
|---|
| 487 | 507 | |
|---|
| 488 | | - kfree(ccw); |
|---|
| 508 | + ccw_device_dma_free(vcdev->cdev, ccw, sizeof(*ccw)); |
|---|
| 489 | 509 | } |
|---|
| 490 | 510 | |
|---|
| 491 | 511 | static struct virtqueue *virtio_ccw_setup_vq(struct virtio_device *vdev, |
|---|
| .. | .. |
|---|
| 497 | 517 | int err; |
|---|
| 498 | 518 | struct virtqueue *vq = NULL; |
|---|
| 499 | 519 | struct virtio_ccw_vq_info *info; |
|---|
| 500 | | - unsigned long size = 0; /* silence the compiler */ |
|---|
| 520 | + u64 queue; |
|---|
| 501 | 521 | unsigned long flags; |
|---|
| 522 | + bool may_reduce; |
|---|
| 502 | 523 | |
|---|
| 503 | 524 | /* Allocate queue. */ |
|---|
| 504 | 525 | info = kzalloc(sizeof(struct virtio_ccw_vq_info), GFP_KERNEL); |
|---|
| .. | .. |
|---|
| 507 | 528 | err = -ENOMEM; |
|---|
| 508 | 529 | goto out_err; |
|---|
| 509 | 530 | } |
|---|
| 510 | | - info->info_block = kzalloc(sizeof(*info->info_block), |
|---|
| 511 | | - GFP_DMA | GFP_KERNEL); |
|---|
| 531 | + info->info_block = ccw_device_dma_zalloc(vcdev->cdev, |
|---|
| 532 | + sizeof(*info->info_block)); |
|---|
| 512 | 533 | if (!info->info_block) { |
|---|
| 513 | 534 | dev_warn(&vcdev->cdev->dev, "no info block\n"); |
|---|
| 514 | 535 | err = -ENOMEM; |
|---|
| .. | .. |
|---|
| 519 | 540 | err = info->num; |
|---|
| 520 | 541 | goto out_err; |
|---|
| 521 | 542 | } |
|---|
| 522 | | - size = PAGE_ALIGN(vring_size(info->num, KVM_VIRTIO_CCW_RING_ALIGN)); |
|---|
| 523 | | - info->queue = alloc_pages_exact(size, GFP_KERNEL | __GFP_ZERO); |
|---|
| 524 | | - if (info->queue == NULL) { |
|---|
| 525 | | - dev_warn(&vcdev->cdev->dev, "no queue\n"); |
|---|
| 526 | | - err = -ENOMEM; |
|---|
| 527 | | - goto out_err; |
|---|
| 528 | | - } |
|---|
| 543 | + may_reduce = vcdev->revision > 0; |
|---|
| 544 | + vq = vring_create_virtqueue(i, info->num, KVM_VIRTIO_CCW_RING_ALIGN, |
|---|
| 545 | + vdev, true, may_reduce, ctx, |
|---|
| 546 | + virtio_ccw_kvm_notify, callback, name); |
|---|
| 529 | 547 | |
|---|
| 530 | | - vq = vring_new_virtqueue(i, info->num, KVM_VIRTIO_CCW_RING_ALIGN, vdev, |
|---|
| 531 | | - true, ctx, info->queue, virtio_ccw_kvm_notify, |
|---|
| 532 | | - callback, name); |
|---|
| 533 | 548 | if (!vq) { |
|---|
| 534 | 549 | /* For now, we fail if we can't get the requested size. */ |
|---|
| 535 | 550 | dev_warn(&vcdev->cdev->dev, "no vq\n"); |
|---|
| 536 | 551 | err = -ENOMEM; |
|---|
| 537 | 552 | goto out_err; |
|---|
| 538 | 553 | } |
|---|
| 554 | + /* it may have been reduced */ |
|---|
| 555 | + info->num = virtqueue_get_vring_size(vq); |
|---|
| 539 | 556 | |
|---|
| 540 | 557 | /* Register it with the host. */ |
|---|
| 558 | + queue = virtqueue_get_desc_addr(vq); |
|---|
| 541 | 559 | if (vcdev->revision == 0) { |
|---|
| 542 | | - info->info_block->l.queue = (__u64)info->queue; |
|---|
| 560 | + info->info_block->l.queue = queue; |
|---|
| 543 | 561 | info->info_block->l.align = KVM_VIRTIO_CCW_RING_ALIGN; |
|---|
| 544 | 562 | info->info_block->l.index = i; |
|---|
| 545 | 563 | info->info_block->l.num = info->num; |
|---|
| 546 | 564 | ccw->count = sizeof(info->info_block->l); |
|---|
| 547 | 565 | } else { |
|---|
| 548 | | - info->info_block->s.desc = (__u64)info->queue; |
|---|
| 566 | + info->info_block->s.desc = queue; |
|---|
| 549 | 567 | info->info_block->s.index = i; |
|---|
| 550 | 568 | info->info_block->s.num = info->num; |
|---|
| 551 | | - info->info_block->s.avail = (__u64)virtqueue_get_avail(vq); |
|---|
| 552 | | - info->info_block->s.used = (__u64)virtqueue_get_used(vq); |
|---|
| 569 | + info->info_block->s.avail = (__u64)virtqueue_get_avail_addr(vq); |
|---|
| 570 | + info->info_block->s.used = (__u64)virtqueue_get_used_addr(vq); |
|---|
| 553 | 571 | ccw->count = sizeof(info->info_block->s); |
|---|
| 554 | 572 | } |
|---|
| 555 | 573 | ccw->cmd_code = CCW_CMD_SET_VQ; |
|---|
| .. | .. |
|---|
| 575 | 593 | if (vq) |
|---|
| 576 | 594 | vring_del_virtqueue(vq); |
|---|
| 577 | 595 | if (info) { |
|---|
| 578 | | - if (info->queue) |
|---|
| 579 | | - free_pages_exact(info->queue, size); |
|---|
| 580 | | - kfree(info->info_block); |
|---|
| 596 | + ccw_device_dma_free(vcdev->cdev, info->info_block, |
|---|
| 597 | + sizeof(*info->info_block)); |
|---|
| 581 | 598 | } |
|---|
| 582 | 599 | kfree(info); |
|---|
| 583 | 600 | return ERR_PTR(err); |
|---|
| .. | .. |
|---|
| 591 | 608 | struct virtio_thinint_area *thinint_area = NULL; |
|---|
| 592 | 609 | struct airq_info *info; |
|---|
| 593 | 610 | |
|---|
| 594 | | - thinint_area = kzalloc(sizeof(*thinint_area), GFP_DMA | GFP_KERNEL); |
|---|
| 611 | + thinint_area = ccw_device_dma_zalloc(vcdev->cdev, |
|---|
| 612 | + sizeof(*thinint_area)); |
|---|
| 595 | 613 | if (!thinint_area) { |
|---|
| 596 | 614 | ret = -ENOMEM; |
|---|
| 597 | 615 | goto out; |
|---|
| .. | .. |
|---|
| 606 | 624 | } |
|---|
| 607 | 625 | info = vcdev->airq_info; |
|---|
| 608 | 626 | thinint_area->summary_indicator = |
|---|
| 609 | | - (unsigned long) &info->summary_indicator; |
|---|
| 627 | + (unsigned long) get_summary_indicator(info); |
|---|
| 610 | 628 | thinint_area->isc = VIRTIO_AIRQ_ISC; |
|---|
| 611 | 629 | ccw->cmd_code = CCW_CMD_SET_IND_ADAPTER; |
|---|
| 612 | 630 | ccw->flags = CCW_FLAG_SLI; |
|---|
| .. | .. |
|---|
| 627 | 645 | virtio_ccw_drop_indicators(vcdev); |
|---|
| 628 | 646 | } |
|---|
| 629 | 647 | out: |
|---|
| 630 | | - kfree(thinint_area); |
|---|
| 648 | + ccw_device_dma_free(vcdev->cdev, thinint_area, sizeof(*thinint_area)); |
|---|
| 631 | 649 | return ret; |
|---|
| 632 | 650 | } |
|---|
| 633 | 651 | |
|---|
| .. | .. |
|---|
| 640 | 658 | { |
|---|
| 641 | 659 | struct virtio_ccw_device *vcdev = to_vc_device(vdev); |
|---|
| 642 | 660 | unsigned long *indicatorp = NULL; |
|---|
| 643 | | - int ret, i; |
|---|
| 661 | + int ret, i, queue_idx = 0; |
|---|
| 644 | 662 | struct ccw1 *ccw; |
|---|
| 645 | 663 | |
|---|
| 646 | | - ccw = kzalloc(sizeof(*ccw), GFP_DMA | GFP_KERNEL); |
|---|
| 664 | + ccw = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*ccw)); |
|---|
| 647 | 665 | if (!ccw) |
|---|
| 648 | 666 | return -ENOMEM; |
|---|
| 649 | 667 | |
|---|
| 650 | 668 | for (i = 0; i < nvqs; ++i) { |
|---|
| 651 | | - vqs[i] = virtio_ccw_setup_vq(vdev, i, callbacks[i], names[i], |
|---|
| 652 | | - ctx ? ctx[i] : false, ccw); |
|---|
| 669 | + if (!names[i]) { |
|---|
| 670 | + vqs[i] = NULL; |
|---|
| 671 | + continue; |
|---|
| 672 | + } |
|---|
| 673 | + |
|---|
| 674 | + vqs[i] = virtio_ccw_setup_vq(vdev, queue_idx++, callbacks[i], |
|---|
| 675 | + names[i], ctx ? ctx[i] : false, |
|---|
| 676 | + ccw); |
|---|
| 653 | 677 | if (IS_ERR(vqs[i])) { |
|---|
| 654 | 678 | ret = PTR_ERR(vqs[i]); |
|---|
| 655 | 679 | vqs[i] = NULL; |
|---|
| .. | .. |
|---|
| 661 | 685 | * We need a data area under 2G to communicate. Our payload is |
|---|
| 662 | 686 | * the address of the indicators. |
|---|
| 663 | 687 | */ |
|---|
| 664 | | - indicatorp = kmalloc(sizeof(&vcdev->indicators), GFP_DMA | GFP_KERNEL); |
|---|
| 688 | + indicatorp = ccw_device_dma_zalloc(vcdev->cdev, |
|---|
| 689 | + sizeof(indicators(vcdev))); |
|---|
| 665 | 690 | if (!indicatorp) |
|---|
| 666 | 691 | goto out; |
|---|
| 667 | | - *indicatorp = (unsigned long) &vcdev->indicators; |
|---|
| 692 | + *indicatorp = (unsigned long) indicators(vcdev); |
|---|
| 668 | 693 | if (vcdev->is_thinint) { |
|---|
| 669 | 694 | ret = virtio_ccw_register_adapter_ind(vcdev, vqs, nvqs, ccw); |
|---|
| 670 | 695 | if (ret) |
|---|
| .. | .. |
|---|
| 673 | 698 | } |
|---|
| 674 | 699 | if (!vcdev->is_thinint) { |
|---|
| 675 | 700 | /* Register queue indicators with host. */ |
|---|
| 676 | | - vcdev->indicators = 0; |
|---|
| 701 | + *indicators(vcdev) = 0; |
|---|
| 677 | 702 | ccw->cmd_code = CCW_CMD_SET_IND; |
|---|
| 678 | 703 | ccw->flags = 0; |
|---|
| 679 | | - ccw->count = sizeof(&vcdev->indicators); |
|---|
| 704 | + ccw->count = sizeof(indicators(vcdev)); |
|---|
| 680 | 705 | ccw->cda = (__u32)(unsigned long) indicatorp; |
|---|
| 681 | 706 | ret = ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_SET_IND); |
|---|
| 682 | 707 | if (ret) |
|---|
| 683 | 708 | goto out; |
|---|
| 684 | 709 | } |
|---|
| 685 | 710 | /* Register indicators2 with host for config changes */ |
|---|
| 686 | | - *indicatorp = (unsigned long) &vcdev->indicators2; |
|---|
| 687 | | - vcdev->indicators2 = 0; |
|---|
| 711 | + *indicatorp = (unsigned long) indicators2(vcdev); |
|---|
| 712 | + *indicators2(vcdev) = 0; |
|---|
| 688 | 713 | ccw->cmd_code = CCW_CMD_SET_CONF_IND; |
|---|
| 689 | 714 | ccw->flags = 0; |
|---|
| 690 | | - ccw->count = sizeof(&vcdev->indicators2); |
|---|
| 715 | + ccw->count = sizeof(indicators2(vcdev)); |
|---|
| 691 | 716 | ccw->cda = (__u32)(unsigned long) indicatorp; |
|---|
| 692 | 717 | ret = ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_SET_CONF_IND); |
|---|
| 693 | 718 | if (ret) |
|---|
| 694 | 719 | goto out; |
|---|
| 695 | 720 | |
|---|
| 696 | | - kfree(indicatorp); |
|---|
| 697 | | - kfree(ccw); |
|---|
| 721 | + if (indicatorp) |
|---|
| 722 | + ccw_device_dma_free(vcdev->cdev, indicatorp, |
|---|
| 723 | + sizeof(indicators(vcdev))); |
|---|
| 724 | + ccw_device_dma_free(vcdev->cdev, ccw, sizeof(*ccw)); |
|---|
| 698 | 725 | return 0; |
|---|
| 699 | 726 | out: |
|---|
| 700 | | - kfree(indicatorp); |
|---|
| 701 | | - kfree(ccw); |
|---|
| 727 | + if (indicatorp) |
|---|
| 728 | + ccw_device_dma_free(vcdev->cdev, indicatorp, |
|---|
| 729 | + sizeof(indicators(vcdev))); |
|---|
| 730 | + ccw_device_dma_free(vcdev->cdev, ccw, sizeof(*ccw)); |
|---|
| 702 | 731 | virtio_ccw_del_vqs(vdev); |
|---|
| 703 | 732 | return ret; |
|---|
| 704 | 733 | } |
|---|
| .. | .. |
|---|
| 708 | 737 | struct virtio_ccw_device *vcdev = to_vc_device(vdev); |
|---|
| 709 | 738 | struct ccw1 *ccw; |
|---|
| 710 | 739 | |
|---|
| 711 | | - ccw = kzalloc(sizeof(*ccw), GFP_DMA | GFP_KERNEL); |
|---|
| 740 | + ccw = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*ccw)); |
|---|
| 712 | 741 | if (!ccw) |
|---|
| 713 | 742 | return; |
|---|
| 714 | 743 | |
|---|
| 715 | 744 | /* Zero status bits. */ |
|---|
| 716 | | - *vcdev->status = 0; |
|---|
| 745 | + vcdev->dma_area->status = 0; |
|---|
| 717 | 746 | |
|---|
| 718 | 747 | /* Send a reset ccw on device. */ |
|---|
| 719 | 748 | ccw->cmd_code = CCW_CMD_VDEV_RESET; |
|---|
| .. | .. |
|---|
| 721 | 750 | ccw->count = 0; |
|---|
| 722 | 751 | ccw->cda = 0; |
|---|
| 723 | 752 | ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_RESET); |
|---|
| 724 | | - kfree(ccw); |
|---|
| 753 | + ccw_device_dma_free(vcdev->cdev, ccw, sizeof(*ccw)); |
|---|
| 725 | 754 | } |
|---|
| 726 | 755 | |
|---|
| 727 | 756 | static u64 virtio_ccw_get_features(struct virtio_device *vdev) |
|---|
| .. | .. |
|---|
| 732 | 761 | u64 rc; |
|---|
| 733 | 762 | struct ccw1 *ccw; |
|---|
| 734 | 763 | |
|---|
| 735 | | - ccw = kzalloc(sizeof(*ccw), GFP_DMA | GFP_KERNEL); |
|---|
| 764 | + ccw = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*ccw)); |
|---|
| 736 | 765 | if (!ccw) |
|---|
| 737 | 766 | return 0; |
|---|
| 738 | 767 | |
|---|
| 739 | | - features = kzalloc(sizeof(*features), GFP_DMA | GFP_KERNEL); |
|---|
| 768 | + features = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*features)); |
|---|
| 740 | 769 | if (!features) { |
|---|
| 741 | 770 | rc = 0; |
|---|
| 742 | 771 | goto out_free; |
|---|
| .. | .. |
|---|
| 769 | 798 | rc |= (u64)le32_to_cpu(features->features) << 32; |
|---|
| 770 | 799 | |
|---|
| 771 | 800 | out_free: |
|---|
| 772 | | - kfree(features); |
|---|
| 773 | | - kfree(ccw); |
|---|
| 801 | + ccw_device_dma_free(vcdev->cdev, features, sizeof(*features)); |
|---|
| 802 | + ccw_device_dma_free(vcdev->cdev, ccw, sizeof(*ccw)); |
|---|
| 774 | 803 | return rc; |
|---|
| 804 | +} |
|---|
| 805 | + |
|---|
| 806 | +static void ccw_transport_features(struct virtio_device *vdev) |
|---|
| 807 | +{ |
|---|
| 808 | + /* |
|---|
| 809 | + * Currently nothing to do here. |
|---|
| 810 | + */ |
|---|
| 775 | 811 | } |
|---|
| 776 | 812 | |
|---|
| 777 | 813 | static int virtio_ccw_finalize_features(struct virtio_device *vdev) |
|---|
| .. | .. |
|---|
| 788 | 824 | return -EINVAL; |
|---|
| 789 | 825 | } |
|---|
| 790 | 826 | |
|---|
| 791 | | - ccw = kzalloc(sizeof(*ccw), GFP_DMA | GFP_KERNEL); |
|---|
| 827 | + ccw = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*ccw)); |
|---|
| 792 | 828 | if (!ccw) |
|---|
| 793 | 829 | return -ENOMEM; |
|---|
| 794 | 830 | |
|---|
| 795 | | - features = kzalloc(sizeof(*features), GFP_DMA | GFP_KERNEL); |
|---|
| 831 | + features = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*features)); |
|---|
| 796 | 832 | if (!features) { |
|---|
| 797 | 833 | ret = -ENOMEM; |
|---|
| 798 | 834 | goto out_free; |
|---|
| 799 | 835 | } |
|---|
| 800 | 836 | /* Give virtio_ring a chance to accept features. */ |
|---|
| 801 | 837 | vring_transport_features(vdev); |
|---|
| 838 | + |
|---|
| 839 | + /* Give virtio_ccw a chance to accept features. */ |
|---|
| 840 | + ccw_transport_features(vdev); |
|---|
| 802 | 841 | |
|---|
| 803 | 842 | features->index = 0; |
|---|
| 804 | 843 | features->features = cpu_to_le32((u32)vdev->features); |
|---|
| .. | .. |
|---|
| 824 | 863 | ret = ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_WRITE_FEAT); |
|---|
| 825 | 864 | |
|---|
| 826 | 865 | out_free: |
|---|
| 827 | | - kfree(features); |
|---|
| 828 | | - kfree(ccw); |
|---|
| 866 | + ccw_device_dma_free(vcdev->cdev, features, sizeof(*features)); |
|---|
| 867 | + ccw_device_dma_free(vcdev->cdev, ccw, sizeof(*ccw)); |
|---|
| 829 | 868 | |
|---|
| 830 | 869 | return ret; |
|---|
| 831 | 870 | } |
|---|
| .. | .. |
|---|
| 839 | 878 | void *config_area; |
|---|
| 840 | 879 | unsigned long flags; |
|---|
| 841 | 880 | |
|---|
| 842 | | - ccw = kzalloc(sizeof(*ccw), GFP_DMA | GFP_KERNEL); |
|---|
| 881 | + ccw = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*ccw)); |
|---|
| 843 | 882 | if (!ccw) |
|---|
| 844 | 883 | return; |
|---|
| 845 | 884 | |
|---|
| 846 | | - config_area = kzalloc(VIRTIO_CCW_CONFIG_SIZE, GFP_DMA | GFP_KERNEL); |
|---|
| 885 | + config_area = ccw_device_dma_zalloc(vcdev->cdev, |
|---|
| 886 | + VIRTIO_CCW_CONFIG_SIZE); |
|---|
| 847 | 887 | if (!config_area) |
|---|
| 848 | 888 | goto out_free; |
|---|
| 849 | 889 | |
|---|
| .. | .. |
|---|
| 865 | 905 | memcpy(buf, config_area + offset, len); |
|---|
| 866 | 906 | |
|---|
| 867 | 907 | out_free: |
|---|
| 868 | | - kfree(config_area); |
|---|
| 869 | | - kfree(ccw); |
|---|
| 908 | + ccw_device_dma_free(vcdev->cdev, config_area, VIRTIO_CCW_CONFIG_SIZE); |
|---|
| 909 | + ccw_device_dma_free(vcdev->cdev, ccw, sizeof(*ccw)); |
|---|
| 870 | 910 | } |
|---|
| 871 | 911 | |
|---|
| 872 | 912 | static void virtio_ccw_set_config(struct virtio_device *vdev, |
|---|
| .. | .. |
|---|
| 878 | 918 | void *config_area; |
|---|
| 879 | 919 | unsigned long flags; |
|---|
| 880 | 920 | |
|---|
| 881 | | - ccw = kzalloc(sizeof(*ccw), GFP_DMA | GFP_KERNEL); |
|---|
| 921 | + ccw = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*ccw)); |
|---|
| 882 | 922 | if (!ccw) |
|---|
| 883 | 923 | return; |
|---|
| 884 | 924 | |
|---|
| 885 | | - config_area = kzalloc(VIRTIO_CCW_CONFIG_SIZE, GFP_DMA | GFP_KERNEL); |
|---|
| 925 | + config_area = ccw_device_dma_zalloc(vcdev->cdev, |
|---|
| 926 | + VIRTIO_CCW_CONFIG_SIZE); |
|---|
| 886 | 927 | if (!config_area) |
|---|
| 887 | 928 | goto out_free; |
|---|
| 888 | 929 | |
|---|
| .. | .. |
|---|
| 901 | 942 | ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_WRITE_CONFIG); |
|---|
| 902 | 943 | |
|---|
| 903 | 944 | out_free: |
|---|
| 904 | | - kfree(config_area); |
|---|
| 905 | | - kfree(ccw); |
|---|
| 945 | + ccw_device_dma_free(vcdev->cdev, config_area, VIRTIO_CCW_CONFIG_SIZE); |
|---|
| 946 | + ccw_device_dma_free(vcdev->cdev, ccw, sizeof(*ccw)); |
|---|
| 906 | 947 | } |
|---|
| 907 | 948 | |
|---|
| 908 | 949 | static u8 virtio_ccw_get_status(struct virtio_device *vdev) |
|---|
| 909 | 950 | { |
|---|
| 910 | 951 | struct virtio_ccw_device *vcdev = to_vc_device(vdev); |
|---|
| 911 | | - u8 old_status = *vcdev->status; |
|---|
| 952 | + u8 old_status = vcdev->dma_area->status; |
|---|
| 912 | 953 | struct ccw1 *ccw; |
|---|
| 913 | 954 | |
|---|
| 914 | 955 | if (vcdev->revision < 2) |
|---|
| 915 | | - return *vcdev->status; |
|---|
| 956 | + return vcdev->dma_area->status; |
|---|
| 916 | 957 | |
|---|
| 917 | | - ccw = kzalloc(sizeof(*ccw), GFP_DMA | GFP_KERNEL); |
|---|
| 958 | + ccw = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*ccw)); |
|---|
| 918 | 959 | if (!ccw) |
|---|
| 919 | 960 | return old_status; |
|---|
| 920 | 961 | |
|---|
| 921 | 962 | ccw->cmd_code = CCW_CMD_READ_STATUS; |
|---|
| 922 | 963 | ccw->flags = 0; |
|---|
| 923 | | - ccw->count = sizeof(*vcdev->status); |
|---|
| 924 | | - ccw->cda = (__u32)(unsigned long)vcdev->status; |
|---|
| 964 | + ccw->count = sizeof(vcdev->dma_area->status); |
|---|
| 965 | + ccw->cda = (__u32)(unsigned long)&vcdev->dma_area->status; |
|---|
| 925 | 966 | ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_READ_STATUS); |
|---|
| 926 | 967 | /* |
|---|
| 927 | 968 | * If the channel program failed (should only happen if the device |
|---|
| 928 | 969 | * was hotunplugged, and then we clean up via the machine check |
|---|
| 929 | | - * handler anyway), vcdev->status was not overwritten and we just |
|---|
| 970 | + * handler anyway), vcdev->dma_area->status was not overwritten and we just |
|---|
| 930 | 971 | * return the old status, which is fine. |
|---|
| 931 | 972 | */ |
|---|
| 932 | | - kfree(ccw); |
|---|
| 973 | + ccw_device_dma_free(vcdev->cdev, ccw, sizeof(*ccw)); |
|---|
| 933 | 974 | |
|---|
| 934 | | - return *vcdev->status; |
|---|
| 975 | + return vcdev->dma_area->status; |
|---|
| 935 | 976 | } |
|---|
| 936 | 977 | |
|---|
| 937 | 978 | static void virtio_ccw_set_status(struct virtio_device *vdev, u8 status) |
|---|
| 938 | 979 | { |
|---|
| 939 | 980 | struct virtio_ccw_device *vcdev = to_vc_device(vdev); |
|---|
| 940 | | - u8 old_status = *vcdev->status; |
|---|
| 981 | + u8 old_status = vcdev->dma_area->status; |
|---|
| 941 | 982 | struct ccw1 *ccw; |
|---|
| 942 | 983 | int ret; |
|---|
| 943 | 984 | |
|---|
| 944 | | - ccw = kzalloc(sizeof(*ccw), GFP_DMA | GFP_KERNEL); |
|---|
| 985 | + ccw = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*ccw)); |
|---|
| 945 | 986 | if (!ccw) |
|---|
| 946 | 987 | return; |
|---|
| 947 | 988 | |
|---|
| 948 | 989 | /* Write the status to the host. */ |
|---|
| 949 | | - *vcdev->status = status; |
|---|
| 990 | + vcdev->dma_area->status = status; |
|---|
| 950 | 991 | ccw->cmd_code = CCW_CMD_WRITE_STATUS; |
|---|
| 951 | 992 | ccw->flags = 0; |
|---|
| 952 | 993 | ccw->count = sizeof(status); |
|---|
| 953 | | - ccw->cda = (__u32)(unsigned long)vcdev->status; |
|---|
| 994 | + ccw->cda = (__u32)(unsigned long)&vcdev->dma_area->status; |
|---|
| 954 | 995 | ret = ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_WRITE_STATUS); |
|---|
| 955 | 996 | /* Write failed? We assume status is unchanged. */ |
|---|
| 956 | 997 | if (ret) |
|---|
| 957 | | - *vcdev->status = old_status; |
|---|
| 958 | | - kfree(ccw); |
|---|
| 998 | + vcdev->dma_area->status = old_status; |
|---|
| 999 | + ccw_device_dma_free(vcdev->cdev, ccw, sizeof(*ccw)); |
|---|
| 1000 | +} |
|---|
| 1001 | + |
|---|
| 1002 | +static const char *virtio_ccw_bus_name(struct virtio_device *vdev) |
|---|
| 1003 | +{ |
|---|
| 1004 | + struct virtio_ccw_device *vcdev = to_vc_device(vdev); |
|---|
| 1005 | + |
|---|
| 1006 | + return dev_name(&vcdev->cdev->dev); |
|---|
| 959 | 1007 | } |
|---|
| 960 | 1008 | |
|---|
| 961 | 1009 | static const struct virtio_config_ops virtio_ccw_config_ops = { |
|---|
| .. | .. |
|---|
| 968 | 1016 | .reset = virtio_ccw_reset, |
|---|
| 969 | 1017 | .find_vqs = virtio_ccw_find_vqs, |
|---|
| 970 | 1018 | .del_vqs = virtio_ccw_del_vqs, |
|---|
| 1019 | + .bus_name = virtio_ccw_bus_name, |
|---|
| 971 | 1020 | }; |
|---|
| 972 | 1021 | |
|---|
| 973 | 1022 | |
|---|
| .. | .. |
|---|
| 980 | 1029 | struct virtio_device *dev = dev_to_virtio(_d); |
|---|
| 981 | 1030 | struct virtio_ccw_device *vcdev = to_vc_device(dev); |
|---|
| 982 | 1031 | |
|---|
| 983 | | - kfree(vcdev->status); |
|---|
| 984 | | - kfree(vcdev->config_block); |
|---|
| 1032 | + ccw_device_dma_free(vcdev->cdev, vcdev->dma_area, |
|---|
| 1033 | + sizeof(*vcdev->dma_area)); |
|---|
| 985 | 1034 | kfree(vcdev); |
|---|
| 986 | 1035 | } |
|---|
| 987 | 1036 | |
|---|
| .. | .. |
|---|
| 1079 | 1128 | vcdev->err = -EIO; |
|---|
| 1080 | 1129 | } |
|---|
| 1081 | 1130 | virtio_ccw_check_activity(vcdev, activity); |
|---|
| 1082 | | - for_each_set_bit(i, &vcdev->indicators, |
|---|
| 1083 | | - sizeof(vcdev->indicators) * BITS_PER_BYTE) { |
|---|
| 1131 | + for_each_set_bit(i, indicators(vcdev), |
|---|
| 1132 | + sizeof(*indicators(vcdev)) * BITS_PER_BYTE) { |
|---|
| 1084 | 1133 | /* The bit clear must happen before the vring kick. */ |
|---|
| 1085 | | - clear_bit(i, &vcdev->indicators); |
|---|
| 1134 | + clear_bit(i, indicators(vcdev)); |
|---|
| 1086 | 1135 | barrier(); |
|---|
| 1087 | 1136 | vq = virtio_ccw_vq_by_ind(vcdev, i); |
|---|
| 1088 | 1137 | vring_interrupt(0, vq); |
|---|
| 1089 | 1138 | } |
|---|
| 1090 | | - if (test_bit(0, &vcdev->indicators2)) { |
|---|
| 1139 | + if (test_bit(0, indicators2(vcdev))) { |
|---|
| 1091 | 1140 | virtio_config_changed(&vcdev->vdev); |
|---|
| 1092 | | - clear_bit(0, &vcdev->indicators2); |
|---|
| 1141 | + clear_bit(0, indicators2(vcdev)); |
|---|
| 1093 | 1142 | } |
|---|
| 1094 | 1143 | } |
|---|
| 1095 | 1144 | |
|---|
| .. | .. |
|---|
| 1189 | 1238 | struct ccw1 *ccw; |
|---|
| 1190 | 1239 | int ret; |
|---|
| 1191 | 1240 | |
|---|
| 1192 | | - ccw = kzalloc(sizeof(*ccw), GFP_DMA | GFP_KERNEL); |
|---|
| 1241 | + ccw = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*ccw)); |
|---|
| 1193 | 1242 | if (!ccw) |
|---|
| 1194 | 1243 | return -ENOMEM; |
|---|
| 1195 | | - rev = kzalloc(sizeof(*rev), GFP_DMA | GFP_KERNEL); |
|---|
| 1244 | + rev = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*rev)); |
|---|
| 1196 | 1245 | if (!rev) { |
|---|
| 1197 | | - kfree(ccw); |
|---|
| 1246 | + ccw_device_dma_free(vcdev->cdev, ccw, sizeof(*ccw)); |
|---|
| 1198 | 1247 | return -ENOMEM; |
|---|
| 1199 | 1248 | } |
|---|
| 1200 | 1249 | |
|---|
| .. | .. |
|---|
| 1224 | 1273 | } |
|---|
| 1225 | 1274 | } while (ret == -EOPNOTSUPP); |
|---|
| 1226 | 1275 | |
|---|
| 1227 | | - kfree(ccw); |
|---|
| 1228 | | - kfree(rev); |
|---|
| 1276 | + ccw_device_dma_free(vcdev->cdev, ccw, sizeof(*ccw)); |
|---|
| 1277 | + ccw_device_dma_free(vcdev->cdev, rev, sizeof(*rev)); |
|---|
| 1229 | 1278 | return ret; |
|---|
| 1230 | 1279 | } |
|---|
| 1231 | 1280 | |
|---|
| .. | .. |
|---|
| 1241 | 1290 | ret = -ENOMEM; |
|---|
| 1242 | 1291 | goto out_free; |
|---|
| 1243 | 1292 | } |
|---|
| 1244 | | - vcdev->config_block = kzalloc(sizeof(*vcdev->config_block), |
|---|
| 1245 | | - GFP_DMA | GFP_KERNEL); |
|---|
| 1246 | | - if (!vcdev->config_block) { |
|---|
| 1247 | | - ret = -ENOMEM; |
|---|
| 1248 | | - goto out_free; |
|---|
| 1249 | | - } |
|---|
| 1250 | | - vcdev->status = kzalloc(sizeof(*vcdev->status), GFP_DMA | GFP_KERNEL); |
|---|
| 1251 | | - if (!vcdev->status) { |
|---|
| 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) { |
|---|
| 1252 | 1298 | ret = -ENOMEM; |
|---|
| 1253 | 1299 | goto out_free; |
|---|
| 1254 | 1300 | } |
|---|
| 1255 | 1301 | |
|---|
| 1256 | 1302 | vcdev->is_thinint = virtio_ccw_use_airq; /* at least try */ |
|---|
| 1257 | 1303 | |
|---|
| 1258 | | - vcdev->vdev.dev.parent = &cdev->dev; |
|---|
| 1259 | 1304 | vcdev->vdev.dev.release = virtio_ccw_release_dev; |
|---|
| 1260 | 1305 | vcdev->vdev.config = &virtio_ccw_config_ops; |
|---|
| 1261 | | - vcdev->cdev = cdev; |
|---|
| 1262 | 1306 | init_waitqueue_head(&vcdev->wait_q); |
|---|
| 1263 | 1307 | INIT_LIST_HEAD(&vcdev->virtqueues); |
|---|
| 1264 | 1308 | spin_lock_init(&vcdev->lock); |
|---|
| .. | .. |
|---|
| 1289 | 1333 | return ret; |
|---|
| 1290 | 1334 | out_free: |
|---|
| 1291 | 1335 | if (vcdev) { |
|---|
| 1292 | | - kfree(vcdev->status); |
|---|
| 1293 | | - kfree(vcdev->config_block); |
|---|
| 1336 | + ccw_device_dma_free(vcdev->cdev, vcdev->dma_area, |
|---|
| 1337 | + sizeof(*vcdev->dma_area)); |
|---|
| 1294 | 1338 | } |
|---|
| 1295 | 1339 | kfree(vcdev); |
|---|
| 1296 | 1340 | return ret; |
|---|
| .. | .. |
|---|
| 1328 | 1372 | {}, |
|---|
| 1329 | 1373 | }; |
|---|
| 1330 | 1374 | |
|---|
| 1331 | | -#ifdef CONFIG_PM_SLEEP |
|---|
| 1332 | | -static int virtio_ccw_freeze(struct ccw_device *cdev) |
|---|
| 1333 | | -{ |
|---|
| 1334 | | - struct virtio_ccw_device *vcdev = dev_get_drvdata(&cdev->dev); |
|---|
| 1335 | | - |
|---|
| 1336 | | - return virtio_device_freeze(&vcdev->vdev); |
|---|
| 1337 | | -} |
|---|
| 1338 | | - |
|---|
| 1339 | | -static int virtio_ccw_restore(struct ccw_device *cdev) |
|---|
| 1340 | | -{ |
|---|
| 1341 | | - struct virtio_ccw_device *vcdev = dev_get_drvdata(&cdev->dev); |
|---|
| 1342 | | - int ret; |
|---|
| 1343 | | - |
|---|
| 1344 | | - ret = virtio_ccw_set_transport_rev(vcdev); |
|---|
| 1345 | | - if (ret) |
|---|
| 1346 | | - return ret; |
|---|
| 1347 | | - |
|---|
| 1348 | | - return virtio_device_restore(&vcdev->vdev); |
|---|
| 1349 | | -} |
|---|
| 1350 | | -#endif |
|---|
| 1351 | | - |
|---|
| 1352 | 1375 | static struct ccw_driver virtio_ccw_driver = { |
|---|
| 1353 | 1376 | .driver = { |
|---|
| 1354 | 1377 | .owner = THIS_MODULE, |
|---|
| .. | .. |
|---|
| 1361 | 1384 | .set_online = virtio_ccw_online, |
|---|
| 1362 | 1385 | .notify = virtio_ccw_cio_notify, |
|---|
| 1363 | 1386 | .int_class = IRQIO_VIR, |
|---|
| 1364 | | -#ifdef CONFIG_PM_SLEEP |
|---|
| 1365 | | - .freeze = virtio_ccw_freeze, |
|---|
| 1366 | | - .thaw = virtio_ccw_restore, |
|---|
| 1367 | | - .restore = virtio_ccw_restore, |
|---|
| 1368 | | -#endif |
|---|
| 1369 | 1387 | }; |
|---|
| 1370 | 1388 | |
|---|
| 1371 | 1389 | static int __init pure_hex(char **cp, unsigned int *val, int min_digit, |
|---|
| .. | .. |
|---|
| 1460 | 1478 | |
|---|
| 1461 | 1479 | static int __init virtio_ccw_init(void) |
|---|
| 1462 | 1480 | { |
|---|
| 1481 | + int rc; |
|---|
| 1482 | + |
|---|
| 1463 | 1483 | /* parse no_auto string before we do anything further */ |
|---|
| 1464 | 1484 | no_auto_parse(); |
|---|
| 1465 | | - return ccw_driver_register(&virtio_ccw_driver); |
|---|
| 1485 | + |
|---|
| 1486 | + summary_indicators = cio_dma_zalloc(MAX_AIRQ_AREAS); |
|---|
| 1487 | + if (!summary_indicators) |
|---|
| 1488 | + return -ENOMEM; |
|---|
| 1489 | + rc = ccw_driver_register(&virtio_ccw_driver); |
|---|
| 1490 | + if (rc) |
|---|
| 1491 | + cio_dma_free(summary_indicators, MAX_AIRQ_AREAS); |
|---|
| 1492 | + return rc; |
|---|
| 1466 | 1493 | } |
|---|
| 1467 | 1494 | device_initcall(virtio_ccw_init); |
|---|