Merge "msm: ipa3: fix hdr offset issue"

This commit is contained in:
Linux Build Service Account 2018-08-07 15:24:06 -07:00 committed by Gerrit - the friendly Code Review server
commit 74482c64af
2 changed files with 76 additions and 13 deletions

View file

@ -1249,7 +1249,8 @@ int ipa2_reset_hdr(bool user_only)
struct ipa_hdr_offset_entry *off_next; struct ipa_hdr_offset_entry *off_next;
struct ipa_hdr_proc_ctx_offset_entry *ctx_off_entry; struct ipa_hdr_proc_ctx_offset_entry *ctx_off_entry;
struct ipa_hdr_proc_ctx_offset_entry *ctx_off_next; struct ipa_hdr_proc_ctx_offset_entry *ctx_off_next;
int i; int i, end = 0;
bool user_rule = false;
/* /*
* issue a reset on the routing module since routing rules point to * issue a reset on the routing module since routing rules point to
@ -1287,6 +1288,9 @@ int ipa2_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(ipa_ctx->pdev, dma_unmap_single(ipa_ctx->pdev,
@ -1296,6 +1300,7 @@ int ipa2_reset_hdr(bool user_only)
entry->proc_ctx = NULL; entry->proc_ctx = NULL;
} }
list_del(&entry->link); list_del(&entry->link);
ipa_ctx->hdr_tbl.hdr_cnt--;
entry->ref_cnt = 0; entry->ref_cnt = 0;
entry->cookie = 0; entry->cookie = 0;
@ -1321,6 +1326,13 @@ int ipa2_reset_hdr(bool user_only)
list_del(&off_entry->link); list_del(&off_entry->link);
kmem_cache_free(ipa_ctx->hdr_offset_cache, kmem_cache_free(ipa_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,
@ -1335,11 +1347,15 @@ int ipa2_reset_hdr(bool user_only)
} }
} }
} }
/* there is one header of size 8 */
ipa_ctx->hdr_tbl.end = 8;
ipa_ctx->hdr_tbl.hdr_cnt = 1;
IPADBG("hdr_tbl.end = %d\n", end);
if (user_rule) {
ipa_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,
@ -1352,9 +1368,13 @@ int ipa2_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) {
list_del(&ctx_entry->link); list_del(&ctx_entry->link);
ipa_ctx->hdr_proc_ctx_tbl.proc_ctx_cnt--;
ctx_entry->ref_cnt = 0; ctx_entry->ref_cnt = 0;
ctx_entry->cookie = 0; ctx_entry->cookie = 0;
@ -1375,6 +1395,14 @@ int ipa2_reset_hdr(bool user_only)
kmem_cache_free( kmem_cache_free(
ipa_ctx->hdr_proc_ctx_offset_cache, ipa_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,
@ -1390,8 +1418,12 @@ int ipa2_reset_hdr(bool user_only)
} }
} }
} }
ipa_ctx->hdr_proc_ctx_tbl.end = 0;
ipa_ctx->hdr_proc_ctx_tbl.proc_ctx_cnt = 0; IPADBG("hdr_proc_tbl.end = %d\n", end);
if (user_rule) {
ipa_ctx->hdr_proc_ctx_tbl.end = end;
IPADBG("hdr_proc_tbl.end = %d\n", end);
}
mutex_unlock(&ipa_ctx->lock); mutex_unlock(&ipa_ctx->lock);
return 0; return 0;

View file

@ -654,7 +654,6 @@ static int __ipa3_del_hdr_proc_ctx(u32 proc_ctx_hdl,
return 0; return 0;
} }
int __ipa3_del_hdr(u32 hdr_hdl, bool by_user) int __ipa3_del_hdr(u32 hdr_hdl, bool by_user)
{ {
struct ipa3_hdr_entry *entry; struct ipa3_hdr_entry *entry;
@ -994,7 +993,8 @@ 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; int i, end = 0;
bool user_rule = false;
/* /*
* issue a reset on the routing module since routing rules point to * issue a reset on the routing module since routing rules point to
@ -1032,6 +1032,9 @@ 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,
@ -1041,6 +1044,7 @@ int ipa3_reset_hdr(bool user_only)
entry->proc_ctx = NULL; entry->proc_ctx = NULL;
} }
list_del(&entry->link); list_del(&entry->link);
ipa3_ctx->hdr_tbl.hdr_cnt--;
entry->ref_cnt = 0; entry->ref_cnt = 0;
entry->cookie = 0; entry->cookie = 0;
@ -1066,6 +1070,13 @@ int ipa3_reset_hdr(bool user_only)
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,
@ -1080,11 +1091,15 @@ int ipa3_reset_hdr(bool user_only)
} }
} }
} }
/* 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,
@ -1097,9 +1112,13 @@ 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) {
list_del(&ctx_entry->link); list_del(&ctx_entry->link);
ipa3_ctx->hdr_proc_ctx_tbl.proc_ctx_cnt--;
ctx_entry->ref_cnt = 0; ctx_entry->ref_cnt = 0;
ctx_entry->cookie = 0; ctx_entry->cookie = 0;
@ -1120,6 +1139,14 @@ int ipa3_reset_hdr(bool user_only)
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,
@ -1135,8 +1162,12 @@ int ipa3_reset_hdr(bool user_only)
} }
} }
} }
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);
return 0; return 0;