Merge branch 'drm-armada-devel' of git://ftp.arm.linux.org.uk/~rmk/linux-arm into...
authorDave Airlie <airlied@redhat.com>
Tue, 22 Dec 2015 23:19:58 +0000 (09:19 +1000)
committerDave Airlie <airlied@redhat.com>
Tue, 22 Dec 2015 23:19:58 +0000 (09:19 +1000)
These are the patches from Daniel Vetter, getting rid of struct_mutex
from the Armada DRM driver.

* 'drm-armada-devel' of git://ftp.arm.linux.org.uk/~rmk/linux-arm:
  drm/armada: use a private mutex to protect priv->linear
  drm/armada: drop struct_mutex from cursor paths
  drm/armada: don't grab dev->struct_mutex for in mmap offset ioctl
  drm/armada: plug leak in dumb_map_offset
  drm/armada: use unlocked gem unreferencing

1  2 
drivers/gpu/drm/armada/armada_crtc.c
drivers/gpu/drm/armada/armada_drv.c

@@@ -928,11 -928,10 +928,10 @@@ static int armada_drm_crtc_cursor_set(s
                }
        }
  
-       mutex_lock(&dev->struct_mutex);
        if (dcrtc->cursor_obj) {
                dcrtc->cursor_obj->update = NULL;
                dcrtc->cursor_obj->update_data = NULL;
-               drm_gem_object_unreference(&dcrtc->cursor_obj->obj);
+               drm_gem_object_unreference_unlocked(&dcrtc->cursor_obj->obj);
        }
        dcrtc->cursor_obj = obj;
        dcrtc->cursor_w = w;
                obj->update_data = dcrtc;
                obj->update = cursor_update;
        }
-       mutex_unlock(&dev->struct_mutex);
  
        return ret;
  }
  
  static int armada_drm_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
  {
-       struct drm_device *dev = crtc->dev;
        struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc);
        int ret;
  
        if (!dcrtc->variant->has_spu_adv_reg)
                return -EFAULT;
  
-       mutex_lock(&dev->struct_mutex);
        dcrtc->cursor_x = x;
        dcrtc->cursor_y = y;
        ret = armada_drm_crtc_cursor_update(dcrtc, false);
-       mutex_unlock(&dev->struct_mutex);
  
        return ret;
  }
