drm/amdgpu: add an INFO query for monitoring VRAM CPU page faults
authorMarek Olšák <marek.olsak@amd.com>
Wed, 17 May 2017 18:05:08 +0000 (20:05 +0200)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 24 May 2017 22:24:38 +0000 (18:24 -0400)
v2: bump the DRM version

Signed-off-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu.h
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
include/uapi/drm/amdgpu_drm.h

index 572e508d185f754c2a78be7426a91320343f4a3a..359fb0ca8209314a5d8ac4e276e8c0ab2651a0f5 100644 (file)
@@ -1529,6 +1529,7 @@ struct amdgpu_device {
        atomic64_t                      gtt_usage;
        atomic64_t                      num_bytes_moved;
        atomic64_t                      num_evictions;
+       atomic64_t                      num_vram_cpu_page_faults;
        atomic_t                        gpu_reset_counter;
        atomic_t                        vram_lost_counter;
 
index 1bbf35f02a6380ebe116ce466e0cae347b869710..39432b0802f76758922cdcdbebe4b63d5765bc0a 100644 (file)
  * - 3.14.0 - Fix race in amdgpu_ctx_get_fence() and note new functionality
  * - 3.15.0 - Export more gpu info for gfx9
  * - 3.16.0 - Add reserved vmid support
+ * - 3.17.0 - Add AMDGPU_NUM_VRAM_CPU_PAGE_FAULTS.
  */
 #define KMS_DRIVER_MAJOR       3
-#define KMS_DRIVER_MINOR       16
+#define KMS_DRIVER_MINOR       17
 #define KMS_DRIVER_PATCHLEVEL  0
 
 int amdgpu_vram_limit = 0;
index b324f07f137a2d3396072bb598b15826f3f3d093..cda06a1bd7d7ff76462271dab7773db506dc4614 100644 (file)
@@ -417,6 +417,9 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
        case AMDGPU_INFO_NUM_EVICTIONS:
                ui64 = atomic64_read(&adev->num_evictions);
                return copy_to_user(out, &ui64, min(size, 8u)) ? -EFAULT : 0;
+       case AMDGPU_INFO_NUM_VRAM_CPU_PAGE_FAULTS:
+               ui64 = atomic64_read(&adev->num_vram_cpu_page_faults);
+               return copy_to_user(out, &ui64, min(size, 8u)) ? -EFAULT : 0;
        case AMDGPU_INFO_VRAM_USAGE:
                ui64 = atomic64_read(&adev->vram_usage);
                return copy_to_user(out, &ui64, min(size, 8u)) ? -EFAULT : 0;
index 365883d7948d2ab8ab2bea71163f1eae2c1b2eb6..8ee69652be8ceea145129cefb46ab46920744a74 100644 (file)
@@ -960,6 +960,7 @@ int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo)
                return -EINVAL;
 
        /* hurrah the memory is not visible ! */
+       atomic64_inc(&adev->num_vram_cpu_page_faults);
        amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_VRAM);
        lpfn =  adev->mc.visible_vram_size >> PAGE_SHIFT;
        for (i = 0; i < abo->placement.num_placement; i++) {
index 0c0c4a4910383c04c12114e42768b4b36e00c172..34128f698f5e97e577e01e300ce0ae679c5ce8bd 100644 (file)
@@ -603,6 +603,8 @@ struct drm_amdgpu_cs_chunk_data {
        #define AMDGPU_INFO_SENSOR_VDDNB                0x6
        /* Subquery id: Query graphics voltage */
        #define AMDGPU_INFO_SENSOR_VDDGFX               0x7
+/* Number of VRAM page faults on CPU access. */
+#define AMDGPU_INFO_NUM_VRAM_CPU_PAGE_FAULTS   0x1E
 
 #define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0
 #define AMDGPU_INFO_MMR_SE_INDEX_MASK  0xff