History log of /drivers/infiniband/core/uverbs_cmd.c
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
e47e321a35c741ee41b67976f8c6a3a7a42bc5c0 20-Jan-2012 Bernd Schubert <bernd.schubert@itwm.fraunhofer.de> RDMA/core: Fix kernel panic by always initializing qp->usecnt

We have just been investigating kernel panics related to
cq->ibcq.event_handler() completion calls. The problem is that
ib_destroy_qp() fails with -EBUSY.

Further investigation revealed qp->usecnt is not initialized. This
counter was introduced in linux-3.2 by commit 0e0ec7e0638e
("RDMA/core: Export ib_open_qp() to share XRC TGT QPs") but it only
gets initialized for IB_QPT_XRC_TGT, but it is checked in
ib_destroy_qp() for any QP type.

Fix this by initializing qp->usecnt for every QP we create.

Signed-off-by: Bernd Schubert <bernd.schubert@itwm.fraunhofer.de>
Signed-off-by: Sven Breuner <sven.breuner@itwm.fraunhofer.de>

[ Initialize qp->usecnt in uverbs too. - Sean ]

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Roland Dreier <roland@purestorage.com>
/drivers/infiniband/core/uverbs_cmd.c
1583676d9e3f97371eaa726c4e061f9b23f43c44 04-Jan-2012 Roland Dreier <roland@purestorage.com> Merge branches 'cma', 'misc', 'mlx4', 'nes', 'qib' and 'uverbs' into for-next
c89d1bedf8b130d5b20f56a484989a19a2c2842a 06-Dec-2011 Sean Hefty <sean.hefty@intel.com> rdma/core: Fix sparse warnings

Clean up sparse warnings in the rdma core layer.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
/drivers/infiniband/core/uverbs_cmd.c
e214a0fe2b382fa302c036ecd6e6ffe99e3b9875 04-Jan-2012 Eli Cohen <eli@dev.mellanox.co.il> IB/uverbs: Protect QP multicast list

Userspace verbs multicast attach/detach operations on a QP are done
while holding the rwsem of the QP for reading. That's not sufficient
since a reader lock allows more than one reader to acquire the
lock. However, multicast attach/detach does list manipulation that
can corrupt the list if multiple threads run in parallel.

Fix this by acquiring the rwsem as a writer to serialize attach/detach
operations. Add idr_write_qp() and put_qp_write() to encapsulate
this.

This fixes oops seen when running applications that perform multicast
joins/leaves.

Reported by: Mike Dubman <miked@mellanox.com>
Signed-off-by: Eli Cohen <eli@mellanox.com>
Cc: <stable@kernel.org>
Signed-off-by: Roland Dreier <roland@purestorage.com>
/drivers/infiniband/core/uverbs_cmd.c
42849b2697c36abdafa6aef64186b15055392046 11-Aug-2011 Sean Hefty <sean.hefty@intel.com> RDMA/uverbs: Export ib_open_qp() capability to user space

Allow processes that share the same XRC domain to open an existing
shareable QP. This permits those processes to receive events on the
shared QP and transfer ownership, so that any process may modify the
QP. The latter allows the creating process to exit, while a remaining
process can still transition it for path migration purposes.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
/drivers/infiniband/core/uverbs_cmd.c
0e0ec7e0638ef48e0c661873dfcc8caccab984c6 09-Aug-2011 Sean Hefty <sean.hefty@intel.com> RDMA/core: Export ib_open_qp() to share XRC TGT QPs

XRC TGT QPs are shared resources among multiple processes. Since the
creating process may exit, allow other processes which share the same
XRC domain to open an existing QP. This allows us to transfer
ownership of an XRC TGT QP to another process.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
/drivers/infiniband/core/uverbs_cmd.c
b93f3c18727634a2e847f067e549762d096921cf 27-May-2011 Sean Hefty <sean.hefty@intel.com> RDMA/uverbs: Export XRC TGT QPs to user space

Allow user space to operate on XRC TGT QPs the same way as other types
of QPs, with one notable exception: since XRC TGT QPs may be shared
among multiple processes, the XRC TGT QP is allowed to exist beyond the
lifetime of the creating process.

The process that creates the QP is allowed to destroy it, but if the
process exits without destroying the QP, then the QP will be left bound
to the lifetime of the XRCD.

TGT QPs are not associated with CQs or a PD.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
/drivers/infiniband/core/uverbs_cmd.c
9977f4f64bfeb5d907a793a6880aab2d43b0bed2 26-May-2011 Sean Hefty <sean.hefty@intel.com> RDMA/uverbs: Export XRC INI QPs to userspace

