Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 02c9f337 authored by Lina Iyer's avatar Lina Iyer
Browse files

drivers: qcom: rpmh-rsc: increase debug verbosity



When RPMH hangs it could be because of accelerator hang in AOSS or Linux
could be lockedup and therefore not processing interrupts. Either of
these case results in a RPMH timeout ending with a OOPS dump. Provide
more information on which accelerator or if it was accelerator that
caused the failure.

Also remove redundant information of printing requests from the data
structure as well as TCS. They are most likely to have the same
information all the time.

Change-Id: I5a184a6a4ba7f09783dc3b48c15b15d24a81a33e
Signed-off-by: default avatarLina Iyer <ilina@codeaurora.org>
parent 5475c1e3
Loading
Loading
Loading
Loading
+29 −22
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
 * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
 */

#define pr_fmt(fmt) "%s " fmt, KBUILD_MODNAME
@@ -66,6 +66,13 @@
#define RSC_PDC_DRV_DATA		0x38
#define RSC_PDC_DATA_OFFSET		0x08

#define ACCL_TYPE(addr)			((addr >> 16) & 0xF)
#define NR_ACCL_TYPES			3

static const char * const accl_str[] = {
	"", "", "", "CLK", "VREG", "BUS",
};

bool rpmh_standalone;
static struct rsc_drv *__rsc_drv[2];
static int __rsc_count;
@@ -630,11 +637,10 @@ static struct tcs_group *get_tcs_from_index(struct rsc_drv *drv, int tcs_id)
	return NULL;
}

static void print_tcs_info(struct rsc_drv *drv, int tcs_id)
static void print_tcs_info(struct rsc_drv *drv, int tcs_id, unsigned long *accl)
{
	struct tcs_group *tcs_grp = get_tcs_from_index(drv, tcs_id);
	const struct tcs_request *req = get_req_from_tcs(drv, tcs_id);
	struct tcs_cmd *cmd;
	unsigned long cmds_enabled;
	u32 addr, data, msgid, sts, irq_sts;
	bool in_use = test_bit(tcs_id, drv->tcs_in_use);
@@ -658,29 +664,17 @@ static void print_tcs_info(struct rsc_drv *drv, int tcs_id)
		tcs_id, sts ? "IDLE" : "BUSY", data,
		(irq_sts & BIT(tcs_id)) ? "COMPLETED" : "PENDING");

	for (i = 0; i < req->num_cmds; i++) {
		cmd = &req->cmds[i];
		pr_warn("\tREQ=%d [addr=0x%x data=0x%x wait=0x%x]\n",
			i, cmd->addr, cmd->data, cmd->wait);

		if (i < MAX_CMDS_PER_TCS) {
			addr = read_tcs_reg(drv, RSC_DRV_CMD_ADDR, tcs_id, i);
			data = read_tcs_reg(drv, RSC_DRV_CMD_DATA, tcs_id, i);
			msgid = read_tcs_reg(drv, RSC_DRV_CMD_MSGID, tcs_id, i);
			sts = read_tcs_reg(drv, RSC_DRV_CMD_STATUS, tcs_id, i);
			pr_warn("\tCMD=%d [addr=0x%x data=0x%x hdr=0x%x sts=0x%x enabled=%ld]\n",
				i, addr, data, msgid, sts,
				(cmds_enabled & BIT(i)));
		}
	}

	for_each_set_bit_from(i, &cmds_enabled, MAX_CMDS_PER_TCS) {
	for_each_set_bit(i, &cmds_enabled, MAX_CMDS_PER_TCS) {
		addr = read_tcs_reg(drv, RSC_DRV_CMD_ADDR, tcs_id, i);
		data = read_tcs_reg(drv, RSC_DRV_CMD_DATA, tcs_id, i);
		msgid = read_tcs_reg(drv, RSC_DRV_CMD_MSGID, tcs_id, i);
		sts = read_tcs_reg(drv, RSC_DRV_CMD_STATUS, tcs_id, i);
		pr_warn("\tCMD=%d [addr=0x%x data=0x%x hdr=0x%x sts=0x%x enabled=1]\n",
			i, addr, data, msgid, sts);
		if (!(sts & CMD_STATUS_ISSUED))
			continue;
		if (!(sts & CMD_STATUS_COMPL))
			*accl |= BIT(ACCL_TYPE(addr));
	}
}

@@ -690,6 +684,8 @@ void rpmh_rsc_debug(struct rsc_drv *drv)
	bool irq_sts;
	int i;
	int busy = 0;
	unsigned long accl = 0;
	char str[20] = "";

	pr_warn("RSC:%s\n", drv->name);

@@ -697,7 +693,7 @@ void rpmh_rsc_debug(struct rsc_drv *drv)
		if (!test_bit(i, drv->tcs_in_use))
			continue;
		busy++;
		print_tcs_info(drv, i);
		print_tcs_info(drv, i, &accl);
	}

	if (!rsc_irq_data) {
@@ -709,6 +705,17 @@ void rpmh_rsc_debug(struct rsc_drv *drv)
	pr_warn("HW IRQ %lu is %s at GIC\n", rsc_irq_data->hwirq,
		irq_sts ? "PENDING" : "NOT PENDING");

	for_each_set_bit(i, &accl, ARRAY_SIZE(accl_str)) {
		strlcat(str, accl_str[i], sizeof(str));
		strlcat(str, " ", sizeof(str));
	}

	if (busy && !irq_sts)
		pr_warn("ERROR:Accelerator(s) { %s } at AOSS did not respond\n",
			str);
	else if (irq_sts)
		pr_warn("ERROR:Possible lockup in Linux\n");

	/*
	 * The TCS(s) are busy waiting, we have no way to recover from this.
	 * If this debug function is called, we assume it's because timeout