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

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

drm/radeon: add userptr flag to register MMU notifier v3



Whenever userspace mapping related to our userptr change
we wait for it to become idle and unmap it from GTT.

v2: rebased, fix mutex unlock in error path
v3: improve commit message

Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 2a84a447
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -115,6 +115,7 @@ config DRM_RADEON
	select HWMON
	select BACKLIGHT_CLASS_DEVICE
	select INTERVAL_TREE
	select MMU_NOTIFIER
	help
	  Choose this option if you have an ATI Radeon graphics card.  There
	  are both PCI and AGP versions.  You don't need to choose this to
+1 −1
Original line number Diff line number Diff line
@@ -80,7 +80,7 @@ radeon-y += radeon_device.o radeon_asic.o radeon_kms.o \
	r600_dpm.o rs780_dpm.o rv6xx_dpm.o rv770_dpm.o rv730_dpm.o rv740_dpm.o \
	rv770_smc.o cypress_dpm.o btc_dpm.o sumo_dpm.o sumo_smc.o trinity_dpm.o \
	trinity_smc.o ni_dpm.o si_smc.o si_dpm.o kv_smc.o kv_dpm.o ci_smc.o \
	ci_dpm.o dce6_afmt.o radeon_vm.o radeon_ucode.o radeon_ib.o
	ci_dpm.o dce6_afmt.o radeon_vm.o radeon_ucode.o radeon_ib.o radeon_mn.o

# add async DMA block
radeon-y += \
+12 −0
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@
#include <linux/list.h>
#include <linux/kref.h>
#include <linux/interval_tree.h>
#include <linux/hashtable.h>

#include <ttm/ttm_bo_api.h>
#include <ttm/ttm_bo_driver.h>
@@ -487,6 +488,9 @@ struct radeon_bo {

	struct ttm_bo_kmap_obj		dma_buf_vmap;
	pid_t				pid;

	struct radeon_mn		*mn;
	struct interval_tree_node	mn_it;
};
#define gem_to_radeon_bo(gobj) container_of((gobj), struct radeon_bo, gem_base)

@@ -1725,6 +1729,11 @@ void radeon_test_ring_sync(struct radeon_device *rdev,
			   struct radeon_ring *cpB);
void radeon_test_syncing(struct radeon_device *rdev);

/*
 * MMU Notifier
 */
int radeon_mn_register(struct radeon_bo *bo, unsigned long addr);
void radeon_mn_unregister(struct radeon_bo *bo);

/*
 * Debugfs
@@ -2372,6 +2381,9 @@ struct radeon_device {
	/* tracking pinned memory */
	u64 vram_pin_size;
	u64 gart_pin_size;

	struct mutex	mn_lock;
	DECLARE_HASHTABLE(mn_hash, 7);
};

bool radeon_is_px(struct drm_device *dev);
+2 −0
Original line number Diff line number Diff line
@@ -1270,6 +1270,8 @@ int radeon_device_init(struct radeon_device *rdev,
	init_rwsem(&rdev->pm.mclk_lock);
	init_rwsem(&rdev->exclusive_lock);
	init_waitqueue_head(&rdev->irq.vblank_queue);
	mutex_init(&rdev->mn_lock);
	hash_init(rdev->mn_hash);
	r = radeon_gem_init(rdev);
	if (r)
		return r;
+8 −1
Original line number Diff line number Diff line
@@ -291,7 +291,8 @@ int radeon_gem_userptr_ioctl(struct drm_device *dev, void *data,

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

	/* readonly pages not tested on older hardware */
@@ -312,6 +313,12 @@ int radeon_gem_userptr_ioctl(struct drm_device *dev, void *data,
	if (r)
		goto release_object;

	if (args->flags & RADEON_GEM_USERPTR_REGISTER) {
		r = radeon_mn_register(bo, args->addr);
		if (r)
			goto release_object;
	}

	if (args->flags & RADEON_GEM_USERPTR_VALIDATE) {
		down_read(&current->mm->mmap_sem);
		r = radeon_bo_reserve(bo, true);
Loading