XRC INI QPs are similar to send only RC QPs. Allow user space to create
INI QPs. Note that INI QPs do not require receive CQs.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
/drivers/infiniband/core/uverbs_cmd.c
8541f8de0583f562c652008a4e7a65e537842a7e 26-May-2011 Sean Hefty <sean.hefty@intel.com> RDMA/uverbs: Export XRC SRQs to user space

We require additional information to create XRC SRQs than we can
exchange using the existing create SRQ ABI. Provide an enhanced create
ABI for extended SRQ types.

Based on patches by Jack Morgenstein <jackm@dev.mellanox.co.il>
and Roland Dreier <roland@purestorage.com>

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
/drivers/infiniband/core/uverbs_cmd.c
53d0bd1e7ff2fc626321f337c609fb76ae5d12c9 24-May-2011 Sean Hefty <sean.hefty@intel.com> RDMA/uverbs: Export XRC domains to user space

Allow user space to create XRC domains. Because XRCDs are expected to
be shared among multiple processes, we use inodes to identify an XRCD.

Based on patches by Jack Morgenstein <jackm@dev.mellanox.co.il>

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
/drivers/infiniband/core/uverbs_cmd.c
96104eda01695a26da2c8f7423ec0ba3509c8c97 24-May-2011 Sean Hefty <sean.hefty@intel.com> RDMA/core: Add SRQ type field

Currently, there is only a single ("basic") type of SRQ, but with XRC
support we will add a second. Prepare for this by defining an SRQ type
and setting all current users to IB_SRQT_BASIC.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
/drivers/infiniband/core/uverbs_cmd.c
7182afea8d1afd432a17c18162cc3fd441d0da93 13-Oct-2010 Dan Carpenter <error27@gmail.com> IB/uverbs: Handle large number of entries in poll CQ

In ib_uverbs_poll_cq() code there is a potential integer overflow if
userspace passes in a large cmd.ne. The calls to kmalloc() would
allocate smaller buffers than intended, leading to memory corruption.
There iss also an information leak if resp wasn't all used.
Unprivileged userspace may call this function, although only if an
RDMA device that uses this function is present.

Fix this by copying CQ entries one at a time, which avoids the
allocation entirely, and also by moving this copying into a function
that makes sure to initialize all memory copied to userspace.

Special thanks to Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
for his help and advice.

Cc: <stable@kernel.org>
Signed-off-by: Dan Carpenter <error27@gmail.com>

[ Monkey around with things a bit to avoid bad code generation by gcc
when designated initializers are used. - Roland ]

Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
2420b60b1dc4ed98cb1788e928bc57ff2efa1a8d 18-Oct-2010 Eli Cohen <eli@mellanox.co.il> IB/uverbs: Return link layer type to userspace for query port operation

Signed-off-by: Eli Cohen <eli@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
5a0e3ad6af8660be21ca98a971cd00f331318c05 24-Mar-2010 Tejun Heo <tj@kernel.org> include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h

percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.

percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.

http://userweb.kernel.org/~tj/misc/slabh-sweep.py

The script does the followings.

* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.

* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.

* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.

The conversion was done in the following steps.

1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.

2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.

3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.

4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.

5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.

6. percpu.h was updated not to include slab.h.

7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).

* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig

8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.

Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.

Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
/drivers/infiniband/core/uverbs_cmd.c
b1e4594ba097634e9436cc4c6ba95f70a2d627ff 18-Jan-2010 Al Viro <viro@zeniv.linux.org.uk> switch infiniband uverbs to anon_inodes

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
/drivers/infiniband/core/uverbs_cmd.c
df42245a3c246ec1eeeedbc3e5edbcc17f081c79 09-Dec-2009 Roel Kluin <roel.kluin@gmail.com> IB/uverbs: Fix return of PTR_ERR() of wrong pointer in ib_uverbs_get_context()

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
00f7ec36c9324928e4cd23f02e6d8550f30c32ca 15-Jul-2008 Steve Wise <swise@opengridcomputing.com> RDMA/core: Add memory management extensions support

This patch adds support for the IB "base memory management extension"
(BMME) and the equivalent iWARP operations (which the iWARP verbs
mandates all devices must implement). The new operations are:

- Allocate an ib_mr for use in fast register work requests.

- Allocate/free a physical buffer lists for use in fast register work
requests. This allows device drivers to allocate this memory as
needed for use in posting send requests (eg via dma_alloc_coherent).

- New send queue work requests:
* send with remote invalidate
* fast register memory region
* local invalidate memory region
* RDMA read with invalidate local memory region (iWARP only)

Consumer interface details:

