* [PATCH] lib: scatterlist: Fix to support no mapped sg
@ 2019-04-18 9:50 Zhou Wang
2019-04-19 10:43 ` Robert Jarzmik
0 siblings, 1 reply; 3+ messages in thread
From: Zhou Wang @ 2019-04-18 9:50 UTC (permalink / raw)
To: robert.jarzmik, axboe; +Cc: linux-kernel, linuxarm, Zhou Wang
In function sg_split, the second sg_calculate_split will return -EINVAL
when in_mapped_nents is 0.
Indeed there is no need to do second sg_calculate_split and sg_split_mapped
when in_mapped_nents is 0, as in_mapped_nents indicates no mapped entry in
original sgl.
Signed-off-by: Zhou Wang <wangzhou1@hisilicon.com>
---
lib/sg_split.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/lib/sg_split.c b/lib/sg_split.c
index b063410..d4181c8 100644
--- a/lib/sg_split.c
+++ b/lib/sg_split.c
@@ -178,11 +178,13 @@ int sg_split(struct scatterlist *in, const int in_mapped_nents,
* The order of these 3 calls is important and should be kept.
*/
sg_split_phys(splitters, nb_splits);
- ret = sg_calculate_split(in, in_mapped_nents, nb_splits, skip,
- split_sizes, splitters, true);
- if (ret < 0)
- goto err;
- sg_split_mapped(splitters, nb_splits);
+ if (in_mapped_nents) {
+ ret = sg_calculate_split(in, in_mapped_nents, nb_splits, skip,
+ split_sizes, splitters, true);
+ if (ret < 0)
+ goto err;
+ sg_split_mapped(splitters, nb_splits);
+ }
for (i = 0; i < nb_splits; i++) {
out[i] = splitters[i].out_sg;
--
2.8.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] lib: scatterlist: Fix to support no mapped sg
2019-04-18 9:50 [PATCH] lib: scatterlist: Fix to support no mapped sg Zhou Wang
@ 2019-04-19 10:43 ` Robert Jarzmik
2019-04-20 3:48 ` Zhou Wang
0 siblings, 1 reply; 3+ messages in thread
From: Robert Jarzmik @ 2019-04-19 10:43 UTC (permalink / raw)
To: Zhou Wang; +Cc: axboe, linux-kernel, linuxarm
Zhou Wang <wangzhou1@hisilicon.com> writes:
> In function sg_split, the second sg_calculate_split will return -EINVAL
> when in_mapped_nents is 0.
>
> Indeed there is no need to do second sg_calculate_split and sg_split_mapped
> when in_mapped_nents is 0, as in_mapped_nents indicates no mapped entry in
> original sgl.
>
> Signed-off-by: Zhou Wang <wangzhou1@hisilicon.com>
That's right. May I know what is the usecase which led you to this fix ?
Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>
--
Robert
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] lib: scatterlist: Fix to support no mapped sg
2019-04-19 10:43 ` Robert Jarzmik
@ 2019-04-20 3:48 ` Zhou Wang
0 siblings, 0 replies; 3+ messages in thread
From: Zhou Wang @ 2019-04-20 3:48 UTC (permalink / raw)
To: Robert Jarzmik; +Cc: axboe, linux-kernel, linuxarm
On 2019/4/19 18:43, Robert Jarzmik wrote:
> Zhou Wang <wangzhou1@hisilicon.com> writes:
>
>> In function sg_split, the second sg_calculate_split will return -EINVAL
>> when in_mapped_nents is 0.
>>
>> Indeed there is no need to do second sg_calculate_split and sg_split_mapped
>> when in_mapped_nents is 0, as in_mapped_nents indicates no mapped entry in
>> original sgl.
>>
>> Signed-off-by: Zhou Wang <wangzhou1@hisilicon.com>
> That's right. May I know what is the usecase which led you to this fix ?
I posted a patchset to support HiSilicon compression engine:
https://lkml.org/lkml/2019/1/23/358. As Herber Xu suggested, it should use
new crypto acomp API which uses sgl as data input and output. However, our
hardware can not handle compress head for input/output data, so I need split
input/output sgl firstly which is not mapped sgl.
New version of HiSilicon compression engine driver has not been posted to
community yet. I will do this later.
>
> Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>
Many thanks for your review,
Zhou
>
> --
> Robert
>
> .
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-04-20 3:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-18 9:50 [PATCH] lib: scatterlist: Fix to support no mapped sg Zhou Wang
2019-04-19 10:43 ` Robert Jarzmik
2019-04-20 3:48 ` Zhou Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).