drm/tinydrm: Use DRM_GEM_CMA_VMAP_DRIVER_OPS
authorNoralf Trønnes <noralf@tronnes.org>
Sat, 10 Nov 2018 14:56:47 +0000 (15:56 +0100)
committerNoralf Trønnes <noralf@tronnes.org>
Tue, 20 Nov 2018 13:58:19 +0000 (14:58 +0100)
The CMA helper now has the functionality to ensure a virtual address on
imported buffer so use that.

While touching all tinydrm drivers, remove the unnecessary inclusion of
drm_fb_helper.h in some drivers.

Cc: David Lechner <david@lechnology.com>
Cc: Eric Anholt <eric@anholt.net>
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Acked-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Link: https://patchwork.freedesktop.org/patch/msgid/20181110145647.17580-6-noralf@tronnes.org
drivers/gpu/drm/tinydrm/core/tinydrm-core.c
drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
drivers/gpu/drm/tinydrm/hx8357d.c
drivers/gpu/drm/tinydrm/ili9225.c
drivers/gpu/drm/tinydrm/ili9341.c
drivers/gpu/drm/tinydrm/mi0283qt.c
drivers/gpu/drm/tinydrm/mipi-dbi.c
drivers/gpu/drm/tinydrm/repaper.c
drivers/gpu/drm/tinydrm/st7586.c
drivers/gpu/drm/tinydrm/st7735r.c
include/drm/tinydrm/tinydrm.h

index 9af51d982a339d9491f44515d649258d2cbdd759..01a6f2d42440e0c2f3573698abfe6ea70f3408b1 100644 (file)
  * and registers the DRM device using devm_tinydrm_register().
  */
 
-/**
- * tinydrm_gem_cma_prime_import_sg_table - Produce a CMA GEM object from
- *     another driver's scatter/gather table of pinned pages
- * @drm: DRM device to import into
- * @attach: DMA-BUF attachment
- * @sgt: Scatter/gather table of pinned pages
- *
- * This function imports a scatter/gather table exported via DMA-BUF by
- * another driver using drm_gem_cma_prime_import_sg_table(). It sets the
- * kernel virtual address on the CMA object. Drivers should use this as their
- * &drm_driver->gem_prime_import_sg_table callback if they need the virtual
- * address. tinydrm_gem_cma_free_object() should be used in combination with
- * this function.
- *
- * Returns:
- * A pointer to a newly created GEM object or an ERR_PTR-encoded negative
- * error code on failure.
- */
-struct drm_gem_object *
-tinydrm_gem_cma_prime_import_sg_table(struct drm_device *drm,
-                                     struct dma_buf_attachment *attach,
-                                     struct sg_table *sgt)
-{
-       struct drm_gem_cma_object *cma_obj;
-       struct drm_gem_object *obj;
-       void *vaddr;
-
-       vaddr = dma_buf_vmap(attach->dmabuf);
-       if (!vaddr) {
-               DRM_ERROR("Failed to vmap PRIME buffer\n");
-               return ERR_PTR(-ENOMEM);
-       }
-
-       obj = drm_gem_cma_prime_import_sg_table(drm, attach, sgt);
-       if (IS_ERR(obj)) {
-               dma_buf_vunmap(attach->dmabuf, vaddr);
-               return obj;
-       }
-
-       cma_obj = to_drm_gem_cma_obj(obj);
-       cma_obj->vaddr = vaddr;
-
-       return obj;
-}
-EXPORT_SYMBOL(tinydrm_gem_cma_prime_import_sg_table);
-
-/**
- * tinydrm_gem_cma_free_object - Free resources associated with a CMA GEM
- *                               object
- * @gem_obj: GEM object to free
- *
- * This function frees the backing memory of the CMA GEM object, cleans up the
- * GEM object state and frees the memory used to store the object itself using
- * drm_gem_cma_free_object(). It also handles PRIME buffers which has the kernel
- * virtual address set by tinydrm_gem_cma_prime_import_sg_table(). Drivers
- * can use this as their &drm_driver->gem_free_object_unlocked callback.
- */
-void tinydrm_gem_cma_free_object(struct drm_gem_object *gem_obj)
-{
-       if (gem_obj->import_attach) {
-               struct drm_gem_cma_object *cma_obj;
-
-               cma_obj = to_drm_gem_cma_obj(gem_obj);
-               dma_buf_vunmap(gem_obj->import_attach->dmabuf, cma_obj->vaddr);
-               cma_obj->vaddr = NULL;
-       }
-
-       drm_gem_cma_free_object(gem_obj);
-}
-EXPORT_SYMBOL_GPL(tinydrm_gem_cma_free_object);
-
 static struct drm_framebuffer *
 tinydrm_fb_create(struct drm_device *drm, struct drm_file *file_priv,
                  const struct drm_mode_fb_cmd2 *mode_cmd)