- A new device capability flag IB_DEVICE_MEM_MGT_EXTENSIONS is added
to indicate device support for these features.

- New send work request opcodes IB_WR_FAST_REG_MR, IB_WR_LOCAL_INV,
IB_WR_RDMA_READ_WITH_INV are added.

- A new consumer API function, ib_alloc_mr() is added to allocate
fast register memory regions.

- New consumer API functions, ib_alloc_fast_reg_page_list() and
ib_free_fast_reg_page_list() are added to allocate and free
device-specific memory for fast registration page lists.

- A new consumer API function, ib_update_fast_reg_key(), is added to
allow the key portion of the R_Key and L_Key of a fast registration
MR to be updated. Consumers call this if desired before posting
a IB_WR_FAST_REG_MR work request.

Consumers can use this as follows:

- MR is allocated with ib_alloc_mr().

- Page list memory is allocated with ib_alloc_fast_reg_page_list().

- MR R_Key/L_Key "key" field is updated with ib_update_fast_reg_key().

- MR made VALID and bound to a specific page list via
ib_post_send(IB_WR_FAST_REG_MR)

- MR made INVALID via ib_post_send(IB_WR_LOCAL_INV),
ib_post_send(IB_WR_RDMA_READ_WITH_INV) or an incoming send with
invalidate operation.

- MR is deallocated with ib_dereg_mr()

- page lists dealloced via ib_free_fast_reg_page_list().

Applications can allocate a fast register MR once, and then can
repeatedly bind the MR to different physical block lists (PBLs) via
posting work requests to a send queue (SQ). For each outstanding
MR-to-PBL binding in the SQ pipe, a fast_reg_page_list needs to be
allocated (the fast_reg_page_list is owned by the low-level driver
from the consumer posting a work request until the request completes).
Thus pipelining can be achieved while still allowing device-specific
page_list processing.

The 32-bit fast register memory key/STag is composed of a 24-bit index
and an 8-bit key. The application can change the key each time it
fast registers thus allowing more control over the peer's use of the
key/STag (ie it can effectively be changed each time the rkey is
rebound to a page list).

Signed-off-by: Steve Wise <swise@opengridcomputing.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
f3781d2e89f12dd5afa046dc56032af6e39bd116 15-Jul-2008 Roland Dreier <rolandd@cisco.com> RDMA: Remove subversion $Id tags

They don't get updated by git and so they're worse than useless.

Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
0f39cf3d54e67a705773fd0ec56ca3dcd3e9272f 17-Apr-2008 Roland Dreier <rolandd@cisco.com> IB/core: Add support for "send with invalidate" work requests

Add a new IB_WR_SEND_WITH_INV send opcode that can be used to mark a
"send with invalidate" work request as defined in the iWARP verbs and
the InfiniBand base memory management extensions. Also put "imm_data"
and a new "invalidate_rkey" member in a new "ex" union in struct
ib_send_wr. The invalidate_rkey member can be used to pass in an
R_Key/STag to be invalidated. Add this new union to struct
ib_uverbs_send_wr. Add code to copy the invalidate_rkey field in
ib_uverbs_post_send().

Fix up low-level drivers to deal with the change to struct ib_send_wr,
and just remove the imm_data initialization from net/sunrpc/xprtrdma/,
since that code never does any send with immediate operations.

Also, move the existing IB_DEVICE_SEND_W_INV flag to a new bit, since
the iWARP drivers currently in the tree set the bit. The amso1100
driver at least will silently fail to honor the IB_SEND_INVALIDATE bit
if passed in as part of userspace send requests (since it does not
implement kernel bypass work request queueing). Remove the flag from
all existing drivers that set it until we know which ones are OK.

The values chosen for the new flag is not consecutive to avoid clashing
with flags defined in the XRC patches, which are not merged yet but
which are already in use and are likely to be merged soon.

This resurrects a patch sent long ago by Mikkel Hagen <mhagen@iol.unh.edu>.

Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
b846f25aa2a353355aec5202fe4dbdc6674dfc64 17-Apr-2008 Eli Cohen <eli@dev.mellanox.co.il> IB/core: Add creation flags to struct ib_qp_init_attr

Add a create_flags member to struct ib_qp_init_attr that will allow a
kernel verbs consumer to create a pass special flags when creating a QP.
Add a flag value for telling low-level drivers that a QP will be used
for IPoIB UD LSO. The create_flags member will also be useful for XRC
and ehca low-latency QP support.

Since no create_flags handling is implemented yet, add code to all
low-level drivers to return -EINVAL if create_flags is non-zero.

