Commit 52f00dd3 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Doug Ledford

ehca: stop using struct ib_phys_buf

And simplify the calling convention for full-memory registrations.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarSagi Grimberg <sagig@mellanox.com>
Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com> [core]
Reviewed-by: default avatarSteve Wise <swise@opengridcomputing.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 33f09219
...@@ -316,9 +316,8 @@ struct ehca_mr_pginfo { ...@@ -316,9 +316,8 @@ struct ehca_mr_pginfo {
union { union {
struct { /* type EHCA_MR_PGI_PHYS section */ struct { /* type EHCA_MR_PGI_PHYS section */
int num_phys_buf; u64 addr;
struct ib_phys_buf *phys_buf_array; u16 size;
u64 next_buf;
} phy; } phy;
struct { /* type EHCA_MR_PGI_USER section */ struct { /* type EHCA_MR_PGI_USER section */
struct ib_umem *region; struct ib_umem *region;
......
...@@ -1289,7 +1289,6 @@ int ehca_reg_internal_maxmr( ...@@ -1289,7 +1289,6 @@ int ehca_reg_internal_maxmr(
u64 *iova_start; u64 *iova_start;
u64 size_maxmr; u64 size_maxmr;
struct ehca_mr_pginfo pginfo; struct ehca_mr_pginfo pginfo;
struct ib_phys_buf ib_pbuf;
u32 num_kpages; u32 num_kpages;
u32 num_hwpages; u32 num_hwpages;
u64 hw_pgsize; u64 hw_pgsize;
...@@ -1310,8 +1309,6 @@ int ehca_reg_internal_maxmr( ...@@ -1310,8 +1309,6 @@ int ehca_reg_internal_maxmr(
/* register internal max-MR on HCA */ /* register internal max-MR on HCA */
size_maxmr = ehca_mr_len; size_maxmr = ehca_mr_len;
iova_start = (u64 *)ehca_map_vaddr((void *)(KERNELBASE + PHYSICAL_START)); iova_start = (u64 *)ehca_map_vaddr((void *)(KERNELBASE + PHYSICAL_START));
ib_pbuf.addr = 0;
ib_pbuf.size = size_maxmr;
num_kpages = NUM_CHUNKS(((u64)iova_start % PAGE_SIZE) + size_maxmr, num_kpages = NUM_CHUNKS(((u64)iova_start % PAGE_SIZE) + size_maxmr,
PAGE_SIZE); PAGE_SIZE);
hw_pgsize = ehca_get_max_hwpage_size(shca); hw_pgsize = ehca_get_max_hwpage_size(shca);
...@@ -1323,8 +1320,8 @@ int ehca_reg_internal_maxmr( ...@@ -1323,8 +1320,8 @@ int ehca_reg_internal_maxmr(
pginfo.num_kpages = num_kpages; pginfo.num_kpages = num_kpages;
pginfo.num_hwpages = num_hwpages; pginfo.num_hwpages = num_hwpages;
pginfo.hwpage_size = hw_pgsize; pginfo.hwpage_size = hw_pgsize;
pginfo.u.phy.num_phys_buf = 1; pginfo.u.phy.addr = 0;
pginfo.u.phy.phys_buf_array = &ib_pbuf; pginfo.u.phy.size = size_maxmr;
ret = ehca_reg_mr(shca, e_mr, iova_start, size_maxmr, 0, e_pd, ret = ehca_reg_mr(shca, e_mr, iova_start, size_maxmr, 0, e_pd,
&pginfo, &e_mr->ib.ib_mr.lkey, &pginfo, &e_mr->ib.ib_mr.lkey,
...@@ -1620,57 +1617,54 @@ static int ehca_set_pagebuf_phys(struct ehca_mr_pginfo *pginfo, ...@@ -1620,57 +1617,54 @@ static int ehca_set_pagebuf_phys(struct ehca_mr_pginfo *pginfo,
u32 number, u64 *kpage) u32 number, u64 *kpage)
{ {
int ret = 0; int ret = 0;
struct ib_phys_buf *pbuf; u64 addr = pginfo->u.phy.addr;
u64 size = pginfo->u.phy.size;
u64 num_hw, offs_hw; u64 num_hw, offs_hw;
u32 i = 0; u32 i = 0;
/* loop over desired phys_buf_array entries */ num_hw = NUM_CHUNKS((addr % pginfo->hwpage_size) + size,
while (i < number) { pginfo->hwpage_size);
pbuf = pginfo->u.phy.phys_buf_array + pginfo->u.phy.next_buf; offs_hw = (addr & ~(pginfo->hwpage_size - 1)) / pginfo->hwpage_size;
num_hw = NUM_CHUNKS((pbuf->addr % pginfo->hwpage_size) +
pbuf->size, pginfo->hwpage_size); while (pginfo->next_hwpage < offs_hw + num_hw) {
offs_hw = (pbuf->addr & ~(pginfo->hwpage_size - 1)) / /* sanity check */
pginfo->hwpage_size; if ((pginfo->kpage_cnt >= pginfo->num_kpages) ||
while (pginfo->next_hwpage < offs_hw + num_hw) { (pginfo->hwpage_cnt >= pginfo->num_hwpages)) {
/* sanity check */ ehca_gen_err("kpage_cnt >= num_kpages, "
if ((pginfo->kpage_cnt >= pginfo->num_kpages) || "kpage_cnt=%llx num_kpages=%llx "
(pginfo->hwpage_cnt >= pginfo->num_hwpages)) { "hwpage_cnt=%llx "
ehca_gen_err("kpage_cnt >= num_kpages, " "num_hwpages=%llx i=%x",
"kpage_cnt=%llx num_kpages=%llx " pginfo->kpage_cnt,
"hwpage_cnt=%llx " pginfo->num_kpages,
"num_hwpages=%llx i=%x", pginfo->hwpage_cnt,
pginfo->kpage_cnt, pginfo->num_hwpages, i);
pginfo->num_kpages, return -EFAULT;
pginfo->hwpage_cnt,
pginfo->num_hwpages, i);
return -EFAULT;
}
*kpage = (pbuf->addr & ~(pginfo->hwpage_size - 1)) +
(pginfo->next_hwpage * pginfo->hwpage_size);
if ( !(*kpage) && pbuf->addr ) {
ehca_gen_err("pbuf->addr=%llx pbuf->size=%llx "
"next_hwpage=%llx", pbuf->addr,
pbuf->size, pginfo->next_hwpage);
return -EFAULT;
}
(pginfo->hwpage_cnt)++;
(pginfo->next_hwpage)++;
if (PAGE_SIZE >= pginfo->hwpage_size) {
if (pginfo->next_hwpage %
(PAGE_SIZE / pginfo->hwpage_size) == 0)
(pginfo->kpage_cnt)++;
} else
pginfo->kpage_cnt += pginfo->hwpage_size /
PAGE_SIZE;
kpage++;
i++;
if (i >= number) break;
} }
if (pginfo->next_hwpage >= offs_hw + num_hw) { *kpage = (addr & ~(pginfo->hwpage_size - 1)) +
(pginfo->u.phy.next_buf)++; (pginfo->next_hwpage * pginfo->hwpage_size);
pginfo->next_hwpage = 0; if ( !(*kpage) && addr ) {
ehca_gen_err("addr=%llx size=%llx "
"next_hwpage=%llx", addr,
size, pginfo->next_hwpage);
return -EFAULT;
} }
(pginfo->hwpage_cnt)++;
(pginfo->next_hwpage)++;
if (PAGE_SIZE >= pginfo->hwpage_size) {
if (pginfo->next_hwpage %
(PAGE_SIZE / pginfo->hwpage_size) == 0)
(pginfo->kpage_cnt)++;
} else
pginfo->kpage_cnt += pginfo->hwpage_size /
PAGE_SIZE;
kpage++;
i++;
if (i >= number) break;
}
if (pginfo->next_hwpage >= offs_hw + num_hw) {
pginfo->next_hwpage = 0;
} }
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment