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

Commit 7f766a68 authored by Vivek Golani's avatar Vivek Golani Committed by Gerrit - the friendly Code Review server
Browse files

diag: Drop packets to avoid memory exhaustion



Added support to drop packets if more than 10
packets have accumulated in the rx list since usb
is not sending write done for previous packets sent
to usb to avoid memory exhaustion.

Change-Id: I44fe814abc5b199e1d1b86dcc6d0e2f043d15c49
Signed-off-by: default avatarVivek Golani <vgolani@codeaurora.org>
parent 468bb1a5
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include "diag_ipc_logging.h"

#define PERI_RPMSG rpmsg_info->peripheral
#define RX_LIST_MAX_PKT_CNT	10

struct diag_rpmsg_read_work {
	struct work_struct work;
@@ -717,8 +718,15 @@ static void diag_rpmsg_notify_rx_work_fn(struct work_struct *work)
			spin_unlock_irqrestore(&read_work_struct->rx_lock,
								flags);
		} else {
			rpmsg_info->list_pkt_cnt += 1;
			if (rpmsg_info->list_pkt_cnt > RX_LIST_MAX_PKT_CNT)
				list_del(&rx_item->list);
			spin_unlock_irqrestore(&read_work_struct->rx_lock,
								flags);
			if (rpmsg_info->list_pkt_cnt > RX_LIST_MAX_PKT_CNT) {
				kfree(rx_item->rpmsg_rx_buf);
				kfree(rx_item);
			}
			goto end;
		}

@@ -782,6 +790,9 @@ void rpmsg_mark_buffers_free(uint8_t peripheral, uint8_t type, int buf_num)
		rpmsg_info->buf2 = NULL;
		DIAG_LOG(DIAG_DEBUG_PERIPHERALS, "marked buf2 NULL");
	}

	if (rpmsg_info->list_pkt_cnt > 0)
		rpmsg_info->list_pkt_cnt -= 1;
}

static void rpmsg_late_init(struct diag_rpmsg_info *rpmsg_info)
@@ -850,6 +861,7 @@ static void __diag_rpmsg_init(struct diag_rpmsg_info *rpmsg_info)
	rpmsg_info->hdl = NULL;
	rpmsg_info->fwd_ctxt = NULL;
	rpmsg_info->probed = 0;
	rpmsg_info->list_pkt_cnt = 0;
	atomic_set(&rpmsg_info->opened, 0);
	atomic_set(&rpmsg_info->diag_state, 0);
	DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
+1 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ struct diag_rpmsg_info {
	atomic_t opened;
	atomic_t diag_state;
	uint32_t fifo_size;
	uint32_t list_pkt_cnt;
	struct rpmsg_device *hdl;
	char edge[DIAG_RPMSG_NAME_SZ];
	char name[DIAG_RPMSG_NAME_SZ];