Commit 7aa7a72a authored by Michal Kazior's avatar Michal Kazior Committed by Kalle Valo
Browse files

ath10k: improve logging to include dev id



This makes it a lot easier to log and debug
messages if there's more than 1 ath10k device on a
system.

Signed-off-by: default avatarMichal Kazior <michal.kazior@tieto.com>
Signed-off-by: default avatarKalle Valo <kvalo@qca.qualcomm.com>
parent 61e9aab7
Loading
Loading
Loading
Loading
+26 −26
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@

void ath10k_bmi_start(struct ath10k *ar)
{
	ath10k_dbg(ATH10K_DBG_BMI, "bmi start\n");
	ath10k_dbg(ar, ATH10K_DBG_BMI, "bmi start\n");

	ar->bmi.done_sent = false;
}
@@ -33,10 +33,10 @@ int ath10k_bmi_done(struct ath10k *ar)
	u32 cmdlen = sizeof(cmd.id) + sizeof(cmd.done);
	int ret;

	ath10k_dbg(ATH10K_DBG_BMI, "bmi done\n");
	ath10k_dbg(ar, ATH10K_DBG_BMI, "bmi done\n");

	if (ar->bmi.done_sent) {
		ath10k_dbg(ATH10K_DBG_BMI, "bmi skipped\n");
		ath10k_dbg(ar, ATH10K_DBG_BMI, "bmi skipped\n");
		return 0;
	}

@@ -45,7 +45,7 @@ int ath10k_bmi_done(struct ath10k *ar)

	ret = ath10k_hif_exchange_bmi_msg(ar, &cmd, cmdlen, NULL, NULL);
	if (ret) {
		ath10k_warn("unable to write to the device: %d\n", ret);
		ath10k_warn(ar, "unable to write to the device: %d\n", ret);
		return ret;
	}

