2020-07-19 07:25:21 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
|
2007-03-05 00:15:11 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2007 Cisco Systems. All rights reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef IB_UMEM_H
|
|
|
|
#define IB_UMEM_H
|
|
|
|
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/scatterlist.h>
|
Detach sched.h from mm.h
First thing mm.h does is including sched.h solely for can_do_mlock() inline
function which has "current" dereference inside. By dealing with can_do_mlock()
mm.h can be detached from sched.h which is good. See below, why.
This patch
a) removes unconditional inclusion of sched.h from mm.h
b) makes can_do_mlock() normal function in mm/mlock.c
c) exports can_do_mlock() to not break compilation
d) adds sched.h inclusions back to files that were getting it indirectly.
e) adds less bloated headers to some files (asm/signal.h, jiffies.h) that were
getting them indirectly
Net result is:
a) mm.h users would get less code to open, read, preprocess, parse, ... if
they don't need sched.h
b) sched.h stops being dependency for significant number of files:
on x86_64 allmodconfig touching sched.h results in recompile of 4083 files,
after patch it's only 3744 (-8.3%).
Cross-compile tested on
all arm defconfigs, all mips defconfigs, all powerpc defconfigs,
alpha alpha-up
arm
i386 i386-up i386-defconfig i386-allnoconfig
ia64 ia64-up
m68k
mips
parisc parisc-up
powerpc powerpc-up
s390 s390-up
sparc sparc-up
sparc64 sparc64-up
um-x86_64
x86_64 x86_64-up x86_64-defconfig x86_64-allnoconfig
as well as my two usual configs.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-05-20 21:22:52 +00:00
|
|
|
#include <linux/workqueue.h>
|
2019-01-09 09:15:16 +00:00
|
|
|
#include <rdma/ib_verbs.h>
|
2007-03-05 00:15:11 +00:00
|
|
|
|
|
|
|
struct ib_ucontext;
|
2014-12-11 15:04:17 +00:00
|
|
|
struct ib_umem_odp;
|
2007-03-05 00:15:11 +00:00
|
|
|
|
|
|
|
struct ib_umem {
|
2019-08-06 23:15:44 +00:00
|
|
|
struct ib_device *ibdev;
|
2018-09-16 17:44:45 +00:00
|
|
|
struct mm_struct *owning_mm;
|
2020-09-04 22:41:47 +00:00
|
|
|
u64 iova;
|
2007-03-05 00:15:11 +00:00
|
|
|
size_t length;
|
2014-12-11 15:04:12 +00:00
|
|
|
unsigned long address;
|
2018-09-16 17:48:06 +00:00
|
|
|
u32 writable : 1;
|
|
|
|
u32 is_odp : 1;
|
2007-04-19 03:20:28 +00:00
|
|
|
struct work_struct work;
|
2014-01-28 11:40:15 +00:00
|
|
|
struct sg_table sg_head;
|
|
|
|
int nmap;
|
2019-04-02 19:52:52 +00:00
|
|
|
unsigned int sg_nents;
|
2007-03-05 00:15:11 +00:00
|
|
|
};
|
|
|
|
|
2014-12-11 15:04:12 +00:00
|
|
|
/* Returns the offset of the umem start relative to the first page. */
|
|
|
|
static inline int ib_umem_offset(struct ib_umem *umem)
|
|
|
|
{
|
2019-05-20 06:05:25 +00:00
|
|
|
return umem->address & ~PAGE_MASK;
|
2014-12-11 15:04:12 +00:00
|
|
|
}
|
|
|
|
|
2020-09-04 22:41:47 +00:00
|
|
|
static inline size_t ib_umem_num_dma_blocks(struct ib_umem *umem,
|
|
|
|
unsigned long pgsz)
|
|
|
|
{
|
|
|
|
return (size_t)((ALIGN(umem->iova + umem->length, pgsz) -
|
|
|
|
ALIGN_DOWN(umem->iova, pgsz))) /
|
|
|
|
pgsz;
|
|
|
|
}
|
|
|
|
|
2014-12-11 15:04:12 +00:00
|
|
|
static inline size_t ib_umem_num_pages(struct ib_umem *umem)
|
|
|
|
{
|
2020-09-04 22:41:47 +00:00
|
|
|
return ib_umem_num_dma_blocks(umem, PAGE_SIZE);
|
2014-12-11 15:04:12 +00:00
|
|
|
}
|
|
|
|
|
2020-09-04 22:41:45 +00:00
|
|
|
static inline void __rdma_umem_block_iter_start(struct ib_block_iter *biter,
|
|
|
|
struct ib_umem *umem,
|
|
|
|
unsigned long pgsz)
|
|
|
|
{
|
|
|
|
__rdma_block_iter_start(biter, umem->sg_head.sgl, umem->nmap, pgsz);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* rdma_umem_for_each_dma_block - iterate over contiguous DMA blocks of the umem
|
|
|
|
* @umem: umem to iterate over
|
|
|
|
* @pgsz: Page size to split the list into
|
|
|
|
*
|
|
|
|
* pgsz must be <= PAGE_SIZE or computed by ib_umem_find_best_pgsz(). The
|
|
|
|
* returned DMA blocks will be aligned to pgsz and span the range:
|
|
|
|
* ALIGN_DOWN(umem->address, pgsz) to ALIGN(umem->address + umem->length, pgsz)
|
2020-09-04 22:41:47 +00:00
|
|
|
*
|
|
|
|
* Performs exactly ib_umem_num_dma_blocks() iterations.
|
2020-09-04 22:41:45 +00:00
|
|
|
*/
|
|
|
|
#define rdma_umem_for_each_dma_block(umem, biter, pgsz) \
|
|
|
|
for (__rdma_umem_block_iter_start(biter, umem, pgsz); \
|
|
|
|
__rdma_block_iter_next(biter);)
|
|
|
|
|
2007-03-05 00:15:11 +00:00
|
|
|
#ifdef CONFIG_INFINIBAND_USER_MEM
|
|
|
|
|
2020-01-15 12:43:31 +00:00
|
|
|
struct ib_umem *ib_umem_get(struct ib_device *device, unsigned long addr,
|
2019-11-13 07:32:14 +00:00
|
|
|
size_t size, int access);
|
2007-03-05 00:15:11 +00:00
|
|
|
void ib_umem_release(struct ib_umem *umem);
|
2014-12-11 15:04:13 +00:00
|
|
|
int ib_umem_copy_from(void *dst, struct ib_umem *umem, size_t offset,
|
|
|
|
size_t length);
|
2019-05-06 13:53:32 +00:00
|
|
|
unsigned long ib_umem_find_best_pgsz(struct ib_umem *umem,
|
|
|
|
unsigned long pgsz_bitmap,
|
|
|
|
unsigned long virt);
|
2007-03-05 00:15:11 +00:00
|
|
|
|
|
|
|
#else /* CONFIG_INFINIBAND_USER_MEM */
|
|
|
|
|
|
|
|
#include <linux/err.h>
|
|
|
|
|
2020-01-15 12:43:31 +00:00
|
|
|
static inline struct ib_umem *ib_umem_get(struct ib_device *device,
|
2007-03-05 00:15:11 +00:00
|
|
|
unsigned long addr, size_t size,
|
2019-11-13 07:32:14 +00:00
|
|
|
int access)
|
2019-01-09 09:15:16 +00:00
|
|
|
{
|
2007-03-05 00:15:11 +00:00
|
|
|
return ERR_PTR(-EINVAL);
|
|
|
|
}
|
|
|
|
static inline void ib_umem_release(struct ib_umem *umem) { }
|
2014-12-11 15:04:14 +00:00
|
|
|
static inline int ib_umem_copy_from(void *dst, struct ib_umem *umem, size_t offset,
|
|
|
|
size_t length) {
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2020-08-25 18:17:08 +00:00
|
|
|
static inline unsigned long ib_umem_find_best_pgsz(struct ib_umem *umem,
|
|
|
|
unsigned long pgsz_bitmap,
|
|
|
|
unsigned long virt)
|
|
|
|
{
|
|
|
|
return 0;
|
2019-05-06 13:53:32 +00:00
|
|
|
}
|
|
|
|
|
2007-03-05 00:15:11 +00:00
|
|
|
#endif /* CONFIG_INFINIBAND_USER_MEM */
|
|
|
|
|
|
|
|
#endif /* IB_UMEM_H */
|