15 Feb, 2017

6 commits

  • commit 0b529f143e8baad441a5aac9ad55ec2434d8fb46 upstream.

    Kernel panics when userspace program try to access AEAD interface.
    Remove node from Linked List before freeing its memory.

    Signed-off-by: Harsh Jain
    Reviewed-by: Stephan Müller
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Harsh Jain
     
  • commit 4087a1fffe38106e10646606a27f10d40451862d upstream.

    Fixes a crash in dm_table_find_target() due to a NULL struct dm_table
    being passed from dm_old_request_fn() that races with DM device
    destruction.

    Reported-by: artem@flashgrid.io
    Signed-off-by: Mike Snitzer
    Signed-off-by: Greg Kroah-Hartman

    Mike Snitzer
     
  • commit bfb34527a32a1a576d9bfb7026d3ab0369a6cd60 upstream.

    When vmemmap_populate() allocates space for the memmap it does so in 2MB
    sized chunks. The libnvdimm-pfn driver incorrectly accounts for this
    when the alignment of the device is set to 4K. When this happens we
    trigger memory allocation failures in altmap_alloc_block_buf() and
    trigger warnings of the form:

    WARNING: CPU: 0 PID: 3376 at arch/x86/mm/init_64.c:656 arch_add_memory+0xe4/0xf0
    [..]
    Call Trace:
    dump_stack+0x86/0xc3
    __warn+0xcb/0xf0
    warn_slowpath_null+0x1d/0x20
    arch_add_memory+0xe4/0xf0
    devm_memremap_pages+0x29b/0x4e0

    Fixes: 315c562536c4 ("libnvdimm, pfn: add 'align' attribute, default to HPAGE_SIZE")
    Signed-off-by: Dan Williams
    Signed-off-by: Greg Kroah-Hartman

    Dan Williams
     
  • commit 9d032f4201d39e5cf43a8709a047e481f5723fdc upstream.

    Given that the naming of pmem devices changes from the pmemX form to the
    pmemX.Y form when namespace id is greater than 0, arrange for namespaces
    with id-0 to be exempt from deletion. Otherwise a simple reconfiguration
    of an existing namespace to a new mode results in a name change of the
    resulting block device:

    # ndctl list --namespace=namespace1.0
    {
    "dev":"namespace1.0",
    "mode":"raw",
    "size":2147483648,
    "uuid":"3dadf3dc-89b9-4b24-b20e-abc8a4707ce3",
    "blockdev":"pmem1"
    }

    # ndctl create-namespace --reconfig=namespace1.0 --mode=memory --force
    {
    "dev":"namespace1.1",
    "mode":"memory",
    "size":2111832064,
    "uuid":"7b4a6341-7318-4219-a02c-fb57c0bbf613",
    "blockdev":"pmem1.1"
    }

    This change does require tooling changes to explicitly look for
    namespaceX.0 if the seed has already advanced to another namespace.

    Fixes: 98a29c39dc68 ("libnvdimm, namespace: allow creation of multiple pmem-namespaces per region")
    Reviewed-by: Johannes Thumshirn
    Signed-off-by: Dan Williams
    Signed-off-by: Greg Kroah-Hartman

    Dan Williams
     
  • commit e471486c13b82b1338d49c798f78bb62b1ed0a9e upstream.

    We queue an on-stack work item to 'nfit_wq' and wait for it to complete
    as part of a 'flush_probe' request. However, if the user cancels the
    wait we need to make sure the item is flushed from the queue otherwise
    we are leaving an out-of-scope stack address on the work list.

    BUG: unable to handle kernel paging request at ffffbcb3c72f7cd0
    IP: [] __list_add+0x1b/0xb0
    [..]
    RIP: 0010:[] [] __list_add+0x1b/0xb0
    RSP: 0018:ffffbcb3c7ba7c00 EFLAGS: 00010046
    [..]
    Call Trace:
    [] insert_work+0x3a/0xc0
    [] ? seq_open+0x5a/0xa0
    [] __queue_work+0x16a/0x460
    [] queue_work_on+0x38/0x40
    [] acpi_nfit_flush_probe+0x95/0xc0 [nfit]
    [] ? nfit_visible+0x40/0x40 [nfit]
    [] wait_probe_show+0x25/0x60
    [] dev_attr_show+0x20/0x50

    Fixes: 7ae0fa439faf ("nfit, libnvdimm: async region scrub workqueue")
    Reviewed-by: Vishal Verma
    Signed-off-by: Dan Williams
    Signed-off-by: Greg Kroah-Hartman

    Dan Williams
     
  • commit 6e978b22efa1db9f6e71b24440b5f1d93e968ee3 upstream.

    Some Kabylake desktop processors may not reach max turbo when running in
    HWP mode, even if running under sustained 100% utilization.

    This occurs when the HWP.EPP (Energy Performance Preference) is set to
    "balance_power" (0x80) -- the default on most systems.

    It occurs because the platform BIOS may erroneously enable an
    energy-efficiency setting -- MSR_IA32_POWER_CTL BIT-EE, which is not
    recommended to be enabled on this SKU.

    On the failing systems, this BIOS issue was not discovered when the
    desktop motherboard was tested with Windows, because the BIOS also
    neglects to provide the ACPI/CPPC table, that Windows requires to enable
    HWP, and so Windows runs in legacy P-state mode, where this setting has
    no effect.

    Linux' intel_pstate driver does not require ACPI/CPPC to enable HWP, and
    so it runs in HWP mode, exposing this incorrect BIOS configuration.

    There are several ways to address this problem.

    First, Linux can also run in legacy P-state mode on this system.
    As intel_pstate is how Linux enables HWP, booting with
    "intel_pstate=disable"
    will run in acpi-cpufreq/ondemand legacy p-state mode.

    Or second, the "performance" governor can be used with intel_pstate,
    which will modify HWP.EPP to 0.

    Or third, starting in 4.10, the
    /sys/devices/system/cpu/cpufreq/policy*/energy_performance_preference
    attribute in can be updated from "balance_power" to "performance".

    Or fourth, apply this patch, which fixes the erroneous setting of
    MSR_IA32_POWER_CTL BIT_EE on this model, allowing the default
    configuration to function as designed.

    Signed-off-by: Srinivas Pandruvada
    Reviewed-by: Len Brown
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Srinivas Pandruvada
     

