Skip to content

Commit ee415d7

Browse files
maorgottliebjgunthorpe
authored andcommitted
tools/testing/scatterlist: Fix test to compile and run
Add missing define of ALIGN_DOWN to make the test build and run. In addition, __sg_alloc_table_from_pages now support unaligned maximum segment, so adapt the test result accordingly. Fixes: 07da122 ("lib/scatterlist: Add support in dynamic allocation of SG table from pages") Link: https://lore.kernel.org/r/20201115120623.139113-1-leon@kernel.org Signed-off-by: Maor Gottlieb <maorg@nvidia.com> Signed-off-by: Leon Romanovsky <leonro@nvidia.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent dabbd6a commit ee415d7

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

tools/testing/scatterlist/linux/mm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ typedef unsigned long dma_addr_t;
3333
#define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1)
3434
#define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
3535
#define ALIGN(x, a) __ALIGN_KERNEL((x), (a))
36+
#define ALIGN_DOWN(x, a) __ALIGN_KERNEL((x) - ((a) - 1), (a))
3637

3738
#define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)
3839

tools/testing/scatterlist/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ int main(void)
5252
{
5353
const unsigned int sgmax = SCATTERLIST_MAX_SEGMENT;
5454
struct test *test, tests[] = {
55-
{ -EINVAL, 1, pfn(0), PAGE_SIZE, PAGE_SIZE + 1, 1 },
5655
{ -EINVAL, 1, pfn(0), PAGE_SIZE, 0, 1 },
57-
{ -EINVAL, 1, pfn(0), PAGE_SIZE, sgmax + 1, 1 },
56+
{ 0, 1, pfn(0), PAGE_SIZE, PAGE_SIZE + 1, 1 },
57+
{ 0, 1, pfn(0), PAGE_SIZE, sgmax + 1, 1 },
5858
{ 0, 1, pfn(0), PAGE_SIZE, sgmax, 1 },
5959
{ 0, 1, pfn(0), 1, sgmax, 1 },
6060
{ 0, 2, pfn(0, 1), 2 * PAGE_SIZE, sgmax, 1 },

0 commit comments

Comments
 (0)