From 09b94adf7ea943317faf9e06799ffb5c517ebd74 Mon Sep 17 00:00:00 2001 From: Akshay Pandit Date: Wed, 7 Oct 2020 12:45:46 +0530 Subject: [PATCH] ipa3: Fix to save sgt table info in proper context Sg table tables are not contiguous page due to this while copying total sg table it failing. To avoid this copying the each sg table individually. Acked-by: Akshay Pandit Signed-off-by: Ashok Vuyyuru --- drivers/platform/msm/ipa/ipa_v3/ipa.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa.c b/drivers/platform/msm/ipa/ipa_v3/ipa.c index 4ed805bf37e0..918a037392d5 100644 --- a/drivers/platform/msm/ipa/ipa_v3/ipa.c +++ b/drivers/platform/msm/ipa/ipa_v3/ipa.c @@ -384,6 +384,8 @@ int ipa_smmu_store_sgt(struct sg_table **out_ch_ptr, struct sg_table *in_sgt_ptr) { unsigned int nents; + int i; + struct scatterlist *in_sg, *out_sg; if (in_sgt_ptr != NULL) { *out_ch_ptr = kzalloc(sizeof(struct sg_table), GFP_KERNEL); @@ -401,8 +403,12 @@ int ipa_smmu_store_sgt(struct sg_table **out_ch_ptr, return -ENOMEM; } - memcpy((*out_ch_ptr)->sgl, in_sgt_ptr->sgl, - nents*sizeof((*out_ch_ptr)->sgl)); + out_sg = (*out_ch_ptr)->sgl; + for_each_sg(in_sgt_ptr->sgl, in_sg, in_sgt_ptr->nents, i) { + memcpy(out_sg, in_sg, sizeof(struct scatterlist)); + out_sg++; + } + (*out_ch_ptr)->nents = nents; (*out_ch_ptr)->orig_nents = in_sgt_ptr->orig_nents; }