27 Jul, 2008

1 commit

  • Add per-device dma_mapping_ops support for CONFIG_X86_64 as POWER
    architecture does:

    This enables us to cleanly fix the Calgary IOMMU issue that some devices
    are not behind the IOMMU (http://lkml.org/lkml/2008/5/8/423).

    I think that per-device dma_mapping_ops support would be also helpful for
    KVM people to support PCI passthrough but Andi thinks that this makes it
    difficult to support the PCI passthrough (see the above thread). So I
    CC'ed this to KVM camp. Comments are appreciated.

    A pointer to dma_mapping_ops to struct dev_archdata is added. If the
    pointer is non NULL, DMA operations in asm/dma-mapping.h use it. If it's
    NULL, the system-wide dma_ops pointer is used as before.

    If it's useful for KVM people, I plan to implement a mechanism to register
    a hook called when a new pci (or dma capable) device is created (it works
    with hot plugging). It enables IOMMUs to set up an appropriate
    dma_mapping_ops per device.

    The major obstacle is that dma_mapping_error doesn't take a pointer to the
    device unlike other DMA operations. So x86 can't have dma_mapping_ops per
    device. Note all the POWER IOMMUs use the same dma_mapping_error function
    so this is not a problem for POWER but x86 IOMMUs use different
    dma_mapping_error functions.

    The first patch adds the device argument to dma_mapping_error. The patch
    is trivial but large since it touches lots of drivers and dma-mapping.h in
    all the architecture.

    This patch:

    dma_mapping_error() doesn't take a pointer to the device unlike other DMA
    operations. So we can't have dma_mapping_ops per device.

    Note that POWER already has dma_mapping_ops per device but all the POWER
    IOMMUs use the same dma_mapping_error function. x86 IOMMUs use device
    argument.

    [akpm@linux-foundation.org: fix sge]
    [akpm@linux-foundation.org: fix svc_rdma]
    [akpm@linux-foundation.org: build fix]
    [akpm@linux-foundation.org: fix bnx2x]
    [akpm@linux-foundation.org: fix s2io]
    [akpm@linux-foundation.org: fix pasemi_mac]
    [akpm@linux-foundation.org: fix sdhci]
    [akpm@linux-foundation.org: build fix]
    [akpm@linux-foundation.org: fix sparc]
    [akpm@linux-foundation.org: fix ibmvscsi]
    Signed-off-by: FUJITA Tomonori
    Cc: Muli Ben-Yehuda
    Cc: Andi Kleen
    Cc: Thomas Gleixner
    Cc: Ingo Molnar
    Cc: Avi Kivity
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    FUJITA Tomonori
     

29 Apr, 2008

3 commits

  • Change all ia64 machvecs to use the new dma_*map*_attrs() interfaces.
    Implement the old dma_*map_*() interfaces in terms of the corresponding new
    interfaces. For ia64/sn, make use of one dma attribute,
    DMA_ATTR_WRITE_BARRIER. Introduce swiotlb_*map*_attrs() functions.

    Signed-off-by: Arthur Kepner
    Cc: Tony Luck
    Cc: Jesse Barnes
    Cc: Jes Sorensen
    Cc: Randy Dunlap
    Cc: Roland Dreier
    Cc: James Bottomley
    Cc: David Miller
    Cc: Benjamin Herrenschmidt
    Cc: Grant Grundler
    Cc: Michael Ellerman
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Arthur Kepner
     
  • iommu_is_span_boundary in lib/iommu-helper.c was exported for PARISC IOMMUs
    (commit 3715863aa142c4f4c5208f5f3e5e9bac06006d2f). SWIOTLB can use it instead
    of the homegrown function.

    Signed-off-by: FUJITA Tomonori
    Cc: Thomas Gleixner
    Cc: Ingo Molnar
    Cc: H. Peter Anvin
    Cc: Tony Luck
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    FUJITA Tomonori
     
  • There's a pointlessly braced block of code in there. Remove the braces and
    save a tabstop.

    Cc: Andi Kleen
    Cc: FUJITA Tomonori
    Cc: Jan Beulich
    Cc: Tony Luck
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrew Morton
     

14 Mar, 2008

1 commit

  • Commit 681cc5cd3efbeafca6386114070e0bfb5012e249 ("iommu sg merging:
    swiotlb: respect the segment boundary limits") introduced two
    possibilities for entering an endless loop in lib/swiotlb.c:

    - if max_slots is zero (possible if mask is ~0UL)
    - if the number of slots requested fits into a swiotlb segment, but is
    too large for the part of a segment which remains after considering
    offset_slots

    This fixes them

    Signed-off-by: Jan Beulich
    Cc: FUJITA Tomonori
    Cc: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jan Beulich
     

06 Feb, 2008

1 commit

  • This patch makes swiotlb not allocate a memory area spanning LLD's segment
    boundary.

    is_span_boundary() judges whether a memory area spans LLD's segment boundary.
    If map_single finds such a area, map_single tries to find the next available
    memory area.

    Signed-off-by: FUJITA Tomonori
    Cc: James Bottomley
    Cc: Jens Axboe
    Cc: Greg KH
    Cc: Jeff Garzik
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    FUJITA Tomonori
     

23 Oct, 2007

1 commit


17 Oct, 2007

1 commit


16 Oct, 2007

1 commit


13 Oct, 2007

1 commit

  • On at least ARM (and I'm told MIPS too) dma_free_coherent() has a newish
    call context requirement: unlike its dma_alloc_coherent() sibling, it may
    not be called with IRQs disabled. (This was new behavior on ARM as of late
    2005, caused by ARM SMP updates.) This little surprise can be annoyingly
    driver-visible.

    Since it looks like that restriction won't be removed, this patch changes
    the definition of the API to include that requirement. Also, to help catch
    nonportable drivers, it updates the x86 and swiotlb versions to include the
    relevant warnings. (I already observed that it trips on the
    bus_reset_tasklet of the new firewire_ohci driver.)

    Signed-off-by: David Brownell
    Cc: David Miller
    Acked-by: Russell King
    Cc: Andi Kleen
    Signed-off-by: Andrew Morton
    Signed-off-by: Greg Kroah-Hartman

    David Brownell
     

22 Jul, 2007

1 commit

  • If the swiotlb maps a multi-slab region, swiotlb_sync_single_range() can be
    invoked to sync a sub-region which does not include the first slab.
    Unfortunately io_tlb_orig_addr[] is only initialised for the first slab,
    and hence the call to sync_single() will read a garbage orig_addr in this
    case.

    This patch fixes the issue by initialising all mapped slabs in
    io_tlb_orig_addr[]. It also correctly adjusts the buffer pointer in
    sync_single() to handle the case that the given dma_addr is not aligned on
    a slab boundary.

    Signed-off-by: Keir Fraser
    Cc: "Luck, Tony"
    Acked-by: Andi Kleen
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Keir Fraser
     

09 May, 2007

1 commit

  • kbuild spits outs following warning on a
    defconfig x86_64 build:
    WARNING: swiotlb.o - Section mismatch: reference to .init.text:swiotlb_init from __ksymtab between '__ksymtab_swiotlb_init' (at offset 0xa0) and '__ksymtab_swiotlb_free_coherent'

    This warning happens because the function swiotlb_init is marked __init and
    EXPORT_SYMBOL(). A 'git grep swiotlb_init' showed no users in drivers/ so
    remove the EXPORT_SYMBOL.

    Signed-off-by: Sam Ravnborg
    Cc: Andi Kleen
    Cc: "Luck, Tony"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Sam Ravnborg
     

07 Mar, 2007

1 commit


13 Feb, 2007

1 commit

  • Optimise swiotlb.c for size.

    text data bss dec hex filename
    5009 89 64 5162 142a lib/swiotlb.o-before
    4666 89 64 4819 12d3 lib/swiotlb.o-after

    For some reason my gcc (4.0.2) doesn't want to tailcall these things.

    swiotlb_sync_sg_for_device:
    pushq %rbp #
    movl $1, %r8d #,
    movq %rsp, %rbp #,
    call swiotlb_sync_sg #
    leave
    ret
    .size swiotlb_sync_sg_for_device, .-swiotlb_sync_sg_for_device
    .section .text.swiotlb_sync_sg_for_cpu,"ax",@progbits
    .globl swiotlb_sync_sg_for_cpu
    .type swiotlb_sync_sg_for_cpu, @function
    swiotlb_sync_sg_for_cpu:
    pushq %rbp #
    xorl %r8d, %r8d #
    movq %rsp, %rbp #,
    call swiotlb_sync_sg #
    leave
    ret

    Cc: Jan Beulich
    Cc: Andi Kleen
    Cc: "Luck, Tony"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrew Morton
     

06 Feb, 2007

4 commits

  • Add abstraction so that the file can be used by environments other than IA64
    and EM64T, namely for Xen.

    Signed-off-by: Jan Beulich
    Signed-off-by: Andrew Morton
    Signed-off-by: Tony Luck

    Jan Beulich
     
  • - add proper __init decoration to swiotlb's init code (and the code calling
    it, where not already the case)

    - replace uses of 'unsigned long' with dma_addr_t where appropriate

    - do miscellaneous simplicfication and cleanup

    Signed-off-by: Jan Beulich
    Signed-off-by: Andrew Morton
    Signed-off-by: Tony Luck

    Jan Beulich
     
  • Convert all phys_to_virt/virt_to_phys uses to bus_to_virt/virt_to_bus, as is
    what is meant and what is needed in (at least) some virtualized environments
    like Xen.

    Signed-off-by: Jan Beulich
    Acked-by: Muli Ben-Yehuda
    Signed-off-by: Andrew Morton
    Signed-off-by: Tony Luck

    Jan Beulich
     
  • This patch fixes
    - marking I-cache clean of pages DMAed to now only done for IA64
    - broken multiple inclusion in include/asm-x86_64/swiotlb.h
    - missing call to mark_clean in swiotlb_sync_sg()
    - a (perhaps only theoretical) issue in swiotlb_dma_supported() when
    io_tlb_end is exactly at the end of memory

    Signed-off-by: Jan Beulich
    Signed-off-by: Andrew Morton
    Signed-off-by: Tony Luck

    Jan Beulich
     

25 Mar, 2006

1 commit


12 Jan, 2006

1 commit

  • AK: I hacked Muli's original patch a lot and there were a lot
    of changes - all bugs are probably to blame on me now.
    There were also some changes in the fall back behaviour
    for swiotlb - in particular it doesn't try to use GFP_DMA
    now anymore. Also all DMA mapping operations use the
    same core dma_alloc_coherent code with proper fallbacks now.
    And various other changes and cleanups.

    Known problems: iommu=force swiotlb=force together breaks
    needs more testing.

    This patch cleans up x86_64's DMA mapping dispatching code. Right now
    we have three possible IOMMU types: AGP GART, swiotlb and nommu, and
    in the future we will also have Xen's x86_64 swiotlb and other HW
    IOMMUs for x86_64. In order to support all of them cleanly, this
    patch:

    - introduces a struct dma_mapping_ops with function pointers for each
    of the DMA mapping operations of gart (AMD HW IOMMU), swiotlb
    (software IOMMU) and nommu (no IOMMU).

    - gets rid of:

    if (swiotlb)
    return swiotlb_xxx();

    - PCI_DMA_BUS_IS_PHYS is now checked against the dma_ops being set
    This makes swiotlb faster by avoiding double copying in some cases.

    Signed-Off-By: Muli Ben-Yehuda
    Signed-Off-By: Jon D. Mason
    Signed-off-by: Andi Kleen
    Signed-off-by: Linus Torvalds

    Muli Ben-Yehuda
     

07 Jan, 2006

1 commit


21 Dec, 2005

1 commit

  • The overflow checking condition in lib/swiotlb.c was wrong.
    It would first run a NULL pointer through virt_to_phys before
    testing it. Since pci_map_sg overflow is not that uncommon
    and causes data corruption (including broken file systems) when not
    properly detected I think it's better to fix it in 2.6.15.

    This affects x86-64 and IA64.

    Signed-off-by: Andi Kleen
    Signed-off-by: Linus Torvalds

    Andi Kleen
     

01 Nov, 2005

1 commit


21 Oct, 2005

1 commit


30 Sep, 2005

6 commits