ntb: Add alignment check to meet hardware requirement

The NTB translate register must have the value to be BAR size aligned.
This alignment check make sure that the DMA memory allocated has the
proper alignment. Another requirement for NTB to function properly with
memory window BAR size greater or equal to 4M is to use the CMA feature
in 3.16 kernel with the appropriate CONFIG_CMA_ALIGNMENT and
CONFIG_CMA_SIZE_MBYTES set.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Jon Mason <jdmason@kudzu.us>

authored by Dave Jiang and committed by Jon Mason 3cc5ba19 9ef6bf6c

Changed files
+13
drivers
+13
drivers/ntb/ntb_transport.c
··· 576 576 return -ENOMEM; 577 577 } 578 578 579 + /* 580 + * we must ensure that the memory address allocated is BAR size 581 + * aligned in order for the XLAT register to take the value. This 582 + * is a requirement of the hardware. It is recommended to setup CMA 583 + * for BAR sizes equal or greater than 4MB. 584 + */ 585 + if (!IS_ALIGNED(mw->dma_addr, mw->size)) { 586 + dev_err(&pdev->dev, "DMA memory %pad not aligned to BAR size\n", 587 + &mw->dma_addr); 588 + ntb_free_mw(nt, num_mw); 589 + return -ENOMEM; 590 + } 591 + 579 592 /* Notify HW the memory location of the receive buffer */ 580 593 ntb_set_mw_addr(nt->ndev, num_mw, mw->dma_addr); 581 594