Re: [patch] zero-bounce highmem I/O

David S. Miller (davem@redhat.com)
Thu, 16 Aug 2001 07:15:19 -0700 (PDT)


From: Gerd Knorr <kraxel@bytesex.org>
Date: Thu, 16 Aug 2001 15:35:41 +0200

> To be honest, you really shouldn't care about this. If you are
> writing a block device, the block/scsi/ide/whatever layer should take
> care to only give you memory that can be DMA'd to/from.
>
> Same goes for the networking layer.

bttv is neither blkdev nor networking ...

It is video layer, and the video layer should be helping along with
these sorts of issues.

The video layer should provide PCI device helpers which allow the
drivers to just do something like:

struct scatterlist *video_pci_get_user_pages(struct pci_dev *pdev,
int npages);

void video_pci_put_user_pages(struct pci_dev *pdev,
struct scatterlist *sg,
int npages);

The scatter list returned (NULL indicates failure, ala -ENOMEM)
will tell the driver everything it needs to know. Let us define
it as follows:

SG entry 0
address == base of vmalloc()'d area

SG entry 0 ... NPAGES
sg_dma_address(sg) = dma_address for that page
sg_dma_len(sg) = dma_length, usually PAGE_SIZE

sg_dma_len could be something larger than PAGE_SIZE if the
platform has a way of using virtual mappings in PCI space.
You would simply give the device DMA address/len pairs from
the SG array until you either hit the NPAGES entry or you
see a dma_len of zero.

I realize this does not address the kiovec based scheme you
are experimenting with now, but this does deal with the biggest
problem the video layer has right now wrt. portability.

In fact, this isn't even a video layer issue, and the kernel
ought to provide my suggested interfaces in some generic
place.

Later,
David S. Miller
davem@redhat.com
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/