@@@ -972,7 -967,7 +967,7 @@@ static void armada_drm_crtc_destroy(str
        struct armada_private *priv = crtc->dev->dev_private;
  
        if (dcrtc->cursor_obj)
-               drm_gem_object_unreference(&dcrtc->cursor_obj->obj);
+               drm_gem_object_unreference_unlocked(&dcrtc->cursor_obj->obj);
  
        priv->dcrtc[dcrtc->num] = NULL;
        drm_crtc_cleanup(&dcrtc->crtc);
@@@ -1074,7 -1069,7 +1069,7 @@@ armada_drm_crtc_set_property(struct drm
        return 0;
  }
  
 -static struct drm_crtc_funcs armada_crtc_funcs = {
 +static const struct drm_crtc_funcs armada_crtc_funcs = {
        .cursor_set     = armada_drm_crtc_cursor_set,
        .cursor_move    = armada_drm_crtc_cursor_move,
        .destroy        = armada_drm_crtc_destroy,
@@@ -1216,14 -1211,14 +1211,14 @@@ static int armada_drm_crtc_create(struc
                                       &armada_primary_plane_funcs,
                                       armada_primary_formats,
                                       ARRAY_SIZE(armada_primary_formats),
 -                                     DRM_PLANE_TYPE_PRIMARY);
 +                                     DRM_PLANE_TYPE_PRIMARY, NULL);
        if (ret) {
                kfree(primary);
                return ret;
        }
  
        ret = drm_crtc_init_with_planes(drm, &dcrtc->crtc, &primary->base, NULL,
 -                                      &armada_crtc_funcs);
 +                                      &armada_crtc_funcs, NULL);
        if (ret)
                goto err_crtc_init;
  
@@@ -11,7 -11,6 +11,7 @@@
  #include <linux/of_graph.h>
  #include <drm/drmP.h>
  #include <drm/drm_crtc_helper.h>
 +#include <drm/drm_of.h>
  #include "armada_crtc.h"
  #include "armada_drm.h"
  #include "armada_gem.h"
@@@ -102,6 -101,7 +102,7 @@@ static int armada_drm_load(struct drm_d
        dev->mode_config.preferred_depth = 24;
        dev->mode_config.funcs = &armada_drm_mode_config_funcs;
        drm_mm_init(&priv->linear, mem->start, resource_size(mem));
+       mutex_init(&priv->linear_lock);
  
        ret = component_bind_all(dev->dev, dev);
        if (ret)
@@@ -150,23 -150,26 +151,23 @@@ static int armada_drm_unload(struct drm
  }
  
  /* These are called under the vbl_lock. */
 -static int armada_drm_enable_vblank(struct drm_device *dev, int crtc)
 +static int armada_drm_enable_vblank(struct drm_device *dev, unsigned int pipe)
  {
        struct armada_private *priv = dev->dev_private;
 -      armada_drm_crtc_enable_irq(priv->dcrtc[crtc], VSYNC_IRQ_ENA);
 +      armada_drm_crtc_enable_irq(priv->dcrtc[pipe], VSYNC_IRQ_ENA);
        return 0;
  }
  
 -static void armada_drm_disable_vblank(struct drm_device *dev, int crtc)
 +static void armada_drm_disable_vblank(struct drm_device *dev, unsigned int pipe)
  {
        struct armada_private *priv = dev->dev_private;
 -      armada_drm_crtc_disable_irq(priv->dcrtc[crtc], VSYNC_IRQ_ENA);
 +      armada_drm_crtc_disable_irq(priv->dcrtc[pipe], VSYNC_IRQ_ENA);
  }
  
  static struct drm_ioctl_desc armada_ioctls[] = {
 -      DRM_IOCTL_DEF_DRV(ARMADA_GEM_CREATE, armada_gem_create_ioctl,
 -              DRM_UNLOCKED),
 -      DRM_IOCTL_DEF_DRV(ARMADA_GEM_MMAP, armada_gem_mmap_ioctl,
 -              DRM_UNLOCKED),
 -      DRM_IOCTL_DEF_DRV(ARMADA_GEM_PWRITE, armada_gem_pwrite_ioctl,
 -              DRM_UNLOCKED),
 +      DRM_IOCTL_DEF_DRV(ARMADA_GEM_CREATE, armada_gem_create_ioctl,0),
 +      DRM_IOCTL_DEF_DRV(ARMADA_GEM_MMAP, armada_gem_mmap_ioctl, 0),
 +      DRM_IOCTL_DEF_DRV(ARMADA_GEM_PWRITE, armada_gem_pwrite_ioctl, 0),
  };
  
  static void armada_drm_lastclose(struct drm_device *dev)
@@@ -193,7 -196,7 +194,7 @@@ static struct drm_driver armada_drm_dri
        .lastclose              = armada_drm_lastclose,
        .unload                 = armada_drm_unload,
        .set_busid              = drm_platform_set_busid,
 -      .get_vblank_counter     = drm_vblank_count,
 +      .get_vblank_counter     = drm_vblank_no_hw_counter,
        .enable_vblank          = armada_drm_enable_vblank,
        .disable_vblank         = armada_drm_disable_vblank,
  #ifdef CONFIG_DEBUG_FS
@@@ -263,29 -266,43 +264,29 @@@ static void armada_add_endpoints(struc
        }
  }
  
 -static int armada_drm_find_components(struct device *dev,
 -      struct component_match **match)
 -{
 -      struct device_node *port;
 -      int i;
 -
 -      if (dev->of_node) {
 -              struct device_node *np = dev->of_node;
 -
 -              for (i = 0; ; i++) {
 -                      port = of_parse_phandle(np, "ports", i);
 -                      if (!port)
 -                              break;
 -
 -                      component_match_add(dev, match, compare_of, port);
 -                      of_node_put(port);
 -              }
 +static const struct component_master_ops armada_master_ops = {
 +      .bind = armada_drm_bind,
 +      .unbind = armada_drm_unbind,
 +};
  
 -              if (i == 0) {
 -                      dev_err(dev, "missing 'ports' property\n");
 -                      return -ENODEV;
 -              }
 +static int armada_drm_probe(struct platform_device *pdev)
 +{
 +      struct component_match *match = NULL;
 +      struct device *dev = &pdev->dev;
 +      int ret;
  
 -              for (i = 0; ; i++) {
 -                      port = of_parse_phandle(np, "ports", i);
 -                      if (!port)
 -                              break;
 +      ret = drm_of_component_probe(dev, compare_dev_name, &armada_master_ops);
 +      if (ret != -EINVAL)
 +              return ret;
  
 -                      armada_add_endpoints(dev, match, port);
 -                      of_node_put(port);
 -              }
 -      } else if (dev->platform_data) {
 +      if (dev->platform_data) {
                char **devices = dev->platform_data;
 +              struct device_node *port;
                struct device *d;
 +              int i;
  
                for (i = 0; devices[i]; i++)
 -                      component_match_add(dev, match, compare_dev_name,
 +                      component_match_add(dev, &match, compare_dev_name,
                                            devices[i]);
  
                if (i == 0) {
  
                for (i = 0; devices[i]; i++) {
                        d = bus_find_device_by_name(&platform_bus_type, NULL,
 -                                      devices[i]);
 +                                                  devices[i]);
                        if (d && d->of_node) {
                                for_each_child_of_node(d->of_node, port)
 -                                      armada_add_endpoints(dev, match, port);
 +                                      armada_add_endpoints(dev, &match, port);
                        }
                        put_device(d);
                }
        }
  
 -      return 0;
 -}
 -
 -static const struct component_master_ops armada_master_ops = {
 -      .bind = armada_drm_bind,
 -      .unbind = armada_drm_unbind,
 -};
 -
 -static int armada_drm_probe(struct platform_device *pdev)
 -{
 -      struct component_match *match = NULL;
 -      int ret;
 -
 -      ret = armada_drm_find_components(&pdev->dev, &match);
 -      if (ret < 0)
 -              return ret;
 -
        return component_master_add_with_match(&pdev->dev, &armada_master_ops,
                                               match);
  }