Merge tag 'topic/drm-misc-2015-07-23' of git://anongit.freedesktop.org/drm-intel...
authorDave Airlie <airlied@redhat.com>
Fri, 24 Jul 2015 04:28:16 +0000 (14:28 +1000)
committerDave Airlie <airlied@redhat.com>
Fri, 24 Jul 2015 04:28:16 +0000 (14:28 +1000)
Update drm-misc pull request since the first one didn't go in yet. Few
atomic helper patches, rejecting some old dri1 crap for modern drivers and
a few trivial things on top.

* tag 'topic/drm-misc-2015-07-23' of git://anongit.freedesktop.org/drm-intel:
  drm/mgag200: remove unneeded variable
  drm/mgag200: remove unused variables
  drm/atomic: Only update crtc->x/y if it's part of the state, v2.
  drm/fb: drop panic handling
  drm: Fix warning with make xmldocs caused by drm_irq.c
  drm/gem: rip out drm vma accounting for gem mmaps
  drm/fourcc: Add formats R8, RG88, GR88
  drm/atomic: Cleanup on error properly in the atomic ioctl.
  drm: Update plane->fb also for page_flip
  drm: remove redundant code form drm_ioc32.c
  drm: reset empty state in transitional helpers
  drm/crtc-helper: Fixup error handling in drm_helper_crtc_mode_set
  drm/atomic: Update old_fb after setting a property.
  drm: Remove useless blank line
  drm: Reject DRI1 hw lock ioctl functions for kms drivers
  drm: Convert drm_legacy_ctxbitmap_init to void return type
  drm: Turn off Legacy Context Functions

1  2 
drivers/gpu/drm/drm_crtc.c
drivers/gpu/drm/drm_ioc32.c
drivers/gpu/drm/mgag200/mgag200_mode.c
drivers/gpu/drm/nouveau/nouveau_drm.c