@@ -61,10 +61,10 @@ int ath10k_bmi_get_target_info(struct ath10k *ar,
	u32 resplen = sizeof(resp.get_target_info);
	int ret;

	ath10k_dbg(ATH10K_DBG_BMI, "bmi get target info\n");
	ath10k_dbg(ar, ATH10K_DBG_BMI, "bmi get target info\n");

	if (ar->bmi.done_sent) {
		ath10k_warn("BMI Get Target Info Command disallowed\n");
		ath10k_warn(ar, "BMI Get Target Info Command disallowed\n");
		return -EBUSY;
	}

@@ -72,12 +72,12 @@ int ath10k_bmi_get_target_info(struct ath10k *ar,

	ret = ath10k_hif_exchange_bmi_msg(ar, &cmd, cmdlen, &resp, &resplen);
	if (ret) {
		ath10k_warn("unable to get target info from device\n");
		ath10k_warn(ar, "unable to get target info from device\n");
		return ret;
	}

	if (resplen < sizeof(resp.get_target_info)) {
		ath10k_warn("invalid get_target_info response length (%d)\n",
		ath10k_warn(ar, "invalid get_target_info response length (%d)\n",
			    resplen);
		return -EIO;
	}
@@ -97,11 +97,11 @@ int ath10k_bmi_read_memory(struct ath10k *ar,
	u32 rxlen;
	int ret;

	ath10k_dbg(ATH10K_DBG_BMI, "bmi read address 0x%x length %d\n",
	ath10k_dbg(ar, ATH10K_DBG_BMI, "bmi read address 0x%x length %d\n",
		   address, length);

	if (ar->bmi.done_sent) {
		ath10k_warn("command disallowed\n");
		ath10k_warn(ar, "command disallowed\n");
		return -EBUSY;
	}

@@ -115,7 +115,7 @@ int ath10k_bmi_read_memory(struct ath10k *ar,
		ret = ath10k_hif_exchange_bmi_msg(ar, &cmd, cmdlen,
						  &resp, &rxlen);
		if (ret) {
			ath10k_warn("unable to read from the device (%d)\n",
			ath10k_warn(ar, "unable to read from the device (%d)\n",
				    ret);
			return ret;
		}
@@ -137,11 +137,11 @@ int ath10k_bmi_write_memory(struct ath10k *ar,
	u32 txlen;
	int ret;

	ath10k_dbg(ATH10K_DBG_BMI, "bmi write address 0x%x length %d\n",
	ath10k_dbg(ar, ATH10K_DBG_BMI, "bmi write address 0x%x length %d\n",
		   address, length);

	if (ar->bmi.done_sent) {
		ath10k_warn("command disallowed\n");
		ath10k_warn(ar, "command disallowed\n");
		return -EBUSY;
	}

@@ -159,7 +159,7 @@ int ath10k_bmi_write_memory(struct ath10k *ar,
		ret = ath10k_hif_exchange_bmi_msg(ar, &cmd, hdrlen + txlen,
						  NULL, NULL);
		if (ret) {
			ath10k_warn("unable to write to the device (%d)\n",
			ath10k_warn(ar, "unable to write to the device (%d)\n",
				    ret);
			return ret;
		}
@@ -183,11 +183,11 @@ int ath10k_bmi_execute(struct ath10k *ar, u32 address, u32 param, u32 *result)
	u32 resplen = sizeof(resp.execute);
	int ret;

	ath10k_dbg(ATH10K_DBG_BMI, "bmi execute address 0x%x param 0x%x\n",
	ath10k_dbg(ar, ATH10K_DBG_BMI, "bmi execute address 0x%x param 0x%x\n",
		   address, param);

	if (ar->bmi.done_sent) {
		ath10k_warn("command disallowed\n");
		ath10k_warn(ar, "command disallowed\n");
		return -EBUSY;
	}

@@ -197,19 +197,19 @@ int ath10k_bmi_execute(struct ath10k *ar, u32 address, u32 param, u32 *result)

	ret = ath10k_hif_exchange_bmi_msg(ar, &cmd, cmdlen, &resp, &resplen);
	if (ret) {
		ath10k_warn("unable to read from the device\n");
		ath10k_warn(ar, "unable to read from the device\n");
		return ret;
	}

	if (resplen < sizeof(resp.execute)) {
		ath10k_warn("invalid execute response length (%d)\n",
		ath10k_warn(ar, "invalid execute response length (%d)\n",
			    resplen);
		return -EIO;
	}

	*result = __le32_to_cpu(resp.execute.result);

	ath10k_dbg(ATH10K_DBG_BMI, "bmi execute result 0x%x\n", *result);
	ath10k_dbg(ar, ATH10K_DBG_BMI, "bmi execute result 0x%x\n", *result);

	return 0;
}
@@ -221,11 +221,11 @@ int ath10k_bmi_lz_data(struct ath10k *ar, const void *buffer, u32 length)
	u32 txlen;
	int ret;

	ath10k_dbg(ATH10K_DBG_BMI, "bmi lz data buffer 0x%p length %d\n",
	ath10k_dbg(ar, ATH10K_DBG_BMI, "bmi lz data buffer 0x%p length %d\n",
		   buffer, length);

	if (ar->bmi.done_sent) {
		ath10k_warn("command disallowed\n");
		ath10k_warn(ar, "command disallowed\n");
		return -EBUSY;
	}

@@ -241,7 +241,7 @@ int ath10k_bmi_lz_data(struct ath10k *ar, const void *buffer, u32 length)
		ret = ath10k_hif_exchange_bmi_msg(ar, &cmd, hdrlen + txlen,
						  NULL, NULL);
		if (ret) {
			ath10k_warn("unable to write to the device\n");
			ath10k_warn(ar, "unable to write to the device\n");
			return ret;
		}

@@ -258,11 +258,11 @@ int ath10k_bmi_lz_stream_start(struct ath10k *ar, u32 address)
	u32 cmdlen = sizeof(cmd.id) + sizeof(cmd.lz_start);
	int ret;

	ath10k_dbg(ATH10K_DBG_BMI, "bmi lz stream start address 0x%x\n",
	ath10k_dbg(ar, ATH10K_DBG_BMI, "bmi lz stream start address 0x%x\n",
		   address);

	if (ar->bmi.done_sent) {
		ath10k_warn("command disallowed\n");
		ath10k_warn(ar, "command disallowed\n");
		return -EBUSY;
	}

@@ -271,7 +271,7 @@ int ath10k_bmi_lz_stream_start(struct ath10k *ar, u32 address)

	ret = ath10k_hif_exchange_bmi_msg(ar, &cmd, cmdlen, NULL, NULL);
	if (ret) {
		ath10k_warn("unable to Start LZ Stream to the device\n");
		ath10k_warn(ar, "unable to Start LZ Stream to the device\n");
		return ret;
	}

@@ -286,7 +286,7 @@ int ath10k_bmi_fast_download(struct ath10k *ar,
	u32 trailer_len = length - head_len;
	int ret;

	ath10k_dbg(ATH10K_DBG_BMI,
	ath10k_dbg(ar, ATH10K_DBG_BMI,
		   "bmi fast download address 0x%x buffer 0x%p length %d\n",
		   address, buffer, length);

+7 −7
Original line number Diff line number Diff line
@@ -284,7 +284,7 @@ int ath10k_ce_send_nolock(struct ath10k_ce_pipe *ce_state,
	int ret = 0;

	if (nbytes > ce_state->src_sz_max)
		ath10k_warn("%s: send more we can (nbytes: %d, max: %d)\n",
		ath10k_warn(ar, "%s: send more we can (nbytes: %d, max: %d)\n",
			    __func__, nbytes, ce_state->src_sz_max);

	if (unlikely(CE_RING_DELTA(nentries_mask,
@@ -853,7 +853,7 @@ static int ath10k_ce_init_src_ring(struct ath10k *ar,
	ath10k_ce_src_ring_lowmark_set(ar, ctrl_addr, 0);
	ath10k_ce_src_ring_highmark_set(ar, ctrl_addr, nentries);

	ath10k_dbg(ATH10K_DBG_BOOT,
	ath10k_dbg(ar, ATH10K_DBG_BOOT,
		   "boot init ce src ring id %d entries %d base_addr %p\n",
		   ce_id, nentries, src_ring->base_addr_owner_space);

@@ -887,7 +887,7 @@ static int ath10k_ce_init_dest_ring(struct ath10k *ar,
	ath10k_ce_dest_ring_lowmark_set(ar, ctrl_addr, 0);
	ath10k_ce_dest_ring_highmark_set(ar, ctrl_addr, nentries);

	ath10k_dbg(ATH10K_DBG_BOOT,
	ath10k_dbg(ar, ATH10K_DBG_BOOT,
		   "boot ce dest ring id %d entries %d base_addr %p\n",
		   ce_id, nentries, dest_ring->base_addr_owner_space);

@@ -1056,7 +1056,7 @@ int ath10k_ce_init_pipe(struct ath10k *ar, unsigned int ce_id,
	if (attr->src_nentries) {
		ret = ath10k_ce_init_src_ring(ar, ce_id, attr);
		if (ret) {
			ath10k_err("Failed to initialize CE src ring for ID: %d (%d)\n",
			ath10k_err(ar, "Failed to initialize CE src ring for ID: %d (%d)\n",
				   ce_id, ret);
			return ret;
		}
@@ -1065,7 +1065,7 @@ int ath10k_ce_init_pipe(struct ath10k *ar, unsigned int ce_id,
	if (attr->dest_nentries) {
		ret = ath10k_ce_init_dest_ring(ar, ce_id, attr);
		if (ret) {
			ath10k_err("Failed to initialize CE dest ring for ID: %d (%d)\n",
			ath10k_err(ar, "Failed to initialize CE dest ring for ID: %d (%d)\n",
				   ce_id, ret);
			return ret;
		}
@@ -1110,7 +1110,7 @@ int ath10k_ce_alloc_pipe(struct ath10k *ar, int ce_id,
		ce_state->src_ring = ath10k_ce_alloc_src_ring(ar, ce_id, attr);
		if (IS_ERR(ce_state->src_ring)) {
			ret = PTR_ERR(ce_state->src_ring);
			ath10k_err("failed to allocate copy engine source ring %d: %d\n",
			ath10k_err(ar, "failed to allocate copy engine source ring %d: %d\n",
				   ce_id, ret);
			ce_state->src_ring = NULL;
			return ret;
@@ -1122,7 +1122,7 @@ int ath10k_ce_alloc_pipe(struct ath10k *ar, int ce_id,
								attr);
		if (IS_ERR(ce_state->dest_ring)) {
			ret = PTR_ERR(ce_state->dest_ring);
			ath10k_err("failed to allocate copy engine destination ring %d: %d\n",
			ath10k_err(ar, "failed to allocate copy engine destination ring %d: %d\n",
				   ce_id, ret);
			ce_state->dest_ring = NULL;
			return ret;
+92 −89

File changed.

Preview size limit exceeded, changes collapsed.

+24 −43
Original line number Diff line number Diff line
@@ -106,25 +106,7 @@ struct ath10k_dump_file_data {
	u8 data[0];
} __packed;

static int ath10k_printk(const char *level, const char *fmt, ...)
{
	struct va_format vaf;
	va_list args;
	int rtn;

	va_start(args, fmt);

	vaf.fmt = fmt;
	vaf.va = &args;

	rtn = printk("%sath10k: %pV", level, &vaf);

	va_end(args);

	return rtn;
}

int ath10k_info(const char *fmt, ...)
int ath10k_info(struct ath10k *ar, const char *fmt, ...)
{
	struct va_format vaf = {
		.fmt = fmt,
@@ -134,7 +116,7 @@ int ath10k_info(const char *fmt, ...)

	va_start(args, fmt);
	vaf.va = &args;
	ret = ath10k_printk(KERN_INFO, "%pV", &vaf);
	ret = dev_info(ar->dev, "%pV", &vaf);
	trace_ath10k_log_info(&vaf);
	va_end(args);

@@ -144,7 +126,7 @@ EXPORT_SYMBOL(ath10k_info);

void ath10k_print_driver_info(struct ath10k *ar)
{
	ath10k_info("%s (0x%08x, 0x%08x) fw %s api %d htt %d.%d\n",
	ath10k_info(ar, "%s (0x%08x, 0x%08x) fw %s api %d htt %d.%d\n",
		    ar->hw_params.name,
		    ar->target_version,
		    ar->chip_id,
@@ -152,7 +134,7 @@ void ath10k_print_driver_info(struct ath10k *ar)
		    ar->fw_api,
		    ar->htt.target_version_major,
		    ar->htt.target_version_minor);
	ath10k_info("debug %d debugfs %d tracing %d dfs %d\n",
	ath10k_info(ar, "debug %d debugfs %d tracing %d dfs %d\n",
		    config_enabled(CONFIG_ATH10K_DEBUG),
		    config_enabled(CONFIG_ATH10K_DEBUGFS),
		    config_enabled(CONFIG_ATH10K_TRACING),
@@ -160,7 +142,7 @@ void ath10k_print_driver_info(struct ath10k *ar)
}
EXPORT_SYMBOL(ath10k_print_driver_info);

int ath10k_err(const char *fmt, ...)
int ath10k_err(struct ath10k *ar, const char *fmt, ...)
{
	struct va_format vaf = {
		.fmt = fmt,
@@ -170,7 +152,7 @@ int ath10k_err(const char *fmt, ...)

	va_start(args, fmt);
	vaf.va = &args;
	ret = ath10k_printk(KERN_ERR, "%pV", &vaf);
	ret = dev_err(ar->dev, "%pV", &vaf);
	trace_ath10k_log_err(&vaf);
	va_end(args);

@@ -178,25 +160,21 @@ int ath10k_err(const char *fmt, ...)
}
EXPORT_SYMBOL(ath10k_err);

int ath10k_warn(const char *fmt, ...)
int ath10k_warn(struct ath10k *ar, const char *fmt, ...)
{
	struct va_format vaf = {
		.fmt = fmt,
	};
	va_list args;
	int ret = 0;

	va_start(args, fmt);
	vaf.va = &args;

	if (net_ratelimit())
		ret = ath10k_printk(KERN_WARNING, "%pV", &vaf);

	dev_warn_ratelimited(ar->dev, "%pV", &vaf);
	trace_ath10k_log_warn(&vaf);

	va_end(args);

	return ret;
	return 0;
}
EXPORT_SYMBOL(ath10k_warn);

@@ -417,7 +395,7 @@ static ssize_t ath10k_read_fw_stats(struct file *file, char __user *user_buf,

	ret = ath10k_wmi_request_stats(ar, WMI_REQUEST_PEER_STAT);
	if (ret) {
		ath10k_warn("could not request stats (%d)\n", ret);
		ath10k_warn(ar, "could not request stats (%d)\n", ret);
		goto exit;
	}

@@ -635,10 +613,10 @@ static ssize_t ath10k_write_simulate_fw_crash(struct file *file,
	}

	if (!strcmp(buf, "soft")) {
		ath10k_info("simulating soft firmware crash\n");
		ath10k_info(ar, "simulating soft firmware crash\n");
		ret = ath10k_wmi_force_fw_hang(ar, WMI_FORCE_FW_HANG_ASSERT, 0);
	} else if (!strcmp(buf, "hard")) {
		ath10k_info("simulating hard firmware crash\n");
		ath10k_info(ar, "simulating hard firmware crash\n");
		/* 0x7fff is vdev id, and it is always out of range for all
		 * firmware variants in order to force a firmware crash.
		 */
@@ -650,7 +628,7 @@ static ssize_t ath10k_write_simulate_fw_crash(struct file *file,
	}

	if (ret) {
		ath10k_warn("failed to simulate firmware crash: %d\n", ret);
		ath10k_warn(ar, "failed to simulate firmware crash: %d\n", ret);
		goto exit;
	}

@@ -839,7 +817,7 @@ static int ath10k_debug_htt_stats_req(struct ath10k *ar)
	ret = ath10k_htt_h2t_stats_req(&ar->htt, ar->debug.htt_stats_mask,
				       cookie);
	if (ret) {
		ath10k_warn("failed to send htt stats request: %d\n", ret);
		ath10k_warn(ar, "failed to send htt stats request: %d\n", ret);
		return ret;
	}

@@ -1013,7 +991,7 @@ static ssize_t ath10k_write_fw_dbglog(struct file *file,
	if (ar->state == ATH10K_STATE_ON) {
		ret = ath10k_wmi_dbglog_cfg(ar, ar->debug.fw_dbglog_mask);
		if (ret) {
			ath10k_warn("dbglog cfg failed from debugfs: %d\n",
			ath10k_warn(ar, "dbglog cfg failed from debugfs: %d\n",
				    ret);
			goto exit;
		}
@@ -1044,13 +1022,14 @@ int ath10k_debug_start(struct ath10k *ar)
	ret = ath10k_debug_htt_stats_req(ar);
	if (ret)
		/* continue normally anyway, this isn't serious */
		ath10k_warn("failed to start htt stats workqueue: %d\n", ret);
		ath10k_warn(ar, "failed to start htt stats workqueue: %d\n",
			    ret);

	if (ar->debug.fw_dbglog_mask) {
		ret = ath10k_wmi_dbglog_cfg(ar, ar->debug.fw_dbglog_mask);
		if (ret)
			/* not serious */
			ath10k_warn("failed to enable dbglog during start: %d",
			ath10k_warn(ar, "failed to enable dbglog during start: %d",
				    ret);
	}

@@ -1230,7 +1209,8 @@ void ath10k_debug_destroy(struct ath10k *ar)
#endif /* CONFIG_ATH10K_DEBUGFS */

#ifdef CONFIG_ATH10K_DEBUG
void ath10k_dbg(enum ath10k_debug_mask mask, const char *fmt, ...)
void ath10k_dbg(struct ath10k *ar, enum ath10k_debug_mask mask,
		const char *fmt, ...)
{
	struct va_format vaf;
	va_list args;
@@ -1241,7 +1221,7 @@ void ath10k_dbg(enum ath10k_debug_mask mask, const char *fmt, ...)
	vaf.va = &args;

	if (ath10k_debug_mask & mask)
		ath10k_printk(KERN_DEBUG, "%pV", &vaf);
		dev_printk(KERN_DEBUG, ar->dev, "%pV", &vaf);

	trace_ath10k_log_dbg(mask, &vaf);

@@ -1249,13 +1229,14 @@ void ath10k_dbg(enum ath10k_debug_mask mask, const char *fmt, ...)
}
EXPORT_SYMBOL(ath10k_dbg);

void ath10k_dbg_dump(enum ath10k_debug_mask mask,
void ath10k_dbg_dump(struct ath10k *ar,
		     enum ath10k_debug_mask mask,
		     const char *msg, const char *prefix,
		     const void *buf, size_t len)
{
	if (ath10k_debug_mask & mask) {
		if (msg)
			ath10k_dbg(mask, "%s\n", msg);
			ath10k_dbg(ar, mask, "%s\n", msg);

		print_hex_dump_bytes(prefix, DUMP_PREFIX_OFFSET, buf, len);
	}
+11 −7
Original line number Diff line number Diff line
@@ -39,9 +39,9 @@ enum ath10k_debug_mask {

extern unsigned int ath10k_debug_mask;

__printf(1, 2) int ath10k_info(const char *fmt, ...);
__printf(1, 2) int ath10k_err(const char *fmt, ...);
__printf(1, 2) int ath10k_warn(const char *fmt, ...);
__printf(2, 3) int ath10k_info(struct ath10k *ar, const char *fmt, ...);
__printf(2, 3) int ath10k_err(struct ath10k *ar, const char *fmt, ...);
__printf(2, 3) int ath10k_warn(struct ath10k *ar, const char *fmt, ...);
void ath10k_print_driver_info(struct ath10k *ar);

#ifdef CONFIG_ATH10K_DEBUGFS
@@ -107,20 +107,24 @@ ath10k_debug_get_new_fw_crash_data(struct ath10k *ar)
#endif /* CONFIG_ATH10K_DEBUGFS */

#ifdef CONFIG_ATH10K_DEBUG
__printf(2, 3) void ath10k_dbg(enum ath10k_debug_mask mask,
__printf(3, 4) void ath10k_dbg(struct ath10k *ar,
			       enum ath10k_debug_mask mask,
			       const char *fmt, ...);
void ath10k_dbg_dump(enum ath10k_debug_mask mask,
void ath10k_dbg_dump(struct ath10k *ar,
		     enum ath10k_debug_mask mask,
		     const char *msg, const char *prefix,
		     const void *buf, size_t len);
#else /* CONFIG_ATH10K_DEBUG */

static inline int ath10k_dbg(enum ath10k_debug_mask dbg_mask,
static inline int ath10k_dbg(struct ath10k *ar,
			     enum ath10k_debug_mask dbg_mask,
			     const char *fmt, ...)
{
	return 0;
}

static inline void ath10k_dbg_dump(enum ath10k_debug_mask mask,
static inline void ath10k_dbg_dump(struct ath10k *ar,
				   enum ath10k_debug_mask mask,
				   const char *msg, const char *prefix,
				   const void *buf, size_t len)
{
Loading