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

Commit 4201acd0 authored by Rahul Sharma's avatar Rahul Sharma Committed by Yong Ding
Browse files

soc: qcom: hab: add send/recv total msg count



This stat can be used to determine if there is any
message lost between hab_vchan_send and hab_vchan_recv.

Change-Id: I37be3e0a1359315e213399b9f91b18158006cd3e
Signed-off-by: default avatarRahul Sharma <rahsha@codeaurora.org>
Signed-off-by: default avatarYong Ding <yongding@codeaurora.org>
parent e2ae22f9
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -587,6 +587,13 @@ long hab_vchan_send(struct uhab_context *ctx,

		schedule();
	}

	/*
	 * The ret here as 0 indicates the message was already sent out
	 * from the hab_vchan_send()'s perspective.
	 */
	if (!ret)
		vchan->tx_cnt++;
err:
	if (vchan)
		hab_vchan_put(vchan);
@@ -611,6 +618,8 @@ int hab_vchan_recv(struct uhab_context *ctx,
		return -ENODEV;
	}

	vchan->rx_inflight = 1;

	if (nonblocking_flag) {
		/*
		 * Try to pull data from the ring in this context instead of
@@ -628,8 +637,17 @@ int hab_vchan_recv(struct uhab_context *ctx,
			ret = -ENODEV;
		else if (ret == -ERESTARTSYS)
			ret = -EINTR;
	} else if (!ret) {
		/*
		 * Here, it is for sure that a message was received from the
		 * hab_vchan_recv()'s view w/ the ret as 0 and *message as
		 * non-zero.
		 */
		vchan->rx_cnt++;
	}

	vchan->rx_inflight = 0;

	hab_vchan_put(vchan);
	return ret;
}
+5 −1
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved.
 * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
 */
#ifndef __HAB_H
#define __HAB_H
@@ -341,6 +341,10 @@ struct virtual_channel {
	 */
	int closed;
	int forked; /* if fork is detected and assume only once */
	/* stats */
	uint64_t tx_cnt; /* total succeeded tx */
	uint64_t rx_cnt; /* total succeeded rx */
	int rx_inflight; /* rx in progress/blocking */
};

/*
+6 −3
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
 * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
 */
#include "hab.h"
#include "hab_grantable.h"
@@ -61,9 +61,12 @@ int hab_stat_show_vchan(struct hab_driver *driver,
			read_lock(&pchan->vchans_lock);
			list_for_each_entry(vc, &pchan->vchannels, pnode) {
				ret = hab_stat_buffer_print(buf, size,
					"%08X(%d:%d) ", vc->id,
					"%08X(%d:%d:%lu:%lu:%d) ", vc->id,
					get_refcnt(vc->refcount),
					vc->otherend_closed);
					vc->otherend_closed,
					(unsigned long)vc->tx_cnt,
					(unsigned long)vc->rx_cnt,
					vc->rx_inflight);
			}
			ret = hab_stat_buffer_print(buf, size, "\n");
			read_unlock(&pchan->vchans_lock);