Skip to content

Commit fecca68

Browse files
committed
Merge tag 'drm-fixes-2020-04-18' of git://anongit.freedesktop.org/drm/drm
Pull drm fixes from Dave Airlie: "Quiet enough for rc2, mostly amdgpu fixes, a couple of i915 fixes, and one nouveau module firmware fix: i915: - Fix guest page access by using the brand new VFIO dma r/w interface (Yan) - Fix for i915 perf read buffers (Ashutosh) amdgpu: - gfx10 fix - SMU7 overclocking fix - RAS fix - GPU reset fix - Fix a regression in a previous suspend/resume fix - Add a gfxoff quirk nouveau: - fix missing MODULE_FIRMWARE" * tag 'drm-fixes-2020-04-18' of git://anongit.freedesktop.org/drm/drm: drm/nouveau/sec2/gv100-: add missing MODULE_FIRMWARE() drm/amdgpu/gfx9: add gfxoff quirk drm/amdgpu: fix the hw hang during perform system reboot and reset drm/i915/gvt: switch to user vfio_group_pin/upin_pages drm/i915/gvt: subsitute kvm_read/write_guest with vfio_dma_rw drm/i915/gvt: hold reference of VFIO group during opening of vgpu drm/i915/perf: Do not clear pollin for small user read buffers drm/amdgpu: fix wrong vram lost counter increment V2 drm/amd/powerplay: unload mp1 for Arcturus RAS baco reset drm/amd/powerplay: force the trim of the mclk dpm_levels if OD is enabled Revert "drm/amdgpu: change SH MEM alignment mode for gfx10"
2 parents 90280ea + 4da858c commit fecca68

File tree

13 files changed

+85
-94
lines changed

13 files changed

+85
-94
lines changed

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2008,8 +2008,24 @@ static void amdgpu_device_fill_reset_magic(struct amdgpu_device *adev)
20082008
*/
20092009
static bool amdgpu_device_check_vram_lost(struct amdgpu_device *adev)
20102010
{
2011-
return !!memcmp(adev->gart.ptr, adev->reset_magic,
2012-
AMDGPU_RESET_MAGIC_NUM);
2011+
if (memcmp(adev->gart.ptr, adev->reset_magic,
2012+
AMDGPU_RESET_MAGIC_NUM))
2013+
return true;
2014+
2015+
if (!adev->in_gpu_reset)
2016+
return false;
2017+
2018+
/*
2019+
* For all ASICs with baco/mode1 reset, the VRAM is
2020+
* always assumed to be lost.
2021+
*/
2022+
switch (amdgpu_asic_reset_method(adev)) {
2023+
case AMD_RESET_METHOD_BACO:
2024+
case AMD_RESET_METHOD_MODE1:
2025+
return true;
2026+
default:
2027+
return false;
2028+
}
20132029
}
20142030

20152031
/**
@@ -2340,6 +2356,8 @@ static int amdgpu_device_ip_suspend_phase1(struct amdgpu_device *adev)
23402356
{
23412357
int i, r;
23422358

2359+
amdgpu_device_set_pg_state(adev, AMD_PG_STATE_UNGATE);
2360+
amdgpu_device_set_cg_state(adev, AMD_CG_STATE_UNGATE);
23432361

23442362
for (i = adev->num_ip_blocks - 1; i >= 0; i--) {
23452363
if (!adev->ip_blocks[i].status.valid)

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,8 +1358,6 @@ static int cik_asic_reset(struct amdgpu_device *adev)
13581358
int r;
13591359

13601360
if (cik_asic_reset_method(adev) == AMD_RESET_METHOD_BACO) {
1361-
if (!adev->in_suspend)
1362-
amdgpu_inc_vram_lost(adev);
13631361
r = amdgpu_dpm_baco_reset(adev);
13641362
} else {
13651363
r = cik_asic_pci_config_reset(adev);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ static const struct soc15_reg_golden golden_settings_gc_10_1_2_nv12[] =
279279

280280
#define DEFAULT_SH_MEM_CONFIG \
281281
((SH_MEM_ADDRESS_MODE_64 << SH_MEM_CONFIG__ADDRESS_MODE__SHIFT) | \
282-
(SH_MEM_ALIGNMENT_MODE_DWORD << SH_MEM_CONFIG__ALIGNMENT_MODE__SHIFT) | \
282+
(SH_MEM_ALIGNMENT_MODE_UNALIGNED << SH_MEM_CONFIG__ALIGNMENT_MODE__SHIFT) | \
283283
(SH_MEM_RETRY_MODE_ALL << SH_MEM_CONFIG__RETRY_MODE__SHIFT) | \
284284
(3 << SH_MEM_CONFIG__INITIAL_INST_PREFETCH__SHIFT))
285285

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,6 +1234,8 @@ struct amdgpu_gfxoff_quirk {
12341234
static const struct amdgpu_gfxoff_quirk amdgpu_gfxoff_quirk_list[] = {
12351235
/* https://bugzilla.kernel.org/show_bug.cgi?id=204689 */
12361236
{ 0x1002, 0x15dd, 0x1002, 0x15dd, 0xc8 },
1237+
/* https://bugzilla.kernel.org/show_bug.cgi?id=207171 */
1238+
{ 0x1002, 0x15dd, 0x103c, 0x83e7, 0xd3 },
12371239
{ 0, 0, 0, 0, 0 },
12381240
};
12391241

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,17 +351,13 @@ static int nv_asic_reset(struct amdgpu_device *adev)
351351
struct smu_context *smu = &adev->smu;
352352

