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

Commit cc7f349b authored by Vivek Golani's avatar Vivek Golani Committed by Chetan C R
Browse files

diag: Handle drops for diag over rpmsg



Handle log drops for modem to apps diag communication over rpmsg.
Changes were made to clear the rpmsg buffers after they are marked
free and delete packets from the rx list only after they are processed.

Change-Id: Iee899640a20f9be0dc8d12428504ad986508ebc2
Signed-off-by: default avatarVivek Golani <vgolani@codeaurora.org>
parent ea96d05a
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (c) 2015-2019, The Linux Foundation. All rights reserved.
/* Copyright (c) 2015-2019, 2021, The Linux Foundation. All rights reserved.
 */
#include <linux/slab.h>
#include <linux/err.h>
@@ -1440,6 +1440,7 @@ void diagfwd_write_done(uint8_t peripheral, uint8_t type, int buf_num)
			DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
			"Buffer 1 for core PD is marked free, p: %d, t: %d, buf_num: %d\n",
				fwd_info->peripheral, fwd_info->type, buf_num);
			rpmsg_mark_buffers_free(peripheral, type, buf_num);
		}
	} else if (buf_num == 2 && fwd_info->buf_2) {
		/*
@@ -1466,6 +1467,7 @@ void diagfwd_write_done(uint8_t peripheral, uint8_t type, int buf_num)
			DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
			"Buffer 2 for core PD is marked free, p: %d, t: %d, buf_num: %d\n",
				fwd_info->peripheral, fwd_info->type, buf_num);
			rpmsg_mark_buffers_free(peripheral, type, buf_num);
		}
	} else if (buf_num >= 3 && (buf_num % 2)) {
		/*
@@ -1501,6 +1503,7 @@ void diagfwd_write_done(uint8_t peripheral, uint8_t type, int buf_num)
			DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
				"Buffer 1 for core PD is marked free, p: %d, t: %d, buf_num: %d\n",
				fwd_info->peripheral, fwd_info->type, buf_num);
			rpmsg_mark_buffers_free(peripheral, type, 1);
		}
	} else if (buf_num >= 4 && !(buf_num % 2)) {
		/*
@@ -1536,6 +1539,7 @@ void diagfwd_write_done(uint8_t peripheral, uint8_t type, int buf_num)
			DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
			"Buffer 2 for core PD is marked free, p: %d, t: %d, buf_num: %d\n",
			fwd_info->peripheral, fwd_info->type, buf_num);
			rpmsg_mark_buffers_free(peripheral, type, 2);
		}
	} else
		pr_err("diag: In %s, invalid buf_num %d\n", __func__, buf_num);
+40 −6
Original line number Diff line number Diff line
@@ -657,7 +657,7 @@ static void diag_rpmsg_notify_rx_work_fn(struct work_struct *work)
		/* detach last entry */
		rx_item = list_last_entry(&read_work_struct->rx_list_head,
						struct rx_buff_list, list);
		list_del(&rx_item->list);

		spin_unlock_irqrestore(&read_work_struct->rx_lock, flags);

		if (!rx_item)
@@ -707,13 +707,9 @@ static void diag_rpmsg_notify_rx_work_fn(struct work_struct *work)
		diagfwd_channel_read_done(rpmsg_info->fwd_ctxt,
				(unsigned char *)(buf), rx_item->rx_buf_size);

		if (buf == rpmsg_info->buf1)
			rpmsg_info->buf1 = NULL;
		else if (buf == rpmsg_info->buf2)
			rpmsg_info->buf2 = NULL;

		mutex_unlock(&driver->diagfwd_channel_mutex[PERI_RPMSG]);

		list_del(&rx_item->list);
		kfree(rx_item->rpmsg_rx_buf);
		kfree(rx_item);
	} else {
@@ -723,6 +719,44 @@ static void diag_rpmsg_notify_rx_work_fn(struct work_struct *work)
	return;
}

static struct diag_rpmsg_info *get_info_ptr(int type, int peripheral)
{
	if (type == TYPE_CMD)
		return &rpmsg_cmd[peripheral];
	else if (type == TYPE_CNTL)
		return &rpmsg_cntl[peripheral];
	else if (type == TYPE_DATA)
		return &rpmsg_data[peripheral];
	else if (type == TYPE_DCI_CMD)
		return &rpmsg_dci_cmd[peripheral];
	else if (type == TYPE_DCI)
		return &rpmsg_dci[peripheral];
	else
		return NULL;
}

void rpmsg_mark_buffers_free(uint8_t peripheral, uint8_t type, int buf_num)
{
	struct diag_rpmsg_info *rpmsg_info;

	if ((peripheral != PERIPHERAL_WDSP) &&
		(peripheral != PERIPHERAL_WCNSS) &&
			(peripheral != PERIPHERAL_MODEM))
		return;

	rpmsg_info =  get_info_ptr(type, peripheral);
	if (!rpmsg_info)
		return;

	if (buf_num == 1) {
		rpmsg_info->buf1 = NULL;
		DIAG_LOG(DIAG_DEBUG_PERIPHERALS, "marked buf1 NULL");
	} else if (buf_num == 2) {
		rpmsg_info->buf2 = NULL;
		DIAG_LOG(DIAG_DEBUG_PERIPHERALS, "marked buf2 NULL");
	}
}

static void rpmsg_late_init(struct diag_rpmsg_info *rpmsg_info)
{
	struct diagfwd_info *fwd_info = NULL;
+2 −1
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2017-2018, 2021, The Linux Foundation. All rights reserved.
 */

#ifndef DIAGFWD_RPMSG_H
@@ -43,5 +43,6 @@ int diag_rpmsg_init(void);
void diag_rpmsg_early_exit(void);
void diag_rpmsg_invalidate(void *ctxt, struct diagfwd_info *fwd_ctxt);
int diag_rpmsg_check_state(void *ctxt);
void rpmsg_mark_buffers_free(uint8_t peripheral, uint8_t type, int buf_num);

#endif