Path: blob/master/drivers/gpu/drm/amd/amdgpu/amdgpu_cper.h
26517 views
/* SPDX-License-Identifier: GPL-2.0 */1/*2* Copyright 2025 Advanced Micro Devices, Inc.3*4* Permission is hereby granted, free of charge, to any person obtaining a5* copy of this software and associated documentation files (the "Software"),6* to deal in the Software without restriction, including without limitation7* the rights to use, copy, modify, merge, publish, distribute, sublicense,8* and/or sell copies of the Software, and to permit persons to whom the9* Software is furnished to do so, subject to the following conditions:10*11* The above copyright notice and this permission notice shall be included in12* all copies or substantial portions of the Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR18* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,19* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR20* OTHER DEALINGS IN THE SOFTWARE.21*22*/2324#ifndef __AMDGPU_CPER_H__25#define __AMDGPU_CPER_H__2627#include "amd_cper.h"28#include "amdgpu_aca.h"2930#define CPER_MAX_ALLOWED_COUNT 0x100031#define CPER_MAX_RING_SIZE 0X10000032#define HDR_LEN (sizeof(struct cper_hdr))33#define SEC_DESC_LEN (sizeof(struct cper_sec_desc))3435#define BOOT_SEC_LEN (sizeof(struct cper_sec_crashdump_boot))36#define FATAL_SEC_LEN (sizeof(struct cper_sec_crashdump_fatal))37#define NONSTD_SEC_LEN (sizeof(struct cper_sec_nonstd_err))3839#define SEC_DESC_OFFSET(idx) (HDR_LEN + (SEC_DESC_LEN * idx))4041#define BOOT_SEC_OFFSET(count, idx) (HDR_LEN + (SEC_DESC_LEN * count) + (BOOT_SEC_LEN * idx))42#define FATAL_SEC_OFFSET(count, idx) (HDR_LEN + (SEC_DESC_LEN * count) + (FATAL_SEC_LEN * idx))43#define NONSTD_SEC_OFFSET(count, idx) (HDR_LEN + (SEC_DESC_LEN * count) + (NONSTD_SEC_LEN * idx))4445enum amdgpu_cper_type {46AMDGPU_CPER_TYPE_RUNTIME,47AMDGPU_CPER_TYPE_FATAL,48AMDGPU_CPER_TYPE_BOOT,49AMDGPU_CPER_TYPE_BP_THRESHOLD,50};5152struct amdgpu_cper {53bool enabled;5455atomic_t unique_id;56struct mutex cper_lock;5758/* Lifetime CPERs generated */59uint32_t count;60uint32_t max_count;6162uint32_t wptr;6364void *ring[CPER_MAX_ALLOWED_COUNT];65struct amdgpu_ring ring_buf;66struct mutex ring_lock;67};6869void amdgpu_cper_entry_fill_hdr(struct amdgpu_device *adev,70struct cper_hdr *hdr,71enum amdgpu_cper_type type,72enum cper_error_severity sev);73int amdgpu_cper_entry_fill_fatal_section(struct amdgpu_device *adev,74struct cper_hdr *hdr,75uint32_t idx,76struct cper_sec_crashdump_reg_data reg_data);77int amdgpu_cper_entry_fill_runtime_section(struct amdgpu_device *adev,78struct cper_hdr *hdr,79uint32_t idx,80enum cper_error_severity sev,81uint32_t *reg_dump,82uint32_t reg_count);83int amdgpu_cper_entry_fill_bad_page_threshold_section(struct amdgpu_device *adev,84struct cper_hdr *hdr,85uint32_t section_idx);8687struct cper_hdr *amdgpu_cper_alloc_entry(struct amdgpu_device *adev,88enum amdgpu_cper_type type,89uint16_t section_count);90/* UE must be encoded into separated cper entries, 1 UE 1 cper */91int amdgpu_cper_generate_ue_record(struct amdgpu_device *adev,92struct aca_bank *bank);93/* CEs and DEs are combined into 1 cper entry */94int amdgpu_cper_generate_ce_records(struct amdgpu_device *adev,95struct aca_banks *banks,96uint16_t bank_count);97/* Bad page threshold is encoded into separated cper entry */98int amdgpu_cper_generate_bp_threshold_record(struct amdgpu_device *adev);99void amdgpu_cper_ring_write(struct amdgpu_ring *ring,100void *src, int count);101int amdgpu_cper_init(struct amdgpu_device *adev);102int amdgpu_cper_fini(struct amdgpu_device *adev);103104#endif105106107