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

Commit 4fef11ac authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm:ipa3: fix the header table gap issue"

parents ba632bd2 128bb1d7
Loading
Loading
Loading
Loading
+39 −67
Original line number Original line Diff line number Diff line
@@ -998,8 +998,9 @@ int ipa3_reset_hdr(bool user_only)
	struct ipa_hdr_offset_entry *off_next;
	struct ipa_hdr_offset_entry *off_next;
	struct ipa3_hdr_proc_ctx_offset_entry *ctx_off_entry;
	struct ipa3_hdr_proc_ctx_offset_entry *ctx_off_entry;
	struct ipa3_hdr_proc_ctx_offset_entry *ctx_off_next;
	struct ipa3_hdr_proc_ctx_offset_entry *ctx_off_next;
	int i, end = 0;
	struct ipa3_hdr_tbl *htbl = &ipa3_ctx->hdr_tbl;
	bool user_rule = false;
	struct ipa3_hdr_proc_ctx_tbl *htbl_proc = &ipa3_ctx->hdr_proc_ctx_tbl;
	int i;


	/*
	/*
	 * issue a reset on the routing module since routing rules point to
	 * issue a reset on the routing module since routing rules point to
@@ -1037,9 +1038,6 @@ int ipa3_reset_hdr(bool user_only)
			return -EFAULT;
			return -EFAULT;
		}
		}


		if (entry->ipacm_installed)
			user_rule = true;

		if (!user_only || entry->ipacm_installed) {
		if (!user_only || entry->ipacm_installed) {
			if (entry->is_hdr_proc_ctx) {
			if (entry->is_hdr_proc_ctx) {
				dma_unmap_single(ipa3_ctx->pdev,
				dma_unmap_single(ipa3_ctx->pdev,
@@ -1047,9 +1045,15 @@ int ipa3_reset_hdr(bool user_only)
					entry->hdr_len,
					entry->hdr_len,
					DMA_TO_DEVICE);
					DMA_TO_DEVICE);
				entry->proc_ctx = NULL;
				entry->proc_ctx = NULL;
			} else {
				/* move the offset entry to free list */
				entry->offset_entry->ipacm_installed = 0;
				list_move(&entry->offset_entry->link,
				&htbl->head_free_offset_list[
					entry->offset_entry->bin]);
			}
			}
			list_del(&entry->link);
			list_del(&entry->link);
			ipa3_ctx->hdr_tbl.hdr_cnt--;
			htbl->hdr_cnt--;
			entry->ref_cnt = 0;
			entry->ref_cnt = 0;
			entry->cookie = 0;
			entry->cookie = 0;


