1. 25 Apr, 2013 40 commits
    • Carsten Emde's avatar
      drm/i915: panel: invert brightness via parameter · f76bb07c
      Carsten Emde authored
      commit 7bd90909 upstream.
      
      Following the documentation of the Legacy Backlight Brightness (LBB)
      Register in the configuration space of some Intel PCI graphics adapters,
      setting the LBB register with the value 0x0 causes the backlight to be
      turned off, and 0xFF causes the backlight to be set to 100% intensity
      (http://download.intel.com/embedded/processors/Whitepaper/324567.pdf).
      The Acer Aspire 5734Z, however, turns the backlight off at 0xFF and sets
      it to maximum intensity at 0. In consequence, the screen of this systems
      becomes dark at an early boot stage which makes it unusable. The same
      inversion applies to the BLC_PWM_CTL I915 register. This problem was
      introduced in kernel version 2.6.38 when the PCI device of this system
      was first supported by the i915 KMS module.
      
      This patch adds a parameter to the i915 module to enable inversion of
      the brightness variable (i915.invert_brightness).
      Signed-off-by: default avatarCarsten Emde <C.Emde@osadl.org>
      Reviewed-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Acked-by: default avatarJani Nikula <jani.nikula@intel.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      f76bb07c
    • Chris Mason's avatar
      Btrfs: fix race between mmap writes and compression · e6742b36
      Chris Mason authored
      commit 4adaa611 upstream.
      
      Btrfs uses page_mkwrite to ensure stable pages during
      crc calculations and mmap workloads.  We call clear_page_dirty_for_io
      before we do any crcs, and this forces any application with the file
      mapped to wait for the crc to finish before it is allowed to change
      the file.
      
      With compression on, the clear_page_dirty_for_io step is happening after
      we've compressed the pages.  This means the applications might be
      changing the pages while we are compressing them, and some of those
      modifications might not hit the disk.
      
      This commit adds the clear_page_dirty_for_io before compression starts
      and makes sure to redirty the page if we have to fallback to
      uncompressed IO as well.
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      Reported-by: default avatarAlexandre Oliva <oliva@gnu.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      e6742b36
    • Wu Fengguang's avatar
      writeback: fix dirtied pages accounting on redirty · 40e5c2b1
      Wu Fengguang authored
      commit 2f800fbd upstream.
      
      De-account the accumulative dirty counters on page redirty.
      
      Page redirties (very common in ext4) will introduce mismatch between
      counters (a) and (b)
      
      a) NR_DIRTIED, BDI_DIRTIED, tsk->nr_dirtied
      b) NR_WRITTEN, BDI_WRITTEN
      
      This will introduce systematic errors in balanced_rate and result in
      dirty page position errors (ie. the dirty pages are no longer balanced
      around the global/bdi setpoints).
      Acked-by: default avatarJan Kara <jack@suse.cz>
      Acked-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
      Signed-off-by: default avatarWu Fengguang <fengguang.wu@intel.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      40e5c2b1
    • Richard Guy Briggs's avatar
      thermal: return an error on failure to register thermal class · 2f0500f5
      Richard Guy Briggs authored
      commit da28d966 upstream.
      
      The return code from the registration of the thermal class is used to
      unallocate resources, but this failure isn't passed back to the caller of
      thermal_init.  Return this failure back to the caller.
      
      This bug was introduced in changeset 4cb18728 which overwrote the return code
      when the variable was re-used to catch the return code of the registration of
      the genetlink thermal socket family.
      Signed-off-by: default avatarRichard Guy Briggs <rbriggs@redhat.com>
      Signed-off-by: default avatarZhang Rui <rui.zhang@intel.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      2f0500f5
    • Linus Torvalds's avatar
      net: fix incorrect credentials passing · 5428146e
      Linus Torvalds authored
      commit 83f1b4ba upstream.
      
      Commit 257b5358 ("scm: Capture the full credentials of the scm
      sender") changed the credentials passing code to pass in the effective
      uid/gid instead of the real uid/gid.
      
      Obviously this doesn't matter most of the time (since normally they are
      the same), but it results in differences for suid binaries when the wrong
      uid/gid ends up being used.
      
      This just undoes that (presumably unintentional) part of the commit.
      Reported-by: default avatarAndy Lutomirski <luto@amacapital.net>
      Cc: Eric W. Biederman <ebiederm@xmission.com>
      Cc: Serge E. Hallyn <serge@hallyn.com>
      Cc: David S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Acked-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      [bwh: Backported to 3.2: scm_set_cred() does user namespace conversion
       of euid/egid using cred_to_ucred().  Add and use cred_real_to_ucred() to
       do the same thing for real uid/gid.]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      5428146e
    • Emese Revfy's avatar
      kernel/signal.c: stop info leak via the tkill and the tgkill syscalls · ffe1341e
      Emese Revfy authored
      commit b9e146d8 upstream.
      
      This fixes a kernel memory contents leak via the tkill and tgkill syscalls
      for compat processes.
      
      This is visible in the siginfo_t->_sifields._rt.si_sigval.sival_ptr field
      when handling signals delivered from tkill.
      
      The place of the infoleak:
      
      int copy_siginfo_to_user32(compat_siginfo_t __user *to, siginfo_t *from)
      {
              ...
              put_user_ex(ptr_to_compat(from->si_ptr), &to->si_ptr);
              ...
      }
      Signed-off-by: default avatarEmese Revfy <re.emese@gmail.com>
      Reviewed-by: default avatarPaX Team <pageexec@freemail.hu>
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Serge Hallyn <serge.hallyn@canonical.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      ffe1341e
    • Naoya Horiguchi's avatar
      hugetlbfs: add swap entry check in follow_hugetlb_page() · 7ec0873a
      Naoya Horiguchi authored
      commit 9cc3a5bd upstream.
      
      With applying the previous patch "hugetlbfs: stop setting VM_DONTDUMP in
      initializing vma(VM_HUGETLB)" to reenable hugepage coredump, if a memory
      error happens on a hugepage and the affected processes try to access the
      error hugepage, we hit VM_BUG_ON(atomic_read(&page->_count) <= 0) in
      get_page().
      
      The reason for this bug is that coredump-related code doesn't recognise
      "hugepage hwpoison entry" with which a pmd entry is replaced when a memory
      error occurs on a hugepage.
      
      In other words, physical address information is stored in different bit
      layout between hugepage hwpoison entry and pmd entry, so
      follow_hugetlb_page() which is called in get_dump_page() returns a wrong
      page from a given address.
      
      The expected behavior is like this:
      
        absent   is_swap_pte   FOLL_DUMP   Expected behavior
        -------------------------------------------------------------------
         true     false         false       hugetlb_fault
         false    true          false       hugetlb_fault
         false    false         false       return page
         true     false         true        skip page (to avoid allocation)
         false    true          true        hugetlb_fault
         false    false         true        return page
      
      With this patch, we can call hugetlb_fault() and take proper actions (we
      wait for migration entries, fail with VM_FAULT_HWPOISON_LARGE for
      hwpoisoned entries,) and as the result we can dump all hugepages except
      for hwpoisoned ones.
      Signed-off-by: default avatarNaoya Horiguchi <n-horiguchi@ah.jp.nec.com>
      Cc: Rik van Riel <riel@redhat.com>
      Acked-by: default avatarMichal Hocko <mhocko@suse.cz>
      Cc: HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
      Acked-by: default avatarKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
      Acked-by: default avatarDavid Rientjes <rientjes@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      7ec0873a
    • Will Deacon's avatar
      ARM: 7698/1: perf: fix group validation when using enable_on_exec · e23d55ac
      Will Deacon authored
      commit cb2d8b34 upstream.
      
      Events may be created with attr->disabled == 1 and attr->enable_on_exec
      == 1, which confuses the group validation code because events with the
      PERF_EVENT_STATE_OFF are not considered candidates for scheduling, which
      may lead to failure at group scheduling time.
      
      This patch fixes the validation check for ARM, so that events in the
      OFF state are still considered when enable_on_exec is true.
      
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Reported-by: default avatarSudeep KarkadaNagesha <Sudeep.KarkadaNagesha@arm.com>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      e23d55ac
    • Illia Ragozin's avatar
      ARM: 7696/1: Fix kexec by setting outer_cache.inv_all for Feroceon · 608ba3bf
      Illia Ragozin authored
      commit cd272d1e upstream.
      
      On Feroceon the L2 cache becomes non-coherent with the CPU
      when the L1 caches are disabled. Thus the L2 needs to be invalidated
      after both L1 caches are disabled.
      
      On kexec before the starting the code for relocation the kernel,
      the L1 caches are disabled in cpu_froc_fin (cpu_v7_proc_fin for Feroceon),
      but after L2 cache is never invalidated, because inv_all is not set
      in cache-feroceon-l2.c.
      So kernel relocation and decompression may has (and usually has) errors.
      Setting the function enables L2 invalidation and fixes the issue.
      Signed-off-by: default avatarIllia Ragozin <illia.ragozin@grapecom.com>
      Acked-by: default avatarJason Cooper <jason@lakedaemon.net>
      Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      608ba3bf
    • Felix Fietkau's avatar
      ath9k_hw: change AR9580 initvals to fix a stability issue · dffca037
      Felix Fietkau authored
      commit f09a8785 upstream.
      
      The hardware parsing of Control Wrapper Frames needs to be disabled, as
      it has been causing spurious decryption error reports. The initvals for
      other chips have been updated to disable it, but AR9580 was left out for
      some reason.
      Signed-off-by: default avatarFelix Fietkau <nbd@openwrt.org>
      Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      dffca037
    • Christoph Fritz's avatar
      can: sja1000: fix handling on dt properties on little endian systems · b53f79a6
      Christoph Fritz authored
      commit 0443de5f upstream.
      
      To get correct endianes on little endian cpus (like arm) while reading device
      tree properties, this patch replaces of_get_property() with
      of_property_read_u32(). While there use of_property_read_bool() for the
      handling of the boolean "nxp,no-comparator-bypass" property.
      Signed-off-by: default avatarChristoph Fritz <chf.fritz@googlemail.com>
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      b53f79a6
    • Jean-Christophe PLAGNIOL-VILLARD's avatar
      of: introduce helper to manage boolean · 2930913e
      Jean-Christophe PLAGNIOL-VILLARD authored
      commit fa4d34cc upstream.
      
      of_property_read_bool
      
      Search for a property in a device node.
      Returns true if the property exist false otherwise.
      Signed-off-by: default avatarJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
      Acked-by: default avatarRob Herring <rob.herring@calxeda.com>
      Acked-by: default avatarArnd Bergmann <arnd@arndb.de>
      Acked-by: default avatarGrant Likely <grant.likely@secretlab.ca>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      2930913e
    • Felix Fietkau's avatar
      ath9k_htc: accept 1.x firmware newer than 1.3 · add02e68
      Felix Fietkau authored
      commit 319e7bd9 upstream.
      
      Since the firmware has been open sourced, the minor version has been
      bumped to 1.4 and the API/ABI will stay compatible across further 1.x
      releases.
      Signed-off-by: default avatarFelix Fietkau <nbd@openwrt.org>
      Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      add02e68
    • Russell King's avatar
      ARM: Do 15e0d9e3 (ARM: pm: let platforms select cpu_suspend support) properly · 5e034d8d
      Russell King authored
      commit b6c7aabd upstream.
      
      Let's do the changes properly and fix the same problem everywhere, not
      just for one case.
      Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
      [bwh: Backported to 3.2: mohawk doesn't support suspend at all]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      5e034d8d
    • Suleiman Souhlal's avatar
      vfs: Revert spurious fix to spinning prevention in prune_icache_sb · 5ef143d9
      Suleiman Souhlal authored
      commit 5b55d708 upstream.
      
      Revert commit 62a3ddef ("vfs: fix spinning prevention in prune_icache_sb").
      
      This commit doesn't look right: since we are looking at the tail of the
      list (sb->s_inode_lru.prev) if we want to skip an inode, we should put
      it back at the head of the list instead of the tail, otherwise we will
      keep spinning on it.
      
      Discovered when investigating why prune_icache_sb came top in perf
      reports of a swapping load.
      Signed-off-by: default avatarSuleiman Souhlal <suleiman@google.com>
      Signed-off-by: default avatarHugh Dickins <hughd@google.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      5ef143d9
    • Linus Torvalds's avatar
      kobject: fix kset_find_obj() race with concurrent last kobject_put() · c6680a13
      Linus Torvalds authored
      commit a49b7e82 upstream.
      
      Anatol Pomozov identified a race condition that hits module unloading
      and re-loading.  To quote Anatol:
      
       "This is a race codition that exists between kset_find_obj() and
        kobject_put().  kset_find_obj() might return kobject that has refcount
        equal to 0 if this kobject is freeing by kobject_put() in other
        thread.
      
        Here is timeline for the crash in case if kset_find_obj() searches for
        an object tht nobody holds and other thread is doing kobject_put() on
        the same kobject:
      
          THREAD A (calls kset_find_obj())     THREAD B (calls kobject_put())
          splin_lock()
                                               atomic_dec_return(kobj->kref), counter gets zero here
                                               ... starts kobject cleanup ....
                                               spin_lock() // WAIT thread A in kobj_kset_leave()
          iterate over kset->list
          atomic_inc(kobj->kref) (counter becomes 1)
          spin_unlock()
                                               spin_lock() // taken
                                               // it does not know that thread A increased counter so it
                                               remove obj from list
                                               spin_unlock()
                                               vfree(module) // frees module object with containing kobj
      
          // kobj points to freed memory area!!
          kobject_put(kobj) // OOPS!!!!
      
        The race above happens because module.c tries to use kset_find_obj()
        when somebody unloads module.  The module.c code was introduced in
        commit 6494a93d"
      
      Anatol supplied a patch specific for module.c that worked around the
      problem by simply not using kset_find_obj() at all, but rather than make
      a local band-aid, this just fixes kset_find_obj() to be thread-safe
      using the proper model of refusing the get a new reference if the
      refcount has already dropped to zero.
      
      See examples of this proper refcount handling not only in the kref
      documentation, but in various other equivalent uses of this pattern by
      grepping for atomic_inc_not_zero().
      
      [ Side note: the module race does indicate that module loading and
        unloading is not properly serialized wrt sysfs information using the
        module mutex.  That may require further thought, but this is the
        correct fix at the kobject layer regardless. ]
      Reported-analyzed-and-tested-by: default avatarAnatol Pomozov <anatol.pomozov@gmail.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      c6680a13
    • Thomas Hellstrom's avatar
      kref: Implement kref_get_unless_zero v3 · 3fa8ee5f
      Thomas Hellstrom authored
      commit 4b20db3d upstream.
      
      This function is intended to simplify locking around refcounting for
      objects that can be looked up from a lookup structure, and which are
      removed from that lookup structure in the object destructor.
      Operations on such objects require at least a read lock around
      lookup + kref_get, and a write lock around kref_put + remove from lookup
      structure. Furthermore, RCU implementations become extremely tricky.
      With a lookup followed by a kref_get_unless_zero *with return value check*
      locking in the kref_put path can be deferred to the actual removal from
      the lookup structure and RCU lookups become trivial.
      
      v2: Formatting fixes.
      v3: Invert the return value.
      Signed-off-by: default avatarThomas Hellstrom <thellstrom@vmware.com>
      Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
      [bwh: Backported to 3.2:
       - Adjust context
       - Add #include <linux/atomic.h>]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      3fa8ee5f
    • Josef Bacik's avatar
      Btrfs: make sure nbytes are right after log replay · 595b57bb
      Josef Bacik authored
      commit 4bc4bee4 upstream.
      
      While trying to track down a tree log replay bug I noticed that fsck was always
      complaining about nbytes not being right for our fsynced file.  That is because
      the new fsync stuff doesn't wait for ordered extents to complete, so the inodes
      nbytes are not necessarily updated properly when we log it.  So to fix this we
      need to set nbytes to whatever it is on the inode that is on disk, so when we
      replay the extents we can just add the bytes that are being added as we replay
      the extent.  This makes it work for the case that we have the wrong nbytes or
      the case that we logged everything and nbytes is actually correct.  With this
      I'm no longer getting nbytes errors out of btrfsck.
      Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      [bwh: Backported to 3.2: adjust context]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      595b57bb
    • Namhyung Kim's avatar
      tracing: Fix possible NULL pointer dereferences · ee3c9aab
      Namhyung Kim authored
      commit 6a76f8c0 upstream.
      
      Currently set_ftrace_pid and set_graph_function files use seq_lseek
      for their fops.  However seq_open() is called only for FMODE_READ in
      the fops->open() so that if an user tries to seek one of those file
      when she open it for writing, it sees NULL seq_file and then panic.
      
      It can be easily reproduced with following command:
      
        $ cd /sys/kernel/debug/tracing
        $ echo 1234 | sudo tee -a set_ftrace_pid
      
      In this example, GNU coreutils' tee opens the file with fopen(, "a")
      and then the fopen() internally calls lseek().
      
      Link: http://lkml.kernel.org/r/1365663302-2170-1-git-send-email-namhyung@kernel.org
      
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Namhyung Kim <namhyung.kim@lge.com>
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      [bwh: Backported to 3.2: ftrace_regex_lseek() is static]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      ee3c9aab
    • Nicholas Bellinger's avatar
      target: Fix incorrect fallthrough of ALUA Standby/Offline/Transition CDBs · 2ee3a5e3
      Nicholas Bellinger authored
      commit 30f359a6 upstream.
      
      This patch fixes a bug where a handful of informational / control CDBs
      that should be allowed during ALUA access state Standby/Offline/Transition
      where incorrectly returning CHECK_CONDITION + ASCQ_04H_ALUA_TG_PT_*.
      
      This includes INQUIRY + REPORT_LUNS, which would end up preventing LUN
      registration when LUN scanning occured during these ALUA access states.
      
      Cc: Hannes Reinecke <hare@suse.de>
      Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      2ee3a5e3
    • Nicholas Bellinger's avatar
      target: Fix MAINTENANCE_IN service action CDB checks to use lower 5 bits · d801775a
      Nicholas Bellinger authored
      commit ba539743 upstream.
      
      This patch fixes the MAINTENANCE_IN service action type checks to only
      look at the proper lower 5 bits of cdb byte 1.  This addresses the case
      where MI_REPORT_TARGET_PGS w/ extended header using the upper three bits of
      cdb byte 1 was not processed correctly in transport_generic_cmd_sequencer,
      as well as the three cases for standby, unavailable, and transition ALUA
      primary access state checks.
      
      Also add MAINTENANCE_IN to the excluded list in transport_generic_prepare_cdb()
      to prevent the PARAMETER DATA FORMAT bits from being cleared.
      
      Cc: Hannes Reinecke <hare@suse.de>
      Cc: Rob Evers <revers@redhat.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Roland Dreier <roland@purestorage.com>
      Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      d801775a
    • Boris Ostrovsky's avatar
      x86, mm: Patch out arch_flush_lazy_mmu_mode() when running on bare metal · 04de139a
      Boris Ostrovsky authored
      commit 511ba86e upstream.
      
      Invoking arch_flush_lazy_mmu_mode() results in calls to
      preempt_enable()/disable() which may have performance impact.
      
      Since lazy MMU is not used on bare metal we can patch away
      arch_flush_lazy_mmu_mode() so that it is never called in such
      environment.
      
      [ hpa: the previous patch "Fix vmalloc_fault oops during lazy MMU
        updates" may cause a minor performance regression on
        bare metal.  This patch resolves that performance regression.  It is
        somewhat unclear to me if this is a good -stable candidate. ]
      Signed-off-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
      Link: http://lkml.kernel.org/r/1364045796-10720-2-git-send-email-konrad.wilk@oracle.comTested-by: default avatarJosh Boyer <jwboyer@redhat.com>
      Tested-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Acked-by: default avatarBorislav Petkov <bp@suse.de>
      Signed-off-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Signed-off-by: default avatarH. Peter Anvin <hpa@linux.intel.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      04de139a
    • Samu Kallio's avatar
      x86, mm, paravirt: Fix vmalloc_fault oops during lazy MMU updates · 5bb757c0
      Samu Kallio authored
      commit 1160c277 upstream.
      
      In paravirtualized x86_64 kernels, vmalloc_fault may cause an oops
      when lazy MMU updates are enabled, because set_pgd effects are being
      deferred.
      
      One instance of this problem is during process mm cleanup with memory
      cgroups enabled. The chain of events is as follows:
      
      - zap_pte_range enables lazy MMU updates
      - zap_pte_range eventually calls mem_cgroup_charge_statistics,
        which accesses the vmalloc'd mem_cgroup per-cpu stat area
      - vmalloc_fault is triggered which tries to sync the corresponding
        PGD entry with set_pgd, but the update is deferred
      - vmalloc_fault oopses due to a mismatch in the PUD entries
      
      The OOPs usually looks as so:
      
      ------------[ cut here ]------------
      kernel BUG at arch/x86/mm/fault.c:396!
      invalid opcode: 0000 [#1] SMP
      .. snip ..
      CPU 1
      Pid: 10866, comm: httpd Not tainted 3.6.10-4.fc18.x86_64 #1
      RIP: e030:[<ffffffff816271bf>]  [<ffffffff816271bf>] vmalloc_fault+0x11f/0x208
      .. snip ..
      Call Trace:
       [<ffffffff81627759>] do_page_fault+0x399/0x4b0
       [<ffffffff81004f4c>] ? xen_mc_extend_args+0xec/0x110
       [<ffffffff81624065>] page_fault+0x25/0x30
       [<ffffffff81184d03>] ? mem_cgroup_charge_statistics.isra.13+0x13/0x50
       [<ffffffff81186f78>] __mem_cgroup_uncharge_common+0xd8/0x350
       [<ffffffff8118aac7>] mem_cgroup_uncharge_page+0x57/0x60
       [<ffffffff8115fbc0>] page_remove_rmap+0xe0/0x150
       [<ffffffff8115311a>] ? vm_normal_page+0x1a/0x80
       [<ffffffff81153e61>] unmap_single_vma+0x531/0x870
       [<ffffffff81154962>] unmap_vmas+0x52/0xa0
       [<ffffffff81007442>] ? pte_mfn_to_pfn+0x72/0x100
       [<ffffffff8115c8f8>] exit_mmap+0x98/0x170
       [<ffffffff810050d9>] ? __raw_callee_save_xen_pmd_val+0x11/0x1e
       [<ffffffff81059ce3>] mmput+0x83/0xf0
       [<ffffffff810624c4>] exit_mm+0x104/0x130
       [<ffffffff8106264a>] do_exit+0x15a/0x8c0
       [<ffffffff810630ff>] do_group_exit+0x3f/0xa0
       [<ffffffff81063177>] sys_exit_group+0x17/0x20
       [<ffffffff8162bae9>] system_call_fastpath+0x16/0x1b
      
      Calling arch_flush_lazy_mmu_mode immediately after set_pgd makes the
      changes visible to the consistency checks.
      
      RedHat-Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=914737Tested-by: default avatarJosh Boyer <jwboyer@redhat.com>
      Reported-and-Tested-by: default avatarKrishna Raman <kraman@redhat.com>
      Signed-off-by: default avatarSamu Kallio <samu.kallio@aberdeencloud.com>
      Link: http://lkml.kernel.org/r/1364045796-10720-1-git-send-email-konrad.wilk@oracle.comTested-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Signed-off-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Signed-off-by: default avatarH. Peter Anvin <hpa@linux.intel.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      5bb757c0
    • Namhyung Kim's avatar
      tracing: Fix double free when function profile init failed · fb8384c3
      Namhyung Kim authored
      commit 83e03b3f upstream.
      
      On the failure path, stat->start and stat->pages will refer same page.
      So it'll attempt to free the same page again and get kernel panic.
      
      Link: http://lkml.kernel.org/r/1364820385-32027-1-git-send-email-namhyung@kernel.org
      
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Namhyung Kim <namhyung.kim@lge.com>
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      fb8384c3
    • Linus Torvalds's avatar
      spinlocks and preemption points need to be at least compiler barriers · 9dc0052f
      Linus Torvalds authored
      commit 386afc91 upstream.
      
      In UP and non-preempt respectively, the spinlocks and preemption
      disable/enable points are stubbed out entirely, because there is no
      regular code that can ever hit the kind of concurrency they are meant to
      protect against.
      
      However, while there is no regular code that can cause scheduling, we
      _do_ end up having some exceptional (literally!) code that can do so,
      and that we need to make sure does not ever get moved into the critical
      region by the compiler.
      
      In particular, get_user() and put_user() is generally implemented as
      inline asm statements (even if the inline asm may then make a call
      instruction to call out-of-line), and can obviously cause a page fault
      and IO as a result.  If that inline asm has been scheduled into the
      middle of a preemption-safe (or spinlock-protected) code region, we
      obviously lose.
      
      Now, admittedly this is *very* unlikely to actually ever happen, and
      we've not seen examples of actual bugs related to this.  But partly
      exactly because it's so hard to trigger and the resulting bug is so
      subtle, we should be extra careful to get this right.
      
      So make sure that even when preemption is disabled, and we don't have to
      generate any actual *code* to explicitly tell the system that we are in
      a preemption-disabled region, we need to at least tell the compiler not
      to move things around the critical region.
      
      This patch grew out of the same discussion that caused commits
      79e5f05e ("ARC: Add implicit compiler barrier to raw_local_irq*
      functions") and 3e2e0d2c ("tile: comment assumption about
      __insn_mtspr for <asm/irqflags.h>") to come about.
      
      Note for stable: use discretion when/if applying this.  As mentioned,
      this bug may never have actually bitten anybody, and gcc may never have
      done the required code motion for it to possibly ever trigger in
      practice.
      
      Cc: Steven Rostedt <srostedt@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      [bwh: Backported to 3.2: drop sched_preempt_enable_no_resched()]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      9dc0052f
    • Alban Bedel's avatar
      ASoC: wm8903: Fix the bypass to HP/LINEOUT when no DAC or ADC is running · 6248d3d8
      Alban Bedel authored
      commit f1ca493b upstream.
      
      The Charge Pump needs the DSP clock to work properly, without it the
      bypass to HP/LINEOUT is not working properly. This requirement is not
      mentioned in the datasheet but has been confirmed by Mark Brown from
      Wolfson.
      Signed-off-by: default avatarAlban Bedel <alban.bedel@avionic-design.de>
      Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      6248d3d8
    • Wei Yongjun's avatar
      can: gw: use kmem_cache_free() instead of kfree() · d9d7d36d
      Wei Yongjun authored
      commit 3480a212 upstream.
      
      Memory allocated by kmem_cache_alloc() should be freed using
      kmem_cache_free(), not kfree().
      Signed-off-by: default avatarWei Yongjun <yongjun_wei@trendmicro.com.cn>
      Acked-by: default avatarOliver Hartkopp <socketcan@hartkopp.net>
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      d9d7d36d
    • Huacai Chen's avatar
      PM / reboot: call syscore_shutdown() after disable_nonboot_cpus() · 903bd59a
      Huacai Chen authored
      commit 6f389a8f upstream.
      
      As commit 40dc166c (PM / Core: Introduce struct syscore_ops for core
      subsystems PM) say, syscore_ops operations should be carried with one
      CPU on-line and interrupts disabled. However, after commit f96972f2
      (kernel/sys.c: call disable_nonboot_cpus() in kernel_restart()),
      syscore_shutdown() is called before disable_nonboot_cpus(), so break
      the rules. We have a MIPS machine with a 8259A PIC, and there is an
      external timer (HPET) linked at 8259A. Since 8259A has been shutdown
      too early (by syscore_shutdown()), disable_nonboot_cpus() runs without
      timer interrupt, so it hangs and reboot fails. This patch call
      syscore_shutdown() a little later (after disable_nonboot_cpus()) to
      avoid reboot failure, this is the same way as poweroff does.
      
      For consistency, add disable_nonboot_cpus() to kernel_halt().
      Signed-off-by: default avatarHuacai Chen <chenhc@lemote.com>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      903bd59a
    • Jan Kiszka's avatar
      ftrace: Consistently restore trace function on sysctl enabling · b7e45b96
      Jan Kiszka authored
      commit 5000c418 upstream.
      
      If we reenable ftrace via syctl, we currently set ftrace_trace_function
      based on the previous simplistic algorithm. This is inconsistent with
      what update_ftrace_function does. So better call that helper instead.
      
      Link: http://lkml.kernel.org/r/5151D26F.1070702@siemens.comSigned-off-by: default avatarJan Kiszka <jan.kiszka@siemens.com>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      b7e45b96
    • Thomas Gleixner's avatar
      sched_clock: Prevent 64bit inatomicity on 32bit systems · 4dfc47d2
      Thomas Gleixner authored
      commit a1cbcaa9 upstream.
      
      The sched_clock_remote() implementation has the following inatomicity
      problem on 32bit systems when accessing the remote scd->clock, which
      is a 64bit value.
      
      CPU0			CPU1
      
      sched_clock_local()	sched_clock_remote(CPU0)
      ...
      			remote_clock = scd[CPU0]->clock
      			    read_low32bit(scd[CPU0]->clock)
      cmpxchg64(scd->clock,...)
      			    read_high32bit(scd[CPU0]->clock)
      
      While the update of scd->clock is using an atomic64 mechanism, the
      readout on the remote cpu is not, which can cause completely bogus
      readouts.
      
      It is a quite rare problem, because it requires the update to hit the
      narrow race window between the low/high readout and the update must go
      across the 32bit boundary.
      
      The resulting misbehaviour is, that CPU1 will see the sched_clock on
      CPU1 ~4 seconds ahead of it's own and update CPU1s sched_clock value
      to this bogus timestamp. This stays that way due to the clamping
      implementation for about 4 seconds until the synchronization with
      CLOCK_MONOTONIC undoes the problem.
      
      The issue is hard to observe, because it might only result in a less
      accurate SCHED_OTHER timeslicing behaviour. To create observable
      damage on realtime scheduling classes, it is necessary that the bogus
      update of CPU1 sched_clock happens in the context of an realtime
      thread, which then gets charged 4 seconds of RT runtime, which results
      in the RT throttler mechanism to trigger and prevent scheduling of RT
      tasks for a little less than 4 seconds. So this is quite unlikely as
      well.
      
      The issue was quite hard to decode as the reproduction time is between
      2 days and 3 weeks and intrusive tracing makes it less likely, but the
      following trace recorded with trace_clock=global, which uses
      sched_clock_local(), gave the final hint:
      
        <idle>-0   0d..30 400269.477150: hrtimer_cancel: hrtimer=0xf7061e80
        <idle>-0   0d..30 400269.477151: hrtimer_start:  hrtimer=0xf7061e80 ...
      irq/20-S-587 1d..32 400273.772118: sched_wakeup:   comm= ... target_cpu=0
        <idle>-0   0dN.30 400273.772118: hrtimer_cancel: hrtimer=0xf7061e80
      
      What happens is that CPU0 goes idle and invokes
      sched_clock_idle_sleep_event() which invokes sched_clock_local() and
      CPU1 runs a remote wakeup for CPU0 at the same time, which invokes
      sched_remote_clock(). The time jump gets propagated to CPU0 via
      sched_remote_clock() and stays stale on both cores for ~4 seconds.
      
      There are only two other possibilities, which could cause a stale
      sched clock:
      
      1) ktime_get() which reads out CLOCK_MONOTONIC returns a sporadic
         wrong value.
      
      2) sched_clock() which reads the TSC returns a sporadic wrong value.
      
      #1 can be excluded because sched_clock would continue to increase for
         one jiffy and then go stale.
      
      #2 can be excluded because it would not make the clock jump
         forward. It would just result in a stale sched_clock for one jiffy.
      
      After quite some brain twisting and finding the same pattern on other
      traces, sched_clock_remote() remained the only place which could cause
      such a problem and as explained above it's indeed racy on 32bit
      systems.
      
      So while on 64bit systems the readout is atomic, we need to verify the
      remote readout on 32bit machines. We need to protect the local->clock
      readout in sched_clock_remote() on 32bit as well because an NMI could
      hit between the low and the high readout, call sched_clock_local() and
      modify local->clock.
      
      Thanks to Siegfried Wulsch for bearing with my debug requests and
      going through the tedious tasks of running a bunch of reproducer
      systems to generate the debug information which let me decode the
      issue.
      Reported-by: default avatarSiegfried Wulsch <Siegfried.Wulsch@rovema.de>
      Acked-by: default avatarPeter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Link: http://lkml.kernel.org/r/alpine.LFD.2.02.1304051544160.21884@ionosSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      [bwh: Backported to 3.2: adjust filename]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      4dfc47d2
    • Michael Wolf's avatar
      powerpc: pSeries_lpar_hpte_remove fails from Adjunct partition being performed... · 2efb2740
      Michael Wolf authored
      powerpc: pSeries_lpar_hpte_remove fails from Adjunct partition being performed before the ANDCOND test
      
      commit 9fb26401 upstream.
      
      Some versions of pHyp will perform the adjunct partition test before the
      ANDCOND test.  The result of this is that H_RESOURCE can be returned and
      cause the BUG_ON condition to occur. The HPTE is not removed.  So add a
      check for H_RESOURCE, it is ok if this HPTE is not removed as
      pSeries_lpar_hpte_remove is looking for an HPTE to remove and not a
      specific HPTE to remove.  So it is ok to just move on to the next slot
      and try again.
      Signed-off-by: default avatarMichael Wolf <mjw@linux.vnet.ibm.com>
      Signed-off-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      2efb2740
    • Jay Estabrook's avatar
      alpha: Add irongate_io to PCI bus resources · 9c7787a1
      Jay Estabrook authored
      commit aa8b4be3 upstream.
      
      Fixes a NULL pointer dereference at boot on UP1500.
      Reviewed-and-Tested-by: default avatarMatt Turner <mattst88@gmail.com>
      Signed-off-by: default avatarJay Estabrook <jay.estabrook@gmail.com>
      Signed-off-by: default avatarMatt Turner <mattst88@gmail.com>
      Signed-off-by: default avatarMichael Cree <mcree@orcon.net.nz>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      9c7787a1
    • Eldad Zack's avatar
      ALSA: usb-audio: fix endianness bug in snd_nativeinstruments_* · 74e038af
      Eldad Zack authored
      commit 889d6684 upstream.
      
      The usb_control_msg() function expects __u16 types and performs
      the endianness conversions by itself.
      However, in three places, a conversion is performed before it is
      handed over to usb_control_msg(), which leads to a double conversion
      (= no conversion):
      * snd_usb_nativeinstruments_boot_quirk()
      * snd_nativeinstruments_control_get()
      * snd_nativeinstruments_control_put()
      
      Caught by sparse:
      
      sound/usb/mixer_quirks.c:512:38: warning: incorrect type in argument 6 (different base types)
      sound/usb/mixer_quirks.c:512:38:    expected unsigned short [unsigned] [usertype] index
      sound/usb/mixer_quirks.c:512:38:    got restricted __le16 [usertype] <noident>
      sound/usb/mixer_quirks.c:543:35: warning: incorrect type in argument 5 (different base types)
      sound/usb/mixer_quirks.c:543:35:    expected unsigned short [unsigned] [usertype] value
      sound/usb/mixer_quirks.c:543:35:    got restricted __le16 [usertype] <noident>
      sound/usb/mixer_quirks.c:543:56: warning: incorrect type in argument 6 (different base types)
      sound/usb/mixer_quirks.c:543:56:    expected unsigned short [unsigned] [usertype] index
      sound/usb/mixer_quirks.c:543:56:    got restricted __le16 [usertype] <noident>
      sound/usb/quirks.c:502:35: warning: incorrect type in argument 5 (different base types)
      sound/usb/quirks.c:502:35:    expected unsigned short [unsigned] [usertype] value
      sound/usb/quirks.c:502:35:    got restricted __le16 [usertype] <noident>
      Signed-off-by: default avatarEldad Zack <eldad@fogrefinery.com>
      Acked-by: default avatarDaniel Mack <zonque@gmail.com>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      74e038af
    • Li Fei's avatar
      hwspinlock: fix __hwspin_lock_request error path · f7626edc
      Li Fei authored
      commit c10b90d8 upstream.
      
      Even in failed case of pm_runtime_get_sync, the usage_count
      is incremented. In order to keep the usage_count with correct
      value and runtime power management to behave correctly, call
      pm_runtime_put_noidle in such case.
      
      In __hwspin_lock_request, module_put is also called before
      return in pm_runtime_get_sync failed case.
      
      Signed-off-by Liu Chuansheng <chuansheng.liu@intel.com>
      Signed-off-by: default avatarLi Fei <fei.li@intel.com>
      [edit commit log]
      Signed-off-by: default avatarOhad Ben-Cohen <ohad@wizery.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      f7626edc
    • Youquan Song's avatar
      ata_piix: Fix DVD not dectected at some Haswell platforms · e319383b
      Youquan Song authored
      commit b55f84e2 upstream.
      
      There is a quirk patch 5e5a4f5d
      "ata_piix: make DVD Drive recognisable on systems with Intel Sandybridge
       chipsets(v2)" fixing the 4 ports IDE controller 32bit PIO mode.
      
      We've hit a problem with DVD not recognized on Haswell Desktop platform which
      includes Lynx Point 2-port SATA controller.
      
      This quirk patch disables 32bit PIO on this controller in IDE mode.
      
      v2: Change spelling error in statememnt pointed by Sergei Shtylyov.
      v3: Change comment statememnt and spliting line over 80 characters pointed by
          Libor Pechacek and also rebase the patch against 3.8-rc7 kernel.
      Tested-by: default avatarLee, Chun-Yi <jlee@suse.com>
      Signed-off-by: default avatarYouquan Song <youquan.song@intel.com>
      Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      e319383b
    • Shan Hai's avatar
      libata: Set max sector to 65535 for Slimtype DVD A DS8A8SH drive · 2c10a283
      Shan Hai authored
      commit a32450e1 upstream.
      
      The Slimtype DVD A  DS8A8SH drive locks up when max sector is smaller than
      65535, and the blow backtrace is observed on locking up:
      
      INFO: task flush-8:32:1130 blocked for more than 120 seconds.
      "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
      flush-8:32      D ffffffff8180cf60     0  1130      2 0x00000000
       ffff880273aef618 0000000000000046 0000000000000005 ffff880273aee000
       ffff880273aee000 ffff880273aeffd8 ffff880273aee010 ffff880273aee000
       ffff880273aeffd8 ffff880273aee000 ffff88026e842ea0 ffff880274a10000
      Call Trace:
       [<ffffffff8168fc2d>] schedule+0x5d/0x70
       [<ffffffff8168fccc>] io_schedule+0x8c/0xd0
       [<ffffffff81324461>] get_request+0x731/0x7d0
       [<ffffffff8133dc60>] ? cfq_allow_merge+0x50/0x90
       [<ffffffff81083aa0>] ? wake_up_bit+0x40/0x40
       [<ffffffff81320443>] ? bio_attempt_back_merge+0x33/0x110
       [<ffffffff813248ea>] blk_queue_bio+0x23a/0x3f0
       [<ffffffff81322176>] generic_make_request+0xc6/0x120
       [<ffffffff81322308>] submit_bio+0x138/0x160
       [<ffffffff811d7596>] ? bio_alloc_bioset+0x96/0x120
       [<ffffffff811d1f61>] submit_bh+0x1f1/0x220
       [<ffffffff811d48b8>] __block_write_full_page+0x228/0x340
       [<ffffffff811d3650>] ? attach_nobh_buffers+0xc0/0xc0
       [<ffffffff811d8960>] ? I_BDEV+0x10/0x10
       [<ffffffff811d8960>] ? I_BDEV+0x10/0x10
       [<ffffffff811d4ab6>] block_write_full_page_endio+0xe6/0x100
       [<ffffffff811d4ae5>] block_write_full_page+0x15/0x20
       [<ffffffff811d9268>] blkdev_writepage+0x18/0x20
       [<ffffffff81142527>] __writepage+0x17/0x40
       [<ffffffff811438ba>] write_cache_pages+0x34a/0x4a0
       [<ffffffff81142510>] ? set_page_dirty+0x70/0x70
       [<ffffffff81143a61>] generic_writepages+0x51/0x80
       [<ffffffff81143ab0>] do_writepages+0x20/0x50
       [<ffffffff811c9ed6>] __writeback_single_inode+0xa6/0x2b0
       [<ffffffff811ca861>] writeback_sb_inodes+0x311/0x4d0
       [<ffffffff811caaa6>] __writeback_inodes_wb+0x86/0xd0
       [<ffffffff811cad43>] wb_writeback+0x1a3/0x330
       [<ffffffff816916cf>] ? _raw_spin_lock_irqsave+0x3f/0x50
       [<ffffffff811b8362>] ? get_nr_inodes+0x52/0x70
       [<ffffffff811cb0ac>] wb_do_writeback+0x1dc/0x260
       [<ffffffff8168dd34>] ? schedule_timeout+0x204/0x240
       [<ffffffff811cb232>] bdi_writeback_thread+0x102/0x2b0
       [<ffffffff811cb130>] ? wb_do_writeback+0x260/0x260
       [<ffffffff81083550>] kthread+0xc0/0xd0
       [<ffffffff81083490>] ? kthread_worker_fn+0x1b0/0x1b0
       [<ffffffff8169a3ec>] ret_from_fork+0x7c/0xb0
       [<ffffffff81083490>] ? kthread_worker_fn+0x1b0/0x1b0
      
       The above trace was triggered by
         "dd if=/dev/zero of=/dev/sr0 bs=2048 count=32768"
      
       It was previously working by accident, since another bug introduced
       by 4dce8ba9 (libata: Use 'bool' return value for ata_id_XXX) caused
       all drives to use maxsect=65535.
      Signed-off-by: default avatarShan Hai <shan.hai@windriver.com>
      Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      2c10a283
    • Shan Hai's avatar
      libata: Use integer return value for atapi_command_packet_set · 274c4edc
      Shan Hai authored
      commit d8668fcb upstream.
      
      The function returns type of ATAPI drives so it should return integer value.
      The commit 4dce8ba9 (libata: Use 'bool' return value for ata_id_XXX) since
      v2.6.39 changed the type of return value from int to bool, the change would
      cause all of the ATAPI class drives to be treated as TYPE_TAPE and the
      max_sectors of the drives to be set to 65535 because of the commit
      f8d8e579(libata: increase 128 KB / cmd limit for ATAPI tape drives), for the
      function would return true for all ATAPI class drives and the TYPE_TAPE is
      defined as 0x01.
      Signed-off-by: default avatarShan Hai <shan.hai@windriver.com>
      Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      274c4edc
    • Tim Gardner's avatar
      rt2x00: rt2x00pci_regbusy_read() - only print register access failure once · 61d50e12
      Tim Gardner authored
      commit 83589b30 upstream.
      
      BugLink: http://bugs.launchpad.net/bugs/1128840
      
      It appears that when this register read fails it never recovers, so
      I think there is no need to repeat the same error message ad infinitum.
      
      Cc: Ivo van Doorn <IvDoorn@gmail.com>
      Cc: Gertjan van Wingerde <gwingerde@gmail.com>
      Cc: Helmut Schaa <helmut.schaa@googlemail.com>
      Cc: "John W. Linville" <linville@tuxdriver.com>
      Cc: linux-wireless@vger.kernel.org
      Cc: users@rt2x00.serialmonkey.com
      Cc: netdev@vger.kernel.org
      Signed-off-by: default avatarTim Gardner <tim.gardner@canonical.com>
      Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      61d50e12
    • Jussi Kivilinna's avatar
      crypto: gcm - fix assumption that assoc has one segment · da6e577a
      Jussi Kivilinna authored
      commit d3dde522 upstream.
      
      rfc4543(gcm(*)) code for GMAC assumes that assoc scatterlist always contains
      only one segment and only makes use of this first segment. However ipsec passes
      assoc with three segments when using 'extended sequence number' thus in this
      case rfc4543(gcm(*)) fails to function correctly. Patch fixes this issue.
      Reported-by: default avatarChaoxing Lin <Chaoxing.Lin@ultra-3eti.com>
      Tested-by: default avatarChaoxing Lin <Chaoxing.Lin@ultra-3eti.com>
      Signed-off-by: default avatarJussi Kivilinna <jussi.kivilinna@iki.fi>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      da6e577a
    • Michael Bohan's avatar
      hrtimer: Don't reinitialize a cpu_base lock on CPU_UP · de16cb5f
      Michael Bohan authored
      commit 84cc8fd2 upstream.
      
      The current code makes the assumption that a cpu_base lock won't be
      held if the CPU corresponding to that cpu_base is offline, which isn't
      always true.
      
      If a hrtimer is not queued, then it will not be migrated by
      migrate_hrtimers() when a CPU is offlined. Therefore, the hrtimer's
      cpu_base may still point to a CPU which has subsequently gone offline
      if the timer wasn't enqueued at the time the CPU went down.
      
      Normally this wouldn't be a problem, but a cpu_base's lock is blindly
      reinitialized each time a CPU is brought up. If a CPU is brought
      online during the period that another thread is performing a hrtimer
      operation on a stale hrtimer, then the lock will be reinitialized
      under its feet, and a SPIN_BUG() like the following will be observed:
      
      <0>[   28.082085] BUG: spinlock already unlocked on CPU#0, swapper/0/0
      <0>[   28.087078]  lock: 0xc4780b40, value 0x0 .magic: dead4ead, .owner: <none>/-1, .owner_cpu: -1
      <4>[   42.451150] [<c0014398>] (unwind_backtrace+0x0/0x120) from [<c0269220>] (do_raw_spin_unlock+0x44/0xdc)
      <4>[   42.460430] [<c0269220>] (do_raw_spin_unlock+0x44/0xdc) from [<c071b5bc>] (_raw_spin_unlock+0x8/0x30)
      <4>[   42.469632] [<c071b5bc>] (_raw_spin_unlock+0x8/0x30) from [<c00a9ce0>] (__hrtimer_start_range_ns+0x1e4/0x4f8)
      <4>[   42.479521] [<c00a9ce0>] (__hrtimer_start_range_ns+0x1e4/0x4f8) from [<c00aa014>] (hrtimer_start+0x20/0x28)
      <4>[   42.489247] [<c00aa014>] (hrtimer_start+0x20/0x28) from [<c00e6190>] (rcu_idle_enter_common+0x1ac/0x320)
      <4>[   42.498709] [<c00e6190>] (rcu_idle_enter_common+0x1ac/0x320) from [<c00e6440>] (rcu_idle_enter+0xa0/0xb8)
      <4>[   42.508259] [<c00e6440>] (rcu_idle_enter+0xa0/0xb8) from [<c000f268>] (cpu_idle+0x24/0xf0)
      <4>[   42.516503] [<c000f268>] (cpu_idle+0x24/0xf0) from [<c06ed3c0>] (rest_init+0x88/0xa0)
      <4>[   42.524319] [<c06ed3c0>] (rest_init+0x88/0xa0) from [<c0c00978>] (start_kernel+0x3d0/0x434)
      
      As an example, this particular crash occurred when hrtimer_start() was
      executed on CPU #0. The code locked the hrtimer's current cpu_base
      corresponding to CPU #1. CPU #0 then tried to switch the hrtimer's
      cpu_base to an optimal CPU which was online. In this case, it selected
      the cpu_base corresponding to CPU #3.
      
      Before it could proceed, CPU #1 came online and reinitialized the
      spinlock corresponding to its cpu_base. Thus now CPU #0 held a lock
      which was reinitialized. When CPU #0 finally ended up unlocking the
      old cpu_base corresponding to CPU #1 so that it could switch to CPU
      #3, we hit this SPIN_BUG() above while in switch_hrtimer_base().
      
      CPU #0                            CPU #1
      ----                              ----
      ...                               <offline>
      hrtimer_start()
      lock_hrtimer_base(base #1)
      ...                               init_hrtimers_cpu()
      switch_hrtimer_base()             ...
      ...                               raw_spin_lock_init(&cpu_base->lock)
      raw_spin_unlock(&cpu_base->lock)  ...
      <spin_bug>
      
      Solve this by statically initializing the lock.
      Signed-off-by: default avatarMichael Bohan <mbohan@codeaurora.org>
      Link: http://lkml.kernel.org/r/1363745965-23475-1-git-send-email-mbohan@codeaurora.orgSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      de16cb5f