summaryrefslogtreecommitdiff
path: root/drivers/gpu
diff options
context:
space:
mode:
authorYiPeng Chai <YiPeng.Chai@amd.com>2026-04-22 10:34:17 +0800
committerAlex Deucher <alexander.deucher@amd.com>2026-08-25 18:26:11 -0400
commit486680e9d3cf6f3eb8aae8a6cf51c893e1159ece (patch)
tree58d50d81c01dbd33cdabf0fc1513c5d4853a8f1b /drivers/gpu
parent93a05388b07156c0446e297927b8ed60db26e0f7 (diff)
drm/amd/ras: preload and handle bad pages at boot time
Preload bad pages occur during the sw_init stage, so the preload-related code in RAS module must be moved to sw_init for proper initialization. v2: Rename functions and variables. Signed-off-by: YiPeng Chai <YiPeng.Chai@amd.com> Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/amd/ras/core/core.c54
-rw-r--r--drivers/gpu/drm/amd/ras/core/eeprom.c27
-rw-r--r--drivers/gpu/drm/amd/ras/core/ras.h7
-rw-r--r--drivers/gpu/drm/amd/ras/core/ras_mp1.c7
-rw-r--r--drivers/gpu/drm/amd/ras/core/ras_mp1.h4
-rw-r--r--drivers/gpu/drm/amd/ras/core/ras_umc.c17
-rw-r--r--drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_ras_mgr.c25
-rw-r--r--drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_ras_mgr.h1
-rw-r--r--drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_ras_sys.c22
9 files changed, 132 insertions, 32 deletions
diff --git a/drivers/gpu/drm/amd/ras/core/core.c b/drivers/gpu/drm/amd/ras/core/core.c
index 9bfa77ff72ae..5b139eff736f 100644
--- a/drivers/gpu/drm/amd/ras/core/core.c
+++ b/drivers/gpu/drm/amd/ras/core/core.c
@@ -331,6 +331,12 @@ int ras_core_sw_init(struct ras_core_context *ras_core)
return -EINVAL;
}
+ ras_core->ras_eeprom_supported = ras_core->config->ras_eeprom_supported;
+ ras_core->poison_supported = ras_core->config->poison_supported;
+ ras_core->early_init_service_enabled = ras_core->config->early_init_service_supported;
+
+ ras_core->in_early_init = true;
+
ras_core->sys_fn = ras_core->config->sys_fn;
if (!ras_core->sys_fn)
return -EINVAL;
@@ -367,6 +373,14 @@ int ras_core_sw_init(struct ras_core_context *ras_core)
if (ret)
return ret;
+ ret = ras_mp1_sw_init(ras_core);
+ if (ret)
+ return ret;
+
+ ret = ras_eeprom_mgr_sw_init(ras_core);
+ if (ret)
+ return ret;
+
ret = ras_mce_sw_init(ras_core);
if (ret)
return ret;
@@ -383,7 +397,9 @@ int ras_core_sw_fini(struct ras_core_context *ras_core)
ras_log_ring_sw_fini(ras_core);
ras_cmd_fini(ras_core);
ras_umc_sw_fini(ras_core);
+ ras_mp1_sw_fini(ras_core);
ras_aca_sw_fini(ras_core);
+ ras_eeprom_mgr_sw_fini(ras_core);
ras_mce_sw_fini(ras_core);
return 0;
@@ -393,11 +409,6 @@ int ras_core_hw_init(struct ras_core_context *ras_core)
{
int ret;
- ras_core->ras_eeprom_supported =
- ras_core->config->ras_eeprom_supported;
-
- ras_core->poison_supported = ras_core->config->poison_supported;
-
ret = ras_psp_hw_init(ras_core);
if (ret)
return ret;
@@ -406,10 +417,6 @@ int ras_core_hw_init(struct ras_core_context *ras_core)
if (ret)
goto init_err1;
- ret = ras_mp1_hw_init(ras_core);
- if (ret)
- goto init_err2;
-
ret = ras_nbio_hw_init(ras_core);
if (ret)
goto init_err3;
@@ -424,6 +431,8 @@ int ras_core_hw_init(struct ras_core_context *ras_core)
ret = ras_eeprom_mgr_hw_init(ras_core);
+ ras_core->in_early_init = false;
+
/*
* NOTE:
* For ras_fw_eeprom_hw_init, if it fails without control->ras_tbl_mutex
@@ -466,8 +475,6 @@ init_err5:
init_err4:
ras_nbio_hw_fini(ras_core);
init_err3:
- ras_mp1_hw_fini(ras_core);
-init_err2:
ras_aca_hw_fini(ras_core);
init_err1:
ras_psp_hw_fini(ras_core);
@@ -483,7 +490,6 @@ int ras_core_hw_fini(struct ras_core_context *ras_core)
ras_gfx_hw_fini(ras_core);
ras_nbio_hw_fini(ras_core);
ras_umc_hw_fini(ras_core);
- ras_mp1_hw_fini(ras_core);
ras_aca_hw_fini(ras_core);
ras_psp_hw_fini(ras_core);
@@ -798,3 +804,27 @@ bool ras_core_poison_supported(struct ras_core_context *ras_core)
return ras_core->poison_supported ? true :
ras_psp_poison_supported(ras_core);
}
+
+bool ras_core_in_early_init(struct ras_core_context *ras_core)
+{
+ if (!ras_core)
+ return true;
+
+ return ras_core->in_early_init;
+}
+
+bool ras_core_early_init_service_enabled(struct ras_core_context *ras_core)
+{
+ return ras_core->early_init_service_enabled &&
+ ras_eeprom_mgr_early_init_service_supported(ras_core);
+}
+
+int ras_core_eeprom_early_init_service(struct ras_core_context *ras_core)
+{
+ if (!ras_core_early_init_service_enabled(ras_core))
+ return -EOPNOTSUPP;
+ else if (!ras_core_in_early_init(ras_core))
+ return -EACCES;
+
+ return ras_core_eeprom_recovery(ras_core);
+}
diff --git a/drivers/gpu/drm/amd/ras/core/eeprom.c b/drivers/gpu/drm/amd/ras/core/eeprom.c
index b261f11799f6..01e4cde581f4 100644
--- a/drivers/gpu/drm/amd/ras/core/eeprom.c
+++ b/drivers/gpu/drm/amd/ras/core/eeprom.c
@@ -1085,7 +1085,7 @@ Out:
return res == RAS_TABLE_V2_1_INFO_SIZE ? 0 : res;
}
-static int __check_ras_table_status(struct ras_core_context *ras_core)
+static int __ras_table_init(struct ras_core_context *ras_core)
{
struct ras_eeprom_control *control = ras_core->eeprom_mgr.ras_eeprom;
unsigned char buf[RAS_TABLE_HEADER_SIZE] = { 0 };
@@ -1102,7 +1102,6 @@ static int __check_ras_table_status(struct ras_core_context *ras_core)
control->ras_header_offset = RAS_HDR_START;
control->ras_info_offset = RAS_TABLE_V2_1_INFO_START;
- mutex_init(&control->ras_tbl_mutex);
/* Read the table header from EEPROM address */
res = __eeprom_read(ras_core,
@@ -1284,18 +1283,26 @@ static int ras_eeprom_sw_init(struct ras_core_context *ras_core,
control->i2c_adapter = param->eeprom_i2c_adapter;
control->i2c_port = param->eeprom_i2c_port;
control->i2c_address = param->eeprom_i2c_addr;
+ control->record_threshold_count = param->record_threshold;
+ control->sys_func = param->sys_fn;
control->update_channel_flag = false;
+ mutex_init(&control->ras_tbl_mutex);
+
return 0;
}
static int ras_eeprom_sw_fini(struct ras_core_context *ras_core)
{
- if (!ras_core)
+ struct ras_eeprom_control *control = ras_core->eeprom_mgr.ras_eeprom;
+
+ if (!control)
return -EINVAL;
- kfree(ras_core->eeprom_mgr.ras_eeprom);
+ mutex_destroy(&control->ras_tbl_mutex);
+
+ kfree(control);
ras_core->eeprom_mgr.ras_eeprom = NULL;
return 0;
@@ -1309,15 +1316,17 @@ static int ras_eeprom_hw_init(struct ras_core_context *ras_core,
if (!control)
return -EINVAL;
- return __check_ras_table_status(ras_core);
+ control->max_read_len = param->max_i2c_read_len;
+ control->max_write_len = param->max_i2c_write_len;
+ control->i2c_adapter = param->eeprom_i2c_adapter;
+ control->i2c_port = param->eeprom_i2c_port;
+ control->i2c_address = param->eeprom_i2c_addr;
+
+ return __ras_table_init(ras_core);
}
static int ras_eeprom_hw_fini(struct ras_core_context *ras_core)
{
- struct ras_eeprom_control *control = ras_core->eeprom_mgr.ras_eeprom;
-
- mutex_destroy(&control->ras_tbl_mutex);
-
return 0;
}
diff --git a/drivers/gpu/drm/amd/ras/core/ras.h b/drivers/gpu/drm/amd/ras/core/ras.h
index ddc22019b55c..c344fc67b13d 100644
--- a/drivers/gpu/drm/amd/ras/core/ras.h
+++ b/drivers/gpu/drm/amd/ras/core/ras.h
@@ -153,6 +153,7 @@ enum ras_notify_event {
RAS_EVENT_ID__RAS_EVENT_PROC_BEGIN,
RAS_EVENT_ID__RAS_EVENT_PROC_END,
RAS_EVENT_ID__UPDATE_ACA_DATA,
+ RAS_EVENT_ID__EARLY_INIT_RESERVE_PAGE,
};
enum ras_gpu_status {
@@ -363,6 +364,7 @@ struct ras_core_config {
u32 nbio_ip_version;
u32 psp_ip_version;
+ bool early_init_service_supported;
bool poison_supported;
bool ras_eeprom_supported;
uint ras_debug_mask;
@@ -406,6 +408,8 @@ struct ras_core_context {
bool is_rma;
bool is_initialized;
+ bool in_early_init;
+ bool early_init_service_enabled;
struct kfifo de_seqno_fifo;
struct kfifo consumption_seqno_fifo;
@@ -478,4 +482,7 @@ int ras_core_get_ip_version(struct ras_core_context *ras_core,
enum ras_unit_id unit_id, uint32_t *version);
uint64_t ras_core_get_ras_caps(struct ras_core_context *ras_core);
bool ras_core_poison_supported(struct ras_core_context *ras_core);
+bool ras_core_in_early_init(struct ras_core_context *ras_core);
+bool ras_core_early_init_service_enabled(struct ras_core_context *ras_core);
+int ras_core_eeprom_early_init_service(struct ras_core_context *ras_core);
#endif
diff --git a/drivers/gpu/drm/amd/ras/core/ras_mp1.c b/drivers/gpu/drm/amd/ras/core/ras_mp1.c
index 7a2a6da26ae3..7ba872732efd 100644
--- a/drivers/gpu/drm/amd/ras/core/ras_mp1.c
+++ b/drivers/gpu/drm/amd/ras/core/ras_mp1.c
@@ -183,11 +183,14 @@ int ras_mp1_set_debug_mode(struct ras_core_context *ras_core, bool enable)
return mp1->ip_func->set_debug_mode(ras_core, enable);
}
-int ras_mp1_hw_init(struct ras_core_context *ras_core)
+int ras_mp1_sw_init(struct ras_core_context *ras_core)
{
struct ras_mp1 *mp1 = &ras_core->ras_mp1;
int ret = 0;
+ if (!ras_core->config)
+ return -EINVAL;
+
mp1->mp1_ip_version = ras_core->config->mp1_ip_version;
if (ras_core->config && ras_core->config->mp1_cfg.mp1_sys_fn)
@@ -208,7 +211,7 @@ int ras_mp1_hw_init(struct ras_core_context *ras_core)
return ret;
}
-int ras_mp1_hw_fini(struct ras_core_context *ras_core)
+int ras_mp1_sw_fini(struct ras_core_context *ras_core)
{
struct ras_mp1 *mp1 = &ras_core->ras_mp1;
diff --git a/drivers/gpu/drm/amd/ras/core/ras_mp1.h b/drivers/gpu/drm/amd/ras/core/ras_mp1.h
index 3b3d4cab1d0c..6eac9488843e 100644
--- a/drivers/gpu/drm/amd/ras/core/ras_mp1.h
+++ b/drivers/gpu/drm/amd/ras/core/ras_mp1.h
@@ -88,8 +88,8 @@ struct ras_mp1 {
struct mutex op_mutex;
};
-int ras_mp1_hw_init(struct ras_core_context *ras_core);
-int ras_mp1_hw_fini(struct ras_core_context *ras_core);
+int ras_mp1_sw_init(struct ras_core_context *ras_core);
+int ras_mp1_sw_fini(struct ras_core_context *ras_core);
int ras_mp1_get_bank_count(struct ras_core_context *ras_core,
enum ras_err_type type, u32 *count);
diff --git a/drivers/gpu/drm/amd/ras/core/ras_umc.c b/drivers/gpu/drm/amd/ras/core/ras_umc.c
index 81267c08e8c9..cf024dd94f95 100644
--- a/drivers/gpu/drm/amd/ras/core/ras_umc.c
+++ b/drivers/gpu/drm/amd/ras/core/ras_umc.c
@@ -187,8 +187,9 @@ static void ras_umc_reserve_eeprom_record(struct ras_core_context *ras_core,
/* Reserve memory */
for (i = 0; i < count; i++)
- ras_core_event_notify(ras_core,
- RAS_EVENT_ID__RESERVE_BAD_PAGE, &page_pfn[i]);
+ ras_core_event_notify(ras_core, ras_core_in_early_init(ras_core) ?
+ RAS_EVENT_ID__EARLY_INIT_RESERVE_PAGE : RAS_EVENT_ID__RESERVE_BAD_PAGE,
+ &page_pfn[i]);
}
/* When gpu reset is ongoing, ecc logging operations will be pended.
@@ -727,6 +728,13 @@ int ras_umc_sw_init(struct ras_core_context *ras_core)
mutex_init(&ras_umc->umc_lock);
mutex_init(&ras_umc->bank_log_lock);
+ ras_umc->umc_ip_version = ras_core->config->umc_ip_version;
+ ras_umc->ip_func = ras_umc_get_ip_func(ras_core, ras_umc->umc_ip_version);
+ if (!ras_umc->ip_func) {
+ RAS_DEV_ERR(ras_core->dev, "Failed to get umc ip function!\n");
+ return -EINVAL;
+ }
+
return 0;
}
@@ -779,11 +787,6 @@ int ras_umc_hw_init(struct ras_core_context *ras_core)
ras_umc->pa_base = ras_core->config->umc_cfg.pa_base;
ras_umc->lfb_size = ras_core->config->umc_cfg.lfb_size;
- ras_umc->umc_ip_version = ras_core->config->umc_ip_version;
- ras_umc->ip_func = ras_umc_get_ip_func(ras_core, ras_umc->umc_ip_version);
- if (!ras_umc->ip_func)
- return -EINVAL;
-
return 0;
}
diff --git a/drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_ras_mgr.c b/drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_ras_mgr.c
index c8be2372bcf9..5823c91caa44 100644
--- a/drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_ras_mgr.c
+++ b/drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_ras_mgr.c
@@ -259,6 +259,9 @@ static struct ras_core_context *amdgpu_ras_mgr_create_ras_core(struct amdgpu_dev
init_config.umc_ip_version == IP_VERSION(12, 5, 0))
init_config.aca_ip_version = IP_VERSION(1, 0, 0);
+ if (init_config.mp1_ip_version == IP_VERSION(15, 0, 8))
+ init_config.early_init_service_supported = true;
+
init_config.sys_fn = &amdgpu_ras_sys_fn;
init_config.ras_eeprom_supported =
amdgpu_ras_mgr_eeprom_is_supported(adev);
@@ -740,3 +743,25 @@ bool amdgpu_ras_mgr_get_debug_mode(struct amdgpu_device *adev)
return ras_mgr->is_debug_mode;
}
+
+int amdgpu_ras_mgr_early_init_service(struct amdgpu_device *adev)
+{
+ struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
+ struct amdgpu_ras_mgr *ras_mgr;
+ int ret;
+
+ if (!con->uniras_enabled)
+ return 0;
+
+ ras_mgr = amdgpu_ras_mgr_get_context(adev);
+ if (!ras_mgr || !ras_mgr->ras_core) {
+ RAS_DEV_ERR(adev, "amdgpu ras sw is not ready!\n");
+ return -EPERM;
+ }
+
+ ret = ras_core_eeprom_early_init_service(ras_mgr->ras_core);
+ if (ret)
+ RAS_DEV_WARN(adev, "RAS early init service failure! ret:%d\n", ret);
+
+ return ret;
+}
diff --git a/drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_ras_mgr.h b/drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_ras_mgr.h
index 056d48264498..cb9860630693 100644
--- a/drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_ras_mgr.h
+++ b/drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_ras_mgr.h
@@ -61,6 +61,7 @@ struct amdgpu_ras_mgr {
extern const struct amdgpu_ip_block_version ras_v1_0_ip_block;
+int amdgpu_ras_mgr_early_init_service(struct amdgpu_device *adev);
struct amdgpu_ras_mgr *amdgpu_ras_mgr_get_context(
struct amdgpu_device *adev);
int amdgpu_enable_uniras(struct amdgpu_device *adev, bool enable);
diff --git a/drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_ras_sys.c b/drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_ras_sys.c
index 4744a7991757..6115f241f13b 100644
--- a/drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_ras_sys.c
+++ b/drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_ras_sys.c
@@ -110,6 +110,25 @@ static int amdgpu_ras_sys_gen_seqno(struct ras_core_context *ras_core,
}
+static int amdgpu_ras_early_init_reserve_badpage(struct ras_core_context *ras_core,
+ uint64_t pfn)
+{
+ struct amdgpu_bo *bo;
+ void *va;
+ int ret;
+
+ ret = amdgpu_bo_create_kernel_at(ras_core->dev, RAS_PFN_TO_ADDR(pfn),
+ AMDGPU_GPU_PAGE_SIZE, &bo, &va);
+ if (ret) {
+ ras_core->is_rma = true;
+ RAS_DEV_ERR(ras_core->dev,
+ "Early init: RAS failed to reserve: offset=0x%llx size=0x%x ret=%d\n",
+ RAS_PFN_TO_ADDR(pfn), AMDGPU_GPU_PAGE_SIZE, ret);
+ }
+
+ return ret;
+}
+
static int amdgpu_ras_sys_event_notifier(struct ras_core_context *ras_core,
enum ras_notify_event event_id, void *data)
{
@@ -126,6 +145,9 @@ static int amdgpu_ras_sys_event_notifier(struct ras_core_context *ras_core,
case RAS_EVENT_ID__RESERVE_BAD_PAGE:
ret = amdgpu_ras_reserve_page(ras_core->dev, *(uint64_t *)data);
break;
+ case RAS_EVENT_ID__EARLY_INIT_RESERVE_PAGE:
+ ret = amdgpu_ras_early_init_reserve_badpage(ras_core, *(uint64_t *)data);
+ break;
case RAS_EVENT_ID__FATAL_ERROR_DETECTED:
ret = amdgpu_ras_sys_detect_fatal_event(ras_core, data);
break;