Skip to content

Commit 4efdddb

Browse files
committed
Merge tag 'amd-drm-next-5.17-2022-01-12' of https://gitlab.freedesktop.org/agd5f/linux into drm-next
amd-drm-next-5.17-2022-01-12: amdgpu: - SR-IOV fixes - Suspend/resume fixes - Display fixes - DMCUB fixes - DP alt mode fixes - RAS fixes - UBSAN fix - Navy Flounder VCN fix - ttm resource manager cleanup - default_groups change for kobj_type - vkms fix - Aldebaran fixes amdkfd: - SDMA ECC interrupt fix - License clarification - Pointer check fix - DQM fixes for hawaii - default_groups change for kobj_type - Typo fixes Signed-off-by: Daniel Vetter <[email protected]> From: Alex Deucher <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2 parents 820e690 + 5eb877b commit 4efdddb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+422
-330
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -514,13 +514,6 @@ int amdgpu_amdkfd_get_dmabuf_info(struct amdgpu_device *adev, int dma_buf_fd,
514514
return r;
515515
}
516516

517-
uint64_t amdgpu_amdkfd_get_vram_usage(struct amdgpu_device *adev)
518-
{
519-
struct ttm_resource_manager *vram_man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
520-
521-
return amdgpu_vram_mgr_usage(vram_man);
522-
}
523-
524517
uint8_t amdgpu_amdkfd_get_xgmi_hops_count(struct amdgpu_device *dst,
525518
struct amdgpu_device *src)
526519
{

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ int amdgpu_amdkfd_get_dmabuf_info(struct amdgpu_device *adev, int dma_buf_fd,
223223
uint64_t *bo_size, void *metadata_buffer,
224224
size_t buffer_size, uint32_t *metadata_size,
225225
uint32_t *flags);
226-
uint64_t amdgpu_amdkfd_get_vram_usage(struct amdgpu_device *adev);
227226
uint8_t amdgpu_amdkfd_get_xgmi_hops_count(struct amdgpu_device *dst,
228227
struct amdgpu_device *src);
229228
int amdgpu_amdkfd_get_xgmi_bandwidth_mbytes(struct amdgpu_device *dst,

drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,6 @@ static void amdgpu_cs_get_threshold_for_moves(struct amdgpu_device *adev,
298298
{
299299
s64 time_us, increment_us;
300300
u64 free_vram, total_vram, used_vram;
301-
struct ttm_resource_manager *vram_man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
302301
/* Allow a maximum of 200 accumulated ms. This is basically per-IB
303302
* throttling.
304303
*
@@ -315,7 +314,7 @@ static void amdgpu_cs_get_threshold_for_moves(struct amdgpu_device *adev,
315314
}
316315

317316
total_vram = adev->gmc.real_vram_size - atomic64_read(&adev->vram_pin_size);
318-
used_vram = amdgpu_vram_mgr_usage(vram_man);
317+
used_vram = amdgpu_vram_mgr_usage(&adev->mman.vram_mgr);
319318
free_vram = used_vram >= total_vram ? 0 : total_vram - used_vram;
320319

321320
spin_lock(&adev->mm_stats.lock);
@@ -362,7 +361,7 @@ static void amdgpu_cs_get_threshold_for_moves(struct amdgpu_device *adev,
362361
if (!amdgpu_gmc_vram_full_visible(&adev->gmc)) {
363362
u64 total_vis_vram = adev->gmc.visible_vram_size;
364363
u64 used_vis_vram =
365-
amdgpu_vram_mgr_vis_usage(vram_man);
364+
amdgpu_vram_mgr_vis_usage(&adev->mman.vram_mgr);
366365

367366
if (used_vis_vram < total_vis_vram) {
368367
u64 free_vis_vram = total_vis_vram - used_vis_vram;

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ void amdgpu_device_wreg(struct amdgpu_device *adev,
552552
}
553553

554554
/**
555-
* amdgpu_mm_wreg_mmio_rlc - write register either with mmio or with RLC path if in range
555+
* amdgpu_mm_wreg_mmio_rlc - write register either with direct/indirect mmio or with RLC path if in range
556556
*
557557
* this function is invoked only the debugfs register access
558558
*/
@@ -567,6 +567,8 @@ void amdgpu_mm_wreg_mmio_rlc(struct amdgpu_device *adev,
567567
adev->gfx.rlc.funcs->is_rlcg_access_range) {
568568
if (adev->gfx.rlc.funcs->is_rlcg_access_range(adev, reg))
569569
return adev->gfx.rlc.funcs->sriov_wreg(adev, reg, v, 0, 0);
570+
} else if ((reg * 4) >= adev->rmmio_size) {
571+
adev->pcie_wreg(adev, reg * 4, v);
570572
} else {
571573
writel(v, ((void __iomem *)adev->rmmio) + (reg * 4));
572574
}
@@ -1448,7 +1450,7 @@ static int amdgpu_device_init_apu_flags(struct amdgpu_device *adev)
14481450
adev->apu_flags |= AMD_APU_IS_CYAN_SKILLFISH2;
14491451
break;
14501452
default:
1451-
return -EINVAL;
1453+
break;
14521454
}
14531455

14541456
return 0;
@@ -3496,9 +3498,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
34963498
mutex_init(&adev->psp.mutex);
34973499
mutex_init(&adev->notifier_lock);
34983500

3499-
r = amdgpu_device_init_apu_flags(adev);
3500-
if (r)
3501-
return r;
3501+
amdgpu_device_init_apu_flags(adev);
35023502

35033503
r = amdgpu_device_check_arguments(adev);
35043504
if (r)
@@ -3833,6 +3833,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
38333833

38343834
static void amdgpu_device_unmap_mmio(struct amdgpu_device *adev)
38353835
{
3836+
38363837
/* Clear all CPU mappings pointing to this device */
38373838
unmap_mapping_range(adev->ddev.anon_inode->i_mapping, 0, 0, 1);
38383839

@@ -3913,6 +3914,8 @@ void amdgpu_device_fini_hw(struct amdgpu_device *adev)
39133914

39143915
void amdgpu_device_fini_sw(struct amdgpu_device *adev)
39153916
{
3917+
int idx;
3918+
39163919
amdgpu_fence_driver_sw_fini(adev);
39173920
amdgpu_device_ip_fini(adev);
39183921
release_firmware(adev->firmware.gpu_info_fw);
@@ -3937,6 +3940,14 @@ void amdgpu_device_fini_sw(struct amdgpu_device *adev)
39373940
if ((adev->pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
39383941
vga_client_unregister(adev->pdev);
39393942

3943+
if (drm_dev_enter(adev_to_drm(adev), &idx)) {
3944+
3945+
iounmap(adev->rmmio);
3946+
adev->rmmio = NULL;
3947+
amdgpu_device_doorbell_fini(adev);
3948+
drm_dev_exit(idx);
3949+
}
3950+
39403951
if (IS_ENABLED(CONFIG_PERF_EVENTS))
39413952
amdgpu_pmu_fini(adev);
39423953
if (adev->mman.discovery_bin)
@@ -3957,8 +3968,8 @@ void amdgpu_device_fini_sw(struct amdgpu_device *adev)
39573968
*/
39583969
static void amdgpu_device_evict_resources(struct amdgpu_device *adev)
39593970
{
3960-
/* No need to evict vram on APUs for suspend to ram */
3961-
if (adev->in_s3 && (adev->flags & AMD_IS_APU))
3971+
/* No need to evict vram on APUs for suspend to ram or s2idle */
3972+
if ((adev->in_s3 || adev->in_s0ix) && (adev->flags & AMD_IS_APU))
39623973
return;
39633974

39643975
if (amdgpu_ttm_evict_resources(adev, TTM_PL_VRAM))
@@ -4005,16 +4016,11 @@ int amdgpu_device_suspend(struct drm_device *dev, bool fbcon)
40054016
if (!adev->in_s0ix)
40064017
amdgpu_amdkfd_suspend(adev, adev->in_runpm);
40074018

4008-
/* First evict vram memory */
40094019
amdgpu_device_evict_resources(adev);
40104020

40114021
amdgpu_fence_driver_hw_fini(adev);
40124022

40134023
amdgpu_device_ip_suspend_phase2(adev);
4014-
/* This second call to evict device resources is to evict
4015-
* the gart page table using the CPU.
4016-
*/
4017-
amdgpu_device_evict_resources(adev);
40184024

40194025
return 0;
40204026
}
@@ -4359,8 +4365,6 @@ static int amdgpu_device_reset_sriov(struct amdgpu_device *adev,
43594365
goto error;
43604366

43614367
amdgpu_virt_init_data_exchange(adev);
4362-
/* we need recover gart prior to run SMC/CP/SDMA resume */
4363-
amdgpu_gtt_mgr_recover(ttm_manager_type(&adev->mman.bdev, TTM_PL_TT));
43644368

43654369
r = amdgpu_device_fw_loading(adev);
43664370
if (r)
@@ -4680,10 +4684,6 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle,
46804684
amdgpu_inc_vram_lost(tmp_adev);
46814685
}
46824686

4683-
r = amdgpu_gtt_mgr_recover(ttm_manager_type(&tmp_adev->mman.bdev, TTM_PL_TT));
4684-
if (r)
4685-
goto out;
4686-
46874687
r = amdgpu_device_fw_loading(tmp_adev);
46884688
if (r)
46894689
return r;

drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,8 @@ void amdgpu_discovery_harvest_ip(struct amdgpu_device *adev)
550550
}
551551
/* some IP discovery tables on Navy Flounder don't have this set correctly */
552552
if ((adev->ip_versions[UVD_HWIP][1] == IP_VERSION(3, 0, 1)) &&
553-
(adev->ip_versions[GC_HWIP][0] == IP_VERSION(10, 3, 2)))
553+
(adev->ip_versions[GC_HWIP][0] == IP_VERSION(10, 3, 2)) &&
554+
(adev->pdev->revision != 0xFF))
554555
adev->vcn.harvest_config |= AMDGPU_VCN_HARVEST_VCN1;
555556
if (vcn_harvest_count == adev->vcn.num_vcn_inst) {
556557
adev->harvest_ip_mask |= AMD_HARVEST_IP_VCN_MASK;

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2166,9 +2166,9 @@ static int amdgpu_pmops_suspend(struct device *dev)
21662166

21672167
if (amdgpu_acpi_is_s0ix_active(adev))
21682168
adev->in_s0ix = true;
2169-
adev->in_s3 = true;
2169+
else
2170+
adev->in_s3 = true;
21702171
r = amdgpu_device_suspend(drm_dev, true);
2171-
adev->in_s3 = false;
21722172
if (r)
21732173
return r;
21742174
if (!adev->in_s0ix)
@@ -2189,6 +2189,8 @@ static int amdgpu_pmops_resume(struct device *dev)
21892189
r = amdgpu_device_resume(drm_dev, true);
21902190
if (amdgpu_acpi_is_s0ix_active(adev))
21912191
adev->in_s0ix = false;
2192+
else
2193+
adev->in_s3 = false;
21922194
return r;
21932195
}
21942196

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c

Lines changed: 6 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -114,80 +114,12 @@ void amdgpu_gart_dummy_page_fini(struct amdgpu_device *adev)
114114
*/
115115
int amdgpu_gart_table_vram_alloc(struct amdgpu_device *adev)
116116
{
117-
int r;
118-
119-
if (adev->gart.bo == NULL) {
120-
struct amdgpu_bo_param bp;
121-
122-
memset(&bp, 0, sizeof(bp));
123-
bp.size = adev->gart.table_size;
124-
bp.byte_align = PAGE_SIZE;
125-
bp.domain = AMDGPU_GEM_DOMAIN_VRAM;
126-
bp.flags = AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
127-
AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS;
128-
bp.type = ttm_bo_type_kernel;
129-
bp.resv = NULL;
130-
bp.bo_ptr_size = sizeof(struct amdgpu_bo);
131-
132-
r = amdgpu_bo_create(adev, &bp, &adev->gart.bo);
133-
if (r) {
134-
return r;
135-
}
136-
}
137-
return 0;
138-
}
139-
140-
/**
141-
* amdgpu_gart_table_vram_pin - pin gart page table in vram
142-
*
143-
* @adev: amdgpu_device pointer
144-
*
145-
* Pin the GART page table in vram so it will not be moved
146-
* by the memory manager (pcie r4xx, r5xx+). These asics require the
147-
* gart table to be in video memory.
148-
* Returns 0 for success, error for failure.
149-
*/
150-
int amdgpu_gart_table_vram_pin(struct amdgpu_device *adev)
151-
{
152-
int r;
153-
154-
r = amdgpu_bo_reserve(adev->gart.bo, false);
155-
if (unlikely(r != 0))
156-
return r;
157-
r = amdgpu_bo_pin(adev->gart.bo, AMDGPU_GEM_DOMAIN_VRAM);
158-
if (r) {
159-
amdgpu_bo_unreserve(adev->gart.bo);
160-
return r;
161-
}
162-
r = amdgpu_bo_kmap(adev->gart.bo, &adev->gart.ptr);
163-
if (r)
164-
amdgpu_bo_unpin(adev->gart.bo);
165-
amdgpu_bo_unreserve(adev->gart.bo);
166-
return r;
167-
}
168-
169-
/**
170-
* amdgpu_gart_table_vram_unpin - unpin gart page table in vram
171-
*
172-
* @adev: amdgpu_device pointer
173-
*
174-
* Unpin the GART page table in vram (pcie r4xx, r5xx+).
175-
* These asics require the gart table to be in video memory.
176-
*/
177-
void amdgpu_gart_table_vram_unpin(struct amdgpu_device *adev)
178-
{
179-
int r;
117+
if (adev->gart.bo != NULL)
118+
return 0;
180119

181-
if (adev->gart.bo == NULL) {
182-
return;
183-
}
184-
r = amdgpu_bo_reserve(adev->gart.bo, true);
185-
if (likely(r == 0)) {
186-
amdgpu_bo_kunmap(adev->gart.bo);
187-
amdgpu_bo_unpin(adev->gart.bo);
188-
amdgpu_bo_unreserve(adev->gart.bo);
189-
adev->gart.ptr = NULL;
190-
}
120+
return amdgpu_bo_create_kernel(adev, adev->gart.table_size, PAGE_SIZE,
121+
AMDGPU_GEM_DOMAIN_VRAM, &adev->gart.bo,
122+
NULL, (void *)&adev->gart.ptr);
191123
}
192124

193125
/**
@@ -201,11 +133,7 @@ void amdgpu_gart_table_vram_unpin(struct amdgpu_device *adev)
201133
*/
202134
void amdgpu_gart_table_vram_free(struct amdgpu_device *adev)
203135
{
204-
if (adev->gart.bo == NULL) {
205-
return;
206-
}
207-
amdgpu_bo_unref(&adev->gart.bo);
208-
adev->gart.ptr = NULL;
136+
amdgpu_bo_free_kernel(&adev->gart.bo, NULL, (void *)&adev->gart.ptr);
209137
}
210138

211139
/*

drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,6 @@ static int amdgpu_gem_object_mmap(struct drm_gem_object *obj, struct vm_area_str
264264
!(vma->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)))
265265
vma->vm_flags &= ~VM_MAYWRITE;
266266

267-
if (bo->kfd_bo)
268-
vma->vm_flags |= VM_DONTCOPY;
269-
270267
return drm_gem_ttm_mmap(obj, vma);
271268
}
272269

drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,8 @@ static ssize_t amdgpu_mem_info_gtt_used_show(struct device *dev,
7777
{
7878
struct drm_device *ddev = dev_get_drvdata(dev);
7979
struct amdgpu_device *adev = drm_to_adev(ddev);
80-
struct ttm_resource_manager *man;
8180

82-
man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
83-
return sysfs_emit(buf, "%llu\n", amdgpu_gtt_mgr_usage(man));
81+
return sysfs_emit(buf, "%llu\n", amdgpu_gtt_mgr_usage(&adev->mman.gtt_mgr));
8482
}
8583

8684
static DEVICE_ATTR(mem_info_gtt_total, S_IRUGO,
@@ -206,30 +204,27 @@ static void amdgpu_gtt_mgr_del(struct ttm_resource_manager *man,
206204
/**
207205
* amdgpu_gtt_mgr_usage - return usage of GTT domain
208206
*
209-
* @man: TTM memory type manager
207+
* @mgr: amdgpu_gtt_mgr pointer
210208
*
211209
* Return how many bytes are used in the GTT domain
212210
*/
213-
uint64_t amdgpu_gtt_mgr_usage(struct ttm_resource_manager *man)
211+
uint64_t amdgpu_gtt_mgr_usage(struct amdgpu_gtt_mgr *mgr)
214212
{
215-
struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
216-
217213
return atomic64_read(&mgr->used) * PAGE_SIZE;
218214
}
219215

220216
/**
221217
* amdgpu_gtt_mgr_recover - re-init gart
222218
*
223-
* @man: TTM memory type manager
219+
* @mgr: amdgpu_gtt_mgr pointer
224220
*
225221
* Re-init the gart for each known BO in the GTT.
226222
*/
227-
int amdgpu_gtt_mgr_recover(struct ttm_resource_manager *man)
223+
int amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr)
228224
{
229-
struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
230-
struct amdgpu_device *adev;
231225
struct amdgpu_gtt_node *node;
232226
struct drm_mm_node *mm_node;
227+
struct amdgpu_device *adev;
233228
int r = 0;
234229

235230
adev = container_of(mgr, typeof(*adev), mman.gtt_mgr);

0 commit comments

Comments
 (0)