2007-03-04 17: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-20 15:22:52 -06:00
|
|
|
#include <linux/workqueue.h>
|
2007-03-04 17:15:11 -07:00
|
|
|
|
|
|
|
struct ib_ucontext;
|
|
|
|
|
|
|
|
struct ib_umem {
|
|
|
|
struct ib_ucontext *context;
|
|
|
|
size_t length;
|
2014-12-11 08:04:12 -07:00
|
|
|
unsigned long address;
|
2007-03-04 17:15:11 -07:00
|
|
|
int page_size;
|
|
|
|
int writable;
|
2007-09-13 10:15:28 -06:00
|
|
|
int hugetlb;
|
2007-04-18 21:20:28 -06:00
|
|
|
struct work_struct work;
|
2014-09-03 11:13:57 -06:00
|
|
|
struct pid *pid;
|
2007-04-18 21:20:28 -06:00
|
|
|
struct mm_struct *mm;
|
|
|
|
unsigned long diff;
|
2014-01-28 04:40:15 -07:00
|
|
|
struct sg_table sg_head;
|
|
|
|
int nmap;
|
|
|
|
int npages;
|
2007-03-04 17:15:11 -07:00
|
|
|
};
|
|
|
|
|
2014-12-11 08: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)
|
|
|
|
{
|
|
|
|
return umem->address & ((unsigned long)umem->page_size - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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)
|
|
|
|
{
|
|
|
|
return PAGE_ALIGN(umem->address + umem->length);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline size_t ib_umem_num_pages(struct ib_umem *umem)
|
|
|
|
{
|
|
|
|
return (ib_umem_end(umem) - ib_umem_start(umem)) >> PAGE_SHIFT;
|
|
|
|
}
|
|
|
|
|
2007-03-04 17:15:11 -07:00
|
|
|
#ifdef CONFIG_INFINIBAND_USER_MEM
|
|
|
|
|
|
|
|
struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
|
2008-04-29 02:00:34 -06:00
|
|
|
size_t size, int access, int dmasync);
|
2007-03-04 17:15:11 -07:00
|
|
|
void ib_umem_release(struct ib_umem *umem);
|
|
|
|
int ib_umem_page_count(struct ib_umem *umem);
|
2014-12-11 08:04:13 -07:00
|
|
|
int ib_umem_copy_from(void *dst, struct ib_umem *umem, size_t offset,
|
|
|
|
size_t length);
|
2007-03-04 17:15:11 -07:00
|
|
|
|
|
|
|
#else /* CONFIG_INFINIBAND_USER_MEM */
|
|
|
|
|
|
|
|
#include <linux/err.h>
|
|
|
|
|
|
|
|
static inline struct ib_umem *ib_umem_get(struct ib_ucontext *context,
|
|
|
|
unsigned long addr, size_t size,
|
2008-04-29 02:00:34 -06:00
|
|
|
int access, int dmasync) {
|
2007-03-04 17: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 08: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;
|
|
|
|
}
|
2007-03-04 17:15:11 -07:00
|
|
|
#endif /* CONFIG_INFINIBAND_USER_MEM */
|
|
|
|
|
|
|
|
#endif /* IB_UMEM_H */
|