1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * Copyright (C) 2015-2018 Etnaviv Project 4 */ 5 6 #include <linux/component.h> 7 #include <linux/dma-mapping.h> 8 #include <linux/module.h> 9 #include <linux/of_platform.h> 10 #include <linux/uaccess.h> 11 12 #include <drm/drm_debugfs.h> 13 #include <drm/drm_drv.h> 14 #include <drm/drm_file.h> 15 #include <drm/drm_ioctl.h> 16 #include <drm/drm_of.h> 17 #include <drm/drm_prime.h> 18 19 #include "etnaviv_cmdbuf.h" 20 #include "etnaviv_drv.h" 21 #include "etnaviv_gpu.h" 22 #include "etnaviv_gem.h" 23 #include "etnaviv_mmu.h" 24 #include "etnaviv_perfmon.h" 25 26 /* 27 * DRM operations: 28 */ 29 30 31 static void load_gpu(struct drm_device *dev) 32 { 33 struct etnaviv_drm_private *priv = dev->dev_private; 34 unsigned int i; 35 36 for (i = 0; i < ETNA_MAX_PIPES; i++) { 37 struct etnaviv_gpu *g = priv->gpu[i]; 38 39 if (g) { 40 int ret; 41 42 ret = etnaviv_gpu_init(g); 43 if (ret) 44 priv->gpu[i] = NULL; 45 } 46 } 47 } 48 49 static int etnaviv_open(struct drm_device *dev, struct drm_file *file) 50 { 51 struct etnaviv_drm_private *priv = dev->dev_private; 52 struct etnaviv_file_private *ctx; 53 int ret, i; 54 55 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); 56 if (!ctx) 57 return -ENOMEM; 58 59 ctx->mmu = etnaviv_iommu_context_init(priv->mmu_global, 60 priv->cmdbuf_suballoc); 61 if (!ctx->mmu) { 62 ret = -ENOMEM; 63 goto out_free; 64 } 65 66 for (i = 0; i < ETNA_MAX_PIPES; i++) { 67 struct etnaviv_gpu *gpu = priv->gpu[i]; 68 struct drm_sched_rq *rq; 69 70 if (gpu) { 71 rq = &gpu->sched.sched_rq[DRM_SCHED_PRIORITY_NORMAL]; 72 drm_sched_entity_init(&ctx->sched_entity[i], 73 &rq, 1, NULL); 74 } 75 } 76 77 file->driver_priv = ctx; 78 79 return 0; 80 81 out_free: 82 kfree(ctx); 83 return ret; 84 } 85 86 static void etnaviv_postclose(struct drm_device *dev, struct drm_file *file) 87 { 88 struct etnaviv_drm_private *priv = dev->dev_private; 89 struct etnaviv_file_private *ctx = file->driver_priv; 90 unsigned int i; 91 92 for (i = 0; i < ETNA_MAX_PIPES; i++) { 93 struct etnaviv_gpu *gpu = priv->gpu[i]; 94 95 if (gpu) 96 drm_sched_entity_destroy(&ctx->sched_entity[i]); 97 } 98 99 etnaviv_iommu_context_put(ctx->mmu); 100 101 kfree(ctx); 102 } 103 104 /* 105 * DRM debugfs: 106 */ 107 108 #ifdef CONFIG_DEBUG_FS 109 static int etnaviv_gem_show(struct drm_device *dev, struct seq_file *m) 110 { 111 struct etnaviv_drm_private *priv = dev->dev_private; 112 113 etnaviv_gem_describe_objects(priv, m); 114 115 return 0; 116 } 117 118 static int etnaviv_mm_show(struct drm_device *dev, struct seq_file *m) 119 { 120 struct drm_printer p = drm_seq_file_printer(m); 121 122 read_lock(&dev->vma_offset_manager->vm_lock); 123 drm_mm_print(&dev->vma_offset_manager->vm_addr_space_mm, &p); 124 read_unlock(&dev->vma_offset_manager->vm_lock); 125 126 return 0; 127 } 128 129 static int etnaviv_mmu_show(struct etnaviv_gpu *gpu, struct seq_file *m) 130 { 131 struct drm_printer p = drm_seq_file_printer(m); 132 struct etnaviv_iommu_context *mmu_context; 133 134 seq_printf(m, "Active Objects (%s):\n", dev_name(gpu->dev)); 135 136 /* 137 * Lock the GPU to avoid a MMU context switch just now and elevate 138 * the refcount of the current context to avoid it disappearing from 139 * under our feet. 140 */ 141 mutex_lock(&gpu->lock); 142 mmu_context = gpu->mmu_context; 143 if (mmu_context) 144 etnaviv_iommu_context_get(mmu_context); 145 mutex_unlock(&gpu->lock); 146 147 if (!mmu_context) 148 return 0; 149 150 mutex_lock(&mmu_context->lock); 151 drm_mm_print(&mmu_context->mm, &p); 152 mutex_unlock(&mmu_context->lock); 153 154 etnaviv_iommu_context_put(mmu_context); 155 156 return 0; 157 } 158 159 static void etnaviv_buffer_dump(struct etnaviv_gpu *gpu, struct seq_file *m) 160 { 161 struct etnaviv_cmdbuf *buf = &gpu->buffer; 162 u32 size = buf->size; 163 u32 *ptr = buf->vaddr; 164 u32 i; 165 166 seq_printf(m, "virt %p - phys 0x%llx - free 0x%08x\n", 167 buf->vaddr, (u64)etnaviv_cmdbuf_get_pa(buf), 168 size - buf->user_size); 169 170 for (i = 0; i < size / 4; i++) { 171 if (i && !(i % 4)) 172 seq_puts(m, "\n"); 173 if (i % 4 == 0) 174 seq_printf(m, "\t0x%p: ", ptr + i); 175 seq_printf(m, "%08x ", *(ptr + i)); 176 } 177 seq_puts(m, "\n"); 178 } 179 180 static int etnaviv_ring_show(struct etnaviv_gpu *gpu, struct seq_file *m) 181 { 182 seq_printf(m, "Ring Buffer (%s): ", dev_name(gpu->dev)); 183 184 mutex_lock(&gpu->lock); 185 etnaviv_buffer_dump(gpu, m); 186 mutex_unlock(&gpu->lock); 187 188 return 0; 189 } 190 191 static int show_unlocked(struct seq_file *m, void *arg) 192 { 193 struct drm_info_node *node = (struct drm_info_node *) m->private; 194 struct drm_device *dev = node->minor->dev; 195 int (*show)(struct drm_device *dev, struct seq_file *m) = 196 node->info_ent->data; 197 198 return show(dev, m); 199 } 200 201 static int show_each_gpu(struct seq_file *m, void *arg) 202 { 203 struct drm_info_node *node = (struct drm_info_node *) m->private; 204 struct drm_device *dev = node->minor->dev; 205 struct etnaviv_drm_private *priv = dev->dev_private; 206 struct etnaviv_gpu *gpu; 207 int (*show)(struct etnaviv_gpu *gpu, struct seq_file *m) = 208 node->info_ent->data; 209 unsigned int i; 210 int ret = 0; 211 212 for (i = 0; i < ETNA_MAX_PIPES; i++) { 213 gpu = priv->gpu[i]; 214 if (!gpu) 215 continue; 216 217 ret = show(gpu, m); 218 if (ret < 0) 219 break; 220 } 221 222 return ret; 223 } 224 225 static struct drm_info_list etnaviv_debugfs_list[] = { 226 {"gpu", show_each_gpu, 0, etnaviv_gpu_debugfs}, 227 {"gem", show_unlocked, 0, etnaviv_gem_show}, 228 { "mm", show_unlocked, 0, etnaviv_mm_show }, 229 {"mmu", show_each_gpu, 0, etnaviv_mmu_show}, 230 {"ring", show_each_gpu, 0, etnaviv_ring_show}, 231 }; 232 233 static int etnaviv_debugfs_init(struct drm_minor *minor) 234 { 235 struct drm_device *dev = minor->dev; 236 int ret; 237 238 ret = drm_debugfs_create_files(etnaviv_debugfs_list, 239 ARRAY_SIZE(etnaviv_debugfs_list), 240 minor->debugfs_root, minor); 241 242 if (ret) { 243 dev_err(dev->dev, "could not install etnaviv_debugfs_list\n"); 244 return ret; 245 } 246 247 return ret; 248 } 249 #endif 250 251 /* 252 * DRM ioctls: 253 */ 254 255 static int etnaviv_ioctl_get_param(struct drm_device *dev, void *data, 256 struct drm_file *file) 257 { 258 struct etnaviv_drm_private *priv = dev->dev_private; 259 struct drm_etnaviv_param *args = data; 260 struct etnaviv_gpu *gpu; 261 262 if (args->pipe >= ETNA_MAX_PIPES) 263 return -EINVAL; 264 265 gpu = priv->gpu[args->pipe]; 266 if (!gpu) 267 return -ENXIO; 268 269 return etnaviv_gpu_get_param(gpu, args->param, &args->value); 270 } 271 272 static int etnaviv_ioctl_gem_new(struct drm_device *dev, void *data, 273 struct drm_file *file) 274 { 275 struct drm_etnaviv_gem_new *args = data; 276 277 if (args->flags & ~(ETNA_BO_CACHED | ETNA_BO_WC | ETNA_BO_UNCACHED | 278 ETNA_BO_FORCE_MMU)) 279 return -EINVAL; 280 281 return etnaviv_gem_new_handle(dev, file, args->size, 282 args->flags, &args->handle); 283 } 284 285 static int etnaviv_ioctl_gem_cpu_prep(struct drm_device *dev, void *data, 286 struct drm_file *file) 287 { 288 struct drm_etnaviv_gem_cpu_prep *args = data; 289 struct drm_gem_object *obj; 290 int ret; 291 292 if (args->op & ~(ETNA_PREP_READ | ETNA_PREP_WRITE | ETNA_PREP_NOSYNC)) 293 return -EINVAL; 294 295 if (args->timeout.tv_nsec > NSEC_PER_SEC) 296 return -EINVAL; 297 298 obj = drm_gem_object_lookup(file, args->handle); 299 if (!obj) 300 return -ENOENT; 301 302 ret = etnaviv_gem_cpu_prep(obj, args->op, &args->timeout); 303 304 drm_gem_object_put_unlocked(obj); 305 306 return ret; 307 } 308 309 static int etnaviv_ioctl_gem_cpu_fini(struct drm_device *dev, void *data, 310 struct drm_file *file) 311 { 312 struct drm_etnaviv_gem_cpu_fini *args = data; 313 struct drm_gem_object *obj; 314 int ret; 315 316 if (args->flags) 317 return -EINVAL; 318 319 obj = drm_gem_object_lookup(file, args->handle); 320 if (!obj) 321 return -ENOENT; 322 323 ret = etnaviv_gem_cpu_fini(obj); 324 325 drm_gem_object_put_unlocked(obj); 326 327 return ret; 328 } 329 330 static int etnaviv_ioctl_gem_info(struct drm_device *dev, void *data, 331 struct drm_file *file) 332 { 333 struct drm_etnaviv_gem_info *args = data; 334 struct drm_gem_object *obj; 335 int ret; 336 337 if (args->pad) 338 return -EINVAL; 339 340 obj = drm_gem_object_lookup(file, args->handle); 341 if (!obj) 342 return -ENOENT; 343 344 ret = etnaviv_gem_mmap_offset(obj, &args->offset); 345 drm_gem_object_put_unlocked(obj); 346 347 return ret; 348 } 349 350 static int etnaviv_ioctl_wait_fence(struct drm_device *dev, void *data, 351 struct drm_file *file) 352 { 353 struct drm_etnaviv_wait_fence *args = data; 354 struct etnaviv_drm_private *priv = dev->dev_private; 355 struct drm_etnaviv_timespec *timeout = &args->timeout; 356 struct etnaviv_gpu *gpu; 357 358 if (args->flags & ~(ETNA_WAIT_NONBLOCK)) 359 return -EINVAL; 360 361 if (args->timeout.tv_nsec > NSEC_PER_SEC) 362 return -EINVAL; 363 364 if (args->pipe >= ETNA_MAX_PIPES) 365 return -EINVAL; 366 367 gpu = priv->gpu[args->pipe]; 368 if (!gpu) 369 return -ENXIO; 370 371 if (args->flags & ETNA_WAIT_NONBLOCK) 372 timeout = NULL; 373 374 return etnaviv_gpu_wait_fence_interruptible(gpu, args->fence, 375 timeout); 376 } 377 378 static int etnaviv_ioctl_gem_userptr(struct drm_device *dev, void *data, 379 struct drm_file *file) 380 { 381 struct drm_etnaviv_gem_userptr *args = data; 382 383 if (args->flags & ~(ETNA_USERPTR_READ|ETNA_USERPTR_WRITE) || 384 args->flags == 0) 385 return -EINVAL; 386 387 if (offset_in_page(args->user_ptr | args->user_size) || 388 (uintptr_t)args->user_ptr != args->user_ptr || 389 (u32)args->user_size != args->user_size || 390 args->user_ptr & ~PAGE_MASK) 391 return -EINVAL; 392 393 if (!access_ok((void __user *)(unsigned long)args->user_ptr, 394 args->user_size)) 395 return -EFAULT; 396 397 return etnaviv_gem_new_userptr(dev, file, args->user_ptr, 398 args->user_size, args->flags, 399 &args->handle); 400 } 401 402 static int etnaviv_ioctl_gem_wait(struct drm_device *dev, void *data, 403 struct drm_file *file) 404 { 405 struct etnaviv_drm_private *priv = dev->dev_private; 406 struct drm_etnaviv_gem_wait *args = data; 407 struct drm_etnaviv_timespec *timeout = &args->timeout; 408 struct drm_gem_object *obj; 409 struct etnaviv_gpu *gpu; 410 int ret; 411 412 if (args->flags & ~(ETNA_WAIT_NONBLOCK)) 413 return -EINVAL; 414 415 if (args->timeout.tv_nsec > NSEC_PER_SEC) 416 return -EINVAL; 417 418 if (args->pipe >= ETNA_MAX_PIPES) 419 return -EINVAL; 420 421 gpu = priv->gpu[args->pipe]; 422 if (!gpu) 423 return -ENXIO; 424 425 obj = drm_gem_object_lookup(file, args->handle); 426 if (!obj) 427 return -ENOENT; 428 429 if (args->flags & ETNA_WAIT_NONBLOCK) 430 timeout = NULL; 431 432 ret = etnaviv_gem_wait_bo(gpu, obj, timeout); 433 434 drm_gem_object_put_unlocked(obj); 435 436 return ret; 437 } 438 439 static int etnaviv_ioctl_pm_query_dom(struct drm_device *dev, void *data, 440 struct drm_file *file) 441 { 442 struct etnaviv_drm_private *priv = dev->dev_private; 443 struct drm_etnaviv_pm_domain *args = data; 444 struct etnaviv_gpu *gpu; 445 446 if (args->pipe >= ETNA_MAX_PIPES) 447 return -EINVAL; 448 449 gpu = priv->gpu[args->pipe]; 450 if (!gpu) 451 return -ENXIO; 452 453 return etnaviv_pm_query_dom(gpu, args); 454 } 455 456 static int etnaviv_ioctl_pm_query_sig(struct drm_device *dev, void *data, 457 struct drm_file *file) 458 { 459 struct etnaviv_drm_private *priv = dev->dev_private; 460 struct drm_etnaviv_pm_signal *args = data; 461 struct etnaviv_gpu *gpu; 462 463 if (args->pipe >= ETNA_MAX_PIPES) 464 return -EINVAL; 465 466 gpu = priv->gpu[args->pipe]; 467 if (!gpu) 468 return -ENXIO; 469 470 return etnaviv_pm_query_sig(gpu, args); 471 } 472 473 static const struct drm_ioctl_desc etnaviv_ioctls[] = { 474 #define ETNA_IOCTL(n, func, flags) \ 475 DRM_IOCTL_DEF_DRV(ETNAVIV_##n, etnaviv_ioctl_##func, flags) 476 ETNA_IOCTL(GET_PARAM, get_param, DRM_RENDER_ALLOW), 477 ETNA_IOCTL(GEM_NEW, gem_new, DRM_RENDER_ALLOW), 478 ETNA_IOCTL(GEM_INFO, gem_info, DRM_RENDER_ALLOW), 479 ETNA_IOCTL(GEM_CPU_PREP, gem_cpu_prep, DRM_RENDER_ALLOW), 480 ETNA_IOCTL(GEM_CPU_FINI, gem_cpu_fini, DRM_RENDER_ALLOW), 481 ETNA_IOCTL(GEM_SUBMIT, gem_submit, DRM_RENDER_ALLOW), 482 ETNA_IOCTL(WAIT_FENCE, wait_fence, DRM_RENDER_ALLOW), 483 ETNA_IOCTL(GEM_USERPTR, gem_userptr, DRM_RENDER_ALLOW), 484 ETNA_IOCTL(GEM_WAIT, gem_wait, DRM_RENDER_ALLOW), 485 ETNA_IOCTL(PM_QUERY_DOM, pm_query_dom, DRM_RENDER_ALLOW), 486 ETNA_IOCTL(PM_QUERY_SIG, pm_query_sig, DRM_RENDER_ALLOW), 487 }; 488 489 static const struct vm_operations_struct vm_ops = { 490 .fault = etnaviv_gem_fault, 491 .open = drm_gem_vm_open, 492 .close = drm_gem_vm_close, 493 }; 494 495 static const struct file_operations fops = { 496 .owner = THIS_MODULE, 497 .open = drm_open, 498 .release = drm_release, 499 .unlocked_ioctl = drm_ioctl, 500 .compat_ioctl = drm_compat_ioctl, 501 .poll = drm_poll, 502 .read = drm_read, 503 .llseek = no_llseek, 504 .mmap = etnaviv_gem_mmap, 505 }; 506 507 static struct drm_driver etnaviv_drm_driver = { 508 .driver_features = DRIVER_GEM | DRIVER_RENDER, 509 .open = etnaviv_open, 510 .postclose = etnaviv_postclose, 511 .gem_free_object_unlocked = etnaviv_gem_free_object, 512 .gem_vm_ops = &vm_ops, 513 .prime_handle_to_fd = drm_gem_prime_handle_to_fd, 514 .prime_fd_to_handle = drm_gem_prime_fd_to_handle, 515 .gem_prime_pin = etnaviv_gem_prime_pin, 516 .gem_prime_unpin = etnaviv_gem_prime_unpin, 517 .gem_prime_get_sg_table = etnaviv_gem_prime_get_sg_table, 518 .gem_prime_import_sg_table = etnaviv_gem_prime_import_sg_table, 519 .gem_prime_vmap = etnaviv_gem_prime_vmap, 520 .gem_prime_vunmap = etnaviv_gem_prime_vunmap, 521 .gem_prime_mmap = etnaviv_gem_prime_mmap, 522 #ifdef CONFIG_DEBUG_FS 523 .debugfs_init = etnaviv_debugfs_init, 524 #endif 525 .ioctls = etnaviv_ioctls, 526 .num_ioctls = DRM_ETNAVIV_NUM_IOCTLS, 527 .fops = &fops, 528 .name = "etnaviv", 529 .desc = "etnaviv DRM", 530 .date = "20151214", 531 .major = 1, 532 .minor = 3, 533 }; 534 535 /* 536 * Platform driver: 537 */ 538 static int etnaviv_bind(struct device *dev) 539 { 540 struct etnaviv_drm_private *priv; 541 struct drm_device *drm; 542 int ret; 543 544 drm = drm_dev_alloc(&etnaviv_drm_driver, dev); 545 if (IS_ERR(drm)) 546 return PTR_ERR(drm); 547 548 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 549 if (!priv) { 550 dev_err(dev, "failed to allocate private data\n"); 551 ret = -ENOMEM; 552 goto out_put; 553 } 554 drm->dev_private = priv; 555 556 dev->dma_parms = &priv->dma_parms; 557 dma_set_max_seg_size(dev, SZ_2G); 558 559 mutex_init(&priv->gem_lock); 560 INIT_LIST_HEAD(&priv->gem_list); 561 priv->num_gpus = 0; 562 563 priv->cmdbuf_suballoc = etnaviv_cmdbuf_suballoc_new(drm->dev); 564 if (IS_ERR(priv->cmdbuf_suballoc)) { 565 dev_err(drm->dev, "Failed to create cmdbuf suballocator\n"); 566 ret = PTR_ERR(priv->cmdbuf_suballoc); 567 goto out_free_priv; 568 } 569 570 dev_set_drvdata(dev, drm); 571 572 ret = component_bind_all(dev, drm); 573 if (ret < 0) 574 goto out_destroy_suballoc; 575 576 load_gpu(drm); 577 578 ret = drm_dev_register(drm, 0); 579 if (ret) 580 goto out_unbind; 581 582 return 0; 583 584 out_unbind: 585 component_unbind_all(dev, drm); 586 out_destroy_suballoc: 587 etnaviv_cmdbuf_suballoc_destroy(priv->cmdbuf_suballoc); 588 out_free_priv: 589 kfree(priv); 590 out_put: 591 drm_dev_put(drm); 592 593 return ret; 594 } 595 596 static void etnaviv_unbind(struct device *dev) 597 { 598 struct drm_device *drm = dev_get_drvdata(dev); 599 struct etnaviv_drm_private *priv = drm->dev_private; 600 601 drm_dev_unregister(drm); 602 603 component_unbind_all(dev, drm); 604 605 dev->dma_parms = NULL; 606 607 etnaviv_cmdbuf_suballoc_destroy(priv->cmdbuf_suballoc); 608 609 drm->dev_private = NULL; 610 kfree(priv); 611 612 drm_dev_put(drm); 613 } 614 615 static const struct component_master_ops etnaviv_master_ops = { 616 .bind = etnaviv_bind, 617 .unbind = etnaviv_unbind, 618 }; 619 620 static int compare_of(struct device *dev, void *data) 621 { 622 struct device_node *np = data; 623 624 return dev->of_node == np; 625 } 626 627 static int compare_str(struct device *dev, void *data) 628 { 629 return !strcmp(dev_name(dev), data); 630 } 631 632 static int etnaviv_pdev_probe(struct platform_device *pdev) 633 { 634 struct device *dev = &pdev->dev; 635 struct component_match *match = NULL; 636 637 if (!dev->platform_data) { 638 struct device_node *core_node; 639 640 for_each_compatible_node(core_node, NULL, "vivante,gc") { 641 if (!of_device_is_available(core_node)) 642 continue; 643 644 drm_of_component_match_add(&pdev->dev, &match, 645 compare_of, core_node); 646 } 647 } else { 648 char **names = dev->platform_data; 649 unsigned i; 650 651 for (i = 0; names[i]; i++) 652 component_match_add(dev, &match, compare_str, names[i]); 653 } 654 655 return component_master_add_with_match(dev, &etnaviv_master_ops, match); 656 } 657 658 static int etnaviv_pdev_remove(struct platform_device *pdev) 659 { 660 component_master_del(&pdev->dev, &etnaviv_master_ops); 661 662 return 0; 663 } 664 665 static struct platform_driver etnaviv_platform_driver = { 666 .probe = etnaviv_pdev_probe, 667 .remove = etnaviv_pdev_remove, 668 .driver = { 669 .name = "etnaviv", 670 }, 671 }; 672 673 static struct platform_device *etnaviv_drm; 674 675 static int __init etnaviv_init(void) 676 { 677 struct platform_device *pdev; 678 int ret; 679 struct device_node *np; 680 681 etnaviv_validate_init(); 682 683 ret = platform_driver_register(&etnaviv_gpu_driver); 684 if (ret != 0) 685 return ret; 686 687 ret = platform_driver_register(&etnaviv_platform_driver); 688 if (ret != 0) 689 goto unregister_gpu_driver; 690 691 /* 692 * If the DT contains at least one available GPU device, instantiate 693 * the DRM platform device. 694 */ 695 for_each_compatible_node(np, NULL, "vivante,gc") { 696 if (!of_device_is_available(np)) 697 continue; 698 699 pdev = platform_device_alloc("etnaviv", -1); 700 if (!pdev) { 701 ret = -ENOMEM; 702 of_node_put(np); 703 goto unregister_platform_driver; 704 } 705 pdev->dev.coherent_dma_mask = DMA_BIT_MASK(40); 706 pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; 707 708 /* 709 * Apply the same DMA configuration to the virtual etnaviv 710 * device as the GPU we found. This assumes that all Vivante 711 * GPUs in the system share the same DMA constraints. 712 */ 713 of_dma_configure(&pdev->dev, np, true); 714 715 ret = platform_device_add(pdev); 716 if (ret) { 717 platform_device_put(pdev); 718 of_node_put(np); 719 goto unregister_platform_driver; 720 } 721 722 etnaviv_drm = pdev; 723 of_node_put(np); 724 break; 725 } 726 727 return 0; 728 729 unregister_platform_driver: 730 platform_driver_unregister(&etnaviv_platform_driver); 731 unregister_gpu_driver: 732 platform_driver_unregister(&etnaviv_gpu_driver); 733 return ret; 734 } 735 module_init(etnaviv_init); 736 737 static void __exit etnaviv_exit(void) 738 { 739 platform_device_unregister(etnaviv_drm); 740 platform_driver_unregister(&etnaviv_platform_driver); 741 platform_driver_unregister(&etnaviv_gpu_driver); 742 } 743 module_exit(etnaviv_exit); 744 745 MODULE_AUTHOR("Christian Gmeiner <christian.gmeiner@gmail.com>"); 746 MODULE_AUTHOR("Russell King <rmk+kernel@arm.linux.org.uk>"); 747 MODULE_AUTHOR("Lucas Stach <l.stach@pengutronix.de>"); 748 MODULE_DESCRIPTION("etnaviv DRM Driver"); 749 MODULE_LICENSE("GPL v2"); 750 MODULE_ALIAS("platform:etnaviv"); 751