353353
if (nv_asic_reset_method(adev) == AMD_RESET_METHOD_BACO) {
354-
if (!adev->in_suspend)
355-
amdgpu_inc_vram_lost(adev);
356354
ret = smu_baco_enter(smu);
357355
if (ret)
358356
return ret;
359357
ret = smu_baco_exit(smu);
360358
if (ret)
361359
return ret;
362360
} else {
363-
if (!adev->in_suspend)
364-
amdgpu_inc_vram_lost(adev);
365361
ret = nv_asic_mode1_reset(adev);
366362
}
367363

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -569,14 +569,10 @@ static int soc15_asic_reset(struct amdgpu_device *adev)
569569

570570
switch (soc15_asic_reset_method(adev)) {
571571
case AMD_RESET_METHOD_BACO:
572-
if (!adev->in_suspend)
573-
amdgpu_inc_vram_lost(adev);
574572
return soc15_asic_baco_reset(adev);
575573
case AMD_RESET_METHOD_MODE2:
576574
return amdgpu_dpm_mode2_reset(adev);
577575
default:
578-
if (!adev->in_suspend)
579-
amdgpu_inc_vram_lost(adev);
580576
return soc15_asic_mode1_reset(adev);
581577
}
582578
}

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -765,8 +765,6 @@ static int vi_asic_reset(struct amdgpu_device *adev)
765765
int r;
766766