@@ -1058,53 +1062,37 @@ int ipa3_reset_hdr(bool user_only)
			kmem_cache_free(ipa3_ctx->hdr_cache, entry);
			kmem_cache_free(ipa3_ctx->hdr_cache, entry);
		}
		}
	}
	}

	/* only clean up offset_list and free_offset_list on global reset */
	if (!user_only) {
		for (i = 0; i < IPA_HDR_BIN_MAX; i++) {
		for (i = 0; i < IPA_HDR_BIN_MAX; i++) {
			list_for_each_entry_safe(off_entry, off_next,
			list_for_each_entry_safe(off_entry, off_next,
					 &ipa3_ctx->hdr_tbl.head_offset_list[i],
					 &ipa3_ctx->hdr_tbl.head_offset_list[i],
					 link) {
					 link) {

				/**
			/*
				 * do not remove the default exception
			 * do not remove the default exception header which is
				 * header which is at offset 0
			 * at offset 0
				 */
				 */
				if (off_entry->offset == 0)
				if (off_entry->offset == 0)
					continue;
					continue;

			if (!user_only ||
					off_entry->ipacm_installed) {
				list_del(&off_entry->link);
				list_del(&off_entry->link);
				kmem_cache_free(ipa3_ctx->hdr_offset_cache,
				kmem_cache_free(ipa3_ctx->hdr_offset_cache,
					off_entry);
					off_entry);
			} else {
				if (off_entry->offset +
					ipa_hdr_bin_sz[off_entry->bin] > end) {
					end = off_entry->offset +
						ipa_hdr_bin_sz[off_entry->bin];
					IPADBG("replace end = %d\n", end);
				}
			}
			}
			}
			list_for_each_entry_safe(off_entry, off_next,
			list_for_each_entry_safe(off_entry, off_next,
				&ipa3_ctx->hdr_tbl.head_free_offset_list[i],
				&ipa3_ctx->hdr_tbl.head_free_offset_list[i],
				link) {
				link) {

			if (!user_only ||
					off_entry->ipacm_installed) {
				list_del(&off_entry->link);
				list_del(&off_entry->link);
				kmem_cache_free(ipa3_ctx->hdr_offset_cache,
				kmem_cache_free(ipa3_ctx->hdr_offset_cache,
					off_entry);
					off_entry);
			}
			}
		}
		}
		/* there is one header of size 8 */
		ipa3_ctx->hdr_tbl.end = 8;
		ipa3_ctx->hdr_tbl.hdr_cnt = 1;
	}
	}


	IPADBG("hdr_tbl.end = %d\n", end);
	if (user_rule) {
		ipa3_ctx->hdr_tbl.end = end;
		IPADBG("hdr_tbl.end = %d\n", end);
	}
	IPADBG("reset hdr proc ctx\n");
	IPADBG("reset hdr proc ctx\n");
	user_rule = false;
	end = 0;
	list_for_each_entry_safe(
	list_for_each_entry_safe(
		ctx_entry,
		ctx_entry,
		ctx_next,
		ctx_next,
@@ -1117,13 +1105,14 @@ int ipa3_reset_hdr(bool user_only)
			return -EFAULT;
			return -EFAULT;
		}
		}


		if (entry->ipacm_installed)
			user_rule = true;

		if (!user_only ||
		if (!user_only ||
				ctx_entry->ipacm_installed) {
				ctx_entry->ipacm_installed) {
			/* move the offset entry to appropriate free list */
			list_move(&ctx_entry->offset_entry->link,
				&htbl_proc->head_free_offset_list[
					ctx_entry->offset_entry->bin]);
			list_del(&ctx_entry->link);
			list_del(&ctx_entry->link);
			ipa3_ctx->hdr_proc_ctx_tbl.proc_ctx_cnt--;
			htbl_proc->proc_ctx_cnt--;
			ctx_entry->ref_cnt = 0;
			ctx_entry->ref_cnt = 0;
			ctx_entry->cookie = 0;
			ctx_entry->cookie = 0;


@@ -1133,45 +1122,28 @@ int ipa3_reset_hdr(bool user_only)
				ctx_entry);
				ctx_entry);
		}
		}
	}
	}
	/* only clean up offset_list and free_offset_list on global reset */
	if (!user_only) {
		for (i = 0; i < IPA_HDR_PROC_CTX_BIN_MAX; i++) {
		for (i = 0; i < IPA_HDR_PROC_CTX_BIN_MAX; i++) {
			list_for_each_entry_safe(ctx_off_entry, ctx_off_next,
			list_for_each_entry_safe(ctx_off_entry, ctx_off_next,
				&ipa3_ctx->hdr_proc_ctx_tbl.head_offset_list[i],
				&ipa3_ctx->hdr_proc_ctx_tbl.head_offset_list[i],
				link) {
				link) {

			if (!user_only ||
					ctx_off_entry->ipacm_installed) {
				list_del(&ctx_off_entry->link);
				list_del(&ctx_off_entry->link);
				kmem_cache_free(
				kmem_cache_free(
					ipa3_ctx->hdr_proc_ctx_offset_cache,
					ipa3_ctx->hdr_proc_ctx_offset_cache,
					ctx_off_entry);
					ctx_off_entry);
			} else {
				if (ctx_off_entry->offset +
					ipa_hdr_bin_sz[ctx_off_entry->bin]
					> end) {
					end = ctx_off_entry->offset +
					ipa_hdr_bin_sz[ctx_off_entry->bin];
					IPADBG("replace hdr_proc as %d\n", end);
				}
			}
			}
			}
			list_for_each_entry_safe(ctx_off_entry, ctx_off_next,
			list_for_each_entry_safe(ctx_off_entry, ctx_off_next,
			&ipa3_ctx->hdr_proc_ctx_tbl.head_free_offset_list[i],
				&ipa3_ctx->hdr_proc_ctx_tbl.
			link) {
				head_free_offset_list[i], link) {

			if (!user_only ||
					ctx_off_entry->ipacm_installed) {
				list_del(&ctx_off_entry->link);
				list_del(&ctx_off_entry->link);
				kmem_cache_free(
				kmem_cache_free(
					ipa3_ctx->hdr_proc_ctx_offset_cache,
					ipa3_ctx->hdr_proc_ctx_offset_cache,
					ctx_off_entry);
					ctx_off_entry);
			}
			}
		}
		}
	}
		ipa3_ctx->hdr_proc_ctx_tbl.end = 0;

		ipa3_ctx->hdr_proc_ctx_tbl.proc_ctx_cnt = 0;
	IPADBG("hdr_proc_tbl.end = %d\n", end);
	if (user_rule) {
		ipa3_ctx->hdr_proc_ctx_tbl.end = end;
		IPADBG("hdr_proc_tbl.end = %d\n", end);
	}
	}
	mutex_unlock(&ipa3_ctx->lock);
	mutex_unlock(&ipa3_ctx->lock);