0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 #ifndef _AMDGPU_RAS_EEPROM_H
0025 #define _AMDGPU_RAS_EEPROM_H
0026
0027 #include <linux/i2c.h>
0028
0029 struct amdgpu_device;
0030
0031 enum amdgpu_ras_eeprom_err_type {
0032 AMDGPU_RAS_EEPROM_ERR_NA,
0033 AMDGPU_RAS_EEPROM_ERR_RECOVERABLE,
0034 AMDGPU_RAS_EEPROM_ERR_NON_RECOVERABLE,
0035 AMDGPU_RAS_EEPROM_ERR_COUNT,
0036 };
0037
0038 struct amdgpu_ras_eeprom_table_header {
0039 uint32_t header;
0040 uint32_t version;
0041 uint32_t first_rec_offset;
0042 uint32_t tbl_size;
0043 uint32_t checksum;
0044 } __packed;
0045
0046 struct amdgpu_ras_eeprom_control {
0047 struct amdgpu_ras_eeprom_table_header tbl_hdr;
0048
0049
0050
0051
0052
0053 u32 i2c_address;
0054
0055
0056
0057
0058
0059
0060 u32 ras_header_offset;
0061 u32 ras_record_offset;
0062
0063
0064
0065 u32 ras_num_recs;
0066
0067
0068
0069
0070
0071
0072 u32 ras_fri;
0073
0074
0075
0076
0077
0078 u32 ras_max_record_count;
0079
0080
0081
0082 struct mutex ras_tbl_mutex;
0083
0084
0085
0086 u32 bad_channel_bitmap;
0087 };
0088
0089
0090
0091
0092
0093 struct eeprom_table_record {
0094
0095 union {
0096 uint64_t address;
0097 uint64_t offset;
0098 };
0099
0100 uint64_t retired_page;
0101 uint64_t ts;
0102
0103 enum amdgpu_ras_eeprom_err_type err_type;
0104
0105 union {
0106 unsigned char bank;
0107 unsigned char cu;
0108 };
0109
0110 unsigned char mem_channel;
0111 unsigned char mcumc_id;
0112 } __packed;
0113
0114 int amdgpu_ras_eeprom_init(struct amdgpu_ras_eeprom_control *control,
0115 bool *exceed_err_limit);
0116
0117 int amdgpu_ras_eeprom_reset_table(struct amdgpu_ras_eeprom_control *control);
0118
0119 bool amdgpu_ras_eeprom_check_err_threshold(struct amdgpu_device *adev);
0120
0121 int amdgpu_ras_eeprom_read(struct amdgpu_ras_eeprom_control *control,
0122 struct eeprom_table_record *records, const u32 num);
0123
0124 int amdgpu_ras_eeprom_append(struct amdgpu_ras_eeprom_control *control,
0125 struct eeprom_table_record *records, const u32 num);
0126
0127 uint32_t amdgpu_ras_eeprom_max_record_count(void);
0128
0129 void amdgpu_ras_debugfs_set_ret_size(struct amdgpu_ras_eeprom_control *control);
0130
0131 extern const struct file_operations amdgpu_ras_debugfs_eeprom_size_ops;
0132 extern const struct file_operations amdgpu_ras_debugfs_eeprom_table_ops;
0133
0134 #endif