Skip to content

Commit e180af1

Browse files
committed
Merge tag 'amd-drm-fixes-5.6-2020-02-26' of git://people.freedesktop.org/~agd5f/linux into drm-fixes
amd-drm-fixes-5.6-2020-02-26: amdgpu: - Drop DRIVER_USE_AGP - Fix memory leak in GPU reset - Resume fix for raven radeon: - Drop DRIVER_USE_AGP Signed-off-by: Dave Airlie <[email protected]> From: Alex Deucher <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2 parents f8788d8 + eb12c95 commit e180af1

File tree

7 files changed

+92
-5
lines changed

7 files changed

+92
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,7 @@ amdgpu_get_crtc_scanout_position(struct drm_device *dev, unsigned int pipe,
13891389

13901390
static struct drm_driver kms_driver = {
13911391
.driver_features =
1392-
DRIVER_USE_AGP | DRIVER_ATOMIC |
1392+
DRIVER_ATOMIC |
13931393
DRIVER_GEM |
13941394
DRIVER_RENDER | DRIVER_MODESET | DRIVER_SYNCOBJ |
13951395
DRIVER_SYNCOBJ_TIMELINE,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ struct amdgpu_gmc {
195195
uint32_t srbm_soft_reset;
196196
bool prt_warning;
197197
uint64_t stolen_size;
198+
uint32_t sdpif_register;
198199
/* apertures */
199200
u64 shared_aperture_start;
200201
u64 shared_aperture_end;

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

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,19 @@ static void gmc_v9_0_init_golden_registers(struct amdgpu_device *adev)
12711271
}
12721272
}
12731273

1274+
/**
1275+
* gmc_v9_0_restore_registers - restores regs
1276+
*
1277+
* @adev: amdgpu_device pointer
1278+
*
1279+
* This restores register values, saved at suspend.
1280+
*/
1281+
static void gmc_v9_0_restore_registers(struct amdgpu_device *adev)
1282+
{
1283+
if (adev->asic_type == CHIP_RAVEN)
1284+
WREG32(mmDCHUBBUB_SDPIF_MMIO_CNTRL_0, adev->gmc.sdpif_register);
1285+
}
1286+
12741287
/**
12751288
* gmc_v9_0_gart_enable - gart enable
12761289
*
@@ -1376,6 +1389,20 @@ static int gmc_v9_0_hw_init(void *handle)
13761389
return r;
13771390
}
13781391

1392+
/**
1393+
* gmc_v9_0_save_registers - saves regs
1394+
*
1395+
* @adev: amdgpu_device pointer
1396+
*
1397+
* This saves potential register values that should be
1398+
* restored upon resume
1399+
*/
1400+
static void gmc_v9_0_save_registers(struct amdgpu_device *adev)
1401+
{
1402+
if (adev->asic_type == CHIP_RAVEN)
1403+
adev->gmc.sdpif_register = RREG32(mmDCHUBBUB_SDPIF_MMIO_CNTRL_0);
1404+
}
1405+
13791406
/**
13801407
* gmc_v9_0_gart_disable - gart disable
13811408
*
@@ -1412,16 +1439,24 @@ static int gmc_v9_0_hw_fini(void *handle)
14121439

14131440
static int gmc_v9_0_suspend(void *handle)
14141441
{
1442+
int r;
14151443
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
14161444

1417-
return gmc_v9_0_hw_fini(adev);
1445+
r = gmc_v9_0_hw_fini(adev);
1446+
if (r)
1447+
return r;
1448+
1449+
gmc_v9_0_save_registers(adev);
1450+
1451+
return 0;
14181452
}
14191453

14201454
static int gmc_v9_0_resume(void *handle)
14211455
{
14221456
int r;
14231457
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
14241458

1459+
gmc_v9_0_restore_registers(adev);
14251460
r = gmc_v9_0_hw_init(adev);
14261461
if (r)
14271462
return r;

drivers/gpu/drm/amd/include/asic_reg/dce/dce_12_0_offset.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7376,6 +7376,8 @@
73767376
#define mmCRTC4_CRTC_DRR_CONTROL 0x0f3e
73777377
#define mmCRTC4_CRTC_DRR_CONTROL_BASE_IDX 2
73787378

7379+
#define mmDCHUBBUB_SDPIF_MMIO_CNTRL_0 0x395d
7380+
#define mmDCHUBBUB_SDPIF_MMIO_CNTRL_0_BASE_IDX 2
73797381

73807382
// addressBlock: dce_dc_fmt4_dispdec
73817383
// base address: 0x2000

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -978,8 +978,12 @@ int smu_v11_0_init_max_sustainable_clocks(struct smu_context *smu)
978978
struct smu_11_0_max_sustainable_clocks *max_sustainable_clocks;
979979
int ret = 0;
980980

981-
max_sustainable_clocks = kzalloc(sizeof(struct smu_11_0_max_sustainable_clocks),
981+
if (!smu->smu_table.max_sustainable_clocks)
982+
max_sustainable_clocks = kzalloc(sizeof(struct smu_11_0_max_sustainable_clocks),
982983
GFP_KERNEL);
984+
else
985+
max_sustainable_clocks = smu->smu_table.max_sustainable_clocks;
986+
983987
smu->smu_table.max_sustainable_clocks = (void *)max_sustainable_clocks;
984988

985989
max_sustainable_clocks->uclock = smu->smu_table.boot_values.uclk / 100;

drivers/gpu/drm/radeon/radeon_drv.c

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <linux/vga_switcheroo.h>
3838
#include <linux/mmu_notifier.h>
3939

40+
#include <drm/drm_agpsupport.h>
4041
#include <drm/drm_crtc_helper.h>
4142
#include <drm/drm_drv.h>
4243
#include <drm/drm_fb_helper.h>
@@ -325,6 +326,7 @@ static int radeon_pci_probe(struct pci_dev *pdev,
325326
const struct pci_device_id *ent)
326327
{
327328
unsigned long flags = 0;
329+
struct drm_device *dev;
328330
int ret;
329331

330332
if (!ent)
@@ -365,7 +367,44 @@ static int radeon_pci_probe(struct pci_dev *pdev,
365367
if (ret)
366368
return ret;
367369

368-
return drm_get_pci_dev(pdev, ent, &kms_driver);
370+
dev = drm_dev_alloc(&kms_driver, &pdev->dev);
371+
if (IS_ERR(dev))
372+
return PTR_ERR(dev);
373+
374+
ret = pci_enable_device(pdev);
375+
if (ret)
376+
goto err_free;
377+
378+
dev->pdev = pdev;
379+
#ifdef __alpha__
380+
dev->hose = pdev->sysdata;
381+
#endif
382+
383+
pci_set_drvdata(pdev, dev);
384+
385+
if (pci_find_capability(dev->pdev, PCI_CAP_ID_AGP))
386+
dev->agp = drm_agp_init(dev);
387+
if (dev->agp) {
388+
dev->agp->agp_mtrr = arch_phys_wc_add(
389+
dev->agp->agp_info.aper_base,
390+
dev->agp->agp_info.aper_size *
391+
1024 * 1024);
392+
}
393+
394+
ret = drm_dev_register(dev, ent->driver_data);
395+
if (ret)
396+
goto err_agp;
397+
398+
return 0;
399+
400+
err_agp:
401+
if (dev->agp)
402+
arch_phys_wc_del(dev->agp->agp_mtrr);
403+
kfree(dev->agp);
404+
pci_disable_device(pdev);
405+
err_free:
406+
drm_dev_put(dev);
407+
return ret;
369408
}
370409

371410
static void
@@ -575,7 +614,7 @@ radeon_get_crtc_scanout_position(struct drm_device *dev, unsigned int pipe,
575614

576615
static struct drm_driver kms_driver = {
577616
.driver_features =
578-
DRIVER_USE_AGP | DRIVER_GEM | DRIVER_RENDER,
617+
DRIVER_GEM | DRIVER_RENDER,
579618
.load = radeon_driver_load_kms,
580619
.open = radeon_driver_open_kms,
581620
.postclose = radeon_driver_postclose_kms,

drivers/gpu/drm/radeon/radeon_kms.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <linux/uaccess.h>
3333
#include <linux/vga_switcheroo.h>
3434

35+
#include <drm/drm_agpsupport.h>
3536
#include <drm/drm_fb_helper.h>
3637
#include <drm/drm_file.h>
3738
#include <drm/drm_ioctl.h>
@@ -77,6 +78,11 @@ void radeon_driver_unload_kms(struct drm_device *dev)
7778
radeon_modeset_fini(rdev);
7879
radeon_device_fini(rdev);
7980

81+
if (dev->agp)
82+
arch_phys_wc_del(dev->agp->agp_mtrr);
83+
kfree(dev->agp);
84+
dev->agp = NULL;
85+
8086
done_free:
8187
kfree(rdev);
8288
dev->dev_private = NULL;

0 commit comments

Comments
 (0)