svn commit: r289346 - head/sys/dev/ntb/if_ntb
Conrad E. Meyer
cem at FreeBSD.org
Wed Oct 14 23:47:53 UTC 2015
Author: cem
Date: Wed Oct 14 23:47:52 2015
New Revision: 289346
URL: https://svnweb.freebsd.org/changeset/base/289346
Log:
if_ntb: MFV 3cc5ba19: Add alignment check to meet hardware requirement
Original Linux commit log:
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.
Authored by: Dave Jiang
Obtained from: Linux (Dual BSD/GPL driver)
Sponsored by: EMC / Isilon Storage Division
Modified:
head/sys/dev/ntb/if_ntb/if_ntb.c
Modified: head/sys/dev/ntb/if_ntb/if_ntb.c
==============================================================================
--- head/sys/dev/ntb/if_ntb/if_ntb.c Wed Oct 14 23:47:35 2015 (r289345)
+++ head/sys/dev/ntb/if_ntb/if_ntb.c Wed Oct 14 23:47:52 2015 (r289346)
@@ -1163,13 +1163,26 @@ ntb_set_mw(struct ntb_netdev *nt, int nu
BUS_SPACE_MAXADDR, mw->size, 0);
if (mw->virt_addr == NULL) {
mw->size = 0;
- printf("ntb: Unable to allocate MW buffer of size %d\n",
- (int)mw->size);
+ printf("ntb: Unable to allocate MW buffer of size %zu\n",
+ mw->size);
return (ENOMEM);
}
/* TODO: replace with bus_space_* functions */
mw->dma_addr = vtophys(mw->virt_addr);
+ /*
+ * Ensure that the allocation from contigmalloc is aligned as
+ * requested. XXX: This may not be needed -- brought in for parity
+ * with the Linux driver.
+ */
+ if (mw->dma_addr % size != 0) {
+ device_printf(ntb_get_device(nt->ntb),
+ "DMA memory 0x%jx not aligned to BAR size 0x%x\n",
+ (uintmax_t)mw->dma_addr, size);
+ ntb_free_mw(nt, num_mw);
+ return (ENOMEM);
+ }
+
/* Notify HW the memory location of the receive buffer */
ntb_set_mw_addr(nt->ntb, num_mw, mw->dma_addr);
More information about the svn-src-all
mailing list