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

Commit 362f844a authored by Skylar Chang's avatar Skylar Chang Committed by Gerrit - the friendly Code Review server
Browse files

msm: ipa: ipahal: change IPC logging to common buffer



Use IPA driver IPC buffer for IPC logging for IPAHAL.

CRs-Fixed: 1005492
Change-Id: Iee4f6e7b5da3ca27e9ef619bfb2bacc45970d3cc
Acked-by: default avatarAdy Abraham <adya@qti.qualcomm.com>
Signed-off-by: default avatarSkylar Chang <chiaweic@codeaurora.org>
parent 94cde8db
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -4936,6 +4936,18 @@ static int ipa2_stop_gsi_channel(u32 clnt_hdl)
	return -EFAULT;
}

static void *ipa2_get_ipc_logbuf(void)
{
	/* no support for IPC logging in IPAv2 */
	return NULL;
}

static void *ipa2_get_ipc_logbuf_low(void)
{
	/* no support for IPC logging in IPAv2 */
	return NULL;
}


int ipa2_bind_api_controller(enum ipa_hw_type ipa_hw_type,
	struct ipa_api_controller *api_ctrl)
@@ -5072,6 +5084,9 @@ int ipa2_bind_api_controller(enum ipa_hw_type ipa_hw_type,
	api_ctrl->ipa_suspend_resource_sync = ipa2_suspend_resource_sync;
	api_ctrl->ipa_set_required_perf_profile =
		ipa2_set_required_perf_profile;
	api_ctrl->ipa_get_ipc_logbuf = ipa2_get_ipc_logbuf;
	api_ctrl->ipa_get_ipc_logbuf_low = ipa2_get_ipc_logbuf_low;


	return 0;
}
+0 −1
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@
#include <asm/dma-iommu.h>
#include <linux/iommu.h>
#include <linux/platform_device.h>
#include <linux/ipc_logging.h>
#include <linux/firmware.h>
#include "ipa_hw_defs.h"
#include "ipa_ram_mmap.h"
+17 −0
Original line number Diff line number Diff line
@@ -4439,6 +4439,21 @@ int ipa3_disable_apps_wan_cons_deaggr(uint32_t agg_size, uint32_t agg_count)
	return res;
}

static void *ipa3_get_ipc_logbuf(void)
{
	if (ipa3_ctx)
		return ipa3_ctx->logbuf;

	return NULL;
}

static void *ipa3_get_ipc_logbuf_low(void)
{
	if (ipa3_ctx)
		return ipa3_ctx->logbuf_low;

	return NULL;
}

int ipa3_bind_api_controller(enum ipa_hw_type ipa_hw_type,
	struct ipa_api_controller *api_ctrl)
@@ -4576,6 +4591,8 @@ int ipa3_bind_api_controller(enum ipa_hw_type ipa_hw_type,
	api_ctrl->ipa_suspend_resource_sync = ipa3_suspend_resource_sync;
	api_ctrl->ipa_set_required_perf_profile =
		ipa3_set_required_perf_profile;
	api_ctrl->ipa_get_ipc_logbuf = ipa3_get_ipc_logbuf;
	api_ctrl->ipa_get_ipc_logbuf_low = ipa3_get_ipc_logbuf_low;

	return 0;
}
+5 −50
Original line number Diff line number Diff line
@@ -10,7 +10,6 @@
 * GNU General Public License for more details.
 */

#include <linux/ipc_logging.h>
#include <linux/debugfs.h>
#include "ipahal.h"
#include "ipahal_i.h"
@@ -987,46 +986,12 @@ const char *ipahal_pkt_status_exception_str(
	return ipahal_pkt_status_exception_to_str[exception];
}

