ok, i think i have this figured out.  the current build error for a
nios2 kernel:

  ...
  CC      arch/nios2nommu/mm/dma-noncoherent.o
arch/nios2nommu/mm/dma-noncoherent.c: In function `dma_map_sg':
arch/nios2nommu/mm/dma-noncoherent.c:139: error: structure has no member named 
`page'
arch/nios2nommu/mm/dma-noncoherent.c:142: error: structure has no member named 
`page'
arch/nios2nommu/mm/dma-noncoherent.c: In function `dma_unmap_sg':
arch/nios2nommu/mm/dma-noncoherent.c:194: error: structure has no member named 
`page'
arch/nios2nommu/mm/dma-noncoherent.c: In function `dma_sync_sg_for_cpu':
arch/nios2nommu/mm/dma-noncoherent.c:263: error: structure has no member named 
`page'
arch/nios2nommu/mm/dma-noncoherent.c: In function `dma_sync_sg_for_device':
arch/nios2nommu/mm/dma-noncoherent.c:278: error: structure has no member named 
`page'
make[2]: *** [arch/nios2nommu/mm/dma-noncoherent.o] Error 1
make[1]: *** [arch/nios2nommu/mm] Error 2
make[1]: Leaving directory
`/home/rpjday/nios2/uclinux/uClinux-dist-cvs/linux-2.6.x'
make: *** [linux] Error 1
$

  that's because a "struct sg" doesn't have a simple "page" member
anymore, it has a "page_link" member which allows "sg" structs to not
be consecutive.  that means that, when you iterate through a list of
"struct sg"s, it's not enough to just keep incrementing the current
pointer, as in "sg++", as it's doing in the current source file
arch/nios2nommu/mm/dma-noncoherent.c (here's one example):


        for (i = 0; i < nents; i++, sg++) {
                unsigned long addr;

                addr = (unsigned long) page_address(sg->page);
                if (addr) {
                        __dma_sync(addr + sg->offset, sg->length, direction);
                        sg->dma_address = (dma_addr_t)page_to_phys(sg->page)
                                          + sg->offset;
                }
        }

see how that just assumes that all sg's are consecutive?  but you
can't assume that anymore.  happily, the current header file
include/linux/scatterlist.h takes care of that with an iterator
definition:

/*
 * Loop over each sg element, following the pointer to a new list if necessary
 */
#define for_each_sg(sglist, sg, nr, __i)        \
        for (__i = 0, sg = (sglist); __i < (nr); __i++, sg = sg_next(sg))

  and it's that "sg_next(sg)" macro that automatically handles either
a simple iteration, or following the pointer, so any sg iterator loops
should be re-coded to use the newer macro.  note that those new
macros are fully backward-compatible, so just changing the way
iteration is done should work just fine with older code.

  of course, i've been wrong before.

rday

p.s.  obviously, the include/asm-nios2nommu/scatterlist.h header file
has to be updated to match the new scatterlist definition as well.
this is what i've got now, just FYI:

==============================
#ifndef __ASM_NIOS2_SCATTERLIST_H
#define __ASM_NIOS2_SCATTERLIST_H

struct scatterlist {
#ifdef CONFIG_DEBUG_SG
        unsigned long sg_magic;
#endif
        unsigned long page_link;
        unsigned int offset;
        dma_addr_t dma_address;
        unsigned int length;
};

#define ISA_DMA_THRESHOLD (0xffffffff)

#define sg_dma_address(sg)      (virt_to_bus((sg)->dma_address))
#define sg_dma_len(sg)          ((sg)->length)

#endif /* __ASM_NIOS2_SCATTERLIST_H */
==================================
-- 
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://crashcourse.ca
========================================================================
_______________________________________________
uClinux-dev mailing list
uClinux-dev@uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev@uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev

Reply via email to