Creating a page pool on open requires knowing the DMA direction. We want BIDI if an XDP program is loaded (because it might modify and XDP_TX the buffer) and only need FROM_DEVICE otherwise. However, we do not reopen on .ndo_bpf() to load an XDP program. This means the DMA direction might be wrong. Options: - Reopen on XDP program load if no program was loaded before. - Always use BIDI. Option 2 shows no reproducible performance costs on my target. It implies an additional dma_sync_single_for_device() when page pool buffers are recycled; see __page_pool_put_page(). Signed-off-by: Théo Lebrun --- drivers/net/ethernet/cadence/macb_main.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index 918eee5c8a5b..05bbbaf260ce 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -1582,7 +1582,7 @@ static int gem_rx(struct macb_queue *queue, struct napi_struct *napi, dma_sync_single_for_cpu(&bp->pdev->dev, addr, bp->rx_buffer_size, - page_pool_get_dma_dir(queue->page_pool)); + DMA_BIDIRECTIONAL); /* Ensure ctrl is at least as up-to-date as rxused */ dma_rmb(); @@ -2867,9 +2867,7 @@ static int gem_create_page_pool(struct macb_queue *queue, int qid) .flags = PP_FLAG_DMA_MAP | PP_FLAG_DMA_SYNC_DEV, .pool_size = queue->bp->rx_ring_size, .nid = NUMA_NO_NODE, - .dma_dir = rcu_access_pointer(queue->bp->prog) - ? DMA_BIDIRECTIONAL - : DMA_FROM_DEVICE, + .dma_dir = DMA_BIDIRECTIONAL, .dev = &queue->bp->pdev->dev, .napi = &queue->napi_rx, .max_len = PAGE_SIZE, -- 2.53.0