Skip to content

Commit

Permalink
ieee1394: speed up of dma_region_sync_for_cpu
Browse files Browse the repository at this point in the history
when attempting to find the 'last' part of the dma region continue the
search from where we left off, instead of starting the search over.

Signed-off-by: Jim Westfall <jwestfall@surrealistic.net>
Signed-off-by: Ben Collins <bcollins@ubuntu.com>
  • Loading branch information
Ben Collins committed Jun 12, 2006
1 parent f54b1bd commit 9bb2bcd
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions drivers/ieee1394/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,12 @@ void dma_region_free(struct dma_region *dma)
/* find the scatterlist index and remaining offset corresponding to a
given offset from the beginning of the buffer */
static inline int dma_region_find(struct dma_region *dma, unsigned long offset,
unsigned long *rem)
unsigned int start, unsigned long *rem)
{
int i;
unsigned long off = offset;

for (i = 0; i < dma->n_dma_pages; i++) {
for (i = start; i < dma->n_dma_pages; i++) {
if (off < sg_dma_len(&dma->sglist[i])) {
*rem = off;
break;
Expand All @@ -170,21 +170,21 @@ dma_addr_t dma_region_offset_to_bus(struct dma_region * dma,
unsigned long rem = 0;

struct scatterlist *sg =
&dma->sglist[dma_region_find(dma, offset, &rem)];
&dma->sglist[dma_region_find(dma, offset, 0, &rem)];
return sg_dma_address(sg) + rem;
}

void dma_region_sync_for_cpu(struct dma_region *dma, unsigned long offset,
unsigned long len)
{
int first, last;
unsigned long rem;
unsigned long rem = 0;

if (!len)
len = 1;

first = dma_region_find(dma, offset, &rem);
last = dma_region_find(dma, offset + len - 1, &rem);
first = dma_region_find(dma, offset, 0, &rem);
last = dma_region_find(dma, rem + len - 1, first, &rem);

pci_dma_sync_sg_for_cpu(dma->dev, &dma->sglist[first], last - first + 1,
dma->direction);
Expand All @@ -194,13 +194,13 @@ void dma_region_sync_for_device(struct dma_region *dma, unsigned long offset,
unsigned long len)
{
int first, last;
unsigned long rem;
unsigned long rem = 0;

if (!len)
len = 1;

first = dma_region_find(dma, offset, &rem);
last = dma_region_find(dma, offset + len - 1, &rem);
first = dma_region_find(dma, offset, 0, &rem);
last = dma_region_find(dma, rem + len - 1, first, &rem);

pci_dma_sync_sg_for_device(dma->dev, &dma->sglist[first],
last - first + 1, dma->direction);
Expand Down

0 comments on commit 9bb2bcd

Please sign in to comment.