gru: support contexts with zero dsrs or cbrs
authorJack Steiner <steiner@sgi.com>
Wed, 17 Jun 2009 23:28:23 +0000 (16:28 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 18 Jun 2009 20:04:00 +0000 (13:04 -0700)
Support alocation of GRU contexts that contain zero DSR or CBR resources.
Some instructions do not require DSR resources.  Contexts without CBR
resources are useful for diagnostics.

Signed-off-by: Jack Steiner <steiner@sgi.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/misc/sgi-gru/grufile.c
drivers/misc/sgi-gru/grumain.c

index 9e6da46eeb04043030d79a9ae91a884771afdf9d..b1567ce868e9d5f289acf664ff2f28bbfdd42de4 100644 (file)
@@ -135,11 +135,9 @@ static int gru_create_new_context(unsigned long arg)
        if (copy_from_user(&req, (void __user *)arg, sizeof(req)))
                return -EFAULT;
 
-       if (req.data_segment_bytes == 0 ||
-                               req.data_segment_bytes > max_user_dsr_bytes)
+       if (req.data_segment_bytes > max_user_dsr_bytes)
                return -EINVAL;
-       if (!req.control_blocks || !req.maximum_thread_count ||
-                               req.control_blocks > max_user_cbrs)
+       if (req.control_blocks > max_user_cbrs || !req.maximum_thread_count)
                return -EINVAL;
 
        if (!(req.options & GRU_OPT_MISS_MASK))
index 3398e54a762be43c1e5992435e835d5f0f1e9e2d..4e6e8c3554f009e1a0cb909226b1f6cc0389be24 100644 (file)
@@ -150,7 +150,7 @@ static unsigned long reserve_resources(unsigned long *p, int n, int mmax,
        unsigned long bits = 0;
        int i;
 
-       do {
+       while (n--) {
                i = find_first_bit(p, mmax);
                if (i == mmax)
                        BUG();
@@ -158,7 +158,7 @@ static unsigned long reserve_resources(unsigned long *p, int n, int mmax,
                __set_bit(i, &bits);
                if (idx)
                        *idx++ = i;
-       } while (--n);
+       }
        return bits;
 }