09 Feb, 2017

34 commits

  • Greg Kroah-Hartman
     
  • commit bafb2f7d4755bf1571bd5e9a03b97f3fc4fe69ae upstream.

    There is a disparity in the context image saved to disk and our own
    bookkeeping - that is we presume the RING_HEAD and RING_TAIL match our
    stored ce->ring->tail value. However, as we emit WA_TAIL_DWORDS into the
    ring but may not tell the GPU about them, the GPU may be lagging behind
    our bookkeeping. Upon hibernation we do not save stolen pages, presuming
    that their contents are volatile. This means that although we start
    writing into the ring at tail, the GPU starts executing from its HEAD
    and there may be some garbage in between and so the GPU promptly hangs
    upon resume.

    Testcase: igt/gem_exec_suspend/basic-S4
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=96526
    Signed-off-by: Chris Wilson
    Reviewed-by: Joonas Lahtinen
    Link: http://patchwork.freedesktop.org/patch/msgid/20160921135108.29574-3-chris@chris-wilson.co.uk
    Cc: Eric Blau
    Signed-off-by: Greg Kroah-Hartman

    Chris Wilson
     
  • commit d1908f52557b3230fbd63c0429f3b4b748bf2b6d upstream.

    Tetsuo has noticed that an OOM stress test which performs large write
    requests can cause the full memory reserves depletion. He has tracked
    this down to the following path

    __alloc_pages_nodemask+0x436/0x4d0
    alloc_pages_current+0x97/0x1b0
    __page_cache_alloc+0x15d/0x1a0 mm/filemap.c:728
    pagecache_get_page+0x5a/0x2b0 mm/filemap.c:1331
    grab_cache_page_write_begin+0x23/0x40 mm/filemap.c:2773
    iomap_write_begin+0x50/0xd0 fs/iomap.c:118
    iomap_write_actor+0xb5/0x1a0 fs/iomap.c:190
    ? iomap_write_end+0x80/0x80 fs/iomap.c:150
    iomap_apply+0xb3/0x130 fs/iomap.c:79
    iomap_file_buffered_write+0x68/0xa0 fs/iomap.c:243
    ? iomap_write_end+0x80/0x80
    xfs_file_buffered_aio_write+0x132/0x390 [xfs]
    ? remove_wait_queue+0x59/0x60
    xfs_file_write_iter+0x90/0x130 [xfs]
    __vfs_write+0xe5/0x140
    vfs_write+0xc7/0x1f0
    ? syscall_trace_enter+0x1d0/0x380
    SyS_write+0x58/0xc0
    do_syscall_64+0x6c/0x200
    entry_SYSCALL64_slow_path+0x25/0x25

    the oom victim has access to all memory reserves to make a forward
    progress to exit easier. But iomap_file_buffered_write and other
    callers of iomap_apply loop to complete the full request. We need to
    check for fatal signals and back off with a short write instead.

    As the iomap_apply delegates all the work down to the actor we have to
    hook into those. All callers that work with the page cache are calling
    iomap_write_begin so we will check for signals there. dax_iomap_actor
    has to handle the situation explicitly because it copies data to the
    userspace directly. Other callers like iomap_page_mkwrite work on a
    single page or iomap_fiemap_actor do not allocate memory based on the
    given len.

    Fixes: 68a9f5e7007c ("xfs: implement iomap based buffered write path")
    Link: http://lkml.kernel.org/r/20170201092706.9966-2-mhocko@kernel.org
    Signed-off-by: Michal Hocko
    Reported-by: Tetsuo Handa
    Reviewed-by: Christoph Hellwig
    Cc: Al Viro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Signed-off-by: Greg Kroah-Hartman

    Michal Hocko
     
  • commit b414fa01c31318383ae29d9d23cb9ca4184bbd86 upstream.

    The current QP FetchBurstMax value is 256B, which
    is incorrect since a WR can exceed that value. The
    result being a partial WR fetched by hardware, and
    a fatal "bad WR" error posted by the SGE.

    So bump the FetchBurstMax to 512B.

    Signed-off-by: Steve Wise
    Signed-off-by: Doug Ledford
    Signed-off-by: Greg Kroah-Hartman

    Steve Wise
     
  • commit aaaec6fc755447a1d056765b11b24d8ff2b81366 upstream.

    The recent commit which prevents double activation of interrupts unearthed
    interesting code in x86. The code (ab)uses irq_domain_activate_irq() to
    reconfigure an already activated interrupt. That trips over the prevention
    code now.

    Fix it by deactivating the interrupt before activating the new configuration.

    Fixes: 08d85f3ea99f1 "irqdomain: Avoid activating interrupts more than once"
    Reported-and-tested-by: Mike Galbraith
    Reported-and-tested-by: Borislav Petkov
    Signed-off-by: Thomas Gleixner
    Cc: Andrey Ryabinin
    Cc: Marc Zyngier
    Link: http://lkml.kernel.org/r/alpine.DEB.2.20.1701311901580.3457@nanos
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     
  • commit 08d85f3ea99f1eeafc4e8507936190e86a16ee8c upstream.

    Since commit f3b0946d629c ("genirq/msi: Make sure PCI MSIs are
    activated early"), we can end-up activating a PCI/MSI twice (once
    at allocation time, and once at startup time).

    This is normally of no consequences, except that there is some
    HW out there that may misbehave if activate is used more than once
    (the GICv3 ITS, for example, uses the activate callback
    to issue the MAPVI command, and the architecture spec says that
    "If there is an existing mapping for the EventID-DeviceID
    combination, behavior is UNPREDICTABLE").

    While this could be worked around in each individual driver, it may
    make more sense to tackle the issue at the core level. In order to
    avoid getting in that situation, let's have a per-interrupt flag
    to remember if we have already activated that interrupt or not.

    Fixes: f3b0946d629c ("genirq/msi: Make sure PCI MSIs are activated early")
    Reported-and-tested-by: Andre Przywara
    Signed-off-by: Marc Zyngier
    Link: http://lkml.kernel.org/r/1484668848-24361-1-git-send-email-marc.zyngier@arm.com
    Signed-off-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Marc Zyngier
     
  • commit 828f84ee8f84710ea1818b3565add268bcb824c8 upstream.

    FIFO was being read every sample after the "almost full" state was
    reached. This was due to an incorrect placement of the parenthesis
    in the while condition check.

    Note - the fixes tag is not actually correct, but the fix in this patch
    would also be needed for it to function correctly so we'll go with that
    one. Backports should pick up both.

    Signed-off-by: Matt Ranostay
    Fixes: b74fccad7 ("iio: health: max30100: correct FIFO check condition")
    Signed-off-by: Jonathan Cameron
    Signed-off-by: Greg Kroah-Hartman

    Matt Ranostay
     
  • commit 5c113b5e0082e90d2e1c7b12e96a7b8cf0623e27 upstream.

    The DHT22 (AM2302) datasheet specifies that the LOW start pulse should not
    exceed 20ms. However, observations with an oscilloscope of an RPi Model 2B
    (rev 1.1) communicating with a DHT22 sensor showed that the driver was
    consistently sending start pulses longer than 20ms:

    Kernel 4.7.10-v7+ (n=132):
    Minimum pulse length: 20.20ms
    Maximum: 29.84ms
    Mean: 24.96ms
    StDev: 2.82ms
    Sensor response rate: 100%
    Read success rate: 76%

    On kernel 4.8, the start pulse was so long that the sensor would not even
    respond 97% of the time:

    Kernel 4.8.16-v7+ (n=100):
    Minimum pulse length: 30.4ms
    Maximum: 74.4ms
    Mean: 39.3ms
    StDev: 10.2ms
    Sensor response rate: 3%
    Read success rate: 3%

    The driver would return ETIMEDOUT and write log messages like this:

    [ 51.430987] dht11 dht11@0: Only 1 signal edges detected
    [ 66.311019] dht11 dht11@0: Only 0 signal edges detected

    Replacing msleep(18) with usleep_range(18000, 20000) made the pulse length
    sane again and restored responsiveness:

    Kernel 4.8.16-v7+ with usleep_range (n=123):
    Minimum pulse length: 18.16ms
    Maximum: 20.20ms
    Mean: 19.85ms
    StDev: 0.51ms
    Sensor response rate: 100%
    Read success rate: 84%

    Signed-off-by: John Brooks
    Reviewed-by: Harald Geyer
    Signed-off-by: Jonathan Cameron
    Signed-off-by: Greg Kroah-Hartman

    John Brooks
     
  • commit a5badd1e97e6caeca78ad74191f12fc923c403a8 upstream.

    The suspend/resume functions were using dev_to_iio_dev() to get
    the iio_dev. That only works on IIO dev's. Replace it with spi
    functions to get the correct iio_dev.

    Signed-off-by: Alison Schofield
    Acked-by: Andrew F. Davis
    Signed-off-by: Jonathan Cameron
    Signed-off-by: Greg Kroah-Hartman

    Alison Schofield
     
  • commit 802ecfc113df1e15af1d028427cbbe785ae9cc4a upstream.

    The suspend/resume functions were using dev_to_iio_dev() to get
    the iio_dev. That only works on IIO dev's. Replace it with i2c
    functions to get the correct iio_dev.

    Signed-off-by: Alison Schofield
    Acked-by: Andrew F. Davis
    Signed-off-by: Jonathan Cameron
    Signed-off-by: Greg Kroah-Hartman

    Alison Schofield
     
  • commit d1aaf20ee655888c227d5137b7a63551f8d15416 upstream.

    The suspend/resume functions were using dev_to_iio_dev() to get
    the iio_dev. That only works on IIO dev's. Use dev_get_drvdata()
    for a platform device to get the correct iio_dev.

    Signed-off-by: Alison Schofield
    Signed-off-by: Jonathan Cameron
    Signed-off-by: Greg Kroah-Hartman

    Alison Schofield
     
  • commit b17c1bba9cec1727451b906d9a0c209774624873 upstream.

    When tearingdown timesync, and not in arche platform, the state platform
    callback is not initialized. That will trigger the following NULL
    dereferencing.
    CallTrace:

    ? gb_timesync_platform_unlock_bus+0x11/0x20 [greybus]
    gb_timesync_teardown+0x85/0xc0 [greybus]
    gb_timesync_svc_remove+0xab/0x190 [greybus]
    gb_svc_del+0x29/0x110 [greybus]
    gb_hd_del+0x14/0x20 [greybus]
    ap_disconnect+0x24/0x60 [gb_es2]
    usb_unbind_interface+0x7a/0x2c0
    __device_release_driver+0x96/0x150
    device_release_driver+0x1e/0x30
    bus_remove_device+0xe7/0x130
    device_del+0x116/0x230
    usb_disable_device+0x97/0x1f0
    usb_disconnect+0x80/0x260
    hub_event+0x5ca/0x10e0
    process_one_work+0x126/0x3b0
    worker_thread+0x55/0x4c0
    ? process_one_work+0x3b0/0x3b0
    kthread+0xc4/0xe0
    ? kthread_park+0xb0/0xb0
    ret_from_fork+0x22/0x30

    So, fix that by adding checks before use the callback.

    Fixes: 970dc85bd95d ("greybus: timesync: Add timesync core driver")
    Signed-off-by: Rui Miguel Silva
    Reviewed-by: Viresh Kumar
    Reviewed-by: Johan Hovold
    Signed-off-by: Greg Kroah-Hartman

    Rui Miguel Silva
     
  • commit 5d03a2fd2292e71936c4235885c35ccc3c94695b upstream.

    Yet another laptop vendor rebranded Novatel E371.

    Signed-off-by: Bjørn Mork
    Signed-off-by: Johan Hovold
    Signed-off-by: Greg Kroah-Hartman

    Bjørn Mork
     
  • commit 83e526f2a2fa4b2e82b6bd3ddbb26b70acfa8947 upstream.

    OS descriptor head, when flagged as provided, is accessed without
    checking if it fits in provided buffer. Verify length before access.
    Also, there are other places where buffer length it checked
    after accessing offsets which are potentially past the end. Check
    buffer length before as well to fail cleanly.

    Signed-off-by: Vincent Pelletier
    Acked-by: Felipe Balbi
    Signed-off-by: Greg Kroah-Hartman

    Vincent Pelletier
     
  • commit 407788b51db6f6aab499d02420082f436abf3238 upstream.

    Commit 467d5c980709 ("usb: musb: Implement session bit based runtime PM for
    musb-core") started implementing musb generic runtime PM support by
    introducing devctl register session bit based state control.

    This caused a regression where if a USB mass storage device is connected
    to a USB hub, we can get:

    usb 1-1: reset high-speed USB device number 2 using musb-hdrc
    usb 1-1: device descriptor read/64, error -71
    usb 1-1.1: new high-speed USB device number 4 using musb-hdrc

    This is because before the USB storage device is connected, musb is
    in OTG_STATE_A_SUSPEND. And we currently only set need_finish_resume
    in musb_stage0_irq() and the related code calling finish_resume_work
    in musb_resume() and musb_runtime_resume() never gets called.

    To fix the issue, we can call schedule_delayed_work() directly in
    musb_stage0_irq() to have finish_resume_work run.

    And we should no longer never get interrupts when when suspended.
    We have changed musb to no longer need pm_runtime_irqsafe().
    The need_finish_resume flag was added in commit 9298b4aad37e ("usb:
    musb: fix device hotplug behind hub") and no longer applies as far
    as I can tell. So let's just remove the earlier code that no longer
    is needed.

    Fixes: 467d5c980709 ("usb: musb: Implement session bit based runtime PM for musb-core")
    Reported-by: Bin Liu
    Signed-off-by: Tony Lindgren
    Signed-off-by: Bin Liu
    Signed-off-by: Greg Kroah-Hartman

    Tony Lindgren
     
  • commit d9b2997e4a0a874e452df7cdd7de5a54502bd0aa upstream.

    Add a quirk for WORLDE easykey.25 MIDI keyboard (idVendor=0218,
    idProduct=0401). The device reports that it has config string
    descriptor at index 3, but when the system selects the configuration
    and tries to get the description, it returns a -EPROTO error,
    the communication restarts and this keeps repeating over and over again.
    Not requesting the string descriptor makes the device work correctly.

    Relevant info from Wireshark:

    [...]

    CONFIGURATION DESCRIPTOR
    bLength: 9
    bDescriptorType: 0x02 (CONFIGURATION)
    wTotalLength: 101
    bNumInterfaces: 2
    bConfigurationValue: 1
    iConfiguration: 3
    Configuration bmAttributes: 0xc0 SELF-POWERED NO REMOTE-WAKEUP
    1... .... = Must be 1: Must be 1 for USB 1.1 and higher
    .1.. .... = Self-Powered: This device is SELF-POWERED
    ..0. .... = Remote Wakeup: This device does NOT support remote wakeup
    bMaxPower: 50 (100mA)

    [...]

    45 0.369104 host 2.38.0 USB 64 GET DESCRIPTOR Request STRING

    [...]

    URB setup
    bmRequestType: 0x80
    1... .... = Direction: Device-to-host
    .00. .... = Type: Standard (0x00)
    ...0 0000 = Recipient: Device (0x00)
    bRequest: GET DESCRIPTOR (6)
    Descriptor Index: 0x03
    bDescriptorType: 0x03
    Language Id: English (United States) (0x0409)
    wLength: 255

    46 0.369255 2.38.0 host USB 64 GET DESCRIPTOR Response STRING[Malformed Packet]

    [...]

    Frame 46: 64 bytes on wire (512 bits), 64 bytes captured (512 bits) on interface 0
    USB URB
    [Source: 2.38.0]
    [Destination: host]
    URB id: 0xffff88021f62d480
    URB type: URB_COMPLETE ('C')
    URB transfer type: URB_CONTROL (0x02)
    Endpoint: 0x80, Direction: IN
    Device: 38
    URB bus id: 2
    Device setup request: not relevant ('-')
    Data: present (0)
    URB sec: 1484896277
    URB usec: 455031
    URB status: Protocol error (-EPROTO) (-71)
    URB length [bytes]: 0
    Data length [bytes]: 0
    [Request in: 45]
    [Time from request: 0.000151000 seconds]
    Unused Setup Header
    Interval: 0
    Start frame: 0
    Copy of Transfer Flags: 0x00000200
    Number of ISO descriptors: 0
    [Malformed Packet: USB]
    [Expert Info (Error/Malformed): Malformed Packet (Exception occurred)]
    [Malformed Packet (Exception occurred)]
    [Severity level: Error]
    [Group: Malformed]

    Signed-off-by: Lukáš Lalinský
    Signed-off-by: Greg Kroah-Hartman

    Lukáš Lalinský
     
  • commit d07830db1bdb254e4b50d366010b219286b8c937 upstream.

    Seems that ATEN serial-to-usb devices using pl2303 exist with
    different device ids. This patch adds a missing device ID so it
    is recognised by the driver.

    Signed-off-by: Marcel J.E. Mol
    Signed-off-by: Johan Hovold
    Signed-off-by: Greg Kroah-Hartman

    Marcel J.E. Mol
     
  • commit 24d615a694d649aa2e167c3f97f62bdad07e3f84 upstream.

    The Dell DW5570 is a re-branded Sierra Wireless MC8805 which will by
    default boot with vid 0x413c and pid 0x81a3. When triggered QDL download
    mode, the device switches to pid 0x81a6 and provides the standard TTY
    used for firmware upgrade.

    Signed-off-by: Aleksander Morgado
    Signed-off-by: Johan Hovold
    Signed-off-by: Greg Kroah-Hartman

    Aleksander Morgado
     
  • commit 00c87e9a70a17b355b81c36adedf05e84f54e10d upstream.

    Saving unsupported state prevents migration when the new host does not
    support a XSAVE feature of the original host, even if the feature is not
    exposed to the guest.

    We've masked host features with guest-visible features before, with
    4344ee981e21 ("KVM: x86: only copy XSAVE state for the supported
    features") and dropped it when implementing XSAVES. Do it again.

    Fixes: df1daba7d1cb ("KVM: x86: support XSAVES usage in the host")
    Reviewed-by: Paolo Bonzini
    Signed-off-by: Radim Krčmář
    Signed-off-by: Greg Kroah-Hartman

    Radim Krčmář
     
  • commit 362f4562466c3b9490e733e06999025638310d4a upstream.

    Commit fdea2d09b997 ("dmaengine: cppi41: Add basic PM runtime support")
    together with recent MUSB changes allowed USB and DMA on BeagleBone to idle
    when no cable is connected. But looks like few corner case issues still
    remain.

    Looks like just by re-plugging USB cable about ten or so times on BeagleBone
    when configured in USB peripheral mode we can get warnings and eventually
    trigger an oops in cppi41 DMA:

    WARNING: CPU: 0 PID: 14 at drivers/dma/cppi41.c:1154 cppi41_runtime_suspend+
    x28/0x38 [cppi41]
    ...

    WARNING: CPU: 0 PID: 14 at drivers/dma/cppi41.c:452
    push_desc_queue+0x94/0x9c [cppi41]
    ...

    Unable to handle kernel NULL pointer dereference at virtual
    address 00000104
    pgd = c0004000
    [00000104] *pgd=00000000
    Internal error: Oops: 805 [#1] SMP ARM
    ...
    [] (cppi41_runtime_resume [cppi41]) from []
    (__rpm_callback+0xc0/0x214)
    [] (__rpm_callback) from [] (rpm_callback+0x20/0x80)
    [] (rpm_callback) from [] (rpm_resume+0x504/0x78c)
    [] (rpm_resume) from [] (pm_runtime_work+0x60/0xa8)
    [] (pm_runtime_work) from [] (process_one_work+0x2b4/0x808)

    This is because of a race with runtime PM and cppi41_dma_issue_pending()
    as reported by Alexandre Bailon in earlier
    set of patches. Based on mailing list discussions we however came to the
    conclusion that a different fix from Alexandre's fix is needed in order
    to guarantee that DMA is really active when we try to use it.

    To fix the issue, we need to add a driver specific flag as we otherwise
    can have -EINPROGRESS state set by runtime PM and can't rely on
    pm_runtime_active() to tell us when we can use the DMA.

    And we need to make sure the DMA transfers get triggered in the queued
    order. So let's always queue the transfers, then flush the queue
    from both cppi41_dma_issue_pending() and cppi41_runtime_resume()
    as suggested by Grygorii Strashko in an
    earlier example patch.

    For reference, this is also documented in Documentation/power/runtime_pm.txt
    in the example at the end of the file as pointed out by Grygorii Strashko
    .

    Based on earlier patches from Alexandre Bailon
    and Grygorii Strashko modified based on
    testing and what was discussed on the mailing lists.

    Fixes: fdea2d09b997 ("dmaengine: cppi41: Add basic PM runtime support")
    Cc: Andy Shevchenko
    Cc: Bin Liu
    Cc: Grygorii Strashko
    Cc: Kevin Hilman
    Cc: Patrick Titiano
    Cc: Sergei Shtylyov
    Reported-by: Alexandre Bailon
    Signed-off-by: Tony Lindgren
    Tested-by: Bin Liu
    Signed-off-by: Vinod Koul
    Signed-off-by: Greg Kroah-Hartman

    Tony Lindgren
     
  • commit ae4a3e028bb8b59e7cfeb0cc9ef03d885182ce8b upstream.

    Commit fdea2d09b997 ("dmaengine: cppi41: Add basic PM runtime support")
    added runtime PM support for cppi41, but had corner case issues. Some of
    the issues were fixed with commit 098de42ad670 ("dmaengine: cppi41: Fix
    unpaired pm runtime when only a USB hub is connected"). That fix however
    caused a new regression where we can get error -115 messages with USB on
    BeagleBone when connecting a USB mass storage device to a hub.

    This is because when connecting a USB mass storage device to a hub, the
    initial DMA transfers can take over 200ms to complete and cppi41
    autosuspend delay times out.

    To fix the issue, we want to implement refcounting for chan_busy array
    that contains the active dma transfers. Increasing the autosuspend delay
    won't help as that the delay could be potentially seconds, and it's best
    to let the USB subsystem to deal with the timeouts on errors.

    The earlier attempt for runtime PM was buggy as the pm_runtime_get/put()
    calls could get unpaired easily as they did not follow the state of
    the chan_busy array as described in commit 098de42ad670 ("dmaengine:
    cppi41: Fix unpaired pm runtime when only a USB hub is connected".

    Let's fix the issue by adding pm_runtime_get() to where a new transfer
    is added to the chan_busy array, and calls to pm_runtime_put() where
    chan_busy array entry is cleared. This prevents any autosuspend timeouts
    from happening while dma transfers are active.

    Fixes: 098de42ad670 ("dmaengine: cppi41: Fix unpaired pm runtime when
    only a USB hub is connected")
    Fixes: fdea2d09b997 ("dmaengine: cppi41: Add basic PM runtime support")
    Cc: Andy Shevchenko
    Cc: Bin Liu
    Cc: Grygorii Strashko
    Cc: Kevin Hilman
    Cc: Patrick Titiano
    Cc: Sergei Shtylyov
    Signed-off-by: Tony Lindgren
    Tested-by: Bin Liu
    Signed-off-by: Vinod Koul
    Signed-off-by: Greg Kroah-Hartman

    Tony Lindgren
     
  • commit 1aa6cfd33df492939b0be15ebdbcff1f8ae5ddb6 upstream.

    The recent conversion to the hotplug state machine kept two mechanisms from
    the original code:

    1) The first_init logic which adds the number of online CPUs in a package
    to the refcount. That's wrong because the callbacks are executed for
    all online CPUs.

    Remove it so the refcounting is correct.

    2) The on_each_cpu() call to undo box->init() in the error handling
    path. That's bogus because when the prepare callback fails no box has
    been initialized yet.

    Remove it.

    Signed-off-by: Thomas Gleixner
    Cc: Alexander Shishkin
    Cc: Arnaldo Carvalho de Melo
    Cc: Jiri Olsa
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Sebastian Siewior
    Cc: Stephane Eranian
    Cc: Vince Weaver
    Cc: Yasuaki Ishimatsu
    Fixes: 1a246b9f58c6 ("perf/x86/intel/uncore: Convert to hotplug state machine")
    Link: http://lkml.kernel.org/r/20170131230141.298032324@linutronix.de
    Signed-off-by: Ingo Molnar
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     
  • commit 282e4637bc1c0b338708bcebd09d31c69abec070 upstream.

    Commit 025bcc1 performed cleanup work on the 'wacom_pl_irq' function, making
    it follow the standards used in the rest of the codebase. The change
    unintiontionally allowed the function to send input events from reports
    that are not marked as being in prox. This can cause problems as the
    report values for X, Y, etc. are not guaranteed to be correct. In
    particular, occasionally the tablet will send a report with these values
    set to zero. If such a report is received it can caus an unexpected jump
    in the XY position.

    This patch surrounds more of the processing code with a proximity check,
    preventing these zeroed reports from overwriting the current state. To
    be safe, only the tool type and ABS_MISC events should be reported when
    the pen is marked as being out of prox.

    Fixes: 025bcc1540 ("HID: wacom: Simplify 'wacom_pl_irq'")
    Signed-off-by: Jason Gerecke
    Reviewed-by: Ping Cheng
    Signed-off-by: Jiri Kosina
    Signed-off-by: Greg Kroah-Hartman

    Jason Gerecke
     
  • commit 877a021e08ccb6434718c0cc781fdf943c884cc0 upstream.

    With NOGET quirk Logitech F510 is now fully workable in dinput mode including
    rumble effects (according to fftest).

    Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=117091

    [jkosina@suse.cz: fix patch format]
    Signed-off-by: Ardinartsev Nikita
    Acked-by: Benjamin Tissoires
    Signed-off-by: Jiri Kosina
    Signed-off-by: Greg Kroah-Hartman

    Ardinartsev Nikita
     
  • commit ed9ab4287f96e66340e0390e2c583f2f9110cba0 upstream.

    Quirking the following AMI USB device with ALWAYS_POLL fixes an AMI
    virtual keyboard and mouse from not responding and timing out when
    it is attached to a ppc64el Power 8 system and when we have some
    rapid open/closes on the mouse device.

    usb 1-3: new high-speed USB device number 2 using xhci_hcd
    usb 1-3: New USB device found, idVendor=046b, idProduct=ff01
    usb 1-3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
    usb 1-3: Product: Virtual Hub
    usb 1-3: Manufacturer: American Megatrends Inc.
    usb 1-3: SerialNumber: serial
    usb 1-3.3: new high-speed USB device number 3 using xhci_hcd
    usb 1-3.3: New USB device found, idVendor=046b, idProduct=ff31
    usb 1-3.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
    usb 1-3.3: Product: Virtual HardDisk Device
    usb 1-3.3: Manufacturer: American Megatrends Inc.
    usb 1-3.4: new low-speed USB device number 4 using xhci_hcd
    usb 1-3.4: New USB device found, idVendor=046b, idProduct=ff10
    usb 1-3.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
    usb 1-3.4: Product: Virtual Keyboard and Mouse
    usb 1-3.4: Manufacturer: American Megatrends Inc.

    With the quirk I have not been able to trigger the issue with
    half an hour of saturation soak testing.

    Signed-off-by: Colin Ian King
    Signed-off-by: Jiri Kosina
    Signed-off-by: Greg Kroah-Hartman

    Colin Ian King
     
  • commit 03c902bff524e0cf664737a33f2365f7837040bf upstream.

    When the firmware restarts in a situation in which any station
    has no queue reserved anymore because that queue was used, the
    code will crash trying to access the queue_info array at the
    offset 255, which is far too big. Fix this by checking that a
    queue is actually reserved before writing its status.

    Fixes: 8d98ae6eb0d5 ("iwlwifi: mvm: re-assign old queues after hw restart in dqa mode")
    Signed-off-by: Johannes Berg
    Signed-off-by: Luca Coelho
    Signed-off-by: Greg Kroah-Hartman

    Johannes Berg
     
  • commit 7941c59e45f3b6d30e07375e9b6713427e0a9f98 upstream.

    Mistakenly, the driver is trying to load the 8000C firmware with an
    incorrect name (i.e. with two hyphens where there should be only one)
    and that fails. Fix that by removing the hyphen from the format
    macro.

    Fixes: e1ba684f762b ("iwlwifi: 8000: fix MODULE_FIRMWARE input")
    Signed-off-by: Jürg Billeter
    Signed-off-by: Luca Coelho
    Signed-off-by: Greg Kroah-Hartman

    Jürg Billeter
     
  • commit 19b26d92dfb70f56440c187a20c49102ab648b97 upstream.

    Not every pin can be configured. Add missed check to prevent access
    violation.

    Fixes: 4e80c8f50574 ("pinctrl: intel: Add Intel Merrifield pin controller support")
    Acked-by: Mika Westerberg
    Signed-off-by: Andy Shevchenko
    Signed-off-by: Linus Walleij
    Signed-off-by: Greg Kroah-Hartman

    Andy Shevchenko
     
  • commit 1b89970d81bbd52720fc64a3fe9572ee33588363 upstream.

    Debounce value is set globally per community. Otherwise user will easily
    get a kernel crash when they start using the feature:

    BUG: unable to handle kernel paging request at ffffc900003be000
    IP: byt_gpio_dbg_show+0xa9/0x430

    Make it clear in byt_gpio_reg().

    Note that this fix just prevents kernel to crash, but doesn't make any
    difference to the existing logic. It means the last caller will win the
    trade and debounce value will be configured accordingly. The actual
    logic fix needs to be thought about and it's not as important as crash
    fix. That's why the latter goes separately and right now.

    Fixes: 658b476c742f ("pinctrl: baytrail: Add debounce configuration")
    Cc: Cristina Ciocan
    Signed-off-by: Andy Shevchenko
    Reviewed-by: Jean Delvare
    Acked-by: Mika Westerberg
    Signed-off-by: Linus Walleij
    Signed-off-by: Greg Kroah-Hartman

    Andy Shevchenko
     
  • commit 0d5415b489f68b58e1983a53793d25d53098ed4b upstream.

    This reverts commit c7070619f3408d9a0dffbed9149e6f00479cf43b.

    This has been shown to regress on some ARM systems:

    by forcing on DMA API usage for ARM systems, we have inadvertently
    kicked open a hornets' nest in terms of cache-coherency. Namely that
    unless the virtio device is explicitly described as capable of coherent
    DMA by firmware, the DMA APIs on ARM and other DT-based platforms will
    assume it is non-coherent. This turns out to cause a big problem for the
    likes of QEMU and kvmtool, which generate virtio-mmio devices in their
    guest DTs but neglect to add the often-overlooked "dma-coherent"
    property; as a result, we end up with the guest making non-cacheable
    accesses to the vring, the host doing so cacheably, both talking past
    each other and things going horribly wrong.

    We are working on a safer work-around.

    Fixes: c7070619f340 ("vring: Force use of DMA API for ARM-based systems with legacy devices")
    Reported-by: Robin Murphy
    Signed-off-by: Will Deacon
    Signed-off-by: Michael S. Tsirkin
    Acked-by: Marc Zyngier
    Signed-off-by: Greg Kroah-Hartman

    Michael S. Tsirkin
     
  • commit 7195439d1d71bc4a6c33cfb57bc669a7cd041041 upstream.

    This reverts commit 4c81acab3816 ("bcma: init serial console directly
    from ChipCommon code") as it broke IRQ assignment. Getting IRQ with
    bcma_core_irq helper on SoC requires MIPS core to be set. It happens
    *after* ChipCommon initialization so we can't do this so early.

    This fixes a user reported regression. It wasn't critical as serial was
    still somehow working but lack of IRQs was making in unreliable.

    Fixes: 4c81acab3816 ("bcma: init serial console directly from ChipCommon code")
    Reported-by: Felix Fietkau
    Signed-off-by: Rafał Miłecki
    Signed-off-by: Kalle Valo
    Signed-off-by: Greg Kroah-Hartman

    Rafał Miłecki
     
  • commit 966d2b04e070bc040319aaebfec09e0144dc3341 upstream.

    percpu_ref_tryget() and percpu_ref_tryget_live() should return
    "true" IFF they acquire a reference. But the return value from
    atomic_long_inc_not_zero() is a long and may have high bits set,
    e.g. PERCPU_COUNT_BIAS, and the return value of the tryget routines
    is bool so the reference may actually be acquired but the routines
    return "false" which results in a reference leak since the caller
    assumes it does not need to do a corresponding percpu_ref_put().

    This was seen when performing CPU hotplug during I/O, as hangs in
    blk_mq_freeze_queue_wait where percpu_ref_kill (blk_mq_freeze_queue_start)
    raced with percpu_ref_tryget (blk_mq_timeout_work).
    Sample stack trace:

    __switch_to+0x2c0/0x450
    __schedule+0x2f8/0x970
    schedule+0x48/0xc0
    blk_mq_freeze_queue_wait+0x94/0x120
    blk_mq_queue_reinit_work+0xb8/0x180
    blk_mq_queue_reinit_prepare+0x84/0xa0
    cpuhp_invoke_callback+0x17c/0x600
    cpuhp_up_callbacks+0x58/0x150
    _cpu_up+0xf0/0x1c0
    do_cpu_up+0x120/0x150
    cpu_subsys_online+0x64/0xe0
    device_online+0xb4/0x120
    online_store+0xb4/0xc0
    dev_attr_store+0x68/0xa0
    sysfs_kf_write+0x80/0xb0
    kernfs_fop_write+0x17c/0x250
    __vfs_write+0x6c/0x1e0
    vfs_write+0xd0/0x270
    SyS_write+0x6c/0x110
    system_call+0x38/0xe0

    Examination of the queue showed a single reference (no PERCPU_COUNT_BIAS,
    and __PERCPU_REF_DEAD, __PERCPU_REF_ATOMIC set) and no requests.
    However, conditions at the time of the race are count of PERCPU_COUNT_BIAS + 0
    and __PERCPU_REF_DEAD and __PERCPU_REF_ATOMIC set.

    The fix is to make the tryget routines use an actual boolean internally instead
    of the atomic long result truncated to a int.

    Fixes: e625305b3907 percpu-refcount: make percpu_ref based on longs instead of ints
    Link: https://bugzilla.kernel.org/show_bug.cgi?id=190751
    Signed-off-by: Douglas Miller
    Reviewed-by: Jens Axboe
    Signed-off-by: Tejun Heo
    Fixes: e625305b3907 ("percpu-refcount: make percpu_ref based on longs instead of ints")
    Signed-off-by: Greg Kroah-Hartman

    Douglas Miller
     
  • commit d0e287a401d9acf67b75180b26e2d62b7d482652 upstream.

    A typo or copy-paste bug means that the register access intended for
    regulator dcdce goes to dcdcb instead. This patch corrects it.

    Fixes: 2ca342d391e3 (regulator: axp20x: Support AXP806 variant)
    Signed-off-by: Rask Ingemann Lambertsen
    Acked-by: Chen-Yu Tsai
    Signed-off-by: Mark Brown
    Signed-off-by: Greg Kroah-Hartman

    Rask Ingemann Lambertsen
     
  • commit cda8bba0f99d25d2061c531113c14fa41effc3ae upstream.

    Currently, under certain circumstances vhost_init_is_le does just a part
    of the initialization job, and depends on vhost_reset_is_le being called
    too. For this reason vhost_vq_init_access used to call vhost_reset_is_le
    when vq->private_data is NULL. This is not only counter intuitive, but
    also real a problem because it breaks vhost_net. The bug was introduced to
    vhost_net with commit 2751c9882b94 ("vhost: cross-endian support for
    legacy devices"). The symptom is corruption of the vq's used.idx field
    (virtio) after VHOST_NET_SET_BACKEND was issued as a part of the vhost
    shutdown on a vq with pending descriptors.

    Let us make sure the outcome of vhost_init_is_le never depend on the state
    it is actually supposed to initialize, and fix virtio_net by removing the
    reset from vhost_vq_init_access.

    With the above, there is no reason for vhost_reset_is_le to do just half
    of the job. Let us make vhost_reset_is_le reinitialize is_le.

    Signed-off-by: Halil Pasic
    Reported-by: Michael A. Tebolt
    Reported-by: Dr. David Alan Gilbert
    Fixes: commit 2751c9882b94 ("vhost: cross-endian support for legacy devices")
    Signed-off-by: Michael S. Tsirkin
    Reviewed-by: Greg Kurz
    Tested-by: Michael A. Tebolt
    Signed-off-by: Greg Kroah-Hartman

    Halil Pasic