index dcd390163a4a9bcef2e93185414c7444083e3d25..bf6bfbc5d412c8c2bb2e8a14fed1d16a139f1b88 100644 (file)
@@ -9,12 +9,18 @@
 
 #include <linux/backlight.h>
 #include <linux/dma-buf.h>
+#include <linux/module.h>
 #include <linux/pm.h>
 #include <linux/spi/spi.h>
 #include <linux/swab.h>
 
+#include <drm/drm_device.h>
+#include <drm/drm_drv.h>
+#include <drm/drm_fourcc.h>
+#include <drm/drm_print.h>
 #include <drm/tinydrm/tinydrm.h>
 #include <drm/tinydrm/tinydrm-helpers.h>
+#include <uapi/drm/drm.h>
 
 static unsigned int spi_max;
 module_param(spi_max, uint, 0400);
index c3e51c2baebc9c1f81a4fc7951fa59b5a9101a40..81a2bbeb25d41cc3c63388f3de50aa7b60f60a51 100644 (file)
@@ -16,7 +16,7 @@
 #include <linux/property.h>
 #include <linux/spi/spi.h>
 
-#include <drm/drm_fb_helper.h>
+#include <drm/drm_gem_cma_helper.h>
 #include <drm/drm_gem_framebuffer_helper.h>
 #include <drm/drm_modeset_helper.h>
 #include <drm/tinydrm/mipi-dbi.h>
