xref: /openbsd/sys/dev/pci/drm/amd/amdgpu/mca_v3_0.c (revision f005ef32)
15ca02815Sjsg /*
25ca02815Sjsg  * Copyright 2021 Advanced Micro Devices, Inc.
35ca02815Sjsg  *
45ca02815Sjsg  * Permission is hereby granted, free of charge, to any person obtaining a
55ca02815Sjsg  * copy of this software and associated documentation files (the "Software"),
65ca02815Sjsg  * to deal in the Software without restriction, including without limitation
75ca02815Sjsg  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
85ca02815Sjsg  * and/or sell copies of the Software, and to permit persons to whom the
95ca02815Sjsg  * Software is furnished to do so, subject to the following conditions:
105ca02815Sjsg  *
115ca02815Sjsg  * The above copyright notice and this permission notice shall be included in
125ca02815Sjsg  * all copies or substantial portions of the Software.
135ca02815Sjsg  *
145ca02815Sjsg  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
155ca02815Sjsg  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
165ca02815Sjsg  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
175ca02815Sjsg  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
185ca02815Sjsg  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
195ca02815Sjsg  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
205ca02815Sjsg  * OTHER DEALINGS IN THE SOFTWARE.
215ca02815Sjsg  *
225ca02815Sjsg  */
235ca02815Sjsg #include "amdgpu_ras.h"
245ca02815Sjsg #include "amdgpu.h"
255ca02815Sjsg #include "amdgpu_mca.h"
265ca02815Sjsg 
275ca02815Sjsg #define smnMCMP0_STATUST0 	0x03830408
285ca02815Sjsg #define smnMCMP1_STATUST0 	0x03b30408
295ca02815Sjsg #define smnMCMPIO_STATUST0 	0x0c930408
305ca02815Sjsg 
315ca02815Sjsg 
mca_v3_0_mp0_query_ras_error_count(struct amdgpu_device * adev,void * ras_error_status)325ca02815Sjsg static void mca_v3_0_mp0_query_ras_error_count(struct amdgpu_device *adev,
335ca02815Sjsg 					       void *ras_error_status)
345ca02815Sjsg {
355ca02815Sjsg 	amdgpu_mca_query_ras_error_count(adev,
365ca02815Sjsg 				         smnMCMP0_STATUST0,
375ca02815Sjsg 				         ras_error_status);
385ca02815Sjsg }
395ca02815Sjsg 
mca_v3_0_ras_block_match(struct amdgpu_ras_block_object * block_obj,enum amdgpu_ras_block block,uint32_t sub_block_index)401bb76ff1Sjsg static int mca_v3_0_ras_block_match(struct amdgpu_ras_block_object *block_obj,
411bb76ff1Sjsg 				enum amdgpu_ras_block block, uint32_t sub_block_index)
425ca02815Sjsg {
431bb76ff1Sjsg 	if (!block_obj)
441bb76ff1Sjsg 		return -EINVAL;
451bb76ff1Sjsg 
461bb76ff1Sjsg 	if ((block_obj->ras_comm.block == block) &&
471bb76ff1Sjsg 		(block_obj->ras_comm.sub_block_index == sub_block_index)) {
481bb76ff1Sjsg 		return 0;
495ca02815Sjsg 	}
505ca02815Sjsg 
511bb76ff1Sjsg 	return -EINVAL;
525ca02815Sjsg }
535ca02815Sjsg 
54*f005ef32Sjsg static const struct amdgpu_ras_block_hw_ops mca_v3_0_mp0_hw_ops = {
555ca02815Sjsg 	.query_ras_error_count = mca_v3_0_mp0_query_ras_error_count,
565ca02815Sjsg 	.query_ras_error_address = NULL,
571bb76ff1Sjsg };
581bb76ff1Sjsg 
591bb76ff1Sjsg struct amdgpu_mca_ras_block mca_v3_0_mp0_ras = {
601bb76ff1Sjsg 	.ras_block = {
611bb76ff1Sjsg 		.hw_ops = &mca_v3_0_mp0_hw_ops,
621bb76ff1Sjsg 		.ras_block_match = mca_v3_0_ras_block_match,
631bb76ff1Sjsg 	},
645ca02815Sjsg };
655ca02815Sjsg 
mca_v3_0_mp1_query_ras_error_count(struct amdgpu_device * adev,void * ras_error_status)665ca02815Sjsg static void mca_v3_0_mp1_query_ras_error_count(struct amdgpu_device *adev,
675ca02815Sjsg 					       void *ras_error_status)
685ca02815Sjsg {
695ca02815Sjsg 	amdgpu_mca_query_ras_error_count(adev,
705ca02815Sjsg 				         smnMCMP1_STATUST0,
715ca02815Sjsg 				         ras_error_status);
725ca02815Sjsg }
735ca02815Sjsg 
74*f005ef32Sjsg static const struct amdgpu_ras_block_hw_ops mca_v3_0_mp1_hw_ops = {
755ca02815Sjsg 	.query_ras_error_count = mca_v3_0_mp1_query_ras_error_count,
765ca02815Sjsg 	.query_ras_error_address = NULL,
771bb76ff1Sjsg };
781bb76ff1Sjsg 
791bb76ff1Sjsg struct amdgpu_mca_ras_block mca_v3_0_mp1_ras = {
801bb76ff1Sjsg 	.ras_block = {
811bb76ff1Sjsg 		.hw_ops = &mca_v3_0_mp1_hw_ops,
821bb76ff1Sjsg 		.ras_block_match = mca_v3_0_ras_block_match,
831bb76ff1Sjsg 	},
845ca02815Sjsg };
855ca02815Sjsg 
mca_v3_0_mpio_query_ras_error_count(struct amdgpu_device * adev,void * ras_error_status)865ca02815Sjsg static void mca_v3_0_mpio_query_ras_error_count(struct amdgpu_device *adev,
875ca02815Sjsg 					       void *ras_error_status)
885ca02815Sjsg {
895ca02815Sjsg 	amdgpu_mca_query_ras_error_count(adev,
905ca02815Sjsg 				         smnMCMPIO_STATUST0,
915ca02815Sjsg 				         ras_error_status);
925ca02815Sjsg }
935ca02815Sjsg 
94*f005ef32Sjsg static const struct amdgpu_ras_block_hw_ops mca_v3_0_mpio_hw_ops = {
955ca02815Sjsg 	.query_ras_error_count = mca_v3_0_mpio_query_ras_error_count,
965ca02815Sjsg 	.query_ras_error_address = NULL,
971bb76ff1Sjsg };
981bb76ff1Sjsg 
991bb76ff1Sjsg struct amdgpu_mca_ras_block mca_v3_0_mpio_ras = {
1001bb76ff1Sjsg 	.ras_block = {
1011bb76ff1Sjsg 		.hw_ops = &mca_v3_0_mpio_hw_ops,
1021bb76ff1Sjsg 		.ras_block_match = mca_v3_0_ras_block_match,
1031bb76ff1Sjsg 	},
1045ca02815Sjsg };
105