Skip to content

Commit 49eea1c

Browse files
committed
Merge tag 'amd-drm-next-5.8-2020-05-12' of git://people.freedesktop.org/~agd5f/linux into drm-next
amd-drm-next-5.8-2020-05-12: amdgpu: - Misc cleanups - RAS fixes - Expose FP16 for modesetting - DP 1.4 compliance test fixes - Clockgating fixes - MAINTAINERS update - Soft recovery for gfx10 - Runtime PM cleanups - PSP code cleanups amdkfd: - Track GPU memory utilization per process - Report PCI domain in topology Signed-off-by: Dave Airlie <[email protected]> From: Alex Deucher <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2 parents a1fb548 + 37e4f05 commit 49eea1c

File tree

98 files changed

+1549
-1981
lines changed

Some content is hidden

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

98 files changed

+1549
-1981
lines changed

MAINTAINERS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14063,7 +14063,6 @@ F: drivers/net/wireless/quantenna
1406314063
RADEON and AMDGPU DRM DRIVERS
1406414064
M: Alex Deucher <[email protected]>
1406514065
M: Christian König <[email protected]>
14066-
M: David (ChunMing) Zhou <[email protected]>
1406714066
1406814067
S: Supported
1406914068
T: git git://people.freedesktop.org/~agd5f/linux

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,6 @@ struct amdgpu_device {
765765
uint8_t *bios;
766766
uint32_t bios_size;
767767
struct amdgpu_bo *stolen_vga_memory;
768-
struct amdgpu_bo *discovery_memory;
769768
uint32_t bios_scratch_reg_offset;
770769
uint32_t bios_scratch[AMDGPU_BIOS_NUM_SCRATCH];
771770

@@ -918,7 +917,9 @@ struct amdgpu_device {
918917
struct amdgpu_display_manager dm;
919918

920919
/* discovery */
921-
uint8_t *discovery;
920+
uint8_t *discovery_bin;
921+
uint32_t discovery_tmr_size;
922+
struct amdgpu_bo *discovery_memory;
922923

923924
/* mes */
924925
bool enable_mes;
@@ -957,6 +958,7 @@ struct amdgpu_device {
957958

958959
/* s3/s4 mask */
959960
bool in_suspend;
961+
bool in_hibernate;
960962

961963
bool in_gpu_reset;
962964
enum pp_mp1_state mp1_state;

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,6 @@ static int amdgpu_atif_handler(struct amdgpu_device *adev,
444444

445445
DRM_DEBUG_DRIVER("ATIF: %d pending SBIOS requests\n", count);
446446

447-
/* todo: add DC handling */
448447
if ((req.pending & ATIF_PANEL_BRIGHTNESS_CHANGE_REQUEST) &&
449448
!amdgpu_device_has_dc_support(adev)) {
450449
struct amdgpu_encoder *enc = atif->encoder_for_bl;
@@ -463,6 +462,27 @@ static int amdgpu_atif_handler(struct amdgpu_device *adev,
463462
#endif
464463
}
465464
}
465+
#if defined(CONFIG_DRM_AMD_DC)
466+
#if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) || defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)
467+
if ((req.pending & ATIF_PANEL_BRIGHTNESS_CHANGE_REQUEST) &&
468+
amdgpu_device_has_dc_support(adev)) {
469+
struct amdgpu_display_manager *dm = &adev->dm;
470+
struct backlight_device *bd = dm->backlight_dev;
471+
472+
if (bd) {
473+
DRM_DEBUG_DRIVER("Changing brightness to %d\n",
474+
req.backlight_level);
475+
476+
/*
477+
* XXX backlight_device_set_brightness() is
478+
* hardwired to post BACKLIGHT_UPDATE_SYSFS.
479+
* It probably should accept 'reason' parameter.
480+
*/
481+
backlight_device_set_brightness(bd, req.backlight_level);
482+
}
483+
}
484+
#endif
485+
#endif
466486
if (req.pending & ATIF_DGPU_DISPLAY_EVENT) {
467487
if (adev->flags & AMD_IS_PX) {
468488
pm_runtime_get_sync(adev->ddev->dev);

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ struct kgd_mem {
6565
struct amdgpu_sync sync;
6666

6767
bool aql_queue;
68+
bool is_imported;
6869
};
6970

7071
/* KFD Memory Eviction */
@@ -148,6 +149,9 @@ int amdgpu_amdkfd_post_reset(struct amdgpu_device *adev);
148149

149150
void amdgpu_amdkfd_gpu_reset(struct kgd_dev *kgd);
150151

152+
int amdgpu_queue_mask_bit_to_set_resource_bit(struct amdgpu_device *adev,
153+
int queue_bit);
154+
151155
/* Shared API */
152156
int amdgpu_amdkfd_alloc_gtt_mem(struct kgd_dev *kgd, size_t size,
153157
void **mem_obj, uint64_t *gpu_addr,
@@ -219,7 +223,7 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(
219223
void *vm, struct kgd_mem **mem,
220224
uint64_t *offset, uint32_t flags);
221225
int amdgpu_amdkfd_gpuvm_free_memory_of_gpu(
222-
struct kgd_dev *kgd, struct kgd_mem *mem);
226+
struct kgd_dev *kgd, struct kgd_mem *mem, uint64_t *size);
223227
int amdgpu_amdkfd_gpuvm_map_memory_to_gpu(
224228
struct kgd_dev *kgd, struct kgd_mem *mem, void *vm);
225229
int amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu(

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

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,7 +1277,7 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(
12771277
}
12781278

12791279
int amdgpu_amdkfd_gpuvm_free_memory_of_gpu(
1280-
struct kgd_dev *kgd, struct kgd_mem *mem)
1280+
struct kgd_dev *kgd, struct kgd_mem *mem, uint64_t *size)
12811281
{
12821282
struct amdkfd_process_info *process_info = mem->process_info;
12831283
unsigned long bo_size = mem->bo->tbo.mem.size;
@@ -1286,9 +1286,11 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu(
12861286
struct ttm_validate_buffer *bo_list_entry;
12871287
unsigned int mapped_to_gpu_memory;
12881288
int ret;
1289+
bool is_imported = 0;
12891290

12901291
mutex_lock(&mem->lock);
12911292
mapped_to_gpu_memory = mem->mapped_to_gpu_memory;
1293+
is_imported = mem->is_imported;
12921294
mutex_unlock(&mem->lock);
12931295
/* lock is not needed after this, since mem is unused and will
12941296
* be freed anyway
@@ -1340,8 +1342,19 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu(
13401342
kfree(mem->bo->tbo.sg);
13411343
}
13421344

1345+
/* Update the size of the BO being freed if it was allocated from
1346+
* VRAM and is not imported.
1347+
*/
1348+
if (size) {
1349+
if ((mem->bo->preferred_domains == AMDGPU_GEM_DOMAIN_VRAM) &&
1350+
(!is_imported))
1351+
*size = bo_size;
1352+
else
1353+
*size = 0;
1354+
}
1355+
13431356
/* Free the BO*/
1344-
amdgpu_bo_unref(&mem->bo);
1357+
drm_gem_object_put_unlocked(&mem->bo->tbo.base);
13451358
mutex_destroy(&mem->lock);
13461359
kfree(mem);
13471360

@@ -1686,14 +1699,16 @@ int amdgpu_amdkfd_gpuvm_import_dmabuf(struct kgd_dev *kgd,
16861699
| KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE
16871700
| KFD_IOC_ALLOC_MEM_FLAGS_EXECUTABLE;
16881701

1689-
(*mem)->bo = amdgpu_bo_ref(bo);
1702+
drm_gem_object_get(&bo->tbo.base);
1703+
(*mem)->bo = bo;
16901704
(*mem)->va = va;
16911705
(*mem)->domain = (bo->preferred_domains & AMDGPU_GEM_DOMAIN_VRAM) ?
16921706
AMDGPU_GEM_DOMAIN_VRAM : AMDGPU_GEM_DOMAIN_GTT;
16931707
(*mem)->mapped_to_gpu_memory = 0;
16941708
(*mem)->process_info = avm->process_info;
16951709
add_kgd_mem_to_kfd_bo_list(*mem, avm->process_info, false);
16961710
amdgpu_sync_create(&(*mem)->sync);
1711+
(*mem)->is_imported = true;
16971712

16981713
return 0;
16991714
}

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,6 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
12081208
{
12091209
struct amdgpu_fpriv *fpriv = p->filp->driver_priv;
12101210
struct drm_sched_entity *entity = p->entity;
1211-
enum drm_sched_priority priority;
12121211
struct amdgpu_bo_list_entry *e;
12131212
struct amdgpu_job *job;
12141213
uint64_t seq;
@@ -1258,7 +1257,6 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
12581257

12591258
trace_amdgpu_cs_ioctl(job);
12601259
amdgpu_vm_bo_trace_cs(&fpriv->vm, &p->ticket);
1261-
priority = job->base.s_priority;
12621260
drm_sched_entity_push_job(&job->base, entity);
12631261

12641262
amdgpu_vm_move_to_lru_tail(p->adev, &fpriv->vm);

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

Lines changed: 113 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868

6969
#include <linux/suspend.h>
7070
#include <drm/task_barrier.h>
71+
#include <linux/pm_runtime.h>
7172

7273
MODULE_FIRMWARE("amdgpu/vega10_gpu_info.bin");
7374
MODULE_FIRMWARE("amdgpu/vega12_gpu_info.bin");
@@ -254,6 +255,32 @@ void amdgpu_device_vram_access(struct amdgpu_device *adev, loff_t pos,
254255
uint32_t hi = ~0;
255256
uint64_t last;
256257

258+
259+
#ifdef CONFIG_64BIT
260+
last = min(pos + size, adev->gmc.visible_vram_size);
261+
if (last > pos) {
262+
void __iomem *addr = adev->mman.aper_base_kaddr + pos;
263+
size_t count = last - pos;
264+
265+
if (write) {
266+
memcpy_toio(addr, buf, count);
267+
mb();
268+
amdgpu_asic_flush_hdp(adev, NULL);
269+
} else {
270+
amdgpu_asic_invalidate_hdp(adev, NULL);
271+
mb();
272+
memcpy_fromio(buf, addr, count);
273+
}
274+
275+
if (count == size)
276+
return;
277+
278+
pos += count;
279+
buf += count / 4;
280+
size -= count;
281+
}
282+
#endif
283+
257284
spin_lock_irqsave(&adev->mmio_idx_lock, flags);
258285
for (last = pos + size; pos < last; pos += 4) {
259286
uint32_t tmp = pos >> 31;
@@ -2891,6 +2918,14 @@ static int amdgpu_device_get_job_timeout_settings(struct amdgpu_device *adev)
28912918
return ret;
28922919
}
28932920

2921+
static const struct attribute *amdgpu_dev_attributes[] = {
2922+
&dev_attr_product_name.attr,
2923+
&dev_attr_product_number.attr,
2924+
&dev_attr_serial_number.attr,
2925+
&dev_attr_pcie_replay_count.attr,
2926+
NULL
2927+
};
2928+
28942929
/**
28952930
* amdgpu_device_init - initialize the driver
28962931
*
@@ -3240,27 +3275,9 @@ int amdgpu_device_init(struct amdgpu_device *adev,
32403275
queue_delayed_work(system_wq, &adev->delayed_init_work,
32413276
msecs_to_jiffies(AMDGPU_RESUME_MS));
32423277

3243-
r = device_create_file(adev->dev, &dev_attr_pcie_replay_count);
3278+
r = sysfs_create_files(&adev->dev->kobj, amdgpu_dev_attributes);
32443279
if (r) {
3245-
dev_err(adev->dev, "Could not create pcie_replay_count");
3246-
return r;
3247-
}
3248-
3249-
r = device_create_file(adev->dev, &dev_attr_product_name);
3250-
if (r) {
3251-
dev_err(adev->dev, "Could not create product_name");
3252-
return r;
3253-
}
3254-
3255-
r = device_create_file(adev->dev, &dev_attr_product_number);
3256-
if (r) {
3257-
dev_err(adev->dev, "Could not create product_number");
3258-
return r;
3259-
}
3260-
3261-
r = device_create_file(adev->dev, &dev_attr_serial_number);
3262-
if (r) {
3263-
dev_err(adev->dev, "Could not create serial_number");
3280+
dev_err(adev->dev, "Could not create amdgpu device attr\n");
32643281
return r;
32653282
}
32663283

@@ -3343,12 +3360,10 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
33433360
adev->rmmio = NULL;
33443361
amdgpu_device_doorbell_fini(adev);
33453362

3346-
device_remove_file(adev->dev, &dev_attr_pcie_replay_count);
33473363
if (adev->ucode_sysfs_en)
33483364
amdgpu_ucode_sysfs_fini(adev);
3349-
device_remove_file(adev->dev, &dev_attr_product_name);
3350-
device_remove_file(adev->dev, &dev_attr_product_number);
3351-
device_remove_file(adev->dev, &dev_attr_serial_number);
3365+
3366+
sysfs_remove_files(&adev->dev->kobj, amdgpu_dev_attributes);
33523367
if (IS_ENABLED(CONFIG_PERF_EVENTS))
33533368
amdgpu_pmu_fini(adev);
33543369
if (amdgpu_discovery && adev->asic_type >= CHIP_NAVI10)
@@ -4116,6 +4131,64 @@ static void amdgpu_device_unlock_adev(struct amdgpu_device *adev)
41164131
mutex_unlock(&adev->lock_reset);
41174132
}
41184133

4134+
static void amdgpu_device_resume_display_audio(struct amdgpu_device *adev)
4135+
{
4136+
struct pci_dev *p = NULL;
4137+
4138+
p = pci_get_domain_bus_and_slot(pci_domain_nr(adev->pdev->bus),
4139+
adev->pdev->bus->number, 1);
4140+
if (p) {
4141+
pm_runtime_enable(&(p->dev));
4142+
pm_runtime_resume(&(p->dev));
4143+
}
4144+
}
4145+
4146+
static int amdgpu_device_suspend_display_audio(struct amdgpu_device *adev)
4147+
{
4148+
enum amd_reset_method reset_method;
4149+
struct pci_dev *p = NULL;
4150+
u64 expires;
4151+
4152+
/*
4153+
* For now, only BACO and mode1 reset are confirmed
4154+
* to suffer the audio issue without proper suspended.
4155+
*/
4156+
reset_method = amdgpu_asic_reset_method(adev);
4157+
if ((reset_method != AMD_RESET_METHOD_BACO) &&
4158+
(reset_method != AMD_RESET_METHOD_MODE1))
4159+
return -EINVAL;
4160+
4161+
p = pci_get_domain_bus_and_slot(pci_domain_nr(adev->pdev->bus),
4162+
adev->pdev->bus->number, 1);
4163+
if (!p)
4164+
return -ENODEV;
4165+
4166+
expires = pm_runtime_autosuspend_expiration(&(p->dev));
4167+
if (!expires)
4168+
/*
4169+
* If we cannot get the audio device autosuspend delay,
4170+
* a fixed 4S interval will be used. Considering 3S is
4171+
* the audio controller default autosuspend delay setting.
4172+
* 4S used here is guaranteed to cover that.
4173+
*/
4174+
expires = ktime_get_mono_fast_ns() + NSEC_PER_SEC * 4ULL;
4175+
4176+
while (!pm_runtime_status_suspended(&(p->dev))) {
4177+
if (!pm_runtime_suspend(&(p->dev)))
4178+
break;
4179+
4180+
if (expires < ktime_get_mono_fast_ns()) {
4181+
dev_warn(adev->dev, "failed to suspend display audio\n");
4182+
/* TODO: abort the succeeding gpu reset? */
4183+
return -ETIMEDOUT;
4184+
}
4185+
}
4186+
4187+
pm_runtime_disable(&(p->dev));
4188+
4189+
return 0;
4190+
}
4191+
41194192
/**
41204193
* amdgpu_device_gpu_recover - reset the asic and recover scheduler
41214194
*
@@ -4140,6 +4213,7 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,
41404213
bool use_baco =
41414214
(amdgpu_asic_reset_method(adev) == AMD_RESET_METHOD_BACO) ?
41424215
true : false;
4216+
bool audio_suspended = false;
41434217

41444218
/*
41454219
* Flush RAM to disk so that after reboot
@@ -4197,6 +4271,19 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,
41974271
return 0;
41984272
}
41994273

4274+
/*
4275+
* Try to put the audio codec into suspend state
4276+
* before gpu reset started.
4277+
*
4278+
* Due to the power domain of the graphics device
4279+
* is shared with AZ power domain. Without this,
4280+
* we may change the audio hardware from behind
4281+
* the audio driver's back. That will trigger
4282+
* some audio codec errors.
4283+
*/
4284+
if (!amdgpu_device_suspend_display_audio(tmp_adev))
4285+
audio_suspended = true;
4286+
42004287
amdgpu_ras_set_error_query_ready(tmp_adev, false);
42014288

42024289
cancel_delayed_work_sync(&tmp_adev->delayed_init_work);
@@ -4309,6 +4396,8 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,
43094396
/*unlock kfd: SRIOV would do it separately */
43104397
if (!(in_ras_intr && !use_baco) && !amdgpu_sriov_vf(tmp_adev))
43114398
amdgpu_amdkfd_post_reset(tmp_adev);
4399+
if (audio_suspended)
4400+
amdgpu_device_resume_display_audio(tmp_adev);
43124401
amdgpu_device_unlock_adev(tmp_adev);
43134402
}
43144403

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ struct amdgpu_df_funcs {
5252
uint64_t (*get_fica)(struct amdgpu_device *adev, uint32_t ficaa_val);
5353
void (*set_fica)(struct amdgpu_device *adev, uint32_t ficaa_val,
5454
uint32_t ficadl_val, uint32_t ficadh_val);
55-
uint64_t (*get_dram_base_addr)(struct amdgpu_device *adev,
56-
uint32_t df_inst);
57-
uint32_t (*get_df_inst_id)(struct amdgpu_device *adev);
5855
};
5956

6057
struct amdgpu_df {

0 commit comments

Comments
 (0)