1. 07 Feb, 2014 7 commits
    • Tejun Heo's avatar
      kernfs: remove KERNFS_ACTIVE_REF and add kernfs_lockdep() · 182fd64b
      Tejun Heo authored
      There currently are two mechanisms gating active ref lockdep
      annotations - KERNFS_LOCKDEP flag and KERNFS_ACTIVE_REF type mask.
      The former disables lockdep annotations in kernfs_get/put_active()
      while the latter disables all of kernfs_deactivate().
      
      While KERNFS_ACTIVE_REF also behaves as an optimization to skip the
      deactivation step for non-file nodes, the benefit is marginal and it
      needlessly diverges code paths.  Let's drop KERNFS_ACTIVE_REF.
      
      While at it, add a test helper kernfs_lockdep() to test KERNFS_LOCKDEP
      flag so that it's more convenient and the related code can be compiled
      out when not enabled.
      
      v2: Refreshed on top of ("kernfs: make kernfs_deactivate() honor
          KERNFS_LOCKDEP flag").  As the earlier patch already added
          KERNFS_LOCKDEP tests to kernfs_deactivate(), those additions are
          dropped from this patch and the existing ones are simply converted
          to kernfs_lockdep().
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      182fd64b
    • Tejun Heo's avatar
      kernfs: remove kernfs_addrm_cxt · 988cd7af
      Tejun Heo authored
      kernfs_addrm_cxt and the accompanying kernfs_addrm_start/finish() were
      added because there were operations which should be performed outside
      kernfs_mutex after adding and removing kernfs_nodes.  The necessary
      operations were recorded in kernfs_addrm_cxt and performed by
      kernfs_addrm_finish(); however, after the recent changes which
      relocated deactivation and unmapping so that they're performed
      directly during removal, the only operation kernfs_addrm_finish()
      performs is kernfs_put(), which can be moved inside the removal path
      too.
      
      This patch moves the kernfs_put() of the base ref to __kernfs_remove()
      and remove kernfs_addrm_cxt and kernfs_addrm_start/finish().
      
      * kernfs_add_one() is updated to grab and release kernfs_mutex itself.
        sysfs_addrm_start/finish() invocations around it are removed from
        all users.
      
      * __kernfs_remove() puts an unlinked node directly instead of chaining
        it to kernfs_addrm_cxt.  Its callers are updated to grab and release
        kernfs_mutex instead of calling kernfs_addrm_start/finish() around
        it.
      
      v2: Rebased on top of "kernfs: associate a new kernfs_node with its
          parent on creation" which dropped @parent from kernfs_add_one().
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      988cd7af
    • Tejun Heo's avatar
      kernfs: invoke kernfs_unmap_bin_file() directly from kernfs_deactivate() · ccf02aaf
      Tejun Heo authored
      kernfs_unmap_bin_file() is supposed to unmap all memory mappings of
      the target file before kernfs_remove() finishes; however, it currently
      is being called from kernfs_addrm_finish() and has the same race
      problem as the original implementation of deactivation when there are
      multiple removers - only the remover which snatches the node to its
      addrm_cxt->removed list is guaranteed to wait for its completion
      before returning.
      
      It can be easily fixed by moving kernfs_unmap_bin_file() invocation
      from kernfs_addrm_finish() to kernfs_deactivated().  The function may
      be called multiple times but that shouldn't do any harm.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ccf02aaf
    • Tejun Heo's avatar
      kernfs: restructure removal path to fix possible premature return · 35beab06
      Tejun Heo authored
      The recursive nature of kernfs_remove() means that, even if
      kernfs_remove() is not allowed to be called multiple times on the same
      node, there may be race conditions between removal of parent and its
      descendants.  While we can claim that kernfs_remove() shouldn't be
      called on one of the descendants while the removal of an ancestor is
      in progress, such rule is unnecessarily restrictive and very difficult
      to enforce.  It's better to simply allow invoking kernfs_remove() as
      the caller sees fit as long as the caller ensures that the node is
      accessible.
      
      The current behavior in such situations is broken.  Whoever enters
      removal path first takes the node off the hierarchy and then
      deactivates.  Following removers either return as soon as it notices
      that it's not the first one or can't even find the target node as it
      has already been removed from the hierarchy.  In both cases, the
      following removers may finish prematurely while the nodes which should
      be removed and drained are still being processed by the first one.
      
      This patch restructures so that multiple removers, whether through
      recursion or direction invocation, always follow the following rules.
      
      * When there are multiple concurrent removers, only one puts the base
        ref.
      
      * Regardless of which one puts the base ref, all removers are blocked
        until the target node is fully deactivated and removed.
      
      To achieve the above, removal path now first marks all descendants
      including self REMOVED and then deactivates and unlinks leftmost
      descendant one-by-one.  kernfs_deactivate() is called directly from
      __kernfs_removal() and drops and regrabs kernfs_mutex for each
      descendant to drain active refs.  As this means that multiple removers
      can enter kernfs_deactivate() for the same node, the function is
      updated so that it can handle multiple deactivators of the same node -
      only one actually deactivates but all wait till drain completion.
      
      The restructured removal path guarantees that a removed node gets
      unlinked only after the node is deactivated and drained.  Combined
      with proper multiple deactivator handling, this guarantees that any
      invocation of kernfs_remove() returns only after the node itself and
      all its descendants are deactivated, drained and removed.
      
      v2: Draining separated into a separate loop (used to be in the same
          loop as unlink) and done from __kernfs_deactivate().  This is to
          allow exposing deactivation as a separate interface later.
      
          Root node removal was broken in v1 patch.  Fixed.
      
      v3: Revert most of v2 except for root node removal fix and
          simplification of KERNFS_REMOVED setting loop.
      
      v4: Refreshed on top of ("kernfs: make kernfs_deactivate() honor
          KERNFS_LOCKDEP flag").
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      35beab06
    • Tejun Heo's avatar
      kernfs: replace kernfs_node->u.completion with kernfs_root->deactivate_waitq · abd54f02
      Tejun Heo authored
      kernfs_node->u.completion is used to notify deactivation completion
      from kernfs_put_active() to kernfs_deactivate().  We now allow
      multiple racing removals of the same node and the current removal
      scheme is no longer correct - kernfs_remove() invocation may return
      before the node is properly deactivated if it races against another
      removal.  The removal path will be restructured to address the issue.
      
      To help such restructure which requires supporting multiple waiters,
      this patch replaces kernfs_node->u.completion with
      kernfs_root->deactivate_waitq.  This makes deactivation event
      notifications share a per-root waitqueue_head; however, the wait path
      is quite cold and this will also allow shaving one pointer off
      kernfs_node.
      
      v2: Refreshed on top of ("kernfs: make kernfs_deactivate() honor
          KERNFS_LOCKDEP flag").
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      abd54f02
    • Tejun Heo's avatar
      kernfs: make kernfs_deactivate() honor KERNFS_LOCKDEP flag · a6607930
      Tejun Heo authored
      kernfs_deactivate() forgot to check whether KERNFS_LOCKDEP is set
      before performing lockdep annotations and ends up feeding
      uninitialized lockdep_map to lockdep triggering warning like the
      following on USB stick hotunplug.
      
       usb 1-2: USB disconnect, device number 2
       INFO: trying to register non-static key.
       the code is fine but needs lockdep annotation.
       turning off the locking correctness validator.
       CPU: 1 PID: 62 Comm: khubd Not tainted 3.13.0-work+ #82
       Hardware name: empty empty/S3992, BIOS 080011  10/26/2007
        ffff880065ca7f60 ffff88013a4ffa08 ffffffff81cfb6bd 0000000000000002
        ffff88013a4ffac8 ffffffff810f8530 ffff88013a4fc710 0000000000000002
        ffff880100000000 ffffffff82a3db50 0000000000000001 ffff88013a4fc710
       Call Trace:
        [<ffffffff81cfb6bd>] dump_stack+0x4e/0x7a
        [<ffffffff810f8530>] __lock_acquire+0x1910/0x1e70
        [<ffffffff810f931a>] lock_acquire+0x9a/0x1d0
        [<ffffffff8127c75e>] kernfs_deactivate+0xee/0x130
        [<ffffffff8127d4c8>] kernfs_addrm_finish+0x38/0x60
        [<ffffffff8127d701>] kernfs_remove_by_name_ns+0x51/0xa0
        [<ffffffff8127b4f1>] remove_files.isra.1+0x41/0x80
        [<ffffffff8127b7e7>] sysfs_remove_group+0x47/0xa0
        [<ffffffff8127b873>] sysfs_remove_groups+0x33/0x50
        [<ffffffff8177d66d>] device_remove_attrs+0x4d/0x80
        [<ffffffff8177e25e>] device_del+0x12e/0x1d0
        [<ffffffff819722c2>] usb_disconnect+0x122/0x1a0
        [<ffffffff819749b5>] hub_thread+0x3c5/0x1290
        [<ffffffff810c6a6d>] kthread+0xed/0x110
        [<ffffffff81d0a56c>] ret_from_fork+0x7c/0xb0
      
      Fix it by making kernfs_deactivate() perform lockdep annotations only
      if KERNFS_LOCKDEP is set.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Reported-by: default avatarFabio Estevam <festevam@gmail.com>
      Reported-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a6607930
    • Colin Cross's avatar
      dma-buf: avoid using IS_ERR_OR_NULL · fee0c54e
      Colin Cross authored
      dma_buf_map_attachment and dma_buf_vmap can return NULL or
      ERR_PTR on a error.  This encourages a common buggy pattern in
      callers:
      	sgt = dma_buf_map_attachment(attach, DMA_BIDIRECTIONAL);
      	if (IS_ERR_OR_NULL(sgt))
                      return PTR_ERR(sgt);
      
      This causes the caller to return 0 on an error.  IS_ERR_OR_NULL
      is almost always a sign of poorly-defined error handling.
      
      This patch converts dma_buf_map_attachment to always return
      ERR_PTR, and fixes the callers that incorrectly handled NULL.
      There are a few more callers that were not checking for NULL
      at all, which would have dereferenced a NULL pointer later.
      There are also a few more callers that correctly handled NULL
      and ERR_PTR differently, I left those alone but they could also
      be modified to delete the NULL check.
      
      This patch also converts dma_buf_vmap to always return NULL.
      All the callers to dma_buf_vmap only check for NULL, and would
      have dereferenced an ERR_PTR and panic'd if one was ever
      returned. This is not consistent with the rest of the dma buf
      APIs, but matches the expectations of all of the callers.
      Signed-off-by: default avatarColin Cross <ccross@android.com>
      Reviewed-by: default avatarRob Clark <robdclark@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fee0c54e
  2. 03 Feb, 2014 4 commits
    • Linus Torvalds's avatar
      Linus 3.14-rc1 · 38dbfb59
      Linus Torvalds authored
      38dbfb59
    • Linus Torvalds's avatar
      Merge branch 'parisc-3.14' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux · 69048e01
      Linus Torvalds authored
      Pull parisc updates from Helge Deller:
       "The three major changes in this patchset is a implementation for
        flexible userspace memory maps, cache-flushing fixes (again), and a
        long-discussed ABI change to make EWOULDBLOCK the same value as
        EAGAIN.
      
        parisc has been the only platform where we had EWOULDBLOCK != EAGAIN
        to keep HP-UX compatibility.  Since we will probably never implement
        full HP-UX support, we prefer to drop this compatibility to make it
        easier for us with Linux userspace programs which mostly never checked
        for both values.  We don't expect major fall-outs because of this
        change, and if we face some, we will simply rebuild the necessary
        applications in the debian archives"
      
      * 'parisc-3.14' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux:
        parisc: add flexible mmap memory layout support
        parisc: Make EWOULDBLOCK be equal to EAGAIN on parisc
        parisc: convert uapi/asm/stat.h to use native types only
        parisc: wire up sched_setattr and sched_getattr
        parisc: fix cache-flushing
        parisc/sti_console: prefer Linux fonts over built-in ROM fonts
      69048e01
    • Mikulas Patocka's avatar
      hpfs: optimize quad buffer loading · 1c0b8a7a
      Mikulas Patocka authored
      HPFS needs to load 4 consecutive 512-byte sectors when accessing the
      directory nodes or bitmaps.  We can't switch to 2048-byte block size
      because files are allocated in the units of 512-byte sectors.
      
      Previously, the driver would allocate a 2048-byte area using kmalloc,
      copy the data from four buffers to this area and eventually copy them
      back if they were modified.
      
      In the current implementation of the buffer cache, buffers are allocated
      in the pagecache.  That means that 4 consecutive 512-byte buffers are
      stored in consecutive areas in the kernel address space.  So, we don't
      need to allocate extra memory and copy the content of the buffers there.
      
      This patch optimizes the code to avoid copying the buffers.  It checks
      if the four buffers are stored in contiguous memory - if they are not,
      it falls back to allocating a 2048-byte area and copying data there.
      Signed-off-by: default avatarMikulas Patocka <mikulas@artax.karlin.mff.cuni.cz>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      1c0b8a7a
    • Mikulas Patocka's avatar
      hpfs: remember free space · 2cbe5c76
      Mikulas Patocka authored
      Previously, hpfs scanned all bitmaps each time the user asked for free
      space using statfs.  This patch changes it so that hpfs scans the
      bitmaps only once, remembes the free space and on next invocation of
      statfs it returns the value instantly.
      
      New versions of wine are hammering on the statfs syscall very heavily,
      making some games unplayable when they're stored on hpfs, with load
      times in minutes.
      
      This should be backported to the stable kernels because it fixes
      user-visible problem (excessive level load times in wine).
      Signed-off-by: default avatarMikulas Patocka <mikulas@artax.karlin.mff.cuni.cz>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      2cbe5c76
  3. 02 Feb, 2014 12 commits
  4. 01 Feb, 2014 12 commits
  5. 31 Jan, 2014 5 commits
    • Linus Torvalds's avatar
      Merge tag 'nfs-for-3.14-2' of git://git.linux-nfs.org/projects/trondmy/linux-nfs · 8a1f006a
      Linus Torvalds authored
      Pull NFS client bugfixes from Trond Myklebust:
       "Highlights:
      
         - Fix several races in nfs_revalidate_mapping
         - NFSv4.1 slot leakage in the pNFS files driver
         - Stable fix for a slot leak in nfs40_sequence_done
         - Don't reject NFSv4 servers that support ACLs with only ALLOW aces"
      
      * tag 'nfs-for-3.14-2' of git://git.linux-nfs.org/projects/trondmy/linux-nfs:
        nfs: initialize the ACL support bits to zero.
        NFSv4.1: Cleanup
        NFSv4.1: Clean up nfs41_sequence_done
        NFSv4: Fix a slot leak in nfs40_sequence_done
        NFSv4.1 free slot before resending I/O to MDS
        nfs: add memory barriers around NFS_INO_INVALID_DATA and NFS_INO_INVALIDATING
        NFS: Fix races in nfs_revalidate_mapping
        sunrpc: turn warn_gssd() log message into a dprintk()
        NFS: fix the handling of NFS_INO_INVALID_DATA flag in nfs_revalidate_mapping
        nfs: handle servers that support only ALLOW ACE type.
      8a1f006a
    • Linus Torvalds's avatar
      Merge tag 'sound-fix-3.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound · 14864a52
      Linus Torvalds authored
      Pull sound fixes from Takashi Iwai:
       "The big chunks here are the updates for oxygen driver for Xonar DG
        devices, which were slipped from the previous pull request.  They are
        device-specific and thus not too dangerous.
      
        Other than that, all patches are small bug fixes, mainly for Samsung
        build fixes, a few HD-audio enhancements, and other misc ASoC fixes.
        (And this time ASoC merge is less than Octopus, lucky seven :)"
      
      * tag 'sound-fix-3.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound: (42 commits)
        ALSA: hda/hdmi - allow PIN_OUT to be dynamically enabled
        ALSA: hda - add headset mic detect quirks for another Dell laptop
        ALSA: oxygen: Xonar DG(X): cleanup and minor changes
        ALSA: oxygen: Xonar DG(X): modify high-pass filter control
        ALSA: oxygen: Xonar DG(X): modify input select functions
        ALSA: oxygen: Xonar DG(X): modify capture volume functions
        ALSA: oxygen: Xonar DG(X): use headphone volume control
        ALSA: oxygen: Xonar DG(X): modify playback output select
        ALSA: oxygen: Xonar DG(X): capture from I2S channel 1, not 2
        ALSA: oxygen: Xonar DG(X): move the mixer code into another file
        ALSA: oxygen: modify CS4245 register dumping function
        ALSA: oxygen: modify adjust_dg_dac_routing function
        ALSA: oxygen: Xonar DG(X): modify DAC/ADC parameters function
        ALSA: oxygen: Xonar DG(X): modify initialization functions
        ALSA: oxygen: Xonar DG(X): add new CS4245 SPI functions
        ALSA: oxygen: additional definitions for the Xonar DG/DGX card
        ALSA: oxygen: change description of the xonar_dg.c file
        ALSA: oxygen: export oxygen_update_dac_routing symbol
        ALSA: oxygen: add mute mask for the OXYGEN_PLAY_ROUTING register
        ALSA: oxygen: modify the SPI writing function
        ...
      14864a52
    • Linus Torvalds's avatar
      Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending · 4e13c5d0
      Linus Torvalds authored
      Pull SCSI target updates from Nicholas Bellinger:
       "The highlights this round include:
      
        - add support for SCSI Referrals (Hannes)
        - add support for T10 DIF into target core (nab + mkp)
        - add support for T10 DIF emulation in FILEIO + RAMDISK backends (Sagi + nab)
        - add support for T10 DIF -> bio_integrity passthrough in IBLOCK backend (nab)
        - prep changes to iser-target for >= v3.15 T10 DIF support (Sagi)
        - add support for qla2xxx N_Port ID Virtualization - NPIV (Saurav + Quinn)
        - allow percpu_ida_alloc() to receive task state bitmask (Kent)
        - fix >= v3.12 iscsi-target session reset hung task regression (nab)
        - fix >= v3.13 percpu_ref se_lun->lun_ref_active race (nab)
        - fix a long-standing network portal creation race (Andy)"
      
      * 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending: (51 commits)
        target: Fix percpu_ref_put race in transport_lun_remove_cmd
        target/iscsi: Fix network portal creation race
        target: Report bad sector in sense data for DIF errors
        iscsi-target: Convert gfp_t parameter to task state bitmask
        iscsi-target: Fix connection reset hang with percpu_ida_alloc
        percpu_ida: Make percpu_ida_alloc + callers accept task state bitmask
        iscsi-target: Pre-allocate more tags to avoid ack starvation
        qla2xxx: Configure NPIV fc_vport via tcm_qla2xxx_npiv_make_lport
        qla2xxx: Enhancements to enable NPIV support for QLOGIC ISPs with TCM/LIO.
        qla2xxx: Fix scsi_host leak on qlt_lport_register callback failure
        IB/isert: pass scatterlist instead of cmd to fast_reg_mr routine
        IB/isert: Move fastreg descriptor creation to a function
        IB/isert: Avoid frwr notation, user fastreg
        IB/isert: seperate connection protection domains and dma MRs
        tcm_loop: Enable DIF/DIX modes in SCSI host LLD
        target/rd: Add DIF protection into rd_execute_rw
        target/rd: Add support for protection SGL setup + release
        target/rd: Refactor rd_build_device_space + rd_release_device_space
        target/file: Add DIF protection support to fd_execute_rw
        target/file: Add DIF protection init/format support
        ...
      4e13c5d0
    • Lorenzo Pieralisi's avatar
      drivers: bus: fix CCI driver kcalloc call parameters swap · 7c762036
      Lorenzo Pieralisi authored
      This patch fixes a bug/typo in the CCI driver kcalloc usage
      that inadvertently swapped the parameters order in the
      kcalloc call and went unnoticed.
      Reported-by: default avatarXia Feng <xiafeng@allwinnertech.com>
      Signed-off-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Signed-off-by: default avatarOlof Johansson <olof@lixom.net>
      7c762036
    • Tim Kryger's avatar
      ARM: dts: bcm28155-ap: Fix Card Detection GPIO · 94db37ad
      Tim Kryger authored
      The board schematic states that the "SD_CARD_DET_N gets pulled to GND
      when card is inserted" so the polarity has been updated to active low.
      
      Polarity is now specified with a GPIO define instead of a magic number.
      Signed-off-by: default avatarTim Kryger <tim.kryger@linaro.org>
      Reviewed-by: default avatarMatt Porter <matt.porter@linaro.org>
      Signed-off-by: default avatarOlof Johansson <olof@lixom.net>
      94db37ad