HFI1: use original length calculation in sdma_send_pkts()

Conflicts:
	kernel/include/hfi1/sdma.h
This commit is contained in:
Balazs Gerofi
2017-08-17 14:07:59 +09:00
parent 60f6862db2
commit 3b5363c533
2 changed files with 37 additions and 47 deletions

View File

@ -736,7 +736,6 @@ static inline int _sdma_txadd_daddr(
return rval; return rval;
} }
#ifdef __HFI1_ORIG__
/** /**
* sdma_txadd_page() - add a page to the sdma_txreq * sdma_txadd_page() - add a page to the sdma_txreq
* @dd: the device to use for mapping * @dd: the device to use for mapping
@ -756,12 +755,18 @@ static inline int _sdma_txadd_daddr(
static inline int sdma_txadd_page( static inline int sdma_txadd_page(
struct hfi1_devdata *dd, struct hfi1_devdata *dd,
struct sdma_txreq *tx, struct sdma_txreq *tx,
#ifdef __HFI1_ORIG__
struct page *page, struct page *page,
unsigned long offset, unsigned long offset,
#else
void *virt,
#endif
u16 len) u16 len)
{ {
dma_addr_t addr; dma_addr_t addr;
int rval; int rval;
#ifdef __HFI1_ORIG__
/* TODO: check this coealesce thing */
hfi1_cdbg(AIOWRITE, "+"); hfi1_cdbg(AIOWRITE, "+");
if ((unlikely(tx->num_desc == tx->desc_limit))) { if ((unlikely(tx->num_desc == tx->desc_limit))) {
rval = ext_coal_sdma_tx_descs(dd, tx, SDMA_MAP_PAGE, rval = ext_coal_sdma_tx_descs(dd, tx, SDMA_MAP_PAGE,
@ -783,10 +788,25 @@ static inline int sdma_txadd_page(
} }
hfi1_cdbg(AIOWRITE, "-"); hfi1_cdbg(AIOWRITE, "-");
#else
if (ihk_mc_pt_virt_to_phys(
cpu_local_var(current)->vm->address_space->page_table,
virt, &addr) < 0) {
/* TODO: shall we make this function fail? *
* Handle this error. */
kprintf("%s: ERROR: virt_to_phys failed - virt = 0x%lx\n",
__FUNCTION__, virt);
return -EFAULT;
}
#endif
/*
* XXX: It seems that this is the place where the reference to
* the payload is added, but addr is kernel virtual here.
* TODO: verify this by printing it out in Linux.
*/
return _sdma_txadd_daddr( return _sdma_txadd_daddr(
dd, SDMA_MAP_PAGE, tx, addr, len); dd, SDMA_MAP_PAGE, tx, addr, len);
} }
#endif /* __HFI1_ORIG__ */
/** /**
* sdma_txadd_daddr() - add a dma address to the sdma_txreq * sdma_txadd_daddr() - add a dma address to the sdma_txreq

View File

@ -1130,7 +1130,8 @@ static int user_sdma_send_pkts(struct user_sdma_request *req, unsigned maxpkts)
while (npkts < maxpkts) { while (npkts < maxpkts) {
u32 datalen = 0, queued = 0, data_sent = 0; u32 datalen = 0, queued = 0, data_sent = 0;
//u64 iov_offset = 0; unsigned long base_phys;
u64 iov_offset = 0;
//TODO: enable test_bit //TODO: enable test_bit
#ifdef __HFI1_ORIG__ #ifdef __HFI1_ORIG__
@ -1275,76 +1276,47 @@ static int user_sdma_send_pkts(struct user_sdma_request *req, unsigned maxpkts)
TP("+ If the request contains any data vectors, add up to fragsize bytes to the descriptor."); TP("+ If the request contains any data vectors, add up to fragsize bytes to the descriptor.");
while (queued < datalen && while (queued < datalen &&
(req->sent + data_sent) < req->data_len) { (req->sent + data_sent) < req->data_len) {
#ifdef __HFI1_ORIG__
unsigned pageidx, len; unsigned pageidx, len;
unsigned long base, offset; unsigned long base, offset;
const void *virt;
base = (unsigned long)iovec->iov.iov_base; base = (unsigned long)iovec->iov.iov_base;
offset = offset_in_page(base + iovec->offset + offset = offset_in_page(base + iovec->offset +
iov_offset); iov_offset);
virt = base + iovec->offset + iov_offset;
pageidx = (((iovec->offset + iov_offset + pageidx = (((iovec->offset + iov_offset +
base) - (base & PAGE_MASK)) >> PAGE_SHIFT); base) - (base & PAGE_MASK)) >> PAGE_SHIFT);
len = offset + req->info.fragsize > PAGE_SIZE ? len = offset + req->info.fragsize > PAGE_SIZE ?
PAGE_SIZE - offset : req->info.fragsize; PAGE_SIZE - offset : req->info.fragsize;
len = min((datalen - queued), len); len = min((datalen - queued), len);
SDMA_DBG("%s: dl: %d, qd: %d, len: %d\n",
__FUNCTION__, datalen, queued, len);
ret = sdma_txadd_page(pq->dd, &tx->txreq, ret = sdma_txadd_page(pq->dd, &tx->txreq,
iovec->pages[pageidx], #ifdef __HFI1_ORIG__
offset, len); iovec->pages[pageidx], offset,
#else #else
struct sdma_txreq *txreq = &tx->txreq; virt,
if ((unlikely(txreq->num_desc == txreq->desc_limit))) { #endif
kprintf("%s: ERROR: ext_coal_sdma_tx_descs() should have been called here\n", len);
__FUNCTION__);
}
unsigned long base;
const void *virt = (unsigned long)iovec->iov.iov_base + iovec->offset;
WARN_ON(iovec->iov.iov_len < iovec->offset);
unsigned len = (unsigned)iovec->iov.iov_len - iovec->offset;
len = min(((unsigned long)virt & PAGE_MASK)
+ PAGE_SIZE - (unsigned long)virt, len);
len = min(req->info.fragsize, len);
len = min(txreq->tlen, len);
len = min((datalen - queued), len);
if (len) {
if (ihk_mc_pt_virt_to_phys(cpu_local_var(current)->vm->address_space->page_table, virt, &base) < 0) {
/* TODO: shall we make this function fail? *
* Handle this error. */
kprintf("%s: ERROR: virt_to_phys failed - virt = 0x%lx, iovec->iov.iov_base = 0x%lx\n",
__FUNCTION__, virt, iovec->iov.iov_base);
return 0;
}
ret = _sdma_txadd_daddr(pq->dd, SDMA_MAP_PAGE, txreq, base, len);
if (ret) {
kprintf("%s: ERROR _sdma_txadd_daddr()", __FUNCTION__);
return 0;
}
else {
//kprintf("%s: txadd: base = 0x%lx, len = %d\n", __FUNCTION__, base, len);
}
}
TP("- custom sdma_txadd_page");
#endif /* __HFI1_ORIG__ */
if (ret) { if (ret) {
SDMA_DBG(req, "SDMA txreq add page failed %d\n", SDMA_DBG(req, "SDMA txreq add page failed %d\n",
ret); ret);
goto free_txreq; goto free_txreq;
} }
#ifdef __HFI1_ORIG__
iov_offset += len; iov_offset += len;
#else
iovec->offset += len;
#endif /* __HFI1_ORIG__ */
queued += len; queued += len;
data_sent += len; data_sent += len;
#ifdef __HFI1_ORIG__
if (unlikely(queued < datalen && if (unlikely(queued < datalen &&
#ifdef __HFI1_ORIG__
pageidx == iovec->npages && pageidx == iovec->npages &&
#else
iov_offset == iovec->iov.iov_len &&
#endif /* __HFI1_ORIG__ */
req->iov_idx < req->data_iovs - 1)) { req->iov_idx < req->data_iovs - 1)) {
iovec->offset += iov_offset; iovec->offset += iov_offset;
iovec = &req->iovs[++req->iov_idx]; iovec = &req->iovs[++req->iov_idx];
iov_offset = 0; iov_offset = 0;
} }
#endif /* __HFI1_ORIG__ */
} }
TP("- If the request contains any data vectors, add up to fragsize bytes to the descriptor."); TP("- If the request contains any data vectors, add up to fragsize bytes to the descriptor.");
/* /*
@ -1355,10 +1327,8 @@ static int user_sdma_send_pkts(struct user_sdma_request *req, unsigned maxpkts)
if (req_opcode(req->info.ctrl) == EXPECTED) if (req_opcode(req->info.ctrl) == EXPECTED)
req->tidoffset += datalen; req->tidoffset += datalen;
req->sent += data_sent; req->sent += data_sent;
#ifdef __HFI1_ORIG__
if (req->data_len) if (req->data_len)
iovec->offset += iov_offset; iovec->offset += iov_offset;
#endif /* __HFI1_ORIG__ */
list_add_tail(&tx->txreq.list, &req->txps); list_add_tail(&tx->txreq.list, &req->txps);
/* /*
* It is important to increment this here as it is used to * It is important to increment this here as it is used to