diff options
author | Joachim Fenkes <fenkes@de.ibm.com> | 2007-10-16 11:26:54 -0400 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2007-10-18 00:46:37 -0400 |
commit | 8c08d50d4fc52a9367c356ebbeb194c30fbc7ac8 (patch) | |
tree | eb1f102cd3a99b3f91b8923996a24f42e165543c | |
parent | 9511724da9c090da5a6dcf6c557b1cedc4f5cfd7 (diff) |
IB/ehca: Fix ehca_encode_hwpage_size() and alloc_fmr()
Simplify ehca_encode_hwpage_size(), fixing an infinite loop for pgsize == 0
in the process. Fix the bug in alloc_fmr() that triggered the loop.
Signed-off-by: Joachim Fenkes <fenkes@de.ibm.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
-rw-r--r-- | drivers/infiniband/hw/ehca/ehca_mrmw.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/drivers/infiniband/hw/ehca/ehca_mrmw.c b/drivers/infiniband/hw/ehca/ehca_mrmw.c index 16c9efd8eeac..b9a788c4fdd1 100644 --- a/drivers/infiniband/hw/ehca/ehca_mrmw.c +++ b/drivers/infiniband/hw/ehca/ehca_mrmw.c | |||
@@ -72,17 +72,9 @@ enum ehca_mr_pgsize { | |||
72 | 72 | ||
73 | static u32 ehca_encode_hwpage_size(u32 pgsize) | 73 | static u32 ehca_encode_hwpage_size(u32 pgsize) |
74 | { | 74 | { |
75 | u32 idx = 0; | 75 | int log = ilog2(pgsize); |
76 | pgsize >>= 12; | 76 | WARN_ON(log < 12 || log > 24 || log & 3); |
77 | /* | 77 | return (log - 12) / 4; |
78 | * map mr page size into hw code: | ||
79 | * 0, 1, 2, 3 for 4K, 64K, 1M, 64M | ||
80 | */ | ||
81 | while (!(pgsize & 1)) { | ||
82 | idx++; | ||
83 | pgsize >>= 4; | ||
84 | } | ||
85 | return idx; | ||
86 | } | 78 | } |
87 | 79 | ||
88 | static u64 ehca_get_max_hwpage_size(struct ehca_shca *shca) | 80 | static u64 ehca_get_max_hwpage_size(struct ehca_shca *shca) |
@@ -826,6 +818,7 @@ struct ib_fmr *ehca_alloc_fmr(struct ib_pd *pd, | |||
826 | 818 | ||
827 | /* register MR on HCA */ | 819 | /* register MR on HCA */ |
828 | memset(&pginfo, 0, sizeof(pginfo)); | 820 | memset(&pginfo, 0, sizeof(pginfo)); |
821 | pginfo.hwpage_size = hw_pgsize; | ||
829 | /* | 822 | /* |
830 | * pginfo.num_hwpages==0, ie register_rpages() will not be called | 823 | * pginfo.num_hwpages==0, ie register_rpages() will not be called |
831 | * but deferred to map_phys_fmr() | 824 | * but deferred to map_phys_fmr() |