30 Mar, 2010

1 commit

  • …it slab.h inclusion from percpu.h

    percpu.h is included by sched.h and module.h and thus ends up being
    included when building most .c files. percpu.h includes slab.h which
    in turn includes gfp.h making everything defined by the two files
    universally available and complicating inclusion dependencies.

    percpu.h -> slab.h dependency is about to be removed. Prepare for
    this change by updating users of gfp and slab facilities include those
    headers directly instead of assuming availability. As this conversion
    needs to touch large number of source files, the following script is
    used as the basis of conversion.

    http://userweb.kernel.org/~tj/misc/slabh-sweep.py

    The script does the followings.

    * Scan files for gfp and slab usages and update includes such that
    only the necessary includes are there. ie. if only gfp is used,
    gfp.h, if slab is used, slab.h.

    * When the script inserts a new include, it looks at the include
    blocks and try to put the new include such that its order conforms
    to its surrounding. It's put in the include block which contains
    core kernel includes, in the same order that the rest are ordered -
    alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
    doesn't seem to be any matching order.

    * If the script can't find a place to put a new include (mostly
    because the file doesn't have fitting include block), it prints out
    an error message indicating which .h file needs to be added to the
    file.

    The conversion was done in the following steps.

    1. The initial automatic conversion of all .c files updated slightly
    over 4000 files, deleting around 700 includes and adding ~480 gfp.h
    and ~3000 slab.h inclusions. The script emitted errors for ~400
    files.

    2. Each error was manually checked. Some didn't need the inclusion,
    some needed manual addition while adding it to implementation .h or
    embedding .c file was more appropriate for others. This step added
    inclusions to around 150 files.

    3. The script was run again and the output was compared to the edits
    from #2 to make sure no file was left behind.

    4. Several build tests were done and a couple of problems were fixed.
    e.g. lib/decompress_*.c used malloc/free() wrappers around slab
    APIs requiring slab.h to be added manually.

    5. The script was run on all .h files but without automatically
    editing them as sprinkling gfp.h and slab.h inclusions around .h
    files could easily lead to inclusion dependency hell. Most gfp.h
    inclusion directives were ignored as stuff from gfp.h was usually
    wildly available and often used in preprocessor macros. Each
    slab.h inclusion directive was examined and added manually as
    necessary.

    6. percpu.h was updated not to include slab.h.

    7. Build test were done on the following configurations and failures
    were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
    distributed build env didn't work with gcov compiles) and a few
    more options had to be turned off depending on archs to make things
    build (like ipr on powerpc/64 which failed due to missing writeq).

    * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
    * powerpc and powerpc64 SMP allmodconfig
    * sparc and sparc64 SMP allmodconfig
    * ia64 SMP allmodconfig
    * s390 SMP allmodconfig
    * alpha SMP allmodconfig
    * um on x86_64 SMP allmodconfig

    8. percpu.h modifications were reverted so that it could be applied as
    a separate patch and serve as bisection point.

    Given the fact that I had only a couple of failures from tests on step
    6, I'm fairly confident about the coverage of this conversion patch.
    If there is a breakage, it's likely to be something in one of the arch
    headers which should be easily discoverable easily on most builds of
    the specific arch.

    Signed-off-by: Tejun Heo <tj@kernel.org>
    Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>

    Tejun Heo
     

16 Dec, 2009

1 commit

  • dma_mask is, when interpreted as address, the last valid byte, and hence
    comparison msut also be done using the last valid of the buffer in
    question.

    Also fix the open-coded instances in lib/swiotlb.c.

    Signed-off-by: Jan Beulich
    Cc: FUJITA Tomonori
    Cc: Becky Bruce
    Cc: "Luck, Tony"
    Cc: Benjamin Herrenschmidt
    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Cc: "H. Peter Anvin"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jan Beulich
     

08 Dec, 2009

1 commit


04 Dec, 2009

