diff --git a/drivers/soc/qcom/hab/hab.c b/drivers/soc/qcom/hab/hab.c index c7e333d5ba57..553aa93aa60f 100644 --- a/drivers/soc/qcom/hab/hab.c +++ b/drivers/soc/qcom/hab/hab.c @@ -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; } diff --git a/drivers/soc/qcom/hab/hab.h b/drivers/soc/qcom/hab/hab.h index bc11f2f47bcd..78b70995f4ca 100644 --- a/drivers/soc/qcom/hab/hab.h +++ b/drivers/soc/qcom/hab/hab.h @@ -1,6 +1,6 @@ /* 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 */ }; /* diff --git a/drivers/soc/qcom/hab/hab_stat.c b/drivers/soc/qcom/hab/hab_stat.c index 998ec6b43cee..de66b819d722 100644 --- a/drivers/soc/qcom/hab/hab_stat.c +++ b/drivers/soc/qcom/hab/hab_stat.c @@ -1,6 +1,6 @@ // 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);