xref: /OK3568_Linux_fs/kernel/drivers/gpu/arm/bifrost/csf/mali_kbase_csf_firmware_core_dump.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 /*
3  *
4  * (C) COPYRIGHT 2021-2022 ARM Limited. All rights reserved.
5  *
6  * This program is free software and is provided to you under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation, and any use by you of this program is subject to the terms
9  * of such GNU license.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you can access it online at
18  * http://www.gnu.org/licenses/gpl-2.0.html.
19  *
20  */
21 
22 #ifndef _KBASE_CSF_FIRMWARE_CORE_DUMP_H_
23 #define _KBASE_CSF_FIRMWARE_CORE_DUMP_H_
24 
25 struct kbase_device;
26 
27 /** Offset of the last field of core dump entry from the image header */
28 #define CORE_DUMP_ENTRY_START_ADDR_OFFSET (0x4)
29 
30 /**
31  * kbase_csf_firmware_core_dump_entry_parse() - Parse a "core dump" entry from
32  *                                              the image header.
33  *
34  * @kbdev: Instance of a GPU platform device that implements a CSF interface.
35  * @entry: Pointer to section.
36  *
37  * Read a "core dump" entry from the image header, check the version for
38  * compatibility and store the address pointer.
39  *
40  * Return: 0 if successfully parse entry, negative error code otherwise.
41  */
42 int kbase_csf_firmware_core_dump_entry_parse(struct kbase_device *kbdev, const u32 *entry);
43 
44 /**
45  * kbase_csf_firmware_core_dump_init() - Initialize firmware core dump support
46  *
47  * @kbdev: Instance of a GPU platform device that implements a CSF interface.
48  *         Must be zero-initialized.
49  *
50  * Creates the fw_core_dump debugfs file through which to request a firmware
51  * core dump. The created debugfs file is cleaned up as part of kbdev debugfs
52  * cleanup.
53  *
54  * The fw_core_dump debugs file that case be used in the following way:
55  *
56  * To explicitly request core dump:
57  *     echo 1 >/sys/kernel/debug/mali0/fw_core_dump
58  *
59  * To output current core dump (after explicitly requesting a core dump, or
60  * kernel driver reported an internal firmware error):
61  *     cat /sys/kernel/debug/mali0/fw_core_dump
62  */
63 void kbase_csf_firmware_core_dump_init(struct kbase_device *const kbdev);
64 
65 #endif /* _KBASE_CSF_FIRMWARE_CORE_DUMP_H_ */
66