Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) //
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3) // Copyright 2020 NXP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4) //
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) // Common helpers for the audio DSP on i.MX8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) #include <sound/sof/xtensa.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include "../ops.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include "imx-common.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)  * imx8_get_registers() - This function is called in case of DSP oops
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)  * in order to gather information about the registers, filename and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)  * linenumber and stack.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)  * @sdev: SOF device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)  * @xoops: Stores information about registers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)  * @panic_info: Stores information about filename and line number.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)  * @stack: Stores the stack dump.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)  * @stack_words: Size of the stack dump.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) void imx8_get_registers(struct snd_sof_dev *sdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 			struct sof_ipc_dsp_oops_xtensa *xoops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 			struct sof_ipc_panic_info *panic_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 			u32 *stack, size_t stack_words)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 	u32 offset = sdev->dsp_oops_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	/* first read registers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	sof_mailbox_read(sdev, offset, xoops, sizeof(*xoops));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	/* then get panic info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 	if (xoops->arch_hdr.totalsize > EXCEPT_MAX_HDR_SIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 		dev_err(sdev->dev, "invalid header size 0x%x. FW oops is bogus\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 			xoops->arch_hdr.totalsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	offset += xoops->arch_hdr.totalsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 	sof_mailbox_read(sdev, offset, panic_info, sizeof(*panic_info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	/* then get the stack */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 	offset += sizeof(*panic_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	sof_mailbox_read(sdev, offset, stack, stack_words * sizeof(u32));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)  * imx8_dump() - This function is called when a panic message is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)  * received from the firmware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) void imx8_dump(struct snd_sof_dev *sdev, u32 flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	struct sof_ipc_dsp_oops_xtensa xoops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 	struct sof_ipc_panic_info panic_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 	u32 stack[IMX8_STACK_DUMP_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 	u32 status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 	/* Get information about the panic status from the debug box area.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 	 * Compute the trace point based on the status.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 	sof_mailbox_read(sdev, sdev->debug_box.offset + 0x4, &status, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 	/* Get information about the registers, the filename and line
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 	 * number and the stack.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 	imx8_get_registers(sdev, &xoops, &panic_info, stack,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 			   IMX8_STACK_DUMP_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 	/* Print the information to the console */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 	snd_sof_get_status(sdev, status, status, &xoops, &panic_info, stack,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 			   IMX8_STACK_DUMP_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) EXPORT_SYMBOL(imx8_dump);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) MODULE_LICENSE("Dual BSD/GPL");