@@ -43,6 +43,7 @@
#include "amdgpu_ctx.h"
#include <linux/atomic.h>
+#include <linux/cgroup_dev.h>
#include <linux/wait.h>
#include <linux/list.h>
#include <linux/kref.h>
@@ -835,6 +836,7 @@ struct amdgpu_device {
struct device *dev;
struct pci_dev *pdev;
struct drm_device ddev;
+ struct dev_cgroup_device cg;
#ifdef CONFIG_DRM_AMD_ACP
struct amdgpu_acp acp;
@@ -1874,6 +1874,12 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
return r;
}
+ r = drmm_cgroup_register_device(adev_to_drm(adev), &adev->cg);
+ if (r) {
+ DRM_ERROR("Failed initializing cgroup allocator.\n");
+ return r;
+ }
+
/* Change the size here instead of the init above so only lpfn is affected */
amdgpu_ttm_set_buffer_funcs_status(adev, false);
#ifdef CONFIG_64BIT
@@ -927,6 +927,12 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev)
DRM_INFO("Setup dummy vram mgr\n");
}
+ adev->cg.regions[0].size = adev->gmc.real_vram_size;
+ adev->cg.regions[0].name = "vram";
+ adev->cg.num_regions++;
+ man->cgdev = &adev->cg;
+ man->cgidx = 0;
+
ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_VRAM, &mgr->manager);
ttm_resource_manager_set_used(man, true);
return 0;