Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 105655
b: refs/heads/master
c: 1fa6d81
h: refs/heads/master
i:
  105653: 4a8a64f
  105651: b7f5c50
  105647: c451939
v: v3
  • Loading branch information
Roland Dreier committed Jul 23, 2008
1 parent d705f60 commit 7b5d335
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 22 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e8bb4beb2b1f90d499134f2849727ed04c3bedc4
refs/heads/master: 1fa6d8181b7bb0361512170c30e436dcc95591ee
2 changes: 0 additions & 2 deletions trunk/MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -2915,8 +2915,6 @@ P: Faisal Latif
M: flatif@neteffect.com
P: Chien Tung
M: ctung@neteffect.com
P: Glenn Streiff
M: gstreiff@neteffect.com
L: general@lists.openfabrics.org
W: http://www.neteffect.com
S: Supported
Expand Down
1 change: 0 additions & 1 deletion trunk/drivers/infiniband/hw/mthca/mthca_dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ struct mthca_pd_table {

struct mthca_buddy {
unsigned long **bits;
int *num_free;
int max_order;
spinlock_t lock;
};
Expand Down
26 changes: 8 additions & 18 deletions trunk/drivers/infiniband/hw/mthca/mthca_mr.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,26 +89,23 @@ static u32 mthca_buddy_alloc(struct mthca_buddy *buddy, int order)

spin_lock(&buddy->lock);

for (o = order; o <= buddy->max_order; ++o)
if (buddy->num_free[o]) {
m = 1 << (buddy->max_order - o);
seg = find_first_bit(buddy->bits[o], m);
if (seg < m)
goto found;
}
for (o = order; o <= buddy->max_order; ++o) {
m = 1 << (buddy->max_order - o);
seg = find_first_bit(buddy->bits[o], m);
if (seg < m)
goto found;
}

spin_unlock(&buddy->lock);
return -1;

found:
clear_bit(seg, buddy->bits[o]);
--buddy->num_free[o];

while (o > order) {
--o;
seg <<= 1;
set_bit(seg ^ 1, buddy->bits[o]);
++buddy->num_free[o];
}

spin_unlock(&buddy->lock);
Expand All @@ -126,13 +123,11 @@ static void mthca_buddy_free(struct mthca_buddy *buddy, u32 seg, int order)

while (test_bit(seg ^ 1, buddy->bits[order])) {
clear_bit(seg ^ 1, buddy->bits[order]);
--buddy->num_free[order];
seg >>= 1;
++order;
}

set_bit(seg, buddy->bits[order]);
++buddy->num_free[order];

spin_unlock(&buddy->lock);
}
Expand All @@ -146,9 +141,7 @@ static int mthca_buddy_init(struct mthca_buddy *buddy, int max_order)

buddy->bits = kzalloc((buddy->max_order + 1) * sizeof (long *),
GFP_KERNEL);
buddy->num_free = kzalloc((buddy->max_order + 1) * sizeof (int *),
GFP_KERNEL);
if (!buddy->bits || !buddy->num_free)
if (!buddy->bits)
goto err_out;

for (i = 0; i <= buddy->max_order; ++i) {
Expand All @@ -161,18 +154,16 @@ static int mthca_buddy_init(struct mthca_buddy *buddy, int max_order)
}

set_bit(0, buddy->bits[buddy->max_order]);
buddy->num_free[buddy->max_order] = 1;

return 0;

err_out_free:
for (i = 0; i <= buddy->max_order; ++i)
kfree(buddy->bits[i]);

err_out:
kfree(buddy->bits);
kfree(buddy->num_free);

err_out:
return -ENOMEM;
}

Expand All @@ -184,7 +175,6 @@ static void mthca_buddy_cleanup(struct mthca_buddy *buddy)
kfree(buddy->bits[i]);

kfree(buddy->bits);
kfree(buddy->num_free);
}

static u32 mthca_alloc_mtt_range(struct mthca_dev *dev, int order,
Expand Down

0 comments on commit 7b5d335

Please sign in to comment.