767767
if (vi_asic_reset_method(adev) == AMD_RESET_METHOD_BACO) {
768-
if (!adev->in_suspend)
769-
amdgpu_inc_vram_lost(adev);
770768
r = amdgpu_dpm_baco_reset(adev);
771769
} else {
772770
r = vi_asic_pci_config_reset(adev);

drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3804,9 +3804,12 @@ static int smu7_trim_single_dpm_states(struct pp_hwmgr *hwmgr,
38043804
{
38053805
uint32_t i;
38063806

3807+
/* force the trim if mclk_switching is disabled to prevent flicker */
3808+
bool force_trim = (low_limit == high_limit);
38073809
for (i = 0; i < dpm_table->count; i++) {
38083810
/*skip the trim if od is enabled*/
3809-
if (!hwmgr->od_enabled && (dpm_table->dpm_levels[i].value < low_limit
3811+
if ((!hwmgr->od_enabled || force_trim)
3812+
&& (dpm_table->dpm_levels[i].value < low_limit
38103813
|| dpm_table->dpm_levels[i].value > high_limit))
38113814
dpm_table->dpm_levels[i].enabled = false;
38123815
else

drivers/gpu/drm/amd/powerplay/smu_v11_0.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1718,6 +1718,12 @@ int smu_v11_0_baco_set_state(struct smu_context *smu, enum smu_baco_state state)
17181718
if (ret)
17191719
goto out;
17201720

1721+
if (ras && ras->supported) {
1722+
ret = smu_send_smc_msg(smu, SMU_MSG_PrepareMp1ForUnload, NULL);
1723+
if (ret)
1724+
goto out;
1725+
}
1726+
17211727
/* clear vbios scratch 6 and 7 for coming asic reinit */
17221728
WREG32(adev->bios_scratch_reg_offset + 6, 0);
17231729
WREG32(adev->bios_scratch_reg_offset + 7, 0);

drivers/gpu/drm/i915/gvt/kvmgt.c

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ struct kvmgt_vdev {
131131
struct work_struct release_work;
132132
atomic_t released;
133133
struct vfio_device *vfio_device;
134+
struct vfio_group *vfio_group;
134135
};
135136

136137
static inline struct kvmgt_vdev *kvmgt_vdev(struct intel_vgpu *vgpu)
@@ -151,6 +152,7 @@ static void gvt_unpin_guest_page(struct intel_vgpu *vgpu, unsigned long gfn,
151152
unsigned long size)
152153
{
153154
struct drm_i915_private *i915 = vgpu->gvt->gt->i915;
155+
struct kvmgt_vdev *vdev = kvmgt_vdev(vgpu);
154156
int total_pages;
155157
int npage;
156158
int ret;
@@ -160,7 +162,7 @@ static void gvt_unpin_guest_page(struct intel_vgpu *vgpu, unsigned long gfn,
160162
for (npage = 0; npage < total_pages; npage++) {
161163
unsigned long cur_gfn = gfn + npage;
162164

163-
ret = vfio_unpin_pages(mdev_dev(kvmgt_vdev(vgpu)->mdev), &cur_gfn, 1);
165+
ret = vfio_group_unpin_pages(vdev->vfio_group, &cur_gfn, 1);
164166
drm_WARN_ON(&i915->drm, ret != 1);
165167
}
166168
}
@@ -169,6 +171,7 @@ static void gvt_unpin_guest_page(struct intel_vgpu *vgpu, unsigned long gfn,
169171
static int gvt_pin_guest_page(struct intel_vgpu *vgpu, unsigned long gfn,
170172
unsigned long size, struct page **page)
171173
{
174+
struct kvmgt_vdev *vdev = kvmgt_vdev(vgpu);
172175
unsigned long base_pfn = 0;
173176
int total_pages;
174177
int npage;
@@ -183,8 +186,8 @@ static int gvt_pin_guest_page(struct intel_vgpu *vgpu, unsigned long gfn,
183186
unsigned long cur_gfn = gfn + npage;
184187
unsigned long pfn;
185188

186-
ret = vfio_pin_pages(mdev_dev(kvmgt_vdev(vgpu)->mdev), &cur_gfn, 1,
187-
IOMMU_READ | IOMMU_WRITE, &pfn);
189+
ret = vfio_group_pin_pages(vdev->vfio_group, &cur_gfn, 1,
190+
IOMMU_READ | IOMMU_WRITE, &pfn);
188191
if (ret != 1) {
189192
gvt_vgpu_err("vfio_pin_pages failed for gfn 0x%lx, ret %d\n",
190193
cur_gfn, ret);
@@ -792,6 +795,7 @@ static int intel_vgpu_open(struct mdev_device *mdev)
792795
struct kvmgt_vdev *vdev = kvmgt_vdev(vgpu);
793796
unsigned long events;
794797
int ret;
798+
struct vfio_group *vfio_group;
795799

796800
vdev->iommu_notifier.notifier_call = intel_vgpu_iommu_notifier;
797801
vdev->group_notifier.notifier_call = intel_vgpu_group_notifier;
@@ -814,6 +818,14 @@ static int intel_vgpu_open(struct mdev_device *mdev)
814818
goto undo_iommu;
815819
}
816820

821+
vfio_group = vfio_group_get_external_user_from_dev(mdev_dev(mdev));
822+
if (IS_ERR_OR_NULL(vfio_group)) {
823+
ret = !vfio_group ? -EFAULT : PTR_ERR(vfio_group);
824+
gvt_vgpu_err("vfio_group_get_external_user_from_dev failed\n");
825+
goto undo_register;
826+
}
827+
vdev->vfio_group = vfio_group;
828+
817829
/* Take a module reference as mdev core doesn't take
818830
* a reference for vendor driver.
819831
*/
@@ -830,6 +842,10 @@ static int intel_vgpu_open(struct mdev_device *mdev)
830842
return ret;
831843

832844
undo_group:
845+
vfio_group_put_external_user(vdev->vfio_group);
846+
vdev->vfio_group = NULL;
847+
848+
undo_register:
833849
vfio_unregister_notifier(mdev_dev(mdev), VFIO_GROUP_NOTIFY,
834850
&vdev->group_notifier);
835851

@@ -884,6 +900,7 @@ static void __intel_vgpu_release(struct intel_vgpu *vgpu)
884900
kvmgt_guest_exit(info);
885901

886902
intel_vgpu_release_msi_eventfd_ctx(vgpu);
903+
vfio_group_put_external_user(vdev->vfio_group);
887904

888905
vdev->kvm = NULL;
889906
vgpu->handle = 0;
@@ -2035,33 +2052,14 @@ static int kvmgt_rw_gpa(unsigned long handle, unsigned long gpa,
20352052
void *buf, unsigned long len, bool write)
20362053
{
20372054
struct kvmgt_guest_info *info;
2038-
struct kvm *kvm;
2039-
int idx, ret;
2040-
bool kthread = current->mm == NULL;
20412055

20422056
if (!handle_valid(handle))
20432057
return -ESRCH;
20442058

20452059
info = (struct kvmgt_guest_info *)handle;
2046-
kvm = info->kvm;
2047-
2048-
if (kthread) {
2049-
if (!mmget_not_zero(kvm->mm))
2050-
return -EFAULT;
2051-
use_mm(kvm->mm);
2052-
}
2053-
2054-
idx = srcu_read_lock(&kvm->srcu);
2055-
ret = write ? kvm_write_guest(kvm, gpa, buf, len) :
2056-
kvm_read_guest(kvm, gpa, buf, len);
2057-
srcu_read_unlock(&kvm->srcu, idx);
2058-
2059-
if (kthread) {
2060-
unuse_mm(kvm->mm);
2061-
mmput(kvm->mm);
2062-
}
20632060

2064-
return ret;
2061+
return vfio_dma_rw(kvmgt_vdev(info->vgpu)->vfio_group,
2062+
gpa, buf, len, write);
20652063
}
20662064

20672065
static int kvmgt_read_gpa(unsigned long handle, unsigned long gpa,

0 commit comments

Comments
 (0)