Skip to content

Commit 6eb9278

Browse files
danvetairlied
authored andcommitted
drm: remove the dma_ioctl special-case
We might as well have a real ioctl function which checks for the callbacks. This seems to be a remnant from back in the days when each drm driver had their own complete ioctl table, with no shared core drm table at all. To make really sure no mis-guided user in a kms driver pops up again explicitly check for that in the new ioctl implementation. v2: Drop the unused variable I've accidentally left in the code, spotted by David Herrmann. Cc: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Reviewed-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
1 parent 2ba5f7d commit 6eb9278

3 files changed

Lines changed: 15 additions & 5 deletions

File tree

‎drivers/gpu/drm/drm_bufs.c‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,6 +1455,18 @@ int drm_mapbufs(struct drm_device *dev, void *data,
14551455
return retcode;
14561456
}
14571457

1458+
int drm_dma_ioctl(struct drm_device *dev, void *data,
1459+
struct drm_file *file_priv)
1460+
{
1461+
if (drm_core_check_feature(dev, DRIVER_MODESET))
1462+
return -EINVAL;
1463+
1464+
if (dev->driver->dma_ioctl)
1465+
return dev->driver->dma_ioctl(dev, data, file_priv);
1466+
else
1467+
return -EINVAL;
1468+
}
1469+
14581470
struct drm_local_map *drm_getsarea(struct drm_device *dev)
14591471
{
14601472
struct drm_map_list *entry;

‎drivers/gpu/drm/drm_drv.c‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ static const struct drm_ioctl_desc drm_ioctls[] = {
106106
DRM_IOCTL_DEF(DRM_IOCTL_INFO_BUFS, drm_infobufs, DRM_AUTH),
107107
DRM_IOCTL_DEF(DRM_IOCTL_MAP_BUFS, drm_mapbufs, DRM_AUTH),
108108
DRM_IOCTL_DEF(DRM_IOCTL_FREE_BUFS, drm_freebufs, DRM_AUTH),
109-
/* The DRM_IOCTL_DMA ioctl should be defined by the driver. */
110-
DRM_IOCTL_DEF(DRM_IOCTL_DMA, NULL, DRM_AUTH),
109+
DRM_IOCTL_DEF(DRM_IOCTL_DMA, drm_dma_ioctl, DRM_AUTH),
111110

112111
DRM_IOCTL_DEF(DRM_IOCTL_CONTROL, drm_control, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
113112

@@ -397,9 +396,6 @@ long drm_ioctl(struct file *filp,
397396

398397
/* Do not trust userspace, use our own definition */
399398
func = ioctl->func;
400-
/* is there a local override? */
401-
if ((nr == DRM_IOCTL_NR(DRM_IOCTL_DMA)) && dev->driver->dma_ioctl)
402-
func = dev->driver->dma_ioctl;
403399

404400
if (!func) {
405401
DRM_DEBUG("no function\n");

‎include/drm/drmP.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,6 +1355,8 @@ extern int drm_freebufs(struct drm_device *dev, void *data,
13551355
struct drm_file *file_priv);
13561356
extern int drm_mapbufs(struct drm_device *dev, void *data,
13571357
struct drm_file *file_priv);
1358+
extern int drm_dma_ioctl(struct drm_device *dev, void *data,
1359+
struct drm_file *file_priv);
13581360

13591361
/* DMA support (drm_dma.h) */
13601362
extern int drm_legacy_dma_setup(struct drm_device *dev);

0 commit comments

Comments
 (0)