1. 03 9月, 2013 4 次提交
    • L
      lockref: implement lockless reference count updates using cmpxchg() · bc08b449
      Linus Torvalds 提交于
      Instead of taking the spinlock, the lockless versions atomically check
      that the lock is not taken, and do the reference count update using a
      cmpxchg() loop.  This is semantically identical to doing the reference
      count update protected by the lock, but avoids the "wait for lock"
      contention that you get when accesses to the reference count are
      contended.
      
      Note that a "lockref" is absolutely _not_ equivalent to an atomic_t.
      Even when the lockref reference counts are updated atomically with
      cmpxchg, the fact that they also verify the state of the spinlock means
      that the lockless updates can never happen while somebody else holds the
      spinlock.
      
      So while "lockref_put_or_lock()" looks a lot like just another name for
      "atomic_dec_and_lock()", and both optimize to lockless updates, they are
      fundamentally different: the decrement done by atomic_dec_and_lock() is
      truly independent of any lock (as long as it doesn't decrement to zero),
      so a locked region can still see the count change.
      
      The lockref structure, in contrast, really is a *locked* reference
      count.  If you hold the spinlock, the reference count will be stable and
      you can modify the reference count without using atomics, because even
      the lockless updates will see and respect the state of the lock.
      
      In order to enable the cmpxchg lockless code, the architecture needs to
      do three things:
      
       (1) Make sure that the "arch_spinlock_t" and an "unsigned int" can fit
           in an aligned u64, and have a "cmpxchg()" implementation that works
           on such a u64 data type.
      
       (2) define a helper function to test for a spinlock being unlocked
           ("arch_spin_value_unlocked()")
      
       (3) select the "ARCH_USE_CMPXCHG_LOCKREF" config variable in its
           Kconfig file.
      
      This enables it for x86-64 (but not 32-bit, we'd need to make sure
      cmpxchg() turns into the proper cmpxchg8b in order to enable it for
      32-bit mode).
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      bc08b449
    • L
      lockref: uninline lockref helper functions · 2f4f12e5
      Linus Torvalds 提交于
      They aren't very good to inline, since they already call external
      functions (the spinlock code), and we're going to create rather more
      complicated versions of them that can do the reference count updates
      locklessly.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      2f4f12e5
    • L
      vfs: reimplement d_rcu_to_refcount() using lockref_get_or_lock() · 15570086
      Linus Torvalds 提交于
      This moves __d_rcu_to_refcount() from <linux/dcache.h> into fs/namei.c
      and re-implements it using the lockref infrastructure instead.  It also
      adds a lot of comments about what is actually going on, because turning
      a dentry that was looked up using RCU into a long-lived reference
      counted entry is one of the more subtle parts of the rcu walk.
      
      We also used to be _particularly_ subtle in unlazy_walk() where we
      re-validate both the dentry and its parent using the same sequence
      count.  We used to do it by nesting the locks and then verifying the
      sequence count just once.
      
      That was silly, because nested locking is expensive, but the sequence
      count check is not.  So this just re-validates the dentry and the parent
      separately, avoiding the nested locking, and making the lockref lookup
      possible.
      Acked-by: NWaiman Long <waiman.long@hp.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      15570086
    • L
      lockref: add 'lockref_get_or_lock() helper · b3abd802
      Linus Torvalds 提交于
      This behaves like "lockref_get_not_zero()", but instead of doing nothing
      if the count was zero, it returns with the lock held.
      
      This allows callers to revalidate the lockref-protected data structure
      if required even if the count was zero to begin with, and possibly
      increment the count if it passes muster.
      
      In particular, the dentry code wants this when it wants to turn an
      RCU-protected dentry into a stable refcounted one: if the dentry count
      it zero, but the sequence number still validates the dentry, we can take
      a reference to it.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      b3abd802
  2. 31 8月, 2013 1 次提交
  3. 30 8月, 2013 4 次提交
    • A
      regulator: tps65217: Convert to use linear ranges · 6290d606
      Axel Lin 提交于
      Below is the equation in original code:
      
      tps65217_uv1_ranges:
              0  ... 24: uV = vsel * 25000 + 900000;
              25 ... 52: uV = (vsel - 24) * 50000 + 1500000;
                            = (vsel - 25) * 50000 + 1550000;
              53 ... 55: uV = (vsel - 52) * 100000 + 2900000;
                            = (vsel - 53) * 100000 + 3000000;
              56 ... 62: uV = 3300000;
      
      tps65217_uv2_ranges:
              0  ...  8: uV = vsel * 50000 + 1500000;
              9  ... 13: uV = (vsel - 8) * 100000 + 1900000;
                            = (vsel - 9) * 100000 + 2000000;
              14 ... 31: uV = (vsel - 13) * 50000 + 2400000;
                            = (vsel - 14) * 50000 + 2450000;
      
      The voltage tables are composed of linear ranges.
      This patch converts this driver to use multiple linear ranges APIs.
      
      In original code, voltage range for DCDC1 is 900000 ~ 1800000 and voltage range
      for DCDC3 is 900000 ~ 1500000.  This patch separates the range 25~52 in
      tps65217_uv1_ranges table to two linear ranges: 25~30 and 31~52.
      This change makes it possible to reuse the same linear_ranges table for DCDCx.
      Signed-off-by: NAxel Lin <axel.lin@ingics.com>
      Signed-off-by: NMark Brown <broonie@linaro.org>
      6290d606
    • J
      iio: at91: Use different prescal, startup mask in MR for different IP · 9120c0be
      Josh Wu 提交于
      For at91 boards, there are different IPs for adc. Different IPs has different
      STARTUP & PRESCAL mask in ADC_MR.
      Signed-off-by: NJosh Wu <josh.wu@atmel.com>
      Acked-by: NMaxime Ripard <maxime.ripard@free-electrons.com>
      Signed-off-by: NJonathan Cameron <jic23@kernel.org>
      9120c0be
    • R
      driver core / ACPI: Avoid device hot remove locking issues · 5e33bc41
      Rafael J. Wysocki 提交于
      device_hotplug_lock is held around the acpi_bus_trim() call in
      acpi_scan_hot_remove() which generally removes devices (it removes
      ACPI device objects at least, but it may also remove "physical"
      device objects through .detach() callbacks of ACPI scan handlers).
      Thus, potentially, device sysfs attributes are removed under that
      lock and to remove those attributes it is necessary to hold the
      s_active references of their directory entries for writing.
      
      On the other hand, the execution of a .show() or .store() callback
      from a sysfs attribute is carried out with that attribute's s_active
      reference held for reading.  Consequently, if any device sysfs
      attribute that may be removed from within acpi_scan_hot_remove()
      through acpi_bus_trim() has a .store() or .show() callback which
      acquires device_hotplug_lock, the execution of that callback may
      deadlock with the removal of the attribute.  [Unfortunately, the
      "online" device attribute of CPUs and memory blocks is one of them.]
      
      To avoid such deadlocks, make all of the sysfs attribute callbacks
      that need to lock device hotplug, for example store_online(), use
      a special function, lock_device_hotplug_sysfs(), to lock device
      hotplug and return the result of that function immediately if it is
      not zero.  This will cause the s_active reference of the directory
      entry in question to be released and the syscall to be restarted
      if device_hotplug_lock cannot be acquired.
      
      [show_online() actually doesn't need to lock device hotplug, but
      it is useful to serialize it with respect to device_offline() and
      device_online() for the same device (in case user space attempts to
      run them concurrently) which can be done with the help of
      device_lock().]
      Reported-by: NYasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
      Reported-and-tested-by: NGu Zheng <guz.fnst@cn.fujitsu.com>
      Suggested-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Acked-by: NToshi Kani <toshi.kani@hp.com>
      5e33bc41
    • M
      regulator: Add devm_regulator_get_exclusive() · 9efdd276
      Matthias Kaehlcke 提交于
      Add a resource managed regulator_get_exclusive()
      Signed-off-by: NMatthias Kaehlcke <matthias@kaehlcke.net>
      Signed-off-by: NMark Brown <broonie@linaro.org>
      9efdd276
  4. 29 8月, 2013 4 次提交
    • W
      vfs: make the dentry cache use the lockref infrastructure · 98474236
      Waiman Long 提交于
      This just replaces the dentry count/lock combination with the lockref
      structure that contains both a count and a spinlock, and does the
      mechanical conversion to use the lockref infrastructure.
      
      There are no semantic changes here, it's purely syntactic.  The
      reference lockref implementation uses the spinlock exactly the same way
      that the old dcache code did, and the bulk of this patch is just
      expanding the internal "d_count" use in the dcache code to use
      "d_lockref.count" instead.
      
      This is purely preparation for the real change to make the reference
      count updates be lockless during the 3.12 merge window.
      
      [ As with the previous commit, this is a rewritten version of a concept
        originally from Waiman, so credit goes to him, blame for any errors
        goes to me.
      
        Waiman's patch had some semantic differences for taking advantage of
        the lockless update in dget_parent(), while this patch is
        intentionally a pure search-and-replace change with no semantic
        changes.     - Linus ]
      Signed-off-by: NWaiman Long <Waiman.Long@hp.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      98474236
    • W
      Add new lockref infrastructure reference implementation · 0f8f2aaa
      Waiman Long 提交于
      This introduces a new "lockref" structure that supports the concept of
      lockless updates of reference counts that still honor an attached
      spinlock.
      
      NOTE! This reference implementation is not the optimized lockless
      version, rather it is the fallback implementation using standard
      spinlocks.  The actual optimized versions will be merged into 3.12, but
      I wanted to get the infrastructure in place and document the new
      interfaces.
      
      [ Also note that this particular commit is drastically cut-down minimal
        version of the original patch by Waiman.  In order to properly credit
        the original author I'm marking Waiman as the author here, but in the
        end this patch bears little resemblance to the patch by Waiman.  So
        blame any errors on me editing things down to the point where I can
        introduce the infrastructure before the merge window for 3.12 actually
        opens.     - Linus ]
      Signed-off-by: NWaiman Long <Waiman.Long@hp.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      0f8f2aaa
    • D
      dev-core: fix build break when DEBUG is enabled · 8ef2d651
      Dmitry Kasatkin 提交于
      When DEBUG is defined, dev_dbg_ratelimited uses dynamic debug data
      structures even when CONFIG_DYNAMIC_DEBUG is not defined.
      It leads to build break.
      For example, when I try to use dev_dbg_ratelimited in USB code and
      CONFIG_USB_DEBUG is enabled, but CONFIG_DYNAMIC_DEBUG is not, I get:
      
        CC [M]  drivers/usb/host/xhci-ring.o
        drivers/usb/host/xhci-ring.c: In function ‘xhci_queue_intr_tx’:
        drivers/usb/host/xhci-ring.c:3059:3: error: implicit declaration of function ‘DEFINE_DYNAMIC_DEBUG_METADATA’ [-Werror=implicit-function-declaration]
        drivers/usb/host/xhci-ring.c:3059:3: error: ‘descriptor’ undeclared (first use in this function)
        drivers/usb/host/xhci-ring.c:3059:3: note: each undeclared identifier is reported only once for each function it appears in
        drivers/usb/host/xhci-ring.c:3059:3: error: implicit declaration of function ‘__dynamic_pr_debug’ [-Werror=implicit-function-declaration]
        drivers/usb/host/xhci-ring.c: In function ‘xhci_queue_isoc_tx_prepare’:
        drivers/usb/host/xhci-ring.c:3847:3: error: ‘descriptor’ undeclared (first use in this function)
        cc1: some warnings being treated as errors
        make[2]: *** [drivers/usb/host/xhci-ring.o] Error 1
        make[1]: *** [drivers/usb/host] Error 2
        make: *** [drivers/usb/] Error 2
      
      This patch separates definition for CONFIG_DYNAMIC_DEBUG and DEBUG cases.
      
      [Note, Sarah moved the comment above the macro to avoid checkpatch
      warnings.]
      Signed-off-by: NDmitry Kasatkin <d.kasatkin@samsung.com>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8ef2d651
    • G
      sysfs: sysfs_create_groups returns a value. · 574979c6
      Greg Kroah-Hartman 提交于
      When I included the "empty" function for sysfs_create_groups() when
      CONFIG_SYSFS=n, I forgot to return a value for it, so things blew up the
      build.  This patch fixes that, stupid me.
      Reported-by: Nkbuild test robot <fengguang.wu@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      574979c6
  5. 28 8月, 2013 3 次提交
  6. 25 8月, 2013 1 次提交
  7. 24 8月, 2013 2 次提交
  8. 23 8月, 2013 6 次提交
  9. 22 8月, 2013 6 次提交
    • M
      [SCSI] zfcp: fix lock imbalance by reworking request queue locking · d79ff142
      Martin Peschke 提交于
      This patch adds wait_event_interruptible_lock_irq_timeout(), which is a
      straight-forward descendant of wait_event_interruptible_timeout() and
      wait_event_interruptible_lock_irq().
      
      The zfcp driver used to call wait_event_interruptible_timeout()
      in combination with some intricate and error-prone locking. Using
      wait_event_interruptible_lock_irq_timeout() as a replacement
      nicely cleans up that locking.
      
      This rework removes a situation that resulted in a locking imbalance
      in zfcp_qdio_sbal_get():
      
      BUG: workqueue leaked lock or atomic: events/1/0xffffff00/10
          last function: zfcp_fc_wka_port_offline+0x0/0xa0 [zfcp]
      
      It was introduced by commit c2af7545
      "[SCSI] zfcp: Do not wait for SBALs on stopped queue", which had a new
      code path related to ZFCP_STATUS_ADAPTER_QDIOUP that took an early exit
      without a required lock being held. The problem occured when a
      special, non-SCSI I/O request was being submitted in process context,
      when the adapter's queues had been torn down. In this case the bug
      surfaced when the Fibre Channel port connection for a well-known address
      was closed during a concurrent adapter shut-down procedure, which is a
      rare constellation.
      
      This patch also fixes these warnings from the sparse tool (make C=1):
      
      drivers/s390/scsi/zfcp_qdio.c:224:12: warning: context imbalance in
       'zfcp_qdio_sbal_check' - wrong count at exit
      drivers/s390/scsi/zfcp_qdio.c:244:5: warning: context imbalance in
       'zfcp_qdio_sbal_get' - unexpected unlock
      
      Last but not least, we get rid of that crappy lock-unlock-lock
      sequence at the beginning of the critical section.
      
      It is okay to call zfcp_erp_adapter_reopen() with req_q_lock held.
      Reported-by: NMikulas Patocka <mpatocka@redhat.com>
      Reported-by: NHeiko Carstens <heiko.carstens@de.ibm.com>
      Signed-off-by: NMartin Peschke <mpeschke@linux.vnet.ibm.com>
      Cc: stable@vger.kernel.org #2.6.35+
      Signed-off-by: NSteffen Maier <maier@linux.vnet.ibm.com>
      Signed-off-by: NJames Bottomley <JBottomley@Parallels.com>
      d79ff142
    • W
      spi: DUAL and QUAD support · f477b7fb
      wangyuhang 提交于
      fix the previous patch some mistake below:
      1. DT in slave node, use "spi-tx-nbits = <1/2/4>" in place of using
         "spi-tx-dual, spi-tx-quad" directly, same to rx. So correct the
         previous way to get the property in @of_register_spi_devices().
      2. Change the value of transfer bit macro(SPI_NBITS_SINGLE, SPI_NBITS_DUAL
         SPI_NBITS_QUAD) to 0x01, 0x02 and 0x04 to match the actual wires.
      3. Add the following check
         (1)keep the tx_nbits and rx_nbits in spi_transfer is not beyond the
            single, dual and quad.
         (2)keep tx_nbits and rx_nbits are contained by @spi_device->mode
            example: if @spi_device->mode = DUAL, then tx/rx_nbits can not be set
                     to QUAD(SPI_NBITS_QUAD)
         (3)if "@spi_device->mode & SPI_3WIRE", then tx/rx_nbits should be in
            single(SPI_NBITS_SINGLE)
      Signed-off-by: Nwangyuhang <wangyuhang2014@gmail.com>
      Signed-off-by: NMark Brown <broonie@linaro.org>
      f477b7fb
    • G
      sysfs: fix up minor coding style issues in sysfs.h · 5da5c9c8
      Greg Kroah-Hartman 提交于
      As long as we are cleaning up sysfs coding style issues, don't forget
      the main sysfs.h file, so fix up the space issues there as well.
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5da5c9c8
    • G
      sysfs: add sysfs_create/remove_groups() · 3e9b2bae
      Greg Kroah-Hartman 提交于
      These functions are being open-coded in 3 different places in the driver
      core, and other driver subsystems will want to start doing this as well,
      so move it to the sysfs core to keep it all in one place, where we know
      it is written properly.
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3e9b2bae
    • S
      drivers: base: use standard device online/offline for state change · fa2be40f
      Seth Jennings 提交于
      There are two ways to set the online/offline state for a memory block:
      echo 0|1 > online and echo online|online_kernel|online_movable|offline >
      state.
      
      The state attribute can online a memory block with extra data, the
      "online type", where the online attribute uses a default online type of
      ONLINE_KEEP, same as echo online > state.
      
      Currently there is a state_mutex that provides consistency between the
      memory block state and the underlying memory.
      
      The problem is that this code does a lot of things that the common
      device layer can do for us, such as the serialization of the
      online/offline handlers using the device lock, setting the dev->offline
      field, and calling kobject_uevent().
      
      This patch refactors the online/offline code to allow the common
      device_[online|offline] functions to be used.  The result is a simpler
      and more common code path for the two state setting mechanisms.  It also
      removes the state_mutex from the struct memory_block as the memory block
      device lock provides the state consistency.
      
      No functional change is intended by this patch.
      Signed-off-by: NSeth Jennings <sjenning@linux.vnet.ibm.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fa2be40f
    • S
      drivers: base: reduce add_memory_section() for boot-time only · 37a7bd62
      Seth Jennings 提交于
      Now that add_memory_section() is only called from boot time, reduce
      the logic and remove the enum.
      Signed-off-by: NSeth Jennings <sjenning@linux.vnet.ibm.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      37a7bd62
  10. 21 8月, 2013 3 次提交
  11. 20 8月, 2013 2 次提交
  12. 18 8月, 2013 1 次提交
  13. 16 8月, 2013 3 次提交
    • T
      USB: WUSBCORE: clear RPIPE stall for control endpoints · 6d33f7bb
      Thomas Pugliese 提交于
      When the HWA encounters a STALL on a control endpoint, it should clear the
      RPIPE_STALL feature on the RPIPE before processing the next transfer
      request.  Otherwise, all transfer requests on that endpoint after the
      first STALL will fail because the RPIPE is still in the halted state.
      This also removes the unneccessary call to spin_lock_irqsave for a nested
      lock that was present in the first patch.
      Signed-off-by: NThomas Pugliese <thomas.pugliese@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6d33f7bb
    • J
      Staging: olpc_dcon: replace some magic numbers · 98d4f93c
      Jens Frederich 提交于
      This patch replace some magic numbers. I believe it makes
      the driver more readable.
      
      The magic number 0x26 is the XO system embedded controller
      (EC) command 'DCON power enable/disable'.
      
      Number 0x41, and 0x42 are special memory controller settings
      register.  The 0x41 initialize bit sequence 0x101 means:
      enable memory power down function and special SDRAM clock
      delay for synchronize SDRAM output and clock signal.
      
      The 0x42 initialize squence 0x101 is wrong.  According to
      the specification Bit 8 is reserved, thus not in use.
      I removed it.
      Signed-off-by: NJens Frederich <jfrederich@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      98d4f93c
    • M
      net/mlx5_core: Support MANAGE_PAGES and QUERY_PAGES firmware command changes · 0a324f31
      Moshe Lazer 提交于
      In the previous QUERY_PAGES command version we used one command to get the
      required amount of boot, init and post init pages.  The new version uses the
      op_mod field to specify whether the query is for the required amount of boot,
      init or post init pages. In addition the output field size for the required
      amount of pages increased from 16 to 32 bits.
      
      In MANAGE_PAGES command the input_num_entries and output_num_entries fields
      sizes changed from 16 to 32 bits and the PAS tables offset changed to 0x10.
      
      In the pages request event the num_pages field also changed to 32 bits.
      
      In the HCA-capabilities-layout the size and location of max_qp_mcg field has
      been changed to support 24 bits.
      
      This patch isn't compatible with firmware versions < 5; however, it  turns out that the
      first GA firmware we will publish will not support previous versions so this should be OK.
      Signed-off-by: NMoshe Lazer <moshel@mellanox.com>
      Signed-off-by: NEli Cohen <eli@mellanox.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      0a324f31