Skip to content

Commit ddd3736

Browse files
caseorumlgirdwood
authored andcommitted
ipc: Use DMA attribute for min. ptable copy size
This rounds up the page table DMA transfer size to DMA_ATTR_COPY_ALIGNMENT instead of a hard-coded 4 bytes. Signed-off-by: Joseph Burt <caseorum@gmail.com>
1 parent 1edfe08 commit ddd3736

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/ipc/ipc-host-ptable.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ static int ipc_get_page_descriptors(struct dma *dmac, uint8_t *page_table,
8787
struct dma_sg_config config;
8888
struct dma_sg_elem elem;
8989
struct dma_chan_data *chan;
90+
uint32_t dma_copy_align;
9091
int ret = 0;
9192

9293
/* get DMA channel from DMAC */
@@ -109,8 +110,14 @@ static int ipc_get_page_descriptors(struct dma *dmac, uint8_t *page_table,
109110
elem.src = ring->phy_addr;
110111

111112
/* source buffer size is always PAGE_SIZE bytes */
112-
/* 20 bits for each page, round up to 32 */
113-
elem.size = 4 * ((ring->pages * 20 + 31) / 32);
113+
/* 20 bits for each page, round up to minimum DMA copy size */
114+
ret = dma_get_attribute(dmac, DMA_ATTR_COPY_ALIGNMENT, &dma_copy_align);
115+
if (ret < 0) {
116+
tr_err(&ipc_tr, "ipc_get_page_descriptors(): dma_get_attribute() failed");
117+
goto out;
118+
}
119+
elem.size = (ring->pages * 20 + 7) / 8;
120+
elem.size = ALIGN_UP(elem.size, dma_copy_align);
114121
config.elem_array.elems = &elem;
115122
config.elem_array.count = 1;
116123

0 commit comments

Comments
 (0)