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

Commit 960b3b8e authored by Dhoat Harpal's avatar Dhoat Harpal
Browse files

soc: qcom: glink: Move tx_info allocation in beginning



TX_info is allocated after pop remote intent, this can cause problem
when there is no memory for allocation then glink has to push back the
intent, which again needs memory.

Tx_info allocation is moved before op remote intent.

CRs-Fixed: 2063427
Change-Id: I4f174c4b0143454596ac8f7a1c639c853b98a2ce
Signed-off-by: default avatarDhoat Harpal <hdhoat@codeaurora.org>
parent f59ff970
Loading
Loading
Loading
Loading
+14 −9
Original line number Diff line number Diff line
@@ -2862,7 +2862,7 @@ static int glink_tx_common(void *handle, void *pkt_priv,
	struct channel_ctx *ctx = (struct channel_ctx *)handle;
	uint32_t riid;
	int ret = 0;
	struct glink_core_tx_pkt *tx_info;
	struct glink_core_tx_pkt *tx_info = NULL;
	size_t intent_size;
	bool is_atomic =
		tx_flags & (GLINK_TX_SINGLE_THREADED | GLINK_TX_ATOMIC);
@@ -2877,6 +2877,13 @@ static int glink_tx_common(void *handle, void *pkt_priv,
		return ret;

	rwref_read_get_atomic(&ctx->ch_state_lhb2, is_atomic);
	tx_info = kzalloc(sizeof(struct glink_core_tx_pkt),
				is_atomic ? GFP_ATOMIC : GFP_KERNEL);
	if (!tx_info) {
		GLINK_ERR_CH(ctx, "%s: No memory for allocation\n", __func__);
		ret = -ENOMEM;
		goto glink_tx_common_err;
	}
	if (!(vbuf_provider || pbuf_provider)) {
		ret = -EINVAL;
		goto glink_tx_common_err;
@@ -2996,14 +3003,7 @@ static int glink_tx_common(void *handle, void *pkt_priv,
	GLINK_INFO_PERF_CH(ctx, "%s: R[%u]:%zu data[%p], size[%zu]. TID %u\n",
			__func__, riid, intent_size,
			data ? data : iovec, size, current->pid);
	tx_info = kzalloc(sizeof(struct glink_core_tx_pkt),
				is_atomic ? GFP_ATOMIC : GFP_KERNEL);
	if (!tx_info) {
		GLINK_ERR_CH(ctx, "%s: No memory for allocation\n", __func__);
		ch_push_remote_rx_intent(ctx, intent_size, riid, cookie);
		ret = -ENOMEM;
		goto glink_tx_common_err;
	}

	rwref_lock_init(&tx_info->pkt_ref, glink_tx_pkt_release);
	INIT_LIST_HEAD(&tx_info->list_done);
	INIT_LIST_HEAD(&tx_info->list_node);
@@ -3028,10 +3028,15 @@ static int glink_tx_common(void *handle, void *pkt_priv,
	else
		xprt_schedule_tx(ctx->transport_ptr, ctx, tx_info);

	rwref_read_put(&ctx->ch_state_lhb2);
	glink_put_ch_ctx(ctx, false);
	return ret;

glink_tx_common_err:
	rwref_read_put(&ctx->ch_state_lhb2);
glink_tx_common_err_2:
	glink_put_ch_ctx(ctx, false);
	kfree(tx_info);
	return ret;
}