2007-03-05 08:15:11 +08: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 05:22:52 +08:00
|
|
|
#include <linux/workqueue.h>
|
2019-01-09 17:15:16 +08:00
|
|
|
#include <rdma/ib_verbs.h>
|
2007-03-05 08:15:11 +08:00
|
|
|
|
|
|
|
struct ib_ucontext;
|
2014-12-11 23:04:17 +08:00
|
|
|
struct ib_umem_odp;
|
2007-03-05 08:15:11 +08:00
|
|
|
|
|
|
|
struct ib_umem {
|
|
|
|
struct ib_ucontext *context;
|
2018-09-17 01:44:45 +08:00
|
|
|
struct mm_struct *owning_mm;
|
2007-03-05 08:15:11 +08:00
|
|
|
size_t length;
|
2014-12-11 23:04:12 +08:00
|
|
|
unsigned long address;
|
2017-04-05 14:23:50 +08:00
|
|
|
int page_shift;
|
2018-09-17 01:48:06 +08:00
|
|
|
u32 writable : 1;
|
|
|
|
u32 is_odp : 1;
|
2007-04-19 11:20:28 +08:00
|
|
|
struct work_struct work;
|
2014-01-28 19:40:15 +08:00
|
|
|
struct sg_table sg_head;
|
|
|
|
int nmap;
|
2019-04-03 03:52:52 +08:00
|
|
|
unsigned int sg_nents;
|
2007-03-05 08:15:11 +08:00
|
|
|
};
|
|
|
|
|
2014-12-11 23:04:12 +08:00
|
|
|
/* Returns the offset of the umem start relative to the first page. */
|
|
|
|
static inline int ib_umem_offset(struct ib_umem *umem)
|
|
|
|
{
|
2017-04-05 14:23:50 +08:00
|
|
|
return umem->address & (BIT(umem->page_shift) - 1);
|
2014-12-11 23:04:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Returns the first page of an ODP umem. */
|
|
|
|
static inline unsigned long ib_umem_start(struct ib_umem *umem)
|
|
|
|
{
|
|
|
|
return umem->address - ib_umem_offset(umem);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Returns the address of the page after the last one of an ODP umem. */
|
|
|
|
static inline unsigned long ib_umem_end(struct ib_umem *umem)
|
|
|
|
{
|
2017-04-05 14:23:55 +08:00
|
|
|
return ALIGN(umem->address + umem->length, BIT(umem->page_shift));
|
2014-12-11 23:04:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline size_t ib_umem_num_pages(struct ib_umem *umem)
|
|
|
|
{
|
2017-04-05 14:23:55 +08:00
|
|
|
return (ib_umem_end(umem) - ib_umem_start(umem)) >> umem->page_shift;
|
2014-12-11 23:04:12 +08:00
|
|
|
}
|
|
|
|
|
2007-03-05 08:15:11 +08:00
|
|
|
#ifdef CONFIG_INFINIBAND_USER_MEM
|
|
|
|
|
2019-01-09 17:15:16 +08:00
|
|
|
struct ib_umem *ib_umem_get(struct ib_udata *udata, unsigned long addr,
|
2008-04-29 16:00:34 +08:00
|
|
|
size_t size, int access, int dmasync);
|
2007-03-05 08:15:11 +08:00
|
|
|
void ib_umem_release(struct ib_umem *umem);
|
|
|
|
int ib_umem_page_count(struct ib_umem *umem);
|
2014-12-11 23:04:13 +08:00
|
|
|
int ib_umem_copy_from(void *dst, struct ib_umem *umem, size_t offset,
|
|
|
|
size_t length);
|
2019-05-06 21:53:32 +08:00
|
|
|
unsigned long ib_umem_find_best_pgsz(struct ib_umem *umem,
|
|
|
|
unsigned long pgsz_bitmap,
|
|
|
|
unsigned long virt);
|
2007-03-05 08:15:11 +08:00
|
|
|
|
|
|
|
#else /* CONFIG_INFINIBAND_USER_MEM */
|
|
|
|
|
|
|
|
#include <linux/err.h>
|
|
|
|
|
2019-01-09 17:15:16 +08:00
|
|
|
static inline struct ib_umem *ib_umem_get(struct ib_udata *udata,
|
2007-03-05 08:15:11 +08:00
|
|
|
unsigned long addr, size_t size,
|
2019-01-09 17:15:16 +08:00
|
|
|
int access, int dmasync)
|
|
|
|
{
|
2007-03-05 08:15:11 +08: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 23:04:14 +08: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 21:53:32 +08: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 08:15:11 +08:00
|
|
|
#endif /* CONFIG_INFINIBAND_USER_MEM */
|
|
|
|
|
|
|
|
#endif /* IB_UMEM_H */
|