1 commit

  • That is "success", "unknown", "through", "performance", "[re|un]mapping"
    , "access", "default", "reasonable", "[con]currently", "temperature"
    , "channel", "[un]used", "application", "example","hierarchy", "therefore"
    , "[over|under]flow", "contiguous", "threshold", "enough" and others.

    Signed-off-by: André Goddard Rosa
    Signed-off-by: Jiri Kosina

    André Goddard Rosa
     

11 Nov, 2009

1 commit

  • POWERPC doesn't expect it to be used.

    This fixes the linux-next build failure reported by
    Stephen Rothwell:

    lib/swiotlb.c: In function 'setup_io_tlb_npages':
    lib/swiotlb.c:114: error: 'swiotlb' undeclared (first use in this function)

    Reported-by: Stephen Rothwell
    Signed-off-by: FUJITA Tomonori
    Cc: peterz@infradead.org
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    FUJITA Tomonori
     

10 Nov, 2009

3 commits

  • If HW IOMMU initialization fails (Intel VT-d often does this,
    typically due to BIOS bugs), we fall back to nommu. It doesn't
    work for the majority since nowadays we have more than 4GB
    memory so we must use swiotlb instead of nommu.

    The problem is that it's too late to initialize swiotlb when HW
    IOMMU initialization fails. We need to allocate swiotlb memory
    earlier from bootmem allocator. Chris explained the issue in
    detail:

    http://marc.info/?l=linux-kernel&m=125657444317079&w=2

    The current x86 IOMMU initialization sequence is too complicated
    and handling the above issue makes it more hacky.

    This patch changes x86 IOMMU initialization sequence to handle
    the above issue cleanly.

    The new x86 IOMMU initialization sequence are:

    1. we initialize the swiotlb (and setting swiotlb to 1) in the case
    of (max_pfn > MAX_DMA32_PFN && !no_iommu). dma_ops is set to
    swiotlb_dma_ops or nommu_dma_ops. if swiotlb usage is forced by
    the boot option, we finish here.

    2. we call the detection functions of all the IOMMUs

    3. the detection function sets x86_init.iommu.iommu_init to the
    IOMMU initialization function (so we can avoid calling the
    initialization functions of all the IOMMUs needlessly).

    4. if the IOMMU initialization function doesn't need to swiotlb
    then sets swiotlb to zero (e.g. the initialization is
    sucessful).

    5. if we find that swiotlb is set to zero, we free swiotlb
    resource.

    Signed-off-by: FUJITA Tomonori
    Cc: chrisw@sous-sol.org
    Cc: dwmw2@infradead.org
    Cc: joerg.roedel@amd.com
    Cc: muli@il.ibm.com
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    FUJITA Tomonori
     
  • This enables us to avoid printing swiotlb memory info when we
    initialize swiotlb. After swiotlb initialization, we could find
    that we don't need swiotlb.

    This patch removes the code to print swiotlb memory info in
    swiotlb_init() and exports the function to do that.

    Signed-off-by: FUJITA Tomonori
    Cc: chrisw@sous-sol.org
    Cc: dwmw2@infradead.org
    Cc: joerg.roedel@amd.com
    Cc: muli@il.ibm.com
    Cc: tony.luck@intel.com
    Cc: benh@kernel.crashing.org
    LKML-Reference:
    [ -v2: merge up conflict ]
    Signed-off-by: Ingo Molnar

    FUJITA Tomonori
     
  • swiotlb_free() function frees all allocated memory for swiotlb.

    We need to initialize swiotlb before IOMMU initialization (x86
    and powerpc needs to allocate memory from bootmem allocator). If
    IOMMU initialization is successful, we need to free swiotlb
    resource (don't want to waste 64MB).

    Signed-off-by: FUJITA Tomonori
    Cc: chrisw@sous-sol.org
    Cc: dwmw2@infradead.org
    Cc: joerg.roedel@amd.com
    Cc: muli@il.ibm.com
    LKML-Reference:
    [ -v2: build fix for the !CONFIG_SWIOTLB case ]
    Signed-off-by: Ingo Molnar

    FUJITA Tomonori
     

21 Aug, 2009

1 commit

  • swiotlb_full() in lib/swiotlb.c throws one of two panic messages
    based on whether the direction of transfer is from the device
    or to the device. The logic around this is somewhat weird in
    the case of bidirectional transfers. It appears to want to
    throw both in succession, but since its a panic only the first
    makes it.

    This patch adds a third, separate error for DMA_BIDIRECTIONAL
    to make things a bit clearer.

    Signed-off-by: Casey Dahlin
    Cc: FUJITA Tomonori
    Cc: Becky Bruce
    [ further fixed the error message ]
    Signed-off-by: Andrew Morton
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Casey Dahlin
     

28 Jul, 2009

6 commits


08 Apr, 2009

7 commits

  • Add a hwdev argument that is needed on some architectures
    in order to access a per-device offset that is taken into
    account when producing a physical address (also needed to
    get from bus address to virtual address because the physical
    address is an intermediate step).

    Also make swiotlb_bus_to_virt weak so architectures can
    override it.

    Signed-off-by: Becky Bruce
    Acked-by: FUJITA Tomonori
    Signed-off-by: Kumar Gala
    Cc: jeremy@goop.org
    Cc: ian.campbell@citrix.com
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Becky Bruce
     
  • Right now both swiotlb_sync_single_range and swiotlb_sync_sg
    were duplicating the code in swiotlb_sync_single. Just call it
    instead. Also rearrange the sync_single code for readability.

    Note that the swiotlb_sync_sg code was previously doing
    a complicated comparison to determine if an addresses needed
    to be unmapped where a simple is_swiotlb_buffer() call
    would have sufficed.

    Signed-off-by: Becky Bruce
    Acked-by: FUJITA Tomonori
    Signed-off-by: Kumar Gala
    Cc: jeremy@goop.org
    Cc: ian.campbell@citrix.com
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Becky Bruce
     
  • Previously, swiotlb_unmap_page and swiotlb_unmap_sg were
    duplicating very similar code. Refactor that code into a
    new unmap_single and unmap_single use do_unmap_single.

    Note that the swiotlb_unmap_sg code was previously doing
    a complicated comparison to determine if an addresses needed
    to be unmapped where a simple is_swiotlb_buffer() call
    would have sufficed.

    Signed-off-by: Becky Bruce
    Signed-off-by: Kumar Gala
    Cc: jeremy@goop.org
    Cc: ian.campbell@citrix.com
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Becky Bruce
     
  • Some architectures require additional checking to determine
    if a device can dma to an address and need to provide their
    own address_needs_mapping..

    Signed-off-by: Becky Bruce
    Acked-by: FUJITA Tomonori
    Signed-off-by: Kumar Gala
    Cc: jeremy@goop.org
    Cc: ian.campbell@citrix.com
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Becky Bruce
     
  • The current code calls virt_to_phys() on address that might
    be in highmem, which is bad. This wasn't needed, anyway, because
    we already have the physical address we need.

    Get rid of the now-unused virtual address as well.

    Signed-off-by: Becky Bruce
    Acked-by: FUJITA Tomonori
    Signed-off-by: Kumar Gala
    Cc: jeremy@goop.org
    Cc: ian.campbell@citrix.com
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Becky Bruce
     
  • Squash a build warning seen on 32-bit powerpc caused by
    calling min() with 2 different types. Use min_t() instead.

    Signed-off-by: Becky Bruce
    Acked-by: FUJITA Tomonori
    Signed-off-by: Kumar Gala
    Cc: jeremy@goop.org
    Cc: ian.campbell@citrix.com
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Becky Bruce
     
  • Impact: cleanup

    swiotlb_map/unmap_single are now swiotlb_map/unmap_page;
    trivially change all the comments to reference new names.

    Also, there were some comments that should have been
    referring to just plain old map_single, not swiotlb_map_single;
    fix those as well.

    Also change a use of the word "pointer", when what is
    referred to is actually a dma/physical address.

    Signed-off-by: Becky Bruce
    Acked-by: FUJITA Tomonori
    Signed-off-by: Kumar Gala
    Cc: jeremy@goop.org
    Cc: ian.campbell@citrix.com
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Becky Bruce
     

07 Apr, 2009

1 commit


11 Jan, 2009

3 commits


07 Jan, 2009

2 commits

  • …/git/tip/linux-2.6-tip

    * 'core-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
    rcu: fix rcutorture bug
    rcu: eliminate synchronize_rcu_xxx macro
    rcu: make treercu safe for suspend and resume
    rcu: fix rcutree grace-period-latency bug on small systems
    futex: catch certain assymetric (get|put)_futex_key calls
    futex: make futex_(get|put)_key() calls symmetric
    locking, percpu counters: introduce separate lock classes
    swiotlb: clean up EXPORT_SYMBOL usage
    swiotlb: remove unnecessary declaration
    swiotlb: replace architecture-specific swiotlb.h with linux/swiotlb.h
    swiotlb: add support for systems with highmem
    swiotlb: store phys address in io_tlb_orig_addr array
    swiotlb: add hwdev to swiotlb_phys_to_bus() / swiotlb_sg_to_bus()

    Linus Torvalds
     
  • Signed-off-by: Kay Sievers
    Signed-off-by: Greg Kroah-Hartman

    Kay Sievers
     

06 Jan, 2009

2 commits

  • This adds swiotlb_map_page and swiotlb_unmap_page to lib/swiotlb.c and
    remove IA64 and X86's swiotlb_map_page and swiotlb_unmap_page.

    This also removes unnecessary swiotlb_map_single, swiotlb_map_single_attrs,
    swiotlb_unmap_single and swiotlb_unmap_single_attrs.

    Signed-off-by: FUJITA Tomonori
    Acked-by: Tony Luck
    Signed-off-by: Ingo Molnar

    FUJITA Tomonori
     
  • This converts X86 and IA64 to use include/linux/dma-mapping.h.

    It's a bit large but pretty boring. The major change for X86 is
    converting 'int dir' to 'enum dma_data_direction dir' in DMA mapping
    operations. The major changes for IA64 is using map_page and
    unmap_page instead of map_single and unmap_single.

    Signed-off-by: FUJITA Tomonori
    Acked-by: Tony Luck
    Signed-off-by: Ingo Molnar

    FUJITA Tomonori
     

05 Jan, 2009

1 commit


04 Jan, 2009

1 commit


03 Jan, 2009

1 commit

  • Impact: cleanup, reduce kernel size a bit

    The current kernel build warns:

    WARNING: vmlinux.o(.text+0x11458): Section mismatch in reference from the function swiotlb_alloc_boot() to the function .init.text:__alloc_bootmem_low()
    The function swiotlb_alloc_boot() references
    the function __init __alloc_bootmem_low().
    This is often because swiotlb_alloc_boot lacks a __init
    annotation or the annotation of __alloc_bootmem_low is wrong.

    WARNING: vmlinux.o(.text+0x1011f2): Section mismatch in reference from the function swiotlb_late_init_with_default_size() to the function .init.text:__alloc_bootmem_low()
    The function swiotlb_late_init_with_default_size() references
    the function __init __alloc_bootmem_low().
    This is often because swiotlb_late_init_with_default_size lacks a __init
    annotation or the annotation of __alloc_bootmem_low is wrong.

    and indeed the functions calling __alloc_bootmem_low() can be marked
    __init as well.

    Signed-off-by: Roland Dreier
    Signed-off-by: Ingo Molnar

    Roland Dreier
     

28 Dec, 2008

5 commits


18 Dec, 2008

2 commits