Skip to content

Commit

Permalink
gru: support contexts with zero dsrs or cbrs
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Jack Steiner authored and torvalds committed Jun 18, 2009
1 parent 836ce67 commit 3eac2e9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions drivers/misc/sgi-gru/grufile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions drivers/misc/sgi-gru/grumain.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,15 @@ 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();
__clear_bit(i, p);
__set_bit(i, &bits);
if (idx)
*idx++ = i;
} while (--n);
}
return bits;
}

Expand Down

0 comments on commit 3eac2e9

Please sign in to comment.