mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
drm/amdgpu: Add ras module files into amdgpu
Add ras module files into amdgpu. Signed-off-by: YiPeng Chai <YiPeng.Chai@amd.com> Reviewed-by: Tao Zhou <tao.zhou1@amd.com> Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
committed by
Alex Deucher
parent
42f1487884
commit
ace232eff5
@@ -37,7 +37,8 @@ ccflags-y := -I$(FULL_AMD_PATH)/include/asic_reg \
|
|||||||
-I$(FULL_AMD_DISPLAY_PATH)/modules/inc \
|
-I$(FULL_AMD_DISPLAY_PATH)/modules/inc \
|
||||||
-I$(FULL_AMD_DISPLAY_PATH)/dc \
|
-I$(FULL_AMD_DISPLAY_PATH)/dc \
|
||||||
-I$(FULL_AMD_DISPLAY_PATH)/amdgpu_dm \
|
-I$(FULL_AMD_DISPLAY_PATH)/amdgpu_dm \
|
||||||
-I$(FULL_AMD_PATH)/amdkfd
|
-I$(FULL_AMD_PATH)/amdkfd \
|
||||||
|
-I$(FULL_AMD_PATH)/ras/ras_mgr
|
||||||
|
|
||||||
# Locally disable W=1 warnings enabled in drm subsystem Makefile
|
# Locally disable W=1 warnings enabled in drm subsystem Makefile
|
||||||
subdir-ccflags-y += -Wno-override-init
|
subdir-ccflags-y += -Wno-override-init
|
||||||
@@ -324,4 +325,9 @@ amdgpu-y += \
|
|||||||
isp_v4_1_1.o
|
isp_v4_1_1.o
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
AMD_GPU_RAS_PATH := ../ras
|
||||||
|
AMD_GPU_RAS_FULL_PATH := $(FULL_AMD_PATH)/ras
|
||||||
|
include $(AMD_GPU_RAS_FULL_PATH)/Makefile
|
||||||
|
amdgpu-y += $(AMD_GPU_RAS_FILES)
|
||||||
|
|
||||||
obj-$(CONFIG_DRM_AMDGPU)+= amdgpu.o
|
obj-$(CONFIG_DRM_AMDGPU)+= amdgpu.o
|
||||||
|
|||||||
@@ -504,6 +504,7 @@ struct ras_critical_region {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct amdgpu_ras {
|
struct amdgpu_ras {
|
||||||
|
void *ras_mgr;
|
||||||
/* ras infrastructure */
|
/* ras infrastructure */
|
||||||
/* for ras itself. */
|
/* for ras itself. */
|
||||||
uint32_t features;
|
uint32_t features;
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ static struct ras_core_context *ras_cmd_get_ras_core(uint64_t dev_handle)
|
|||||||
if (!dev_handle || (dev_handle == RAS_CMD_DEV_HANDLE_MAGIC))
|
if (!dev_handle || (dev_handle == RAS_CMD_DEV_HANDLE_MAGIC))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ras_core = (struct ras_core_context *)(dev_handle ^ RAS_CMD_DEV_HANDLE_MAGIC);
|
ras_core = (struct ras_core_context *)(uintptr_t)(dev_handle ^ RAS_CMD_DEV_HANDLE_MAGIC);
|
||||||
|
|
||||||
if (ras_cmd_get_dev_handle(ras_core) == dev_handle)
|
if (ras_cmd_get_dev_handle(ras_core) == dev_handle)
|
||||||
return ras_core;
|
return ras_core;
|
||||||
|
|||||||
@@ -373,7 +373,7 @@ struct amdgpu_ras_mgr *amdgpu_ras_mgr_get_context(struct amdgpu_device *adev)
|
|||||||
return (struct amdgpu_ras_mgr *)adev->psp.ras_context.ras->ras_mgr;
|
return (struct amdgpu_ras_mgr *)adev->psp.ras_context.ras->ras_mgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct amd_ip_funcs ras_v1_0_ip_funcs = {
|
static const struct amd_ip_funcs __maybe_unused ras_v1_0_ip_funcs = {
|
||||||
.name = "ras_v1_0",
|
.name = "ras_v1_0",
|
||||||
.sw_init = amdgpu_ras_mgr_sw_init,
|
.sw_init = amdgpu_ras_mgr_sw_init,
|
||||||
.sw_fini = amdgpu_ras_mgr_sw_fini,
|
.sw_fini = amdgpu_ras_mgr_sw_fini,
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include <linux/stdarg.h>
|
#include <linux/stdarg.h>
|
||||||
#include <linux/printk.h>
|
#include <linux/printk.h>
|
||||||
#include <linux/dev_printk.h>
|
#include <linux/dev_printk.h>
|
||||||
|
#include <linux/mempool.h>
|
||||||
#include "amdgpu.h"
|
#include "amdgpu.h"
|
||||||
|
|
||||||
#define RAS_DEV_ERR(device, fmt, ...) \
|
#define RAS_DEV_ERR(device, fmt, ...) \
|
||||||
|
|||||||
@@ -350,7 +350,7 @@ static int aca_banks_update(struct ras_core_context *ras_core,
|
|||||||
struct aca_bank_ecc bank_ecc;
|
struct aca_bank_ecc bank_ecc;
|
||||||
struct ras_log_batch_tag *batch_tag = NULL;
|
struct ras_log_batch_tag *batch_tag = NULL;
|
||||||
u32 count = 0;
|
u32 count = 0;
|
||||||
int ret;
|
int ret = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
mutex_lock(&ras_core->ras_aca.bank_op_lock);
|
mutex_lock(&ras_core->ras_aca.bank_op_lock);
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ static int ras_cmd_add_device(struct ras_core_context *ras_core)
|
|||||||
{
|
{
|
||||||
INIT_LIST_HEAD(&ras_core->ras_cmd.head);
|
INIT_LIST_HEAD(&ras_core->ras_cmd.head);
|
||||||
ras_core->ras_cmd.ras_core = ras_core;
|
ras_core->ras_cmd.ras_core = ras_core;
|
||||||
ras_core->ras_cmd.dev_handle = (uint64_t)ras_core ^ RAS_CMD_DEV_HANDLE_MAGIC;
|
ras_core->ras_cmd.dev_handle = (uintptr_t)ras_core ^ RAS_CMD_DEV_HANDLE_MAGIC;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,11 +212,6 @@ static int ras_cmd_get_cper_records(struct ras_core_context *ras_core,
|
|||||||
if (!req->buf_size || !req->buf_ptr || !req->cper_num)
|
if (!req->buf_size || !req->buf_ptr || !req->cper_num)
|
||||||
return RAS_CMD__ERROR_INVALID_INPUT_DATA;
|
return RAS_CMD__ERROR_INVALID_INPUT_DATA;
|
||||||
|
|
||||||
if (!access_ok((void *)req->buf_ptr, req->buf_size)) {
|
|
||||||
RAS_DEV_ERR(ras_core->dev, "Invalid cper buffer memory!\n");
|
|
||||||
return RAS_CMD__ERROR_INVALID_INPUT_DATA;
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer = kzalloc(req->buf_size, GFP_KERNEL);
|
buffer = kzalloc(req->buf_size, GFP_KERNEL);
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
return RAS_CMD__ERROR_GENERIC;
|
return RAS_CMD__ERROR_GENERIC;
|
||||||
@@ -240,7 +235,7 @@ static int ras_cmd_get_cper_records(struct ras_core_context *ras_core,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((ret && (ret != -ENOMEM)) ||
|
if ((ret && (ret != -ENOMEM)) ||
|
||||||
copy_to_user((void *)req->buf_ptr, buffer, offset)) {
|
copy_to_user(u64_to_user_ptr(req->buf_ptr), buffer, offset)) {
|
||||||
kfree(buffer);
|
kfree(buffer);
|
||||||
return RAS_CMD__ERROR_GENERIC;
|
return RAS_CMD__ERROR_GENERIC;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,8 +68,7 @@ int ras_core_convert_timestamp_to_time(struct ras_core_context *ras_core,
|
|||||||
int seconds_per_minute = 60;
|
int seconds_per_minute = 60;
|
||||||
int days, remaining_seconds;
|
int days, remaining_seconds;
|
||||||
|
|
||||||
days = timestamp / seconds_per_day;
|
days = div64_u64_rem(timestamp, seconds_per_day, (uint64_t *)&remaining_seconds);
|
||||||
remaining_seconds = timestamp % seconds_per_day;
|
|
||||||
|
|
||||||
/* utc_timestamp follows the Unix epoch */
|
/* utc_timestamp follows the Unix epoch */
|
||||||
year = 1970;
|
year = 1970;
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ static int ras_log_ring_add_data(struct ras_core_context *ras_core,
|
|||||||
{
|
{
|
||||||
struct ras_log_ring *log_ring = &ras_core->ras_log_ring;
|
struct ras_log_ring *log_ring = &ras_core->ras_log_ring;
|
||||||
unsigned long flags = 0;
|
unsigned long flags = 0;
|
||||||
int ret;
|
int ret = 0;
|
||||||
|
|
||||||
if (batch_tag && (batch_tag->sub_seqno >= MAX_RECORD_PER_BATCH)) {
|
if (batch_tag && (batch_tag->sub_seqno >= MAX_RECORD_PER_BATCH)) {
|
||||||
RAS_DEV_ERR(ras_core->dev,
|
RAS_DEV_ERR(ras_core->dev,
|
||||||
@@ -200,7 +200,7 @@ struct ras_log_batch_tag *ras_log_ring_create_batch_tag(struct ras_core_context
|
|||||||
{
|
{
|
||||||
struct ras_log_ring *log_ring = &ras_core->ras_log_ring;
|
struct ras_log_ring *log_ring = &ras_core->ras_log_ring;
|
||||||
struct ras_log_batch_tag *batch_tag;
|
struct ras_log_batch_tag *batch_tag;
|
||||||
unsigned long flags;
|
unsigned long flags = 0;
|
||||||
|
|
||||||
batch_tag = kzalloc(sizeof(*batch_tag), GFP_KERNEL);
|
batch_tag = kzalloc(sizeof(*batch_tag), GFP_KERNEL);
|
||||||
if (!batch_tag)
|
if (!batch_tag)
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ int ras_mp1_get_bank_count(struct ras_core_context *ras_core,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ras_mp1_dump_bank(struct ras_core_context *ras_core,
|
int ras_mp1_dump_bank(struct ras_core_context *ras_core,
|
||||||
enum ras_err_type type, u32 idx, u32 reg_idx, u64 *val)
|
u32 type, u32 idx, u32 reg_idx, u64 *val)
|
||||||
{
|
{
|
||||||
struct ras_mp1 *mp1 = &ras_core->ras_mp1;
|
struct ras_mp1 *mp1 = &ras_core->ras_mp1;
|
||||||
|
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ static uint32_t __get_ring_frame_slot(struct ras_core_context *ras_core)
|
|||||||
|
|
||||||
ras_ring_wptr_dw = psp->ip_func->psp_ras_ring_wptr_get(ras_core);
|
ras_ring_wptr_dw = psp->ip_func->psp_ras_ring_wptr_get(ras_core);
|
||||||
|
|
||||||
return (ras_ring_wptr_dw << 2) / sizeof(struct psp_gfx_rb_frame);
|
return div64_u64((ras_ring_wptr_dw << 2), sizeof(struct psp_gfx_rb_frame));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __set_ring_frame_slot(struct ras_core_context *ras_core,
|
static int __set_ring_frame_slot(struct ras_core_context *ras_core,
|
||||||
@@ -200,7 +200,7 @@ static int write_frame_to_ras_psp_ring(struct ras_core_context *ras_core,
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
max_frame_slot =
|
max_frame_slot =
|
||||||
ring_mem->mem_size / sizeof(struct psp_gfx_rb_frame);
|
div64_u64(ring_mem->mem_size, sizeof(struct psp_gfx_rb_frame));
|
||||||
|
|
||||||
rb_frame =
|
rb_frame =
|
||||||
(struct psp_gfx_rb_frame *)ring_mem->mem_cpu_addr;
|
(struct psp_gfx_rb_frame *)ring_mem->mem_cpu_addr;
|
||||||
|
|||||||
Reference in New Issue
Block a user