[openib-general] Re: zero-sized memory regions

Michael S. Tsirkin mst at mellanox.co.il
Mon Mar 28 08:42:23 PST 2005


Quoting r. Roland Dreier <roland at topspin.com>:
> Subject: Re: zero-sized memory regions
> 
>     Michael> Hi!  Currently an attempt to create a zero sized memory
>     Michael> region in mthca succeeds, but apparently the key field in
>     Michael> the region returned is uninitialized.  Further,
>     Michael> buffer_list passed in must have length of at least 1
>     Michael> which is somewhat counterintuitive.
> 
>     Michael> Should not the operation rather return -EINVAL, and avoid
>     Michael> accessing the buffer list at all?  Roland - want a patch
>     Michael> like this?
> 
> >From looking at the IB spec, it seems that a length of 0 is valid.
> However I agree that the current behavior is not reasonable, and I
> don't particularly feel like implementing 0 length regions.  So
> returning -EINVAL before we do anything is probably the best way to
> go.
> 
>  - R.
> 

Something like the following then (untested)

Disable 0-sized regions. They are legal in IB spec, but
currently unused, and I dont feel like implementing them now.

Signed-off-by: Michael S. Tsirkin <mst at mellanox.co.il>

Index: mthca_provider.c
===================================================================
--- mthca_provider.c	(revision 2054)
+++ mthca_provider.c	(working copy)
@@ -483,6 +483,9 @@ static struct ib_mr *mthca_reg_phys_mr(s
 	int err;
 	int i, j, n;
 
+	if (!num_phys_buf)
+		return ERR_PTR(-EINVAL);
+
 	/* First check that we have enough alignment */
 	if ((*iova_start & ~PAGE_MASK) != (buffer_list[0].addr & ~PAGE_MASK))
 		return ERR_PTR(-EINVAL);

-- 
MST - Michael S. Tsirkin



More information about the general mailing list