File Index
Files and directories
Sign in
FILE

ras_nbio.c

File preview with syntax highlighting.

linux-6.19.14/drivers/gpu/drm/amd/ras/rascore/ras_nbio.c C
 1// SPDX-License-Identifier: MIT
 2/*
 3 * Copyright 2025 Advanced Micro Devices, Inc.
 4 *
 5 * Permission is hereby granted, free of charge, to any person obtaining a
 6 * copy of this software and associated documentation files (the "Software"),
 7 * to deal in the Software without restriction, including without limitation
 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 * OTHER DEALINGS IN THE SOFTWARE.
22 *
23 */
24
25#include "ras.h"
26#include "ras_nbio.h"
27#include "ras_nbio_v7_9.h"
28
29static const struct ras_nbio_ip_func *ras_nbio_get_ip_funcs(
30				struct ras_core_context *ras_core, uint32_t ip_version)
31{
32	switch (ip_version) {
33	case IP_VERSION(7, 9, 0):
34	case IP_VERSION(7, 9, 1):
35		return &ras_nbio_v7_9;
36	default:
37		RAS_DEV_ERR(ras_core->dev,
38			"NBIO ip version(0x%x) is not supported!\n", ip_version);
39		break;
40	}
41
42	return NULL;
43}
44
45int ras_nbio_hw_init(struct ras_core_context *ras_core)
46{
47	struct ras_nbio *nbio = &ras_core->ras_nbio;
48
49	nbio->nbio_ip_version = ras_core->config->nbio_ip_version;
50	nbio->sys_func = ras_core->config->nbio_cfg.nbio_sys_fn;
51	if (!nbio->sys_func) {
52		RAS_DEV_ERR(ras_core->dev, "RAS nbio sys function not configured!\n");
53		return -EINVAL;
54	}
55
56	nbio->ip_func = ras_nbio_get_ip_funcs(ras_core, nbio->nbio_ip_version);
57	if (!nbio->ip_func)
58		return -EINVAL;
59
60	if (nbio->sys_func) {
61		if (nbio->sys_func->set_ras_controller_irq_state)
62			nbio->sys_func->set_ras_controller_irq_state(ras_core, true);
63		if (nbio->sys_func->set_ras_err_event_athub_irq_state)
64			nbio->sys_func->set_ras_err_event_athub_irq_state(ras_core, true);
65	}
66
67	return 0;
68}
69
70int ras_nbio_hw_fini(struct ras_core_context *ras_core)
71{
72	struct ras_nbio *nbio = &ras_core->ras_nbio;
73
74	if (nbio->sys_func) {
75		if (nbio->sys_func->set_ras_controller_irq_state)
76			nbio->sys_func->set_ras_controller_irq_state(ras_core, false);
77		if (nbio->sys_func->set_ras_err_event_athub_irq_state)
78			nbio->sys_func->set_ras_err_event_athub_irq_state(ras_core, false);
79	}
80
81	return 0;
82}
83
84bool ras_nbio_handle_irq_error(struct ras_core_context *ras_core, void *data)
85{
86	struct ras_nbio *nbio = &ras_core->ras_nbio;
87
88	if (nbio->ip_func) {
89		if (nbio->ip_func->handle_ras_controller_intr_no_bifring)
90			nbio->ip_func->handle_ras_controller_intr_no_bifring(ras_core);
91		if (nbio->ip_func->handle_ras_err_event_athub_intr_no_bifring)
92			nbio->ip_func->handle_ras_err_event_athub_intr_no_bifring(ras_core);
93	}
94
95	return true;
96}
~/ Read-only file preview.