2007-03-05 07:15:11 +07:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2007 Cisco Systems. All rights reserved.
|
|
|
|
*
|
|
|
|
* This software is available to you under a choice of one of two
|
|
|
|
* licenses. You may choose to be licensed under the terms of the GNU
|
|
|
|
* General Public License (GPL) Version 2, available from the file
|
|
|
|
* COPYING in the main directory of this source tree, or the
|
|
|
|
* OpenIB.org BSD license below:
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or
|
|
|
|
* without modification, are permitted provided that the following
|
|
|
|
* conditions are met:
|
|
|
|
*
|
|
|
|
* - Redistributions of source code must retain the above
|
|
|
|
* copyright notice, this list of conditions and the following
|
|
|
|
* disclaimer.
|
|
|
|
*
|
|
|
|
* - Redistributions in binary form must reproduce the above
|
|
|
|
* copyright notice, this list of conditions and the following
|
|
|
|
* disclaimer in the documentation and/or other materials
|
|
|
|
* provided with the distribution.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#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-21 04:22:52 +07:00
|
|
|
#include <linux/workqueue.h>
|
2019-01-09 16:15:16 +07:00
|
|
|
#include <rdma/ib_verbs.h>
|
2007-03-05 07:15:11 +07:00
|
|
|
|
|
|
|
struct ib_ucontext;
|
2014-12-11 22:04:17 +07:00
|
|
|
struct ib_umem_odp;
|
2007-03-05 07:15:11 +07:00
|
|
|
|
|
|
|
struct ib_umem {
|
2019-08-07 06:15:44 +07:00
|
|
|
struct ib_device *ibdev;
|
2018-09-17 00:44:45 +07:00
|
|
|
struct mm_struct *owning_mm;
|
2007-03-05 07:15:11 +07:00
|
|
|
size_t length;
|
2014-12-11 22:04:12 +07:00
|
|
|
unsigned long address;
|
2018-09-17 00:48:06 +07:00
|
|
|
u32 writable : 1;
|
|
|
|
u32 is_odp : 1;
|
2007-04-19 10:20:28 +07:00
|
|
|
struct work_struct work;
|
2014-01-28 18:40:15 +07:00
|
|
|
struct sg_table sg_head;
|
|
|
|
int nmap;
|
2019-04-03 02:52:52 +07:00
|
|
|
unsigned int sg_nents;
|
2007-03-05 07:15:11 +07:00
|
|
|
};
|
|
|
|
|
2014-12-11 22:04:12 +07: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 13:05:25 +07:00
|
|
|
return umem->address & ~PAGE_MASK;
|
2014-12-11 22:04:12 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline size_t ib_umem_num_pages(struct ib_umem *umem)
|
|
|
|
{
|
2019-05-20 13:05:25 +07:00
|
|
|
return (ALIGN(umem->address + umem->length, PAGE_SIZE) -
|
|
|
|
ALIGN_DOWN(umem->address, PAGE_SIZE)) >>
|
|
|
|
PAGE_SHIFT;
|
2014-12-11 22:04:12 +07:00
|
|
|
}
|
|
|
|
|
2007-03-05 07:15:11 +07:00
|
|
|
#ifdef CONFIG_INFINIBAND_USER_MEM
|
|
|
|
|
2020-01-15 19:43:31 +07:00
|
|
|
struct ib_umem *ib_umem_get(struct ib_device *device, unsigned long addr,
|
2019-11-13 14:32:14 +07:00
|
|
|
size_t size, int access);
|
2007-03-05 07:15:11 +07:00
|
|
|
void ib_umem_release(struct ib_umem *umem);
|
|
|
|
int ib_umem_page_count(struct ib_umem *umem);
|
2014-12-11 22:04:13 +07:00
|
|
|
int ib_umem_copy_from(void *dst, struct ib_umem *umem, size_t offset,
|
|
|
|
size_t length);
|
2019-05-06 20:53:32 +07:00
|
|
|
unsigned long ib_umem_find_best_pgsz(struct ib_umem *umem,
|
|
|
|
unsigned long pgsz_bitmap,
|
|
|
|
unsigned long virt);
|
2007-03-05 07:15:11 +07:00
|
|
|
|
|
|
|
#else /* CONFIG_INFINIBAND_USER_MEM */
|
|
|
|
|
|
|
|
#include <linux/err.h>
|
|
|
|
|
2020-01-15 19:43:31 +07:00
|
|
|
static inline struct ib_umem *ib_umem_get(struct ib_device *device,
|
2007-03-05 07:15:11 +07:00
|
|
|
unsigned long addr, size_t size,
|
2019-11-13 14:32:14 +07:00
|
|
|
int access)
|
2019-01-09 16:15:16 +07:00
|
|
|
{
|
2007-03-05 07:15:11 +07:00
|
|
|
return ERR_PTR(-EINVAL);
|
|
|
|
}
|
|
|
|
static inline void ib_umem_release(struct ib_umem *umem) { }
|
|
|
|
static inline int ib_umem_page_count(struct ib_umem *umem) { return 0; }
|
2014-12-11 22:04:14 +07:00
|
|
|
static inline int ib_umem_copy_from(void *dst, struct ib_umem *umem, size_t offset,
|
|
|
|
size_t length) {
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2019-05-06 20:53:32 +07:00
|
|
|
static inline int ib_umem_find_best_pgsz(struct ib_umem *umem,
|
|
|
|
unsigned long pgsz_bitmap,
|
|
|
|
unsigned long virt) {
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2007-03-05 07:15:11 +07:00
|
|
|
#endif /* CONFIG_INFINIBAND_USER_MEM */
|
|
|
|
|
|
|
|
#endif /* IB_UMEM_H */
|