Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/gm12u320: Set struct drm_device.dma_dev

Set the dma_dev field provided by the DRM device. Required for PRIME
dma-buf import. Remove the driver's implementation.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250307080836.42848-4-tzimmermann@suse.de

+13 -33
+13 -33
drivers/gpu/drm/tiny/gm12u320.c
··· 86 86 87 87 struct gm12u320_device { 88 88 struct drm_device dev; 89 - struct device *dmadev; 90 89 struct drm_simple_display_pipe pipe; 91 90 struct drm_connector conn; 92 91 unsigned char *cmd_buf; ··· 601 602 DRM_FORMAT_MOD_INVALID 602 603 }; 603 604 604 - /* 605 - * FIXME: Dma-buf sharing requires DMA support by the importing device. 606 - * This function is a workaround to make USB devices work as well. 607 - * See todo.rst for how to fix the issue in the dma-buf framework. 608 - */ 609 - static struct drm_gem_object *gm12u320_gem_prime_import(struct drm_device *dev, 610 - struct dma_buf *dma_buf) 611 - { 612 - struct gm12u320_device *gm12u320 = to_gm12u320(dev); 613 - 614 - if (!gm12u320->dmadev) 615 - return ERR_PTR(-ENODEV); 616 - 617 - return drm_gem_prime_import_dev(dev, dma_buf, gm12u320->dmadev); 618 - } 619 - 620 605 DEFINE_DRM_GEM_FOPS(gm12u320_fops); 621 606 622 607 static const struct drm_driver gm12u320_drm_driver = { ··· 613 630 614 631 .fops = &gm12u320_fops, 615 632 DRM_GEM_SHMEM_DRIVER_OPS, 616 - .gem_prime_import = gm12u320_gem_prime_import, 617 633 DRM_FBDEV_SHMEM_DRIVER_OPS, 618 634 }; 619 635 ··· 627 645 { 628 646 struct gm12u320_device *gm12u320; 629 647 struct drm_device *dev; 648 + struct device *dma_dev; 630 649 int ret; 631 650 632 651 /* ··· 643 660 return PTR_ERR(gm12u320); 644 661 dev = &gm12u320->dev; 645 662 646 - gm12u320->dmadev = usb_intf_get_dma_device(to_usb_interface(dev->dev)); 647 - if (!gm12u320->dmadev) 663 + dma_dev = usb_intf_get_dma_device(interface); 664 + if (dma_dev) { 665 + drm_dev_set_dma_dev(dev, dma_dev); 666 + put_device(dma_dev); 667 + } else { 648 668 drm_warn(dev, "buffer sharing not supported"); /* not an error */ 669 + } 649 670 650 671 INIT_DELAYED_WORK(&gm12u320->fb_update.work, gm12u320_fb_update_work); 651 672 mutex_init(&gm12u320->fb_update.lock); 652 673 653 674 ret = drmm_mode_config_init(dev); 654 675 if (ret) 655 - goto err_put_device; 676 + return ret; 656 677 657 678 dev->mode_config.min_width = GM12U320_USER_WIDTH; 658 679 dev->mode_config.max_width = GM12U320_USER_WIDTH; ··· 666 679 667 680 ret = gm12u320_usb_alloc(gm12u320); 668 681 if (ret) 669 - goto err_put_device; 682 + return ret; 670 683 671 684 ret = gm12u320_set_ecomode(gm12u320); 672 685 if (ret) 673 - goto err_put_device; 686 + return ret; 674 687 675 688 ret = gm12u320_conn_init(gm12u320); 676 689 if (ret) 677 - goto err_put_device; 690 + return ret; 678 691 679 692 ret = drm_simple_display_pipe_init(&gm12u320->dev, 680 693 &gm12u320->pipe, ··· 684 697 gm12u320_pipe_modifiers, 685 698 &gm12u320->conn); 686 699 if (ret) 687 - goto err_put_device; 700 + return ret; 688 701 689 702 drm_mode_config_reset(dev); 690 703 691 704 usb_set_intfdata(interface, dev); 692 705 ret = drm_dev_register(dev, 0); 693 706 if (ret) 694 - goto err_put_device; 707 + return ret; 695 708 696 709 drm_client_setup(dev, NULL); 697 710 698 711 return 0; 699 - 700 - err_put_device: 701 - put_device(gm12u320->dmadev); 702 - return ret; 703 712 } 704 713 705 714 static void gm12u320_usb_disconnect(struct usb_interface *interface) 706 715 { 707 716 struct drm_device *dev = usb_get_intfdata(interface); 708 - struct gm12u320_device *gm12u320 = to_gm12u320(dev); 709 717 710 - put_device(gm12u320->dmadev); 711 - gm12u320->dmadev = NULL; 712 718 drm_dev_unplug(dev); 713 719 drm_atomic_helper_shutdown(dev); 714 720 }