07 Oct, 2016

1 commit

  • Pull dmaengine updates from Vinod Koul:
    "This is bit large pile of code which bring in some nice additions:

    - Error reporting: we have added a new mechanism for users of
    dmaenegine to register a callback_result which tells them the
    result of the dma transaction. Right now only one user (ntb) is
    using it.

    - As we discussed on KS mailing list and pointed out NO_IRQ has no
    place in kernel, this also remove NO_IRQ from dmaengine subsystem
    (both arm and ppc users)

    - Support for IOMMU slave transfers and its implementation for arm.

    - To get better build coverage, enable COMPILE_TEST for bunch of
    driver, and fix the warning and sparse complaints on these.

    - Apart from above, usual updates spread across drivers"

    * tag 'dmaengine-4.9-rc1' of git://git.infradead.org/users/vkoul/slave-dma: (169 commits)
    async_pq_val: fix DMA memory leak
    dmaengine: virt-dma: move function declarations
    dmaengine: omap-dma: Enable burst and data pack for SG
    DT: dmaengine: rcar-dmac: document R8A7743/5 support
    dmaengine: fsldma: Unmap region obtained by of_iomap
    dmaengine: jz4780: fix resource leaks on error exit return
    dma-debug: fix ia64 build, use PHYS_PFN
    dmaengine: coh901318: fix integer overflow when shifting more than 32 places
    dmaengine: edma: avoid uninitialized variable use
    dma-mapping: fix m32r build warning
    dma-mapping: fix ia64 build, use PHYS_PFN
    dmaengine: ti-dma-crossbar: enable COMPILE_TEST
    dmaengine: omap-dma: enable COMPILE_TEST
    dmaengine: edma: enable COMPILE_TEST
    dmaengine: ti-dma-crossbar: Fix of_device_id data parameter usage
    dmaengine: ti-dma-crossbar: Correct type for of_find_property() third parameter
    dmaengine/ARM: omap-dma: Fix the DMAengine compile test on non OMAP configs
    dmaengine: edma: Rename set_bits and remove unused clear_bits helper
    dmaengine: edma: Use correct type for of_find_property() third parameter
    dmaengine: edma: Fix of_device_id data parameter usage (legacy vs TPCC)
    ...

    Linus Torvalds
     

01 Oct, 2016

1 commit

  • kbuild test robot reports:

    lib/dma-debug.c: In function 'debug_dma_map_resource':
    >> lib/dma-debug.c:1541:16: error: implicit declaration of function '__phys_to_pfn' [-Werror=implicit-function-declaration]
    entry->pfn = __phys_to_pfn(addr);
    ^~~~~~~~~~~~~

    ia64 does not provide __phys_to_pfn(), use the PHYS_PFN() alias.

    Fixes: 0e74b34dfc3318bf ("dma-debug: add support for resource mappings")
    Signed-off-by: Niklas Söderlund
    Signed-off-by: Vinod Koul

    Niklas Söderlund
     

27 Sep, 2016

1 commit

  • A MMIO mapped resource can not be represented by a struct page so a new
    debug type is needed to handle this. This patch add such type and
    functionality to add/remove entries and how to translate them to a
    physical address.

    Signed-off-by: Niklas Söderlund
    Acked-by: Arnd Bergmann
    Signed-off-by: Vinod Koul

    Niklas Söderlund
     

24 Aug, 2016

1 commit

  • If we're using CONFIG_VMAP_STACK=y and we manage to point an sg entry
    at the stack, then either the sg page will be in highmem or sg_virt()
    will return the direct-map alias. In neither case will the existing
    check_for_stack() implementation realize that it's a stack page.

    Fix it by explicitly checking for stack pages.

    This has no effect by itself. It's broken out for ease of review.

    Signed-off-by: Andy Lutomirski
    Cc: Andrew Morton
    Cc: Arnd Bergmann
    Cc: Borislav Petkov
    Cc: Brian Gerst
    Cc: Denys Vlasenko
    Cc: H. Peter Anvin
    Cc: Josh Poimboeuf
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/448460622731312298bf19dcbacb1606e75de7a9.1470907718.git.luto@kernel.org
    [ Minor edits. ]
    Signed-off-by: Ingo Molnar

    Andy Lutomirski
     