Signed-off-by: Eli Cohen <eli@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
cbfb50e6e2e9c580848c0f51d37c24cdfb1cb704 20-Oct-2007 Roland Dreier <rolandd@cisco.com> IB/uverbs: Fix checking of userspace object ownership

Commit 9ead190b ("IB/uverbs: Don't serialize with ib_uverbs_idr_mutex")
rewrote how userspace objects are looked up in the uverbs module's
idrs, and introduced a severe bug in the process: there is no checking
that an operation is being performed by the right process any more.
Fix this by adding the missing check of uobj->context in __idr_get_uobj().

Apparently everyone is being very careful to only touch their own
objects, because this bug was introduced in June 2006 in 2.6.18, and
has gone undetected until now.

Cc: stable <stable@kernel.org>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
f7c6a7b5d59980b076abbf2ceeb8735591290285 05-Mar-2007 Roland Dreier <rolandd@cisco.com> IB/uverbs: Export ib_umem_get()/ib_umem_release() to modules

Export ib_umem_get()/ib_umem_release() and put low-level drivers in
control of when to call ib_umem_get() to pin and DMA map userspace,
rather than always calling it in ib_uverbs_reg_mr() before calling the
low-level driver's reg_user_mr method.

Also move these functions to be in the ib_core module instead of
ib_uverbs, so that driver modules using them do not depend on
ib_uverbs.

This has a number of advantages:
- It is better design from the standpoint of making generic code a
library that can be used or overridden by device-specific code as
the details of specific devices dictate.
- Drivers that do not need to pin userspace memory regions do not
need to take the performance hit of calling ib_mem_get(). For
example, although I have not tried to implement it in this patch,
the ipath driver should be able to avoid pinning memory and just
use copy_{to,from}_user() to access userspace memory regions.
- Buffers that need special mapping treatment can be identified by
the low-level driver. For example, it may be possible to solve
some Altix-specific memory ordering issues with mthca CQs in
userspace by mapping CQ buffers with extra flags.
- Drivers that need to pin and DMA map userspace memory for things
other than memory regions can use ib_umem_get() directly, instead
of hacks using extra parameters to their reg_phys_mr method. For
example, the mlx4 driver that is pending being merged needs to pin
and DMA map QP and CQ buffers, but it does not need to create a
memory key for these buffers. So the cleanest solution is for mlx4
to call ib_umem_get() in the create_qp and create_cq methods.

Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
f4fd0b224d60044d2da5ca02f8f2b5150c1d8731 03-May-2007 Michael S. Tsirkin <mst@dev.mellanox.co.il> IB: Add CQ comp_vector support

Add a num_comp_vectors member to struct ib_device and extend
ib_create_cq() to pass in a comp_vector parameter -- this parallels
the userspace libibverbs API. Update all hardware drivers to set
num_comp_vectors to 1 and have all ULPs pass 0 for the comp_vector
value. Pass the value of num_comp_vectors to userspace rather than
hard-coding a value of 1.

We want multiple CQ event vector support (via MSI-X or similar for
adapters that can generate multiple interrupts), but it's not clear
how many vectors we want, or how we want to deal with policy issues
such as how to decide which vector to use or how to set up interrupt
affinity. This patch is useful for experimenting, since no core
changes will be necessary when updating a driver to support multiple
vectors, and we know that we want to make at least these changes
anyway.

Signed-off-by: Michael S. Tsirkin <mst@dev.mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
aaf1aef55f50f53812871693692c7cbefcd57f39 22-Feb-2007 Roland Dreier <rolandd@cisco.com> IB/uverbs: Return correct error for invalid PD in register MR

If no matching PD is found in ib_uverbs_reg_mr(), then the function
jumps to err_release without setting the return value ret. This means
that ret will hold the return value of the call to ib_umem_get() a few
lines earlier; if the function reaches the point where it looks for
the PD, we know that ib_umem_get() must have returned 0, so
ib_uverbs_reg_mr() ends up return 0 for a bad PD ID. Fix this by
setting ret to -EINVAL before jumping to the exit path when no PD is
found.

Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
062dbb69f32b9ccea701b30f8cc0049482e6211f 31-Dec-2006 Michael S. Tsirkin <mst@mellanox.co.il> IB: Return qp pointer as part of ib_wc

struct ib_wc currently only includes the local QP number: this matches
the IB spec, but seems mostly useless. The following patch replaces
this with the pointer to qp itself, and updates all low level drivers
and all users.

This has the following advantages:
- Ability to get a per-qp context through wc->qp->qp_context
- Existing drivers already have the qp pointer ready in poll cq, so
this change actually saves a tiny bit (extra memory read) on data path
(for ehca it would actually be expensive to find the QP pointer when
polling a CQ, but ehca does not support SRQ so we can leave wc->qp as
NULL for ehca)
- Users that need the QP number can still get it through wc->qp->qp_num