index 357bd04a173b6aa51b896394a2e2f9f5754f7a21,2bbb232e80d7b55ef6f8f7a16d8289405262df78..9b6cdcbbe5bb3beb0d6e0b09ae0936cee8c927d2
@@@ -2706,11 -2706,8 +2706,11 @@@ int drm_mode_setcrtc(struct drm_device 
        if (!drm_core_check_feature(dev, DRIVER_MODESET))
                return -EINVAL;
  
 -      /* For some reason crtc x/y offsets are signed internally. */
 -      if (crtc_req->x > INT_MAX || crtc_req->y > INT_MAX)
 +      /*
 +       * Universal plane src offsets are only 16.16, prevent havoc for
 +       * drivers using universal plane code internally.
 +       */
 +      if (crtc_req->x & 0xffff0000 || crtc_req->y & 0xffff0000)
                return -ERANGE;
  
        drm_modeset_lock_all(dev);
@@@ -4301,7 -4298,6 +4301,6 @@@ void drm_property_unreference_blob(stru
                mutex_unlock(&dev->mode_config.blob_lock);
        else
                might_lock(&dev->mode_config.blob_lock);
  }
  EXPORT_SYMBOL(drm_property_unreference_blob);
  
@@@ -4735,7 -4731,7 +4734,7 @@@ int drm_mode_connector_update_edid_prop
                return 0;
  
        if (edid)
 -              size = EDID_LENGTH + (1 + edid->extensions);
 +              size = EDID_LENGTH * (1 + edid->extensions);
  
        ret = drm_property_replace_global_blob(dev,
                                               &connector->edid_blob_ptr,
@@@ -5349,13 -5345,7 +5348,7 @@@ int drm_mode_page_flip_ioctl(struct drm
                /* Keep the old fb, don't unref it. */
                crtc->primary->old_fb = NULL;
        } else {
-               /*
-                * Warn if the driver hasn't properly updated the crtc->fb
-                * field to reflect that the new framebuffer is now used.
-                * Failing to do so will screw with the reference counting
-                * on framebuffers.
-                */
-               WARN_ON(crtc->primary->fb != fb);
+               crtc->primary->fb = fb;
                /* Unref only the old framebuffer. */
                fb = NULL;
        }
index 9cfcd0aef0dfacf8389407d78981b78c8c85ddf8,8dcfa76b09e65e5db76fd58ed616e83e2a84b760..ddfa6014c2c2e2cb0e9aa9b99a8fa41c7eb926f2
@@@ -70,8 -70,6 +70,8 @@@
  
  #define DRM_IOCTL_WAIT_VBLANK32               DRM_IOWR(0x3a, drm_wait_vblank32_t)
  
 +#define DRM_IOCTL_MODE_ADDFB232               DRM_IOWR(0xb8, drm_mode_fb_cmd232_t)
 +
  typedef struct drm_version_32 {
        int version_major;        /**< Major version */
        int version_minor;        /**< Minor version */
@@@ -95,7 -93,7 +95,7 @@@ static int compat_drm_version(struct fi
                return -EFAULT;
  
        version = compat_alloc_user_space(sizeof(*version));
-       if (!access_ok(VERIFY_WRITE, version, sizeof(*version)))
+       if (!version)
                return -EFAULT;
        if (__put_user(v32.name_len, &version->name_len)
            || __put_user((void __user *)(unsigned long)v32.name,
@@@ -142,7 -140,7 +142,7 @@@ static int compat_drm_getunique(struct 
                return -EFAULT;
  
        u = compat_alloc_user_space(sizeof(*u));
-       if (!access_ok(VERIFY_WRITE, u, sizeof(*u)))
+       if (!u)
                return -EFAULT;
        if (__put_user(uq32.unique_len, &u->unique_len)
            || __put_user((void __user *)(unsigned long)uq32.unique,
@@@ -170,7 -168,7 +170,7 @@@ static int compat_drm_setunique(struct 
                return -EFAULT;
  
        u = compat_alloc_user_space(sizeof(*u));
-       if (!access_ok(VERIFY_WRITE, u, sizeof(*u)))
+       if (!u)
                return -EFAULT;
        if (__put_user(uq32.unique_len, &u->unique_len)
            || __put_user((void __user *)(unsigned long)uq32.unique,
@@@ -202,7 -200,7 +202,7 @@@ static int compat_drm_getmap(struct fil
                return -EFAULT;
  
        map = compat_alloc_user_space(sizeof(*map));
-       if (!access_ok(VERIFY_WRITE, map, sizeof(*map)))
+       if (!map)
                return -EFAULT;
        if (__put_user(idx, &map->offset))
                return -EFAULT;
@@@ -239,7 -237,7 +239,7 @@@ static int compat_drm_addmap(struct fil
                return -EFAULT;
  
        map = compat_alloc_user_space(sizeof(*map));
-       if (!access_ok(VERIFY_WRITE, map, sizeof(*map)))
+       if (!map)
                return -EFAULT;
        if (__put_user(m32.offset, &map->offset)
            || __put_user(m32.size, &map->size)
@@@ -279,7 -277,7 +279,7 @@@ static int compat_drm_rmmap(struct fil
                return -EFAULT;
  
        map = compat_alloc_user_space(sizeof(*map));
-       if (!access_ok(VERIFY_WRITE, map, sizeof(*map)))
+       if (!map)
                return -EFAULT;
        if (__put_user((void *)(unsigned long)handle, &map->handle))
                return -EFAULT;
@@@ -308,7 -306,7 +308,7 @@@ static int compat_drm_getclient(struct 
                return -EFAULT;
  
        client = compat_alloc_user_space(sizeof(*client));
-       if (!access_ok(VERIFY_WRITE, client, sizeof(*client)))
+       if (!client)
                return -EFAULT;
        if (__put_user(idx, &client->idx))
                return -EFAULT;
@@@ -347,7 -345,7 +347,7 @@@ static int compat_drm_getstats(struct f
        int i, err;
  
        stats = compat_alloc_user_space(sizeof(*stats));
-       if (!access_ok(VERIFY_WRITE, stats, sizeof(*stats)))
+       if (!stats)
                return -EFAULT;
  
        err = drm_ioctl(file, DRM_IOCTL_GET_STATS, (unsigned long)stats);
@@@ -384,8 -382,7 +384,7 @@@ static int compat_drm_addbufs(struct fi
        unsigned long agp_start;
  
        buf = compat_alloc_user_space(sizeof(*buf));
-       if (!access_ok(VERIFY_WRITE, buf, sizeof(*buf))
-           || !access_ok(VERIFY_WRITE, argp, sizeof(*argp)))
+       if (!buf || !access_ok(VERIFY_WRITE, argp, sizeof(*argp)))
                return -EFAULT;
  
        if (__copy_in_user(buf, argp, offsetof(drm_buf_desc32_t, agp_start))
@@@ -416,7 -413,7 +415,7 @@@ static int compat_drm_markbufs(struct f
                return -EFAULT;
  
        buf = compat_alloc_user_space(sizeof(*buf));
-       if (!access_ok(VERIFY_WRITE, buf, sizeof(*buf)))
+       if (!buf)
                return -EFAULT;
  
        if (__put_user(b32.size, &buf->size)
@@@ -457,7 -454,7 +456,7 @@@ static int compat_drm_infobufs(struct f
  
        nbytes = sizeof(*request) + count * sizeof(struct drm_buf_desc);
        request = compat_alloc_user_space(nbytes);
-       if (!access_ok(VERIFY_WRITE, request, nbytes))
+       if (!request)
                return -EFAULT;
        list = (struct drm_buf_desc *) (request + 1);
  
@@@ -518,7 -515,7 +517,7 @@@ static int compat_drm_mapbufs(struct fi
                return -EINVAL;
        nbytes = sizeof(*request) + count * sizeof(struct drm_buf_pub);
        request = compat_alloc_user_space(nbytes);
-       if (!access_ok(VERIFY_WRITE, request, nbytes))
+       if (!request)
                return -EFAULT;
        list = (struct drm_buf_pub *) (request + 1);
  
@@@ -565,7 -562,7 +564,7 @@@ static int compat_drm_freebufs(struct f
                return -EFAULT;
  
        request = compat_alloc_user_space(sizeof(*request));
-       if (!access_ok(VERIFY_WRITE, request, sizeof(*request)))
+       if (!request)
                return -EFAULT;
        if (__put_user(req32.count, &request->count)
            || __put_user((int __user *)(unsigned long)req32.list,
@@@ -591,7 -588,7 +590,7 @@@ static int compat_drm_setsareactx(struc
                return -EFAULT;
  
        request = compat_alloc_user_space(sizeof(*request));
-       if (!access_ok(VERIFY_WRITE, request, sizeof(*request)))
+       if (!request)
                return -EFAULT;
        if (__put_user(req32.ctx_id, &request->ctx_id)
            || __put_user((void *)(unsigned long)req32.handle,
@@@ -615,7 -612,7 +614,7 @@@ static int compat_drm_getsareactx(struc
                return -EFAULT;
  
        request = compat_alloc_user_space(sizeof(*request));
-       if (!access_ok(VERIFY_WRITE, request, sizeof(*request)))
+       if (!request)
                return -EFAULT;
        if (__put_user(ctx_id, &request->ctx_id))
                return -EFAULT;
@@@ -648,7 -645,7 +647,7 @@@ static int compat_drm_resctx(struct fil
                return -EFAULT;
  
        res = compat_alloc_user_space(sizeof(*res));
-       if (!access_ok(VERIFY_WRITE, res, sizeof(*res)))
+       if (!res)
                return -EFAULT;
        if (__put_user(res32.count, &res->count)
            || __put_user((struct drm_ctx __user *) (unsigned long)res32.contexts,
@@@ -691,7 -688,7 +690,7 @@@ static int compat_drm_dma(struct file *
                return -EFAULT;
  
        d = compat_alloc_user_space(sizeof(*d));
-       if (!access_ok(VERIFY_WRITE, d, sizeof(*d)))
+       if (!d)
                return -EFAULT;
  
        if (__put_user(d32.context, &d->context)
@@@ -766,7 -763,7 +765,7 @@@ static int compat_drm_agp_info(struct f
        int err;
  
        info = compat_alloc_user_space(sizeof(*info));
-       if (!access_ok(VERIFY_WRITE, info, sizeof(*info)))
+       if (!info)
                return -EFAULT;
  
        err = drm_ioctl(file, DRM_IOCTL_AGP_INFO, (unsigned long)info);
@@@ -809,7 -806,7 +808,7 @@@ static int compat_drm_agp_alloc(struct 
                return -EFAULT;
  
        request = compat_alloc_user_space(sizeof(*request));
-       if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
+       if (!request
            || __put_user(req32.size, &request->size)
            || __put_user(req32.type, &request->type))
                return -EFAULT;
@@@ -836,7 -833,7 +835,7 @@@ static int compat_drm_agp_free(struct f
        u32 handle;
  
        request = compat_alloc_user_space(sizeof(*request));
-       if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
+       if (!request
            || get_user(handle, &argp->handle)
            || __put_user(handle, &request->handle))
                return -EFAULT;
@@@ -860,7 -857,7 +859,7 @@@ static int compat_drm_agp_bind(struct f
                return -EFAULT;
  
        request = compat_alloc_user_space(sizeof(*request));
-       if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
+       if (!request
            || __put_user(req32.handle, &request->handle)
            || __put_user(req32.offset, &request->offset))
                return -EFAULT;
@@@ -876,7 -873,7 +875,7 @@@ static int compat_drm_agp_unbind(struc
        u32 handle;
  
        request = compat_alloc_user_space(sizeof(*request));
-       if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
+       if (!request
            || get_user(handle, &argp->handle)
            || __put_user(handle, &request->handle))
                return -EFAULT;
@@@ -899,8 -896,7 +898,7 @@@ static int compat_drm_sg_alloc(struct f
        unsigned long x;
  
        request = compat_alloc_user_space(sizeof(*request));
-       if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
-           || !access_ok(VERIFY_WRITE, argp, sizeof(*argp))
+       if (!request || !access_ok(VERIFY_WRITE, argp, sizeof(*argp))
            || __get_user(x, &argp->size)
            || __put_user(x, &request->size))
                return -EFAULT;
@@@ -925,8 -921,7 +923,7 @@@ static int compat_drm_sg_free(struct fi
        unsigned long x;
  
        request = compat_alloc_user_space(sizeof(*request));
-       if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
-           || !access_ok(VERIFY_WRITE, argp, sizeof(*argp))
+       if (!request || !access_ok(VERIFY_WRITE, argp, sizeof(*argp))
            || __get_user(x, &argp->handle)
            || __put_user(x << PAGE_SHIFT, &request->handle))
                return -EFAULT;
@@@ -954,7 -949,7 +951,7 @@@ static int compat_drm_update_draw(struc
                return -EFAULT;
  
        request = compat_alloc_user_space(sizeof(*request));
-       if (!access_ok(VERIFY_WRITE, request, sizeof(*request)) ||
+       if (!request ||
            __put_user(update32.handle, &request->handle) ||
            __put_user(update32.type, &request->type) ||
            __put_user(update32.num, &request->num) ||
@@@ -996,7 -991,7 +993,7 @@@ static int compat_drm_wait_vblank(struc
                return -EFAULT;
  
        request = compat_alloc_user_space(sizeof(*request));
-       if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
+       if (!request
            || __put_user(req32.request.type, &request->request.type)
            || __put_user(req32.request.sequence, &request->request.sequence)
            || __put_user(req32.request.signal, &request->request.signal))
        return 0;
  }
  
 +typedef struct drm_mode_fb_cmd232 {
 +      u32 fb_id;
 +      u32 width;
 +      u32 height;
 +      u32 pixel_format;
 +      u32 flags;
 +      u32 handles[4];
 +      u32 pitches[4];
 +      u32 offsets[4];
 +      u64 modifier[4];
 +} __attribute__((packed)) drm_mode_fb_cmd232_t;
 +
 +static int compat_drm_mode_addfb2(struct file *file, unsigned int cmd,
 +                                unsigned long arg)
 +{
 +      struct drm_mode_fb_cmd232 __user *argp = (void __user *)arg;
 +      struct drm_mode_fb_cmd232 req32;
 +      struct drm_mode_fb_cmd2 __user *req64;
 +      int i;
 +      int err;
 +
 +      if (copy_from_user(&req32, argp, sizeof(req32)))
 +              return -EFAULT;
 +
 +      req64 = compat_alloc_user_space(sizeof(*req64));
 +
 +      if (!access_ok(VERIFY_WRITE, req64, sizeof(*req64))
 +          || __put_user(req32.width, &req64->width)
 +          || __put_user(req32.height, &req64->height)
 +          || __put_user(req32.pixel_format, &req64->pixel_format)
 +          || __put_user(req32.flags, &req64->flags))
 +              return -EFAULT;
 +
 +      for (i = 0; i < 4; i++) {
 +              if (__put_user(req32.handles[i], &req64->handles[i]))
 +                      return -EFAULT;
 +              if (__put_user(req32.pitches[i], &req64->pitches[i]))
 +                      return -EFAULT;
 +              if (__put_user(req32.offsets[i], &req64->offsets[i]))
 +                      return -EFAULT;
 +              if (__put_user(req32.modifier[i], &req64->modifier[i]))
 +                      return -EFAULT;
 +      }
 +
 +      err = drm_ioctl(file, DRM_IOCTL_MODE_ADDFB2, (unsigned long)req64);
 +      if (err)
 +              return err;
 +
 +      if (__get_user(req32.fb_id, &req64->fb_id))
 +              return -EFAULT;
 +
 +      if (copy_to_user(argp, &req32, sizeof(req32)))
 +              return -EFAULT;
 +
 +      return 0;
 +}
 +
  static drm_ioctl_compat_t *drm_compat_ioctls[] = {
        [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
        [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
        [DRM_IOCTL_NR(DRM_IOCTL_UPDATE_DRAW32)] = compat_drm_update_draw,
  #endif
        [DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK32)] = compat_drm_wait_vblank,
 +      [DRM_IOCTL_NR(DRM_IOCTL_MODE_ADDFB232)] = compat_drm_mode_addfb2,
  };
  
  /**
index ad4b9010dfb0bbed135185e9f64aed98c3239a24,67ae9f79dbd2d04272c5fbb593eaf399ce479b5f..cd75cff096e1ccebbb1be0a4461e0f9b7d855fbf
@@@ -158,7 -158,7 +158,7 @@@ static int mga_g200se_set_plls(struct m
  static int mga_g200wb_set_plls(struct mga_device *mdev, long clock)
  {
        unsigned int vcomax, vcomin, pllreffreq;
-       unsigned int delta, tmpdelta, permitteddelta;
+       unsigned int delta, tmpdelta;
        unsigned int testp, testm, testn;
        unsigned int p, m, n;
        unsigned int computed;
        pllreffreq = 48000;
  
        delta = 0xffffffff;
-       permitteddelta = clock * 5 / 1000;
  
        for (testp = 1; testp < 9; testp++) {
                if (clock * testp > vcomax)
  static int mga_g200ev_set_plls(struct mga_device *mdev, long clock)
  {
        unsigned int vcomax, vcomin, pllreffreq;
-       unsigned int delta, tmpdelta, permitteddelta;
+       unsigned int delta, tmpdelta;
        unsigned int testp, testm, testn;
        unsigned int p, m, n;
        unsigned int computed;
        pllreffreq = 50000;
  
        delta = 0xffffffff;
-       permitteddelta = clock * 5 / 1000;
  
        for (testp = 16; testp > 0; testp--) {
                if (clock * testp > vcomax)
  static int mga_g200eh_set_plls(struct mga_device *mdev, long clock)
  {
        unsigned int vcomax, vcomin, pllreffreq;
-       unsigned int delta, tmpdelta, permitteddelta;
+       unsigned int delta, tmpdelta;
        unsigned int testp, testm, testn;
        unsigned int p, m, n;
        unsigned int computed;
        pllreffreq = 33333;
  
        delta = 0xffffffff;
-       permitteddelta = clock * 5 / 1000;
  
        for (testp = 16; testp > 0; testp >>= 1) {
                if (clock * testp > vcomax)
@@@ -1526,11 -1523,6 +1523,11 @@@ static int mga_vga_mode_valid(struct dr
                return MODE_BANDWIDTH;
        }
  
 +      if ((mode->hdisplay % 8) != 0 || (mode->hsync_start % 8) != 0 ||
 +          (mode->hsync_end % 8) != 0 || (mode->htotal % 8) != 0) {
 +              return MODE_H_ILLEGAL;
 +      }
 +
        if (mode->crtc_hdisplay > 2048 || mode->crtc_hsync_start > 4096 ||
            mode->crtc_hsync_end > 4096 || mode->crtc_htotal > 4096 ||
            mode->crtc_vdisplay > 2048 || mode->crtc_vsync_start > 4096 ||
index 649024d4daf1da6e5aa1e074e303ba02ec312de0,9624b3827c349ae503c65fd5ee138988cf37f1ab..36b40c9252b5df3f7aac5608957f78e9c887aa4f
@@@ -23,7 -23,6 +23,7 @@@
   */
  
  #include <linux/console.h>
 +#include <linux/delay.h>
  #include <linux/module.h>
  #include <linux/pci.h>
  #include <linux/pm_runtime.h>
@@@ -667,7 -666,6 +667,7 @@@ nouveau_pmops_suspend(struct device *de
        pci_save_state(pdev);
        pci_disable_device(pdev);
        pci_set_power_state(pdev, PCI_D3hot);
 +      udelay(200);
        return 0;
  }
  
@@@ -943,7 -941,8 +943,8 @@@ static struct drm_drive
  driver_stub = {
        .driver_features =
                DRIVER_USE_AGP |
-               DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_RENDER,
+               DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_RENDER |
+               DRIVER_KMS_LEGACY_CONTEXT,
  
        .load = nouveau_drm_load,
        .unload = nouveau_drm_unload,