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

Commit bd645e43 authored by Christian König's avatar Christian König Committed by Alex Deucher
Browse files

drm/radeon: allow userptr write access under certain conditions



It needs to be anonymous memory (no file mappings)
and we are requried to install an MMU notifier.

Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 341cb9e4
Loading
Loading
Loading
Loading
+12 −7
Original line number Diff line number Diff line
@@ -285,20 +285,25 @@ int radeon_gem_userptr_ioctl(struct drm_device *dev, void *data,
	if (offset_in_page(args->addr | args->size))
		return -EINVAL;

	/* we only support read only mappings for now */
	if (!(args->flags & RADEON_GEM_USERPTR_READONLY))
		return -EACCES;

	/* reject unknown flag values */
	if (args->flags & ~(RADEON_GEM_USERPTR_READONLY |
	    RADEON_GEM_USERPTR_ANONONLY | RADEON_GEM_USERPTR_VALIDATE |
	    RADEON_GEM_USERPTR_REGISTER))
		return -EINVAL;

	if (args->flags & RADEON_GEM_USERPTR_READONLY) {
		/* readonly pages not tested on older hardware */
		if (rdev->family < CHIP_R600)
			return -EINVAL;

	} else if (!(args->flags & RADEON_GEM_USERPTR_ANONONLY) ||
		   !(args->flags & RADEON_GEM_USERPTR_REGISTER)) {

		/* if we want to write to it we must require anonymous
		   memory and install a MMU notifier */
		return -EACCES;
	}

	down_read(&rdev->exclusive_lock);

	/* create a gem object to contain this object in */