Skip to content

Commit

Permalink
libxdma.c: Bug fix Xilinx/dma_ip_drivers#48
Browse files Browse the repository at this point in the history
This is a minimal implementation based on [1] that matches the existing
code style for handling the page crossing edge case. Previously only one
place in the code correctly handled adjacent descriptors crossing a page
boundary, but now that code is copied to the other relevant places too.

We hit this case when attempting to re-load ELF files after a few
attempts, at least with my CheriBSD image.

[1] Xilinx/dma_ip_drivers#49
  • Loading branch information
jrtc27 committed Jun 30, 2020
1 parent bae15da commit 7a43fc1
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions drivers/pcieportal/libxdma.c
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,10 @@ static struct xdma_transfer *engine_start(struct xdma_engine *engine)
u32 w;
int extra_adj = 0;
int rv;
/* BEGIN CONNECTAL */
/* See https://github.com/Xilinx/dma_ip_drivers/pull/49 */
u32 max_adj_4k = 0;
/* END CONNECTAL */

if (!engine) {
pr_err("dma engine NULL\n");
Expand Down Expand Up @@ -705,6 +709,14 @@ static struct xdma_transfer *engine_start(struct xdma_engine *engine)
extra_adj = transfer->desc_adjacent - 1;
if (extra_adj > MAX_EXTRA_ADJ)
extra_adj = MAX_EXTRA_ADJ;
/* BEGIN CONNECTAL */
/* See https://github.com/Xilinx/dma_ip_drivers/pull/49 */
max_adj_4k =
(0x1000 - (transfer->desc_bus & 0xFFF)) / 32 -
1;
if (extra_adj > max_adj_4k)
extra_adj = max_adj_4k;
/* END CONNECTAL */
}
dbg_tfr("iowrite32(0x%08x to 0x%p) (first_desc_adjacent)\n", extra_adj,
(void *)&engine->sgdma_regs->first_desc_adjacent);
Expand Down Expand Up @@ -2453,6 +2465,10 @@ static int transfer_desc_init(struct xdma_transfer *transfer, int count)
int adj = count - 1;
int extra_adj;
u32 temp_control;
/* BEGIN CONNECTAL */
/* See https://github.com/Xilinx/dma_ip_drivers/pull/49 */
u32 max_adj_4k = 0;
/* END CONNECTAL */

if (count > XDMA_TRANSFER_MAX_DESC) {
pr_err("Engine cannot transfer more than %d descriptors\n",
Expand All @@ -2475,6 +2491,14 @@ static int transfer_desc_init(struct xdma_transfer *transfer, int count)
extra_adj = adj - 1;
if (extra_adj > MAX_EXTRA_ADJ)
extra_adj = MAX_EXTRA_ADJ;
/* BEGIN CONNECTAL */
/* See https://github.com/Xilinx/dma_ip_drivers/pull/49 */
max_adj_4k =
(0x1000 - (desc_bus & 0xFFF)) / 32 -
1;
if (extra_adj > max_adj_4k)
extra_adj = max_adj_4k;
/* END CONNECTAL */

adj--;
} else {
Expand Down

0 comments on commit 7a43fc1

Please sign in to comment.