Commit 1ce65f52 authored by Harry Wentland's avatar Harry Wentland Committed by Alex Deucher

drm/amdgpu: Read vram width from integrated system info table

On KB, KV, CZ we should read the vram width from integrated system
table, if we can. The NOOFCHAN in MC_SHARED_CHMAP is not accurate.

With this change we can enable two 4k displays on CZ again. This use
case was broken sometime in January when we started looking at
vram_width for bandwidth calculations instead of hardcoding this value.

v2:
  Return 0 if integrated system info table is not available.
Tested-by: default avatarRoman Li <roman.li@amd.com>
Signed-off-by: default avatarHarry Wentland <harry.wentland@amd.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 83ca145d
...@@ -754,6 +754,35 @@ union igp_info { ...@@ -754,6 +754,35 @@ union igp_info {
struct _ATOM_INTEGRATED_SYSTEM_INFO_V1_9 info_9; struct _ATOM_INTEGRATED_SYSTEM_INFO_V1_9 info_9;
}; };
/*
* Return vram width from integrated system info table, if available,
* or 0 if not.
*/
int amdgpu_atombios_get_vram_width(struct amdgpu_device *adev)
{
struct amdgpu_mode_info *mode_info = &adev->mode_info;
int index = GetIndexIntoMasterTable(DATA, IntegratedSystemInfo);
u16 data_offset, size;
union igp_info *igp_info;
u8 frev, crev;
/* get any igp specific overrides */
if (amdgpu_atom_parse_data_header(mode_info->atom_context, index, &size,
&frev, &crev, &data_offset)) {
igp_info = (union igp_info *)
(mode_info->atom_context->bios + data_offset);
switch (crev) {
case 8:
case 9:
return igp_info->info_8.ucUMAChannelNumber * 64;
default:
return 0;
}
}
return 0;
}
static void amdgpu_atombios_get_igp_ss_overrides(struct amdgpu_device *adev, static void amdgpu_atombios_get_igp_ss_overrides(struct amdgpu_device *adev,
struct amdgpu_atom_ss *ss, struct amdgpu_atom_ss *ss,
int id) int id)
......
...@@ -148,6 +148,8 @@ int amdgpu_atombios_get_clock_info(struct amdgpu_device *adev); ...@@ -148,6 +148,8 @@ int amdgpu_atombios_get_clock_info(struct amdgpu_device *adev);
int amdgpu_atombios_get_gfx_info(struct amdgpu_device *adev); int amdgpu_atombios_get_gfx_info(struct amdgpu_device *adev);
int amdgpu_atombios_get_vram_width(struct amdgpu_device *adev);
bool amdgpu_atombios_get_asic_ss_info(struct amdgpu_device *adev, bool amdgpu_atombios_get_asic_ss_info(struct amdgpu_device *adev,
struct amdgpu_atom_ss *ss, struct amdgpu_atom_ss *ss,
int id, u32 clock); int id, u32 clock);
......
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
#include "oss/oss_2_0_d.h" #include "oss/oss_2_0_d.h"
#include "oss/oss_2_0_sh_mask.h" #include "oss/oss_2_0_sh_mask.h"
#include "amdgpu_atombios.h"
static void gmc_v7_0_set_gart_funcs(struct amdgpu_device *adev); static void gmc_v7_0_set_gart_funcs(struct amdgpu_device *adev);
static void gmc_v7_0_set_irq_funcs(struct amdgpu_device *adev); static void gmc_v7_0_set_irq_funcs(struct amdgpu_device *adev);
static int gmc_v7_0_wait_for_idle(void *handle); static int gmc_v7_0_wait_for_idle(void *handle);
...@@ -325,48 +327,51 @@ static void gmc_v7_0_mc_program(struct amdgpu_device *adev) ...@@ -325,48 +327,51 @@ static void gmc_v7_0_mc_program(struct amdgpu_device *adev)
*/ */
static int gmc_v7_0_mc_init(struct amdgpu_device *adev) static int gmc_v7_0_mc_init(struct amdgpu_device *adev)
{ {
u32 tmp; adev->mc.vram_width = amdgpu_atombios_get_vram_width(adev);
int chansize, numchan; if (!adev->mc.vram_width) {
u32 tmp;
/* Get VRAM informations */ int chansize, numchan;
tmp = RREG32(mmMC_ARB_RAMCFG);
if (REG_GET_FIELD(tmp, MC_ARB_RAMCFG, CHANSIZE)) { /* Get VRAM informations */
chansize = 64; tmp = RREG32(mmMC_ARB_RAMCFG);
} else { if (REG_GET_FIELD(tmp, MC_ARB_RAMCFG, CHANSIZE)) {
chansize = 32; chansize = 64;
} } else {
tmp = RREG32(mmMC_SHARED_CHMAP); chansize = 32;
switch (REG_GET_FIELD(tmp, MC_SHARED_CHMAP, NOOFCHAN)) { }
case 0: tmp = RREG32(mmMC_SHARED_CHMAP);
default: switch (REG_GET_FIELD(tmp, MC_SHARED_CHMAP, NOOFCHAN)) {
numchan = 1; case 0:
break; default:
case 1: numchan = 1;
numchan = 2; break;
break; case 1:
case 2: numchan = 2;
numchan = 4; break;
break; case 2:
case 3: numchan = 4;
numchan = 8; break;
break; case 3:
case 4: numchan = 8;
numchan = 3; break;
break; case 4:
case 5: numchan = 3;
numchan = 6; break;
break; case 5:
case 6: numchan = 6;
numchan = 10; break;
break; case 6:
case 7: numchan = 10;
numchan = 12; break;
break; case 7:
case 8: numchan = 12;
numchan = 16; break;
break; case 8:
numchan = 16;
break;
}
adev->mc.vram_width = numchan * chansize;
} }
adev->mc.vram_width = numchan * chansize;
/* Could aper size report 0 ? */ /* Could aper size report 0 ? */
adev->mc.aper_base = pci_resource_start(adev->pdev, 0); adev->mc.aper_base = pci_resource_start(adev->pdev, 0);
adev->mc.aper_size = pci_resource_len(adev->pdev, 0); adev->mc.aper_size = pci_resource_len(adev->pdev, 0);
......
...@@ -38,6 +38,8 @@ ...@@ -38,6 +38,8 @@
#include "vid.h" #include "vid.h"
#include "vi.h" #include "vi.h"
#include "amdgpu_atombios.h"
static void gmc_v8_0_set_gart_funcs(struct amdgpu_device *adev); static void gmc_v8_0_set_gart_funcs(struct amdgpu_device *adev);
static void gmc_v8_0_set_irq_funcs(struct amdgpu_device *adev); static void gmc_v8_0_set_irq_funcs(struct amdgpu_device *adev);
...@@ -487,48 +489,51 @@ static void gmc_v8_0_mc_program(struct amdgpu_device *adev) ...@@ -487,48 +489,51 @@ static void gmc_v8_0_mc_program(struct amdgpu_device *adev)
*/ */
static int gmc_v8_0_mc_init(struct amdgpu_device *adev) static int gmc_v8_0_mc_init(struct amdgpu_device *adev)
{ {
u32 tmp; adev->mc.vram_width = amdgpu_atombios_get_vram_width(adev);
int chansize, numchan; if (!adev->mc.vram_width) {
u32 tmp;
/* Get VRAM informations */ int chansize, numchan;
tmp = RREG32(mmMC_ARB_RAMCFG);
if (REG_GET_FIELD(tmp, MC_ARB_RAMCFG, CHANSIZE)) { /* Get VRAM informations */
chansize = 64; tmp = RREG32(mmMC_ARB_RAMCFG);
} else { if (REG_GET_FIELD(tmp, MC_ARB_RAMCFG, CHANSIZE)) {
chansize = 32; chansize = 64;
} } else {
tmp = RREG32(mmMC_SHARED_CHMAP); chansize = 32;
switch (REG_GET_FIELD(tmp, MC_SHARED_CHMAP, NOOFCHAN)) { }
case 0: tmp = RREG32(mmMC_SHARED_CHMAP);
default: switch (REG_GET_FIELD(tmp, MC_SHARED_CHMAP, NOOFCHAN)) {
numchan = 1; case 0:
break; default:
case 1: numchan = 1;
numchan = 2; break;
break; case 1:
case 2: numchan = 2;
numchan = 4; break;
break; case 2:
case 3: numchan = 4;
numchan = 8; break;
break; case 3:
case 4: numchan = 8;
numchan = 3; break;
break; case 4:
case 5: numchan = 3;
numchan = 6; break;
break; case 5:
case 6: numchan = 6;
numchan = 10; break;
break; case 6:
case 7: numchan = 10;
numchan = 12; break;
break; case 7:
case 8: numchan = 12;
numchan = 16; break;
break; case 8:
numchan = 16;
break;
}
adev->mc.vram_width = numchan * chansize;
} }
adev->mc.vram_width = numchan * chansize;
/* Could aper size report 0 ? */ /* Could aper size report 0 ? */
adev->mc.aper_base = pci_resource_start(adev->pdev, 0); adev->mc.aper_base = pci_resource_start(adev->pdev, 0);
adev->mc.aper_size = pci_resource_len(adev->pdev, 0); adev->mc.aper_size = pci_resource_len(adev->pdev, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment