lkml.org 
[lkml]   [1998]   [Nov]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: virt_to_bus and >1G of memory (was MAX_DMA_ADDRESS ...)

    On 12 Nov 1998, Linus Torvalds wrote:

    > In article <199811111858.TAA03864@gloin.fi.muni.cz>,
    > Jan Kasprzak <kas@informatics.muni.cz> wrote:
    > >
    > > Can anybody explain this to me? Is (x)-PAGE_OFFSET at any chance
    > >slower or less efficient than (x)&~PAGE_OFFSET?
    >
    > No.
    >
    > But the one using logical operations is safer in the presense of old
    > drivers that don't do the right thing. There are some historical
    > drivers that may mix physical and virtual addresses, and just masking
    > off (or turning on) the high bits makes them work even though they
    > shouldn't.
    >
    > For 2.3.x we definitely want to use the +-PAGE_OFFSET version.

    And we probably will implement these ones differently:

    #define readb(addr) (*(volatile unsigned char *) __io_virt(addr))
    #define readw(addr) (*(volatile unsigned short *) __io_virt(addr))
    #define readl(addr) (*(volatile unsigned int *) __io_virt(addr))

    #define writeb(b,addr) (*(volatile unsigned char *) __io_virt(addr) = (b))
    #define writew(b,addr) (*(volatile unsigned short *) __io_virt(addr) = (b))
    #define writel(b,addr) (*(volatile unsigned int *) __io_virt(addr) = (b))

    #define memset_io(a,b,c) memset(__io_virt(a),(b),(c))
    #define memcpy_fromio(a,b,c) memcpy((a),__io_virt(b),(c))
    #define memcpy_toio(a,b,c) memcpy(__io_virt(a),(b),(c))

    The +-PAGE_OFFSET version breaks all the above functions when the address
    is remapped using ioremap(). (PCI for example).

    In practice, the current implementation of x86/io.h allows to deal with
    high addresses and low addresses (and probably old drivers) by
    transparently working for addresses that are remapped and those that are
    not. But the cost is 1 useless logical operation for each MMIO access.


    Regards,
    Gerard.



    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.rutgers.edu
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2005-03-22 13:45    [W:0.020 / U:0.628 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site