From a2f9149175ad5ebd47307bddce69af6fc11f05aa Mon Sep 17 00:00:00 2001 From: Ram Nagesh Date: Thu, 23 Mar 2023 22:26:09 +0530 Subject: [PATCH] drivers: rdbg: Adds support for debugging multiple DSPs at the same time Chooses to retrieve data from common SMEM partition or device specific SMEM partition depending on the allocation done on the DSP side. Change-Id: I9e0346c2ea7163cca9f36ad01cf40916197e47d0 Acked-by: Gayathri Nadupalli Signed-off-by: Ram Nagesh --- drivers/char/rdbg.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/char/rdbg.c b/drivers/char/rdbg.c index d9d351f7debc..b4a40d419c5e 100644 --- a/drivers/char/rdbg.c +++ b/drivers/char/rdbg.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2013-2021, The Linux Foundation. All rights reserved. - * ​​​​Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. + * ​​​​Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -115,6 +115,7 @@ struct rdbg_data { struct smq producer_smrb; struct smq consumer_smrb; struct mutex write_mutex; + int smp2p_data[32]; }; struct rdbg_device { @@ -125,8 +126,6 @@ struct rdbg_device { struct rdbg_data *rdbg_data; }; - -int registers[32] = {0}; static struct rdbg_device g_rdbg_instance = { .class = NULL, .dev_no = 0, @@ -730,11 +729,10 @@ static void send_interrupt_to_subsystem(struct rdbg_data *rdbgdata) { unsigned int offset = rdbgdata->gpio_out_offset; unsigned int val; - - val = (registers[offset]) ^ (BIT(rdbgdata->out.smem_bit+offset)); + val = (rdbgdata->smp2p_data[offset]) ^ (BIT(rdbgdata->out.smem_bit+offset)); qcom_smem_state_update_bits(rdbgdata->out.smem_state, - BIT(rdbgdata->out.smem_bit+offset), val); - registers[offset] = val; + BIT(rdbgdata->out.smem_bit+offset), val); + rdbgdata->smp2p_data[offset] = val; rdbgdata->gpio_out_offset = (offset + 1) % 32; } @@ -809,6 +807,16 @@ static int rdbg_open(struct inode *inode, struct file *filp) rdbgdata->smem_addr = qcom_smem_get(QCOM_SMEM_HOST_ANY, proc_info[device_id].smem_buffer_addr, &(rdbgdata->smem_size)); + + if (IS_ERR(rdbgdata->smem_addr)) { + pr_err("rdbg: Can't retrieve data from common SMEM region.\n" + "Retrieving data from device specific partition.\n"); + if (PTR_ERR(rdbgdata->smem_addr) == -ENOENT) { + rdbgdata->smem_addr = qcom_smem_get(device_id, + proc_info[device_id].smem_buffer_addr, + &(rdbgdata->smem_size)); + } + } if (!rdbgdata->smem_addr) { dev_err(rdbgdata->device, "%s: Could not allocate smem memory\n", __func__);