1. 02 Apr, 2012 40 commits
    • NeilBrown's avatar
      md/bitmap: ensure to load bitmap when creating via sysfs. · aae19423
      NeilBrown authored
      commit 4474ca42 upstream.
      
      When commit 69e51b44 (md/bitmap:  separate out loading a bitmap...)
      created bitmap_load, it missed calling it after bitmap_create when a
      bitmap is created through the sysfs interface.
      So if a bitmap is added this way, we don't allocate memory properly
      and can crash.
      
      This is suitable for any -stable release since 2.6.35.
      Signed-off-by: default avatarNeilBrown <neilb@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      aae19423
    • Nicholas Bellinger's avatar
      tcm_fc: Fix fc_exch memory leak in ft_send_resp_status · 9a0aae0c
      Nicholas Bellinger authored
      commit 031ed4d5 upstream.
      
      This patch fixes a bug in tcm_fc where fc_exch memory from fc_exch_mgr->ep_pool
      is currently being leaked by ft_send_resp_status() usage.  Following current
      code in ft_queue_status() response path, using lport->tt.seq_send() needs to be
      followed by a lport->tt.exch_done() in order to release fc_exch memory back into
      libfc_em kmem_cache.
      
      ft_send_resp_status() code is currently used in pre submit se_cmd ft_send_work()
      error exceptions, TM request setup exceptions, and main TM response callback
      path in ft_queue_tm_resp().  This bugfix addresses the leak in these cases.
      
      Cc: Mark D Rustad <mark.d.rustad@intel.com>
      Cc: Kiran Patil <kiran.patil@intel.com>
      Cc: Robert Love <robert.w.love@intel.com>
      Cc: Andy Grover <agrover@redhat.com>
      Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9a0aae0c
    • Kay Sievers's avatar
      udlfb: remove sysfs framebuffer device with USB .disconnect() · ee7d30aa
      Kay Sievers authored
      commit ce880cb8 upstream.
      
      The USB graphics card driver delays the unregistering of the framebuffer
      device to a workqueue, which breaks the userspace visible remove uevent
      sequence. Recent userspace tools started to support USB graphics card
      hotplug out-of-the-box and rely on proper events sent by the kernel.
      
      The framebuffer device is a direct child of the USB interface which is
      removed immediately after the USB .disconnect() callback. But the fb device
      in /sys stays around until its final cleanup, at a time where all the parent
      devices have been removed already.
      
      To work around that, we remove the sysfs fb device directly in the USB
      .disconnect() callback and leave only the cleanup of the internal fb
      data to the delayed work.
      
      Before:
       add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2 (usb)
       add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0 (usb)
       add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0/graphics/fb0 (graphics)
       remove   /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0 (usb)
       remove   /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2 (usb)
       remove   /2-1.2:1.0/graphics/fb0 (graphics)
      
      After:
       add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2 (usb)
       add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0 (usb)
       add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0/graphics/fb1 (graphics)
       remove   /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0/graphics/fb1 (graphics)
       remove   /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0 (usb)
       remove   /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2 (usb)
      Tested-by: default avatarBernie Thompson <bernie@plugable.com>
      Acked-by: default avatarBernie Thompson <bernie@plugable.com>
      Signed-off-by: default avatarKay Sievers <kay.sievers@vrfy.org>
      Signed-off-by: default avatarFlorian Tobias Schandinat <FlorianSchandinat@gmx.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ee7d30aa
    • Lothar Waßmann's avatar
      usb gadget: fix a section mismatch when compiling g_ffs with CONFIG_USB_FUNCTIONFS_ETH · 3b6df5f6
      Lothar Waßmann authored
      commit 8d069842 upstream.
      
       commit 28824b18:
       |Author: Michal Nazarewicz <m.nazarewicz@samsung.com>
       |Date:   Wed May 5 12:53:13 2010 +0200
       |
       |    USB: gadget: __init and __exit tags removed
       |
       |    __init, __initdata and __exit tags have have been removed from
       |    various files to make it possible for gadgets that do not use
       |    the __init/__exit tags to use those.
       obviously missed (at least) this case leading to a section mismatch in
       g_ffs.c when compiling with CONFIG_USB_FUNCTIONFS_ETH enabled.
      Signed-off-by: default avatarLothar Waßmann <LW@KARO-electronics.de>
      Acked-by: default avatarMichal Nazarewicz <mina86@mina86.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3b6df5f6
    • Anssi Hannula's avatar
      ALSA: hda - fix printing of high HDMI sample rates · d8b8c61f
      Anssi Hannula authored
      commit 25dc16f6 upstream.
      
      A previous commit af65cbf2 (ALSA: hdmi: fix printout of SAD sampling
      rates) fixed the sample rates shown in /proc/asound/cardX/eldY and
      kernel log to not be entirely wrong. However, a missing rate from the
      array added in the patch causes HDMI rates 88.2 kHz, 96 kHz, 176.4 kHz,
      and 192 kHz to be shown as 96 kHz, 176.4 kHz, 192 kHz, and 384 kHz,
      respectively.
      
      Fix the reporting by adding the ALSA rate 64 kHz into the conversion
      array between 48 kHz and 88.2 kHz.
      Signed-off-by: default avatarAnssi Hannula <anssi.hannula@iki.fi>
      Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d8b8c61f
    • Nicholas Bellinger's avatar
      iscsi-target: Fix dynamic -> explict NodeACL pointer reference · abd8ea07
      Nicholas Bellinger authored
      commit d0628334 upstream.
      
      This patch fixes a free after use in lio_target_make_nodeacl() where
      iscsi_node_acl was referenced from the original se_nacl_new allocation,
      instead of from core_tpg_add_initiator_node_acl() in the case of dynamic
      -> explict NodeACL conversion.
      Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      abd8ea07
    • Nicholas Bellinger's avatar
      iscsi-target: Fix iscsit_alloc_buffs() failure cases · 05ea4968
      Nicholas Bellinger authored
      commit d335e605 upstream.
      
      Make iscsit_alloc_buffs() failure case for page_alloc_failed use correct
      __free_page() SGL pointer, and return -ENOMEM for iscsit_allocate_iovecs
      failure to push se_cmd->t_mem_sg release into iscsit_release_cmd()
      callback during iscsit_add_reject_from_cmd() connection reset.
      
      Also drop cmd->t_mem_sg = NULL assignment from page_alloc_failed
      failure case.
      Reported-by: default avatarRoland Dreier <roland@purestorage.com>
      Cc: Andy Grover <agrover@redhat.com>
      Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      05ea4968
    • Roland Dreier's avatar
      tcm_loop: Set residual field for SCSI commands · bb9ed4f0
      Roland Dreier authored
      commit 6cf3fa69 upstream.
      
      If the target core signals an over- or under-run, tcm_loop should call
      scsi_set_resid() to tell the SCSI midlayer about the residual data length.
      
      The difference can be seen by doing something like
      
          strace -eioctl sg_raw -r 1024 /dev/sda 8 0 0 0 1 0 > /dev/null
      
      and looking at the "resid=" part of the SG_IO ioctl -- after this patch,
      the field is correctly reported as 512.
      Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
      Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bb9ed4f0
    • Daniel Mack's avatar
      ASoC: pxa-ssp: atomically set stream active masks · 0f813454
      Daniel Mack authored
      commit 273b72c8 upstream.
      
      PXA's SSP engine fails to take its current channel phase into account
      when enabling a stream while the engine is already running. This
      results in randomly swapped left/right channels on either the record
      or the playback side, depending on which one was enabled first.
      
      The following patch fixes this by factoring out the bit field
      modifications in question to a separate function that pauses the
      engine temporarily, modifies the bits and kicks it off again
      afterwards. Appearantly, a transition of SSCR0_SSE syncs both
      directions properly.
      
      The patch has been rolled out to quite a number of devices over the
      last weeks and seems to fix the issue reliably.
      Signed-off-by: default avatarDaniel Mack <zonque@gmail.com>
      Reported-and-tested-by: default avatarSven Neumann <s.neumann@raumfeld.com>
      Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0f813454
    • Timur Tabi's avatar
      ASoC: fsl: p1022ds: tell the WM8776 codec driver that it's the master · 34ef160b
      Timur Tabi authored
      commit 70ac07bb upstream.
      
      The WM8776 codec driver requires the machine driver to set one of the
      SND_SOC_DAIFMT_CBx_xxx values.  The P1022DS machine driver should be setting
      SND_SOC_DAIFMT_CBM_CFM, but since that value was zero, no one noticed.
      
      Commit 75d9ac46 ("ASoC: Allow DAI formats to be specified in the
      dai_link"), however, changed the value of SND_SOC_DAIFMT_CBM_CFM from zero
      to a non-zero value, which means that it now needs to be specifically set
      by the machine driver.
      
      We also set SND_SOC_DAIFMT_NB_NF, for the same reason.
      Signed-off-by: default avatarTimur Tabi <timur@freescale.com>
      Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      34ef160b
    • Aneesh Kumar K.V's avatar
      hugetlbfs: avoid taking i_mutex from hugetlbfs_read() · fe4e2fab
      Aneesh Kumar K.V authored
      commit a05b0855 upstream.
      
      Taking i_mutex in hugetlbfs_read() can result in deadlock with mmap as
      explained below
      
       Thread A:
        read() on hugetlbfs
         hugetlbfs_read() called
          i_mutex grabbed
           hugetlbfs_read_actor() called
            __copy_to_user() called
             page fault is triggered
       Thread B, sharing address space with A:
        mmap() the same file
         ->mmap_sem is grabbed on task_B->mm->mmap_sem
          hugetlbfs_file_mmap() is called
           attempt to grab ->i_mutex and block waiting for A to give it up
       Thread A:
        pagefault handled blocked on attempt to grab task_A->mm->mmap_sem,
       which happens to be the same thing as task_B->mm->mmap_sem.  Block waiting
       for B to give it up.
      
      AFAIU the i_mutex locking was added to hugetlbfs_read() as per
      http://lkml.indiana.edu/hypermail/linux/kernel/0707.2/3066.html to take
      care of the race between truncate and read.  This patch fixes this by
      looking at page->mapping under lock_page() (find_lock_page()) to ensure
      that the inode didn't get truncated in the range during a parallel read.
      
      Ideally we can extend the patch to make sure we don't increase i_size in
      mmap.  But that will break userspace, because applications will now have
      to use truncate(2) to increase i_size in hugetlbfs.
      
      Based on the original patch from Hillf Danton.
      Signed-off-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
      Cc: Hillf Danton <dhillf@gmail.com>
      Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Hugh Dickins <hughd@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 avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fe4e2fab
    • Nishanth Aravamudan's avatar
      bootmem/sparsemem: remove limit constraint in alloc_bootmem_section · 9565cb71
      Nishanth Aravamudan authored
      commit f5bf18fa upstream.
      
      While testing AMS (Active Memory Sharing) / CMO (Cooperative Memory
      Overcommit) on powerpc, we tripped the following:
      
        kernel BUG at mm/bootmem.c:483!
        cpu 0x0: Vector: 700 (Program Check) at [c000000000c03940]
            pc: c000000000a62bd8: .alloc_bootmem_core+0x90/0x39c
            lr: c000000000a64bcc: .sparse_early_usemaps_alloc_node+0x84/0x29c
            sp: c000000000c03bc0
           msr: 8000000000021032
          current = 0xc000000000b0cce0
          paca    = 0xc000000001d80000
            pid   = 0, comm = swapper
        kernel BUG at mm/bootmem.c:483!
        enter ? for help
        [c000000000c03c80] c000000000a64bcc
        .sparse_early_usemaps_alloc_node+0x84/0x29c
        [c000000000c03d50] c000000000a64f10 .sparse_init+0x12c/0x28c
        [c000000000c03e20] c000000000a474f4 .setup_arch+0x20c/0x294
        [c000000000c03ee0] c000000000a4079c .start_kernel+0xb4/0x460
        [c000000000c03f90] c000000000009670 .start_here_common+0x1c/0x2c
      
      This is
      
              BUG_ON(limit && goal + size > limit);
      
      and after some debugging, it seems that
      
      	goal = 0x7ffff000000
      	limit = 0x80000000000
      
      and sparse_early_usemaps_alloc_node ->
      sparse_early_usemaps_alloc_pgdat_section calls
      
      	return alloc_bootmem_section(usemap_size() * count, section_nr);
      
      This is on a system with 8TB available via the AMS pool, and as a quirk
      of AMS in firmware, all of that memory shows up in node 0.  So, we end
      up with an allocation that will fail the goal/limit constraints.
      
      In theory, we could "fall-back" to alloc_bootmem_node() in
      sparse_early_usemaps_alloc_node(), but since we actually have HOTREMOVE
      defined, we'll BUG_ON() instead.  A simple solution appears to be to
      unconditionally remove the limit condition in alloc_bootmem_section,
      meaning allocations are allowed to cross section boundaries (necessary
      for systems of this size).
      
      Johannes Weiner pointed out that if alloc_bootmem_section() no longer
      guarantees section-locality, we need check_usemap_section_nr() to print
      possible cross-dependencies between node descriptors and the usemaps
      allocated through it.  That makes the two loops in
      sparse_early_usemaps_alloc_node() identical, so re-factor the code a
      bit.
      
      [akpm@linux-foundation.org: code simplification]
      Signed-off-by: default avatarNishanth Aravamudan <nacc@us.ibm.com>
      Cc: Dave Hansen <haveblue@us.ibm.com>
      Cc: Anton Blanchard <anton@au1.ibm.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Ben Herrenschmidt <benh@kernel.crashing.org>
      Cc: Robert Jennings <rcj@linux.vnet.ibm.com>
      Acked-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
      Acked-by: default avatarMel Gorman <mgorman@suse.de>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9565cb71
    • Rafael J. Wysocki's avatar
      PM / Domains: Fix handling of wakeup devices during system resume · 5c6156fa
      Rafael J. Wysocki authored
      commit cc85b207 upstream.
      
      During system suspend pm_genpd_suspend_noirq() checks if the given
      device is in a wakeup path (i.e. it appears to be needed for one or
      more wakeup devices to work or is a wakeup device itself) and if it
      needs to be "active" for wakeup to work.  If that is the case, the
      function returns 0 without incrementing the device domain's counter
      of suspended devices and without executing genpd_stop_dev() for the
      device.  In consequence, the device is not stopped (e.g. its clock
      isn't disabled) and power is always supplied to its domain in the
      resulting system sleep state.
      
      However, pm_genpd_resume_noirq() doesn't repeat that check and it
      runs genpd_start_dev() and decrements the domain's counter of
      suspended devices even for the wakeup device that weren't stopped by
      pm_genpd_suspend_noirq().  As a result, the start callback may be run
      unnecessarily for them and their domains' counters of suspended
      devices may become negative.  Both outcomes aren't desirable, so fix
      pm_genpd_resume_noirq() to look for wakeup devices that might not be
      stopped by during system suspend.
      Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
      Tested-by: default avatarSimon Horman <horms@verge.net.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5c6156fa
    • Tim Gardner's avatar
      TPM: Zero buffer whole after copying to userspace · 923da1e9
      Tim Gardner authored
      commit 3ab1aff8 upstream.
      
      Commit 3321c07a correctly clears the TPM
      buffer if the user specified read length is >= the TPM buffer length. However,
      if the user specified read length is < the TPM buffer length, then part of the
      TPM buffer is left uncleared.
      Reported-by: default avatarSeth Forshee <seth.forshee@canonical.com>
      Cc: Debora Velarde <debora@linux.vnet.ibm.com>
      Cc: Rajiv Andrade <srajiv@linux.vnet.ibm.com>
      Cc: Marcel Selhorst <m.selhorst@sirrix.com>
      Cc: tpmdd-devel@lists.sourceforge.net
      Signed-off-by: default avatarTim Gardner <tim.gardner@canonical.com>
      Signed-off-by: default avatarRajiv Andrade <srajiv@linux.vnet.ibm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      923da1e9
    • Andrea Arcangeli's avatar
      mm: thp: fix pmd_bad() triggering in code paths holding mmap_sem read mode · c6cf24ba
      Andrea Arcangeli authored
      commit 1a5a9906 upstream.
      
      In some cases it may happen that pmd_none_or_clear_bad() is called with
      the mmap_sem hold in read mode.  In those cases the huge page faults can
      allocate hugepmds under pmd_none_or_clear_bad() and that can trigger a
      false positive from pmd_bad() that will not like to see a pmd
      materializing as trans huge.
      
      It's not khugepaged causing the problem, khugepaged holds the mmap_sem
      in write mode (and all those sites must hold the mmap_sem in read mode
      to prevent pagetables to go away from under them, during code review it
      seems vm86 mode on 32bit kernels requires that too unless it's
      restricted to 1 thread per process or UP builds).  The race is only with
      the huge pagefaults that can convert a pmd_none() into a
      pmd_trans_huge().
      
      Effectively all these pmd_none_or_clear_bad() sites running with
      mmap_sem in read mode are somewhat speculative with the page faults, and
      the result is always undefined when they run simultaneously.  This is
      probably why it wasn't common to run into this.  For example if the
      madvise(MADV_DONTNEED) runs zap_page_range() shortly before the page
      fault, the hugepage will not be zapped, if the page fault runs first it
      will be zapped.
      
      Altering pmd_bad() not to error out if it finds hugepmds won't be enough
      to fix this, because zap_pmd_range would then proceed to call
      zap_pte_range (which would be incorrect if the pmd become a
      pmd_trans_huge()).
      
      The simplest way to fix this is to read the pmd in the local stack
      (regardless of what we read, no need of actual CPU barriers, only
      compiler barrier needed), and be sure it is not changing under the code
      that computes its value.  Even if the real pmd is changing under the
      value we hold on the stack, we don't care.  If we actually end up in
      zap_pte_range it means the pmd was not none already and it was not huge,
      and it can't become huge from under us (khugepaged locking explained
      above).
      
      All we need is to enforce that there is no way anymore that in a code
      path like below, pmd_trans_huge can be false, but pmd_none_or_clear_bad
      can run into a hugepmd.  The overhead of a barrier() is just a compiler
      tweak and should not be measurable (I only added it for THP builds).  I
      don't exclude different compiler versions may have prevented the race
      too by caching the value of *pmd on the stack (that hasn't been
      verified, but it wouldn't be impossible considering
      pmd_none_or_clear_bad, pmd_bad, pmd_trans_huge, pmd_none are all inlines
      and there's no external function called in between pmd_trans_huge and
      pmd_none_or_clear_bad).
      
      		if (pmd_trans_huge(*pmd)) {
      			if (next-addr != HPAGE_PMD_SIZE) {
      				VM_BUG_ON(!rwsem_is_locked(&tlb->mm->mmap_sem));
      				split_huge_page_pmd(vma->vm_mm, pmd);
      			} else if (zap_huge_pmd(tlb, vma, pmd, addr))
      				continue;
      			/* fall through */
      		}
      		if (pmd_none_or_clear_bad(pmd))
      
      Because this race condition could be exercised without special
      privileges this was reported in CVE-2012-1179.
      
      The race was identified and fully explained by Ulrich who debugged it.
      I'm quoting his accurate explanation below, for reference.
      
      ====== start quote =======
            mapcount 0 page_mapcount 1
            kernel BUG at mm/huge_memory.c:1384!
      
          At some point prior to the panic, a "bad pmd ..." message similar to the
          following is logged on the console:
      
            mm/memory.c:145: bad pmd ffff8800376e1f98(80000000314000e7).
      
          The "bad pmd ..." message is logged by pmd_clear_bad() before it clears
          the page's PMD table entry.
      
              143 void pmd_clear_bad(pmd_t *pmd)
              144 {
          ->  145         pmd_ERROR(*pmd);
              146         pmd_clear(pmd);
              147 }
      
          After the PMD table entry has been cleared, there is an inconsistency
          between the actual number of PMD table entries that are mapping the page
          and the page's map count (_mapcount field in struct page). When the page
          is subsequently reclaimed, __split_huge_page() detects this inconsistency.
      
             1381         if (mapcount != page_mapcount(page))
             1382                 printk(KERN_ERR "mapcount %d page_mapcount %d\n",
             1383                        mapcount, page_mapcount(page));
          -> 1384         BUG_ON(mapcount != page_mapcount(page));
      
          The root cause of the problem is a race of two threads in a multithreaded
          process. Thread B incurs a page fault on a virtual address that has never
          been accessed (PMD entry is zero) while Thread A is executing an madvise()
          system call on a virtual address within the same 2 MB (huge page) range.
      
                     virtual address space
                    .---------------------.
                    |                     |
                    |                     |
                  .-|---------------------|
                  | |                     |
                  | |                     |<-- B(fault)
                  | |                     |
            2 MB  | |/////////////////////|-.
            huge <  |/////////////////////|  > A(range)
            page  | |/////////////////////|-'
                  | |                     |
                  | |                     |
                  '-|---------------------|
                    |                     |
                    |                     |
                    '---------------------'
      
          - Thread A is executing an madvise(..., MADV_DONTNEED) system call
            on the virtual address range "A(range)" shown in the picture.
      
          sys_madvise
            // Acquire the semaphore in shared mode.
            down_read(&current->mm->mmap_sem)
            ...
            madvise_vma
              switch (behavior)
              case MADV_DONTNEED:
                   madvise_dontneed
                     zap_page_range
                       unmap_vmas
                         unmap_page_range
                           zap_pud_range
                             zap_pmd_range
                               //
                               // Assume that this huge page has never been accessed.
                               // I.e. content of the PMD entry is zero (not mapped).
                               //
                               if (pmd_trans_huge(*pmd)) {
                                   // We don't get here due to the above assumption.
                               }
                               //
                               // Assume that Thread B incurred a page fault and
                   .---------> // sneaks in here as shown below.
                   |           //
                   |           if (pmd_none_or_clear_bad(pmd))
                   |               {
                   |                 if (unlikely(pmd_bad(*pmd)))
                   |                     pmd_clear_bad
                   |                     {
                   |                       pmd_ERROR
                   |                         // Log "bad pmd ..." message here.
                   |                       pmd_clear
                   |                         // Clear the page's PMD entry.
                   |                         // Thread B incremented the map count
                   |                         // in page_add_new_anon_rmap(), but
                   |                         // now the page is no longer mapped
                   |                         // by a PMD entry (-> inconsistency).
                   |                     }
                   |               }
                   |
                   v
          - Thread B is handling a page fault on virtual address "B(fault)" shown
            in the picture.
      
          ...
          do_page_fault
            __do_page_fault
              // Acquire the semaphore in shared mode.
              down_read_trylock(&mm->mmap_sem)
              ...
              handle_mm_fault
                if (pmd_none(*pmd) && transparent_hugepage_enabled(vma))
                    // We get here due to the above assumption (PMD entry is zero).
                    do_huge_pmd_anonymous_page
                      alloc_hugepage_vma
                        // Allocate a new transparent huge page here.
                      ...
                      __do_huge_pmd_anonymous_page
                        ...
                        spin_lock(&mm->page_table_lock)
                        ...
                        page_add_new_anon_rmap
                          // Here we increment the page's map count (starts at -1).
                          atomic_set(&page->_mapcount, 0)
                        set_pmd_at
                          // Here we set the page's PMD entry which will be cleared
                          // when Thread A calls pmd_clear_bad().
                        ...
                        spin_unlock(&mm->page_table_lock)
      
          The mmap_sem does not prevent the race because both threads are acquiring
          it in shared mode (down_read).  Thread B holds the page_table_lock while
          the page's map count and PMD table entry are updated.  However, Thread A
          does not synchronize on that lock.
      
      ====== end quote =======
      
      [akpm@linux-foundation.org: checkpatch fixes]
      Reported-by: default avatarUlrich Obergfell <uobergfe@redhat.com>
      Signed-off-by: default avatarAndrea Arcangeli <aarcange@redhat.com>
      Acked-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
      Cc: Mel Gorman <mgorman@suse.de>
      Cc: Hugh Dickins <hughd@google.com>
      Cc: Dave Jones <davej@redhat.com>
      Acked-by: default avatarLarry Woodman <lwoodman@redhat.com>
      Acked-by: default avatarRik van Riel <riel@redhat.com>
      Cc: Mark Salter <msalter@redhat.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 avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c6cf24ba
    • Suresh Siddha's avatar
      x86/ioapic: Add register level checks to detect bogus io-apic entries · 273fb194
      Suresh Siddha authored
      commit 73d63d03 upstream.
      
      With the recent changes to clear_IO_APIC_pin() which tries to
      clear remoteIRR bit explicitly, some of the users started to see
      "Unable to reset IRR for apic .." messages.
      
      Close look shows that these are related to bogus IO-APIC entries
      which return's all 1's for their io-apic registers. And the
      above mentioned error messages are benign. But kernel should
      have ignored such io-apic's in the first place.
      
      Check if register 0, 1, 2 of the listed io-apic are all 1's and
      ignore such io-apic.
      Reported-by: default avatarÁlvaro Castillo <midgoon@gmail.com>
      Tested-by: default avatarJon Dufresne <jon@jondufresne.org>
      Signed-off-by: default avatarSuresh Siddha <suresh.b.siddha@intel.com>
      Cc: yinghai@kernel.org
      Cc: kernel-team@fedoraproject.org
      Cc: Josh Boyer <jwboyer@redhat.com>
      Link: http://lkml.kernel.org/r/1331577393.31585.94.camel@sbsiddha-desk.sc.intel.com
      [ Performed minor cleanup of affected code. ]
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      273fb194
    • Fabio Estevam's avatar
      ima: fix Kconfig dependencies · 4a02744b
      Fabio Estevam authored
      commit f4a0391d upstream.
      
      Fix the following build warning:
      warning: (IMA) selects TCG_TPM which has unmet direct dependencies
      (HAS_IOMEM && EXPERIMENTAL)
      Suggested-by: default avatarRajiv Andrade <srajiv@linux.vnet.ibm.com>
      Signed-off-by: default avatarFabio Estevam <fabio.estevam@freescale.com>
      Signed-off-by: default avatarRajiv Andrade <srajiv@linux.vnet.ibm.com>
      Signed-off-by: default avatarMimi Zohar <zohar@us.ibm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4a02744b
    • Or Gerlitz's avatar
      IB/iser: Post initial receive buffers before sending the final login request · 9af865fc
      Or Gerlitz authored
      commit 89e984e2 upstream.
      
      An iser target may send iscsi NO-OP PDUs as soon as it marks the iSER
      iSCSI session as fully operative.  This means that there is window
      where there are no posted receive buffers on the initiator side, so
      it's possible for the iSER RC connection to break because of RNR NAK /
      retry errors.  To fix this, rely on the flags bits in the login
      request to have FFP (0x3) in the lower nibble as a marker for the
      final login request, and post an initial chunk of receive buffers
      before sending that login request instead of after getting the login
      response.
      Signed-off-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
      Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9af865fc
    • Greg Rose's avatar
      rtnetlink: Fix VF IFLA policy · 2e4d3c51
      Greg Rose authored
      commit 48752f65 upstream.
      
      Add VF spoof check to IFLA policy.  The original patch I submitted to
      add the spoof checking feature to rtnl failed to add the proper policy
      rule that identifies the data type and len.  This patch corrects that
      oversight.  No bugs have been reported against this but it may cause
      some problem for the netlink message parsing that uses the policy
      table.
      Signed-off-by: default avatarGreg Rose <gregory.v.rose@intel.com>
      Tested-by: default avatarSibai Li <sibai.li@intel.com>
      Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2e4d3c51
    • Max Filippov's avatar
      p54spi: Release GPIO lines and IRQ on error in p54spi_probe · 0abe0c69
      Max Filippov authored
      commit 62ebeed8 upstream.
      
      This makes it possible to reload driver if insmod has failed due to
      missing firmware.
      Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      Acked-by: default avatarChristian Lamparter <chunkeey@googlemail.com>
      Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0abe0c69
    • Rabin Vincent's avatar
      rtc: Disable the alarm in the hardware (v2) · 63d1c866
      Rabin Vincent authored
      commit 41c7f742 upstream.
      
      Currently, the RTC code does not disable the alarm in the hardware.
      
      This means that after a sequence such as the one below (the files are in the
      RTC sysfs), the box will boot up after 2 minutes even though we've
      asked for the alarm to be turned off.
      
      	# echo $((`cat since_epoch`)+120) > wakealarm
      	# echo 0 > wakealarm
      	# poweroff
      
      Fix this by disabling the alarm when there are no timers to run.
      
      The original version of this patch was reverted. This version
      disables the irq directly instead of setting a disabled timer
      in the future.
      
      Cc: John Stultz <john.stultz@linaro.org>
      Signed-off-by: default avatarRabin Vincent <rabin.vincent@stericsson.com>
      [Merged in the second revision from Rabin]
      Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      63d1c866
    • Alexander Gordeev's avatar
      genirq: Fix incorrect check for forced IRQ thread handler · d06ce542
      Alexander Gordeev authored
      commit 540b60e2 upstream.
      
      We do not want a bitwise AND between boolean operands
      Signed-off-by: default avatarAlexander Gordeev <agordeev@redhat.com>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Link: http://lkml.kernel.org/r/20120309135912.GA2114@dhcp-26-207.brq.redhat.comSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d06ce542
    • Russell King's avatar
      genirq: Fix long-term regression in genirq irq_set_irq_type() handling · 4e6c04ec
      Russell King authored
      commit a09b659c upstream.
      
      In 2008, commit 0c5d1eb7 ("genirq: record trigger type") modified the
      way set_irq_type() handles the 'no trigger' condition.  However, this has
      an adverse effect on PCMCIA support on Intel StrongARM and probably PXA
      platforms.
      
      PCMCIA has several status signals on the socket which can trigger
      interrupts; some of these status signals depend on the card's mode
      (whether it is configured in memory or IO mode).  For example, cards have
      a 'Ready/IRQ' signal: in memory mode, this provides an indication to
      PCMCIA that the card has finished its power up initialization.  In IO
      mode, it provides the device interrupt signal.  Other status signals
      switch between on-board battery status and loud speaker output.
      
      In classical PCMCIA implementations, where you have a specific socket
      controller, the controller provides a method to mask interrupts from the
      socket, and importantly ignore any state transitions on the pins which
      correspond with interrupts once masked.  This masking prevents unwanted
      events caused by the removal and application of socket power being
      forwarded.
      
      However, on platforms where there is no socket controller, the PCMCIA
      status and interrupt signals are routed to standard edge-triggered GPIOs.
      These GPIOs can be configured to interrupt on rising edge, falling edge,
      or never.  This is where the problems start.
      
      Edge triggered interrupts are required to record events while disabled via
      the usual methods of {free,request,disable,enable}_irq() to prevent
      problems with dropped interrupts (eg, the 8390 driver uses disable_irq()
      to defer the delivery of interrupts).  As a result, these interfaces can
      not be used to implement the desired behaviour.
      
      The side effect of this is that if the 'Ready/IRQ' GPIO is disabled via
      disable_irq() on suspend, and enabled via enable_irq() after resume, we
      will record the state transitions caused by powering events as valid
      interrupts, and foward them to the card driver, which may attempt to
      access a card which is not powered up.
      
      This leads delays resume while drivers spin in their interrupt handlers,
      and complaints from drivers before they realize what's happened.
      
      Moreover, in the case of the 'Ready/IRQ' signal, this is requested and
      freed by the card driver itself; the PCMCIA core has no idea whether the
      interrupt is requested, and, therefore, whether a call to disable_irq()
      would be valid.  (We tried this around 2.4.17 / 2.5.1 kernel era, and
      ended up throwing it out because of this problem.)
      
      Therefore, it was decided back in around 2002 to disable the edge
      triggering instead, resulting in all state transitions on the GPIO being
      ignored.  That's what we actually need the hardware to do.
      
      The commit above changes this behaviour; it explicitly prevents the 'no
      trigger' state being selected.
      
      The reason that request_irq() does not accept the 'no trigger' state is
      for compatibility with existing drivers which do not provide their desired
      triggering configuration.  The set_irq_type() function is 'new' and not
      used by non-trigger aware drivers.
      
      Therefore, revert this change, and restore previously working platforms
      back to their former state.
      Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
      Cc: linux@arm.linux.org.uk
      Cc: Ingo Molnar <mingo@elte.hu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4e6c04ec
    • Andrew Vagin's avatar
      uevent: send events in correct order according to seqnum (v3) · 1a24aa6e
      Andrew Vagin authored
      commit 7b60a18d upstream.
      
      The queue handling in the udev daemon assumes that the events are
      ordered.
      
      Before this patch uevent_seqnum is incremented under sequence_lock,
      than an event is send uner uevent_sock_mutex. I want to say that code
      contained a window between incrementing seqnum and sending an event.
      
      This patch locks uevent_sock_mutex before incrementing uevent_seqnum.
      
      v2: delete sequence_lock, uevent_seqnum is protected by uevent_sock_mutex
      v3: unlock the mutex before the goto exit
      
      Thanks for Kay for the comments.
      Signed-off-by: default avatarAndrew Vagin <avagin@openvz.org>
      Tested-By: default avatarKay Sievers <kay.sievers@vrfy.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1a24aa6e
    • Sasha Levin's avatar
      ntp: Fix integer overflow when setting time · 1f2c44df
      Sasha Levin authored
      commit a078c6d0 upstream.
      
      'long secs' is passed as divisor to div_s64, which accepts a 32bit
      divisor. On 64bit machines that value is trimmed back from 8 bytes
      back to 4, causing a divide by zero when the number is bigger than
      (1 << 32) - 1 and all 32 lower bits are 0.
      
      Use div64_long() instead.
      Signed-off-by: default avatarSasha Levin <levinsasha928@gmail.com>
      Cc: johnstul@us.ibm.com
      Link: http://lkml.kernel.org/r/1331829374-31543-2-git-send-email-levinsasha928@gmail.comSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1f2c44df
    • Sasha Levin's avatar
      math: Introduce div64_long · c2b03366
      Sasha Levin authored
      commit f910381a upstream.
      
      Add a div64_long macro which is used to devide a 64bit number by a long (which
      can be 4 bytes on 32bit systems and 8 bytes on 64bit systems).
      Suggested-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarSasha Levin <levinsasha928@gmail.com>
      Cc: johnstul@us.ibm.com
      Link: http://lkml.kernel.org/r/1331829374-31543-1-git-send-email-levinsasha928@gmail.comSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c2b03366
    • Johannes Berg's avatar
      iwlwifi: always monitor for stuck queues · c8fe4631
      Johannes Berg authored
      commit 342bbf3f upstream.
      
      If we only monitor while associated, the following
      can happen:
       - we're associated, and the queue stuck check
         runs, setting the queue "touch" time to X
       - we disassociate, stopping the monitoring,
         which leaves the time set to X
       - almost 2s later, we associate, and enqueue
         a frame
       - before the frame is transmitted, we monitor
         for stuck queues, and find the time set to
         X, although it is now later than X + 2000ms,
         so we decide that the queue is stuck and
         erroneously restart the device
      
      It happens more with P2P because there we can
      go between associated/unassociated frequently.
      Reported-by: default avatarBen Cahill <ben.m.cahill@intel.com>
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarWey-Yi Guy <wey-yi.w.guy@intel.com>
      Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c8fe4631
    • Jingjun Wu's avatar
      rtlwifi: rtl8192ce: Fix loss of receive performance · 67fd437f
      Jingjun Wu authored
      commit a9b89e25 upstream.
      
      Driver rtl8192ce when used with the RTL8188CE device would start at about
      20 Mbps on a 54 Mbps connection, but quickly drop to 1 Mbps. One of the
      symptoms is that the AP would need to retransmit each packet 4 of 5 times
      before the driver would acknowledge it. Recovery is possible only by
      unloading and reloading the driver. This problem was reported at
      https://bugzilla.redhat.com/show_bug.cgi?id=770207.
      
      The problem is due to a missing update of the gain setting.
      Signed-off-by: default avatarJingjun Wu <jingjun_wu@realsil.com.cn>
      Signed-off-by: default avatarLarry Finger <Larry.Finger@lwfinger.net>
      Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      67fd437f
    • Larry Finger's avatar
      rtlwifi: rtl8192c: Prevent sleeping from invalid context in rtl8192cu · a6ce707a
      Larry Finger authored
      commit ebecdcc1 upstream.
      
      When driver rtl8192cu is used with the debug level set to 3 or greater,
      the result is "sleeping function called from invalid context" due to
      an rcu_read_lock() call in the DM refresh routine in driver rtl8192c.
      This lock is not necessary as the USB driver does not use the struct
      being protected, thus the lock is set only when a PCI interface is
      active.
      
      This bug is reported in https://bugzilla.kernel.org/show_bug.cgi?id=42775.
      Reported-by: default avatarRonald Wahl <ronald.wahl@raritan.com>
      Tested-by: default avatarRonald Wahl <ronald.wahl@raritan.com>
      Signed-off-by: default avatarLarry Finger <Larry.Finger@lwfinger.net>
      Cc: Ronald Wahl <ronald.wahl@raritan.com>
      Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a6ce707a
    • Simon Graham's avatar
      rtlwifi: Handle previous allocation failures when freeing device memory · 4d804674
      Simon Graham authored
      commit 7f66c2f9 upstream.
      
      Handle previous allocation failures when freeing device memory
      Signed-off-by: default avatarSimon Graham <simon.graham@virtualcomputer.com>
      Signed-off-by: default avatarLarry Finger <Larry.Finger@lwfinger.net>
      Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4d804674
    • Larry Finger's avatar
      rtlwifi: rtl8192c_common: rtl8192de: Check for allocation failures · de886abb
      Larry Finger authored
      commit 76a92be5 upstream.
      
      In https://bugzilla.redhat.com/show_bug.cgi?id=771656, a kernel bug was
      triggered due to a failed skb allocation that was not checked. This event
      lead to an audit of all memory allocations in the complete rtlwifi family
      of drivers. This patch fixes the rest.
      Signed-off-by: default avatarLarry Finger <Larry.Finger@lwfinger.net>
      Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      de886abb
    • Gertjan van Wingerde's avatar
      81a142ca
    • Donald Lee's avatar
      USB: serial: mos7840: Fixed MCS7820 device attach problem · 7b2a7db9
      Donald Lee authored
      commit 093ea2d3 upstream.
      
      A MCS7820 device supports two serial ports and a MCS7840 device supports
      four serial ports. Both devices use the same driver, but the attach function
      in driver was unable to correctly handle the port numbers for MCS7820
      device. This problem has been fixed in this patch and this fix has been
      verified on x86 Linux kernel 3.2.9 with both MCS7820 and MCS7840 devices.
      Signed-off-by: default avatarDonald Lee <donald@asix.com.tw>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7b2a7db9
    • Preston Fick's avatar
      usb: cp210x: Update to support CP2105 and multiple interface devices · 30f05186
      Preston Fick authored
      commit a5360a53 upstream.
      
      This patch updates the cp210x driver to support CP210x multiple
      interface devices devices from Silicon Labs. The existing driver
      always sends control requests to interface 0, which is hardcoded in
      the usb_control_msg function calls. This only allows for single
      interface devices to be used, and causes a bug when using ports on an
      interface other than 0 in the multiple interface devices.
      
      Here are the changes included in this patch:
      - Updated the device list to contain the Silicon Labs factory default
        VID/PID for multiple interface CP210x devices
      - Created a cp210x_port_private struct created for each port on
        startup, this struct holds the interface number
      - Added a cp210x_release function to clean up the cp210x_port_private
        memory created on startup
      - Modified usb_get_config and usb_set_config to get a pointer to the
        cp210x_port_private struct, and use the interface number there in the
        usb_control_message wIndex param
      Signed-off-by: default avatarPreston Fick <preston.fick@silabs.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      30f05186
    • Scott Dial's avatar
      usb-serial: Add support for the Sealevel SeaLINK+8 2038-ROHS device · 39531b95
      Scott Dial authored
      commit 6d161b99 upstream.
      
      This patch adds new device IDs to the ftdi_sio module to support
      the new Sealevel SeaLINK+8 2038-ROHS device.
      Signed-off-by: default avatarScott Dial <scott.dial@scientiallc.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      39531b95
    • Dan Williams's avatar
      USB: qcserial: don't grab QMI port on Gobi 1000 devices · b951f1a7
      Dan Williams authored
      commit c192c8e7 upstream.
      
      Gobi 1000 devices have a different port layout, which wasn't respected
      by the current driver, and thus it grabbed the QMI/net port.  In the
      near future we'll be attaching another driver to the QMI/net port for
      these devices (cdc-wdm and qmi_wwan) so make sure the qcserial driver
      doesn't claim them.  This patch also prevents qcserial from binding to
      interfaces 0 and 1 on 1K devices because those interfaces do not
      respond.
      Signed-off-by: default avatarDan Williams <dcbw@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b951f1a7
    • Thomas Tuttle's avatar
      USB: qcserial: add several new serial devices · 4a39b3bd
      Thomas Tuttle authored
      commit 2db4d870 upstream.
      Signed-off-by: default avatarThomas Tuttle <ttuttle@chromium.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      4a39b3bd
    • Josh Boyer's avatar
      USB: ums_realtek: do not use stack memory for DMA in __do_config_autodelink · 61849d82
      Josh Boyer authored
      commit 4898e071 upstream.
      
      __do_config_autodelink passes the data variable to the transport function.
      If the calling functions pass a stack variable, this will eventually trigger
      a DMA-API debug backtrace for mapping stack memory in the DMA buffer.  Fix
      this by calling kmemdup for the passed data instead.
      Signed-off-by: default avatarJosh Boyer <jwboyer@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      61849d82
    • Peter Chen's avatar
      usb: Fix build error due to dma_mask is not at pdev_archdata at ARM · 72741418
      Peter Chen authored
      commit e90fc3cb upstream.
      
      When build i.mx platform with imx_v6_v7_defconfig, and after adding
      USB Gadget support, it has below build error:
      
      CC      drivers/usb/host/fsl-mph-dr-of.o
      drivers/usb/host/fsl-mph-dr-of.c: In function 'fsl_usb2_device_register':
      drivers/usb/host/fsl-mph-dr-of.c:97: error: 'struct pdev_archdata'
      has no member named 'dma_mask'
      
      It has discussed at: http://www.spinics.net/lists/linux-usb/msg57302.html
      
      For PowerPC, there is dma_mask at struct pdev_archdata, but there is
      no dma_mask at struct pdev_archdata for ARM. The pdev_archdata is
      related to specific platform, it should NOT be accessed by
      cross platform drivers, like USB.
      
      The code for pdev_archdata should be useless, as for PowerPC,
      it has already gotten the value for pdev->dev.dma_mask at function
      arch_setup_pdev_archdata of arch/powerpc/kernel/setup-common.c.
      Tested-by: default avatarRamneek Mehresh <ramneek.mehresh@freescale.com>
      Signed-off-by: default avatarPeter Chen <peter.chen@freescale.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      72741418
    • Peter Chen's avatar
      usb: fsl_udc_core: Fix scheduling while atomic dump message · 8bfc26d2
      Peter Chen authored
      commit c5cc5ed8 upstream.
      
      When loading g_ether gadget, there is below message:
      
      Backtrace:
      [<80012248>] (dump_backtrace+0x0/0x10c) from [<803cb42c>] (dump_stack+0x18/0x1c)
      r7:00000000 r6:80512000 r5:8052bef8 r4:80513f30
      [<803cb414>] (dump_stack+0x0/0x1c) from [<8000feb4>] (show_regs+0x44/0x50)
      [<8000fe70>] (show_regs+0x0/0x50) from [<8004c840>] (__schedule_bug+0x68/0x84)
      r5:8052bef8 r4:80513f30
      [<8004c7d8>] (__schedule_bug+0x0/0x84) from [<803cd0e4>] (__schedule+0x4b0/0x528)
      r5:8052bef8 r4:809aad00
      [<803ccc34>] (__schedule+0x0/0x528) from [<803cd214>] (_cond_resched+0x44/0x58)
      [<803cd1d0>] (_cond_resched+0x0/0x58) from [<800a9488>] (dma_pool_alloc+0x184/0x250)
       r5:9f9b4000 r4:9fb4fb80
       [<800a9304>] (dma_pool_alloc+0x0/0x250) from [<802a8ad8>] (fsl_req_to_dtd+0xac/0x180)
      [<802a8a2c>] (fsl_req_to_dtd+0x0/0x180) from [<802a8ce4>] (fsl_ep_queue+0x138/0x274)
      [<802a8bac>] (fsl_ep_queue+0x0/0x274) from [<7f004328>] (composite_setup+0x2d4/0xfac [g_ether])
      [<7f004054>] (composite_setup+0x0/0xfac [g_ether]) from [<802a9bb4>] (fsl_udc_irq+0x8dc/0xd38)
      [<802a92d8>] (fsl_udc_irq+0x0/0xd38) from [<800704f8>] (handle_irq_event_percpu+0x54/0x188)
      [<800704a4>] (handle_irq_event_percpu+0x0/0x188) from [<80070674>] (handle_irq_event+0x48/0x68)
      [<8007062c>] (handle_irq_event+0x0/0x68) from [<800738ec>] (handle_level_irq+0xb4/0x138)
       r5:80514f94 r4:80514f40
       [<80073838>] (handle_level_irq+0x0/0x138) from [<8006ffa4>] (generic_handle_irq+0x38/0x44)
       r7:00000012 r6:80510b1c r5:80529860 r4:80512000
       [<8006ff6c>] (generic_handle_irq+0x0/0x44) from [<8000f4c4>] (handle_IRQ+0x54/0xb4)
      [<8000f470>] (handle_IRQ+0x0/0xb4) from [<800085b8>] (tzic_handle_irq+0x64/0x94)
       r9:412fc085 r8:00000000 r7:80513f30 r6:00000001 r5:00000000
       r4:00000000
       [<80008554>] (tzic_handle_irq+0x0/0x94) from [<8000e680>] (__irq_svc+0x40/0x60)
      
      The reason of above dump message is calling dma_poll_alloc with can-schedule
      mem_flags at atomic context.
      
      To fix this problem, below changes are made:
      - fsl_req_to_dtd doesn't need to be protected by spin_lock_irqsave,
      as struct usb_request can be access at process context. Move lock
      to beginning of hardware visit (fsl_queue_td).
      - Change the memory flag which using to allocate dTD descriptor buffer,
      the memory flag can be from gadget layer.
      
      It is tested at i.mx51 bbg board with g_mass_storage, g_ether, g_serial.
      Signed-off-by: default avatarPeter Chen <peter.chen@freescale.com>
      Acked-by: default avatarLi Yang <leoli@freescale.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8bfc26d2