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

Commit a3477947 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "diag: Add debug logs tracing diag mhi read and write paths"

parents 73edb29a 0c199069
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -4290,7 +4290,7 @@ static void diag_debug_init(void)
	 * to be logged to IPC
	 */
	diag_debug_mask = DIAG_DEBUG_PERIPHERALS | DIAG_DEBUG_DCI |
				DIAG_DEBUG_USERSPACE | DIAG_DEBUG_BRIDGE;
		DIAG_DEBUG_MHI | DIAG_DEBUG_USERSPACE | DIAG_DEBUG_BRIDGE;
}
#else
static void diag_debug_init(void)
+1 −1
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ static int diagfwd_bridge_mux_write_done(unsigned char *buf, int len,
		return -EINVAL;
	ch = &bridge_info[buf_ctx];
	if (ch->dev_ops && ch->dev_ops->fwd_complete) {
		DIAG_LOG(DIAG_DEBUG_MHI,
		DIAG_LOG(DIAG_DEBUG_BRIDGE,
		"Write done completion received for buf %pK len:%d\n",
			buf, len);
		ch->dev_ops->fwd_complete(ch->ctxt, buf, len, 0);
+44 −15
Original line number Diff line number Diff line
/* Copyright (c) 2014-2019, The Linux Foundation. All rights reserved.
/* Copyright (c) 2014-2020, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -149,9 +149,12 @@ static void mhi_buf_tbl_remove(struct diag_mhi_info *mhi_info, int type,
		list_del(&item->link);
		if (type == TYPE_MHI_READ_CH) {
			DIAG_LOG(DIAG_DEBUG_MHI,
			"Callback received on buffer:%pK from mhi\n", buf);
			"Freeing read channel buffer: %pK\n", buf);
			diagmem_free(driver, item->buf, mhi_info->mempool);
		}
		DIAG_LOG(DIAG_DEBUG_MHI,
		"Removing %s channel item entry from table: %pK\n",
			mhi_info->name, buf);
		kfree(item);
		found = 1;
	}
@@ -189,7 +192,7 @@ static void mhi_buf_tbl_clear(struct diag_mhi_info *mhi_info)
				&mhi_info->read_done_list, link) {
				if (tp->buf == buf) {
					DIAG_LOG(DIAG_DEBUG_MHI,
						"buffer:%pK removed from table for ch:%s\n",
						"Read buffer:%pK removed from table for ch:%s\n",
						buf, mhi_info->name);
					list_del(&tp->link);
					kfree(tp);
@@ -211,6 +214,9 @@ static void mhi_buf_tbl_clear(struct diag_mhi_info *mhi_info)
			item = list_entry(start, struct diag_mhi_buf_tbl_t,
					  link);
			list_del(&item->link);
			DIAG_LOG(DIAG_DEBUG_MHI,
			"Write buffer %pK removed from table for ch: %s\n",
			buf, mhi_info->name);
			diag_remote_dev_write_done(mhi_info->dev_id, item->buf,
						   item->len, mhi_info->id);
			kfree(item);
@@ -237,6 +243,9 @@ static int __mhi_close(struct diag_mhi_info *mhi_info, int close_flag)

	if (close_flag == CLOSE_CHANNELS) {
		mutex_lock(&mhi_info->ch_mutex);
		DIAG_LOG(DIAG_DEBUG_MHI,
			"diag: %s mhi channel closed, calling mhi unprepare\n",
			mhi_info->name);
		mhi_unprepare_from_transfer(mhi_info->mhi_dev);
		mutex_unlock(&mhi_info->ch_mutex);
	}
@@ -252,8 +261,11 @@ static int mhi_close(int id)
		return -EINVAL;
	}

	if (!diag_mhi[id].enabled)
	if (!diag_mhi[id].enabled) {
		pr_err("diag: %s: mhi channel with index: %d is not enabled\n",
			__func__, id);
		return -ENODEV;
	}
	/*
	 * This function is called whenever the channel needs to be closed
	 * explicitly by Diag. Close both the read and write channels (denoted
@@ -286,9 +298,16 @@ static int __mhi_open(struct diag_mhi_info *mhi_info, int open_flag)
		return -ENODEV;
	if (open_flag == OPEN_CHANNELS) {
		if ((atomic_read(&(mhi_info->read_ch.opened))) &&
			(atomic_read(&(mhi_info->write_ch.opened))))
			(atomic_read(&(mhi_info->write_ch.opened)))) {
			DIAG_LOG(DIAG_DEBUG_MHI,
			"Read and write channel already open: %s\n",
			mhi_info->name);
			return 0;
		}
		mutex_lock(&mhi_info->ch_mutex);
		DIAG_LOG(DIAG_DEBUG_MHI,
			"Prepare mhi for transfer on port: %s\n",
			mhi_info->name);
		err = mhi_prepare_for_transfer(mhi_info->mhi_dev);
		mutex_unlock(&mhi_info->ch_mutex);
		if (err) {
@@ -298,9 +317,9 @@ static int __mhi_open(struct diag_mhi_info *mhi_info, int open_flag)
		}
		atomic_set(&mhi_info->read_ch.opened, 1);
		atomic_set(&mhi_info->write_ch.opened, 1);
		DIAG_LOG(DIAG_DEBUG_BRIDGE,
			 "opened mhi read/write channel, port: %d\n",
			mhi_info->id);
		DIAG_LOG(DIAG_DEBUG_MHI,
			"opened mhi read/write channel, port: %s\n",
			mhi_info->name);
	} else if (open_flag == CHANNELS_OPENED) {
		if (!atomic_read(&(mhi_info->read_ch.opened)) ||
		    !atomic_read(&(mhi_info->write_ch.opened))) {
@@ -387,7 +406,7 @@ static void mhi_read_done_work_fn(struct work_struct *work)
		spin_unlock_irqrestore(&mhi_info->read_ch.lock, flags);
		if (!buf)
			break;
		DIAG_LOG(DIAG_DEBUG_BRIDGE,
		DIAG_LOG(DIAG_DEBUG_MHI,
			"read from mhi port %d buf %pK len:%d\n",
			mhi_info->id, buf, len);
		/*
@@ -453,7 +472,7 @@ static void mhi_read_work_fn(struct work_struct *work)
			goto fail;
		}

		DIAG_LOG(DIAG_DEBUG_BRIDGE,
		DIAG_LOG(DIAG_DEBUG_MHI,
			 "queueing a read buf %pK, ch: %s\n",
			 buf, mhi_info->name);

@@ -525,6 +544,8 @@ static int mhi_write(int id, unsigned char *buf, int len, int ctxt)
		spin_unlock_irqrestore(&ch->lock, flags);
		goto fail;
	}
	DIAG_LOG(DIAG_DEBUG_MHI, "diag: queueing a write buf %pK, ch: %s\n",
		 buf, diag_mhi[id].name);

	err = mhi_queue_transfer(diag_mhi[id].mhi_dev, DMA_TO_DEVICE, buf,
				len, mhi_flags);
@@ -602,7 +623,7 @@ static void diag_mhi_read_cb(struct mhi_device *mhi_dev,
		spin_lock_irqsave(&mhi_info->read_ch.lock, flags);
		tp = kmalloc(sizeof(*tp), GFP_ATOMIC);
		if (!tp) {
			DIAG_LOG(DIAG_DEBUG_BRIDGE,
			DIAG_LOG(DIAG_DEBUG_MHI,
			"no mem for list\n");
			spin_unlock_irqrestore(&mhi_info->read_ch.lock, flags);
			return;
@@ -611,7 +632,7 @@ static void diag_mhi_read_cb(struct mhi_device *mhi_dev,
				&mhi_info->read_ch.buf_tbl, link) {
			if (item->buf == buf) {
				DIAG_LOG(DIAG_DEBUG_MHI,
				"Callback received on buffer:%pK from mhi\n",
				"Read callback received on buffer:%pK from mhi\n",
					buf);
				tp->buf = buf;
				tp->len = result->bytes_xferd;
@@ -651,6 +672,9 @@ static void diag_mhi_write_cb(struct mhi_device *mhi_dev,
					__func__);
		return;
	}
	DIAG_LOG(DIAG_DEBUG_MHI,
		"Write callback received on buffer:%pK from mhi\n",
		buf);
	mhi_buf_tbl_remove(mhi_info, TYPE_MHI_WRITE_CH, buf,
				   result->bytes_xferd);
	diag_remote_dev_write_done(mhi_info->dev_id, buf,
@@ -670,6 +694,11 @@ static void diag_mhi_remove(struct mhi_device *mhi_dev)
		return;
	if (!mhi_info->enabled)
		return;

	DIAG_LOG(DIAG_DEBUG_MHI,
		"Remove called on mhi channel: %s\n",
		mhi_info->name);

	__mhi_close(mhi_info, CHANNELS_CLOSED);
	spin_lock_irqsave(&mhi_info->lock, flags);
	mhi_info->enabled = 0;
@@ -684,11 +713,11 @@ static int diag_mhi_probe(struct mhi_device *mhi_dev,
	unsigned long flags;
	struct diag_mhi_info *mhi_info = &diag_mhi[index];

	DIAG_LOG(DIAG_DEBUG_BRIDGE,
	DIAG_LOG(DIAG_DEBUG_MHI,
		"received probe for %d\n",
		index);
	diag_mhi[index].mhi_dev = mhi_dev;
	DIAG_LOG(DIAG_DEBUG_BRIDGE,
	DIAG_LOG(DIAG_DEBUG_MHI,
		"diag: mhi device is ready to open\n");
	spin_lock_irqsave(&mhi_info->lock, flags);
	mhi_info->enabled = 1;
@@ -758,7 +787,7 @@ int diag_mhi_init(void)
			       i, err);
			goto fail;
		}
		DIAG_LOG(DIAG_DEBUG_BRIDGE, "mhi port %d is initailzed\n", i);
		DIAG_LOG(DIAG_DEBUG_MHI, "mhi port %d is initailzed\n", i);
	}

	return 0;