Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 69fdf420 authored by Chris Wilson's avatar Chris Wilson
Browse files

drm: Differentiate the lack of an interface from invalid parameter



If the ioctl is not supported on a particular piece of HW/driver
combination, report ENOTSUP (aka EOPNOTSUPP) so that it can be easily
distinguished from both the lack of the ioctl and from a regular invalid
parameter.

v2: Across all the kms ioctls we had a mixture of reporting EINVAL,
ENODEV and a few ENOTSUPP (most where EINVAL) for a failed
drm_core_check_feature(). Update everybody to report ENOTSUPP.

v3: ENOTSUPP is an internal errno! It's value (524) does not correspond
to a POSIX errno, the one we want is ENOTSUP. However,
uapi/asm-generic/errno.h doesn't include ENOTSUP but man errno says

	"ENOTSUP and EOPNOTSUPP have the same value on Linux,
	but according to POSIX.1 these error values should be
	distinct."

so use EOPNOTSUPP as its equivalent.

Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> #v2
Link: https://patchwork.freedesktop.org/patch/msgid/20180913192050.24812-1-chris@chris-wilson.co.uk
parent 6f19eb21
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1251,7 +1251,7 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,

	/* disallow for drivers not supporting atomic: */
	if (!drm_core_check_feature(dev, DRIVER_ATOMIC))
		return -EINVAL;
		return -EOPNOTSUPP;

	/* disallow for userspace that has not enabled atomic cap (even
	 * though this may be a bit overkill, since legacy userspace
+16 −16
Original line number Diff line number Diff line
@@ -398,7 +398,7 @@ int drm_legacy_addmap_ioctl(struct drm_device *dev, void *data,

	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
	    !drm_core_check_feature(dev, DRIVER_LEGACY))
		return -EINVAL;
		return -EOPNOTSUPP;

	err = drm_addmap_core(dev, map->offset, map->size, map->type,
			      map->flags, &maplist);
@@ -444,7 +444,7 @@ int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,

	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
	    !drm_core_check_feature(dev, DRIVER_LEGACY))
		return -EINVAL;
		return -EOPNOTSUPP;

	idx = map->offset;
	if (idx < 0)
@@ -596,7 +596,7 @@ int drm_legacy_rmmap_ioctl(struct drm_device *dev, void *data,

	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
	    !drm_core_check_feature(dev, DRIVER_LEGACY))
		return -EINVAL;
		return -EOPNOTSUPP;

	mutex_lock(&dev->struct_mutex);
	list_for_each_entry(r_list, &dev->maplist, head) {
@@ -860,7 +860,7 @@ int drm_legacy_addbufs_pci(struct drm_device *dev,
	struct drm_buf **temp_buflist;

	if (!drm_core_check_feature(dev, DRIVER_PCI_DMA))
		return -EINVAL;
		return -EOPNOTSUPP;

	if (!dma)
		return -EINVAL;
@@ -1064,7 +1064,7 @@ static int drm_legacy_addbufs_sg(struct drm_device *dev,
	struct drm_buf **temp_buflist;

	if (!drm_core_check_feature(dev, DRIVER_SG))
		return -EINVAL;
		return -EOPNOTSUPP;

	if (!dma)
		return -EINVAL;
@@ -1221,10 +1221,10 @@ int drm_legacy_addbufs(struct drm_device *dev, void *data,
	int ret;

	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
		return -EINVAL;
		return -EOPNOTSUPP;

	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
		return -EINVAL;
		return -EOPNOTSUPP;

#if IS_ENABLED(CONFIG_AGP)
	if (request->flags & _DRM_AGP_BUFFER)
@@ -1267,10 +1267,10 @@ int __drm_legacy_infobufs(struct drm_device *dev,
	int count;

	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
		return -EINVAL;
		return -EOPNOTSUPP;

	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
		return -EINVAL;
		return -EOPNOTSUPP;

	if (!dma)
		return -EINVAL;
@@ -1352,10 +1352,10 @@ int drm_legacy_markbufs(struct drm_device *dev, void *data,
	struct drm_buf_entry *entry;

	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
		return -EINVAL;
		return -EOPNOTSUPP;

	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
		return -EINVAL;
		return -EOPNOTSUPP;

	if (!dma)
		return -EINVAL;
@@ -1400,10 +1400,10 @@ int drm_legacy_freebufs(struct drm_device *dev, void *data,
	struct drm_buf *buf;

	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
		return -EINVAL;
		return -EOPNOTSUPP;

	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
		return -EINVAL;
		return -EOPNOTSUPP;

	if (!dma)
		return -EINVAL;
@@ -1455,10 +1455,10 @@ int __drm_legacy_mapbufs(struct drm_device *dev, void *data, int *p,
	int i;

	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
		return -EINVAL;
		return -EOPNOTSUPP;

	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
		return -EINVAL;
		return -EOPNOTSUPP;

	if (!dma)
		return -EINVAL;
@@ -1545,7 +1545,7 @@ int drm_legacy_dma_ioctl(struct drm_device *dev, void *data,
		  struct drm_file *file_priv)
{
	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
		return -EINVAL;
		return -EOPNOTSUPP;

	if (dev->driver->dma_ioctl)
		return dev->driver->dma_ioctl(dev, data, file_priv);
+1 −1
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ int drm_client_new(struct drm_device *dev, struct drm_client_dev *client,

	if (!drm_core_check_feature(dev, DRIVER_MODESET) ||
	    !dev->driver->dumb_create || !dev->driver->gem_prime_vmap)
		return -ENOTSUPP;
		return -EOPNOTSUPP;

	if (funcs && !try_module_get(funcs->owner))
		return -ENODEV;
+2 −2
Original line number Diff line number Diff line
@@ -242,7 +242,7 @@ int drm_mode_gamma_set_ioctl(struct drm_device *dev,
	int ret = 0;

	if (!drm_core_check_feature(dev, DRIVER_MODESET))
		return -EINVAL;
		return -EOPNOTSUPP;

	crtc = drm_crtc_find(dev, file_priv, crtc_lut->crtc_id);
	if (!crtc)
@@ -320,7 +320,7 @@ int drm_mode_gamma_get_ioctl(struct drm_device *dev,
	int ret = 0;

	if (!drm_core_check_feature(dev, DRIVER_MODESET))
		return -EINVAL;
		return -EOPNOTSUPP;

	crtc = drm_crtc_find(dev, file_priv, crtc_lut->crtc_id);
	if (!crtc)
+1 −1
Original line number Diff line number Diff line
@@ -1725,7 +1725,7 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,
	LIST_HEAD(export_list);

	if (!drm_core_check_feature(dev, DRIVER_MODESET))
		return -EINVAL;
		return -EOPNOTSUPP;

	memset(&u_mode, 0, sizeof(struct drm_mode_modeinfo));

Loading