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

Commit e9c4d140 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "clk: qcom: Add BIMC logging support during kernel panic"

parents f347b949 c1f10561
Loading
Loading
Loading
Loading
+39 −1
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
 * Copyright (c) 2017-2018, 2020, The Linux Foundation. All rights reserved.
 */

#define pr_fmt(fmt) "%s: " fmt, __func__
@@ -12,6 +12,7 @@
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/mailbox_client.h>
#include <linux/mailbox_controller.h>
#include <dt-bindings/clock/qcom,aop-qmp.h>

#define MAX_LEN			        96
@@ -216,10 +217,43 @@ DEFINE_CLK_AOP_QMP(qdss_qmp_clk, clock, qdss, QDSS_CLK_LEVEL_DYNAMIC,
			QDSS_CLK_LEVEL_OFF, CLK_ENABLE_HAND_OFF);
DEFINE_CLK_AOP_QMP(qdss_ao_qmp_clk, clock, qdss_ao, QDSS_CLK_LEVEL_DYNAMIC,
			QDSS_CLK_LEVEL_OFF, 0);
DEFINE_CLK_AOP_QMP(bimc_qmp_clk, ddr, ddr_log, 1, 0, 0);

static struct clk_hw *aop_qmp_clk_hws[] = {
	[QDSS_CLK] = &qdss_qmp_clk.hw,
	[QDSS_AO_CLK] = &qdss_ao_qmp_clk.hw,
	[BIMC_CLK] = &bimc_qmp_clk.hw,
};

static int aop_qmp_clk_panic_callback(struct notifier_block *nfb,
					unsigned long event, void *unused)
{
	struct qmp_pkt pkt;
	struct clk_aop_qmp *clk = &bimc_qmp_clk;
	char mbox_msg[MAX_LEN];
	int ret;

	/*
	 * The mbox channel cannot be used in blocking mode as panic notifier
	 * callback function is called in atomic context. So update the channel
	 * to non-blocking mode before sending message.
	 */
	clk->mbox->cl->tx_block = false;
	snprintf(mbox_msg, MAX_LEN, "{class: %s, res: %s, val: 0}",
				clk->msg.class, clk->msg.res);
	pkt.size = MAX_LEN;
	pkt.data = mbox_msg;

	ret = mbox_send_message(clk->mbox, &pkt);
	if (ret < 0)
		pr_err("BIMC logging request failed, ret %d\n", ret);

	return NOTIFY_OK;
}

static struct notifier_block aop_qmp_clk_panic_notifier = {
	.notifier_call = aop_qmp_clk_panic_callback,
	.priority = 1,
};

static int qmp_update_client(struct clk_hw *hw, struct device *dev,
@@ -319,6 +353,10 @@ static int aop_qmp_clk_probe(struct platform_device *pdev)

	dev_info(&pdev->dev, "Registered clocks with AOP\n");

	if (of_property_read_bool(np, "qcom,clk-stop-bimc-log"))
		atomic_notifier_chain_register(&panic_notifier_list,
						&aop_qmp_clk_panic_notifier);

	return ret;
fail:
	mbox_free_channel(mbox);
+2 −1
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only */
/* Copyright (c) 2018, The Linux Foundation. All rights reserved. */
/* Copyright (c) 2018, 2020, The Linux Foundation. All rights reserved. */

#ifndef _DT_BINDINGS_CLK_QCOM_AOP_QMP_H
#define _DT_BINDINGS_CLK_QCOM_AOP_QMP_H
@@ -16,4 +16,5 @@
/* clocks id */
#define QDSS_CLK			0
#define QDSS_AO_CLK			1
#define BIMC_CLK			2
#endif