drm/amdgpu/gmc: add new helper to get the FB size used by pre-OS console
This adds a new gmc callback to get the size reserved by the pre-OS console and provides a helper function for use by gmc IP drivers. Reviewed-by: Christian König <christian.koenig@amd.com> Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
@@ -27,6 +27,7 @@
|
|||||||
#include <linux/io-64-nonatomic-lo-hi.h>
|
#include <linux/io-64-nonatomic-lo-hi.h>
|
||||||
|
|
||||||
#include "amdgpu.h"
|
#include "amdgpu.h"
|
||||||
|
#include "amdgpu_gmc.h"
|
||||||
#include "amdgpu_ras.h"
|
#include "amdgpu_ras.h"
|
||||||
#include "amdgpu_xgmi.h"
|
#include "amdgpu_xgmi.h"
|
||||||
|
|
||||||
@@ -431,3 +432,45 @@ void amdgpu_gmc_set_vm_fault_masks(struct amdgpu_device *adev, int hub_type,
|
|||||||
WREG32(reg, tmp);
|
WREG32(reg, tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void amdgpu_gmc_get_vbios_allocations(struct amdgpu_device *adev)
|
||||||
|
{
|
||||||
|
unsigned size;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO:
|
||||||
|
* Currently there is a bug where some memory client outside
|
||||||
|
* of the driver writes to first 8M of VRAM on S3 resume,
|
||||||
|
* this overrides GART which by default gets placed in first 8M and
|
||||||
|
* causes VM_FAULTS once GTT is accessed.
|
||||||
|
* Keep the stolen memory reservation until the while this is not solved.
|
||||||
|
*/
|
||||||
|
switch (adev->asic_type) {
|
||||||
|
case CHIP_VEGA10:
|
||||||
|
case CHIP_RAVEN:
|
||||||
|
case CHIP_ARCTURUS:
|
||||||
|
case CHIP_RENOIR:
|
||||||
|
adev->gmc.keep_stolen_vga_memory = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
adev->gmc.keep_stolen_vga_memory = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!amdgpu_device_ip_get_ip_block(adev, AMD_IP_BLOCK_TYPE_DCE))
|
||||||
|
size = 0;
|
||||||
|
else
|
||||||
|
size = amdgpu_gmc_get_vbios_fb_size(adev);
|
||||||
|
|
||||||
|
/* set to 0 if the pre-OS buffer uses up most of vram */
|
||||||
|
if ((adev->gmc.real_vram_size - size) < (8 * 1024 * 1024))
|
||||||
|
size = 0;
|
||||||
|
|
||||||
|
if (size > AMDGPU_VBIOS_VGA_ALLOCATION) {
|
||||||
|
adev->gmc.stolen_vga_size = AMDGPU_VBIOS_VGA_ALLOCATION;
|
||||||
|
adev->gmc.stolen_extended_size = size - adev->gmc.stolen_vga_size;
|
||||||
|
} else {
|
||||||
|
adev->gmc.stolen_vga_size = size;
|
||||||
|
adev->gmc.stolen_extended_size = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -131,6 +131,8 @@ struct amdgpu_gmc_funcs {
|
|||||||
void (*get_vm_pte)(struct amdgpu_device *adev,
|
void (*get_vm_pte)(struct amdgpu_device *adev,
|
||||||
struct amdgpu_bo_va_mapping *mapping,
|
struct amdgpu_bo_va_mapping *mapping,
|
||||||
uint64_t *flags);
|
uint64_t *flags);
|
||||||
|
/* get the amount of memory used by the vbios for pre-OS console */
|
||||||
|
unsigned int (*get_vbios_fb_size)(struct amdgpu_device *adev);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct amdgpu_xgmi {
|
struct amdgpu_xgmi {
|
||||||
@@ -253,6 +255,7 @@ struct amdgpu_gmc {
|
|||||||
#define amdgpu_gmc_map_mtype(adev, flags) (adev)->gmc.gmc_funcs->map_mtype((adev),(flags))
|
#define amdgpu_gmc_map_mtype(adev, flags) (adev)->gmc.gmc_funcs->map_mtype((adev),(flags))
|
||||||
#define amdgpu_gmc_get_vm_pde(adev, level, dst, flags) (adev)->gmc.gmc_funcs->get_vm_pde((adev), (level), (dst), (flags))
|
#define amdgpu_gmc_get_vm_pde(adev, level, dst, flags) (adev)->gmc.gmc_funcs->get_vm_pde((adev), (level), (dst), (flags))
|
||||||
#define amdgpu_gmc_get_vm_pte(adev, mapping, flags) (adev)->gmc.gmc_funcs->get_vm_pte((adev), (mapping), (flags))
|
#define amdgpu_gmc_get_vm_pte(adev, mapping, flags) (adev)->gmc.gmc_funcs->get_vm_pte((adev), (mapping), (flags))
|
||||||
|
#define amdgpu_gmc_get_vbios_fb_size(adev) (adev)->gmc.gmc_funcs->get_vbios_fb_size((adev))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* amdgpu_gmc_vram_full_visible - Check if full VRAM is visible through the BAR
|
* amdgpu_gmc_vram_full_visible - Check if full VRAM is visible through the BAR
|
||||||
@@ -307,4 +310,6 @@ extern void
|
|||||||
amdgpu_gmc_set_vm_fault_masks(struct amdgpu_device *adev, int hub_type,
|
amdgpu_gmc_set_vm_fault_masks(struct amdgpu_device *adev, int hub_type,
|
||||||
bool enable);
|
bool enable);
|
||||||
|
|
||||||
|
void amdgpu_gmc_get_vbios_allocations(struct amdgpu_device *adev);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user