2019-07-23 19:42:03 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2019 Advanced Micro Devices, Inc.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included
|
|
|
|
* in all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|
|
|
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
#ifndef __AMDGPU_UMC_H__
|
|
|
|
#define __AMDGPU_UMC_H__
|
2022-01-06 14:07:44 +08:00
|
|
|
#include "amdgpu_ras.h"
|
2019-07-23 19:42:03 +08:00
|
|
|
|
2021-06-16 21:14:01 +08:00
|
|
|
/*
|
|
|
|
* (addr / 256) * 4096, the higher 26 bits in ErrorAddr
|
|
|
|
* is the index of 4KB block
|
|
|
|
*/
|
|
|
|
#define ADDR_OF_4KB_BLOCK(addr) (((addr) & ~0xffULL) << 4)
|
2020-07-23 17:38:20 +08:00
|
|
|
/*
|
|
|
|
* (addr / 256) * 8192, the higher 26 bits in ErrorAddr
|
|
|
|
* is the index of 8KB block
|
|
|
|
*/
|
|
|
|
#define ADDR_OF_8KB_BLOCK(addr) (((addr) & ~0xffULL) << 5)
|
|
|
|
/* channel index is the index of 256B block */
|
|
|
|
#define ADDR_OF_256B_BLOCK(channel_index) ((channel_index) << 8)
|
|
|
|
/* offset in 256B block */
|
|
|
|
#define OFFSET_IN_256B_BLOCK(addr) ((addr) & 0xffULL)
|
|
|
|
|
|
|
|
#define LOOP_UMC_INST(umc_inst) for ((umc_inst) = 0; (umc_inst) < adev->umc.umc_inst_num; (umc_inst)++)
|
|
|
|
#define LOOP_UMC_CH_INST(ch_inst) for ((ch_inst) = 0; (ch_inst) < adev->umc.channel_inst_num; (ch_inst)++)
|
|
|
|
#define LOOP_UMC_INST_AND_CH(umc_inst, ch_inst) LOOP_UMC_INST((umc_inst)) LOOP_UMC_CH_INST((ch_inst))
|
|
|
|
|
2022-01-06 14:07:44 +08:00
|
|
|
struct amdgpu_umc_ras {
|
|
|
|
struct amdgpu_ras_block_object ras_block;
|
2019-09-06 14:32:14 +08:00
|
|
|
void (*err_cnt_init)(struct amdgpu_device *adev);
|
2021-09-17 18:18:43 +08:00
|
|
|
bool (*query_ras_poison_mode)(struct amdgpu_device *adev);
|
2021-11-16 20:44:58 +08:00
|
|
|
void (*ecc_info_query_ras_error_count)(struct amdgpu_device *adev,
|
|
|
|
void *ras_error_status);
|
|
|
|
void (*ecc_info_query_ras_error_address)(struct amdgpu_device *adev,
|
|
|
|
void *ras_error_status);
|
2021-03-17 19:17:52 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct amdgpu_umc_funcs {
|
2019-09-24 16:08:00 +08:00
|
|
|
void (*init_registers)(struct amdgpu_device *adev);
|
2019-07-23 19:42:03 +08:00
|
|
|
};
|
|
|
|
|
2019-07-23 12:18:39 +08:00
|
|
|
struct amdgpu_umc {
|
|
|
|
/* max error count in one ras query call */
|
|
|
|
uint32_t max_ras_err_cnt_per_query;
|
2019-07-29 14:10:54 +08:00
|
|
|
/* number of umc channel instance with memory map register access */
|
|
|
|
uint32_t channel_inst_num;
|
|
|
|
/* number of umc instance with memory map register access */
|
|
|
|
uint32_t umc_inst_num;
|
|
|
|
/* UMC regiser per channel offset */
|
|
|
|
uint32_t channel_offs;
|
|
|
|
/* channel index table of interleaved memory */
|
|
|
|
const uint32_t *channel_idx_tbl;
|
2019-09-12 16:34:08 +08:00
|
|
|
struct ras_common_if *ras_if;
|
2019-07-29 14:10:54 +08:00
|
|
|
|
2019-07-23 12:18:39 +08:00
|
|
|
const struct amdgpu_umc_funcs *funcs;
|
2022-01-06 14:07:44 +08:00
|
|
|
struct amdgpu_umc_ras *ras;
|
2019-07-23 12:18:39 +08:00
|
|
|
};
|
|
|
|
|
2022-02-14 14:12:55 +08:00
|
|
|
int amdgpu_umc_ras_late_init(struct amdgpu_device *adev, struct ras_common_if *ras_block);
|
2021-12-20 16:36:54 +08:00
|
|
|
int amdgpu_umc_poison_handler(struct amdgpu_device *adev,
|
2019-09-12 11:11:25 +08:00
|
|
|
void *ras_error_status,
|
2021-12-10 17:01:15 +08:00
|
|
|
bool reset);
|
2019-09-12 11:11:25 +08:00
|
|
|
int amdgpu_umc_process_ecc_irq(struct amdgpu_device *adev,
|
|
|
|
struct amdgpu_irq_src *source,
|
|
|
|
struct amdgpu_iv_entry *entry);
|
2022-01-19 15:42:55 +08:00
|
|
|
void amdgpu_umc_fill_error_record(struct ras_err_data *err_data,
|
|
|
|
uint64_t err_addr,
|
|
|
|
uint64_t retired_page,
|
|
|
|
uint32_t channel_index,
|
|
|
|
uint32_t umc_inst);
|
2022-02-08 11:05:49 +08:00
|
|
|
|
|
|
|
int amdgpu_umc_process_ras_data_cb(struct amdgpu_device *adev,
|
|
|
|
void *ras_error_status,
|
|
|
|
struct amdgpu_iv_entry *entry);
|
2019-07-23 19:42:03 +08:00
|
|
|
#endif
|