Skip to content

Commit

Permalink
Merge tag 'ntb-3.17' of git://github.com/jonmason/ntb
Browse files Browse the repository at this point in the history
Pull ntb driver bugfixes from Jon Mason:
 "NTB driver fixes for queue spread and buffer alignment.  Also, update
  to MAINTAINERS to reflect new e-mail address"

* tag 'ntb-3.17' of git://github.com/jonmason/ntb:
  ntb: Add alignment check to meet hardware requirement
  MAINTAINERS: update NTB info
  NTB: correct the spread of queues over mw's
  • Loading branch information
Linus Torvalds committed Sep 14, 2014
2 parents 8ac19f0 + 3cc5ba1 commit 02c1be3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
3 changes: 2 additions & 1 deletion MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -6424,7 +6424,8 @@ F: Documentation/scsi/NinjaSCSI.txt
F: drivers/scsi/nsp32*

NTB DRIVER
M: Jon Mason <jon.mason@intel.com>
M: Jon Mason <jdmason@kudzu.us>
M: Dave Jiang <dave.jiang@intel.com>
S: Supported
W: https://github.com/jonmason/ntb/wiki
T: git git://github.com/jonmason/ntb.git
Expand Down
17 changes: 15 additions & 2 deletions drivers/ntb/ntb_transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ static void ntb_transport_setup_qp_mw(struct ntb_transport *nt,

WARN_ON(nt->mw[mw_num].virt_addr == NULL);

if (nt->max_qps % mw_max && mw_num < nt->max_qps % mw_max)
if (nt->max_qps % mw_max && mw_num + 1 < nt->max_qps / mw_max)
num_qps_mw = nt->max_qps / mw_max + 1;
else
num_qps_mw = nt->max_qps / mw_max;
Expand Down Expand Up @@ -576,6 +576,19 @@ static int ntb_set_mw(struct ntb_transport *nt, int num_mw, unsigned int size)
return -ENOMEM;
}

/*
* we must ensure that the memory address allocated is BAR size
* aligned in order for the XLAT register to take the value. This
* is a requirement of the hardware. It is recommended to setup CMA
* for BAR sizes equal or greater than 4MB.
*/
if (!IS_ALIGNED(mw->dma_addr, mw->size)) {
dev_err(&pdev->dev, "DMA memory %pad not aligned to BAR size\n",
&mw->dma_addr);
ntb_free_mw(nt, num_mw);
return -ENOMEM;
}

/* Notify HW the memory location of the receive buffer */
ntb_set_mw_addr(nt->ndev, num_mw, mw->dma_addr);

Expand Down Expand Up @@ -856,7 +869,7 @@ static int ntb_transport_init_queue(struct ntb_transport *nt,
qp->client_ready = NTB_LINK_DOWN;
qp->event_handler = NULL;

if (nt->max_qps % mw_max && mw_num < nt->max_qps % mw_max)
if (nt->max_qps % mw_max && mw_num + 1 < nt->max_qps / mw_max)
num_qps_mw = nt->max_qps / mw_max + 1;
else
num_qps_mw = nt->max_qps / mw_max;
Expand Down

0 comments on commit 02c1be3

Please sign in to comment.