27 Jul, 2016

1 commit

  • get_hash_bucket() and put_hash_bucket() acquire and release the same
    spinlock, but this confuses static checkers such as sparse

    lib/dma-debug.c:254:27: warning: context imbalance in 'get_hash_bucket' - wrong count at exit
    lib/dma-debug.c:268:13: warning: context imbalance in 'put_hash_bucket' - unexpected unlock

    Add the appropriate acquire and release statements so that checkers can
    properly track the lock state.

    Link: http://lkml.kernel.org/r/20160701191552.24295-1-sboyd@codeaurora.org
    Signed-off-by: Stephen Boyd
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Stephen Boyd
     

27 May, 2016

1 commit

  • With netconsole (at least) the pr_err("... disablingn") call can
    recurse back into the dma-debug code, where it'll try to grab
    free_entries_lock again. Avoid the problem by doing the printk after
    dropping the lock.

    Link: http://lkml.kernel.org/r/1463678421-18683-1-git-send-email-ville.syrjala@linux.intel.com
    Signed-off-by: Ville Syrjälä
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ville Syrjälä
     

15 Jan, 2016

1 commit

  • In include/asm-generic/sections.h:

    /*
    * Usage guidelines:
    * _text, _data: architecture specific, don't use them in
    * arch-independent code
    * [_stext, _etext]: contains .text.* sections, may also contain
    * .rodata.*
    * and/or .init.* sections

    _text is not guaranteed across architectures. Architectures such as ARM
    may reuse parts which are not actually text and erroneously trigger a bug.
    Switch to using _stext which is guaranteed to contain text sections.

    Came out of https://lkml.kernel.org/g/

    Signed-off-by: Laura Abbott
    Reviewed-by: Kees Cook
    Cc: Russell King
    Cc: Arnd Bergmann
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Laura Abbott
     

17 Dec, 2015

1 commit

  • dma-debug uses struct dma_debug_entry to keep track of dma coherent
    memory allocation requests. The virtual address is converted into a pfn
    and an offset. Previously, the offset was calculated using an incorrect
    bit mask. As a result, we saw incorrect error messages from dma-debug
    like the following:

    "DMA-API: exceeded 7 overlapping mappings of cacheline 0x03e00000"

    Cacheline 0x03e00000 does not exist on our platform.

    Cc:
    Fixes: 0abdd7a81b7e ("dma-debug: introduce debug_dma_assert_idle()")
    Signed-off-by: Daniel Mentz
    Signed-off-by: Dan Williams

    Daniel Mentz
     

07 Nov, 2015

1 commit

  • Like dma_unmap_sg, dma_sync_sg* should be called with the original number
    of entries passed to dma_map_sg, so do the same check in the sync path as
    we do in the unmap path.

    Signed-off-by: Robin Murphy
    Cc: Arnd Bergmann
    Cc: Marek Szyprowski
    Cc: Sumit Semwal
    Cc: Sakari Ailus
    Cc: Russell King
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Robin Murphy
     

04 Oct, 2015

1 commit

  • Its a bit odd that debugfs_create_bool() takes 'u32 *' as an argument,
    when all it needs is a boolean pointer.

    It would be better to update this API to make it accept 'bool *'
    instead, as that will make it more consistent and often more convenient.
    Over that bool takes just a byte.

    That required updates to all user sites as well, in the same commit
    updating the API. regmap core was also using
    debugfs_{read|write}_file_bool(), directly and variable types were
    updated for that to be bool as well.

    Signed-off-by: Viresh Kumar
    Acked-by: Mark Brown
    Acked-by: Charles Keepax
    Signed-off-by: Greg Kroah-Hartman

    Viresh Kumar
     

18 Jul, 2015

1 commit

  • If dma-debug is disabled due to a memory error, DMA unmaps do not affect
    the dma_active_cacheline radix tree anymore, and debug_dma_assert_idle()
    can print false warnings.

    Disable debug_dma_assert_idle() when dma_debug_disabled() is true.

    Signed-off-by: Haggai Eran
    Fixes: 0abdd7a81b7e ("dma-debug: introduce debug_dma_assert_idle()")
    Cc: Dan Williams
    Cc: Joerg Roedel
    Cc: Vinod Koul
    Cc: Russell King
    Cc: James Bottomley
    Cc: Florian Fainelli
    Cc: Sebastian Ott
    Cc: Jiri Kosina
    Cc: Horia Geanta
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Haggai Eran
     

17 Apr, 2015

1 commit

  • bucket_find_contain() will search the bucket list for a dma_debug_entry.
    When the entry isn't found it needs to search other buckets too, since
    only the start address of a dma range is hashed (which might be in a
    different bucket).

    A copy of the dma_debug_entry is used to get the previous hash bucket
    but when its list is searched the original dma_debug_entry is to be used
    not its modified copy.

    This fixes false "device driver tries to sync DMA memory it has not allocated"
    warnings.

    Signed-off-by: Sebastian Ott
    Cc: Florian Fainelli
    Cc: Horia Geanta
    Cc: Jiri Kosina
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Sebastian Ott
     

11 Dec, 2014

2 commits

  • dma_debug_init() is called by architecture specific code at different
    levels, but typically as a fs_initcall due to the debugfs initialization.
    Some platforms may have early callers of the DMA-API, running prior to the
    fs_initcall() level, which is not much of an issue unless
    CONFIG_DMA_API_DEBUG is set. When the DMA-API debugging facilities are
    turned on a caller will go through:

    debug_dma_map_{single,page}
    -> dma_mapping_error (inline function usually)
    -> debug_dma_mapping_error
    -> get_hash_bucket

    Calling get_hash_bucket() returns a valid hash value since we hash on high
    bits of the dma_addr cookie, but we will grab an unitialized spinlock,
    which typically won't crash but produce a warning, the real crash will
    however happen during the bucket list traversal because the list has not
    been initialized yet.

    An obvious solution is of course to move some of the offenders to run
    after the fs_initcall level, but since this might not always be an option,
    we add a flag "dma_debug_initialized" which is set to false by default,
    and set to true once dma_debug_init() has had a chance to run.

    The dma_debug_disabled() helper function previously introduced just needs
    to check for dma_debug_initialized to allow the caller to proceed or not.

    Signed-off-by: Florian Fainelli
    Cc: Dan Williams
    Cc: Jiri Kosina
    Cc: Horia Geanta
    Cc: Brian Norris
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Florian Fainelli
     
  • Add a helper function which returns whether the DMA debugging API is
    disabled, right now we only check for global_disable, but in order to
    accommodate early callers of the DMA-API, we will check for more
    initialization flags in the next patch.

    Signed-off-by: Florian Fainelli
    Cc: Dan Williams
    Cc: Jiri Kosina
    Cc: Horia Geanta
    Cc: Brian Norris
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Florian Fainelli
     

02 Sep, 2014

1 commit


04 Mar, 2014

1 commit

  • While debug_dma_assert_idle() checks if a given *page* is actively
    undergoing dma the valid granularity of a dma mapping is a *cacheline*.
    Sander's testing shows that the warning message "DMA-API: exceeded 7
    overlapping mappings of pfn..." is falsely triggering. The test is
    simply mapping multiple cachelines in a given page.

    Ultimately we want overlap tracking to be valid as it is a real api
    violation, so we need to track active mappings by cachelines. Update
    the active dma tracking to use the page-frame-relative cacheline of the
    mapping as the key, and update debug_dma_assert_idle() to check for all
    possible mapped cachelines for a given page.

    However, the need to track active mappings is only relevant when the
    dma-mapping is writable by the device. In fact it is fairly standard
    for read-only mappings to have hundreds or thousands of overlapping
    mappings at once. Limiting the overlap tracking to writable
    (!DMA_TO_DEVICE) eliminates this class of false-positive overlap
    reports.

    Note, the radix gang lookup is sub-optimal. It would be best if it
    stopped fetching entries once the search passed a page boundary.
    Nevertheless, this implementation does not perturb the original net_dma
    failing case. That is to say the extra overhead does not show up in
    terms of making the failing case pass due to a timing change.

    References:
    http://marc.info/?l=linux-netdev&m=139232263419315&w=2
    http://marc.info/?l=linux-netdev&m=139217088107122&w=2

    Signed-off-by: Dan Williams
    Reported-by: Sander Eikelenboom
    Reported-by: Dave Jones
    Tested-by: Dave Jones
    Tested-by: Sander Eikelenboom
    Cc: Konrad Rzeszutek Wilk
    Cc: Francois Romieu
    Cc: Eric Dumazet
    Cc: Wei Liu
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Dan Williams
     

30 Jan, 2014

1 commit

  • Commit 0abdd7a81b7e ("dma-debug: introduce debug_dma_assert_idle()") was
    reworked to expand the overlap counter to the full range expressable by
    3 tag bits, but it has a thinko in treating the overlap counter as a
    pure reference count for the entry.

    Instead of deleting when the reference-count drops to zero, we need to
    delete when the overlap-count drops below zero. Also, when detecting
    overflow we can just test the overlap-count > MAX rather than applying
    special meaning to 0.

    Regression report available here:
    http://marc.info/?l=linux-netdev&m=139073373932386&w=2

    This patch, now tested on the original net_dma case, sees the expected
    handful of reports before the eventual data corruption occurs.

    Signed-off-by: Dan Williams
    Reported-by: Sander Eikelenboom
    Cc: Francois Romieu
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Dan Williams
     

22 Jan, 2014

1 commit

  • Record actively mapped pages and provide an api for asserting a given
    page is dma inactive before execution proceeds. Placing
    debug_dma_assert_idle() in cow_user_page() flagged the violation of the
    dma-api in the NET_DMA implementation (see commit 77873803363c "net_dma:
    mark broken").

    The implementation includes the capability to count, in a limited way,
    repeat mappings of the same page that occur without an intervening
    unmap. This 'overlap' counter is limited to the few bits of tag space
    in a radix tree. This mechanism is added to mitigate false negative
    cases where, for example, a page is dma mapped twice and
    debug_dma_assert_idle() is called after the page is un-mapped once.

    Signed-off-by: Dan Williams
    Cc: Joerg Roedel
    Cc: Vinod Koul
    Cc: Russell King
    Cc: James Bottomley
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Dan Williams
     

23 Mar, 2013

2 commits

  • There were reports of the igb driver unmapping buffers without calling
    dma_mapping_error. On closer inspection issues were found in the DMA
    debug API and how it handled multiple mappings of the same buffer.

    The issue I found is the fact that the debug_dma_mapping_error would
    only set the map_err_type to MAP_ERR_CHECKED in the case that the was
    only one match for device and device address. However in the case of
    non-IOMMU, multiple addresses existed and as a result it was not setting
    this field once a second mapping was instantiated. I have resolved this
    by changing the search so that it instead will now set MAP_ERR_CHECKED
    on the first buffer that matches the device and DMA address that is
    currently in the state MAP_ERR_NOT_CHECKED.

    A secondary side effect of this patch is that in the case of multiple
    buffers using the same address only the last mapping will have a valid
    map_err_type. The previous mappings will all end up with map_err_type
    set to MAP_ERR_CHECKED because of the dma_mapping_error call in
    debug_dma_map_page. However this behavior may be preferable as it means
    you will likely only see one real error per multi-mapped buffer, versus
    the current behavior of multiple false errors mer multi-mapped buffer.

    Signed-off-by: Alexander Duyck
    Cc: Joerg Roedel
    Reviewed-by: Shuah Khan
    Tested-by: Shuah Khan
    Cc: Jakub Kicinski
    Cc: Konrad Rzeszutek Wilk
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexander Duyck
     
  • In check_unmap() it is possible to get into a dead-locked state if
    dma_mapping_error is called. The problem is that the bucket is locked in
    check_unmap, and locked again by debug_dma_mapping_error which is called
    by dma_mapping_error. To resolve that we must release the lock on the
    bucket before making the call to dma_mapping_error.

    [akpm@linux-foundation.org: restore 80-col trickery to be consistent with the rest of the file]
    Signed-off-by: Alexander Duyck
    Cc: Joerg Roedel
    Reviewed-by: Shuah Khan
    Tested-by: Shuah Khan
    Cc: Jakub Kicinski
    Cc: Konrad Rzeszutek Wilk
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexander Duyck
     

17 Nov, 2012

1 commit

  • dma-debug depends on get_dma_ops() interface. Several architectures
    do not define dma_ops and get_dma_ops(). When dma debug interfaces are
    used on an architecture (e.g: c6x) that doesn't define get_dmap_ops(),
    compilation fails. Changing dma-debug to call dma_mapping_error() instead
    of defining its own that calls get_dma_ops(), such that the internal use of
    dma_mapping_error() doesn't interfere with the debug_dma_mapping_error()
    interface's mapping error checks. Moving dma_mapping_error() checks in
    check_unmap() under the dma debug entry not found is sufficient to fix the
    problem.

    Reference: https://lkml.org/lkml/2012/10/26/367

    Signed-off-by: Shuah Khan
    Reported-by: Mark Salter
    Signed-off-by: Joerg Roedel

    Shuah Khan
     

24 Oct, 2012

1 commit

  • Add dma-debug interface debug_dma_mapping_error() to debug
    drivers that fail to check dma mapping errors on addresses
    returned by dma_map_single() and dma_map_page() interfaces.
    This interface clears a flag set by debug_dma_map_page() to
    indicate that dma_mapping_error() has been called by the
    driver. When driver does unmap, debug_dma_unmap() checks the
    flag and if this flag is still set, prints warning message
    that includes call trace that leads up to the unmap. This
    interface can be called from dma_mapping_error() routines to
    enable dma mapping error check debugging.

    Tested: Intel iommu and swiotlb (iommu=soft) on x86-64 with
    CONFIG_DMA_API_DEBUG enabled and disabled.

    Signed-off-by: Shuah Khan
    Reviewed-by: Konrad Rzeszutek Wilk
    Signed-off-by: Joerg Roedel

    Shuah Khan
     

20 Oct, 2012

1 commit

  • If there is only one match, the unique matched entry should be returned.

    Without the fix, the upcoming dma debug interfaces ("dma-debug: new
    interfaces to debug dma mapping errors") can't work reliably because
    only device and dma_addr are passed to dma_mapping_error().

    Signed-off-by: Ming Lei
    Reported-by: Wu Fengguang
    Cc: Joerg Roedel
    Tested-by: Shuah Khan
    Cc: Paul Gortmaker
    Cc: Jakub Kicinski
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ming Lei
     

02 Oct, 2012

1 commit


02 Jul, 2012

1 commit

  • Even though it has "bool" in the name, you have pass a u32 pointer to
    debugfs_create_bool(). Otherwise you get memory corruption in
    write_file_bool(). Fortunately in this case the corruption happens in
    an alignment hole between variables so it doesn't cause any problems.

    Signed-off-by: Dan Carpenter
    Signed-off-by: Joerg Roedel

    Dan Carpenter
     

12 Apr, 2012

1 commit


25 Jan, 2012

1 commit

  • As part of the removal of get_driver()/put_driver(), this patch
    (as1512) gets rid of various useless and unnecessary calls in several
    drivers. In some cases it may be desirable to pin the driver by
    calling try_module_get(), but that can be done later.

    Signed-off-by: Alan Stern
    CC: "David S. Miller"
    CC: Konrad Rzeszutek Wilk
    CC: Michael Buesch
    CC: Joerg Roedel
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     

21 Nov, 2011

1 commit


01 Nov, 2011

1 commit


23 Aug, 2011

1 commit

  • Summary:
    Users of the pci_dma_sync_single_* api allow users to sync address ranges within
    the range of a mapped entry (i.e. you can dma map address X to dma_addr_t A and
    then pci_dma_sync_single on dma_addr_t A+1. The dma-debug library however
    assume dma syncs will always occur using the base address of a mapped region,
    and uses that assumption to find entries in its hash table. Since thats often
    (but not always the case), the dma debug library can give us false errors about
    missing entries, which are reported as syncing of memory not allocated by the
    driver. This was noted in the cxgb3 driver as this error:

    WARNING: at lib/dma-debug.c:902 check_sync+0xdd/0x48c()
    Hardware name: To be filled by O.E.M.
    cxgb3 0000:01:00.0: DMA-API: device driver tries to sync DMA memory it has not
    allocated [device address=0x00000000fff97800] [size=1984 bytes]
    Modules linked in: autofs4 sunrpc cpufreq_ondemand acpi_cpufreq freq_table
    mperf ip6t_REJECT nf_conntrack_ipv6 ip6table_filter ip6_tables ipv6 uinput
    snd_hda_codec_intelhdmi snd_hda_codec_realtek snd_hda_intel snd_hda_codec
    snd_hwdep snd_seq snd_seq_device snd_pcm snd_timer e1000e snd soundcore r8169
    cxgb3 iTCO_wdt snd_page_alloc mii shpchp i2c_i801 iTCO_vendor_support mdio
    microcode firewire_ohci firewire_core crc_itu_t ata_generic pata_acpi i915
    drm_kms_helper drm i2c_algo_bit i2c_core video output [last unloaded:
    scsi_wait_scan]
    Pid: 1818, comm: ifconfig Not tainted 2.6.35-0.23.rc3.git6.fc14.x86_64 #1
    Call Trace:
    [] warn_slowpath_common+0x85/0x9d
    [] warn_slowpath_fmt+0x46/0x48
    [] ? check_sync+0x39/0x48c
    [] ? trace_hardirqs_on+0xd/0xf
    [] check_sync+0xdd/0x48c
    [] debug_dma_sync_single_for_device+0x3f/0x41
    [] ? pci_map_page+0x84/0x97 [cxgb3]
    [] pci_dma_sync_single_for_device.clone.0+0x65/0x6e [cxgb3]
    [] refill_fl+0x305/0x30a [cxgb3]
    [] t3_sge_alloc_qset+0x6a7/0x821 [cxgb3]
    [] cxgb_up+0x4d0/0xe62 [cxgb3]
    [] ? __module_text_address+0x12/0x58
    [] cxgb_open+0x3f/0x309 [cxgb3]
    [] __dev_open+0x8e/0xbc
    [] __dev_change_flags+0xbe/0x142
    [] dev_change_flags+0x21/0x57
    [] devinet_ioctl+0x29a/0x54b
    [] ? inode_has_perm+0xaa/0xce
    [] inet_ioctl+0x8f/0xa7
    [] sock_do_ioctl+0x29/0x48
    [] sock_ioctl+0x213/0x222
    [] vfs_ioctl+0x32/0xa6
    [] do_vfs_ioctl+0x47a/0x4b3
    [] sys_ioctl+0x56/0x79
    [] system_call_fastpath+0x16/0x1b
    ---[ end trace 69a4d4cc77b58004 ]---

    (some edits by Joerg Roedel)

    Signed-off-by: Neil Horman
    Reported-by: Jay Fenalson
    CC: Divy LeRay
    CC: Stanislaw Gruszka
    CC: Joerg Roedel
    CC: Arnd Bergmann
    Signed-off-by: Joerg Roedel

    Neil Horman
     

07 Apr, 2011

1 commit


15 Oct, 2010

1 commit

  • All file_operations should get a .llseek operation so we can make
    nonseekable_open the default for future file operations without a
    .llseek pointer.

    The three cases that we can automatically detect are no_llseek, seq_lseek
    and default_llseek. For cases where we can we can automatically prove that
    the file offset is always ignored, we use noop_llseek, which maintains
    the current behavior of not returning an error from a seek.

    New drivers should normally not use noop_llseek but instead use no_llseek
    and call nonseekable_open at open time. Existing drivers can be converted
    to do the same when the maintainer knows for certain that no user code
    relies on calling seek on the device file.

    The generated code is often incorrectly indented and right now contains
    comments that clarify for each added line why a specific variant was
    chosen. In the version that gets submitted upstream, the comments will
    be gone and I will manually fix the indentation, because there does not
    seem to be a way to do that using coccinelle.

    Some amount of new code is currently sitting in linux-next that should get
    the same modifications, which I will do at the end of the merge window.

    Many thanks to Julia Lawall for helping me learn to write a semantic
    patch that does all this.

    ===== begin semantic patch =====
    // This adds an llseek= method to all file operations,
    // as a preparation for making no_llseek the default.
    //
    // The rules are
    // - use no_llseek explicitly if we do nonseekable_open
    // - use seq_lseek for sequential files
    // - use default_llseek if we know we access f_pos
    // - use noop_llseek if we know we don't access f_pos,
    // but we still want to allow users to call lseek
    //
    @ open1 exists @
    identifier nested_open;
    @@
    nested_open(...)
    {

    }

    @ open exists@
    identifier open_f;
    identifier i, f;
    identifier open1.nested_open;
    @@
    int open_f(struct inode *i, struct file *f)
    {

    }

    @ read disable optional_qualifier exists @
    identifier read_f;
    identifier f, p, s, off;
    type ssize_t, size_t, loff_t;
    expression E;
    identifier func;
    @@
    ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
    {

    }

    @ read_no_fpos disable optional_qualifier exists @
    identifier read_f;
    identifier f, p, s, off;
    type ssize_t, size_t, loff_t;
    @@
    ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
    {
    ... when != off
    }

    @ write @
    identifier write_f;
    identifier f, p, s, off;
    type ssize_t, size_t, loff_t;
    expression E;
    identifier func;
    @@
    ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
    {

    }

    @ write_no_fpos @
    identifier write_f;
    identifier f, p, s, off;
    type ssize_t, size_t, loff_t;
    @@
    ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
    {
    ... when != off
    }

    @ fops0 @
    identifier fops;
    @@
    struct file_operations fops = {
    ...
    };

    @ has_llseek depends on fops0 @
    identifier fops0.fops;
    identifier llseek_f;
    @@
    struct file_operations fops = {
    ...
    .llseek = llseek_f,
    ...
    };

    @ has_read depends on fops0 @
    identifier fops0.fops;
    identifier read_f;
    @@
    struct file_operations fops = {
    ...
    .read = read_f,
    ...
    };

    @ has_write depends on fops0 @
    identifier fops0.fops;
    identifier write_f;
    @@
    struct file_operations fops = {
    ...
    .write = write_f,
    ...
    };

    @ has_open depends on fops0 @
    identifier fops0.fops;
    identifier open_f;
    @@
    struct file_operations fops = {
    ...
    .open = open_f,
    ...
    };

    // use no_llseek if we call nonseekable_open
    ////////////////////////////////////////////
    @ nonseekable1 depends on !has_llseek && has_open @
    identifier fops0.fops;
    identifier nso ~= "nonseekable_open";
    @@
    struct file_operations fops = {
    ... .open = nso, ...
    +.llseek = no_llseek, /* nonseekable */
    };

    @ nonseekable2 depends on !has_llseek @
    identifier fops0.fops;
    identifier open.open_f;
    @@
    struct file_operations fops = {
    ... .open = open_f, ...
    +.llseek = no_llseek, /* open uses nonseekable */
    };

    // use seq_lseek for sequential files
    /////////////////////////////////////
    @ seq depends on !has_llseek @
    identifier fops0.fops;
    identifier sr ~= "seq_read";
    @@
    struct file_operations fops = {
    ... .read = sr, ...
    +.llseek = seq_lseek, /* we have seq_read */
    };

    // use default_llseek if there is a readdir
    ///////////////////////////////////////////
    @ fops1 depends on !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    identifier readdir_e;
    @@
    // any other fop is used that changes pos
    struct file_operations fops = {
    ... .readdir = readdir_e, ...
    +.llseek = default_llseek, /* readdir is present */
    };

    // use default_llseek if at least one of read/write touches f_pos
    /////////////////////////////////////////////////////////////////
    @ fops2 depends on !fops1 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    identifier read.read_f;
    @@
    // read fops use offset
    struct file_operations fops = {
    ... .read = read_f, ...
    +.llseek = default_llseek, /* read accesses f_pos */
    };

    @ fops3 depends on !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    identifier write.write_f;
    @@
    // write fops use offset
    struct file_operations fops = {
    ... .write = write_f, ...
    + .llseek = default_llseek, /* write accesses f_pos */
    };

    // Use noop_llseek if neither read nor write accesses f_pos
    ///////////////////////////////////////////////////////////

    @ fops4 depends on !fops1 && !fops2 && !fops3 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    identifier read_no_fpos.read_f;
    identifier write_no_fpos.write_f;
    @@
    // write fops use offset
    struct file_operations fops = {
    ...
    .write = write_f,
    .read = read_f,
    ...
    +.llseek = noop_llseek, /* read and write both use no f_pos */
    };

    @ depends on has_write && !has_read && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    identifier write_no_fpos.write_f;
    @@
    struct file_operations fops = {
    ... .write = write_f, ...
    +.llseek = noop_llseek, /* write uses no f_pos */
    };

    @ depends on has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    identifier read_no_fpos.read_f;
    @@
    struct file_operations fops = {
    ... .read = read_f, ...
    +.llseek = noop_llseek, /* read uses no f_pos */
    };

    @ depends on !has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    @@
    struct file_operations fops = {
    ...
    +.llseek = noop_llseek, /* no read or write fn */
    };
    ===== End semantic patch =====

    Signed-off-by: Arnd Bergmann
    Cc: Julia Lawall
    Cc: Christoph Hellwig

    Arnd Bergmann
     