@@ -188,7 +188,7 @@ DEFINE_DRM_GEM_CMA_FOPS(hx8357d_fops);
 static struct drm_driver hx8357d_driver = {
        .driver_features        = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_ATOMIC,
        .fops                   = &hx8357d_fops,
-       TINYDRM_GEM_DRIVER_OPS,
+       DRM_GEM_CMA_VMAP_DRIVER_OPS,
        .debugfs_init           = mipi_dbi_debugfs_init,
        .name                   = "hx8357d",
        .desc                   = "HX8357D",
index 455fefe012f5912e825b4296e8c96b0129b814ea..78f7c2d1b4494078ec42959e22afd5429b06080e 100644 (file)
@@ -20,7 +20,8 @@
 #include <linux/spi/spi.h>
 #include <video/mipi_display.h>
 
-#include <drm/drm_fb_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_gem_cma_helper.h>
 #include <drm/drm_gem_framebuffer_helper.h>
 #include <drm/tinydrm/mipi-dbi.h>
 #include <drm/tinydrm/tinydrm-helpers.h>
@@ -367,7 +368,7 @@ static struct drm_driver ili9225_driver = {
        .driver_features        = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME |
                                  DRIVER_ATOMIC,
        .fops                   = &ili9225_fops,
-       TINYDRM_GEM_DRIVER_OPS,
+       DRM_GEM_CMA_VMAP_DRIVER_OPS,
        .name                   = "ili9225",
        .desc                   = "Ilitek ILI9225",
        .date                   = "20171106",
index 6701037749a74f862f8993fc3c5d7c95d5c69282..51395bdc6ca22a731d5bf9cd70d4bc29ca1387d1 100644 (file)
@@ -15,7 +15,7 @@
 #include <linux/property.h>
 #include <linux/spi/spi.h>
 
-#include <drm/drm_fb_helper.h>
+#include <drm/drm_gem_cma_helper.h>
 #include <drm/drm_gem_framebuffer_helper.h>
 #include <drm/drm_modeset_helper.h>
 #include <drm/tinydrm/mipi-dbi.h>
@@ -144,7 +144,7 @@ DEFINE_DRM_GEM_CMA_FOPS(ili9341_fops);
 static struct drm_driver ili9341_driver = {
        .driver_features        = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_ATOMIC,
        .fops                   = &ili9341_fops,
-       TINYDRM_GEM_DRIVER_OPS,
+       DRM_GEM_CMA_VMAP_DRIVER_OPS,
        .debugfs_init           = mipi_dbi_debugfs_init,
        .name                   = "ili9341",
        .desc                   = "Ilitek ILI9341",
index d7bb4c5e6657a723e9ae03f2cd91e043c942b847..3fa62e77c30b2ceff4a3aeaf9c6f5b8d7eafce6a 100644 (file)
@@ -17,9 +17,9 @@
 #include <linux/regulator/consumer.h>
 #include <linux/spi/spi.h>
 
-#include <drm/drm_fb_helper.h>
-#include <drm/drm_modeset_helper.h>
+#include <drm/drm_gem_cma_helper.h>
 #include <drm/drm_gem_framebuffer_helper.h>
+#include <drm/drm_modeset_helper.h>
 #include <drm/tinydrm/mipi-dbi.h>
 #include <drm/tinydrm/tinydrm-helpers.h>
 #include <video/mipi_display.h>
@@ -153,7 +153,7 @@ static struct drm_driver mi0283qt_driver = {
        .driver_features        = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME |
                                  DRIVER_ATOMIC,
        .fops                   = &mi0283qt_fops,
-       TINYDRM_GEM_DRIVER_OPS,
+       DRM_GEM_CMA_VMAP_DRIVER_OPS,
        .debugfs_init           = mipi_dbi_debugfs_init,
        .name                   = "mi0283qt",
        .desc                   = "Multi-Inno MI0283QT",
index 1bb870021f6e46ec22d3117090b87ef3a2068e37..3a05e56f9b0d81c0cd15780478927086ee3af3c9 100644 (file)
@@ -9,15 +9,19 @@
  * (at your option) any later version.
  */
 
-#include <drm/drm_gem_framebuffer_helper.h>
-#include <drm/tinydrm/mipi-dbi.h>
-#include <drm/tinydrm/tinydrm-helpers.h>
 #include <linux/debugfs.h>
 #include <linux/dma-buf.h>
 #include <linux/gpio/consumer.h>
 #include <linux/module.h>
 #include <linux/regulator/consumer.h>
 #include <linux/spi/spi.h>
+
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+#include <drm/drm_gem_framebuffer_helper.h>
+#include <drm/tinydrm/mipi-dbi.h>
+#include <drm/tinydrm/tinydrm-helpers.h>
+#include <uapi/drm/drm.h>
 #include <video/mipi_display.h>
 
 #define MIPI_DBI_MAX_SPI_READ_SPEED 2000000 /* 2MHz */
index 50a1d4216ce782ff2327ce7ad043fe3af9ee8092..07f45a008a0f7c208b2f88b4b0a3d536e9e9b3db 100644 (file)
@@ -26,6 +26,8 @@
 #include <linux/spi/spi.h>
 #include <linux/thermal.h>
 
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_gem_cma_helper.h>
 #include <drm/drm_gem_framebuffer_helper.h>
 #include <drm/tinydrm/tinydrm.h>
 #include <drm/tinydrm/tinydrm-helpers.h>
@@ -882,7 +884,7 @@ static struct drm_driver repaper_driver = {
        .driver_features        = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME |
                                  DRIVER_ATOMIC,
        .fops                   = &repaper_fops,
-       TINYDRM_GEM_DRIVER_OPS,
+       DRM_GEM_CMA_VMAP_DRIVER_OPS,
        .name                   = "repaper",
        .desc                   = "Pervasive Displays RePaper e-ink panels",
        .date                   = "20170405",
index 2fcbc3067d71b237d3a8a49ffd496d25367ac000..a6a8a1081b73de27256d12b00bda06a4204a4017 100644 (file)
@@ -17,7 +17,8 @@
 #include <linux/spi/spi.h>
 #include <video/mipi_display.h>
 
-#include <drm/drm_fb_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_gem_cma_helper.h>
 #include <drm/drm_gem_framebuffer_helper.h>
 #include <drm/tinydrm/mipi-dbi.h>
 #include <drm/tinydrm/tinydrm-helpers.h>
@@ -303,7 +304,7 @@ static struct drm_driver st7586_driver = {
        .driver_features        = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME |
                                  DRIVER_ATOMIC,
        .fops                   = &st7586_fops,
-       TINYDRM_GEM_DRIVER_OPS,
+       DRM_GEM_CMA_VMAP_DRIVER_OPS,
        .debugfs_init           = mipi_dbi_debugfs_init,
        .name                   = "st7586",
        .desc                   = "Sitronix ST7586",
index 3081bc57c1166dc6849d24ea2abfab47d07e780b..b39779e0dcd8765c58be58b97e63c60848aa82ea 100644 (file)
@@ -14,7 +14,7 @@
 #include <linux/spi/spi.h>
 #include <video/mipi_display.h>
 
-#include <drm/drm_fb_helper.h>
+#include <drm/drm_gem_cma_helper.h>
 #include <drm/drm_gem_framebuffer_helper.h>
 #include <drm/tinydrm/mipi-dbi.h>
 #include <drm/tinydrm/tinydrm-helpers.h>
@@ -119,7 +119,7 @@ static struct drm_driver st7735r_driver = {
        .driver_features        = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME |
                                  DRIVER_ATOMIC,
        .fops                   = &st7735r_fops,
-       TINYDRM_GEM_DRIVER_OPS,
+       DRM_GEM_CMA_VMAP_DRIVER_OPS,
        .debugfs_init           = mipi_dbi_debugfs_init,
        .name                   = "st7735r",
        .desc                   = "Sitronix ST7735R",
index fe9827d0ca8a5c9c5d1c7245dc6d49c4c2b238e7..448aa5ea4722da2007fcfe8ee79855ccb22bb6ef 100644 (file)
 #ifndef __LINUX_TINYDRM_H
 #define __LINUX_TINYDRM_H
 
-#include <drm/drm_gem_cma_helper.h>
-#include <drm/drm_fb_cma_helper.h>
+#include <linux/mutex.h>
 #include <drm/drm_simple_kms_helper.h>
 
+struct drm_clip_rect;
+struct drm_driver;
+struct drm_file;
+struct drm_framebuffer;
+struct drm_framebuffer_funcs;
+
 /**
  * struct tinydrm_device - tinydrm device
  */
@@ -53,27 +58,6 @@ pipe_to_tinydrm(struct drm_simple_display_pipe *pipe)
        return container_of(pipe, struct tinydrm_device, pipe);
 }
 
-/**
- * TINYDRM_GEM_DRIVER_OPS - default tinydrm gem operations
- *
- * This macro provides a shortcut for setting the tinydrm GEM operations in
- * the &drm_driver structure.
- */
-#define TINYDRM_GEM_DRIVER_OPS \
-       .gem_free_object_unlocked = tinydrm_gem_cma_free_object, \
-       .gem_print_info         = drm_gem_cma_print_info, \
-       .gem_vm_ops             = &drm_gem_cma_vm_ops, \
-       .prime_handle_to_fd     = drm_gem_prime_handle_to_fd, \
-       .prime_fd_to_handle     = drm_gem_prime_fd_to_handle, \
-       .gem_prime_import       = drm_gem_prime_import, \
-       .gem_prime_export       = drm_gem_prime_export, \
-       .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table, \
-       .gem_prime_import_sg_table = tinydrm_gem_cma_prime_import_sg_table, \
-       .gem_prime_vmap         = drm_gem_cma_prime_vmap, \
-       .gem_prime_vunmap       = drm_gem_cma_prime_vunmap, \
-       .gem_prime_mmap         = drm_gem_cma_prime_mmap, \
-       .dumb_create            = drm_gem_cma_dumb_create
-
 /**
  * TINYDRM_MODE - tinydrm display mode
  * @hd: Horizontal resolution, width
@@ -97,11 +81,6 @@ pipe_to_tinydrm(struct drm_simple_display_pipe *pipe)
        .type = DRM_MODE_TYPE_DRIVER, \
        .clock = 1 /* pass validation */
 
-void tinydrm_gem_cma_free_object(struct drm_gem_object *gem_obj);
-struct drm_gem_object *
-tinydrm_gem_cma_prime_import_sg_table(struct drm_device *drm,
-                                     struct dma_buf_attachment *attach,
-                                     struct sg_table *sgt);
 int devm_tinydrm_init(struct device *parent, struct tinydrm_device *tdev,
                      const struct drm_framebuffer_funcs *fb_funcs,
                      struct drm_driver *driver);