Use case:

In IPoIB connected mode code, I have a common CQ shared by multiple
QPs. To track connection usage, I need a way to get at some per-QP
context upon the completion, and I would like to avoid allocating
context object per work request just to stick a QP pointer into it.
With this code, I can just use wc->qp->qp_context.

Signed-off-by: Michael S. Tsirkin <mst@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
0b26c88f29ad8bcf91a2ea8f25a36f2028ebabea 25-Oct-2006 Jack Morgenstein <jackm@dev.mellanox.co.il> IB/uverbs: Return sq_draining value in query_qp response

Return the sq_draining value back to user space for query_qp instead
of the en_sqd_async notify value, which is valid only for
modify_qp. For query_qp, the draining status should returned.

Signed-off-by: Jack Morgenstein <jackm@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
3cd965646b7cb75ae84dd0daf6258adf20e4f169 23-Sep-2006 Roland Dreier <rolandd@cisco.com> IB: Whitespace fixes

Remove some trailing whitespace that has snuck in despite the best
efforts of whitespace=error-all. Also fix a few other whitespace
bogosities.

Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
9bc57e2d19db4da81c1150120658cc3658a99ed4 11-Aug-2006 Ralph Campbell <ralphc@pathscale.com> IB/uverbs: Pass userspace data to modify_srq and modify_qp methods

Pass a struct ib_udata to the low-level driver's ->modify_srq() and
->modify_qp() methods, so that it can get to the device-specific data
passed in by the userspace driver.

Signed-off-by: Ralph Campbell <ralph.campbell@qlogic.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
64f817ba98095156149ba5991592d5d039f6da74 23-Sep-2006 Ralph Campbell <ralph.campbell@qlogic.com> IB/uverbs: Allow resize CQ operation to return driver-specific data

Add a ib_uverbs_resize_cq_resp.driver_data field so that low-level
drivers can return data from a resize CQ operation to userspace. Have
ib_uverbs_resize_cq() only copy the cqe field, to avoid having to bump
the userspace ABI.

Signed-off-by: Ralph Campbell <ralph.campbell@qlogic.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
1ccf6aa19aabc11587d6d7818a5729adfed0e3de 23-Sep-2006 Roland Dreier <rolandd@cisco.com> IB/uverbs: Fix lockdep warning when QP is created with 2 CQs

Lockdep warns when userspace creates a QP that uses different CQs for
send completions and receive completions, because both CQs are locked
and their mutexes belong to the same lock class. However, we know
that the mutexes are distinct and the nesting is safe (there is no
possibility of AB-BA deadlock because the mutexes are locked with
down_read()), so annotate the situation with SINGLE_DEPTH_NESTING to
get rid of the lockdep warning.

Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
ab10867621a96230757eb4a2a19d560b85f62ce9 23-Sep-2006 Roland Dreier <rolandd@cisco.com> IB/uverbs: Use idr_read_cq() where appropriate

There were two functions that open-coded idr_read_cq() in terms of
idr_read_uobj() rather than using the helper.

Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
43db2bc04409b1e1b74f9768e3284cec18a87d0b 24-Jul-2006 Roland Dreier <rolandd@cisco.com> IB/uverbs: Fix lockdep warnings

Lockdep warns because uverbs is trying to take uobj->mutex when it
already holds that lock. This is because there are really multiple
types of uobjs even though all of their locks are initialized in
common code.

Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
ec924b4726e3df000d3ac7ae10cb8ef1adcd60ca 17-Jul-2006 Michael S. Tsirkin <mst@mellanox.co.il> IB/uverbs: Fix unlocking in error paths

ib_uverbs_create_ah() and ib_uverbs_create_srq() did not release the
PD's read lock in their error paths, which lead to deadlock when
destroying the PD.

Signed-off-by: Michael S. Tsirkin <mst@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
146d26b2bf167f831d3b7442a01cfdc2b183cb0b 30-Jun-2006 Roland Dreier <rolandd@cisco.com> IB/uverbs: Set correct user handle for user SRQs