07 Apr, 2010

1 commit

  • Earlier in this function we set the last byte of "buf" to NULL so we
    always hit the break statement and "i" is never equal to NAME_MAX_LEN.
    This patch doesn't change how the driver works but it silences a Smatch
    warning and it makes it clearer that we don't write past the end of the
    array.

    Signed-off-by: Dan Carpenter
    Signed-off-by: Joerg Roedel

    Dan Carpenter
     

23 Jan, 2010

2 commits


12 Jan, 2010

1 commit


31 Dec, 2009

1 commit

  • Stephen Rothwell reported the following build warning:

    lib/dma-debug.c: In function 'dma_debug_device_change':
    lib/dma-debug.c:680: warning: 'return' with no value, in function returning non-void

    Introduced by commit f797d9881b62c2ddb1d2e7bd80d87141949c84aa
    ("dma-debug: Do not add notifier when dma debugging is disabled").

    Return 0 [notify-done] when disabled. (this is standard bus notifier behavior.)

    Signed-off-by: Shaun Ruffell
    Signed-off-by: Joerg Roedel
    Cc: Linus Torvalds
    Cc:
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Ingo Molnar
     

21 Dec, 2009

1 commit

  • If CONFIG_HAVE_DMA_API_DEBUG is defined and "dma_debug=off" is
    specified on the kernel command line, when you detach a driver from a
    device you can cause the following NULL pointer dereference:

    BUG: unable to handle kernel NULL pointer dereference at (null)
    IP: [] dma_debug_device_change+0x5d/0x117

    The problem is that the dma_debug_device_change notifier function is
    added to the bus notifier chain even though the dma_entry_hash array
    was never initialized. If dma debugging is disabled, this patch both
    prevents dma_debug_device_change notifiers from being added to the
    chain, and additionally ensures that the dma_debug_device_change
    notifier function is a no-op.

    Cc: stable@kernel.org
    Signed-off-by: Shaun Ruffell
    Signed-off-by: Joerg Roedel

    Shaun Ruffell
     

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
     

29 Oct, 2009

1 commit

  • When PAE is enabled in the kernel configuration the size of
    phys_addr_t differs from the size of a void pointer. The gcc
    prints a warning about that in dma-debug code.
    This patch fixes the warning by converting the output to
    unsigned long long instead of a pointer.

    Signed-off-by: Joerg Roedel

    Joerg Roedel