lkml.org 
[lkml]   [2021]   [Mar]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH v2 06/11] dma-direct: Support PCI P2PDMA pages in dma-direct map_sg
On Thu, Mar 11, 2021 at 04:31:36PM -0700, Logan Gunthorpe wrote:
> for_each_sg(sgl, sg, nents, i) {
> + if (is_pci_p2pdma_page(sg_page(sg))) {
> + if (sg_page(sg)->pgmap != pgmap) {
> + pgmap = sg_page(sg)->pgmap;
> + map = pci_p2pdma_dma_map_type(dev, pgmap);
> + bus_off = pci_p2pdma_bus_offset(sg_page(sg));
> + }
> +
> + if (map < 0) {
> + sg->dma_address = DMA_MAPPING_ERROR;
> + ret = -EREMOTEIO;
> + goto out_unmap;
> + }
> +
> + if (map) {
> + sg->dma_address = sg_phys(sg) + sg->offset -
> + bus_off;
> + sg_dma_len(sg) = sg->length;
> + sg_mark_pci_p2pdma(sg);
> + continue;
> + }
> + }

This code needs to go into a separate noinline helper to reduce the impact
on the fast path. Also as Robin noted the offset is already
accounted for in sg_phys. We also don't ever set the dma_address in
the scatterlist to DMA_MAPPING_ERROR, that is just a return value
for the single entry mapping routines.

\
 
 \ /
  Last update: 2021-03-16 09:13    [W:2.186 / U:0.000 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site