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

Commit e32a1851 authored by Ashok Vuyyuru's avatar Ashok Vuyyuru Committed by Gerrit - the friendly Code Review server
Browse files

msm: ipa4: initialize the replenish pointer for WAN consumer pipe



When coalescing pipe and WAN consumer pipe are configuring case
using the same replenish pointer as coalescing replenish pointer causing
overriding head_idx/tail_idx values for both pipes. Add changes initialize
the new replenish pointer for WAN consumer pipe.

Change-Id: I4d637ae9fd6a6d95a12bc239fbff9dea5668ff03
Signed-off-by: default avatarAshok Vuyyuru <avuyyuru@codeaurora.org>
parent 8ca6d749
Loading
Loading
Loading
Loading
+74 −14
Original line number Original line Diff line number Diff line
@@ -1091,10 +1091,6 @@ int ipa3_setup_sys_pipe(struct ipa_sys_connect_params *sys_in, u32 *clnt_hdl)
		atomic_set(&ep->sys->repl->pending, 0);
		atomic_set(&ep->sys->repl->pending, 0);
		ep->sys->repl->capacity = ep->sys->rx_pool_sz + 1;
		ep->sys->repl->capacity = ep->sys->rx_pool_sz + 1;


		/*double for wan_coal since it will be shared between 2 pipes */
		if (sys_in->client == IPA_CLIENT_APPS_WAN_COAL_CONS)
			ep->sys->repl->capacity *= 2;

		ep->sys->repl->cache = kcalloc(ep->sys->repl->capacity,
		ep->sys->repl->cache = kcalloc(ep->sys->repl->capacity,
				sizeof(void *), GFP_KERNEL);
				sizeof(void *), GFP_KERNEL);
		if (!ep->sys->repl->cache) {
		if (!ep->sys->repl->cache) {
@@ -1210,6 +1206,7 @@ static int ipa_setup_coal_def_pipe(struct ipa_sys_connect_params *sys_in,
	struct ipa3_ep_context *ep;
	struct ipa3_ep_context *ep;
	int result = -EINVAL;
	int result = -EINVAL;
	int ipa_ep_idx, i;
	int ipa_ep_idx, i;
	char buff[IPA_RESOURCE_NAME_MAX];


	ipa_ep_idx = ipa3_get_ep_mapping(sys_in->client);
	ipa_ep_idx = ipa3_get_ep_mapping(sys_in->client);


@@ -1232,13 +1229,34 @@ static int ipa_setup_coal_def_pipe(struct ipa_sys_connect_params *sys_in,
			IPAERR("failed to sys ctx for client %d\n",
			IPAERR("failed to sys ctx for client %d\n",
				IPA_CLIENT_APPS_WAN_CONS);
				IPA_CLIENT_APPS_WAN_CONS);
			result = -ENOMEM;
			result = -ENOMEM;
			goto fail_wq;
			goto fail_gen;
		}
		}


		ep->sys->ep = ep;
		ep->sys->ep = ep;
		ep->sys->wq = ep_coalescing->sys->wq;
		snprintf(buff, IPA_RESOURCE_NAME_MAX, "ipawq%d",
		ep->sys->repl_wq = ep_coalescing->sys->repl_wq;
				sys_in->client);
		ep->sys->wq = alloc_workqueue(buff,
				WQ_MEM_RECLAIM | WQ_UNBOUND | WQ_SYSFS, 1);

		if (!ep->sys->wq) {
			IPAERR("failed to create wq for client %d\n",
					sys_in->client);
			result = -EFAULT;
			goto fail_wq;
		}

		snprintf(buff, IPA_RESOURCE_NAME_MAX, "iparepwq%d",
				sys_in->client);
		ep->sys->repl_wq = alloc_workqueue(buff,
				WQ_MEM_RECLAIM | WQ_UNBOUND | WQ_SYSFS, 1);
		if (!ep->sys->repl_wq) {
			IPAERR("failed to create rep wq for client %d\n",
					sys_in->client);
			result = -EFAULT;
			goto fail_wq2;
		}


		INIT_LIST_HEAD(&ep->sys->rcycl_list);
		spin_lock_init(&ep->sys->spinlock);
		spin_lock_init(&ep->sys->spinlock);
		hrtimer_init(&ep->sys->db_timer, CLOCK_MONOTONIC,
		hrtimer_init(&ep->sys->db_timer, CLOCK_MONOTONIC,
			HRTIMER_MODE_REL);
			HRTIMER_MODE_REL);
@@ -1253,7 +1271,7 @@ static int ipa_setup_coal_def_pipe(struct ipa_sys_connect_params *sys_in,
		IPAERR("failed to sys ctx for client %d\n",
		IPAERR("failed to sys ctx for client %d\n",
			IPA_CLIENT_APPS_WAN_CONS);
			IPA_CLIENT_APPS_WAN_CONS);
		result = -ENOMEM;
		result = -ENOMEM;
		goto fail_wq;
		goto fail_gen2;
	}
	}


	ep->valid = 1;
	ep->valid = 1;
@@ -1267,17 +1285,17 @@ static int ipa_setup_coal_def_pipe(struct ipa_sys_connect_params *sys_in,
	if (!ep->skip_ep_cfg) {
	if (!ep->skip_ep_cfg) {
		if (ipa3_cfg_ep(ipa_ep_idx, &sys_in->ipa_ep_cfg)) {
		if (ipa3_cfg_ep(ipa_ep_idx, &sys_in->ipa_ep_cfg)) {
			IPAERR("fail to configure EP.\n");
			IPAERR("fail to configure EP.\n");
			goto fail_wq;
			goto fail_gen2;
		}
		}


		if (ep->status.status_en) {
		if (ep->status.status_en) {
			IPAERR("status should be disabled for this EP.\n");
			IPAERR("status should be disabled for this EP.\n");
			goto fail_wq;
			goto fail_gen2;
		}
		}


		if (ipa3_cfg_ep_status(ipa_ep_idx, &ep->status)) {
		if (ipa3_cfg_ep_status(ipa_ep_idx, &ep->status)) {
			IPAERR("fail to configure status of EP.\n");
			IPAERR("fail to configure status of EP.\n");
			goto fail_wq;
			goto fail_gen2;
		}
		}
		IPADBG("ep %d configuration successful\n", ipa_ep_idx);
		IPADBG("ep %d configuration successful\n", ipa_ep_idx);
	} else {
	} else {
@@ -1287,10 +1305,33 @@ static int ipa_setup_coal_def_pipe(struct ipa_sys_connect_params *sys_in,
	result = ipa_gsi_setup_coal_def_channel(sys_in, ep, ep_coalescing);
	result = ipa_gsi_setup_coal_def_channel(sys_in, ep, ep_coalescing);
	if (result) {
	if (result) {
		IPAERR("Failed to setup default coal GSI channel\n");
		IPAERR("Failed to setup default coal GSI channel\n");
		goto fail_wq;
		goto fail_gen2;
	}

	if (ep->sys->repl_hdlr == ipa3_fast_replenish_rx_cache) {
		ep->sys->repl = kzalloc(sizeof(*ep->sys->repl), GFP_KERNEL);
		if (!ep->sys->repl) {
			IPAERR("failed to alloc repl for client %d\n",
					sys_in->client);
			result = -ENOMEM;
			goto fail_gen2;
		}
		atomic_set(&ep->sys->repl->pending, 0);
		ep->sys->repl->capacity = ep->sys->rx_pool_sz + 1;

		ep->sys->repl->cache = kcalloc(ep->sys->repl->capacity,
				sizeof(void *), GFP_KERNEL);
		if (!ep->sys->repl->cache) {
			IPAERR("ep=%d fail to alloc repl cache\n", ipa_ep_idx);
			ep->sys->repl_hdlr = ipa3_replenish_rx_cache;
			ep->sys->repl->capacity = 0;
		} else {
			atomic_set(&ep->sys->repl->head_idx, 0);
			atomic_set(&ep->sys->repl->tail_idx, 0);
			ipa3_wq_repl_rx(&ep->sys->repl_work);
		}
	}
	}


	ep->sys->repl = ep_coalescing->sys->repl;
	ipa3_replenish_rx_cache(ep->sys);
	ipa3_replenish_rx_cache(ep->sys);


	for (i = 0; i < GSI_VEID_MAX; i++)
	for (i = 0; i < GSI_VEID_MAX; i++)
@@ -1302,7 +1343,7 @@ static int ipa_setup_coal_def_pipe(struct ipa_sys_connect_params *sys_in,
	if (result) {
	if (result) {
		IPAERR("enable data path failed res=%d ep=%d.\n", result,
		IPAERR("enable data path failed res=%d ep=%d.\n", result,
			ipa_ep_idx);
			ipa_ep_idx);
		goto fail_wq;
		goto fail_repl;
	}
	}


	result = gsi_start_channel(ep->gsi_chan_hdl);
	result = gsi_start_channel(ep->gsi_chan_hdl);
@@ -1317,6 +1358,14 @@ static int ipa_setup_coal_def_pipe(struct ipa_sys_connect_params *sys_in,
/* the rest of the fails are handled by ipa3_setup_sys_pipe */
/* the rest of the fails are handled by ipa3_setup_sys_pipe */
fail_start_channel:
fail_start_channel:
	ipa3_disable_data_path(ipa_ep_idx);
	ipa3_disable_data_path(ipa_ep_idx);
fail_repl:
	ep->sys->repl_hdlr = ipa3_replenish_rx_cache;
	ep->sys->repl->capacity = 0;
	kfree(ep->sys->repl);
fail_gen2:
	destroy_workqueue(ep->sys->repl_wq);
fail_wq2:
	destroy_workqueue(ep->sys->wq);
fail_wq:
fail_wq:
	kfree(ep->sys);
	kfree(ep->sys);
	memset(&ipa3_ctx->ep[ipa_ep_idx], 0, sizeof(struct ipa3_ep_context));
	memset(&ipa3_ctx->ep[ipa_ep_idx], 0, sizeof(struct ipa3_ep_context));
@@ -1519,6 +1568,17 @@ static int ipa3_teardown_coal_def_pipe(u32 clnt_hdl)
		ipa_assert();
		ipa_assert();
		return result;
		return result;
	}
	}

	if (IPA_CLIENT_IS_CONS(ep->client))
		cancel_delayed_work_sync(&ep->sys->replenish_rx_work);

	flush_workqueue(ep->sys->wq);

	if (ep->sys->repl_wq)
		flush_workqueue(ep->sys->repl_wq);
	if (IPA_CLIENT_IS_CONS(ep->client))
		ipa3_cleanup_rx(ep->sys);

	ep->valid = 0;
	ep->valid = 0;


	IPADBG("client (ep: %d) disconnected\n", clnt_hdl);
	IPADBG("client (ep: %d) disconnected\n", clnt_hdl);