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

Commit 283dc27a authored by Mohammed Javid's avatar Mohammed Javid Committed by Gerrit - the friendly Code Review server
Browse files

msm: ipa: gsi: mhi: Couple of code changes



Couple of code changes,

 - Enable IPC logging for MHI driver.
   IPC logging was missed to enable on mhi driver,
   enable it.

 - Configure appropriate polling mode bit for MHI ep.

   A. For MHI --> IPA pipe:
      when resuming due to transition to M0,
      set the polling mode bit to 0. In other cases,
      restore it's value form when you stopped the channel.

   B. For IPA-->MHI pipe:
      Always restore the polling mode bit.

Change-Id: Ibc203e8c9dc8d05107a5eba396c76e29c1646479
Signed-off-by: default avatarMohammed Javid <mjavid@codeaurora.org>
parent ef2f5e61
Loading
Loading
Loading
Loading
+61 −1
Original line number Diff line number Diff line
/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2015-2018, 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
@@ -1742,6 +1742,32 @@ int gsi_alloc_channel(struct gsi_chan_props *props, unsigned long dev_hdl,
}
EXPORT_SYMBOL(gsi_alloc_channel);

static void __gsi_read_channel_scratch(unsigned long chan_hdl,
		union __packed gsi_channel_scratch * val)
{
	uint32_t reg;

	reg = gsi_readl(gsi_ctx->base +
		GSI_EE_n_GSI_CH_k_SCRATCH_0_OFFS(chan_hdl,
			gsi_ctx->per.ee));
	val->data.word1 = reg;

	reg = gsi_readl(gsi_ctx->base +
		GSI_EE_n_GSI_CH_k_SCRATCH_1_OFFS(chan_hdl,
			gsi_ctx->per.ee));
	val->data.word2 = reg;

	reg = gsi_readl(gsi_ctx->base +
		GSI_EE_n_GSI_CH_k_SCRATCH_2_OFFS(chan_hdl,
			gsi_ctx->per.ee));
	val->data.word3 = reg;

	reg = gsi_readl(gsi_ctx->base +
		GSI_EE_n_GSI_CH_k_SCRATCH_3_OFFS(chan_hdl,
			gsi_ctx->per.ee));
	val->data.word4 = reg;
}

static void __gsi_write_channel_scratch(unsigned long chan_hdl,
		union __packed gsi_channel_scratch val)
{
@@ -1802,6 +1828,40 @@ int gsi_write_channel_scratch(unsigned long chan_hdl,
}
EXPORT_SYMBOL(gsi_write_channel_scratch);

int gsi_read_channel_scratch(unsigned long chan_hdl,
	union __packed gsi_channel_scratch * ch_scratch)
{
	struct gsi_chan_ctx *ctx;

	if (!gsi_ctx) {
		pr_err("%s:%d gsi context not allocated\n", __func__, __LINE__);
		return -GSI_STATUS_NODEV;
	}

	if (chan_hdl >= gsi_ctx->max_ch) {
		GSIERR("bad params chan_hdl=%lu\n", chan_hdl);
		return -GSI_STATUS_INVALID_PARAMS;
	}

	if (gsi_ctx->chan[chan_hdl].state != GSI_CHAN_STATE_ALLOCATED &&
		gsi_ctx->chan[chan_hdl].state != GSI_CHAN_STATE_STARTED &&
		gsi_ctx->chan[chan_hdl].state != GSI_CHAN_STATE_STOPPED) {
		GSIERR("bad state %d\n",
				gsi_ctx->chan[chan_hdl].state);
		return -GSI_STATUS_UNSUPPORTED_OP;
	}

	ctx = &gsi_ctx->chan[chan_hdl];

	mutex_lock(&ctx->mlock);
	__gsi_read_channel_scratch(chan_hdl, ch_scratch);
	ctx->restore_scratch = *ch_scratch;
	mutex_unlock(&ctx->mlock);

