.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */ |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright 2015-2016 Freescale Semiconductor, Inc. |
---|
3 | 4 | * Copyright 2017 NXP |
---|
4 | | - * |
---|
5 | | - * Redistribution and use in source and binary forms, with or without |
---|
6 | | - * modification, are permitted provided that the following conditions are met: |
---|
7 | | - * * Redistributions of source code must retain the above copyright |
---|
8 | | - * notice, this list of conditions and the following disclaimer. |
---|
9 | | - * * Redistributions in binary form must reproduce the above copyright |
---|
10 | | - * notice, this list of conditions and the following disclaimer in the |
---|
11 | | - * documentation and/or other materials provided with the distribution. |
---|
12 | | - * * Neither the names of the above-listed copyright holders nor the |
---|
13 | | - * names of any contributors may be used to endorse or promote products |
---|
14 | | - * derived from this software without specific prior written permission. |
---|
15 | | - * |
---|
16 | | - * |
---|
17 | | - * ALTERNATIVELY, this software may be distributed under the terms of the |
---|
18 | | - * GNU General Public License ("GPL") as published by the Free Software |
---|
19 | | - * Foundation, either version 2 of that License or (at your option) any |
---|
20 | | - * later version. |
---|
21 | | - * |
---|
22 | | - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
23 | | - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
24 | | - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
25 | | - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE |
---|
26 | | - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
27 | | - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
28 | | - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
29 | | - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
30 | | - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
31 | | - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
---|
32 | | - * POSSIBILITY OF SUCH DAMAGE. |
---|
33 | 5 | */ |
---|
34 | 6 | |
---|
35 | 7 | #ifndef _SG_SW_QM2_H_ |
---|
.. | .. |
---|
53 | 25 | * but does not have final bit; instead, returns last entry |
---|
54 | 26 | */ |
---|
55 | 27 | static inline struct dpaa2_sg_entry * |
---|
56 | | -sg_to_qm_sg(struct scatterlist *sg, int sg_count, |
---|
| 28 | +sg_to_qm_sg(struct scatterlist *sg, int len, |
---|
57 | 29 | struct dpaa2_sg_entry *qm_sg_ptr, u16 offset) |
---|
58 | 30 | { |
---|
59 | | - while (sg_count && sg) { |
---|
60 | | - dma_to_qm_sg_one(qm_sg_ptr, sg_dma_address(sg), |
---|
61 | | - sg_dma_len(sg), offset); |
---|
| 31 | + int ent_len; |
---|
| 32 | + |
---|
| 33 | + while (len) { |
---|
| 34 | + ent_len = min_t(int, sg_dma_len(sg), len); |
---|
| 35 | + |
---|
| 36 | + dma_to_qm_sg_one(qm_sg_ptr, sg_dma_address(sg), ent_len, |
---|
| 37 | + offset); |
---|
62 | 38 | qm_sg_ptr++; |
---|
63 | 39 | sg = sg_next(sg); |
---|
64 | | - sg_count--; |
---|
| 40 | + len -= ent_len; |
---|
65 | 41 | } |
---|
66 | 42 | return qm_sg_ptr - 1; |
---|
67 | 43 | } |
---|
.. | .. |
---|
70 | 46 | * convert scatterlist to h/w link table format |
---|
71 | 47 | * scatterlist must have been previously dma mapped |
---|
72 | 48 | */ |
---|
73 | | -static inline void sg_to_qm_sg_last(struct scatterlist *sg, int sg_count, |
---|
| 49 | +static inline void sg_to_qm_sg_last(struct scatterlist *sg, int len, |
---|
74 | 50 | struct dpaa2_sg_entry *qm_sg_ptr, |
---|
75 | 51 | u16 offset) |
---|
76 | 52 | { |
---|
77 | | - qm_sg_ptr = sg_to_qm_sg(sg, sg_count, qm_sg_ptr, offset); |
---|
| 53 | + qm_sg_ptr = sg_to_qm_sg(sg, len, qm_sg_ptr, offset); |
---|
78 | 54 | dpaa2_sg_set_final(qm_sg_ptr, true); |
---|
79 | 55 | } |
---|
80 | 56 | |
---|