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

Commit dec36d01 authored by Yong Ding's avatar Yong Ding
Browse files

soc: qcom: hab: add some more logs



With this, it becomes clear to know it is HAB's log and
which line of which function shows the log. Moreover, it
is helpful for issue debugging with those prepared logs.

Change-Id: I9641e779f592a5be7750885228cac6374880c301
Signed-off-by: default avatarYong Ding <yongding@codeaurora.org>
parent 8ad90a3c
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@ struct uhab_context *hab_ctx_alloc(int kernel)
	kref_init(&ctx->refcount);
	ctx->import_ctx = habmem_imp_hyp_open();
	if (!ctx->import_ctx) {
		pr_err("habmem_imp_hyp_open failed\n");
		kfree(ctx);
		return NULL;
	}
@@ -155,6 +156,7 @@ struct virtual_channel *frontend_open(struct uhab_context *ctx,

	dev = find_hab_device(mm_id);
	if (dev == NULL) {
		pr_err("HAB device %d is not initialized\n", mm_id);
		ret = -EINVAL;
		goto err;
	}
@@ -168,6 +170,7 @@ struct virtual_channel *frontend_open(struct uhab_context *ctx,

	vchan = hab_vchan_alloc(ctx, pchan);
	if (!vchan) {
		pr_err("vchan alloc failed\n");
		ret = -ENOMEM;
		goto err;
	}
@@ -195,6 +198,7 @@ struct virtual_channel *frontend_open(struct uhab_context *ctx,
	hab_open_request_free(recv_request);

	vchan->session_id = open_id;
	pr_debug("vchan->session_id:%d\n", vchan->session_id);

	/* Send Ack sequence */
	hab_open_request_init(&request, HAB_PAYLOAD_TYPE_ACK, pchan,
@@ -230,6 +234,7 @@ struct virtual_channel *backend_listen(struct uhab_context *ctx,

	dev = find_hab_device(mm_id);
	if (dev == NULL) {
		pr_err("failed to find dev based on id %d\n", mm_id);
		ret = -EINVAL;
		goto err;
	}
@@ -259,6 +264,7 @@ struct virtual_channel *backend_listen(struct uhab_context *ctx,
		vchan->otherend_id = otherend_vchan_id;

		vchan->session_id = open_id;
		pr_debug("vchan->session_id:%d\n", vchan->session_id);

		/* Send Init-Ack sequence */
		hab_open_request_init(&request, HAB_PAYLOAD_TYPE_INIT_ACK,
@@ -291,6 +297,7 @@ struct virtual_channel *backend_listen(struct uhab_context *ctx,
	hab_pchan_put(pchan);
	return vchan;
err:
	pr_err("listen on mmid %d failed\n", mm_id);
	if (vchan)
		hab_vchan_put(vchan);
	if (pchan)
@@ -396,6 +403,9 @@ int hab_vchan_open(struct uhab_context *ctx,
	struct virtual_channel *vchan = NULL;
	struct hab_device *dev;

	pr_debug("Open mmid=%d, loopback mode=%d, loopback num=%d\n",
		mmid, hab_driver.b_loopback, hab_driver.loopback_num);

	if (!vcid)
		return -EINVAL;

@@ -424,8 +434,13 @@ int hab_vchan_open(struct uhab_context *ctx,
		}
	}

	if (IS_ERR(vchan))
	if (IS_ERR(vchan)) {
		pr_err("vchan open failed over mmid=%d\n", mmid);
		return PTR_ERR(vchan);
	}

	pr_debug("vchan id %x, remote id %x\n",
		vchan->id, vchan->otherend_id);

	write_lock(&ctx->ctx_lock);
	list_add_tail(&vchan->node, &ctx->vchannels);
@@ -718,6 +733,8 @@ static int hab_release(struct inode *inodep, struct file *filep)
	if (!ctx)
		return 0;

	pr_debug("inode %pK, filep %pK\n", inodep, filep);

	write_lock(&ctx->ctx_lock);

	list_for_each_entry_safe(vchan, tmp, &ctx->vchannels, node) {
+1 −1
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@
#ifndef __HAB_H
#define __HAB_H

#define pr_fmt(fmt) "hab: " fmt
#define pr_fmt(fmt) "|hab:%s:%d|" fmt, __func__, __LINE__

#include <linux/types.h>

+22 −2
Original line number Diff line number Diff line
@@ -74,8 +74,12 @@ static int habmem_get_dma_pages(unsigned long address,
	int fd;

	vma = find_vma(current->mm, address);
	if (!vma || !vma->vm_file)
	if (!vma || !vma->vm_file) {
		pr_err("cannot find vma\n");
		goto err;
	}

	pr_debug("vma flags %lx\n", vma->vm_flags);

	/* Look for the fd that matches this the vma file */
	fd = iterate_fd(current->files, 0, match_file, vma->vm_file);
@@ -104,6 +108,7 @@ static int habmem_get_dma_pages(unsigned long address,

	for_each_sg(sg_table->sgl, s, sg_table->nents, i) {
		page = sg_page(s);
		pr_debug("sgl length %d\n", s->length);

		for (j = page_offset; j < (s->length >> PAGE_SHIFT); j++) {
			pages[rc] = nth_page(page, j);
@@ -318,6 +323,9 @@ long habmem_imp_hyp_map(void *imp_ctx,
			kfree(pglist);
			pr_err("%ld pages vmap failed\n", pglist->npages);
			return -ENOMEM;
		} else {
			pr_debug("%ld pages vmap pass, return %pK\n",
				pglist->npages, pglist->kva);
		}

		pglist->uva = NULL;
@@ -332,6 +340,7 @@ long habmem_imp_hyp_map(void *imp_ctx,
	list_add_tail(&pglist->list,  &priv->imp_list);
	priv->cnt++;
	write_unlock(&priv->implist_lock);
	pr_debug("index returned %llx\n", *index);

	return 0;
}
@@ -349,6 +358,9 @@ long habmm_imp_hyp_unmap(void *imp_ctx,

	write_lock(&priv->implist_lock);
	list_for_each_entry_safe(pglist, tmp, &priv->imp_list, list) {
		pr_debug("node pglist %pK, kernel %d, pg_index %llx\n",
			pglist, pglist->kernel, pg_index);

		if (kernel) {
			if (pglist->kva == (void *)((uintptr_t)index))
				found  = 1;
@@ -370,6 +382,9 @@ long habmm_imp_hyp_unmap(void *imp_ctx,
		return -EINVAL;
	}

	pr_debug("detach pglist %pK, index %llx, kernel %d, list cnt %d\n",
		pglist, pglist->index, pglist->kernel, priv->cnt);

	if (kernel)
		if (pglist->kva)
			vunmap(pglist->kva);
@@ -405,6 +420,8 @@ static int hab_map_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
		return VM_FAULT_SIGBUS;
	}

	pr_debug("Fault page index %d\n", page_idx);

	page = pglist->pages[page_idx];
	get_page(page);
	vmf->page = page;
@@ -434,6 +451,9 @@ int habmem_imp_hyp_mmap(struct file *filp, struct vm_area_struct *vma)
	struct pages_list *pglist;
	int bfound = 0;

	pr_debug("mmap request start %lX, len %ld, index %lX\n",
		vma->vm_start, length, vma->vm_pgoff);

	read_lock(&imp_ctx->implist_lock);
	list_for_each_entry(pglist, &imp_ctx->imp_list, list) {
		if (pglist->index == vma->vm_pgoff) {
@@ -444,7 +464,7 @@ int habmem_imp_hyp_mmap(struct file *filp, struct vm_area_struct *vma)
	read_unlock(&imp_ctx->implist_lock);

	if (!bfound) {
		pr_err("Failed to find pglist vm_pgoff: %d\n", vma->vm_pgoff);
		pr_err("Failed to find pglist vm_pgoff: %ld\n", vma->vm_pgoff);
		return -EINVAL;
	}

+19 −2
Original line number Diff line number Diff line
@@ -229,6 +229,8 @@ int hab_mem_export(struct uhab_context *ctx,
	if (!ctx || !param || param->sizebytes > HAB_MAX_EXPORT_SIZE)
		return -EINVAL;

	pr_debug("vc %X, mem size %d\n", param->vcid, param->sizebytes);

	vchan = hab_get_vchan_fromvcid(param->vcid, ctx);
	if (!vchan || !vchan->pchan) {
		ret = -ENODEV;
@@ -304,7 +306,10 @@ int hab_mem_unexport(struct uhab_context *ctx,
		return -EINVAL;

	ret = habmem_hyp_revoke(exp->payload, exp->payload_count);

	if (ret) {
		pr_err("Error found in revoke grant with ret %d", ret);
		return ret;
	}
	habmem_remove_export(exp);
	return ret;
}
@@ -336,6 +341,10 @@ int hab_mem_import(struct uhab_context *ctx,
		return ret;
	}

	pr_debug("call map id: %d pcnt %d remote_dom %d 1st_ref:0x%X\n",
		exp->export_id, exp->payload_count, exp->domid_local,
		*((uint32_t *)exp->payload));

	ret = habmem_imp_hyp_map(ctx->import_ctx,
		exp->payload,
		exp->payload_count,
@@ -350,6 +359,8 @@ int hab_mem_import(struct uhab_context *ctx,
			exp->domid_local, *((uint32_t *)exp->payload));
		return ret;
	}
	pr_debug("import index %llx, kva %llx, kernel %d\n",
		exp->import_index, param->kva, kernel);

	param->index = exp->import_index;
	param->kva = (uint64_t)exp->kva;
@@ -374,6 +385,9 @@ int hab_mem_unimport(struct uhab_context *ctx,
			list_del(&exp->node);
			ctx->import_total--;
			found = 1;

			pr_debug("found id:%d payload cnt:%d kernel:%d\n",
				exp->export_id, exp->payload_count, kernel);
			break;
		}
	}
@@ -386,7 +400,10 @@ int hab_mem_unimport(struct uhab_context *ctx,
			exp->import_index,
			exp->payload_count,
			kernel);

		if (ret) {
			pr_err("unmap fail id:%d pcnt:%d kernel:%d\n",
				exp->export_id, exp->payload_count, kernel);
		}
		param->kva = (uint64_t)exp->kva;
		kfree(exp);
	}
+15 −0
Original line number Diff line number Diff line
@@ -126,6 +126,11 @@ static int hab_receive_create_export_ack(struct physical_channel *pchan,
		sizebytes) != sizebytes)
		return -EIO;

	pr_debug("receive export id %d, local vc %X, vd remote %X\n",
		ack_recvd->ack.export_id,
		ack_recvd->ack.vcid_local,
		ack_recvd->ack.vcid_remote);

	spin_lock_bh(&ctx->expq_lock);
	list_add_tail(&ack_recvd->node, &ctx->exp_rxq);
	spin_unlock_bh(&ctx->expq_lock);
@@ -235,6 +240,10 @@ void hab_msg_recv(struct physical_channel *pchan,
		break;

	case HAB_PAYLOAD_TYPE_CLOSE:
		/* remote request close */
		pr_debug("remote side request close\n");
		pr_debug(" vchan id %X, other end %X, session %d\n",
				vchan->id, vchan->otherend_id, session_id);
		hab_vchan_stop(vchan);
		break;

@@ -254,6 +263,12 @@ void hab_msg_recv(struct physical_channel *pchan,
		break;

	default:
		pr_err("unknown msg is received\n");
		pr_err("payload type %d, vchan id %x\n",
				payload_type, vchan_id);
		pr_err("sizebytes %zx, session %d\n",
				sizebytes, session_id);

		break;
	}
	if (vchan)
Loading