diff options
author | Christian König <christian.koenig@amd.com> | 2017-10-09 09:18:43 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2017-10-19 15:27:04 -0400 |
commit | e55f2b646df3318e24f12b8388ab6e5cccb3e92d (patch) | |
tree | de65b871c6ad10ddfc97a9b74b953d46b72e27f1 | |
parent | 14e47f93c5cc4a1237dbacc137e174706093b69c (diff) |
drm/amdgpu: move the VRAM lost counter per context
Instead of per device track the VRAM lost per context and return ECANCELED
instead of ENODEV.
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 9 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 16 |
4 files changed, 8 insertions, 24 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index aa70f8c045b1..67b864436be1 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h | |||
@@ -732,10 +732,11 @@ struct amdgpu_ctx { | |||
732 | struct amdgpu_device *adev; | 732 | struct amdgpu_device *adev; |
733 | struct amdgpu_queue_mgr queue_mgr; | 733 | struct amdgpu_queue_mgr queue_mgr; |
734 | unsigned reset_counter; | 734 | unsigned reset_counter; |
735 | uint32_t vram_lost_counter; | ||
735 | spinlock_t ring_lock; | 736 | spinlock_t ring_lock; |
736 | struct dma_fence **fences; | 737 | struct dma_fence **fences; |
737 | struct amdgpu_ctx_ring rings[AMDGPU_MAX_RINGS]; | 738 | struct amdgpu_ctx_ring rings[AMDGPU_MAX_RINGS]; |
738 | bool preamble_presented; | 739 | bool preamble_presented; |
739 | enum amd_sched_priority init_priority; | 740 | enum amd_sched_priority init_priority; |
740 | enum amd_sched_priority override_priority; | 741 | enum amd_sched_priority override_priority; |
741 | struct mutex lock; | 742 | struct mutex lock; |
@@ -778,7 +779,6 @@ struct amdgpu_fpriv { | |||
778 | struct mutex bo_list_lock; | 779 | struct mutex bo_list_lock; |
779 | struct idr bo_list_handles; | 780 | struct idr bo_list_handles; |
780 | struct amdgpu_ctx_mgr ctx_mgr; | 781 | struct amdgpu_ctx_mgr ctx_mgr; |
781 | u32 vram_lost_counter; | ||
782 | }; | 782 | }; |
783 | 783 | ||
784 | /* | 784 | /* |
@@ -1860,8 +1860,6 @@ static inline bool amdgpu_has_atpx(void) { return false; } | |||
1860 | extern const struct drm_ioctl_desc amdgpu_ioctls_kms[]; | 1860 | extern const struct drm_ioctl_desc amdgpu_ioctls_kms[]; |
1861 | extern const int amdgpu_max_kms_ioctl; | 1861 | extern const int amdgpu_max_kms_ioctl; |
1862 | 1862 | ||
1863 | bool amdgpu_kms_vram_lost(struct amdgpu_device *adev, | ||
1864 | struct amdgpu_fpriv *fpriv); | ||
1865 | int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags); | 1863 | int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags); |
1866 | void amdgpu_driver_unload_kms(struct drm_device *dev); | 1864 | void amdgpu_driver_unload_kms(struct drm_device *dev); |
1867 | void amdgpu_driver_lastclose_kms(struct drm_device *dev); | 1865 | void amdgpu_driver_lastclose_kms(struct drm_device *dev); |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index 9daa7cac0ffb..b355189533d2 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | |||
@@ -172,7 +172,11 @@ static int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, void *data) | |||
172 | if (ret) | 172 | if (ret) |
173 | goto free_all_kdata; | 173 | goto free_all_kdata; |
174 | 174 | ||
175 | p->job->vram_lost_counter = fpriv->vram_lost_counter; | 175 | p->job->vram_lost_counter = atomic_read(&p->adev->vram_lost_counter); |
176 | if (p->ctx->vram_lost_counter != p->job->vram_lost_counter) { | ||
177 | ret = -ECANCELED; | ||
178 | goto free_all_kdata; | ||
179 | } | ||
176 | 180 | ||
177 | if (p->uf_entry.robj) | 181 | if (p->uf_entry.robj) |
178 | p->job->uf_addr = uf_offset; | 182 | p->job->uf_addr = uf_offset; |
@@ -1205,7 +1209,6 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p, | |||
1205 | int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) | 1209 | int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) |
1206 | { | 1210 | { |
1207 | struct amdgpu_device *adev = dev->dev_private; | 1211 | struct amdgpu_device *adev = dev->dev_private; |
1208 | struct amdgpu_fpriv *fpriv = filp->driver_priv; | ||
1209 | union drm_amdgpu_cs *cs = data; | 1212 | union drm_amdgpu_cs *cs = data; |
1210 | struct amdgpu_cs_parser parser = {}; | 1213 | struct amdgpu_cs_parser parser = {}; |
1211 | bool reserved_buffers = false; | 1214 | bool reserved_buffers = false; |
@@ -1213,8 +1216,6 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) | |||
1213 | 1216 | ||
1214 | if (!adev->accel_working) | 1217 | if (!adev->accel_working) |
1215 | return -EBUSY; | 1218 | return -EBUSY; |
1216 | if (amdgpu_kms_vram_lost(adev, fpriv)) | ||
1217 | return -ENODEV; | ||
1218 | 1219 | ||
1219 | parser.adev = adev; | 1220 | parser.adev = adev; |
1220 | parser.filp = filp; | 1221 | parser.filp = filp; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c index 4309820658c4..c184468e2b2b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | |||
@@ -75,6 +75,7 @@ static int amdgpu_ctx_init(struct amdgpu_device *adev, | |||
75 | } | 75 | } |
76 | 76 | ||
77 | ctx->reset_counter = atomic_read(&adev->gpu_reset_counter); | 77 | ctx->reset_counter = atomic_read(&adev->gpu_reset_counter); |
78 | ctx->vram_lost_counter = atomic_read(&adev->vram_lost_counter); | ||
78 | ctx->init_priority = priority; | 79 | ctx->init_priority = priority; |
79 | ctx->override_priority = AMD_SCHED_PRIORITY_UNSET; | 80 | ctx->override_priority = AMD_SCHED_PRIORITY_UNSET; |
80 | 81 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c index f759836d10ef..ff1a416a66c9 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | |||
@@ -790,21 +790,6 @@ void amdgpu_driver_lastclose_kms(struct drm_device *dev) | |||
790 | } | 790 | } |
791 | 791 | ||
792 | /** | 792 | /** |
793 | * amdgpu_kms_vram_lost - check if VRAM was lost for this client | ||
794 | * | ||
795 | * @adev: amdgpu device | ||
796 | * @fpriv: client private | ||
797 | * | ||
798 | * Check if all CS is blocked for the client because of lost VRAM | ||
799 | */ | ||
800 | bool amdgpu_kms_vram_lost(struct amdgpu_device *adev, | ||
801 | struct amdgpu_fpriv *fpriv) | ||
802 | { | ||
803 | return fpriv->vram_lost_counter != | ||
804 | atomic_read(&adev->vram_lost_counter); | ||
805 | } | ||
806 | |||
807 | /** | ||
808 | * amdgpu_driver_open_kms - drm callback for open | 793 | * amdgpu_driver_open_kms - drm callback for open |
809 | * | 794 | * |
810 | * @dev: drm dev pointer | 795 | * @dev: drm dev pointer |
@@ -860,7 +845,6 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv) | |||
860 | 845 | ||
861 | amdgpu_ctx_mgr_init(&fpriv->ctx_mgr); | 846 | amdgpu_ctx_mgr_init(&fpriv->ctx_mgr); |
862 | 847 | ||
863 | fpriv->vram_lost_counter = atomic_read(&adev->vram_lost_counter); | ||
864 | file_priv->driver_priv = fpriv; | 848 | file_priv->driver_priv = fpriv; |
865 | 849 | ||
866 | out_suspend: | 850 | out_suspend: |