static int ipahal_ipc_logging_init(void)
{
	ipahal_ctx->ipc_logbuf =
		ipc_log_context_create(IPAHAL_IPC_LOG_PAGES, "ipahal", 0);
	if (!ipahal_ctx->ipc_logbuf) {
		/* Cannot use the logging macros as no log buffers yet */
		pr_err("ipaghal: failed to create ipc_logbuf\n");
		return -ENOMEM;
	}

	ipahal_ctx->ipc_logbuf_low =
		ipc_log_context_create(IPAHAL_IPC_LOG_PAGES, "ipahal_low", 0);
	if (!ipahal_ctx->ipc_logbuf_low) {
		/* Cannot use the logging macros as no log buffers yet */
		pr_err("ipaghal: failed to create ipc_logbuf_low\n");
		ipc_log_context_destroy(ipahal_ctx->ipc_logbuf);
		return -ENOMEM;
	}

	return 0;
}

#ifdef CONFIG_DEBUG_FS
static void ipahal_debugfs_init(void)
{
	const mode_t read_write_mode = S_IRUSR | S_IRGRP | S_IROTH |
		S_IWUSR | S_IWGRP;

	ipahal_ctx->dent = debugfs_create_dir("ipahal", 0);
	if (!ipahal_ctx->dent || IS_ERR(ipahal_ctx->dent)) {
		IPAHAL_ERR("fail to create ipahal debugfs folder\n");
		return;
	}

	ipahal_ctx->dfile_enable_low_prio_ipc =
		debugfs_create_u32("enable_low_prio_log", read_write_mode,
		ipahal_ctx->dent, &ipahal_ctx->enable_low_prio_ipc);
	if (!ipahal_ctx->dfile_enable_low_prio_ipc ||
		IS_ERR(ipahal_ctx->dfile_enable_low_prio_ipc)) {
		IPAHAL_ERR("fail create enable_low_prio_log debugfs file\n");
		goto fail;
	}

@@ -1067,23 +1032,16 @@ int ipahal_init(enum ipa_hw_type ipa_hw_type, void __iomem *base)
		goto bail_err_exit;
	}

	if (ipahal_ipc_logging_init()) {
		/* Cannot use the logging macros as no log buffers yet */
		pr_err("ipahal: failed to initialize ipc logging\n");
		result = -ENOMEM;
		goto bail_free_ctx;
	}

	if (ipa_hw_type < IPA_HW_v3_0) {
		IPAHAL_ERR("ipahal supported on IPAv3 and later only\n");
		result = -EINVAL;
		goto bail_destroy_ipc;
		goto bail_free_ctx;
	}

	if (!base) {
		IPAHAL_ERR("invalid memory io mapping addr\n");
		result = -EINVAL;
		goto bail_destroy_ipc;
		goto bail_free_ctx;
	}

	ipahal_ctx->hw_type = ipa_hw_type;
@@ -1092,28 +1050,25 @@ int ipahal_init(enum ipa_hw_type ipa_hw_type, void __iomem *base)
	if (ipahal_reg_init(ipa_hw_type)) {
		IPAHAL_ERR("failed to init ipahal reg\n");
		result = -EFAULT;
		goto bail_destroy_ipc;
		goto bail_free_ctx;
	}

	if (ipahal_imm_cmd_init(ipa_hw_type)) {
		IPAHAL_ERR("failed to init ipahal imm cmd\n");
		result = -EFAULT;
		goto bail_destroy_ipc;
		goto bail_free_ctx;
	}

	if (ipahal_pkt_status_init(ipa_hw_type)) {
		IPAHAL_ERR("failed to init ipahal pkt status\n");
		result = -EFAULT;
		goto bail_destroy_ipc;
		goto bail_free_ctx;
	}

	ipahal_debugfs_init();

	return 0;

bail_destroy_ipc:
	ipc_log_context_destroy(ipahal_ctx->ipc_logbuf_low);
	ipc_log_context_destroy(ipahal_ctx->ipc_logbuf);
bail_free_ctx:
	kfree(ipahal_ctx);
	ipahal_ctx = NULL;
+19 −34
Original line number Diff line number Diff line
@@ -13,44 +13,37 @@
#ifndef _IPAHAL_I_H_
#define _IPAHAL_I_H_

#define IPAHAL_DRV_NAME "ipahal"
#include <linux/ipa.h>
#include "../../ipa_common_i.h"

