xref: /linux/drivers/gpu/drm/amd/amdgpu/mca_v3_0.c (revision 1ac731c529cd4d6adbce134754b51ff7d822b145)
13907c492SJohn Clements /*
23907c492SJohn Clements  * Copyright 2021 Advanced Micro Devices, Inc.
33907c492SJohn Clements  *
43907c492SJohn Clements  * Permission is hereby granted, free of charge, to any person obtaining a
53907c492SJohn Clements  * copy of this software and associated documentation files (the "Software"),
63907c492SJohn Clements  * to deal in the Software without restriction, including without limitation
73907c492SJohn Clements  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
83907c492SJohn Clements  * and/or sell copies of the Software, and to permit persons to whom the
93907c492SJohn Clements  * Software is furnished to do so, subject to the following conditions:
103907c492SJohn Clements  *
113907c492SJohn Clements  * The above copyright notice and this permission notice shall be included in
123907c492SJohn Clements  * all copies or substantial portions of the Software.
133907c492SJohn Clements  *
143907c492SJohn Clements  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
153907c492SJohn Clements  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
163907c492SJohn Clements  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
173907c492SJohn Clements  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
183907c492SJohn Clements  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
193907c492SJohn Clements  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
203907c492SJohn Clements  * OTHER DEALINGS IN THE SOFTWARE.
213907c492SJohn Clements  *
223907c492SJohn Clements  */
233907c492SJohn Clements #include "amdgpu_ras.h"
243907c492SJohn Clements #include "amdgpu.h"
253907c492SJohn Clements #include "amdgpu_mca.h"
263907c492SJohn Clements 
273907c492SJohn Clements #define smnMCMP0_STATUST0 	0x03830408
283907c492SJohn Clements #define smnMCMP1_STATUST0 	0x03b30408
293907c492SJohn Clements #define smnMCMPIO_STATUST0 	0x0c930408
303907c492SJohn Clements 
313907c492SJohn Clements 
mca_v3_0_mp0_query_ras_error_count(struct amdgpu_device * adev,void * ras_error_status)323907c492SJohn Clements static void mca_v3_0_mp0_query_ras_error_count(struct amdgpu_device *adev,
333907c492SJohn Clements 					       void *ras_error_status)
343907c492SJohn Clements {
353907c492SJohn Clements 	amdgpu_mca_query_ras_error_count(adev,
363907c492SJohn Clements 				         smnMCMP0_STATUST0,
373907c492SJohn Clements 				         ras_error_status);
383907c492SJohn Clements }
393907c492SJohn Clements 
mca_v3_0_ras_block_match(struct amdgpu_ras_block_object * block_obj,enum amdgpu_ras_block block,uint32_t sub_block_index)4071b6c4a2Syipechai static int mca_v3_0_ras_block_match(struct amdgpu_ras_block_object *block_obj,
4171b6c4a2Syipechai 				enum amdgpu_ras_block block, uint32_t sub_block_index)
42b0e2062dSyipechai {
43b0e2062dSyipechai 	if (!block_obj)
44b0e2062dSyipechai 		return -EINVAL;
45b0e2062dSyipechai 
46bdb3489cSyipechai 	if ((block_obj->ras_comm.block == block) &&
47bdb3489cSyipechai 		(block_obj->ras_comm.sub_block_index == sub_block_index)) {
48b0e2062dSyipechai 		return 0;
49b0e2062dSyipechai 	}
50b0e2062dSyipechai 
51b0e2062dSyipechai 	return -EINVAL;
52b0e2062dSyipechai }
53b0e2062dSyipechai 
54*7f544c54SHawking Zhang static const struct amdgpu_ras_block_hw_ops mca_v3_0_mp0_hw_ops = {
553907c492SJohn Clements 	.query_ras_error_count = mca_v3_0_mp0_query_ras_error_count,
563907c492SJohn Clements 	.query_ras_error_address = NULL,
57b0e2062dSyipechai };
58b0e2062dSyipechai 
59b0e2062dSyipechai struct amdgpu_mca_ras_block mca_v3_0_mp0_ras = {
60b0e2062dSyipechai 	.ras_block = {
61b0e2062dSyipechai 		.hw_ops = &mca_v3_0_mp0_hw_ops,
62b0e2062dSyipechai 		.ras_block_match = mca_v3_0_ras_block_match,
63b0e2062dSyipechai 	},
643907c492SJohn Clements };
653907c492SJohn Clements 
mca_v3_0_mp1_query_ras_error_count(struct amdgpu_device * adev,void * ras_error_status)663907c492SJohn Clements static void mca_v3_0_mp1_query_ras_error_count(struct amdgpu_device *adev,
673907c492SJohn Clements 					       void *ras_error_status)
683907c492SJohn Clements {
693907c492SJohn Clements 	amdgpu_mca_query_ras_error_count(adev,
703907c492SJohn Clements 				         smnMCMP1_STATUST0,
713907c492SJohn Clements 				         ras_error_status);
723907c492SJohn Clements }
733907c492SJohn Clements 
74*7f544c54SHawking Zhang static const struct amdgpu_ras_block_hw_ops mca_v3_0_mp1_hw_ops = {
753907c492SJohn Clements 	.query_ras_error_count = mca_v3_0_mp1_query_ras_error_count,
763907c492SJohn Clements 	.query_ras_error_address = NULL,
77b0e2062dSyipechai };
78b0e2062dSyipechai 
79b0e2062dSyipechai struct amdgpu_mca_ras_block mca_v3_0_mp1_ras = {
80b0e2062dSyipechai 	.ras_block = {
81b0e2062dSyipechai 		.hw_ops = &mca_v3_0_mp1_hw_ops,
82b0e2062dSyipechai 		.ras_block_match = mca_v3_0_ras_block_match,
83b0e2062dSyipechai 	},
843907c492SJohn Clements };
853907c492SJohn Clements 
mca_v3_0_mpio_query_ras_error_count(struct amdgpu_device * adev,void * ras_error_status)863907c492SJohn Clements static void mca_v3_0_mpio_query_ras_error_count(struct amdgpu_device *adev,
873907c492SJohn Clements 					       void *ras_error_status)
883907c492SJohn Clements {
893907c492SJohn Clements 	amdgpu_mca_query_ras_error_count(adev,
903907c492SJohn Clements 				         smnMCMPIO_STATUST0,
913907c492SJohn Clements 				         ras_error_status);
923907c492SJohn Clements }
933907c492SJohn Clements 
94*7f544c54SHawking Zhang static const struct amdgpu_ras_block_hw_ops mca_v3_0_mpio_hw_ops = {
953907c492SJohn Clements 	.query_ras_error_count = mca_v3_0_mpio_query_ras_error_count,
963907c492SJohn Clements 	.query_ras_error_address = NULL,
97b0e2062dSyipechai };
98b0e2062dSyipechai 
99b0e2062dSyipechai struct amdgpu_mca_ras_block mca_v3_0_mpio_ras = {
100b0e2062dSyipechai 	.ras_block = {
101b0e2062dSyipechai 		.hw_ops = &mca_v3_0_mpio_hw_ops,
102b0e2062dSyipechai 		.ras_block_match = mca_v3_0_ras_block_match,
103b0e2062dSyipechai 	},
1043907c492SJohn Clements };
105