Store away the user handle passed in from userspace when creating an
SRQ, so that the kernel can return the correct handle when an SRQ
asynchronous event occurs. (A 0 was incorrectly stored as the user
handle as part of the changes in 9ead190b, "IB/uverbs: Don't serialize
with ib_uverbs_idr_mutex")

Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
183208284e3ab3816189fc0e23faf29675ce6c9f 22-Jun-2006 Krishna Kumar <krkumar2@in.ibm.com> IB/uverbs: Don't free wr list when it's known to be empty

In ib_uverbs_post_send(), move the "out:" label after the loop that
frees the list of work requests, since the only place that jumps there
is before any work requests could possibly be added to the list.

This removes a compile warning: "is_ud might be used uninitialized in
this function".

Signed-off-by: Krishna Kumar <krkumar2@in.ibm.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
9ead190bfde2a434c74ea604382d08acb2eceef5 18-Jun-2006 Roland Dreier <rolandd@cisco.com> IB/uverbs: Don't serialize with ib_uverbs_idr_mutex

Currently, all userspace verbs operations that call into the kernel
are serialized by ib_uverbs_idr_mutex. This can be a scalability
issue for some workloads, especially for devices driven by the ipath
driver, which needs to call into the kernel even for datapath
operations.

Fix this by adding reference counts to the userspace objects, and then
converting ib_uverbs_idr_mutex into a spinlock that only protects the
idrs long enough to take a reference on the object being looked up.
Because remove operations may fail, we have to do a slightly funky
two-step deletion, which is described in the comments at the top of
uverbs_cmd.c.

This also still leaves ib_uverbs_idr_lock as a single lock that is
possibly subject to contention. However, the lock hold time will only
be a single idr operation, so multiple threads should still be able to
make progress, even if ib_uverbs_idr_lock is being ping-ponged.

Surprisingly, these changes even shrink the object code:

add/remove: 23/5 grow/shrink: 4/21 up/down: 633/-693 (-60)

Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
3463175d6ee55fdbd5cda2a03415e2068599b2b7 18-Jun-2006 Roland Dreier <rolandd@cisco.com> IB/uverbs: Factor out common idr code

Factor out common code for adding a userspace object to an idr into a
function idr_add_uobj(). This shrinks both the source and object code:

add/remove: 1/0 grow/shrink: 0/6 up/down: 57/-220 (-163)
function old new delta
idr_add_uobj - 57 +57
ib_uverbs_create_ah 543 512 -31
ib_uverbs_create_srq 662 630 -32
ib_uverbs_reg_mr 737 699 -38
ib_uverbs_create_cq 639 600 -39
ib_uverbs_alloc_pd 485 446 -39
ib_uverbs_create_qp 1020 979 -41

Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
92b1582268e269b3a9e54e186e740396f0f2012b 18-Jun-2006 Roland Dreier <rolandd@cisco.com> IB/uverbs: Don't decrement usecnt on error paths

In error paths when destroying an object, uverbs should not decrement
associated objects' usecnt, since ib_dereg_mr(), ib_destroy_qp(),
etc. already do that.

Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
77f76013e3ffda605b20184db5862ce1efcb6f5a 18-Jun-2006 Ganapathi CH <cganapathi@novell.com> IB/uverbs: Release lock on error path

If ibdev->alloc_ucontext() fails then ib_uverbs_get_context() does not
unlock file->mutex before returning error.

Signed-off by: Ganapathi CH <cganapathi@novell.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
702b2aaccfbf0fa29c6ffb423a39a7a5573f793a 20-Mar-2006 Ami Perlmutter <amip@mellanox.co.il> IB/uverbs: Use correct alt_pkey_index in modify QP

The old code incorrectly used the primary P_Key index as the alternate
index too.

Signed-off-by: Ami Perlmutter <amip@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
27d56300647f6e76847bc2407d7abc782fe87495 02-Mar-2006 Dotan Barak <dotanb@mellanox.co.il> IB/uverbs: Fix query QP return of sq_sig_all

The old code didn't convert from the kernel's enum correctly.

Signed-off-by: Dotan Barak <dotanb@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
ea88fd16d6e85f4bc71b6053180b64f04be1ff14 23-Feb-2006 Dotan Barak <dotanb@mellanox.co.il> IB/uverbs: Return actual capacity from create SRQ operation

Pass actual capacity of created SRQ back to userspace, so that
userspace can report accurate capacities. This requires an ABI bump,
to change struct ib_uverbs_create_srq_resp.

Signed-off-by: Dotan Barak <dotanb@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
8bdb0e8632e0f5061bd18b6934346cb609490135 14-Feb-2006 Dotan Barak <dotanb@mellanox.co.il> IB/uverbs: Support for query SRQ from userspace

Add support to uverbs to handle querying userspace SRQs (shared
receive queues), including adding an ABI for marshalling requests and
responses. The kernel midlayer already has the underlying
ib_query_srq() function.

Signed-off-by: Dotan Barak <dotanb@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
7ccc9a24e01258a31ee2b964215e4ddddd2a02c4 14-Feb-2006 Dotan Barak <dotanb@mellanox.co.il> IB/uverbs: Support for query QP from userspace

Add support to uverbs to handle querying userspace QPs (queue pairs),
including adding an ABI for marshalling requests and responses. The
kernel midlayer already has the underlying ib_query_qp() function.

Signed-off-by: Dotan Barak <dotanb@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
a74cd4af0bfa9578594acbb711a958104c93b772 14-Feb-2006 Roland Dreier <rolandd@cisco.com> IB: Whitespace cleanups

Remove trailing whitespace and fix indentation that with spaces
instead of tabs.

Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
33b9b3ee9709b19c4f02ab91571d53540d05c3d1 30-Jan-2006 Roland Dreier <rolandd@cisco.com> IB: Add userspace support for resizing CQs

Add support to uverbs to handle resizing userspace CQs (completion
queues), including adding an ABI for marshalling requests and
responses. The kernel midlayer already has ib_resize_cq().

Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
95ed644fd12f53c6fc778f3f246974e5fe3a9468 13-Jan-2006 Ingo Molnar <mingo@elte.hu> IB: convert from semaphores to mutexes

semaphore to mutex conversion by Ingo and Arjan's script.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
[ Sanity-checked on real IB hardware ]
Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
cf311cd49a78f1e431787068cc31d29d06a415e6 10-Jan-2006 Sean Hefty <sean.hefty@intel.com> IB: Add node_guid to struct ib_device

Add a node_guid field to struct ib_device. It is the responsibility
of the low-level driver to initialize this field before registering a
device with the midlayer. Convert everyone to looking at this field
instead of calling ib_query_device() when all they want is the node
GUID, and remove the node_guid field from struct ib_device_attr.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
ac4e7b35579de55db50d602a472858867808a9c3 07-Jan-2006 Jack Morgenstein <jackm@mellanox.co.il> IB/uverbs: Release event file reference on ib_uverbs_create_cq() error

ib_uverbs_create_cq() should release the completion channel event file
if an error occurs after it looks it up. Also, if userspace asks for
a completion channel and we don't find it, an error should be returned
instead of silently creating a CQ without a completion channel.

Signed-off-by: Jack Morgenstein <jackm@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
ea5d4a6ad2bfd1006790666981645cab43d3afbd 07-Jan-2006 Ralph Campbell <ralphc@pathscale.com> IB/uverbs: set ah_flags when creating address handle

AH attribute's ah_flags need to be set according to the is_global flag
passed in from userspace.

Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
b4ca1a3f8ca24033d7b7ef595faef97d9f8b2326 07-Jan-2006 Jack Morgenstein <jackm@mellanox.co.il> IB/uverbs: Fix reference counting on error paths

If an operation fails after incrementing an object's reference count,
then it should decrement the reference count on the error path.

Signed-off-by: Jack Morgenstein <jackm@mellanox.co.il>
Signed-off-by: Michael S. Tsirkin <mst@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
f4e401562c11c7ca65592ebd749353cf0b19af7b 30-Nov-2005 Jack Morgenstein <jackm@mellanox.co.il> IB/uverbs: track multicast group membership for userspace QPs

uverbs needs to track which multicast groups is each qp
attached to, in order to properly detach when cleanup
is performed on device file close.

Signed-off-by: Jack Morgenstein <jackm@mellanox.co.il>
Signed-off-by: Michael S. Tsirkin <mst@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
77369ed31daac51f4827c50d30f233c45480235a 09-Nov-2005 Jack Morgenstein <jackm@mellanox.co.il> [IB] uverbs: have kernel return QP capabilities

Move the computation of QP capabilities (max scatter/gather entries,
max inline data, etc) into the kernel, and have the uverbs module
return the values as part of the create QP response. This keeps
precise knowledge of device limits in the low-level kernel driver.

This requires an ABI bump, so while we're making changes, get rid of
the max_sge parameter for the modify SRQ command -- it's not used and
shouldn't be there.

Signed-off-by: Jack Morgenstein <jackm@mellanox.co.il>
Signed-off-by: Michael S. Tsirkin <mst@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
7162a3e0db34e914a8bc5bf74bbae0b386310cf8 30-Oct-2005 Roland Dreier <rolandd@cisco.com> [IB] uverbs: Avoid NULL pointer deref on CQ async event

Userspace CQs that have no completion event channel attached end up
with their cq_context set to NULL. However, asynchronous events like
"CQ overrun" can still occur on such CQs, so add a uverbs_file member
to struct ib_ucq_object that we can follow to deliver these events.

Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
70a30e16a8a9d22396a4d1e96af86e43594df584 29-Oct-2005 Roland Dreier <rolandd@cisco.com> [IB] uverbs: Fix device lifetime problems

Move ib_uverbs module to using cdev_alloc() and class_device_create()
so that we can handle device lifetime properly. Now we can make sure
we keep all of our data structures around until the last way to reach
them is gone.

Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
67cdb40ca444c09853ab4d8a41cf547ac26a4de4 15-Oct-2005 Roland Dreier <rolandd@cisco.com> [IB] uverbs: Implement more commands

Add kernel support for userspace calling poll CQ, request CQ
notification, post send, post receive, post SRQ receive, create AH and
destroy AH commands. These commands allow us to support userspace
verbs for devices that can't perform these operations directly from
userspace (eg the PathScale HCA).

Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
f575394f1de9b4afa4b474f1882c7e2d3b8e51d7 03-Oct-2005 Roland Dreier <rolandd@cisco.com> [IB] uverbs: reject invalid memory registration permission flags

Reject userspace memory registrations with invalid permission flags:
"local write" is required if "remote write" or "remote atomic" is also
requested.

Pointed out by Jack Morgenstein <jackm@mellanox.co.il>

Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
eb9d3cd5ce2828fbb99ed7270089ea152c8f64b3 28-Sep-2005 Roland Dreier <rolandd@cisco.com> [IB] uverbs: Fix up resource creation error paths

By waiting to add resources to our lists until after the last
operation that can fail, we don't have to remove them from their lists
in the error path. Also, we should hold the idr mutex until we know
whether resource creation has succeed or failed, to avoid someone
finding a resource in our table before we're ready.

Loosely based on work by Robert Walsh <rjwalsh@pathscale.com>.

Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
6b73597e7062118c0549c2702bfb7d273518c906 26-Sep-2005 Roland Dreier <rolandd@cisco.com> [IB] uverbs: ABI-breaking fixes for userspace verbs

Introduce new userspace verbs ABI version 3. This eliminates some
unneeded commands, and adds support for user-created completion
channels. This cleans up problems with file leaks on error paths, and
also makes sure that file descriptors are always installed into the
correct process.

Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
63c47c286d062d93e0501d60797274c84a587e97 26-Sep-2005 Roland Dreier <rolandd@cisco.com> [IB] uverbs: Close some exploitable races

Al Viro pointed out that the current IB userspace verbs interface
allows userspace to cause mischief by closing file descriptors before
we're ready, or issuing the same command twice at the same time. This
patch closes those races, and fixes other obvious problems such as a
module reference leak.

Some other interface bogosities will require an ABI change to fix
properly, so I'm deferring those fixes until 2.6.15.

Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
63aaf647529e8a56bdf31fd8f2979d4371c6a332 10-Sep-2005 Roland Dreier <roland@eddore.topspincom.com> Make sure that userspace does not retrieve stale asynchronous or
completion events after destroying a CQ, QP or SRQ. We do this by
sweeping the event lists before returning from a destroy calls, and
then return the number of events already reported before the destroy
call. This allows userspace wait until it has processed all events
for an object returned from the kernel before it frees its context for
the object.

The ABI of the destroy CQ, destroy QP and destroy SRQ commands has to
change to return the event count, so bump the ABI version from 1 to 2.
The userspace libibverbs library has already been updated to handle
both the old and new ABI versions.

Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
f520ba5aa48e2891c3fb3e364eeaaab4212c7c45 18-Aug-2005 Roland Dreier <roland@eddore.topspincom.com> [PATCH] IB: userspace SRQ support

Add SRQ support to userspace verbs module. This adds several commands
and associated structures, but it's OK to do this without bumping the
ABI version because the commands are added at the end of the list so
they don't change the existing numbering. There are two cases to
worry about:

1. New kernel, old userspace. This is OK because old userspace simply
won't try to use the new SRQ commands. None of the old commands are
changed.

2. Old kernel, new userspace. This works perfectly as long as
userspace doesn't try to use SRQ commands. If userspace tries to
use SRQ commands, it will get EINVAL, which is perfectly
reasonable: the kernel doesn't support SRQs, so we couldn't do any
better.

Signed-off-by: Roland Dreier <rolandd@cisco.com>
/drivers/infiniband/core/uverbs_cmd.c
bc38a6abdd5a50e007d0fcd9b9b6280132b79e62 08-Jul-2005 Roland Dreier <rolandd@cisco.com> [PATCH] IB uverbs: core implementation

Add the core of the InfiniBand userspace verbs implementation, including
creating character device nodes, dispatching requests from userspace, and
passing event notifications back up to userspace.

Signed-off-by: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
/drivers/infiniband/core/uverbs_cmd.c