32 #include <linux/slab.h>
33 #include <asm/byteorder.h>
51 PDBG(
"%s mmid 0x%x mhp %p\n", __func__, mmid, mhp);
52 return insert_handle(mhp->
rhp, &mhp->
rhp->mmidr, mhp, mmid);
62 &stag, mhp->
attr.pdid,
68 mhp->
attr.pbl_size, mhp->
attr.pbl_addr))
71 ret = iwch_finish_mem_reg(mhp, stag);
87 if (npages > mhp->
attr.pbl_size)
90 stag = mhp->
attr.stag;
92 &stag, mhp->
attr.pdid,
98 mhp->
attr.pbl_size, mhp->
attr.pbl_addr))
101 ret = iwch_finish_mem_reg(mhp, stag);
114 if (!mhp->
attr.pbl_addr)
117 mhp->
attr.pbl_size = npages;
125 mhp->
attr.pbl_size << 3);
131 mhp->
attr.pbl_addr + (offset << 3), npages);
147 for (i = 0; i < num_phys_buf; ++
i) {
150 if (i != 0 && i != num_phys_buf - 1 &&
153 *total_size += buffer_list[
i].
size;
155 mask |= buffer_list[
i].
addr;
158 if (i != num_phys_buf - 1)
159 mask |= buffer_list[
i].
addr + buffer_list[
i].
size;
161 mask |= (buffer_list[
i].
addr + buffer_list[
i].
size +
165 if (*total_size > 0xFFFFFFFFULL)
169 for (*shift =
PAGE_SHIFT; *shift < 27; ++(*shift))
170 if ((1ULL << *shift) &
mask)
173 buffer_list[0].
size += buffer_list[0].
addr & ((1ULL << *shift) - 1);
174 buffer_list[0].
addr &= ~0ull << *shift;
177 for (i = 0; i < num_phys_buf; ++
i)
178 *npages += (buffer_list[i].
size +
179 (1ULL << *shift) - 1) >> *shift;
189 for (i = 0; i < num_phys_buf; ++
i)
191 j < (buffer_list[
i].
size + (1ULL << *shift) - 1) >> *shift;
194 ((
u64) j << *shift));
196 PDBG(
"%s va 0x%llx mask 0x%llx shift %d len %lld pbl_size %d\n",
197 __func__, (
unsigned long long) *iova_start,
198 (
unsigned long long) mask, *shift, (
unsigned long long) *total_size,