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

Commit 03e4fd22 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: ipa3: Added retry logic if memory allocate fails" into msm-4.14

parents f22faadc 93b66a8a
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -319,10 +319,12 @@ int ipa3_send(struct ipa3_sys_context *sys,

	for (i = 0; i < num_desc; i++) {
		tx_pkt = kmem_cache_zalloc(ipa3_ctx->tx_pkt_wrapper_cache,
					   mem_flag);
		if (!tx_pkt)
					   GFP_ATOMIC);
		if (!tx_pkt) {
			IPAERR("failed to alloc tx wrapper\n");
			result = -ENOMEM;
			goto failure;

		}
		INIT_LIST_HEAD(&tx_pkt->link);

		if (i == 0) {
@@ -336,6 +338,7 @@ int ipa3_send(struct ipa3_sys_context *sys,
			if (ipa_populate_tag_field(&desc[i], tx_pkt,
				&tag_pyld_ret)) {
				IPAERR("Failed to populate tag field\n");
				result = -EFAULT;
				goto failure_dma_map;
			}
		}
@@ -375,6 +378,7 @@ int ipa3_send(struct ipa3_sys_context *sys,
		}
		if (dma_mapping_error(ipa3_ctx->pdev, tx_pkt->mem.phys_base)) {
			IPAERR("failed to do dma map.\n");
			result = -EFAULT;
			goto failure_dma_map;
		}

@@ -421,6 +425,7 @@ int ipa3_send(struct ipa3_sys_context *sys,
			gsi_xfer, true);
	if (result != GSI_STATUS_SUCCESS) {
		IPAERR("GSI xfer failed.\n");
		result = -EFAULT;
		goto failure;
	}

@@ -472,7 +477,7 @@ int ipa3_send(struct ipa3_sys_context *sys,
	}

	spin_unlock_bh(&sys->spinlock);
	return -EFAULT;
	return result;
}

/**
+17 −1
Original line number Diff line number Diff line
@@ -4151,6 +4151,9 @@ static void ipa3_tag_free_skb(void *user1, int user2)
}

#define REQUIRED_TAG_PROCESS_DESCRIPTORS 4
#define MAX_RETRY_ALLOC 10
#define ALLOC_MIN_SLEEP_RX 100000
#define ALLOC_MAX_SLEEP_RX 200000

/* ipa3_tag_process() - Initiates a tag process. Incorporates the input
 * descriptors
@@ -4178,6 +4181,7 @@ int ipa3_tag_process(struct ipa3_desc desc[],
	int res;
	struct ipa3_tag_completion *comp;
	int ep_idx;
	u32 retry_cnt = 0;

	/* Not enough room for the required descriptors for the tag process */
	if (IPA_TAG_MAX_DESC - descs_num < REQUIRED_TAG_PROCESS_DESCRIPTORS) {
@@ -4283,10 +4287,22 @@ int ipa3_tag_process(struct ipa3_desc desc[],
	tag_desc[desc_idx].callback = ipa3_tag_free_skb;
	tag_desc[desc_idx].user1 = dummy_skb;
	desc_idx++;

retry_alloc:
	/* send all descriptors to IPA with single EOT */
	res = ipa3_send(sys, desc_idx, tag_desc, true);
	if (res) {
		if (res == -ENOMEM) {
			if (retry_cnt < MAX_RETRY_ALLOC) {
				IPADBG(
				"failed to alloc memory retry cnt = %d\n",
					retry_cnt);
				retry_cnt++;
				usleep_range(ALLOC_MIN_SLEEP_RX,
					ALLOC_MAX_SLEEP_RX);
				goto retry_alloc;
			}

		}
		IPAERR("failed to send TAG packets %d\n", res);
		res = -ENOMEM;
		goto fail_free_skb;