#define IPAHAL_IPC_LOG_PAGES 10
#define IPAHAL_IPC_LOG(buf, fmt, args...) \
	ipc_log_string((buf), \
		IPAHAL_DRV_NAME " %s:%d " fmt, __func__, __LINE__, ## args)
#define IPAHAL_DRV_NAME "ipahal"

#define IPAHAL_DBG(fmt, args...) \
	do { \
		pr_debug(IPAHAL_DRV_NAME " %s:%d " fmt, \
			__func__, __LINE__, ## args); \
		if (likely(ipahal_ctx)) { \
			IPAHAL_IPC_LOG(ipahal_ctx->ipc_logbuf, fmt, ## args); \
			IPAHAL_IPC_LOG(ipahal_ctx->ipc_logbuf_low, \
				fmt, ## args); \
		} \
		pr_debug(IPAHAL_DRV_NAME " %s:%d " fmt, __func__, __LINE__, \
			## args); \
		IPA_IPC_LOGGING(ipa_get_ipc_logbuf(), \
			IPAHAL_DRV_NAME " %s:%d " fmt, ## args); \
		IPA_IPC_LOGGING(ipa_get_ipc_logbuf_low(), \
			IPAHAL_DRV_NAME " %s:%d " fmt, ## args); \
	} while (0)

#define IPAHAL_DBG_LOW(fmt, args...) \
	do { \
		pr_debug(IPAHAL_DRV_NAME " %s:%d " fmt, \
			__func__, __LINE__, ## args); \
		if (likely(ipahal_ctx) && \
			ipahal_ctx->enable_low_prio_ipc) { \
			IPAHAL_IPC_LOG(ipahal_ctx->ipc_logbuf_low, \
				fmt, ## args); \
		} \
		pr_debug(IPAHAL_DRV_NAME " %s:%d " fmt, __func__, __LINE__, \
			## args); \
		IPA_IPC_LOGGING(ipa_get_ipc_logbuf_low(), \
			IPAHAL_DRV_NAME " %s:%d " fmt, ## args); \
	} while (0)

#define IPAHAL_ERR(fmt, args...) \
	do { \
		pr_err(IPAHAL_DRV_NAME " %s:%d " fmt, \
			__func__, __LINE__, ## args); \
		if (likely(ipahal_ctx)) { \
			IPAHAL_IPC_LOG(ipahal_ctx->ipc_logbuf, fmt, ## args); \
			IPAHAL_IPC_LOG(ipahal_ctx->ipc_logbuf_low, \
				fmt, ## args); \
		} \
		pr_err(IPAHAL_DRV_NAME " %s:%d " fmt, __func__, __LINE__, \
			## args); \
		IPA_IPC_LOGGING(ipa_get_ipc_logbuf(), \
			IPAHAL_DRV_NAME " %s:%d " fmt, ## args); \
		IPA_IPC_LOGGING(ipa_get_ipc_logbuf_low(), \
			IPAHAL_DRV_NAME " %s:%d " fmt, ## args); \
	} while (0)

/*
@@ -58,21 +51,13 @@
 * @hw_type: IPA H/W type/version.
 * @base: Base address to be used for accessing IPA memory. This is
 *  I/O memory mapped address.
 * @ipc_logbuf: IPC debug logs buffer
 * @ipc_logbuf_low: IPC Low priority debug logs buffer
 * @enable_low_prio_ipc: Flag telling to enable low priority logging
 *  Controlled by debugfs. default is off
 * @dent: Debugfs folder dir entry
 * @dfile_enable_low_prio_ipc: Debugfs file for enable_low_prio_ipc
 */
struct ipahal_context {
	enum ipa_hw_type hw_type;
	void __iomem *base;
	void *ipc_logbuf;
	void *ipc_logbuf_low;
	u32 enable_low_prio_ipc;
	struct dentry *dent;
	struct dentry *dfile_enable_low_prio_ipc;
};

extern struct ipahal_context *ipahal_ctx;
Loading