	return GSI_STATUS_SUCCESS;
}
EXPORT_SYMBOL(gsi_read_channel_scratch);

int gsi_query_channel_db_addr(unsigned long chan_hdl,
		uint32_t *db_addr_wp_lsb, uint32_t *db_addr_wp_msb)
{
+2 −1
Original line number Diff line number Diff line
/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2015-2018, 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
@@ -129,6 +129,7 @@ struct gsi_chan_ctx {
	bool allocated;
	atomic_t poll_mode;
	union __packed gsi_channel_scratch scratch;
	union __packed gsi_channel_scratch restore_scratch;
	struct gsi_chan_stats stats;
	bool enable_dp_stats;
	bool print_dp_stats;
+30 −4
Original line number Diff line number Diff line
/* Copyright (c) 2015, 2017 The Linux Foundation. All rights reserved.
/* Copyright (c) 2015, 2017-2018 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
@@ -21,13 +21,39 @@
#include "../ipa_common_i.h"

#define IPA_MHI_DRV_NAME "ipa_mhi_client"

#define IPA_MHI_DBG(fmt, args...) \
	do { \
		pr_debug(IPA_MHI_DRV_NAME " %s:%d " fmt, \
			__func__, __LINE__, ## args); \
		IPA_IPC_LOGGING(ipa_get_ipc_logbuf(), \
			IPA_MHI_DRV_NAME " %s:%d " fmt, ## args); \
		IPA_IPC_LOGGING(ipa_get_ipc_logbuf_low(), \
			IPA_MHI_DRV_NAME " %s:%d " fmt, ## args); \
	} while (0)

#define IPA_MHI_DBG_LOW(fmt, args...) \
	do { \
		pr_debug(IPA_MHI_DRV_NAME " %s:%d " fmt, \
		 __func__, __LINE__, ## args)
			__func__, __LINE__, ## args); \
		IPA_IPC_LOGGING(ipa_get_ipc_logbuf_low(), \
			IPA_MHI_DRV_NAME " %s:%d " fmt, ## args); \
	} while (0)


#define IPA_MHI_ERR(fmt, args...) \
	pr_err(IPA_MHI_DRV_NAME " %s:%d " fmt, __func__, __LINE__, ## args)
	do { \
		pr_err(IPA_MHI_DRV_NAME " %s:%d " fmt, \
			__func__, __LINE__, ## args); \
		IPA_IPC_LOGGING(ipa_get_ipc_logbuf(), \
				IPA_MHI_DRV_NAME " %s:%d " fmt, ## args); \
		IPA_IPC_LOGGING(ipa_get_ipc_logbuf_low(), \
				IPA_MHI_DRV_NAME " %s:%d " fmt, ## args); \
	} while (0)

#define IPA_MHI_FUNC_ENTRY() \
	IPA_MHI_DBG("ENTRY\n")

#define IPA_MHI_FUNC_EXIT() \
	IPA_MHI_DBG("EXIT\n")

+29 −5
Original line number Diff line number Diff line
/* Copyright (c) 2015-2017 The Linux Foundation. All rights reserved.
/* Copyright (c) 2015-2018 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
@@ -56,9 +56,9 @@


#define IPA_MHI_FUNC_ENTRY() \
	IPA_MHI_DBG_LOW("ENTRY\n")
	IPA_MHI_DBG("ENTRY\n")
#define IPA_MHI_FUNC_EXIT() \
	IPA_MHI_DBG_LOW("EXIT\n")
	IPA_MHI_DBG("EXIT\n")

#define IPA_MHI_MAX_UL_CHANNELS 1
#define IPA_MHI_MAX_DL_CHANNELS 1
@@ -537,6 +537,7 @@ int ipa3_mhi_resume_channels_internal(enum ipa_client_type client,
	int res;
	int ipa_ep_idx;
	struct ipa3_ep_context *ep;
	union __packed gsi_channel_scratch gsi_ch_scratch;

	IPA_MHI_FUNC_ENTRY();

@@ -551,11 +552,34 @@ int ipa3_mhi_resume_channels_internal(enum ipa_client_type client,
		/*
		 * set polling mode bit to DB mode before
		 * resuming the channel
		 *
		 * For MHI-->IPA pipes:
		 * when resuming due to transition to M0,
		 * set the polling mode bit to 0.
		 * In other cases, restore it's value form
		 * when you stopped the channel.
		 * Here, after successful resume client move to M0 state.
		 * So, by default setting polling mode bit to 0.
		 *
		 * For IPA-->MHI pipe:
		 * always restore the polling mode bit.
		 */

		res = gsi_read_channel_scratch(
			ep->gsi_chan_hdl, &gsi_ch_scratch);
		if (res) {
			IPA_MHI_ERR("Read ch scratch fail %d\n"
				, res);
			return res;
		}

		if (IPA_CLIENT_IS_PROD(client))
			gsi_ch_scratch.mhi.polling_mode = false;

		res = gsi_write_channel_scratch(
			ep->gsi_chan_hdl, ch_scratch);
			ep->gsi_chan_hdl, gsi_ch_scratch);
		if (res) {
			IPA_MHI_ERR("write ch scratch fail %d\n"
			IPA_MHI_ERR("Write ch scratch fail %d\n"
				, res);
			return res;
		}
+20 −1
Original line number Diff line number Diff line
/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2015-2018, 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
@@ -835,6 +835,18 @@ int gsi_alloc_channel(struct gsi_chan_props *props, unsigned long dev_hdl,
int gsi_write_channel_scratch(unsigned long chan_hdl,
		union __packed gsi_channel_scratch val);

/**
 * gsi_read_channel_scratch - Peripheral should call this function to
 * read the scratch area of the channel context
 *
 * @chan_hdl:  Client handle previously obtained from
 *             gsi_alloc_channel
 *
 * @Return gsi_status
 */
int gsi_read_channel_scratch(unsigned long chan_hdl,
		union __packed gsi_channel_scratch *ch_scratch);

/**
 * gsi_start_channel - Peripheral should call this function to
 * start a channel i.e put into running state
@@ -1093,6 +1105,7 @@ int gsi_halt_channel_ee(unsigned int chan_idx, unsigned int ee, int *code);
 * gsi_alloc_channel (for as many channels as needed; channels can have
 * no event ring, an exclusive event ring or a shared event ring)
 * gsi_write_channel_scratch
 * gsi_read_channel_scratch
 * gsi_start_channel
 * gsi_queue_xfer/gsi_start_xfer
 * gsi_config_channel_mode/gsi_poll_channel (if clients wants to poll on
@@ -1177,6 +1190,12 @@ static inline int gsi_write_channel_scratch(unsigned long chan_hdl,
	return -GSI_STATUS_UNSUPPORTED_OP;
}

static inline int gsi_read_channel_scratch(unsigned long chan_hdl,
		union __packed gsi_channel_scratch *ch_scratch)
{
	return -GSI_STATUS_UNSUPPORTED_OP;
}

static inline int gsi_start_channel(unsigned long chan_hdl)
{
	return -GSI_STATUS_UNSUPPORTED_OP;