linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 4.9 000/206] 4.9.3-stable review
@ 2017-01-10 13:34 ` Greg Kroah-Hartman
  2017-01-10 13:34   ` [PATCH 4.9 001/206] iio: common: st_sensors: fix channel data parsing Greg Kroah-Hartman
                     ` (189 more replies)
  0 siblings, 190 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:34 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, torvalds, akpm, linux, shuah.kh, patches,
	ben.hutchings, stable

This is the start of the stable review cycle for the 4.9.3 release.
There are 206 patches in this series, all will be posted as a response
to this one.  If anyone has any issues with these being applied, please
let me know.

Responses should be made by Thu Jan 12 13:14:24 UTC 2017.
Anything received after that time might be too late.

The whole patch series can be found in one patch at:
	kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.9.3-rc1.gz
or in the git tree and branch at:
  git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.9.y
and the diffstat can be found below.

thanks,

greg k-h

-------------
Pseudo-Shortlog of commits:

Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Linux 4.9.3-rc1

Thomas Gleixner <tglx@linutronix.de>
    tick/broadcast: Prevent NULL pointer dereference

Thomas Gleixner <tglx@linutronix.de>
    clocksource/dummy_timer: Move hotplug callback after the real timers

Carlos Maiolino <cmaiolino@redhat.com>
    xfs: fix max_retries _show and _store functions

Christoph Hellwig <hch@lst.de>
    xfs: fix crash and data corruption due to removal of busy COW extents

Darrick J. Wong <darrick.wong@oracle.com>
    xfs: use the actual AG length when reserving blocks

Darrick J. Wong <darrick.wong@oracle.com>
    xfs: fix double-cleanup when CUI recovery fails

Darrick J. Wong <darrick.wong@oracle.com>
    xfs: use GPF_NOFS when allocating btree cursors

Eric Sandeen <sandeen@redhat.com>
    xfs: ignore leaf attr ichdr.count in verifier during log replay

Darrick J. Wong <darrick.wong@oracle.com>
    xfs: don't cap maximum dedupe request length

Darrick J. Wong <darrick.wong@oracle.com>
    xfs: don't allow di_size with high bit set

Darrick J. Wong <darrick.wong@oracle.com>
    xfs: error out if trying to add attrs and anextents > 0

Darrick J. Wong <darrick.wong@oracle.com>
    xfs: don't crash if reading a directory results in an unexpected hole

Darrick J. Wong <darrick.wong@oracle.com>
    xfs: complain if we don't get nextents bmap records

Darrick J. Wong <darrick.wong@oracle.com>
    xfs: check for bogus values in btree block headers

Darrick J. Wong <darrick.wong@oracle.com>
    xfs: forbid AG btrees with level == 0

Eric Sandeen <sandeen@sandeen.net>
    xfs: handle cow fork in xfs_bmap_trace_exlist

Eric Sandeen <sandeen@sandeen.net>
    xfs: pass state not whichfork to trace_xfs_extlist

Eric Sandeen <sandeen@sandeen.net>
    xfs: Move AGI buffer type setting to xfs_read_agi

Brian Foster <bfoster@redhat.com>
    xfs: pass post-eof speculative prealloc blocks to bmapi

Christoph Hellwig <hch@lst.de>
    xfs: use new extent lookup helpers xfs_file_iomap_begin_delay

Brian Foster <bfoster@redhat.com>
    xfs: clean up cow fork reservation and tag inodes correctly

Christoph Hellwig <hch@lst.de>
    xfs: use new extent lookup helpers in __xfs_reflink_reserve_cow

Brian Foster <bfoster@redhat.com>
    xfs: track preallocation separately in xfs_bmapi_reserve_delalloc()

Christoph Hellwig <hch@lst.de>
    xfs: remove prev argument to xfs_bmapi_reserve_delalloc

Darrick J. Wong <darrick.wong@oracle.com>
    xfs: always succeed when deduping zero bytes

Darrick J. Wong <darrick.wong@oracle.com>
    xfs: factor rmap btree size into the indlen calculations

Christoph Hellwig <hch@lst.de>
    xfs: new inode extent list lookup helpers

Brian Foster <bfoster@redhat.com>
    xfs: fix unbalanced inode reclaim flush locking

Darrick J. Wong <darrick.wong@oracle.com>
    xfs: check minimum block size for CRC filesystems

Eric Sandeen <sandeen@sandeen.net>
    xfs: provide helper for counting extents from if_bytes

Brian Foster <bfoster@redhat.com>
    xfs: don't BUG() on mixed direct and mapped I/O

Brian Foster <bfoster@redhat.com>
    xfs: don't skip cow forks w/ delalloc blocks in cowblocks scan

Darrick J. Wong <darrick.wong@oracle.com>
    xfs: check return value of _trans_reserve_quota_nblks

Eric Sandeen <sandeen@redhat.com>
    xfs: don't call xfs_sb_quota_from_disk twice

Josh Zimmerman <joshz@google.com>
    tpm_tis: Check return values from get_burstcount.

Paulo Zanoni <paulo.r.zanoni@intel.com>
    drm/i915/gen9: fix the WM memory bandwidth WA for Y tiling cases

Paulo Zanoni <paulo.r.zanoni@intel.com>
    drm/i915/gen9: unconditionally apply the memory bandwidth WA

Paulo Zanoni <paulo.r.zanoni@intel.com>
    drm/i915: disable PSR by default on HSW/BDW

Michel Dänzer <michel.daenzer@amd.com>
    drm/radeon: Always store CRTC relative radeon_crtc->cursor_x/y values

Sebastian Ott <sebott@linux.vnet.ibm.com>
    s390/pci: fix dma address calculation in map_sg

Heiko Carstens <heiko.carstens@de.ibm.com>
    s390/topology: always use s390 specific sched_domain_topology_level

Johan Hovold <johan@kernel.org>
    powerpc/pci/rpadlpar: Fix device reference leaks

Alexey Kardashevskiy <aik@ozlabs.ru>
    PCI: Enable access to non-standard VPD for Chelsio devices (cxgb3)

Noa Osherovich <noaos@mellanox.com>
    PCI: Support INTx masking on ConnectX-4 with firmware x.14.1100+

Noa Osherovich <noaos@mellanox.com>
    PCI: Convert Mellanox broken INTx quirks to be for listed devices only

Noa Osherovich <noaos@mellanox.com>
    PCI: Convert broken INTx masking quirks from HEADER to FINAL

Noa Osherovich <noaos@mellanox.com>
    PCI: Add Mellanox device IDs

Brian Norris <briannorris@chromium.org>
    PCI: rockchip: Correct the use of FTS mask

Shawn Lin <shawn.lin@rock-chips.com>
    PCI: rockchip: Fix negotiated lanes calculation

Dan Carpenter <dan.carpenter@oracle.com>
    staging: media: davinci_vpfe: unlock on error in vpfe_reqbufs()

Arnd Bergmann <arnd@arndb.de>
    f2fs: hide a maybe-uninitialized warning

Jaegeuk Kim <jaegeuk@kernel.org>
    f2fs: remove percpu_count due to performance regression

NeilBrown <neilb@suse.com>
    md: fix refcount problem on mddev when stopping array.

Shaohua Li <shli@fb.com>
    md: MD_RECOVERY_NEEDED is set for mddev->recovery

Ard Biesheuvel <ard.biesheuvel@linaro.org>
    crypto: arm64/aes-ce - fix for big endian

Ard Biesheuvel <ard.biesheuvel@linaro.org>
    crypto: arm64/aes-xts-ce: fix for big endian

Ard Biesheuvel <ard.biesheuvel@linaro.org>
    crypto: arm64/sha1-ce - fix for big endian

Ard Biesheuvel <ard.biesheuvel@linaro.org>
    crypto: arm64/aes-neon - fix for big endian

Ard Biesheuvel <ard.biesheuvel@linaro.org>
    crypto: arm64/aes-ccm-ce: fix for big endian

Ard Biesheuvel <ard.biesheuvel@linaro.org>
    crypto: arm/aes-ce - fix for big endian

Ard Biesheuvel <ard.biesheuvel@linaro.org>
    crypto: arm64/ghash-ce - fix for big endian

Ard Biesheuvel <ard.biesheuvel@linaro.org>
    crypto: arm64/sha2-ce - fix for big endian

Dan Carpenter <dan.carpenter@oracle.com>
    s390/crypto: unlock on error in prng_tdes_read()

Ming Ling <ming.ling@spreadtrum.com>
    mm, compaction: fix NR_ISOLATED_* stats for pfn based migration

Johannes Weiner <hannes@cmpxchg.org>
    mm: khugepaged: fix radix tree node leak in shmem collapse error path

Johannes Weiner <hannes@cmpxchg.org>
    mm: khugepaged: close use-after-free race during shmem collapsing

Mauro Carvalho Chehab <mchehab@kernel.org>
    docs-rst: fix LaTeX \DURole renewcommand with Sphinx 1.3+

Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
    mm/hugetlb.c: use the right pte val for compare in hugetlb_cow

Bjorn Andersson <bjorn.andersson@linaro.org>
    rpmsg: qcom_smd: Correct return value for O_NONBLOCK

Dan Carpenter <dan.carpenter@oracle.com>
    mmc: mmc_test: Uninitialized return value

Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>
    genirq/affinity: Fix node generation from cpumask

Tony Lindgren <tony@atomide.com>
    PM / wakeirq: Fix dedicated wakeirq for drivers not using autosuspend

Florian Fainelli <f.fainelli@gmail.com>
    irqchip/bcm7038-l1: Implement irq_cpu_offline() callback

Jan Beulich <JBeulich@suse.com>
    PCI/MSI: Check for NULL affinity mask in pci_irq_get_affinity()

Eric Richter <erichte@linux.vnet.ibm.com>
    ima: fix memory leak in ima_release_policy

Dan Carpenter <dan.carpenter@oracle.com>
    relay: check array offset before using it

Bart Van Assche <bart.vanassche@sandisk.com>
    sbp-target: Fix second argument of percpu_ida_alloc()

Dan Carpenter <dan.carpenter@oracle.com>
    target/iscsi: Fix double free in lio_target_tiqn_addtpg()

Arnd Bergmann <arnd@arndb.de>
    scsi: mvsas: fix command_active typo

Ondrej Zary <linux@rainbow-software.org>
    scsi: g_NCR5380: Fix release_region in error handling

Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
    ASoC: samsung: i2s: Fixup last IRQ unsafe spin lock call

Dan Carpenter <dan.carpenter@oracle.com>
    ASoC: Intel: Skylake: Fix a shift wrapping bug

Takashi Iwai <tiwai@suse.de>
    ASoC: cht_bsw_rt5645: Fix leftover kmalloc

Arnd Bergmann <arnd@arndb.de>
    ASoC: lpass-platform: initialize dma channel number

Xunlei Pang <xlpang@redhat.com>
    iommu/vt-d: Flush old iommu caches for kdump when the device gets context mapped

Jacob Pan <jacob.jun.pan@linux.intel.com>
    iommu/vt-d: Fix pasid table size encoding

Huang Rui <ray.huang@amd.com>
    iommu/amd: Fix the left value check of cmd buffer

Dan Carpenter <dan.carpenter@oracle.com>
    iommu/amd: Missing error code in amd_iommu_init_device()

Chris Brandt <chris.brandt@renesas.com>
    clk: renesas: mstp: Support 8-bit registers for r7s72100

Vladimir Zapolskiy <vz@mleia.com>
    clk: imx31: fix rewritten input argument of mx31_clocks_init()

Chen-Yu Tsai <wens@csie.org>
    clk: sunxi-ng: sun8i-h3: Set CLK_SET_RATE_PARENT for audio module clocks

Chen-Yu Tsai <wens@csie.org>
    clk: sunxi-ng: sun8i-a23: Set CLK_SET_RATE_PARENT for audio module clocks

Grygorii Strashko <grygorii.strashko@ti.com>
    clk: ti: dra7: fix "failed to lookup clock node gmac_gmii_ref_clk_div" boot message

Pan Bian <bianpan2016@163.com>
    clk: clk-wm831x: fix a logic error

Stephen Boyd <sboyd@codeaurora.org>
    clk: qcom: ipq806x: Fix board clk rates

Dan Carpenter <dan.carpenter@oracle.com>
    Input: synaptics-rmi4 - unlock on error

Michael Walle <michael@walle.cc>
    hwmon: (lm90) fix temp1_max_alarm attribute

Guenter Roeck <linux@roeck-us.net>
    hwmon: (g762) Fix overflows and crash seen when writing limit attributes

Guenter Roeck <linux@roeck-us.net>
    hwmon: (nct7802) Fix overflows seen when writing into limit attributes

Guenter Roeck <linux@roeck-us.net>
    hwmon: (ds620) Fix overflows seen when writing temperature limits

Jared Bents <jared.bents@rockwellcollins.com>
    hwmon: (amc6821) sign extension temperature

Javier Martinez Canillas <javier@osg.samsung.com>
    hwmon: (scpi) Fix module autoload

Micha? K?pie? <kernel@kempniu.pl>
    platform/x86: fujitsu-laptop: use brightness_set_blocking for LED-setting callbacks

Andy Lutomirski <luto@kernel.org>
    x86/cpu: Probe CPUID leaf 6 even when cpuid_level == 6

Dmitry Safonov <dsafonov@virtuozzo.com>
    x86/prctl/uapi: Remove #ifdef for CHECKPOINT_RESTORE

Arnd Bergmann <arnd@arndb.de>
    debugfs: improve DEFINE_DEBUGFS_ATTRIBUTE for !CONFIG_DEBUG_FS

Geert Uytterhoeven <geert+renesas@glider.be>
    clk: renesas: cpg-mssr: Fix inverted debug check

Dan Carpenter <dan.carpenter@oracle.com>
    efi/efivar_ssdt_load: Don't return success on allocation failure

Guenter Roeck <linux@roeck-us.net>
    cris: Only build flash rescue image if CONFIG_ETRAX_AXISFLASHMAP is selected

Nicolas Iooss <nicolas.iooss_linux@m4x.org>
    ath10k: use the right length of "background"

Milo Kim <woogyom.kim@gmail.com>
    mfd: tps65217: Fix page fault on unloading modules

Mohammed Shafi Shajakhan <mohammed@qti.qualcomm.com>
    ath10k: fix failure to send NULL func frame for 10.4

Vamsi Krishna <vamsin@qti.qualcomm.com>
    nl80211: Use different attrs for BSSID and random MAC addr in scan req

Johannes Berg <johannes.berg@intel.com>
    mac80211: fix tid_agg_rx NULL dereference

Daniel Vetter <daniel.vetter@ffwll.ch>
    drm/i915: tune down the fast link training vs boot fail

Matthew Auld <matthew.auld@intel.com>
    drm/i915/dp: add lane_count check in intel_dp_check_link_status

Felipe Balbi <felipe.balbi@linux.intel.com>
    usb: dwc3: gadget: always unmap EP0 requests

Felipe Balbi <felipe.balbi@linux.intel.com>
    usb: dwc3: ep0: explicitly call dwc3_ep0_prepare_one_trb()

Felipe Balbi <felipe.balbi@linux.intel.com>
    usb: dwc3: ep0: add dwc3_ep0_prepare_one_trb()

Linus Walleij <linus.walleij@linaro.org>
    iio: accel: st_accel: fix LIS3LV02 reading and scaling

Eva Rachel Retuya <eraretuya@gmail.com>
    staging: iio: ad7606: fix improper setting of oversampling pins

Alexander Usyskin <alexander.usyskin@intel.com>
    mei: move write cb to completion on credentials failures

Alexander Usyskin <alexander.usyskin@intel.com>
    mei: bus: fix mei_cldev_enable KDoc

Alexander Usyskin <alexander.usyskin@intel.com>
    mei: fix parameter rename KDoc

Johan Hovold <johan@kernel.org>
    USB: serial: io_ti: bind to interface after fw download

Wei Yongjun <weiyongjun1@huawei.com>
    dibusb: fix possible memory leak in dibusb_rc_query()

Chen-Yu Tsai <wens@csie.org>
    ARM: dts: sun7i: bananapi-m1-plus: Enable USB PHY for USB host support

Kefeng Wang <wangkefeng.wang@huawei.com>
    arm64: dts: hip06: Correct hardware pin number of usb node

Johan Hovold <johan@kernel.org>
    USB: phy: am335x-control: fix device and of_node leaks

Geert Uytterhoeven <geert+renesas@glider.be>
    ARM: dts: r8a7794: Correct hsusb parent clock

Peter Chen <peter.chen@nxp.com>
    usb: gadget: fix request length error for isoc transfer

Bart Van Assche <bart.vanassche@sandisk.com>
    usb: gadget: Fix second argument of percpu_ida_alloc()

Pan Bian <bianpan2016@163.com>
    USB: serial: kl5kusb105: abort on open exception path

Takashi Iwai <tiwai@suse.de>
    ALSA: usb-audio: Fix bogus error return in snd_usb_create_stream()

Jérémy Lefaure <jeremy.lefaure@lse.epita.fr>
    usb: musb: blackfin: add bfin_fifo_offset in bfin_ops

Felix Hädicke <felixhaedicke@web.de>
    usb: gadget: udc: core: fix return code of usb_gadget_probe_driver()

Geert Uytterhoeven <geert@linux-m68k.org>
    usb: hub: Move hub_port_disable() to fix warning if PM is disabled

Tony Lindgren <tony@atomide.com>
    usb: musb: Fix trying to free already-free IRQ 4

Roger Quadros <rogerq@ti.com>
    usb: dwc3: gadget: Fix full speed mode

Hans de Goede <hdegoede@redhat.com>
    usb: dwc3: pci: Fix dr_mode misspelling

Heikki Krogerus <heikki.krogerus@linux.intel.com>
    usb: dwc3: pci: add Intel Gemini Lake PCI ID

OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
    xhci: Fix race related to abort operation

OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
    xhci: Use delayed_work instead of timer for command timeout

Dan Carpenter <dan.carpenter@oracle.com>
    usb: xhci-mem: use passed in GFP flags instead of GFP_KERNEL

Johan Hovold <johan@kernel.org>
    USB: serial: mos7720: fix parallel probe

Johan Hovold <johan@kernel.org>
    USB: serial: mos7720: fix parport use-after-free on probe errors

Johan Hovold <johan@kernel.org>
    USB: serial: mos7720: fix use-after-free on probe errors

Johan Hovold <johan@kernel.org>
    USB: serial: mos7720: fix NULL-deref at open

Johan Hovold <johan@kernel.org>
    USB: serial: mos7840: fix NULL-deref at open

Johan Hovold <johan@kernel.org>
    USB: serial: kobil_sct: fix NULL-deref in write

Johan Hovold <johan@kernel.org>
    USB: serial: cyberjack: fix NULL-deref at open

Johan Hovold <johan@kernel.org>
    USB: serial: oti6858: fix NULL-deref at open

Johan Hovold <johan@kernel.org>
    USB: serial: io_edgeport: fix NULL-deref at open

Johan Hovold <johan@kernel.org>
    USB: serial: ti_usb_3410_5052: fix NULL-deref at open

Johan Hovold <johan@kernel.org>
    USB: serial: garmin_gps: fix memory leak on failed URB submit

Johan Hovold <johan@kernel.org>
    USB: serial: iuu_phoenix: fix NULL-deref at open

Johan Hovold <johan@kernel.org>
    USB: serial: io_ti: fix I/O after disconnect

Johan Hovold <johan@kernel.org>
    USB: serial: io_ti: fix another NULL-deref at open

Johan Hovold <johan@kernel.org>
    USB: serial: io_ti: fix NULL-deref at open

Johan Hovold <johan@kernel.org>
    USB: serial: spcp8x5: fix NULL-deref at open

Johan Hovold <johan@kernel.org>
    USB: serial: keyspan_pda: verify endpoints at probe

Johan Hovold <johan@kernel.org>
    USB: serial: pl2303: fix NULL-deref at open

Johan Hovold <johan@kernel.org>
    USB: serial: quatech2: fix sleep-while-atomic in close

Johan Hovold <johan@kernel.org>
    USB: serial: omninet: fix NULL-derefs at open and disconnect

Pan Bian <bianpan2016@163.com>
    usb: return error code when platform_get_irq fails

Lu Baolu <baolu.lu@linux.intel.com>
    usb: xhci: hold lock over xhci_abort_cmd_ring()

Mathias Nyman <mathias.nyman@linux.intel.com>
    xhci: Handle command completion and timeout race

Baolin Wang <baolin.wang@linaro.org>
    usb: host: xhci: Fix possible wild pointer when handling abort command

Lu Baolu <baolu.lu@linux.intel.com>
    usb: xhci: fix return value of xhci_setup_device()

Mathias Nyman <mathias.nyman@linux.intel.com>
    xhci: free xhci virtual devices with leaf nodes first

Wan Ahmad Zainie <wan.ahmad.zainie.wan.mohamad@intel.com>
    usb: xhci: apply XHCI_PME_STUCK_QUIRK to Intel Apollo Lake

Lu Baolu <baolu.lu@linux.intel.com>
    usb: xhci: fix possible wild pointer

Felipe Balbi <felipe.balbi@linux.intel.com>
    usb: dwc3: core: avoid Overflow events

Krzysztof Opasiak <k.opasiak@samsung.com>
    usb: gadget: composite: Test get_alt() presence instead of set_alt()

Alan Stern <stern@rowland.harvard.edu>
    USB: dummy-hcd: fix bug in stop_activity (handle ep0)

Alan Stern <stern@rowland.harvard.edu>
    USB: fix problems with duplicate endpoint addresses

Alan Stern <stern@rowland.harvard.edu>
    USB: gadgetfs: fix checks of wTotalLength in config descriptors

Alan Stern <stern@rowland.harvard.edu>
    USB: gadgetfs: fix use-after-free bug

Alan Stern <stern@rowland.harvard.edu>
    USB: gadgetfs: fix unbounded memory allocation bug

Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    usb: gadgetfs: restrict upper bound on device configuration size

Oliver Neukum <oneukum@suse.com>
    usb: storage: unusual_uas: Add JMicron JMS56x to unusual device

Bin Liu <b-liu@ti.com>
    usb: musb: dsps: implement clear_ep_rxintr() callback

Bin Liu <b-liu@ti.com>
    usb: musb: core: add clear_ep_rxintr() to musb_platform_ops

James Hogan <james.hogan@imgtec.com>
    KVM: MIPS: Flush KVM entry code from icache globally

James Hogan <james.hogan@imgtec.com>
    KVM: MIPS: Don't clobber CP0_Status.UX

Xiao Guangrong <guangrong.xiao@linux.intel.com>
    KVM: x86: reset MMU on KVM_SET_VCPU_EVENTS

Ville Syrjälä <ville.syrjala@linux.intel.com>
    drm/i915: Initialize overlay->last_flip properly

Ville Syrjälä <ville.syrjala@linux.intel.com>
    drm/i915: Force VDD off on the new power seqeuencer before starting to use it

Ville Syrjälä <ville.syrjala@linux.intel.com>
    drm/i915: Fix oops in overlay due to frontbuffer tracking

Ville Syrjälä <ville.syrjala@linux.intel.com>
    drm/i915: Fix oopses in the overlay code due to i915_gem_active stuff

Kees Cook <keescook@chromium.org>
    gcc-plugins: update gcc-common.h for gcc-7

Michal Marek <mmarek@suse.com>
    asm-prototypes: Clear any CPP defines before declaring the functions

Johannes Berg <johannes.berg@intel.com>
    mac80211: initialize fast-xmit 'info' later

Shyam Sundar S K <ssundark@amd.com>
    pinctrl/amd: Set the level based on ACPI tables

Bartosz Golaszewski <bgolaszewski@baylibre.com>
    ARM: davinci: da850: don't add emac clock to lookup table twice

Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
    HID: sensor-hub: Move the memset to sensor_hub_get_feature()

Helge Deller <deller@gmx.de>
    parisc: Mark cr16 clocksource unstable on SMP systems

Helge Deller <deller@gmx.de>
    parisc: Add line-break when printing segfault info

Eric Biggers <ebiggers@google.com>
    fscrypt: fix renaming and linking special files

Ioan-Adrian Ratiu <adi@adirat.com>
    ALSA: usb-audio: Fix irq/process data synchronization

Takashi Iwai <tiwai@suse.de>
    ALSA: hda - Apply asus-mode8 fixup to ASUS X71SL

Takashi Iwai <tiwai@suse.de>
    ALSA: hda - Fix up GPIO for ASUS ROG Ranger

Florian Fainelli <f.fainelli@gmail.com>
    staging: octeon: Call SET_NETDEV_DEV()

Marcin Niestroj <m.niestroj@grinn-global.com>
    iio: bmi160: Fix time needed to sleep after command execution

Akinobu Mita <akinobu.mita@gmail.com>
    iio: max44000: correct value in illuminance_integration_time_available

Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
    iio: common: st_sensors: fix channel data parsing


-------------

Diffstat:

 Documentation/conf.py                             |   6 +-
 Documentation/media/index.rst                     |   5 -
 Makefile                                          |   4 +-
 arch/arm/boot/dts/r8a7794.dtsi                    |   2 +-
 arch/arm/boot/dts/sun7i-a20-bananapi-m1-plus.dts  |   5 +
 arch/arm/crypto/aes-ce-glue.c                     |   5 +
 arch/arm/mach-davinci/da850.c                     |  12 +-
 arch/arm64/boot/dts/hisilicon/hip06.dtsi          |   4 +-
 arch/arm64/crypto/aes-ce-ccm-core.S               |  53 +++---
 arch/arm64/crypto/aes-ce-cipher.c                 |  25 ++-
 arch/arm64/crypto/aes-ce.S                        |   1 +
 arch/arm64/crypto/aes-modes.S                     |   3 +-
 arch/arm64/crypto/aes-neon.S                      |  25 ++-
 arch/arm64/crypto/ghash-ce-core.S                 |   6 +-
 arch/arm64/crypto/sha1-ce-core.S                  |   4 +-
 arch/arm64/crypto/sha2-ce-core.S                  |   4 +-
 arch/cris/boot/rescue/Makefile                    |   8 +
 arch/mips/kvm/entry.c                             |   5 +-
 arch/mips/kvm/mips.c                              |   4 +-
 arch/parisc/kernel/time.c                         |  23 ++-
 arch/parisc/mm/fault.c                            |   2 +-
 arch/s390/crypto/prng.c                           |   6 +-
 arch/s390/kernel/topology.c                       |   2 +-
 arch/s390/pci/pci_dma.c                           |  15 +-
 arch/x86/include/uapi/asm/prctl.h                 |   8 +-
 arch/x86/kernel/cpu/common.c                      |   7 +-
 arch/x86/kvm/x86.c                                |   9 +-
 drivers/base/power/power.h                        |  19 +-
 drivers/base/power/runtime.c                      |   8 +-
 drivers/base/power/wakeirq.c                      |  76 +++++++-
 drivers/char/tpm/tpm_tis_core.c                   |  15 +-
 drivers/clk/clk-wm831x.c                          |   2 +-
 drivers/clk/imx/clk-imx31.c                       |   4 +-
 drivers/clk/qcom/gcc-ipq806x.c                    |   4 +-
 drivers/clk/renesas/clk-mstp.c                    |  27 ++-
 drivers/clk/renesas/renesas-cpg-mssr.c            |   4 +-
 drivers/clk/sunxi-ng/ccu-sun8i-a23.c              |   6 +-
 drivers/clk/sunxi-ng/ccu-sun8i-h3.c               |  10 +-
 drivers/clk/ti/clk-7xx.c                          |   1 -
 drivers/firmware/efi/efi.c                        |   4 +-
 drivers/gpu/drm/i915/i915_gem_request.h           |  19 ++
 drivers/gpu/drm/i915/intel_dp.c                   |  46 ++++-
 drivers/gpu/drm/i915/intel_overlay.c              |   9 +-
 drivers/gpu/drm/i915/intel_pm.c                   |  50 ++++-
 drivers/gpu/drm/i915/intel_psr.c                  |  10 +-
 drivers/gpu/drm/radeon/radeon_cursor.c            |   6 +-
 drivers/hid/hid-sensor-hub.c                      |   3 +-
 drivers/hwmon/amc6821.c                           |   4 +-
 drivers/hwmon/ds620.c                             |   2 +-
 drivers/hwmon/g762.c                              |  11 +-
 drivers/hwmon/lm90.c                              |   2 +-
 drivers/hwmon/nct7802.c                           |   8 +-
 drivers/hwmon/scpi-hwmon.c                        |   1 +
 drivers/iio/accel/st_accel_core.c                 |  12 +-
 drivers/iio/common/st_sensors/st_sensors_buffer.c |   4 +-
 drivers/iio/common/st_sensors/st_sensors_core.c   |  13 +-
 drivers/iio/imu/bmi160/bmi160_core.c              |  25 +--
 drivers/iio/light/max44000.c                      |   2 +-
 drivers/input/rmi4/rmi_f54.c                      |   5 +-
 drivers/iommu/amd_iommu.c                         |   2 +-
 drivers/iommu/amd_iommu_v2.c                      |   4 +-
 drivers/iommu/intel-iommu.c                       |  42 ++++-
 drivers/irqchip/irq-bcm7038-l1.c                  |  26 +++
 drivers/md/md.c                                   |   7 +-
 drivers/media/usb/dvb-usb/dibusb-common.c         |   2 +-
 drivers/mfd/tps65217.c                            |  19 ++
 drivers/misc/mei/bus.c                            |   2 +-
 drivers/misc/mei/client.c                         |  24 ++-
 drivers/mmc/card/mmc_test.c                       |   2 +-
 drivers/net/wireless/ath/ath10k/core.h            |   6 +-
 drivers/net/wireless/ath/ath10k/mac.c             |   2 -
 drivers/net/wireless/ath/ath10k/spectral.c        |   2 +-
 drivers/pci/host/pcie-rockchip.c                  |   6 +-
 drivers/pci/hotplug/rpadlpar_core.c               |  10 +-
 drivers/pci/msi.c                                 |   3 +-
 drivers/pci/quirks.c                              | 180 ++++++++++++++----
 drivers/pinctrl/pinctrl-amd.c                     |  19 +-
 drivers/platform/x86/fujitsu-laptop.c             |  42 ++---
 drivers/rpmsg/qcom_smd.c                          |   2 +-
 drivers/scsi/g_NCR5380.c                          |   6 +-
 drivers/scsi/mvsas/mv_94xx.c                      |   2 +-
 drivers/staging/iio/adc/ad7606_core.c             |   2 +-
 drivers/staging/media/davinci_vpfe/vpfe_video.c   |   2 +-
 drivers/staging/octeon/ethernet.c                 |   2 +
 drivers/target/iscsi/iscsi_target_tpg.c           |   1 -
 drivers/target/sbp/sbp_target.c                   |   2 +-
 drivers/usb/core/config.c                         |  10 +
 drivers/usb/core/hub.c                            |  59 +++---
 drivers/usb/dwc3/core.h                           |  10 +-
 drivers/usb/dwc3/dwc3-pci.c                       |   4 +-
 drivers/usb/dwc3/ep0.c                            |  50 ++---
 drivers/usb/dwc3/gadget.c                         |  13 +-
 drivers/usb/gadget/composite.c                    |  12 +-
 drivers/usb/gadget/function/f_tcm.c               |   2 +-
 drivers/usb/gadget/legacy/inode.c                 |  17 +-
 drivers/usb/gadget/udc/core.c                     |   6 +-
 drivers/usb/gadget/udc/dummy_hcd.c                |   6 +-
 drivers/usb/host/xhci-mem.c                       |  50 ++++-
 drivers/usb/host/xhci-mtk.c                       |   4 +-
 drivers/usb/host/xhci-pci.c                       |   3 +-
 drivers/usb/host/xhci-ring.c                      | 219 +++++++++++++---------
 drivers/usb/host/xhci.c                           |   4 +-
 drivers/usb/host/xhci.h                           |   5 +-
 drivers/usb/musb/blackfin.c                       |   1 +
 drivers/usb/musb/musb_core.h                      |   7 +
 drivers/usb/musb/musb_dsps.c                      |  12 ++
 drivers/usb/musb/musb_host.c                      |  10 +-
 drivers/usb/musb/musbhsdma.h                      |   2 +-
 drivers/usb/phy/phy-am335x-control.c              |   2 +
 drivers/usb/serial/cyberjack.c                    |  10 +
 drivers/usb/serial/garmin_gps.c                   |   1 +
 drivers/usb/serial/io_edgeport.c                  |   5 +
 drivers/usb/serial/io_ti.c                        |  22 ++-
 drivers/usb/serial/iuu_phoenix.c                  |  11 ++
 drivers/usb/serial/keyspan_pda.c                  |  14 ++
 drivers/usb/serial/kl5kusb105.c                   |   2 +
 drivers/usb/serial/kobil_sct.c                    |  12 ++
 drivers/usb/serial/mos7720.c                      |  51 +++--
 drivers/usb/serial/mos7840.c                      |  12 ++
 drivers/usb/serial/omninet.c                      |  13 ++
 drivers/usb/serial/oti6858.c                      |  16 ++
 drivers/usb/serial/pl2303.c                       |   8 +
 drivers/usb/serial/quatech2.c                     |   4 -
 drivers/usb/serial/spcp8x5.c                      |  14 ++
 drivers/usb/serial/ti_usb_3410_5052.c             |   7 +
 drivers/usb/storage/unusual_devs.h                |   7 +
 fs/crypto/policy.c                                |   5 +
 fs/f2fs/data.c                                    |   2 +-
 fs/f2fs/debug.c                                   |  12 +-
 fs/f2fs/f2fs.h                                    |  12 +-
 fs/f2fs/super.c                                   |  16 +-
 fs/xfs/libxfs/xfs_ag_resv.c                       |   3 +
 fs/xfs/libxfs/xfs_alloc.c                         |  10 +-
 fs/xfs/libxfs/xfs_alloc_btree.c                   |   2 +-
 fs/xfs/libxfs/xfs_attr_leaf.c                     |   8 +-
 fs/xfs/libxfs/xfs_bmap.c                          | 116 ++++++++----
 fs/xfs/libxfs/xfs_bmap.h                          |   5 +-
 fs/xfs/libxfs/xfs_bmap_btree.c                    |   2 +-
 fs/xfs/libxfs/xfs_btree.c                         |  20 ++
 fs/xfs/libxfs/xfs_dir2_data.c                     |   2 +-
 fs/xfs/libxfs/xfs_ialloc.c                        |  13 +-
 fs/xfs/libxfs/xfs_ialloc_btree.c                  |   2 +-
 fs/xfs/libxfs/xfs_inode_buf.c                     |   8 +
 fs/xfs/libxfs/xfs_inode_fork.c                    |  77 ++++++--
 fs/xfs/libxfs/xfs_inode_fork.h                    |   7 +
 fs/xfs/libxfs/xfs_refcount_btree.c                |   9 +-
 fs/xfs/libxfs/xfs_refcount_btree.h                |   3 +-
 fs/xfs/libxfs/xfs_rmap_btree.c                    |  14 +-
 fs/xfs/libxfs/xfs_rmap_btree.h                    |   3 +-
 fs/xfs/libxfs/xfs_sb.c                            |  13 +-
 fs/xfs/libxfs/xfs_types.h                         |   3 +
 fs/xfs/xfs_aops.c                                 |  22 ++-
 fs/xfs/xfs_bmap_util.c                            |  34 ++--
 fs/xfs/xfs_file.c                                 |   9 -
 fs/xfs/xfs_fsops.c                                |  14 ++
 fs/xfs/xfs_icache.c                               |  37 ++--
 fs/xfs/xfs_inode.c                                |   2 -
 fs/xfs/xfs_inode.h                                |  11 +-
 fs/xfs/xfs_inode_item.c                           |   4 +-
 fs/xfs/xfs_ioctl.c                                |   6 +-
 fs/xfs/xfs_iomap.c                                |  54 +++---
 fs/xfs/xfs_log_recover.c                          |   1 -
 fs/xfs/xfs_qm.c                                   |   2 +-
 fs/xfs/xfs_refcount_item.c                        |   3 +-
 fs/xfs/xfs_reflink.c                              |  87 ++-------
 fs/xfs/xfs_reflink.h                              |   2 -
 fs/xfs/xfs_sysfs.c                                |   4 +-
 include/asm-generic/asm-prototypes.h              |   6 +
 include/linux/cpuhotplug.h                        |   3 +-
 include/linux/debugfs.h                           |  44 +++--
 include/linux/iio/common/st_sensors.h             |  12 ++
 include/linux/pci_ids.h                           |  27 ++-
 include/linux/usb/gadget.h                        |   4 +-
 include/uapi/linux/nl80211.h                      |   7 +-
 kernel/irq/affinity.c                             |   6 +-
 kernel/relay.c                                    |   4 +-
 kernel/time/tick-broadcast.c                      |   3 +
 mm/compaction.c                                   |  25 +--
 mm/hugetlb.c                                      |  12 +-
 mm/khugepaged.c                                   |  11 +-
 mm/migrate.c                                      |  15 +-
 net/mac80211/agg-rx.c                             |   8 +-
 net/mac80211/debugfs_sta.c                        |   2 +-
 net/mac80211/sta_info.h                           |   4 +-
 net/mac80211/tx.c                                 |   3 +-
 net/wireless/nl80211.c                            |  16 +-
 scripts/gcc-plugins/gcc-common.h                  |  85 +++++++++
 security/integrity/ima/ima_fs.c                   |   2 +-
 sound/pci/hda/patch_realtek.c                     |   2 +
 sound/soc/intel/boards/cht_bsw_rt5645.c           |   6 +-
 sound/soc/intel/skylake/skl-sst-utils.c           |   2 +-
 sound/soc/qcom/lpass-platform.c                   |   3 +
 sound/soc/samsung/i2s.c                           |   5 +-
 sound/usb/card.c                                  |   1 -
 sound/usb/endpoint.c                              |  17 +-
 sound/usb/endpoint.h                              |   2 +-
 sound/usb/pcm.c                                   |  10 +-
 197 files changed, 1902 insertions(+), 905 deletions(-)

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 001/206] iio: common: st_sensors: fix channel data parsing
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
@ 2017-01-10 13:34   ` Greg Kroah-Hartman
  2017-01-10 13:34   ` [PATCH 4.9 002/206] iio: max44000: correct value in illuminance_integration_time_available Greg Kroah-Hartman
                     ` (188 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:34 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Lorenzo Bianconi, Linus Walleij,
	Jonathan Cameron

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>

commit 65c8aea07de11b6507efa175edb44bd8b4488218 upstream.

Using realbits as i2c/spi read len, when that value is not byte aligned
(e.g 12 bits), lead to skip msb part of out data registers.
Fix this taking into account scan_type.shift in addition to
scan_type.realbits as read length:

read_len = DIV_ROUND_UP(realbits + shift, 8)

This fix has been tested on 8, 12, 16, 24 bit sensors

Fixes: e7385de5291e ("iio:st_sensors: align on storagebits boundaries")
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/iio/common/st_sensors/st_sensors_buffer.c |    4 +++-
 drivers/iio/common/st_sensors/st_sensors_core.c   |    4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

--- a/drivers/iio/common/st_sensors/st_sensors_buffer.c
+++ b/drivers/iio/common/st_sensors/st_sensors_buffer.c
@@ -30,7 +30,9 @@ static int st_sensors_get_buffer_element
 
 	for_each_set_bit(i, indio_dev->active_scan_mask, num_data_channels) {
 		const struct iio_chan_spec *channel = &indio_dev->channels[i];
-		unsigned int bytes_to_read = channel->scan_type.realbits >> 3;
+		unsigned int bytes_to_read =
+			DIV_ROUND_UP(channel->scan_type.realbits +
+				     channel->scan_type.shift, 8);
 		unsigned int storage_bytes =
 			channel->scan_type.storagebits >> 3;
 
--- a/drivers/iio/common/st_sensors/st_sensors_core.c
+++ b/drivers/iio/common/st_sensors/st_sensors_core.c
@@ -483,8 +483,10 @@ static int st_sensors_read_axis_data(str
 	int err;
 	u8 *outdata;
 	struct st_sensor_data *sdata = iio_priv(indio_dev);
-	unsigned int byte_for_channel = ch->scan_type.realbits >> 3;
+	unsigned int byte_for_channel;
 
+	byte_for_channel = DIV_ROUND_UP(ch->scan_type.realbits +
+					ch->scan_type.shift, 8);
 	outdata = kmalloc(byte_for_channel, GFP_KERNEL);
 	if (!outdata)
 		return -ENOMEM;

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 002/206] iio: max44000: correct value in illuminance_integration_time_available
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
  2017-01-10 13:34   ` [PATCH 4.9 001/206] iio: common: st_sensors: fix channel data parsing Greg Kroah-Hartman
@ 2017-01-10 13:34   ` Greg Kroah-Hartman
  2017-01-10 13:34   ` [PATCH 4.9 003/206] iio: bmi160: Fix time needed to sleep after command execution Greg Kroah-Hartman
                     ` (187 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:34 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Crestez Dan Leonard,
	Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Akinobu Mita

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Akinobu Mita <akinobu.mita@gmail.com>

commit b4e8a0eb718749455601fa7b283febc42cca8957 upstream.

According to the datasheet, the shortest available integration time for
ALS ADC conversion is 1.5625ms but illuminance_integration_time_available
sysfs file shows wrong value.

Cc: Crestez Dan Leonard <leonard.crestez@intel.com>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: Hartmut Knaack <knaack.h@gmx.de>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Fixes: d5d8f49b6 ("max44000: Expose ambient sensor scaling")
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/iio/light/max44000.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/iio/light/max44000.c
+++ b/drivers/iio/light/max44000.c
@@ -113,7 +113,7 @@ static const char max44000_int_time_avai
 	"0.100 "
 	"0.025 "
 	"0.00625 "
-	"0.001625";
+	"0.0015625";
 
 /* Available scales (internal to ulux) with pretty manual alignment: */
 static const int max44000_scale_avail_ulux_array[] = {

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 003/206] iio: bmi160: Fix time needed to sleep after command execution
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
  2017-01-10 13:34   ` [PATCH 4.9 001/206] iio: common: st_sensors: fix channel data parsing Greg Kroah-Hartman
  2017-01-10 13:34   ` [PATCH 4.9 002/206] iio: max44000: correct value in illuminance_integration_time_available Greg Kroah-Hartman
@ 2017-01-10 13:34   ` Greg Kroah-Hartman
  2017-01-10 13:34   ` [PATCH 4.9 004/206] staging: octeon: Call SET_NETDEV_DEV() Greg Kroah-Hartman
                     ` (186 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:34 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Marcin Niestroj, Jonathan Cameron

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Marcin Niestroj <m.niestroj@grinn-global.com>

commit 01d1f7a99e457952aa51849ed7c1cc4ced7bca4b upstream.

Datasheet specifies typical and maximum execution times for which CMD
register is occupied after previous command execution. We took these
values as minimum and maximum time for usleep_range() call before making
a new command execution.

To be sure, that the CMD register is no longer occupied we need to wait
*at least* the maximum time specified by datasheet.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/iio/imu/bmi160/bmi160_core.c |   25 ++++++-------------------
 1 file changed, 6 insertions(+), 19 deletions(-)

--- a/drivers/iio/imu/bmi160/bmi160_core.c
+++ b/drivers/iio/imu/bmi160/bmi160_core.c
@@ -66,10 +66,8 @@
 
 #define BMI160_REG_DUMMY		0x7F
 
-#define BMI160_ACCEL_PMU_MIN_USLEEP	3200
-#define BMI160_ACCEL_PMU_MAX_USLEEP	3800
-#define BMI160_GYRO_PMU_MIN_USLEEP	55000
-#define BMI160_GYRO_PMU_MAX_USLEEP	80000
+#define BMI160_ACCEL_PMU_MIN_USLEEP	3800
+#define BMI160_GYRO_PMU_MIN_USLEEP	80000
 #define BMI160_SOFTRESET_USLEEP		1000
 
 #define BMI160_CHANNEL(_type, _axis, _index) {			\
@@ -151,20 +149,9 @@ static struct bmi160_regs bmi160_regs[]
 	},
 };
 
-struct bmi160_pmu_time {
-	unsigned long min;
-	unsigned long max;
-};
-
-static struct bmi160_pmu_time bmi160_pmu_time[] = {
-	[BMI160_ACCEL] = {
-		.min = BMI160_ACCEL_PMU_MIN_USLEEP,
-		.max = BMI160_ACCEL_PMU_MAX_USLEEP
-	},
-	[BMI160_GYRO] = {
-		.min = BMI160_GYRO_PMU_MIN_USLEEP,
-		.max = BMI160_GYRO_PMU_MIN_USLEEP,
-	},
+static unsigned long bmi160_pmu_time[] = {
+	[BMI160_ACCEL] = BMI160_ACCEL_PMU_MIN_USLEEP,
+	[BMI160_GYRO] = BMI160_GYRO_PMU_MIN_USLEEP,
 };
 
 struct bmi160_scale {
@@ -289,7 +276,7 @@ int bmi160_set_mode(struct bmi160_data *
 	if (ret < 0)
 		return ret;
 
-	usleep_range(bmi160_pmu_time[t].min, bmi160_pmu_time[t].max);
+	usleep_range(bmi160_pmu_time[t], bmi160_pmu_time[t] + 1000);
 
 	return 0;
 }

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 004/206] staging: octeon: Call SET_NETDEV_DEV()
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (2 preceding siblings ...)
  2017-01-10 13:34   ` [PATCH 4.9 003/206] iio: bmi160: Fix time needed to sleep after command execution Greg Kroah-Hartman
@ 2017-01-10 13:34   ` Greg Kroah-Hartman
  2017-01-10 13:34   ` [PATCH 4.9 005/206] ALSA: hda - Fix up GPIO for ASUS ROG Ranger Greg Kroah-Hartman
                     ` (185 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Aaro Koskinen, Florian Fainelli

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Florian Fainelli <f.fainelli@gmail.com>

commit e7c9a3d9e432200fd4c17855c2c23ac784d6e833 upstream.

The Octeon driver calls into PHYLIB which now checks for
net_device->dev.parent, so make sure we do set it before calling into
any MDIO/PHYLIB related function.

Fixes: ec988ad78ed6 ("phy: Don't increment MDIO bus refcount unless it's a different owner")
Reported-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/staging/octeon/ethernet.c |    2 ++
 1 file changed, 2 insertions(+)

--- a/drivers/staging/octeon/ethernet.c
+++ b/drivers/staging/octeon/ethernet.c
@@ -776,6 +776,7 @@ static int cvm_oct_probe(struct platform
 			/* Initialize the device private structure. */
 			struct octeon_ethernet *priv = netdev_priv(dev);
 
+			SET_NETDEV_DEV(dev, &pdev->dev);
 			dev->netdev_ops = &cvm_oct_pow_netdev_ops;
 			priv->imode = CVMX_HELPER_INTERFACE_MODE_DISABLED;
 			priv->port = CVMX_PIP_NUM_INPUT_PORTS;
@@ -820,6 +821,7 @@ static int cvm_oct_probe(struct platform
 			}
 
 			/* Initialize the device private structure. */
+			SET_NETDEV_DEV(dev, &pdev->dev);
 			priv = netdev_priv(dev);
 			priv->netdev = dev;
 			priv->of_node = cvm_oct_node_for_port(pip, interface,

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 005/206] ALSA: hda - Fix up GPIO for ASUS ROG Ranger
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (3 preceding siblings ...)
  2017-01-10 13:34   ` [PATCH 4.9 004/206] staging: octeon: Call SET_NETDEV_DEV() Greg Kroah-Hartman
@ 2017-01-10 13:34   ` Greg Kroah-Hartman
  2017-01-10 13:34   ` [PATCH 4.9 006/206] ALSA: hda - Apply asus-mode8 fixup to ASUS X71SL Greg Kroah-Hartman
                     ` (184 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Takashi Iwai

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Takashi Iwai <tiwai@suse.de>

commit 85bcf96caba8b4a7c0805555638629ba3c67ea0c upstream.

ASUS ROG Ranger VIII with ALC1150 codec requires the extra GPIO pin to
up for the front panel.  Just use the existing fixup for setting up
the GPIO pins.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=189411
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 sound/pci/hda/patch_realtek.c |    1 +
 1 file changed, 1 insertion(+)

--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -2230,6 +2230,7 @@ static const struct snd_pci_quirk alc882
 	SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC),
 	SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601),
 	SND_PCI_QUIRK(0x1043, 0x84bc, "ASUS ET2700", ALC887_FIXUP_ASUS_BASS),
+	SND_PCI_QUIRK(0x1043, 0x8691, "ASUS ROG Ranger VIII", ALC882_FIXUP_GPIO3),
 	SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT),
 	SND_PCI_QUIRK(0x104d, 0x905a, "Sony Vaio Z", ALC882_FIXUP_NO_PRIMARY_HP),
 	SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP),

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 006/206] ALSA: hda - Apply asus-mode8 fixup to ASUS X71SL
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (4 preceding siblings ...)
  2017-01-10 13:34   ` [PATCH 4.9 005/206] ALSA: hda - Fix up GPIO for ASUS ROG Ranger Greg Kroah-Hartman
@ 2017-01-10 13:34   ` Greg Kroah-Hartman
  2017-01-10 13:34   ` [PATCH 4.9 007/206] ALSA: usb-audio: Fix irq/process data synchronization Greg Kroah-Hartman
                     ` (183 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Takashi Iwai

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Takashi Iwai <tiwai@suse.de>

commit c7efff9284dfde95a11aaa811c9d8ec8167f0f6e upstream.

Although the old quirk table showed ASUS X71SL with ALC663 codec being
compatible with asus-mode3 fixup, the bugzilla reporter explained that
asus-model8 fits better for the dual headphone controls.  So be it.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=191781
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 sound/pci/hda/patch_realtek.c |    1 +
 1 file changed, 1 insertion(+)

--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -6944,6 +6944,7 @@ static const struct snd_pci_quirk alc662
 	SND_PCI_QUIRK(0x1043, 0x15a7, "ASUS UX51VZH", ALC662_FIXUP_BASS_16),
 	SND_PCI_QUIRK(0x1043, 0x177d, "ASUS N551", ALC668_FIXUP_ASUS_Nx51),
 	SND_PCI_QUIRK(0x1043, 0x17bd, "ASUS N751", ALC668_FIXUP_ASUS_Nx51),
+	SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71SL", ALC662_FIXUP_ASUS_MODE8),
 	SND_PCI_QUIRK(0x1043, 0x1b73, "ASUS N55SF", ALC662_FIXUP_BASS_16),
 	SND_PCI_QUIRK(0x1043, 0x1bf3, "ASUS N76VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
 	SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT),

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 007/206] ALSA: usb-audio: Fix irq/process data synchronization
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (5 preceding siblings ...)
  2017-01-10 13:34   ` [PATCH 4.9 006/206] ALSA: hda - Apply asus-mode8 fixup to ASUS X71SL Greg Kroah-Hartman
@ 2017-01-10 13:34   ` Greg Kroah-Hartman
  2017-01-10 13:34   ` [PATCH 4.9 008/206] fscrypt: fix renaming and linking special files Greg Kroah-Hartman
                     ` (182 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Ioan-Adrian Ratiu, Takashi Iwai

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Ioan-Adrian Ratiu <adi@adirat.com>

commit 1d0f953086f090a022f2c0e1448300c15372db46 upstream.

Commit 16200948d83 ("ALSA: usb-audio: Fix race at stopping the stream") was
incomplete causing another more severe kernel panic, so it got reverted.
This fixes both the original problem and its fallout kernel race/crash.

The original fix is to move the endpoint member NULL clearing logic inside
wait_clear_urbs() so the irq triggering the urb completion doesn't call
retire_capture/playback_urb() after the NULL clearing and generate a panic.

However this creates a new race between snd_usb_endpoint_start()'s call
to wait_clear_urbs() and the irq urb completion handler which again calls
retire_capture/playback_urb() leading to a new NULL dereference.

We keep the EP deactivation code in snd_usb_endpoint_start() because
removing it will break the EP reference counting (see [1] [2] for info),
however we don't need the "can_sleep" mechanism anymore because a new
function was introduced (snd_usb_endpoint_sync_pending_stop()) which
synchronizes pending stops and gets called inside the pcm prepare callback.

It also makes sense to remove can_sleep because it was also removed from
deactivate_urbs() signature in [3] so we benefit from more simplification.

[1] commit 015618b90 ("ALSA: snd-usb: Fix URB cancellation at stream start")
[2] commit e9ba389c5 ("ALSA: usb-audio: Fix scheduling-while-atomic bug in PCM capture stream")
[3] commit ccc1696d5 ("ALSA: usb-audio: simplify endpoint deactivation code")

Fixes: f8114f8583bb ("Revert "ALSA: usb-audio: Fix race at stopping the stream"")

Signed-off-by: Ioan-Adrian Ratiu <adi@adirat.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 sound/usb/endpoint.c |   17 +++++++----------
 sound/usb/endpoint.h |    2 +-
 sound/usb/pcm.c      |   10 +++++-----
 3 files changed, 13 insertions(+), 16 deletions(-)

--- a/sound/usb/endpoint.c
+++ b/sound/usb/endpoint.c
@@ -534,6 +534,11 @@ static int wait_clear_urbs(struct snd_us
 			alive, ep->ep_num);
 	clear_bit(EP_FLAG_STOPPING, &ep->flags);
 
+	ep->data_subs = NULL;
+	ep->sync_slave = NULL;
+	ep->retire_data_urb = NULL;
+	ep->prepare_data_urb = NULL;
+
 	return 0;
 }
 
@@ -898,9 +903,7 @@ int snd_usb_endpoint_set_params(struct s
 /**
  * snd_usb_endpoint_start: start an snd_usb_endpoint
  *
- * @ep:		the endpoint to start
- * @can_sleep:	flag indicating whether the operation is executed in
- * 		non-atomic context
+ * @ep: the endpoint to start
  *
  * A call to this function will increment the use count of the endpoint.
  * In case it is not already running, the URBs for this endpoint will be
@@ -910,7 +913,7 @@ int snd_usb_endpoint_set_params(struct s
  *
  * Returns an error if the URB submission failed, 0 in all other cases.
  */
-int snd_usb_endpoint_start(struct snd_usb_endpoint *ep, bool can_sleep)
+int snd_usb_endpoint_start(struct snd_usb_endpoint *ep)
 {
 	int err;
 	unsigned int i;
@@ -924,8 +927,6 @@ int snd_usb_endpoint_start(struct snd_us
 
 	/* just to be sure */
 	deactivate_urbs(ep, false);
-	if (can_sleep)
-		wait_clear_urbs(ep);
 
 	ep->active_mask = 0;
 	ep->unlink_mask = 0;
@@ -1006,10 +1007,6 @@ void snd_usb_endpoint_stop(struct snd_us
 
 	if (--ep->use_count == 0) {
 		deactivate_urbs(ep, false);
-		ep->data_subs = NULL;
-		ep->sync_slave = NULL;
-		ep->retire_data_urb = NULL;
-		ep->prepare_data_urb = NULL;
 		set_bit(EP_FLAG_STOPPING, &ep->flags);
 	}
 }
--- a/sound/usb/endpoint.h
+++ b/sound/usb/endpoint.h
@@ -18,7 +18,7 @@ int snd_usb_endpoint_set_params(struct s
 				struct audioformat *fmt,
 				struct snd_usb_endpoint *sync_ep);
 
-int  snd_usb_endpoint_start(struct snd_usb_endpoint *ep, bool can_sleep);
+int  snd_usb_endpoint_start(struct snd_usb_endpoint *ep);
 void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep);
 void snd_usb_endpoint_sync_pending_stop(struct snd_usb_endpoint *ep);
 int  snd_usb_endpoint_activate(struct snd_usb_endpoint *ep);
--- a/sound/usb/pcm.c
+++ b/sound/usb/pcm.c
@@ -218,7 +218,7 @@ int snd_usb_init_pitch(struct snd_usb_au
 	}
 }
 
-static int start_endpoints(struct snd_usb_substream *subs, bool can_sleep)
+static int start_endpoints(struct snd_usb_substream *subs)
 {
 	int err;
 
@@ -231,7 +231,7 @@ static int start_endpoints(struct snd_us
 		dev_dbg(&subs->dev->dev, "Starting data EP @%p\n", ep);
 
 		ep->data_subs = subs;
-		err = snd_usb_endpoint_start(ep, can_sleep);
+		err = snd_usb_endpoint_start(ep);
 		if (err < 0) {
 			clear_bit(SUBSTREAM_FLAG_DATA_EP_STARTED, &subs->flags);
 			return err;
@@ -260,7 +260,7 @@ static int start_endpoints(struct snd_us
 		dev_dbg(&subs->dev->dev, "Starting sync EP @%p\n", ep);
 
 		ep->sync_slave = subs->data_endpoint;
-		err = snd_usb_endpoint_start(ep, can_sleep);
+		err = snd_usb_endpoint_start(ep);
 		if (err < 0) {
 			clear_bit(SUBSTREAM_FLAG_SYNC_EP_STARTED, &subs->flags);
 			return err;
@@ -839,7 +839,7 @@ static int snd_usb_pcm_prepare(struct sn
 	/* for playback, submit the URBs now; otherwise, the first hwptr_done
 	 * updates for all URBs would happen at the same time when starting */
 	if (subs->direction == SNDRV_PCM_STREAM_PLAYBACK)
-		ret = start_endpoints(subs, true);
+		ret = start_endpoints(subs);
 
  unlock:
 	snd_usb_unlock_shutdown(subs->stream->chip);
@@ -1655,7 +1655,7 @@ static int snd_usb_substream_capture_tri
 
 	switch (cmd) {
 	case SNDRV_PCM_TRIGGER_START:
-		err = start_endpoints(subs, false);
+		err = start_endpoints(subs);
 		if (err < 0)
 			return err;
 

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 008/206] fscrypt: fix renaming and linking special files
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (6 preceding siblings ...)
  2017-01-10 13:34   ` [PATCH 4.9 007/206] ALSA: usb-audio: Fix irq/process data synchronization Greg Kroah-Hartman
@ 2017-01-10 13:34   ` Greg Kroah-Hartman
  2017-01-10 13:34   ` [PATCH 4.9 009/206] parisc: Add line-break when printing segfault info Greg Kroah-Hartman
                     ` (181 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:34 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Eric Biggers, Richard Weinberger,
	Theodore Tso

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Eric Biggers <ebiggers@google.com>

commit 42d97eb0ade31e1bc537d086842f5d6e766d9d51 upstream.

Attempting to link a device node, named pipe, or socket file into an
encrypted directory through rename(2) or link(2) always failed with
EPERM.  This happened because fscrypt_has_permitted_context() saw that
the file was unencrypted and forbid creating the link.  This behavior
was unexpected because such files are never encrypted; only regular
files, directories, and symlinks can be encrypted.

To fix this, make fscrypt_has_permitted_context() always return true on
special files.

This will be covered by a test in my encryption xfstests patchset.

Fixes: 9bd8212f981e ("ext4 crypto: add encryption policy and password salt support")
Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/crypto/policy.c |    5 +++++
 1 file changed, 5 insertions(+)

--- a/fs/crypto/policy.c
+++ b/fs/crypto/policy.c
@@ -171,6 +171,11 @@ int fscrypt_has_permitted_context(struct
 		BUG_ON(1);
 	}
 
+	/* No restrictions on file types which are never encrypted */
+	if (!S_ISREG(child->i_mode) && !S_ISDIR(child->i_mode) &&
+	    !S_ISLNK(child->i_mode))
+		return 1;
+
 	/* no restrictions if the parent directory is not encrypted */
 	if (!parent->i_sb->s_cop->is_encrypted(parent))
 		return 1;

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 009/206] parisc: Add line-break when printing segfault info
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (7 preceding siblings ...)
  2017-01-10 13:34   ` [PATCH 4.9 008/206] fscrypt: fix renaming and linking special files Greg Kroah-Hartman
@ 2017-01-10 13:34   ` Greg Kroah-Hartman
  2017-01-10 13:34   ` [PATCH 4.9 010/206] parisc: Mark cr16 clocksource unstable on SMP systems Greg Kroah-Hartman
                     ` (180 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Helge Deller

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Helge Deller <deller@gmx.de>

commit b4a9eb4cd5966c8aad3d007d206a2cbda97d6928 upstream.

Add a leading line break else printed line gets too long.

Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/parisc/mm/fault.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/arch/parisc/mm/fault.c
+++ b/arch/parisc/mm/fault.c
@@ -234,7 +234,7 @@ show_signal_msg(struct pt_regs *regs, un
 	    tsk->comm, code, address);
 	print_vma_addr(KERN_CONT " in ", regs->iaoq[0]);
 
-	pr_cont(" trap #%lu: %s%c", code, trap_name(code),
+	pr_cont("\ntrap #%lu: %s%c", code, trap_name(code),
 		vma ? ',':'\n');
 
 	if (vma)

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 010/206] parisc: Mark cr16 clocksource unstable on SMP systems
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (8 preceding siblings ...)
  2017-01-10 13:34   ` [PATCH 4.9 009/206] parisc: Add line-break when printing segfault info Greg Kroah-Hartman
@ 2017-01-10 13:34   ` Greg Kroah-Hartman
  2017-01-10 13:34   ` [PATCH 4.9 011/206] HID: sensor-hub: Move the memset to sensor_hub_get_feature() Greg Kroah-Hartman
                     ` (179 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Helge Deller

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Helge Deller <deller@gmx.de>

commit 41744213602a206f24adcb4a2b7551db3c700e72 upstream.

The cr16 interval timer of each CPU is not syncronized to other cr16
timers in other CPUs in a SMP system. So, delay the registration of the
cr16 clocksource until all CPUs have been detected and then - if we are
on a SMP machine - mark the cr16 clocksource as unstable and lower it's
rating before registering it at the clocksource framework.

This patch fixes the stalled CPU warnings which we have seen since
introduction of the cr16 clocksource.

Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/parisc/kernel/time.c |   23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

--- a/arch/parisc/kernel/time.c
+++ b/arch/parisc/kernel/time.c
@@ -289,9 +289,26 @@ void __init time_init(void)
 
 	cr16_hz = 100 * PAGE0->mem_10msec;  /* Hz */
 
-	/* register at clocksource framework */
-	clocksource_register_hz(&clocksource_cr16, cr16_hz);
-
 	/* register as sched_clock source */
 	sched_clock_register(read_cr16_sched_clock, BITS_PER_LONG, cr16_hz);
 }
+
+static int __init init_cr16_clocksource(void)
+{
+	/*
+	 * The cr16 interval timers are not syncronized across CPUs, so mark
+	 * them unstable and lower rating on SMP systems.
+	 */
+	if (num_online_cpus() > 1) {
+		clocksource_cr16.flags = CLOCK_SOURCE_UNSTABLE;
+		clocksource_cr16.rating = 0;
+	}
+
+	/* register at clocksource framework */
+	clocksource_register_hz(&clocksource_cr16,
+		100 * PAGE0->mem_10msec);
+
+	return 0;
+}
+
+device_initcall(init_cr16_clocksource);

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 011/206] HID: sensor-hub: Move the memset to sensor_hub_get_feature()
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (9 preceding siblings ...)
  2017-01-10 13:34   ` [PATCH 4.9 010/206] parisc: Mark cr16 clocksource unstable on SMP systems Greg Kroah-Hartman
@ 2017-01-10 13:34   ` Greg Kroah-Hartman
  2017-01-10 13:34   ` [PATCH 4.9 012/206] ARM: davinci: da850: dont add emac clock to lookup table twice Greg Kroah-Hartman
                     ` (178 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Srinivas Pandruvada, Jiri Kosina

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

commit 143fca77cce906d35f7a60ccef648e888df589f2 upstream.

While applying patch d443a0aa3a29: "HID: hid-sensor-hub: clear memory to
avoid random data", there was some issues in applying correct version of
the patch. This resulted in the breakage of sensor functions as all
request like power-up will be reset by the memset() in the function
sensor_hub_set_feature().
The reset of caller buffer should be in the function
sensor_hub_get_feature(), not in the sensor_hub_set_feature().

Fixes: d443a0aa3a29 ("HID: hid-sensor-hub: clear memory to avoid random data")
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/hid/hid-sensor-hub.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -212,7 +212,6 @@ int sensor_hub_set_feature(struct hid_se
 	__s32 value;
 	int ret = 0;
 
-	memset(buffer, 0, buffer_size);
 	mutex_lock(&data->mutex);
 	report = sensor_hub_report(report_id, hsdev->hdev, HID_FEATURE_REPORT);
 	if (!report || (field_index >= report->maxfield)) {
@@ -256,6 +255,8 @@ int sensor_hub_get_feature(struct hid_se
 	int buffer_index = 0;
 	int i;
 
+	memset(buffer, 0, buffer_size);
+
 	mutex_lock(&data->mutex);
 	report = sensor_hub_report(report_id, hsdev->hdev, HID_FEATURE_REPORT);
 	if (!report || (field_index >= report->maxfield) ||

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 012/206] ARM: davinci: da850: dont add emac clock to lookup table twice
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (10 preceding siblings ...)
  2017-01-10 13:34   ` [PATCH 4.9 011/206] HID: sensor-hub: Move the memset to sensor_hub_get_feature() Greg Kroah-Hartman
@ 2017-01-10 13:34   ` Greg Kroah-Hartman
  2017-01-10 13:34   ` [PATCH 4.9 013/206] pinctrl/amd: Set the level based on ACPI tables Greg Kroah-Hartman
                     ` (177 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Bartosz Golaszewski, Sekhar Nori

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

commit ef37427ac5677331145ab27a17e6f5f1b43f0c11 upstream.

Similarly to the aemif clock - this screws up the linked list of clock
children. Create a separate clock for mdio inheriting the rate from
emac_clk.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
[nsekhar@ti.com: add a comment over mdio_clk to explaing its existence +
		 commit headline updates]
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/arm/mach-davinci/da850.c |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

--- a/arch/arm/mach-davinci/da850.c
+++ b/arch/arm/mach-davinci/da850.c
@@ -319,6 +319,16 @@ static struct clk emac_clk = {
 	.gpsc		= 1,
 };
 
+/*
+ * In order to avoid adding the emac_clk to the clock lookup table twice (and
+ * screwing up the linked list in the process) create a separate clock for
+ * mdio inheriting the rate from emac_clk.
+ */
+static struct clk mdio_clk = {
+	.name		= "mdio",
+	.parent		= &emac_clk,
+};
+
 static struct clk mcasp_clk = {
 	.name		= "mcasp",
 	.parent		= &async3_clk,
@@ -494,7 +504,7 @@ static struct clk_lookup da850_clks[] =
 	CLK(NULL,		"arm",		&arm_clk),
 	CLK(NULL,		"rmii",		&rmii_clk),
 	CLK("davinci_emac.1",	NULL,		&emac_clk),
-	CLK("davinci_mdio.0",	"fck",		&emac_clk),
+	CLK("davinci_mdio.0",	"fck",		&mdio_clk),
 	CLK("davinci-mcasp.0",	NULL,		&mcasp_clk),
 	CLK("davinci-mcbsp.0",	NULL,		&mcbsp0_clk),
 	CLK("davinci-mcbsp.1",	NULL,		&mcbsp1_clk),

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 013/206] pinctrl/amd: Set the level based on ACPI tables
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (11 preceding siblings ...)
  2017-01-10 13:34   ` [PATCH 4.9 012/206] ARM: davinci: da850: dont add emac clock to lookup table twice Greg Kroah-Hartman
@ 2017-01-10 13:34   ` Greg Kroah-Hartman
  2017-01-10 13:34   ` [PATCH 4.9 014/206] mac80211: initialize fast-xmit info later Greg Kroah-Hartman
                     ` (176 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:34 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Pankaj Sen, Nitesh Kumar Agrawal,
	Shah, Nehal-bakulchandra, Shyam-sundar S-k, Linus Walleij

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Shyam Sundar S K <ssundark@amd.com>

commit 2983f296f2327bc517e3b29344fce82271160197 upstream.

In the function amd_gpio_irq_set_type, read the values from
the ACPI table to set the level and drop the settings passed
by the client.

Reviewed-by: Pankaj Sen <Pankaj.Sen@amd.com>
Reviewed-by: Nitesh Kumar Agrawal <Nitesh-kumar.Agrawal@amd.com>
Reviewed-by: Shah, Nehal-bakulchandra <Nehal-bakulchandra.Shah@amd.com>
Signed-off-by: Shyam-sundar S-k <Shyam-sundar.S-k@amd.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/pinctrl/pinctrl-amd.c |   19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

--- a/drivers/pinctrl/pinctrl-amd.c
+++ b/drivers/pinctrl/pinctrl-amd.c
@@ -382,26 +382,21 @@ static int amd_gpio_irq_set_type(struct
 {
 	int ret = 0;
 	u32 pin_reg;
-	unsigned long flags;
-	bool level_trig;
-	u32 active_level;
+	unsigned long flags, irq_flags;
 	struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
 	struct amd_gpio *gpio_dev = gpiochip_get_data(gc);
 
 	spin_lock_irqsave(&gpio_dev->lock, flags);
 	pin_reg = readl(gpio_dev->base + (d->hwirq)*4);
 
-	/*
-	 * When level_trig is set EDGE and active_level is set HIGH in BIOS
-	 * default settings, ignore incoming settings from client and use
-	 * BIOS settings to configure GPIO register.
+	/* Ignore the settings coming from the client and
+	 * read the values from the ACPI tables
+	 * while setting the trigger type
 	 */
-	level_trig = !(pin_reg & (LEVEL_TRIGGER << LEVEL_TRIG_OFF));
-	active_level = pin_reg & (ACTIVE_LEVEL_MASK << ACTIVE_LEVEL_OFF);
 
-	if(level_trig &&
-	   ((active_level >> ACTIVE_LEVEL_OFF) == ACTIVE_HIGH))
-		type = IRQ_TYPE_EDGE_FALLING;
+	irq_flags = irq_get_trigger_type(d->irq);
+	if (irq_flags != IRQ_TYPE_NONE)
+		type = irq_flags;
 
 	switch (type & IRQ_TYPE_SENSE_MASK) {
 	case IRQ_TYPE_EDGE_RISING:

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 014/206] mac80211: initialize fast-xmit info later
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (12 preceding siblings ...)
  2017-01-10 13:34   ` [PATCH 4.9 013/206] pinctrl/amd: Set the level based on ACPI tables Greg Kroah-Hartman
@ 2017-01-10 13:34   ` Greg Kroah-Hartman
  2017-01-10 13:34   ` [PATCH 4.9 016/206] gcc-plugins: update gcc-common.h for gcc-7 Greg Kroah-Hartman
                     ` (175 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Ben Greear, Johannes Berg

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Johannes Berg <johannes.berg@intel.com>

commit 35f432a03e41d3bf08c51ede917f94e2288fbe8c upstream.

In ieee80211_xmit_fast(), 'info' is initialized to point to the skb
that's passed in, but that skb may later be replaced by a clone (if
it was shared), leading to an invalid pointer.

This can lead to use-after-free and also later crashes since the
real SKB's info->hw_queue doesn't get initialized properly.

Fix this by assigning info only later, when it's needed, after the
skb replacement (may have) happened.

Reported-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 net/mac80211/tx.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -3262,7 +3262,7 @@ static bool ieee80211_xmit_fast(struct i
 	int extra_head = fast_tx->hdr_len - (ETH_HLEN - 2);
 	int hw_headroom = sdata->local->hw.extra_tx_headroom;
 	struct ethhdr eth;
-	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
+	struct ieee80211_tx_info *info;
 	struct ieee80211_hdr *hdr = (void *)fast_tx->hdr;
 	struct ieee80211_tx_data tx;
 	ieee80211_tx_result r;
@@ -3326,6 +3326,7 @@ static bool ieee80211_xmit_fast(struct i
 	memcpy(skb->data + fast_tx->da_offs, eth.h_dest, ETH_ALEN);
 	memcpy(skb->data + fast_tx->sa_offs, eth.h_source, ETH_ALEN);
 
+	info = IEEE80211_SKB_CB(skb);
 	memset(info, 0, sizeof(*info));
 	info->band = fast_tx->band;
 	info->control.vif = &sdata->vif;

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 016/206] gcc-plugins: update gcc-common.h for gcc-7
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (13 preceding siblings ...)
  2017-01-10 13:34   ` [PATCH 4.9 014/206] mac80211: initialize fast-xmit info later Greg Kroah-Hartman
@ 2017-01-10 13:34   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 021/206] KVM: x86: reset MMU on KVM_SET_VCPU_EVENTS Greg Kroah-Hartman
                     ` (174 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Kees Cook

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Kees Cook <keescook@chromium.org>

commit 81d873a87114b05dbb74d1fbf0c4322ba4bfdee4 upstream.

This updates gcc-common.h from Emese Revfy for gcc 7. This fixes issues seen
by Kugan and Arnd. Build tested with gcc 5.4 and 7 snapshot.

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 scripts/gcc-plugins/gcc-common.h |   85 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 85 insertions(+)

--- a/scripts/gcc-plugins/gcc-common.h
+++ b/scripts/gcc-plugins/gcc-common.h
@@ -39,6 +39,9 @@
 #include "hash-map.h"
 #endif
 
+#if BUILDING_GCC_VERSION >= 7000
+#include "memmodel.h"
+#endif
 #include "emit-rtl.h"
 #include "debug.h"
 #include "target.h"
@@ -91,6 +94,9 @@
 #include "tree-ssa-alias.h"
 #include "tree-ssa.h"
 #include "stringpool.h"
+#if BUILDING_GCC_VERSION >= 7000
+#include "tree-vrp.h"
+#endif
 #include "tree-ssanames.h"
 #include "print-tree.h"
 #include "tree-eh.h"
@@ -287,6 +293,22 @@ static inline struct cgraph_node *cgraph
 	return NULL;
 }
 
+static inline bool cgraph_for_node_and_aliases(cgraph_node_ptr node, bool (*callback)(cgraph_node_ptr, void *), void *data, bool include_overwritable)
+{
+	cgraph_node_ptr alias;
+
+	if (callback(node, data))
+		return true;
+
+	for (alias = node->same_body; alias; alias = alias->next) {
+		if (include_overwritable || cgraph_function_body_availability(alias) > AVAIL_OVERWRITABLE)
+			if (cgraph_for_node_and_aliases(alias, callback, data, include_overwritable))
+				return true;
+	}
+
+	return false;
+}
+
 #define FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) \
 	for ((node) = cgraph_first_function_with_gimple_body(); (node); \
 		(node) = cgraph_next_function_with_gimple_body(node))
@@ -399,6 +421,7 @@ typedef union gimple_statement_d gassign
 typedef union gimple_statement_d gcall;
 typedef union gimple_statement_d gcond;
 typedef union gimple_statement_d gdebug;
+typedef union gimple_statement_d ggoto;
 typedef union gimple_statement_d gphi;
 typedef union gimple_statement_d greturn;
 
@@ -452,6 +475,16 @@ static inline const gdebug *as_a_const_g
 	return stmt;
 }
 
+static inline ggoto *as_a_ggoto(gimple stmt)
+{
+	return stmt;
+}
+
+static inline const ggoto *as_a_const_ggoto(const_gimple stmt)
+{
+	return stmt;
+}
+
 static inline gphi *as_a_gphi(gimple stmt)
 {
 	return stmt;
@@ -496,6 +529,14 @@ static inline const greturn *as_a_const_
 
 typedef struct rtx_def rtx_insn;
 
+static inline const char *get_decl_section_name(const_tree decl)
+{
+	if (DECL_SECTION_NAME(decl) == NULL_TREE)
+		return NULL;
+
+	return TREE_STRING_POINTER(DECL_SECTION_NAME(decl));
+}
+
 static inline void set_decl_section_name(tree node, const char *value)
 {
 	if (value)
@@ -511,6 +552,7 @@ typedef struct gimple_statement_base gas
 typedef struct gimple_statement_call gcall;
 typedef struct gimple_statement_base gcond;
 typedef struct gimple_statement_base gdebug;
+typedef struct gimple_statement_base ggoto;
 typedef struct gimple_statement_phi gphi;
 typedef struct gimple_statement_base greturn;
 
@@ -564,6 +606,16 @@ static inline const gdebug *as_a_const_g
 	return stmt;
 }
 
+static inline ggoto *as_a_ggoto(gimple stmt)
+{
+	return stmt;
+}
+
+static inline const ggoto *as_a_const_ggoto(const_gimple stmt)
+{
+	return stmt;
+}
+
 static inline gphi *as_a_gphi(gimple stmt)
 {
 	return as_a<gphi>(stmt);
@@ -611,6 +663,11 @@ inline bool is_a_helper<const gassign *>
 
 #define INSN_DELETED_P(insn) (insn)->deleted()
 
+static inline const char *get_decl_section_name(const_tree decl)
+{
+	return DECL_SECTION_NAME(decl);
+}
+
 /* symtab/cgraph related */
 #define debug_cgraph_node(node) (node)->debug()
 #define cgraph_get_node(decl) cgraph_node::get(decl)
@@ -619,6 +676,7 @@ inline bool is_a_helper<const gassign *>
 #define cgraph_n_nodes symtab->cgraph_count
 #define cgraph_max_uid symtab->cgraph_max_uid
 #define varpool_get_node(decl) varpool_node::get(decl)
+#define dump_varpool_node(file, node) (node)->dump(file)
 
 #define cgraph_create_edge(caller, callee, call_stmt, count, freq, nest) \
 	(caller)->create_edge((callee), (call_stmt), (count), (freq))
@@ -674,6 +732,11 @@ static inline cgraph_node_ptr cgraph_ali
 	return node->get_alias_target();
 }
 
+static inline bool cgraph_for_node_and_aliases(cgraph_node_ptr node, bool (*callback)(cgraph_node_ptr, void *), void *data, bool include_overwritable)
+{
+	return node->call_for_symbol_thunks_and_aliases(callback, data, include_overwritable);
+}
+
 static inline struct cgraph_node_hook_list *cgraph_add_function_insertion_hook(cgraph_node_hook hook, void *data)
 {
 	return symtab->add_cgraph_insertion_hook(hook, data);
@@ -731,6 +794,13 @@ static inline gimple gimple_build_assign
 
 template <>
 template <>
+inline bool is_a_helper<const ggoto *>::test(const_gimple gs)
+{
+	return gs->code == GIMPLE_GOTO;
+}
+
+template <>
+template <>
 inline bool is_a_helper<const greturn *>::test(const_gimple gs)
 {
 	return gs->code == GIMPLE_RETURN;
@@ -766,6 +836,16 @@ static inline const gcall *as_a_const_gc
 	return as_a<const gcall *>(stmt);
 }
 
+static inline ggoto *as_a_ggoto(gimple stmt)
+{
+	return as_a<ggoto *>(stmt);
+}
+
+static inline const ggoto *as_a_const_ggoto(const_gimple stmt)
+{
+	return as_a<const ggoto *>(stmt);
+}
+
 static inline gphi *as_a_gphi(gimple stmt)
 {
 	return as_a<gphi *>(stmt);
@@ -828,4 +908,9 @@ static inline void debug_gimple_stmt(con
 #define debug_gimple_stmt(s) debug_gimple_stmt(CONST_CAST_GIMPLE(s))
 #endif
 
+#if BUILDING_GCC_VERSION >= 7000
+#define get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep, keep_aligning)	\
+	get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep)
+#endif
+
 #endif

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 021/206] KVM: x86: reset MMU on KVM_SET_VCPU_EVENTS
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (14 preceding siblings ...)
  2017-01-10 13:34   ` [PATCH 4.9 016/206] gcc-plugins: update gcc-common.h for gcc-7 Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 024/206] usb: musb: core: add clear_ep_rxintr() to musb_platform_ops Greg Kroah-Hartman
                     ` (173 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Xiao Guangrong, Paolo Bonzini

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Xiao Guangrong <guangrong.xiao@linux.intel.com>

commit 6ef4e07ecd2db21025c446327ecf34414366498b upstream.

Otherwise, mismatch between the smm bit in hflags and the MMU role
can cause a NULL pointer dereference.

Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/x86/kvm/x86.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3036,6 +3036,8 @@ static void kvm_vcpu_ioctl_x86_get_vcpu_
 	memset(&events->reserved, 0, sizeof(events->reserved));
 }
 
+static void kvm_set_hflags(struct kvm_vcpu *vcpu, unsigned emul_flags);
+
 static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu,
 					      struct kvm_vcpu_events *events)
 {
@@ -3072,10 +3074,13 @@ static int kvm_vcpu_ioctl_x86_set_vcpu_e
 		vcpu->arch.apic->sipi_vector = events->sipi_vector;
 
 	if (events->flags & KVM_VCPUEVENT_VALID_SMM) {
+		u32 hflags = vcpu->arch.hflags;
 		if (events->smi.smm)
-			vcpu->arch.hflags |= HF_SMM_MASK;
+			hflags |= HF_SMM_MASK;
 		else
-			vcpu->arch.hflags &= ~HF_SMM_MASK;
+			hflags &= ~HF_SMM_MASK;
+		kvm_set_hflags(vcpu, hflags);
+
 		vcpu->arch.smi_pending = events->smi.pending;
 		if (events->smi.smm_inside_nmi)
 			vcpu->arch.hflags |= HF_SMM_INSIDE_NMI_MASK;

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 024/206] usb: musb: core: add clear_ep_rxintr() to musb_platform_ops
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (15 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 021/206] KVM: x86: reset MMU on KVM_SET_VCPU_EVENTS Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 025/206] usb: musb: dsps: implement clear_ep_rxintr() callback Greg Kroah-Hartman
                     ` (172 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Bin Liu

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Bin Liu <b-liu@ti.com>

commit 6def85a396ce7796bd9f4561c6ae8138833f7a52 upstream.

During dma teardown for dequque urb, if musb load is high, musb might
generate bogus rx ep interrupt even when the rx fifo is flushed. In such
case any of the follow log messages could happen.

	musb_host_rx 1853: BOGUS RX2 ready, csr 0000, count 0

	musb_host_rx 1936: RX3 dma busy, csr 2020

As mentioned in the current inline comment, clearing ep interrupt in the
teardown path avoids the bogus interrupt.

Clearing ep interrupt is platform dependent, so this patch adds a
platform callback to allow glue driver to clear the ep interrupt.

This bug seems to be existing since the initial driver for musb support,
but I only validated the fix back to v4.1, so only cc stable for v4.1+.

Signed-off-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/musb/musb_core.h |    7 +++++++
 drivers/usb/musb/musb_host.c |   10 ++++------
 2 files changed, 11 insertions(+), 6 deletions(-)

--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -216,6 +216,7 @@ struct musb_platform_ops {
 	void	(*pre_root_reset_end)(struct musb *musb);
 	void	(*post_root_reset_end)(struct musb *musb);
 	int	(*phy_callback)(enum musb_vbus_id_status status);
+	void	(*clear_ep_rxintr)(struct musb *musb, int epnum);
 };
 
 /*
@@ -626,4 +627,10 @@ static inline void musb_platform_post_ro
 		musb->ops->post_root_reset_end(musb);
 }
 
+static inline void musb_platform_clear_ep_rxintr(struct musb *musb, int epnum)
+{
+	if (musb->ops->clear_ep_rxintr)
+		musb->ops->clear_ep_rxintr(musb, epnum);
+}
+
 #endif	/* __MUSB_CORE_H__ */
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -2374,12 +2374,11 @@ static int musb_cleanup_urb(struct urb *
 	int			is_in = usb_pipein(urb->pipe);
 	int			status = 0;
 	u16			csr;
+	struct dma_channel	*dma = NULL;
 
 	musb_ep_select(regs, hw_end);
 
 	if (is_dma_capable()) {
-		struct dma_channel	*dma;
-
 		dma = is_in ? ep->rx_channel : ep->tx_channel;
 		if (dma) {
 			status = ep->musb->dma_controller->channel_abort(dma);
@@ -2395,10 +2394,9 @@ static int musb_cleanup_urb(struct urb *
 		/* giveback saves bulk toggle */
 		csr = musb_h_flush_rxfifo(ep, 0);
 
-		/* REVISIT we still get an irq; should likely clear the
-		 * endpoint's irq status here to avoid bogus irqs.
-		 * clearing that status is platform-specific...
-		 */
+		/* clear the endpoint's irq status here to avoid bogus irqs */
+		if (is_dma_capable() && dma)
+			musb_platform_clear_ep_rxintr(musb, ep->epnum);
 	} else if (ep->epnum) {
 		musb_h_tx_flush_fifo(ep);
 		csr = musb_readw(epio, MUSB_TXCSR);

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 025/206] usb: musb: dsps: implement clear_ep_rxintr() callback
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (16 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 024/206] usb: musb: core: add clear_ep_rxintr() to musb_platform_ops Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 026/206] usb: storage: unusual_uas: Add JMicron JMS56x to unusual device Greg Kroah-Hartman
                     ` (171 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Bin Liu

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Bin Liu <b-liu@ti.com>

commit c48400baa02155a5ddad63e8554602e48782278c upstream.

During dma teardown for dequque urb, if musb load is high, musb might
generate bogus rx ep interrupt even when the rx fifo is flushed. In such
case any of the follow log messages could happen.

    musb_host_rx 1853: BOGUS RX2 ready, csr 0000, count 0

    musb_host_rx 1936: RX3 dma busy, csr 2020

As mentioned in the current inline comment, clearing ep interrupt in the
teardown path avoids the bogus interrupt, so implement clear_ep_rxintr()
callback.

This bug seems to be existing since the initial driver for musb support,
but I only validated the fix back to v4.1, so only cc stable for v4.1+.

Signed-off-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/musb/musb_dsps.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)

--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -267,6 +267,17 @@ static void otg_timer(unsigned long _mus
 	pm_runtime_put_autosuspend(dev);
 }
 
+void dsps_musb_clear_ep_rxintr(struct musb *musb, int epnum)
+{
+	u32 epintr;
+	struct dsps_glue *glue = dev_get_drvdata(musb->controller->parent);
+	const struct dsps_musb_wrapper *wrp = glue->wrp;
+
+	/* musb->lock might already been held */
+	epintr = (1 << epnum) << wrp->rxep_shift;
+	musb_writel(musb->ctrl_base, wrp->epintr_status, epintr);
+}
+
 static irqreturn_t dsps_interrupt(int irq, void *hci)
 {
 	struct musb  *musb = hci;
@@ -622,6 +633,7 @@ static struct musb_platform_ops dsps_ops
 
 	.set_mode	= dsps_musb_set_mode,
 	.recover	= dsps_musb_recover,
+	.clear_ep_rxintr = dsps_musb_clear_ep_rxintr,
 };
 
 static u64 musb_dmamask = DMA_BIT_MASK(32);

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 026/206] usb: storage: unusual_uas: Add JMicron JMS56x to unusual device
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (17 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 025/206] usb: musb: dsps: implement clear_ep_rxintr() callback Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 027/206] usb: gadgetfs: restrict upper bound on device configuration size Greg Kroah-Hartman
                     ` (170 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, George Cherian, Oliver Neukum

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Oliver Neukum <oneukum@suse.com>

commit 674aea07e38200ea6f31ff6d5f200f0cf6cdb325 upstream.

This device gives the following error on detection.
xhci_hcd 0000:00:11.0: ERROR Transfer event for disabled endpoint or
incorrect stream ring

The same error is not seen when it is added to unusual_device
list with US_FL_NO_REPORT_OPCODES passed.

Signed-off-by: George Cherian <george.cherian@cavium.com>
Signed-off-by: Oliver Neukum <oneukun@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/storage/unusual_devs.h |    7 +++++++
 1 file changed, 7 insertions(+)

--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -2109,6 +2109,13 @@ UNUSUAL_DEV(  0x152d, 0x2566, 0x0114, 0x
 		USB_SC_DEVICE, USB_PR_DEVICE, NULL,
 		US_FL_BROKEN_FUA ),
 
+/* Reported-by George Cherian <george.cherian@cavium.com> */
+UNUSUAL_DEV(0x152d, 0x9561, 0x0000, 0x9999,
+		"JMicron",
+		"JMS56x",
+		USB_SC_DEVICE, USB_PR_DEVICE, NULL,
+		US_FL_NO_REPORT_OPCODES),
+
 /*
  * Entrega Technologies U1-SC25 (later Xircom PortGear PGSCSI)
  * and Mac USB Dock USB-SCSI */

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 027/206] usb: gadgetfs: restrict upper bound on device configuration size
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (18 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 026/206] usb: storage: unusual_uas: Add JMicron JMS56x to unusual device Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 028/206] USB: gadgetfs: fix unbounded memory allocation bug Greg Kroah-Hartman
                     ` (169 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Andrey Konovalov, Felipe Balbi

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0994b0a257557e18ee8f0b7c5f0f73fe2b54eec1 upstream.

Andrey Konovalov reported that we were not properly checking the upper
limit before of a device configuration size before calling
memdup_user(), which could cause some problems.

So set the upper limit to PAGE_SIZE * 4, which should be good enough for
all devices.

Reported-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/gadget/legacy/inode.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/drivers/usb/gadget/legacy/inode.c
+++ b/drivers/usb/gadget/legacy/inode.c
@@ -1762,7 +1762,8 @@ dev_config (struct file *fd, const char
 	}
 	spin_unlock_irq(&dev->lock);
 
-	if (len < (USB_DT_CONFIG_SIZE + USB_DT_DEVICE_SIZE + 4))
+	if ((len < (USB_DT_CONFIG_SIZE + USB_DT_DEVICE_SIZE + 4)) ||
+	    (len > PAGE_SIZE * 4))
 		return -EINVAL;
 
 	/* we might need to change message format someday */

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 028/206] USB: gadgetfs: fix unbounded memory allocation bug
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (19 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 027/206] usb: gadgetfs: restrict upper bound on device configuration size Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 029/206] USB: gadgetfs: fix use-after-free bug Greg Kroah-Hartman
                     ` (168 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Alan Stern, Andrey Konovalov, Felipe Balbi

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Alan Stern <stern@rowland.harvard.edu>

commit faab50984fe6636e616c7cc3d30308ba391d36fd upstream.

Andrey Konovalov reports that fuzz testing with syzkaller causes a
KASAN warning in gadgetfs:

BUG: KASAN: slab-out-of-bounds in dev_config+0x86f/0x1190 at addr ffff88003c47e160
Write of size 65537 by task syz-executor0/6356
CPU: 3 PID: 6356 Comm: syz-executor0 Not tainted 4.9.0-rc7+ #19
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
 ffff88003c107ad8 ffffffff81f96aba ffffffff3dc11ef0 1ffff10007820eee
 ffffed0007820ee6 ffff88003dc11f00 0000000041b58ab3 ffffffff8598b4c8
 ffffffff81f96828 ffffffff813fb4a0 ffff88003b6eadc0 ffff88003c107738
Call Trace:
 [<     inline     >] __dump_stack lib/dump_stack.c:15
 [<ffffffff81f96aba>] dump_stack+0x292/0x398 lib/dump_stack.c:51
 [<ffffffff817e4dec>] kasan_object_err+0x1c/0x70 mm/kasan/report.c:159
 [<     inline     >] print_address_description mm/kasan/report.c:197
 [<ffffffff817e5080>] kasan_report_error+0x1f0/0x4e0 mm/kasan/report.c:286
 [<ffffffff817e5705>] kasan_report+0x35/0x40 mm/kasan/report.c:306
 [<     inline     >] check_memory_region_inline mm/kasan/kasan.c:308
 [<ffffffff817e3fb9>] check_memory_region+0x139/0x190 mm/kasan/kasan.c:315
 [<ffffffff817e4044>] kasan_check_write+0x14/0x20 mm/kasan/kasan.c:326
 [<     inline     >] copy_from_user arch/x86/include/asm/uaccess.h:689
 [<     inline     >] ep0_write drivers/usb/gadget/legacy/inode.c:1135
 [<ffffffff83228caf>] dev_config+0x86f/0x1190 drivers/usb/gadget/legacy/inode.c:1759
 [<ffffffff817fdd55>] __vfs_write+0x5d5/0x760 fs/read_write.c:510
 [<ffffffff817ff650>] vfs_write+0x170/0x4e0 fs/read_write.c:560
 [<     inline     >] SYSC_write fs/read_write.c:607
 [<ffffffff81803a5b>] SyS_write+0xfb/0x230 fs/read_write.c:599
 [<ffffffff84f47ec1>] entry_SYSCALL_64_fastpath+0x1f/0xc2

Indeed, there is a comment saying that the value of len is restricted
to a 16-bit integer, but the code doesn't actually do this.

This patch fixes the warning.  It replaces the comment with a
computation that forces the amount of data copied from the user in
ep0_write() to be no larger than the wLength size for the control
transfer, which is a 16-bit quantity.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Reported-by: Andrey Konovalov <andreyknvl@google.com>
Tested-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/gadget/legacy/inode.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/usb/gadget/legacy/inode.c
+++ b/drivers/usb/gadget/legacy/inode.c
@@ -1126,7 +1126,7 @@ ep0_write (struct file *fd, const char _
 	/* data and/or status stage for control request */
 	} else if (dev->state == STATE_DEV_SETUP) {
 
-		/* IN DATA+STATUS caller makes len <= wLength */
+		len = min_t(size_t, len, dev->setup_wLength);
 		if (dev->setup_in) {
 			retval = setup_req (dev->gadget->ep0, dev->req, len);
 			if (retval == 0) {

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 029/206] USB: gadgetfs: fix use-after-free bug
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (20 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 028/206] USB: gadgetfs: fix unbounded memory allocation bug Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 030/206] USB: gadgetfs: fix checks of wTotalLength in config descriptors Greg Kroah-Hartman
                     ` (167 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Alan Stern, Andrey Konovalov, Felipe Balbi

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Alan Stern <stern@rowland.harvard.edu>

commit add333a81a16abbd4f106266a2553677a165725f upstream.

Andrey Konovalov reports that fuzz testing with syzkaller causes a
KASAN use-after-free bug report in gadgetfs:

BUG: KASAN: use-after-free in gadgetfs_setup+0x208a/0x20e0 at addr ffff88003dfe5bf2
Read of size 2 by task syz-executor0/22994
CPU: 3 PID: 22994 Comm: syz-executor0 Not tainted 4.9.0-rc7+ #16
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
 ffff88006df06a18 ffffffff81f96aba ffffffffe0528500 1ffff1000dbe0cd6
 ffffed000dbe0cce ffff88006df068f0 0000000041b58ab3 ffffffff8598b4c8
 ffffffff81f96828 1ffff1000dbe0ccd ffff88006df06708 ffff88006df06748
Call Trace:
 <IRQ> [  201.343209]  [<     inline     >] __dump_stack lib/dump_stack.c:15
 <IRQ> [  201.343209]  [<ffffffff81f96aba>] dump_stack+0x292/0x398 lib/dump_stack.c:51
 [<ffffffff817e4dec>] kasan_object_err+0x1c/0x70 mm/kasan/report.c:159
 [<     inline     >] print_address_description mm/kasan/report.c:197
 [<ffffffff817e5080>] kasan_report_error+0x1f0/0x4e0 mm/kasan/report.c:286
 [<     inline     >] kasan_report mm/kasan/report.c:306
 [<ffffffff817e562a>] __asan_report_load_n_noabort+0x3a/0x40 mm/kasan/report.c:337
 [<     inline     >] config_buf drivers/usb/gadget/legacy/inode.c:1298
 [<ffffffff8322c8fa>] gadgetfs_setup+0x208a/0x20e0 drivers/usb/gadget/legacy/inode.c:1368
 [<ffffffff830fdcd0>] dummy_timer+0x11f0/0x36d0 drivers/usb/gadget/udc/dummy_hcd.c:1858
 [<ffffffff814807c1>] call_timer_fn+0x241/0x800 kernel/time/timer.c:1308
 [<     inline     >] expire_timers kernel/time/timer.c:1348
 [<ffffffff81482de6>] __run_timers+0xa06/0xec0 kernel/time/timer.c:1641
 [<ffffffff814832c1>] run_timer_softirq+0x21/0x80 kernel/time/timer.c:1654
 [<ffffffff84f4af8b>] __do_softirq+0x2fb/0xb63 kernel/softirq.c:284

The cause of the bug is subtle.  The dev_config() routine gets called
twice by the fuzzer.  The first time, the user data contains both a
full-speed configuration descriptor and a high-speed config
descriptor, causing dev->hs_config to be set.  But it also contains an
invalid device descriptor, so the buffer containing the descriptors is
deallocated and dev_config() returns an error.

The second time dev_config() is called, the user data contains only a
full-speed config descriptor.  But dev->hs_config still has the stale
pointer remaining from the first call, causing the routine to think
that there is a valid high-speed config.  Later on, when the driver
dereferences the stale pointer to copy that descriptor, we get a
use-after-free access.

The fix is simple: Clear dev->hs_config if the passed-in data does not
contain a high-speed config descriptor.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Reported-by: Andrey Konovalov <andreyknvl@google.com>
Tested-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/gadget/legacy/inode.c |    2 ++
 1 file changed, 2 insertions(+)

--- a/drivers/usb/gadget/legacy/inode.c
+++ b/drivers/usb/gadget/legacy/inode.c
@@ -1800,6 +1800,8 @@ dev_config (struct file *fd, const char
 			goto fail;
 		kbuf += total;
 		length -= total;
+	} else {
+		dev->hs_config = NULL;
 	}
 
 	/* could support multiple configs, using another encoding! */

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 030/206] USB: gadgetfs: fix checks of wTotalLength in config descriptors
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (21 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 029/206] USB: gadgetfs: fix use-after-free bug Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 031/206] USB: fix problems with duplicate endpoint addresses Greg Kroah-Hartman
                     ` (166 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Alan Stern, Andrey Konovalov, Felipe Balbi

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Alan Stern <stern@rowland.harvard.edu>

commit 1c069b057dcf64fada952eaa868d35f02bb0cfc2 upstream.

Andrey Konovalov's fuzz testing of gadgetfs showed that we should
improve the driver's checks for valid configuration descriptors passed
in by the user.  In particular, the driver needs to verify that the
wTotalLength value in the descriptor is not too short (smaller
than USB_DT_CONFIG_SIZE).  And the check for whether wTotalLength is
too large has to be changed, because the driver assumes there is
always enough room remaining in the buffer to hold a device descriptor
(at least USB_DT_DEVICE_SIZE bytes).

This patch adds the additional check and fixes the existing check.  It
may do a little more than strictly necessary, but one extra check
won't hurt.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/gadget/legacy/inode.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

--- a/drivers/usb/gadget/legacy/inode.c
+++ b/drivers/usb/gadget/legacy/inode.c
@@ -1734,10 +1734,12 @@ static struct usb_gadget_driver gadgetfs
  * such as configuration notifications.
  */
 
-static int is_valid_config (struct usb_config_descriptor *config)
+static int is_valid_config(struct usb_config_descriptor *config,
+		unsigned int total)
 {
 	return config->bDescriptorType == USB_DT_CONFIG
 		&& config->bLength == USB_DT_CONFIG_SIZE
+		&& total >= USB_DT_CONFIG_SIZE
 		&& config->bConfigurationValue != 0
 		&& (config->bmAttributes & USB_CONFIG_ATT_ONE) != 0
 		&& (config->bmAttributes & USB_CONFIG_ATT_WAKEUP) == 0;
@@ -1787,7 +1789,8 @@ dev_config (struct file *fd, const char
 	/* full or low speed config */
 	dev->config = (void *) kbuf;
 	total = le16_to_cpu(dev->config->wTotalLength);
-	if (!is_valid_config (dev->config) || total >= length)
+	if (!is_valid_config(dev->config, total) ||
+			total > length - USB_DT_DEVICE_SIZE)
 		goto fail;
 	kbuf += total;
 	length -= total;
@@ -1796,7 +1799,8 @@ dev_config (struct file *fd, const char
 	if (kbuf [1] == USB_DT_CONFIG) {
 		dev->hs_config = (void *) kbuf;
 		total = le16_to_cpu(dev->hs_config->wTotalLength);
-		if (!is_valid_config (dev->hs_config) || total >= length)
+		if (!is_valid_config(dev->hs_config, total) ||
+				total > length - USB_DT_DEVICE_SIZE)
 			goto fail;
 		kbuf += total;
 		length -= total;

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 031/206] USB: fix problems with duplicate endpoint addresses
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (22 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 030/206] USB: gadgetfs: fix checks of wTotalLength in config descriptors Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 032/206] USB: dummy-hcd: fix bug in stop_activity (handle ep0) Greg Kroah-Hartman
                     ` (165 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Alan Stern, Andrey Konovalov

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Alan Stern <stern@rowland.harvard.edu>

commit 0a8fd1346254974c3a852338508e4a4cddbb35f1 upstream.

When checking a new device's descriptors, the USB core does not check
for duplicate endpoint addresses.  This can cause a problem when the
sysfs files for those endpoints are created; trying to create multiple
files with the same name will provoke a WARNING:

WARNING: CPU: 2 PID: 865 at fs/sysfs/dir.c:31 sysfs_warn_dup+0x8a/0xa0
sysfs: cannot create duplicate filename
'/devices/platform/dummy_hcd.0/usb2/2-1/2-1:64.0/ep_05'
Kernel panic - not syncing: panic_on_warn set ...

CPU: 2 PID: 865 Comm: kworker/2:1 Not tainted 4.9.0-rc7+ #34
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
Workqueue: usb_hub_wq hub_event
 ffff88006bee64c8 ffffffff81f96b8a ffffffff00000001 1ffff1000d7dcc2c
 ffffed000d7dcc24 0000000000000001 0000000041b58ab3 ffffffff8598b510
 ffffffff81f968f8 ffffffff850fee20 ffffffff85cff020 dffffc0000000000
Call Trace:
 [<     inline     >] __dump_stack lib/dump_stack.c:15
 [<ffffffff81f96b8a>] dump_stack+0x292/0x398 lib/dump_stack.c:51
 [<ffffffff8168c88e>] panic+0x1cb/0x3a9 kernel/panic.c:179
 [<ffffffff812b80b4>] __warn+0x1c4/0x1e0 kernel/panic.c:542
 [<ffffffff812b8195>] warn_slowpath_fmt+0xc5/0x110 kernel/panic.c:565
 [<ffffffff819e70ca>] sysfs_warn_dup+0x8a/0xa0 fs/sysfs/dir.c:30
 [<ffffffff819e7308>] sysfs_create_dir_ns+0x178/0x1d0 fs/sysfs/dir.c:59
 [<     inline     >] create_dir lib/kobject.c:71
 [<ffffffff81fa1b07>] kobject_add_internal+0x227/0xa60 lib/kobject.c:229
 [<     inline     >] kobject_add_varg lib/kobject.c:366
 [<ffffffff81fa2479>] kobject_add+0x139/0x220 lib/kobject.c:411
 [<ffffffff82737a63>] device_add+0x353/0x1660 drivers/base/core.c:1088
 [<ffffffff82738d8d>] device_register+0x1d/0x20 drivers/base/core.c:1206
 [<ffffffff82cb77d3>] usb_create_ep_devs+0x163/0x260 drivers/usb/core/endpoint.c:195
 [<ffffffff82c9f27b>] create_intf_ep_devs+0x13b/0x200 drivers/usb/core/message.c:1030
 [<ffffffff82ca39d3>] usb_set_configuration+0x1083/0x18d0 drivers/usb/core/message.c:1937
 [<ffffffff82cc9e2e>] generic_probe+0x6e/0xe0 drivers/usb/core/generic.c:172
 [<ffffffff82caa7fa>] usb_probe_device+0xaa/0xe0 drivers/usb/core/driver.c:263

This patch prevents the problem by checking for duplicate endpoint
addresses during enumeration and skipping any duplicates.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Reported-by: Andrey Konovalov <andreyknvl@google.com>
Tested-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/core/config.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -234,6 +234,16 @@ static int usb_parse_endpoint(struct dev
 	if (ifp->desc.bNumEndpoints >= num_ep)
 		goto skip_to_next_endpoint_or_interface_descriptor;
 
+	/* Check for duplicate endpoint addresses */
+	for (i = 0; i < ifp->desc.bNumEndpoints; ++i) {
+		if (ifp->endpoint[i].desc.bEndpointAddress ==
+		    d->bEndpointAddress) {
+			dev_warn(ddev, "config %d interface %d altsetting %d has a duplicate endpoint with address 0x%X, skipping\n",
+			    cfgno, inum, asnum, d->bEndpointAddress);
+			goto skip_to_next_endpoint_or_interface_descriptor;
+		}
+	}
+
 	endpoint = &ifp->endpoint[ifp->desc.bNumEndpoints];
 	++ifp->desc.bNumEndpoints;
 

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 032/206] USB: dummy-hcd: fix bug in stop_activity (handle ep0)
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (23 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 031/206] USB: fix problems with duplicate endpoint addresses Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 033/206] usb: gadget: composite: Test get_alt() presence instead of set_alt() Greg Kroah-Hartman
                     ` (164 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Alan Stern, Andrey Konovalov, Felipe Balbi

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Alan Stern <stern@rowland.harvard.edu>

commit bcdbeb844773333d2d1c08004f3b3e25921040e5 upstream.

The stop_activity() routine in dummy-hcd is supposed to unlink all
active requests for every endpoint, among other things.  But it
doesn't handle ep0.  As a result, fuzz testing can generate a WARNING
like the following:

WARNING: CPU: 0 PID: 4410 at drivers/usb/gadget/udc/dummy_hcd.c:672 dummy_free_request+0x153/0x170
Modules linked in:
CPU: 0 PID: 4410 Comm: syz-executor Not tainted 4.9.0-rc7+ #32
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
 ffff88006a64ed10 ffffffff81f96b8a ffffffff41b58ab3 1ffff1000d4c9d35
 ffffed000d4c9d2d ffff880065f8ac00 0000000041b58ab3 ffffffff8598b510
 ffffffff81f968f8 0000000041b58ab3 ffffffff859410e0 ffffffff813f0590
Call Trace:
 [<     inline     >] __dump_stack lib/dump_stack.c:15
 [<ffffffff81f96b8a>] dump_stack+0x292/0x398 lib/dump_stack.c:51
 [<ffffffff812b808f>] __warn+0x19f/0x1e0 kernel/panic.c:550
 [<ffffffff812b831c>] warn_slowpath_null+0x2c/0x40 kernel/panic.c:585
 [<ffffffff830fcb13>] dummy_free_request+0x153/0x170 drivers/usb/gadget/udc/dummy_hcd.c:672
 [<ffffffff830ed1b0>] usb_ep_free_request+0xc0/0x420 drivers/usb/gadget/udc/core.c:195
 [<ffffffff83225031>] gadgetfs_unbind+0x131/0x190 drivers/usb/gadget/legacy/inode.c:1612
 [<ffffffff830ebd8f>] usb_gadget_remove_driver+0x10f/0x2b0 drivers/usb/gadget/udc/core.c:1228
 [<ffffffff830ec084>] usb_gadget_unregister_driver+0x154/0x240 drivers/usb/gadget/udc/core.c:1357

This patch fixes the problem by iterating over all the endpoints in
the driver's ep array instead of iterating over the gadget's ep_list,
which explicitly leaves out ep0.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Reported-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/gadget/udc/dummy_hcd.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- a/drivers/usb/gadget/udc/dummy_hcd.c
+++ b/drivers/usb/gadget/udc/dummy_hcd.c
@@ -330,7 +330,7 @@ static void nuke(struct dummy *dum, stru
 /* caller must hold lock */
 static void stop_activity(struct dummy *dum)
 {
-	struct dummy_ep	*ep;
+	int i;
 
 	/* prevent any more requests */
 	dum->address = 0;
@@ -338,8 +338,8 @@ static void stop_activity(struct dummy *
 	/* The timer is left running so that outstanding URBs can fail */
 
 	/* nuke any pending requests first, so driver i/o is quiesced */
-	list_for_each_entry(ep, &dum->gadget.ep_list, ep.ep_list)
-		nuke(dum, ep);
+	for (i = 0; i < DUMMY_ENDPOINTS; ++i)
+		nuke(dum, &dum->ep[i]);
 
 	/* driver now does any non-usb quiescing necessary */
 }

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 033/206] usb: gadget: composite: Test get_alt() presence instead of set_alt()
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (24 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 032/206] USB: dummy-hcd: fix bug in stop_activity (handle ep0) Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 034/206] usb: dwc3: core: avoid Overflow events Greg Kroah-Hartman
                     ` (163 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Krzysztof Opasiak, Felipe Balbi

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Krzysztof Opasiak <k.opasiak@samsung.com>

commit 7e4da3fcf7c9fe042f2f7cb7bf23861a899b4a8f upstream.

By convention (according to doc) if function does not provide
get_alt() callback composite framework should assume that it has only
altsetting 0 and should respond with error if host tries to set
other one.

After commit dd4dff8b035f ("USB: composite: Fix bug: should test
set_alt function pointer before use it")
we started checking set_alt() callback instead of get_alt().
This check is useless as we check if set_alt() is set inside
usb_add_function() and fail if it's NULL.

Let's fix this check and move comment about why we check the get
method instead of set a little bit closer to prevent future false
fixes.

Fixes: dd4dff8b035f ("USB: composite: Fix bug: should test set_alt function pointer before use it")
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/gadget/composite.c |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -1694,9 +1694,7 @@ composite_setup(struct usb_gadget *gadge
 		value = min(w_length, (u16) 1);
 		break;
 
-	/* function drivers must handle get/set altsetting; if there's
-	 * no get() method, we know only altsetting zero works.
-	 */
+	/* function drivers must handle get/set altsetting */
 	case USB_REQ_SET_INTERFACE:
 		if (ctrl->bRequestType != USB_RECIP_INTERFACE)
 			goto unknown;
@@ -1705,7 +1703,13 @@ composite_setup(struct usb_gadget *gadge
 		f = cdev->config->interface[intf];
 		if (!f)
 			break;
-		if (w_value && !f->set_alt)
+
+		/*
+		 * If there's no get_alt() method, we know only altsetting zero
+		 * works. There is no need to check if set_alt() is not NULL
+		 * as we check this in usb_add_function().
+		 */
+		if (w_value && !f->get_alt)
 			break;
 		value = f->set_alt(f, w_index, w_value);
 		if (value == USB_GADGET_DELAYED_STATUS) {

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 034/206] usb: dwc3: core: avoid Overflow events
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (25 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 033/206] usb: gadget: composite: Test get_alt() presence instead of set_alt() Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 035/206] usb: xhci: fix possible wild pointer Greg Kroah-Hartman
                     ` (162 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Felipe Balbi

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Felipe Balbi <felipe.balbi@linux.intel.com>

commit e71d363d9c611c99fb78f53bfee99616e7fe352c upstream.

Now that we're handling so many transfers at a time
and for some dwc3 revisions LPM events *must* be
enabled, we can fall into a situation where too many
events fire and we start receiving Overflow events.

Let's do what XHCI does and allocate a full page for
the Event Ring, this will avoid any future issues.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/dwc3/core.h |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -43,9 +43,7 @@
 #define DWC3_XHCI_RESOURCES_NUM	2
 
 #define DWC3_SCRATCHBUF_SIZE	4096	/* each buffer is assumed to be 4KiB */
-#define DWC3_EVENT_SIZE		4	/* bytes */
-#define DWC3_EVENT_MAX_NUM	64	/* 2 events/endpoint */
-#define DWC3_EVENT_BUFFERS_SIZE	(DWC3_EVENT_SIZE * DWC3_EVENT_MAX_NUM)
+#define DWC3_EVENT_BUFFERS_SIZE	4096
 #define DWC3_EVENT_TYPE_MASK	0xfe
 
 #define DWC3_EVENT_TYPE_DEV	0

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 035/206] usb: xhci: fix possible wild pointer
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (26 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 034/206] usb: dwc3: core: avoid Overflow events Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 036/206] usb: xhci: apply XHCI_PME_STUCK_QUIRK to Intel Apollo Lake Greg Kroah-Hartman
                     ` (161 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Lu Baolu, Mathias Nyman

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Lu Baolu <baolu.lu@linux.intel.com>

commit 2b985467371a58ae44d76c7ba12b0951fee6ed98 upstream.

handle_cmd_completion() frees a command structure which might be still
referenced by xhci->current_cmd.
This might cause problem when xhci->current_cmd is accessed after that.

A real-life case could be like this. The host takes a very long time to
respond to a command, and the command timer is fired at the same time
when the command completion event arrives. The command completion
handler frees xhci->current_cmd before the timer function can grab
xhci->lock. Afterward, timer function grabs the lock and go ahead with
checking and setting members of xhci->current_cmd.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/host/xhci-ring.c |   16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -1271,14 +1271,18 @@ void xhci_handle_command_timeout(unsigne
 	bool second_timeout = false;
 	xhci = (struct xhci_hcd *) data;
 
-	/* mark this command to be cancelled */
 	spin_lock_irqsave(&xhci->lock, flags);
-	if (xhci->current_cmd) {
-		if (xhci->current_cmd->status == COMP_CMD_ABORT)
-			second_timeout = true;
-		xhci->current_cmd->status = COMP_CMD_ABORT;
+
+	if (!xhci->current_cmd) {
+		spin_unlock_irqrestore(&xhci->lock, flags);
+		return;
 	}
 
+	/* mark this command to be cancelled */
+	if (xhci->current_cmd->status == COMP_CMD_ABORT)
+		second_timeout = true;
+	xhci->current_cmd->status = COMP_CMD_ABORT;
+
 	/* Make sure command ring is running before aborting it */
 	hw_ring_state = xhci_read_64(xhci, &xhci->op_regs->cmd_ring);
 	if ((xhci->cmd_ring_state & CMD_RING_STATE_RUNNING) &&
@@ -1427,6 +1431,8 @@ static void handle_cmd_completion(struct
 		xhci->current_cmd = list_entry(cmd->cmd_list.next,
 					       struct xhci_command, cmd_list);
 		mod_timer(&xhci->cmd_timer, jiffies + XHCI_CMD_DEFAULT_TIMEOUT);
+	} else if (xhci->current_cmd == cmd) {
+		xhci->current_cmd = NULL;
 	}
 
 event_handled:

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 036/206] usb: xhci: apply XHCI_PME_STUCK_QUIRK to Intel Apollo Lake
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (27 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 035/206] usb: xhci: fix possible wild pointer Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 037/206] xhci: free xhci virtual devices with leaf nodes first Greg Kroah-Hartman
                     ` (160 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Wan Ahmad Zainie, Mathias Nyman

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Wan Ahmad Zainie <wan.ahmad.zainie.wan.mohamad@intel.com>

commit 6c97cfc1a097b1e0786c836e92b7a72b4d031e25 upstream.

Intel Apollo Lake also requires XHCI_PME_STUCK_QUIRK.
Adding its PCI ID to quirk.

Signed-off-by: Wan Ahmad Zainie <wan.ahmad.zainie.wan.mohamad@intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/host/xhci-pci.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -165,7 +165,8 @@ static void xhci_pci_quirks(struct devic
 		 pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI ||
 		 pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI ||
 		 pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI ||
-		 pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI)) {
+		 pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI ||
+		 pdev->device == PCI_DEVICE_ID_INTEL_APL_XHCI)) {
 		xhci->quirks |= XHCI_PME_STUCK_QUIRK;
 	}
 	if (pdev->vendor == PCI_VENDOR_ID_INTEL &&

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 037/206] xhci: free xhci virtual devices with leaf nodes first
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (28 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 036/206] usb: xhci: apply XHCI_PME_STUCK_QUIRK to Intel Apollo Lake Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 038/206] usb: xhci: fix return value of xhci_setup_device() Greg Kroah-Hartman
                     ` (159 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Guenter Roeck, Mathias Nyman

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Mathias Nyman <mathias.nyman@linux.intel.com>

commit ee8665e28e8d90ce69d4abe5a469c14a8707ae0e upstream.

the tt_info provided by a HS hub might be in use to by a child device
Make sure we free the devices in the correct order.

This is needed in special cases such as when xhci controller is
reset when resuming from hibernate, and all virt_devices are freed.

Also free the virt_devices starting from max slot_id as children
more commonly have higher slot_id than parent.

Reported-by: Guenter Roeck <groeck@chromium.org>
Tested-by: Guenter Roeck <groeck@chromium.org>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/host/xhci-mem.c |   38 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 36 insertions(+), 2 deletions(-)

--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -979,6 +979,40 @@ void xhci_free_virt_device(struct xhci_h
 	xhci->devs[slot_id] = NULL;
 }
 
+/*
+ * Free a virt_device structure.
+ * If the virt_device added a tt_info (a hub) and has children pointing to
+ * that tt_info, then free the child first. Recursive.
+ * We can't rely on udev at this point to find child-parent relationships.
+ */
+void xhci_free_virt_devices_depth_first(struct xhci_hcd *xhci, int slot_id)
+{
+	struct xhci_virt_device *vdev;
+	struct list_head *tt_list_head;
+	struct xhci_tt_bw_info *tt_info, *next;
+	int i;
+
+	vdev = xhci->devs[slot_id];
+	if (!vdev)
+		return;
+
+	tt_list_head = &(xhci->rh_bw[vdev->real_port - 1].tts);
+	list_for_each_entry_safe(tt_info, next, tt_list_head, tt_list) {
+		/* is this a hub device that added a tt_info to the tts list */
+		if (tt_info->slot_id == slot_id) {
+			/* are any devices using this tt_info? */
+			for (i = 1; i < HCS_MAX_SLOTS(xhci->hcs_params1); i++) {
+				vdev = xhci->devs[i];
+				if (vdev && (vdev->tt_info == tt_info))
+					xhci_free_virt_devices_depth_first(
+						xhci, i);
+			}
+		}
+	}
+	/* we are now at a leaf device */
+	xhci_free_virt_device(xhci, slot_id);
+}
+
 int xhci_alloc_virt_device(struct xhci_hcd *xhci, int slot_id,
 		struct usb_device *udev, gfp_t flags)
 {
@@ -1829,8 +1863,8 @@ void xhci_mem_cleanup(struct xhci_hcd *x
 		}
 	}
 
-	for (i = 1; i < MAX_HC_SLOTS; ++i)
-		xhci_free_virt_device(xhci, i);
+	for (i = HCS_MAX_SLOTS(xhci->hcs_params1); i > 0; i--)
+		xhci_free_virt_devices_depth_first(xhci, i);
 
 	dma_pool_destroy(xhci->segment_pool);
 	xhci->segment_pool = NULL;

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 038/206] usb: xhci: fix return value of xhci_setup_device()
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (29 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 037/206] xhci: free xhci virtual devices with leaf nodes first Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 039/206] usb: host: xhci: Fix possible wild pointer when handling abort command Greg Kroah-Hartman
                     ` (158 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Lu Baolu, Mathias Nyman

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Lu Baolu <baolu.lu@linux.intel.com>

commit 90797aee5d6902b49a453c97d83c326408aeb5a8 upstream.

xhci_setup_device() should return failure with correct error number
when xhci host has died, removed or halted.

During usb device enumeration, if usb host is not accessible (died,
removed or halted), the hc_driver->address_device() should return
a corresponding error code to usb core. But current xhci driver just
returns success. This misleads usb core to continue the enumeration
by reading the device descriptor, which will result in failure, and
users will get a misleading message like "device descriptor read/8,
error -110".

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/host/xhci.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -3783,8 +3783,10 @@ static int xhci_setup_device(struct usb_
 
 	mutex_lock(&xhci->mutex);
 
-	if (xhci->xhc_state)	/* dying, removing or halted */
+	if (xhci->xhc_state) {	/* dying, removing or halted */
+		ret = -ESHUTDOWN;
 		goto out;
+	}
 
 	if (!udev->slot_id) {
 		xhci_dbg_trace(xhci, trace_xhci_dbg_address,

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 039/206] usb: host: xhci: Fix possible wild pointer when handling abort command
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (30 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 038/206] usb: xhci: fix return value of xhci_setup_device() Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 040/206] xhci: Handle command completion and timeout race Greg Kroah-Hartman
                     ` (157 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Baolin Wang, Mathias Nyman

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Baolin Wang <baolin.wang@linaro.org>

commit 2a7cfdf37b7c08ac29df4c62ea5ccb01474b6597 upstream.

When current command was supposed to be aborted, host will free the command
in handle_cmd_completion() function. But it might be still referenced by
xhci->current_cmd, which need to set NULL.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/host/xhci-ring.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -1368,8 +1368,11 @@ static void handle_cmd_completion(struct
 	 */
 	if (cmd_comp_code == COMP_CMD_ABORT) {
 		xhci->cmd_ring_state = CMD_RING_STATE_STOPPED;
-		if (cmd->status == COMP_CMD_ABORT)
+		if (cmd->status == COMP_CMD_ABORT) {
+			if (xhci->current_cmd == cmd)
+				xhci->current_cmd = NULL;
 			goto event_handled;
+		}
 	}
 
 	cmd_type = TRB_FIELD_TO_TYPE(le32_to_cpu(cmd_trb->generic.field[3]));

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 040/206] xhci: Handle command completion and timeout race
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (31 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 039/206] usb: host: xhci: Fix possible wild pointer when handling abort command Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 041/206] usb: xhci: hold lock over xhci_abort_cmd_ring() Greg Kroah-Hartman
                     ` (156 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Baolin Wang, Mathias Nyman

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Mathias Nyman <mathias.nyman@linux.intel.com>

commit a5a1b9514154437aa1ed35c291191f82fd3e941a upstream.

If we get a command completion event at the same time as the command
timeout work starts on another cpu we might end up aborting the wrong
command.

If the command completion takes the xhci lock before the timeout work, it
will handle the command, pick the next command, mark it as current_cmd, and
re-queue the timeout work. When the timeout work finally gets the lock
It will start aborting the wrong command.

This case can be resolved by checking if the timeout work is pending inside
the timeout function itself. A new timeout work can only be pending if the
command completed and a new command was queued.

If there are no more commands pending then command completion will set
the current_cmd to NULL, which is already handled in the timeout work.

Reported-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/host/xhci-ring.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -1273,7 +1273,11 @@ void xhci_handle_command_timeout(unsigne
 
 	spin_lock_irqsave(&xhci->lock, flags);
 
-	if (!xhci->current_cmd) {
+	/*
+	 * If timeout work is pending, or current_cmd is NULL, it means we
+	 * raced with command completion. Command is handled so just return.
+	 */
+	if (!xhci->current_cmd || timer_pending(&xhci->cmd_timer)) {
 		spin_unlock_irqrestore(&xhci->lock, flags);
 		return;
 	}

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 041/206] usb: xhci: hold lock over xhci_abort_cmd_ring()
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (32 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 040/206] xhci: Handle command completion and timeout race Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 042/206] usb: return error code when platform_get_irq fails Greg Kroah-Hartman
                     ` (155 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Lu Baolu, Mathias Nyman

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Lu Baolu <baolu.lu@linux.intel.com>

commit 4dea70778c0f48b4385c7720c363ec8d37a401b4 upstream.

In command timer function, xhci_handle_command_timeout(), xhci->lock
is unlocked before call into xhci_abort_cmd_ring(). This might cause
race between the timer function and the event handler.

The xhci_abort_cmd_ring() function sets the CMD_RING_ABORT bit in the
command register and polling it until the setting takes effect. A stop
command ring event might be handled between writing the abort bit and
polling for it. The event handler will restart the command ring, which
causes the failure of polling, and we ever believed that we failed to
stop it.

As a bonus, this also fixes some issues of calling functions without
locking in xhci_handle_command_timeout().

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/host/xhci-ring.c |   13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -1291,29 +1291,34 @@ void xhci_handle_command_timeout(unsigne
 	hw_ring_state = xhci_read_64(xhci, &xhci->op_regs->cmd_ring);
 	if ((xhci->cmd_ring_state & CMD_RING_STATE_RUNNING) &&
 	    (hw_ring_state & CMD_RING_RUNNING))  {
-		spin_unlock_irqrestore(&xhci->lock, flags);
 		xhci_dbg(xhci, "Command timeout\n");
 		ret = xhci_abort_cmd_ring(xhci);
 		if (unlikely(ret == -ESHUTDOWN)) {
 			xhci_err(xhci, "Abort command ring failed\n");
 			xhci_cleanup_command_queue(xhci);
+			spin_unlock_irqrestore(&xhci->lock, flags);
 			usb_hc_died(xhci_to_hcd(xhci)->primary_hcd);
 			xhci_dbg(xhci, "xHCI host controller is dead.\n");
+
+			return;
 		}
-		return;
+
+		goto time_out_completed;
 	}
 
 	/* command ring failed to restart, or host removed. Bail out */
 	if (second_timeout || xhci->xhc_state & XHCI_STATE_REMOVING) {
-		spin_unlock_irqrestore(&xhci->lock, flags);
 		xhci_dbg(xhci, "command timed out twice, ring start fail?\n");
 		xhci_cleanup_command_queue(xhci);
-		return;
+
+		goto time_out_completed;
 	}
 
 	/* command timeout on stopped ring, ring can't be aborted */
 	xhci_dbg(xhci, "Command timeout on stopped ring\n");
 	xhci_handle_stopped_cmd_ring(xhci, xhci->current_cmd);
+
+time_out_completed:
 	spin_unlock_irqrestore(&xhci->lock, flags);
 	return;
 }

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 042/206] usb: return error code when platform_get_irq fails
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (33 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 041/206] usb: xhci: hold lock over xhci_abort_cmd_ring() Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 043/206] USB: serial: omninet: fix NULL-derefs at open and disconnect Greg Kroah-Hartman
                     ` (154 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Pan Bian, Matthias Brugger, Mathias Nyman

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Pan Bian <bianpan2016@163.com>

commit 28bedb5ae463b9f7e5195cbc93f1795e374bdef8 upstream.

In function xhci_mtk_probe(), variable ret takes the return value. Its
value should be negative on failures. However, when the call to function
platform_get_irq() fails, it does not set the error code, and 0 will be
returned. 0 indicates no error. As a result, the callers of function
xhci_mtk_probe() will not be able to detect the error. This patch fixes
the bug by assigning the return value of platform_get_irq() to variable
ret if it fails.

Signed-off-by: Pan Bian <bianpan2016@163.com>
Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/host/xhci-mtk.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -560,8 +560,10 @@ static int xhci_mtk_probe(struct platfor
 		goto disable_ldos;
 
 	irq = platform_get_irq(pdev, 0);
-	if (irq < 0)
+	if (irq < 0) {
+		ret = irq;
 		goto disable_clk;
+	}
 
 	/* Initialize dma_mask and coherent_dma_mask to 32-bits */
 	ret = dma_set_coherent_mask(dev, DMA_BIT_MASK(32));

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 043/206] USB: serial: omninet: fix NULL-derefs at open and disconnect
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (34 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 042/206] usb: return error code when platform_get_irq fails Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 044/206] USB: serial: quatech2: fix sleep-while-atomic in close Greg Kroah-Hartman
                     ` (153 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Johan Hovold

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Johan Hovold <johan@kernel.org>

commit a5bc01949e3b19d8a23b5eabc6fc71bb50dc820e upstream.

Fix NULL-pointer dereferences at open() and disconnect() should the
device lack the expected bulk-out endpoints:

Unable to handle kernel NULL pointer dereference at virtual address 000000b4
...
[c0170ff0>] (__lock_acquire) from [<c0172f00>] (lock_acquire+0x108/0x264)
[<c0172f00>] (lock_acquire) from [<c06a5090>] (_raw_spin_lock_irqsave+0x58/0x6c)
[<c06a5090>] (_raw_spin_lock_irqsave) from [<c0470684>] (tty_port_tty_set+0x28/0xa4)
[<c0470684>] (tty_port_tty_set) from [<bf08d384>] (omninet_open+0x30/0x40 [omninet])
[<bf08d384>] (omninet_open [omninet]) from [<bf07c118>] (serial_port_activate+0x68/0x98 [usbserial])

Unable to handle kernel NULL pointer dereference at virtual address 00000234
...
[<bf01f418>] (omninet_disconnect [omninet]) from [<bf0016c0>] (usb_serial_disconnect+0xe4/0x100 [usbserial])

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/serial/omninet.c |   13 +++++++++++++
 1 file changed, 13 insertions(+)

--- a/drivers/usb/serial/omninet.c
+++ b/drivers/usb/serial/omninet.c
@@ -38,6 +38,7 @@ static int  omninet_write(struct tty_str
 				const unsigned char *buf, int count);
 static int  omninet_write_room(struct tty_struct *tty);
 static void omninet_disconnect(struct usb_serial *serial);
+static int omninet_attach(struct usb_serial *serial);
 static int omninet_port_probe(struct usb_serial_port *port);
 static int omninet_port_remove(struct usb_serial_port *port);
 
@@ -56,6 +57,7 @@ static struct usb_serial_driver zyxel_om
 	.description =		"ZyXEL - omni.net lcd plus usb",
 	.id_table =		id_table,
 	.num_ports =		1,
+	.attach =		omninet_attach,
 	.port_probe =		omninet_port_probe,
 	.port_remove =		omninet_port_remove,
 	.open =			omninet_open,
@@ -104,6 +106,17 @@ struct omninet_data {
 	__u8	od_outseq;	/* Sequence number for bulk_out URBs */
 };
 
+static int omninet_attach(struct usb_serial *serial)
+{
+	/* The second bulk-out endpoint is used for writing. */
+	if (serial->num_bulk_out < 2) {
+		dev_err(&serial->interface->dev, "missing endpoints\n");
+		return -ENODEV;
+	}
+
+	return 0;
+}
+
 static int omninet_port_probe(struct usb_serial_port *port)
 {
 	struct omninet_data *od;

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 044/206] USB: serial: quatech2: fix sleep-while-atomic in close
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (35 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 043/206] USB: serial: omninet: fix NULL-derefs at open and disconnect Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 045/206] USB: serial: pl2303: fix NULL-deref at open Greg Kroah-Hartman
                     ` (152 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Johan Hovold

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Johan Hovold <johan@kernel.org>

commit f09d1886a41e9063b43da493ef0e845ac8afd2fa upstream.

The write URB was being killed using the synchronous interface while
holding a spin lock in close().

Simply drop the lock and busy-flag update, something which would have
been taken care of by the completion handler if the URB was in flight.

Fixes: f7a33e608d9a ("USB: serial: add quatech2 usb to serial driver")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/serial/quatech2.c |    4 ----
 1 file changed, 4 deletions(-)

--- a/drivers/usb/serial/quatech2.c
+++ b/drivers/usb/serial/quatech2.c
@@ -408,16 +408,12 @@ static void qt2_close(struct usb_serial_
 {
 	struct usb_serial *serial;
 	struct qt2_port_private *port_priv;
-	unsigned long flags;
 	int i;
 
 	serial = port->serial;
 	port_priv = usb_get_serial_port_data(port);
 
-	spin_lock_irqsave(&port_priv->urb_lock, flags);
 	usb_kill_urb(port_priv->write_urb);
-	port_priv->urb_in_use = false;
-	spin_unlock_irqrestore(&port_priv->urb_lock, flags);
 
 	/* flush the port transmit buffer */
 	i = usb_control_msg(serial->dev,

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 045/206] USB: serial: pl2303: fix NULL-deref at open
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (36 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 044/206] USB: serial: quatech2: fix sleep-while-atomic in close Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 046/206] USB: serial: keyspan_pda: verify endpoints at probe Greg Kroah-Hartman
                     ` (151 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Johan Hovold

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Johan Hovold <johan@kernel.org>

commit 76ab439ed1b68778e9059c79ecc5d14de76c89a8 upstream.

Fix NULL-pointer dereference in open() should a type-0 or type-1 device
lack the expected endpoints:

Unable to handle kernel NULL pointer dereference at virtual address 00000030
...
PC is at pl2303_open+0x38/0xec [pl2303]

Note that a missing interrupt-in endpoint would have caused open() to
fail.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/serial/pl2303.c |    8 ++++++++
 1 file changed, 8 insertions(+)

--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -220,9 +220,17 @@ static int pl2303_probe(struct usb_seria
 static int pl2303_startup(struct usb_serial *serial)
 {
 	struct pl2303_serial_private *spriv;
+	unsigned char num_ports = serial->num_ports;
 	enum pl2303_type type = TYPE_01;
 	unsigned char *buf;
 
+	if (serial->num_bulk_in < num_ports ||
+			serial->num_bulk_out < num_ports ||
+			serial->num_interrupt_in < num_ports) {
+		dev_err(&serial->interface->dev, "missing endpoints\n");
+		return -ENODEV;
+	}
+
 	spriv = kzalloc(sizeof(*spriv), GFP_KERNEL);
 	if (!spriv)
 		return -ENOMEM;

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 046/206] USB: serial: keyspan_pda: verify endpoints at probe
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (37 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 045/206] USB: serial: pl2303: fix NULL-deref at open Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 047/206] USB: serial: spcp8x5: fix NULL-deref at open Greg Kroah-Hartman
                     ` (150 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Johan Hovold

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Johan Hovold <johan@kernel.org>

commit 5d9b0f859babe96175cd33d7162a9463a875ffde upstream.

Check for the expected endpoints in attach() and fail loudly if not
present.

Note that failing to do this appears to be benign since da280e348866
("USB: keyspan_pda: clean up write-urb busy handling") which prevents a
NULL-pointer dereference in write() by never marking a non-existent
write-urb as free.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/serial/keyspan_pda.c |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

--- a/drivers/usb/serial/keyspan_pda.c
+++ b/drivers/usb/serial/keyspan_pda.c
@@ -699,6 +699,19 @@ MODULE_FIRMWARE("keyspan_pda/keyspan_pda
 MODULE_FIRMWARE("keyspan_pda/xircom_pgs.fw");
 #endif
 
+static int keyspan_pda_attach(struct usb_serial *serial)
+{
+	unsigned char num_ports = serial->num_ports;
+
+	if (serial->num_bulk_out < num_ports ||
+			serial->num_interrupt_in < num_ports) {
+		dev_err(&serial->interface->dev, "missing endpoints\n");
+		return -ENODEV;
+	}
+
+	return 0;
+}
+
 static int keyspan_pda_port_probe(struct usb_serial_port *port)
 {
 
@@ -776,6 +789,7 @@ static struct usb_serial_driver keyspan_
 	.break_ctl =		keyspan_pda_break_ctl,
 	.tiocmget =		keyspan_pda_tiocmget,
 	.tiocmset =		keyspan_pda_tiocmset,
+	.attach =		keyspan_pda_attach,
 	.port_probe =		keyspan_pda_port_probe,
 	.port_remove =		keyspan_pda_port_remove,
 };

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 047/206] USB: serial: spcp8x5: fix NULL-deref at open
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (38 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 046/206] USB: serial: keyspan_pda: verify endpoints at probe Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 048/206] USB: serial: io_ti: " Greg Kroah-Hartman
                     ` (149 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Johan Hovold

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Johan Hovold <johan@kernel.org>

commit cc0909248258f679c4bb4cd315565d40abaf6bc6 upstream.

Fix NULL-pointer dereference in open() should the device lack the
expected endpoints:

Unable to handle kernel NULL pointer dereference at virtual address 00000030
...
PC is at spcp8x5_open+0x30/0xd0 [spcp8x5]

Fixes: 619a6f1d1423 ("USB: add usb-serial spcp8x5 driver")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/serial/spcp8x5.c |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

--- a/drivers/usb/serial/spcp8x5.c
+++ b/drivers/usb/serial/spcp8x5.c
@@ -154,6 +154,19 @@ static int spcp8x5_probe(struct usb_seri
 	return 0;
 }
 
+static int spcp8x5_attach(struct usb_serial *serial)
+{
+	unsigned char num_ports = serial->num_ports;
+
+	if (serial->num_bulk_in < num_ports ||
+			serial->num_bulk_out < num_ports) {
+		dev_err(&serial->interface->dev, "missing endpoints\n");
+		return -ENODEV;
+	}
+
+	return 0;
+}
+
 static int spcp8x5_port_probe(struct usb_serial_port *port)
 {
 	const struct usb_device_id *id = usb_get_serial_data(port->serial);
@@ -477,6 +490,7 @@ static struct usb_serial_driver spcp8x5_
 	.tiocmget		= spcp8x5_tiocmget,
 	.tiocmset		= spcp8x5_tiocmset,
 	.probe			= spcp8x5_probe,
+	.attach			= spcp8x5_attach,
 	.port_probe		= spcp8x5_port_probe,
 	.port_remove		= spcp8x5_port_remove,
 };

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 048/206] USB: serial: io_ti: fix NULL-deref at open
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (39 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 047/206] USB: serial: spcp8x5: fix NULL-deref at open Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 049/206] USB: serial: io_ti: fix another " Greg Kroah-Hartman
                     ` (148 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Johan Hovold

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Johan Hovold <johan@kernel.org>

commit a323fefc6f5079844dc62ffeb54f491d0242ca35 upstream.

Fix NULL-pointer dereference when clearing halt at open should a
malicious device lack the expected endpoints when in download mode.

Unable to handle kernel NULL pointer dereference at virtual address 00000030
...
[<bf011ed8>] (edge_open [io_ti]) from [<bf000118>] (serial_port_activate+0x68/0x98 [usbserial])
[<bf000118>] (serial_port_activate [usbserial]) from [<c0470ca4>] (tty_port_open+0x9c/0xe8)
[<c0470ca4>] (tty_port_open) from [<bf000da0>] (serial_open+0x48/0x6c [usbserial])
[<bf000da0>] (serial_open [usbserial]) from [<c0469178>] (tty_open+0xcc/0x5cc)

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/serial/io_ti.c |    7 +++++++
 1 file changed, 7 insertions(+)

--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -2549,6 +2549,13 @@ static int edge_startup(struct usb_seria
 	int status;
 	u16 product_id;
 
+	/* Make sure we have the required endpoints when in download mode. */
+	if (serial->interface->cur_altsetting->desc.bNumEndpoints > 1) {
+		if (serial->num_bulk_in < serial->num_ports ||
+				serial->num_bulk_out < serial->num_ports)
+			return -ENODEV;
+	}
+
 	/* create our private serial structure */
 	edge_serial = kzalloc(sizeof(struct edgeport_serial), GFP_KERNEL);
 	if (!edge_serial)

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 049/206] USB: serial: io_ti: fix another NULL-deref at open
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (40 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 048/206] USB: serial: io_ti: " Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 050/206] USB: serial: io_ti: fix I/O after disconnect Greg Kroah-Hartman
                     ` (147 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Johan Hovold

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Johan Hovold <johan@kernel.org>

commit 4f9785cc99feeb3673993b471f646b4dbaec2cc1 upstream.

In case a device is left in "boot-mode" we must not register any port
devices in order to avoid a NULL-pointer dereference on open due to
missing endpoints. This could be used by a malicious device to trigger
an OOPS:

Unable to handle kernel NULL pointer dereference at virtual address 00000030
...
[<bf0caa84>] (edge_open [io_ti]) from [<bf0b0118>] (serial_port_activate+0x68/0x98 [usbserial])
[<bf0b0118>] (serial_port_activate [usbserial]) from [<c0470ca4>] (tty_port_open+0x9c/0xe8)
[<c0470ca4>] (tty_port_open) from [<bf0b0da0>] (serial_open+0x48/0x6c [usbserial])
[<bf0b0da0>] (serial_open [usbserial]) from [<c0469178>] (tty_open+0xcc/0x5cc)

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/serial/io_ti.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -1508,7 +1508,7 @@ stayinbootmode:
 	dev_dbg(dev, "%s - STAYING IN BOOT MODE\n", __func__);
 	serial->product_info.TiMode = TI_MODE_BOOT;
 
-	return 0;
+	return 1;
 }
 
 static int ti_do_config(struct edgeport_port *port, int feature, int on)
@@ -2563,14 +2563,18 @@ static int edge_startup(struct usb_seria
 
 	mutex_init(&edge_serial->es_lock);
 	edge_serial->serial = serial;
+	INIT_DELAYED_WORK(&edge_serial->heartbeat_work, edge_heartbeat_work);
 	usb_set_serial_data(serial, edge_serial);
 
 	status = download_fw(edge_serial);
-	if (status) {
+	if (status < 0) {
 		kfree(edge_serial);
 		return status;
 	}
 
+	if (status > 0)
+		return 1;	/* bind but do not register any ports */
+
 	product_id = le16_to_cpu(
 			edge_serial->serial->dev->descriptor.idProduct);
 
@@ -2582,7 +2586,6 @@ static int edge_startup(struct usb_seria
 		}
 	}
 
-	INIT_DELAYED_WORK(&edge_serial->heartbeat_work, edge_heartbeat_work);
 	edge_heartbeat_schedule(edge_serial);
 
 	return 0;

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 050/206] USB: serial: io_ti: fix I/O after disconnect
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (41 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 049/206] USB: serial: io_ti: fix another " Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 051/206] USB: serial: iuu_phoenix: fix NULL-deref at open Greg Kroah-Hartman
                     ` (146 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Johan Hovold

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Johan Hovold <johan@kernel.org>

commit 2330d0a853da260d8a9834a70df448032b9ff623 upstream.

Cancel the heartbeat work on driver unbind in order to avoid I/O after
disconnect in case the port is held open.

Note that the cancel in release() is still needed to stop the heartbeat
after late probe errors.

Fixes: 26c78daade0f ("USB: io_ti: Add heartbeat to keep idle EP/416 ports from disconnecting")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/serial/io_ti.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -2593,6 +2593,9 @@ static int edge_startup(struct usb_seria
 
 static void edge_disconnect(struct usb_serial *serial)
 {
+	struct edgeport_serial *edge_serial = usb_get_serial_data(serial);
+
+	cancel_delayed_work_sync(&edge_serial->heartbeat_work);
 }
 
 static void edge_release(struct usb_serial *serial)

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 051/206] USB: serial: iuu_phoenix: fix NULL-deref at open
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (42 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 050/206] USB: serial: io_ti: fix I/O after disconnect Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 052/206] USB: serial: garmin_gps: fix memory leak on failed URB submit Greg Kroah-Hartman
                     ` (145 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Johan Hovold

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Johan Hovold <johan@kernel.org>

commit 90507d54f712d81b74815ef3a4bbb555cd9fab2f upstream.

Fix NULL-pointer dereference at open should the device lack a bulk-in or
bulk-out endpoint:

Unable to handle kernel NULL pointer dereference at virtual address 00000030
...
PC is at iuu_open+0x78/0x59c [iuu_phoenix]

Fixes: 07c3b1a10016 ("USB: remove broken usb-serial num_endpoints
check")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/serial/iuu_phoenix.c |   11 +++++++++++
 1 file changed, 11 insertions(+)

--- a/drivers/usb/serial/iuu_phoenix.c
+++ b/drivers/usb/serial/iuu_phoenix.c
@@ -68,6 +68,16 @@ struct iuu_private {
 	u32 clk;
 };
 
+static int iuu_attach(struct usb_serial *serial)
+{
+	unsigned char num_ports = serial->num_ports;
+
+	if (serial->num_bulk_in < num_ports || serial->num_bulk_out < num_ports)
+		return -ENODEV;
+
+	return 0;
+}
+
 static int iuu_port_probe(struct usb_serial_port *port)
 {
 	struct iuu_private *priv;
@@ -1196,6 +1206,7 @@ static struct usb_serial_driver iuu_devi
 	.tiocmset = iuu_tiocmset,
 	.set_termios = iuu_set_termios,
 	.init_termios = iuu_init_termios,
+	.attach = iuu_attach,
 	.port_probe = iuu_port_probe,
 	.port_remove = iuu_port_remove,
 };

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 052/206] USB: serial: garmin_gps: fix memory leak on failed URB submit
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (43 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 051/206] USB: serial: iuu_phoenix: fix NULL-deref at open Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 053/206] USB: serial: ti_usb_3410_5052: fix NULL-deref at open Greg Kroah-Hartman
                     ` (144 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Johan Hovold

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Johan Hovold <johan@kernel.org>

commit c4ac4496e835b78a45dfbf74f6173932217e4116 upstream.

Make sure to free the URB transfer buffer in case submission fails (e.g.
due to a disconnect).

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/serial/garmin_gps.c |    1 +
 1 file changed, 1 insertion(+)

--- a/drivers/usb/serial/garmin_gps.c
+++ b/drivers/usb/serial/garmin_gps.c
@@ -1043,6 +1043,7 @@ static int garmin_write_bulk(struct usb_
 		   "%s - usb_submit_urb(write bulk) failed with status = %d\n",
 				__func__, status);
 		count = status;
+		kfree(buffer);
 	}
 
 	/* we are done with this urb, so let the host driver

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 053/206] USB: serial: ti_usb_3410_5052: fix NULL-deref at open
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (44 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 052/206] USB: serial: garmin_gps: fix memory leak on failed URB submit Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 054/206] USB: serial: io_edgeport: " Greg Kroah-Hartman
                     ` (143 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Johan Hovold

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Johan Hovold <johan@kernel.org>

commit ef079936d3cd09e63612834fe2698eeada0d8e3f upstream.

Fix NULL-pointer dereference in open() should a malicious device lack
the expected endpoints:

Unable to handle kernel NULL pointer dereference at virtual address 00000030
..
[<bf06a6b0>] (ti_open [ti_usb_3410_5052]) from [<bf02e118>] (serial_port_activate+0x68/0x98 [usbserial])

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/serial/ti_usb_3410_5052.c |    7 +++++++
 1 file changed, 7 insertions(+)

--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -579,6 +579,13 @@ static int ti_startup(struct usb_serial
 		goto free_tdev;
 	}
 
+	if (serial->num_bulk_in < serial->num_ports ||
+			serial->num_bulk_out < serial->num_ports) {
+		dev_err(&serial->interface->dev, "missing endpoints\n");
+		status = -ENODEV;
+		goto free_tdev;
+	}
+
 	return 0;
 
 free_tdev:

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 054/206] USB: serial: io_edgeport: fix NULL-deref at open
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (45 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 053/206] USB: serial: ti_usb_3410_5052: fix NULL-deref at open Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 055/206] USB: serial: oti6858: " Greg Kroah-Hartman
                     ` (142 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Johan Hovold

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Johan Hovold <johan@kernel.org>

commit 0dd408425eb21ddf26a692b3c8044c9e7d1a7948 upstream.

Fix NULL-pointer dereference when initialising URBs at open should a
non-EPIC device lack a bulk-in or interrupt-in endpoint.

Unable to handle kernel NULL pointer dereference at virtual address 00000028
...
PC is at edge_open+0x24c/0x3e8 [io_edgeport]

Note that the EPIC-device probe path has the required sanity checks so
this makes those checks partially redundant.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/serial/io_edgeport.c |    5 +++++
 1 file changed, 5 insertions(+)

--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -2754,6 +2754,11 @@ static int edge_startup(struct usb_seria
 					EDGE_COMPATIBILITY_MASK1,
 					EDGE_COMPATIBILITY_MASK2 };
 
+	if (serial->num_bulk_in < 1 || serial->num_interrupt_in < 1) {
+		dev_err(&serial->interface->dev, "missing endpoints\n");
+		return -ENODEV;
+	}
+
 	dev = serial->dev;
 
 	/* create our private serial structure */

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 055/206] USB: serial: oti6858: fix NULL-deref at open
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (46 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 054/206] USB: serial: io_edgeport: " Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 056/206] USB: serial: cyberjack: " Greg Kroah-Hartman
                     ` (141 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Johan Hovold

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Johan Hovold <johan@kernel.org>

commit 5afeef2366db14587b65558bbfd5a067542e07fb upstream.

Fix NULL-pointer dereference in open() should the device lack the
expected endpoints:

Unable to handle kernel NULL pointer dereference at virtual address 00000030
...
PC is at oti6858_open+0x30/0x1d0 [oti6858]

Note that a missing interrupt-in endpoint would have caused open() to
fail.

Fixes: 49cdee0ed0fc ("USB: oti6858 usb-serial driver (in Nokia CA-42
cable)")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/serial/oti6858.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

--- a/drivers/usb/serial/oti6858.c
+++ b/drivers/usb/serial/oti6858.c
@@ -134,6 +134,7 @@ static int oti6858_chars_in_buffer(struc
 static int oti6858_tiocmget(struct tty_struct *tty);
 static int oti6858_tiocmset(struct tty_struct *tty,
 				unsigned int set, unsigned int clear);
+static int oti6858_attach(struct usb_serial *serial);
 static int oti6858_port_probe(struct usb_serial_port *port);
 static int oti6858_port_remove(struct usb_serial_port *port);
 
@@ -158,6 +159,7 @@ static struct usb_serial_driver oti6858_
 	.write_bulk_callback =	oti6858_write_bulk_callback,
 	.write_room =		oti6858_write_room,
 	.chars_in_buffer =	oti6858_chars_in_buffer,
+	.attach =		oti6858_attach,
 	.port_probe =		oti6858_port_probe,
 	.port_remove =		oti6858_port_remove,
 };
@@ -324,6 +326,20 @@ static void send_data(struct work_struct
 	usb_serial_port_softint(port);
 }
 
+static int oti6858_attach(struct usb_serial *serial)
+{
+	unsigned char num_ports = serial->num_ports;
+
+	if (serial->num_bulk_in < num_ports ||
+			serial->num_bulk_out < num_ports ||
+			serial->num_interrupt_in < num_ports) {
+		dev_err(&serial->interface->dev, "missing endpoints\n");
+		return -ENODEV;
+	}
+
+	return 0;
+}
+
 static int oti6858_port_probe(struct usb_serial_port *port)
 {
 	struct oti6858_private *priv;

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 056/206] USB: serial: cyberjack: fix NULL-deref at open
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (47 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 055/206] USB: serial: oti6858: " Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 057/206] USB: serial: kobil_sct: fix NULL-deref in write Greg Kroah-Hartman
                     ` (140 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Johan Hovold

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Johan Hovold <johan@kernel.org>

commit 3dca01114dcecb1cf324534cd8d75fd1306a516b upstream.

Fix NULL-pointer dereference when clearing halt at open should the device
lack a bulk-out endpoint.

Unable to handle kernel NULL pointer dereference at virtual address 00000030
...
PC is at cyberjack_open+0x40/0x9c [cyberjack]

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/serial/cyberjack.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

--- a/drivers/usb/serial/cyberjack.c
+++ b/drivers/usb/serial/cyberjack.c
@@ -50,6 +50,7 @@
 #define CYBERJACK_PRODUCT_ID	0x0100
 
 /* Function prototypes */
+static int cyberjack_attach(struct usb_serial *serial);
 static int cyberjack_port_probe(struct usb_serial_port *port);
 static int cyberjack_port_remove(struct usb_serial_port *port);
 static int  cyberjack_open(struct tty_struct *tty,
@@ -77,6 +78,7 @@ static struct usb_serial_driver cyberjac
 	.description =		"Reiner SCT Cyberjack USB card reader",
 	.id_table =		id_table,
 	.num_ports =		1,
+	.attach =		cyberjack_attach,
 	.port_probe =		cyberjack_port_probe,
 	.port_remove =		cyberjack_port_remove,
 	.open =			cyberjack_open,
@@ -100,6 +102,14 @@ struct cyberjack_private {
 	short		wrsent;		/* Data already sent */
 };
 
+static int cyberjack_attach(struct usb_serial *serial)
+{
+	if (serial->num_bulk_out < serial->num_ports)
+		return -ENODEV;
+
+	return 0;
+}
+
 static int cyberjack_port_probe(struct usb_serial_port *port)
 {
 	struct cyberjack_private *priv;

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 057/206] USB: serial: kobil_sct: fix NULL-deref in write
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (48 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 056/206] USB: serial: cyberjack: " Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 058/206] USB: serial: mos7840: fix NULL-deref at open Greg Kroah-Hartman
                     ` (139 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Johan Hovold

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Johan Hovold <johan@kernel.org>

commit 21ce57840243c7b70fbc1ebd3dceeb70bb6e9e09 upstream.

Fix NULL-pointer dereference in write() should the device lack the
expected interrupt-out endpoint:

Unable to handle kernel NULL pointer dereference at virtual address 00000054
...
PC is at kobil_write+0x144/0x2a0 [kobil_sct]

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/serial/kobil_sct.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)

--- a/drivers/usb/serial/kobil_sct.c
+++ b/drivers/usb/serial/kobil_sct.c
@@ -51,6 +51,7 @@
 
 
 /* Function prototypes */
+static int kobil_attach(struct usb_serial *serial);
 static int kobil_port_probe(struct usb_serial_port *probe);
 static int kobil_port_remove(struct usb_serial_port *probe);
 static int  kobil_open(struct tty_struct *tty, struct usb_serial_port *port);
@@ -86,6 +87,7 @@ static struct usb_serial_driver kobil_de
 	.description =		"KOBIL USB smart card terminal",
 	.id_table =		id_table,
 	.num_ports =		1,
+	.attach =		kobil_attach,
 	.port_probe =		kobil_port_probe,
 	.port_remove =		kobil_port_remove,
 	.ioctl =		kobil_ioctl,
@@ -113,6 +115,16 @@ struct kobil_private {
 };
 
 
+static int kobil_attach(struct usb_serial *serial)
+{
+	if (serial->num_interrupt_out < serial->num_ports) {
+		dev_err(&serial->interface->dev, "missing interrupt-out endpoint\n");
+		return -ENODEV;
+	}
+
+	return 0;
+}
+
 static int kobil_port_probe(struct usb_serial_port *port)
 {
 	struct usb_serial *serial = port->serial;

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 058/206] USB: serial: mos7840: fix NULL-deref at open
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (49 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 057/206] USB: serial: kobil_sct: fix NULL-deref in write Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 059/206] USB: serial: mos7720: " Greg Kroah-Hartman
                     ` (138 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Johan Hovold

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Johan Hovold <johan@kernel.org>

commit 5c75633ef751dd4cd8f443dc35152c1ae563162e upstream.

Fix NULL-pointer dereference in open() should the device lack the
expected endpoints:

Unable to handle kernel NULL pointer dereference at virtual address 00000030
...
PC is at mos7840_open+0x88/0x8dc [mos7840]

Note that we continue to treat the interrupt-in endpoint as optional for
now.

Fixes: 3f5429746d91 ("USB: Moschip 7840 USB-Serial Driver")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/serial/mos7840.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)

--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -2116,6 +2116,17 @@ static int mos7840_calc_num_ports(struct
 	return mos7840_num_ports;
 }
 
+static int mos7840_attach(struct usb_serial *serial)
+{
+	if (serial->num_bulk_in < serial->num_ports ||
+			serial->num_bulk_out < serial->num_ports) {
+		dev_err(&serial->interface->dev, "missing endpoints\n");
+		return -ENODEV;
+	}
+
+	return 0;
+}
+
 static int mos7840_port_probe(struct usb_serial_port *port)
 {
 	struct usb_serial *serial = port->serial;
@@ -2391,6 +2402,7 @@ static struct usb_serial_driver moschip7
 	.tiocmset = mos7840_tiocmset,
 	.tiocmiwait = usb_serial_generic_tiocmiwait,
 	.get_icount = usb_serial_generic_get_icount,
+	.attach = mos7840_attach,
 	.port_probe = mos7840_port_probe,
 	.port_remove = mos7840_port_remove,
 	.read_bulk_callback = mos7840_bulk_in_callback,

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 059/206] USB: serial: mos7720: fix NULL-deref at open
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (50 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 058/206] USB: serial: mos7840: fix NULL-deref at open Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 060/206] USB: serial: mos7720: fix use-after-free on probe errors Greg Kroah-Hartman
                     ` (137 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Johan Hovold

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Johan Hovold <johan@kernel.org>

commit b05aebc25fdc5aeeac3ee29f0dc9f58dd07c13cc upstream.

Fix NULL-pointer dereference at port open if a device lacks the expected
bulk in and out endpoints.

Unable to handle kernel NULL pointer dereference at virtual address 00000030
...
[<bf071c20>] (mos7720_open [mos7720]) from [<bf0490e0>] (serial_port_activate+0x68/0x98 [usbserial])
[<bf0490e0>] (serial_port_activate [usbserial]) from [<c0470ca4>] (tty_port_open+0x9c/0xe8)
[<c0470ca4>] (tty_port_open) from [<bf049d98>] (serial_open+0x48/0x6c [usbserial])
[<bf049d98>] (serial_open [usbserial]) from [<c0469178>] (tty_open+0xcc/0x5cc)

Fixes: 0f64478cbc7a ("USB: add USB serial mos7720 driver")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/serial/mos7720.c |    5 +++++
 1 file changed, 5 insertions(+)

--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -1920,6 +1920,11 @@ static int mos7720_startup(struct usb_se
 	u16 product;
 	int ret_val;
 
+	if (serial->num_bulk_in < 2 || serial->num_bulk_out < 2) {
+		dev_err(&serial->interface->dev, "missing bulk endpoints\n");
+		return -ENODEV;
+	}
+
 	product = le16_to_cpu(serial->dev->descriptor.idProduct);
 	dev = serial->dev;
 

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 060/206] USB: serial: mos7720: fix use-after-free on probe errors
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (51 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 059/206] USB: serial: mos7720: " Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 061/206] USB: serial: mos7720: fix parport " Greg Kroah-Hartman
                     ` (136 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Johan Hovold

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Johan Hovold <johan@kernel.org>

commit 91a1ff4d53c5184d383d0baeeaeab6f9736f2ff3 upstream.

The interrupt URB was submitted on probe but never stopped on probe
errors. This can lead to use-after-free issues in the completion
handler when accessing the freed usb-serial struct:

Unable to handle kernel paging request at virtual address 6b6b6be7
...
[<bf052e70>] (mos7715_interrupt_callback [mos7720]) from [<c052a894>] (__usb_hcd_giveback_urb+0x80/0x140)
[<c052a894>] (__usb_hcd_giveback_urb) from [<c052a9a4>] (usb_hcd_giveback_urb+0x50/0x138)
[<c052a9a4>] (usb_hcd_giveback_urb) from [<c0550684>] (musb_giveback+0xc8/0x1cc)

Fixes: b69578df7e98 ("USB: usbserial: mos7720: add support for parallel port on moschip 7715")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/serial/mos7720.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -1965,8 +1965,10 @@ static int mos7720_startup(struct usb_se
 #ifdef CONFIG_USB_SERIAL_MOS7715_PARPORT
 	if (product == MOSCHIP_DEVICE_ID_7715) {
 		ret_val = mos7715_parport_init(serial);
-		if (ret_val < 0)
+		if (ret_val < 0) {
+			usb_kill_urb(serial->port[0]->interrupt_in_urb);
 			return ret_val;
+		}
 	}
 #endif
 	/* LSR For Port 1 */
@@ -1978,6 +1980,8 @@ static int mos7720_startup(struct usb_se
 
 static void mos7720_release(struct usb_serial *serial)
 {
+	usb_kill_urb(serial->port[0]->interrupt_in_urb);
+
 #ifdef CONFIG_USB_SERIAL_MOS7715_PARPORT
 	/* close the parallel port */
 

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 061/206] USB: serial: mos7720: fix parport use-after-free on probe errors
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (52 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 060/206] USB: serial: mos7720: fix use-after-free on probe errors Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 062/206] USB: serial: mos7720: fix parallel probe Greg Kroah-Hartman
                     ` (135 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Johan Hovold

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Johan Hovold <johan@kernel.org>

commit 75dd211e773afcbc264677b0749d1cf7d937ab2d upstream.

Do not submit the interrupt URB until after the parport has been
successfully registered to avoid another use-after-free in the
completion handler when accessing the freed parport private data in case
of a racing completion.

Fixes: b69578df7e98 ("USB: usbserial: mos7720: add support for parallel port on moschip 7715")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/serial/mos7720.c |   18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -1955,22 +1955,20 @@ static int mos7720_startup(struct usb_se
 	usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
 			(__u8)0x03, 0x00, 0x01, 0x00, NULL, 0x00, 5000);
 
-	/* start the interrupt urb */
-	ret_val = usb_submit_urb(serial->port[0]->interrupt_in_urb, GFP_KERNEL);
-	if (ret_val)
-		dev_err(&dev->dev,
-			"%s - Error %d submitting control urb\n",
-			__func__, ret_val);
-
 #ifdef CONFIG_USB_SERIAL_MOS7715_PARPORT
 	if (product == MOSCHIP_DEVICE_ID_7715) {
 		ret_val = mos7715_parport_init(serial);
-		if (ret_val < 0) {
-			usb_kill_urb(serial->port[0]->interrupt_in_urb);
+		if (ret_val < 0)
 			return ret_val;
-		}
 	}
 #endif
+	/* start the interrupt urb */
+	ret_val = usb_submit_urb(serial->port[0]->interrupt_in_urb, GFP_KERNEL);
+	if (ret_val) {
+		dev_err(&dev->dev, "failed to submit interrupt urb: %d\n",
+			ret_val);
+	}
+
 	/* LSR For Port 1 */
 	read_mos_reg(serial, 0, MOS7720_LSR, &data);
 	dev_dbg(&dev->dev, "LSR:%x\n", data);

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 062/206] USB: serial: mos7720: fix parallel probe
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (53 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 061/206] USB: serial: mos7720: fix parport " Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 063/206] usb: xhci-mem: use passed in GFP flags instead of GFP_KERNEL Greg Kroah-Hartman
                     ` (134 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Johan Hovold

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Johan Hovold <johan@kernel.org>

commit fde1faf872ed86d88e245191bc15a8e57368cd1c upstream.

A static usb-serial-driver structure that is used to initialise the
interrupt URB was modified during probe depending on the currently
probed device type, something which could break a parallel probe of a
device of a different type.

Fix this up by overriding the default completion callback for MCS7715
devices in attach() instead. We may want to use two usb-serial driver
instances for the two types later.

Fixes: fb088e335d78 ("USB: serial: add support for serial port on the moschip 7715")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/serial/mos7720.c |   30 +++++++-----------------------
 1 file changed, 7 insertions(+), 23 deletions(-)

--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -65,8 +65,6 @@ struct moschip_port {
 	struct urb		*write_urb_pool[NUM_URBS];
 };
 
-static struct usb_serial_driver moschip7720_2port_driver;
-
 #define USB_VENDOR_ID_MOSCHIP		0x9710
 #define MOSCHIP_DEVICE_ID_7720		0x7720
 #define MOSCHIP_DEVICE_ID_7715		0x7715
@@ -970,25 +968,6 @@ static void mos7720_bulk_out_data_callba
 		tty_port_tty_wakeup(&mos7720_port->port->port);
 }
 
-/*
- * mos77xx_probe
- *	this function installs the appropriate read interrupt endpoint callback
- *	depending on whether the device is a 7720 or 7715, thus avoiding costly
- *	run-time checks in the high-frequency callback routine itself.
- */
-static int mos77xx_probe(struct usb_serial *serial,
-			 const struct usb_device_id *id)
-{
-	if (id->idProduct == MOSCHIP_DEVICE_ID_7715)
-		moschip7720_2port_driver.read_int_callback =
-			mos7715_interrupt_callback;
-	else
-		moschip7720_2port_driver.read_int_callback =
-			mos7720_interrupt_callback;
-
-	return 0;
-}
-
 static int mos77xx_calc_num_ports(struct usb_serial *serial)
 {
 	u16 product = le16_to_cpu(serial->dev->descriptor.idProduct);
@@ -1949,6 +1928,12 @@ static int mos7720_startup(struct usb_se
 			tmp->interrupt_in_endpointAddress;
 		serial->port[1]->interrupt_in_urb = NULL;
 		serial->port[1]->interrupt_in_buffer = NULL;
+
+		if (serial->port[0]->interrupt_in_urb) {
+			struct urb *urb = serial->port[0]->interrupt_in_urb;
+
+			urb->complete = mos7715_interrupt_callback;
+		}
 	}
 
 	/* setting configuration feature to one */
@@ -2063,7 +2048,6 @@ static struct usb_serial_driver moschip7
 	.close			= mos7720_close,
 	.throttle		= mos7720_throttle,
 	.unthrottle		= mos7720_unthrottle,
-	.probe			= mos77xx_probe,
 	.attach			= mos7720_startup,
 	.release		= mos7720_release,
 	.port_probe		= mos7720_port_probe,
@@ -2077,7 +2061,7 @@ static struct usb_serial_driver moschip7
 	.chars_in_buffer	= mos7720_chars_in_buffer,
 	.break_ctl		= mos7720_break,
 	.read_bulk_callback	= mos7720_bulk_in_callback,
-	.read_int_callback	= NULL  /* dynamically assigned in probe() */
+	.read_int_callback	= mos7720_interrupt_callback,
 };
 
 static struct usb_serial_driver * const serial_drivers[] = {

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 063/206] usb: xhci-mem: use passed in GFP flags instead of GFP_KERNEL
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (54 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 062/206] USB: serial: mos7720: fix parallel probe Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 064/206] xhci: Use delayed_work instead of timer for command timeout Greg Kroah-Hartman
                     ` (133 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Mathias Nyman, Dan Carpenter,
	Sebastian Andrzej Siewior

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Dan Carpenter <dan.carpenter@oracle.com>

commit c95a9f83711bf53faeb4ed9bbb63a3f065613dfb upstream.

We normally use the passed in gfp flags for allocations, it's just these
two which were missed.

Fixes: 22d45f01a836 ("usb/xhci: replace pci_*_consistent() with dma_*_coherent()")
Cc: Mathias Nyman <mathias.nyman@intel.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/host/xhci-mem.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -2418,7 +2418,7 @@ int xhci_mem_init(struct xhci_hcd *xhci,
 	 * "physically contiguous and 64-byte (cache line) aligned".
 	 */
 	xhci->dcbaa = dma_alloc_coherent(dev, sizeof(*xhci->dcbaa), &dma,
-			GFP_KERNEL);
+			flags);
 	if (!xhci->dcbaa)
 		goto fail;
 	memset(xhci->dcbaa, 0, sizeof *(xhci->dcbaa));
@@ -2514,7 +2514,7 @@ int xhci_mem_init(struct xhci_hcd *xhci,
 
 	xhci->erst.entries = dma_alloc_coherent(dev,
 			sizeof(struct xhci_erst_entry) * ERST_NUM_SEGS, &dma,
-			GFP_KERNEL);
+			flags);
 	if (!xhci->erst.entries)
 		goto fail;
 	xhci_dbg_trace(xhci, trace_xhci_dbg_init,

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 064/206] xhci: Use delayed_work instead of timer for command timeout
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (55 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 063/206] usb: xhci-mem: use passed in GFP flags instead of GFP_KERNEL Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 065/206] xhci: Fix race related to abort operation Greg Kroah-Hartman
                     ` (132 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, OGAWA Hirofumi, Mathias Nyman

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

commit cb4d5ce588c5ff68e0fdd30370a0e6bc2c0a736b upstream.

This is preparation to fix abort operation race (See "xhci: Fix race
related to abort operation"). To make timeout sleepable, use
delayed_work instead of timer.

[change a newly added pending timer fix to pending work -Mathias]
Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/host/xhci-mem.c  |    7 +++----
 drivers/usb/host/xhci-ring.c |   26 ++++++++++++++++----------
 drivers/usb/host/xhci.h      |    4 ++--
 3 files changed, 21 insertions(+), 16 deletions(-)

--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -1830,7 +1830,7 @@ void xhci_mem_cleanup(struct xhci_hcd *x
 	int size;
 	int i, j, num_ports;
 
-	del_timer_sync(&xhci->cmd_timer);
+	cancel_delayed_work_sync(&xhci->cmd_timer);
 
 	/* Free the Event Ring Segment Table and the actual Event Ring */
 	size = sizeof(struct xhci_erst_entry)*(xhci->erst.num_entries);
@@ -2377,9 +2377,8 @@ int xhci_mem_init(struct xhci_hcd *xhci,
 
 	INIT_LIST_HEAD(&xhci->cmd_list);
 
-	/* init command timeout timer */
-	setup_timer(&xhci->cmd_timer, xhci_handle_command_timeout,
-		    (unsigned long)xhci);
+	/* init command timeout work */
+	INIT_DELAYED_WORK(&xhci->cmd_timer, xhci_handle_command_timeout);
 
 	page_size = readl(&xhci->op_regs->page_size);
 	xhci_dbg_trace(xhci, trace_xhci_dbg_init,
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -260,6 +260,11 @@ void xhci_ring_cmd_db(struct xhci_hcd *x
 	readl(&xhci->dba->doorbell[0]);
 }
 
+static bool xhci_mod_cmd_timer(struct xhci_hcd *xhci, unsigned long delay)
+{
+	return mod_delayed_work(system_wq, &xhci->cmd_timer, delay);
+}
+
 static int xhci_abort_cmd_ring(struct xhci_hcd *xhci)
 {
 	u64 temp_64;
@@ -276,7 +281,7 @@ static int xhci_abort_cmd_ring(struct xh
 	 * but the completion event in never sent. Use the cmd timeout timer to
 	 * handle those cases. Use twice the time to cover the bit polling retry
 	 */
-	mod_timer(&xhci->cmd_timer, jiffies + (2 * XHCI_CMD_DEFAULT_TIMEOUT));
+	xhci_mod_cmd_timer(xhci, 2 * XHCI_CMD_DEFAULT_TIMEOUT);
 	xhci_write_64(xhci, temp_64 | CMD_RING_ABORT,
 			&xhci->op_regs->cmd_ring);
 
@@ -301,7 +306,7 @@ static int xhci_abort_cmd_ring(struct xh
 
 		xhci_err(xhci, "Stopped the command ring failed, "
 				"maybe the host is dead\n");
-		del_timer(&xhci->cmd_timer);
+		cancel_delayed_work(&xhci->cmd_timer);
 		xhci->xhc_state |= XHCI_STATE_DYING;
 		xhci_quiesce(xhci);
 		xhci_halt(xhci);
@@ -1255,21 +1260,22 @@ static void xhci_handle_stopped_cmd_ring
 	if ((xhci->cmd_ring->dequeue != xhci->cmd_ring->enqueue) &&
 	    !(xhci->xhc_state & XHCI_STATE_DYING)) {
 		xhci->current_cmd = cur_cmd;
-		mod_timer(&xhci->cmd_timer, jiffies + XHCI_CMD_DEFAULT_TIMEOUT);
+		xhci_mod_cmd_timer(xhci, XHCI_CMD_DEFAULT_TIMEOUT);
 		xhci_ring_cmd_db(xhci);
 	}
 	return;
 }
 
 
-void xhci_handle_command_timeout(unsigned long data)
+void xhci_handle_command_timeout(struct work_struct *work)
 {
 	struct xhci_hcd *xhci;
 	int ret;
 	unsigned long flags;
 	u64 hw_ring_state;
 	bool second_timeout = false;
-	xhci = (struct xhci_hcd *) data;
+
+	xhci = container_of(to_delayed_work(work), struct xhci_hcd, cmd_timer);
 
 	spin_lock_irqsave(&xhci->lock, flags);
 
@@ -1277,7 +1283,7 @@ void xhci_handle_command_timeout(unsigne
 	 * If timeout work is pending, or current_cmd is NULL, it means we
 	 * raced with command completion. Command is handled so just return.
 	 */
-	if (!xhci->current_cmd || timer_pending(&xhci->cmd_timer)) {
+	if (!xhci->current_cmd || delayed_work_pending(&xhci->cmd_timer)) {
 		spin_unlock_irqrestore(&xhci->lock, flags);
 		return;
 	}
@@ -1351,7 +1357,7 @@ static void handle_cmd_completion(struct
 
 	cmd = list_entry(xhci->cmd_list.next, struct xhci_command, cmd_list);
 
-	del_timer(&xhci->cmd_timer);
+	cancel_delayed_work(&xhci->cmd_timer);
 
 	trace_xhci_cmd_completion(cmd_trb, (struct xhci_generic_trb *) event);
 
@@ -1442,7 +1448,7 @@ static void handle_cmd_completion(struct
 	if (cmd->cmd_list.next != &xhci->cmd_list) {
 		xhci->current_cmd = list_entry(cmd->cmd_list.next,
 					       struct xhci_command, cmd_list);
-		mod_timer(&xhci->cmd_timer, jiffies + XHCI_CMD_DEFAULT_TIMEOUT);
+		xhci_mod_cmd_timer(xhci, XHCI_CMD_DEFAULT_TIMEOUT);
 	} else if (xhci->current_cmd == cmd) {
 		xhci->current_cmd = NULL;
 	}
@@ -3938,9 +3944,9 @@ static int queue_command(struct xhci_hcd
 
 	/* if there are no other commands queued we start the timeout timer */
 	if (xhci->cmd_list.next == &cmd->cmd_list &&
-	    !timer_pending(&xhci->cmd_timer)) {
+	    !delayed_work_pending(&xhci->cmd_timer)) {
 		xhci->current_cmd = cmd;
-		mod_timer(&xhci->cmd_timer, jiffies + XHCI_CMD_DEFAULT_TIMEOUT);
+		xhci_mod_cmd_timer(xhci, XHCI_CMD_DEFAULT_TIMEOUT);
 	}
 
 	queue_trb(xhci, xhci->cmd_ring, false, field1, field2, field3,
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1571,7 +1571,7 @@ struct xhci_hcd {
 #define CMD_RING_STATE_STOPPED         (1 << 2)
 	struct list_head        cmd_list;
 	unsigned int		cmd_ring_reserved_trbs;
-	struct timer_list	cmd_timer;
+	struct delayed_work	cmd_timer;
 	struct xhci_command	*current_cmd;
 	struct xhci_ring	*event_ring;
 	struct xhci_erst	erst;
@@ -1941,7 +1941,7 @@ void xhci_queue_config_ep_quirk(struct x
 		unsigned int slot_id, unsigned int ep_index,
 		struct xhci_dequeue_state *deq_state);
 void xhci_stop_endpoint_command_watchdog(unsigned long arg);
-void xhci_handle_command_timeout(unsigned long data);
+void xhci_handle_command_timeout(struct work_struct *work);
 
 void xhci_ring_ep_doorbell(struct xhci_hcd *xhci, unsigned int slot_id,
 		unsigned int ep_index, unsigned int stream_id);

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 065/206] xhci: Fix race related to abort operation
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (56 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 064/206] xhci: Use delayed_work instead of timer for command timeout Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 066/206] usb: dwc3: pci: add Intel Gemini Lake PCI ID Greg Kroah-Hartman
                     ` (131 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, OGAWA Hirofumi, Mathias Nyman

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

commit 1c111b6c3844a142e03bcfc2fa17bfbdea08e9dc upstream.

Current abort operation has race.

    xhci_handle_command_timeout()
      xhci_abort_cmd_ring()
        xhci_write_64(CMD_RING_ABORT)
        xhci_handshake(5s)
	  do {
	    check CMD_RING_RUNNING
            udelay(1)
					 ...
					 COMP_CMD_ABORT event
					 COMP_CMD_STOP event
					 xhci_handle_stopped_cmd_ring()
					   restart cmd_ring
                                           CMD_RING_RUNNING become 1 again
	  } while ()
          return -ETIMEDOUT
        xhci_write_64(CMD_RING_ABORT)
        /* can abort random command */

To do abort operation correctly, we have to wait both of COMP_CMD_STOP
event and negation of CMD_RING_RUNNING.

But like above, while timeout handler is waiting negation of
CMD_RING_RUNNING, event handler can restart cmd_ring. So timeout
handler never be notice negation of CMD_RING_RUNNING, and retry of
CMD_RING_ABORT can abort random command (BTW, I guess retry of
CMD_RING_ABORT was workaround of this race).

To fix this race, this moves xhci_handle_stopped_cmd_ring() to
xhci_abort_cmd_ring().  And timeout handler waits COMP_CMD_STOP event.

At this point, timeout handler is owner of cmd_ring, and safely
restart cmd_ring by using xhci_handle_stopped_cmd_ring().

[FWIW, as bonus, this way would be easily extend to add CMD_RING_PAUSE
operation]

[locks edited as patch is rebased on other locking fixes -Mathias]
Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/host/xhci-mem.c  |    1 
 drivers/usb/host/xhci-ring.c |  169 ++++++++++++++++++++++---------------------
 drivers/usb/host/xhci.h      |    1 
 3 files changed, 91 insertions(+), 80 deletions(-)

--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -2379,6 +2379,7 @@ int xhci_mem_init(struct xhci_hcd *xhci,
 
 	/* init command timeout work */
 	INIT_DELAYED_WORK(&xhci->cmd_timer, xhci_handle_command_timeout);
+	init_completion(&xhci->cmd_ring_stop_completion);
 
 	page_size = readl(&xhci->op_regs->page_size);
 	xhci_dbg_trace(xhci, trace_xhci_dbg_init,
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -265,23 +265,71 @@ static bool xhci_mod_cmd_timer(struct xh
 	return mod_delayed_work(system_wq, &xhci->cmd_timer, delay);
 }
 
-static int xhci_abort_cmd_ring(struct xhci_hcd *xhci)
+static struct xhci_command *xhci_next_queued_cmd(struct xhci_hcd *xhci)
+{
+	return list_first_entry_or_null(&xhci->cmd_list, struct xhci_command,
+					cmd_list);
+}
+
+/*
+ * Turn all commands on command ring with status set to "aborted" to no-op trbs.
+ * If there are other commands waiting then restart the ring and kick the timer.
+ * This must be called with command ring stopped and xhci->lock held.
+ */
+static void xhci_handle_stopped_cmd_ring(struct xhci_hcd *xhci,
+					 struct xhci_command *cur_cmd)
+{
+	struct xhci_command *i_cmd;
+	u32 cycle_state;
+
+	/* Turn all aborted commands in list to no-ops, then restart */
+	list_for_each_entry(i_cmd, &xhci->cmd_list, cmd_list) {
+
+		if (i_cmd->status != COMP_CMD_ABORT)
+			continue;
+
+		i_cmd->status = COMP_CMD_STOP;
+
+		xhci_dbg(xhci, "Turn aborted command %p to no-op\n",
+			 i_cmd->command_trb);
+		/* get cycle state from the original cmd trb */
+		cycle_state = le32_to_cpu(
+			i_cmd->command_trb->generic.field[3]) &	TRB_CYCLE;
+		/* modify the command trb to no-op command */
+		i_cmd->command_trb->generic.field[0] = 0;
+		i_cmd->command_trb->generic.field[1] = 0;
+		i_cmd->command_trb->generic.field[2] = 0;
+		i_cmd->command_trb->generic.field[3] = cpu_to_le32(
+			TRB_TYPE(TRB_CMD_NOOP) | cycle_state);
+
+		/*
+		 * caller waiting for completion is called when command
+		 *  completion event is received for these no-op commands
+		 */
+	}
+
+	xhci->cmd_ring_state = CMD_RING_STATE_RUNNING;
+
+	/* ring command ring doorbell to restart the command ring */
+	if ((xhci->cmd_ring->dequeue != xhci->cmd_ring->enqueue) &&
+	    !(xhci->xhc_state & XHCI_STATE_DYING)) {
+		xhci->current_cmd = cur_cmd;
+		xhci_mod_cmd_timer(xhci, XHCI_CMD_DEFAULT_TIMEOUT);
+		xhci_ring_cmd_db(xhci);
+	}
+}
+
+/* Must be called with xhci->lock held, releases and aquires lock back */
+static int xhci_abort_cmd_ring(struct xhci_hcd *xhci, unsigned long flags)
 {
 	u64 temp_64;
 	int ret;
 
 	xhci_dbg(xhci, "Abort command ring\n");
 
-	temp_64 = xhci_read_64(xhci, &xhci->op_regs->cmd_ring);
-	xhci->cmd_ring_state = CMD_RING_STATE_ABORTED;
+	reinit_completion(&xhci->cmd_ring_stop_completion);
 
-	/*
-	 * Writing the CMD_RING_ABORT bit should cause a cmd completion event,
-	 * however on some host hw the CMD_RING_RUNNING bit is correctly cleared
-	 * but the completion event in never sent. Use the cmd timeout timer to
-	 * handle those cases. Use twice the time to cover the bit polling retry
-	 */
-	xhci_mod_cmd_timer(xhci, 2 * XHCI_CMD_DEFAULT_TIMEOUT);
+	temp_64 = xhci_read_64(xhci, &xhci->op_regs->cmd_ring);
 	xhci_write_64(xhci, temp_64 | CMD_RING_ABORT,
 			&xhci->op_regs->cmd_ring);
 
@@ -301,16 +349,30 @@ static int xhci_abort_cmd_ring(struct xh
 		udelay(1000);
 		ret = xhci_handshake(&xhci->op_regs->cmd_ring,
 				     CMD_RING_RUNNING, 0, 3 * 1000 * 1000);
-		if (ret == 0)
-			return 0;
-
-		xhci_err(xhci, "Stopped the command ring failed, "
-				"maybe the host is dead\n");
-		cancel_delayed_work(&xhci->cmd_timer);
-		xhci->xhc_state |= XHCI_STATE_DYING;
-		xhci_quiesce(xhci);
-		xhci_halt(xhci);
-		return -ESHUTDOWN;
+		if (ret < 0) {
+			xhci_err(xhci, "Stopped the command ring failed, "
+				 "maybe the host is dead\n");
+			xhci->xhc_state |= XHCI_STATE_DYING;
+			xhci_quiesce(xhci);
+			xhci_halt(xhci);
+			return -ESHUTDOWN;
+		}
+	}
+	/*
+	 * Writing the CMD_RING_ABORT bit should cause a cmd completion event,
+	 * however on some host hw the CMD_RING_RUNNING bit is correctly cleared
+	 * but the completion event in never sent. Wait 2 secs (arbitrary
+	 * number) to handle those cases after negation of CMD_RING_RUNNING.
+	 */
+	spin_unlock_irqrestore(&xhci->lock, flags);
+	ret = wait_for_completion_timeout(&xhci->cmd_ring_stop_completion,
+					  msecs_to_jiffies(2000));
+	spin_lock_irqsave(&xhci->lock, flags);
+	if (!ret) {
+		xhci_dbg(xhci, "No stop event for abort, ring start fail?\n");
+		xhci_cleanup_command_queue(xhci);
+	} else {
+		xhci_handle_stopped_cmd_ring(xhci, xhci_next_queued_cmd(xhci));
 	}
 
 	return 0;
@@ -1216,64 +1278,12 @@ void xhci_cleanup_command_queue(struct x
 		xhci_complete_del_and_free_cmd(cur_cmd, COMP_CMD_ABORT);
 }
 
-/*
- * Turn all commands on command ring with status set to "aborted" to no-op trbs.
- * If there are other commands waiting then restart the ring and kick the timer.
- * This must be called with command ring stopped and xhci->lock held.
- */
-static void xhci_handle_stopped_cmd_ring(struct xhci_hcd *xhci,
-					 struct xhci_command *cur_cmd)
-{
-	struct xhci_command *i_cmd, *tmp_cmd;
-	u32 cycle_state;
-
-	/* Turn all aborted commands in list to no-ops, then restart */
-	list_for_each_entry_safe(i_cmd, tmp_cmd, &xhci->cmd_list,
-				 cmd_list) {
-
-		if (i_cmd->status != COMP_CMD_ABORT)
-			continue;
-
-		i_cmd->status = COMP_CMD_STOP;
-
-		xhci_dbg(xhci, "Turn aborted command %p to no-op\n",
-			 i_cmd->command_trb);
-		/* get cycle state from the original cmd trb */
-		cycle_state = le32_to_cpu(
-			i_cmd->command_trb->generic.field[3]) &	TRB_CYCLE;
-		/* modify the command trb to no-op command */
-		i_cmd->command_trb->generic.field[0] = 0;
-		i_cmd->command_trb->generic.field[1] = 0;
-		i_cmd->command_trb->generic.field[2] = 0;
-		i_cmd->command_trb->generic.field[3] = cpu_to_le32(
-			TRB_TYPE(TRB_CMD_NOOP) | cycle_state);
-
-		/*
-		 * caller waiting for completion is called when command
-		 *  completion event is received for these no-op commands
-		 */
-	}
-
-	xhci->cmd_ring_state = CMD_RING_STATE_RUNNING;
-
-	/* ring command ring doorbell to restart the command ring */
-	if ((xhci->cmd_ring->dequeue != xhci->cmd_ring->enqueue) &&
-	    !(xhci->xhc_state & XHCI_STATE_DYING)) {
-		xhci->current_cmd = cur_cmd;
-		xhci_mod_cmd_timer(xhci, XHCI_CMD_DEFAULT_TIMEOUT);
-		xhci_ring_cmd_db(xhci);
-	}
-	return;
-}
-
-
 void xhci_handle_command_timeout(struct work_struct *work)
 {
 	struct xhci_hcd *xhci;
 	int ret;
 	unsigned long flags;
 	u64 hw_ring_state;
-	bool second_timeout = false;
 
 	xhci = container_of(to_delayed_work(work), struct xhci_hcd, cmd_timer);
 
@@ -1287,18 +1297,17 @@ void xhci_handle_command_timeout(struct
 		spin_unlock_irqrestore(&xhci->lock, flags);
 		return;
 	}
-
 	/* mark this command to be cancelled */
-	if (xhci->current_cmd->status == COMP_CMD_ABORT)
-		second_timeout = true;
 	xhci->current_cmd->status = COMP_CMD_ABORT;
 
 	/* Make sure command ring is running before aborting it */
 	hw_ring_state = xhci_read_64(xhci, &xhci->op_regs->cmd_ring);
 	if ((xhci->cmd_ring_state & CMD_RING_STATE_RUNNING) &&
 	    (hw_ring_state & CMD_RING_RUNNING))  {
+		/* Prevent new doorbell, and start command abort */
+		xhci->cmd_ring_state = CMD_RING_STATE_ABORTED;
 		xhci_dbg(xhci, "Command timeout\n");
-		ret = xhci_abort_cmd_ring(xhci);
+		ret = xhci_abort_cmd_ring(xhci, flags);
 		if (unlikely(ret == -ESHUTDOWN)) {
 			xhci_err(xhci, "Abort command ring failed\n");
 			xhci_cleanup_command_queue(xhci);
@@ -1312,9 +1321,9 @@ void xhci_handle_command_timeout(struct
 		goto time_out_completed;
 	}
 
-	/* command ring failed to restart, or host removed. Bail out */
-	if (second_timeout || xhci->xhc_state & XHCI_STATE_REMOVING) {
-		xhci_dbg(xhci, "command timed out twice, ring start fail?\n");
+	/* host removed. Bail out */
+	if (xhci->xhc_state & XHCI_STATE_REMOVING) {
+		xhci_dbg(xhci, "host removed, ring start fail?\n");
 		xhci_cleanup_command_queue(xhci);
 
 		goto time_out_completed;
@@ -1365,7 +1374,7 @@ static void handle_cmd_completion(struct
 
 	/* If CMD ring stopped we own the trbs between enqueue and dequeue */
 	if (cmd_comp_code == COMP_CMD_STOP) {
-		xhci_handle_stopped_cmd_ring(xhci, cmd);
+		complete_all(&xhci->cmd_ring_stop_completion);
 		return;
 	}
 
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1572,6 +1572,7 @@ struct xhci_hcd {
 	struct list_head        cmd_list;
 	unsigned int		cmd_ring_reserved_trbs;
 	struct delayed_work	cmd_timer;
+	struct completion	cmd_ring_stop_completion;
 	struct xhci_command	*current_cmd;
 	struct xhci_ring	*event_ring;
 	struct xhci_erst	erst;

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 066/206] usb: dwc3: pci: add Intel Gemini Lake PCI ID
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (57 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 065/206] xhci: Fix race related to abort operation Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 067/206] usb: dwc3: pci: Fix dr_mode misspelling Greg Kroah-Hartman
                     ` (130 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Heikki Krogerus, Felipe Balbi

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Heikki Krogerus <heikki.krogerus@linux.intel.com>

commit 8f8983a5683623b62b339d159573f95a1fce44f3 upstream.

Intel Gemini Lake SoC has the same DWC3 than Broxton. Add
the new ID to the supported Devices.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/dwc3/dwc3-pci.c |    2 ++
 1 file changed, 2 insertions(+)

--- a/drivers/usb/dwc3/dwc3-pci.c
+++ b/drivers/usb/dwc3/dwc3-pci.c
@@ -38,6 +38,7 @@
 #define PCI_DEVICE_ID_INTEL_BXT_M		0x1aaa
 #define PCI_DEVICE_ID_INTEL_APL			0x5aaa
 #define PCI_DEVICE_ID_INTEL_KBP			0xa2b0
+#define PCI_DEVICE_ID_INTEL_GLK			0x31aa
 
 static const struct acpi_gpio_params reset_gpios = { 0, 0, false };
 static const struct acpi_gpio_params cs_gpios = { 1, 0, false };
@@ -229,6 +230,7 @@ static const struct pci_device_id dwc3_p
 	{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BXT_M), },
 	{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_APL), },
 	{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_KBP), },
+	{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_GLK), },
 	{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL_USB), },
 	{  }	/* Terminating Entry */
 };

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 067/206] usb: dwc3: pci: Fix dr_mode misspelling
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (58 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 066/206] usb: dwc3: pci: add Intel Gemini Lake PCI ID Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 068/206] usb: dwc3: gadget: Fix full speed mode Greg Kroah-Hartman
                     ` (129 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Felipe Balbi, Hans de Goede

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Hans de Goede <hdegoede@redhat.com>

commit 51c1685d956221576e165dd88a20063b169bae5a upstream.

usb_get_dr_mode() expects the device-property to be spelled
"dr_mode" not "dr-mode".

Spelling it properly fixes the following warning showing up in dmesg:
[ 8704.500545] dwc3 dwc3.2.auto: Configuration mismatch. dr_mode forced to gadget

Signed-off-by: Hans de Goede <hdegoede@redhat.com
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/dwc3/dwc3-pci.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/usb/dwc3/dwc3-pci.c
+++ b/drivers/usb/dwc3/dwc3-pci.c
@@ -82,7 +82,7 @@ static int dwc3_pci_quirks(struct pci_de
 		int ret;
 
 		struct property_entry properties[] = {
-			PROPERTY_ENTRY_STRING("dr-mode", "peripheral"),
+			PROPERTY_ENTRY_STRING("dr_mode", "peripheral"),
 			{ }
 		};
 

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 068/206] usb: dwc3: gadget: Fix full speed mode
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (59 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 067/206] usb: dwc3: pci: Fix dr_mode misspelling Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 069/206] usb: musb: Fix trying to free already-free IRQ 4 Greg Kroah-Hartman
                     ` (128 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, John Youn, Roger Quadros, Felipe Balbi

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Roger Quadros <rogerq@ti.com>

commit 9418ee15f718939aa7e650fd586d73765eb21f20 upstream.

DCFG.DEVSPD == 0x3 is not valid and we need to set
DCFG.DEVSPD to 0x1 for full speed mode. Same goes for
DSTS.CONNECTSPD.

Old databooks had 0x3 for full speed in 48MHz mode for
USB1.1 transceivers which was never supported. Newer databooks
don't mention 0x3 at all.

Cc: John Youn <John.Youn@synopsys.com>
Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/dwc3/core.h   |    6 ++----
 drivers/usb/dwc3/gadget.c |    5 ++---
 2 files changed, 4 insertions(+), 7 deletions(-)

--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -301,9 +301,8 @@
 #define DWC3_DCFG_SUPERSPEED_PLUS (5 << 0)  /* DWC_usb31 only */
 #define DWC3_DCFG_SUPERSPEED	(4 << 0)
 #define DWC3_DCFG_HIGHSPEED	(0 << 0)
-#define DWC3_DCFG_FULLSPEED2	(1 << 0)
+#define DWC3_DCFG_FULLSPEED	(1 << 0)
 #define DWC3_DCFG_LOWSPEED	(2 << 0)
-#define DWC3_DCFG_FULLSPEED1	(3 << 0)
 
 #define DWC3_DCFG_NUMP_SHIFT	17
 #define DWC3_DCFG_NUMP(n)	(((n) >> DWC3_DCFG_NUMP_SHIFT) & 0x1f)
@@ -395,9 +394,8 @@
 #define DWC3_DSTS_SUPERSPEED_PLUS	(5 << 0) /* DWC_usb31 only */
 #define DWC3_DSTS_SUPERSPEED		(4 << 0)
 #define DWC3_DSTS_HIGHSPEED		(0 << 0)
-#define DWC3_DSTS_FULLSPEED2		(1 << 0)
+#define DWC3_DSTS_FULLSPEED		(1 << 0)
 #define DWC3_DSTS_LOWSPEED		(2 << 0)
-#define DWC3_DSTS_FULLSPEED1		(3 << 0)
 
 /* Device Generic Command Register */
 #define DWC3_DGCMD_SET_LMP		0x01
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1606,7 +1606,7 @@ static int __dwc3_gadget_start(struct dw
 			reg |= DWC3_DCFG_LOWSPEED;
 			break;
 		case USB_SPEED_FULL:
-			reg |= DWC3_DCFG_FULLSPEED1;
+			reg |= DWC3_DCFG_FULLSPEED;
 			break;
 		case USB_SPEED_HIGH:
 			reg |= DWC3_DCFG_HIGHSPEED;
@@ -2465,8 +2465,7 @@ static void dwc3_gadget_conndone_interru
 		dwc->gadget.ep0->maxpacket = 64;
 		dwc->gadget.speed = USB_SPEED_HIGH;
 		break;
-	case DWC3_DSTS_FULLSPEED2:
-	case DWC3_DSTS_FULLSPEED1:
+	case DWC3_DSTS_FULLSPEED:
 		dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(64);
 		dwc->gadget.ep0->maxpacket = 64;
 		dwc->gadget.speed = USB_SPEED_FULL;

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 069/206] usb: musb: Fix trying to free already-free IRQ 4
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (60 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 068/206] usb: dwc3: gadget: Fix full speed mode Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 073/206] ALSA: usb-audio: Fix bogus error return in snd_usb_create_stream() Greg Kroah-Hartman
                     ` (127 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Tony Lindgren, Bin Liu

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Tony Lindgren <tony@atomide.com>

commit 8c300fe282fa254ea730c92cb0983e2642dc1fff upstream.

When unloading omap2430, we can get the following splat:

WARNING: CPU: 1 PID: 295 at kernel/irq/manage.c:1478 __free_irq+0xa8/0x2c8
Trying to free already-free IRQ 4
...
[<c01a8b78>] (free_irq) from [<bf0aea84>]
(musbhs_dma_controller_destroy+0x28/0xb0 [musb_hdrc])
[<bf0aea84>] (musbhs_dma_controller_destroy [musb_hdrc]) from
[<bf09f88c>] (musb_remove+0xf0/0x12c [musb_hdrc])
[<bf09f88c>] (musb_remove [musb_hdrc]) from [<c056a384>]
(platform_drv_remove+0x24/0x3c)
...

This is because the irq number in use is 260 nowadays, and the dma
controller is using u8 instead of int.

Fixes: 6995eb68aab7 ("USB: musb: enable low level DMA operation for Blackfin")
Signed-off-by: Tony Lindgren <tony@atomide.com>
[b-liu@ti.com: added Fixes tag]
Signed-off-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/musb/musbhsdma.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/usb/musb/musbhsdma.h
+++ b/drivers/usb/musb/musbhsdma.h
@@ -157,5 +157,5 @@ struct musb_dma_controller {
 	void __iomem			*base;
 	u8				channel_count;
 	u8				used_channels;
-	u8				irq;
+	int				irq;
 };

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 073/206] ALSA: usb-audio: Fix bogus error return in snd_usb_create_stream()
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (61 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 069/206] usb: musb: Fix trying to free already-free IRQ 4 Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 074/206] USB: serial: kl5kusb105: abort on open exception path Greg Kroah-Hartman
                     ` (126 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Takashi Iwai

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Takashi Iwai <tiwai@suse.de>

commit 4763601a56f155ddf94ef35fc2c41504a2de15f5 upstream.

The function returns -EINVAL even if it builds the stream properly.
The bogus error code sneaked in during the code refactoring, but it
wasn't noticed until now since the returned error code itself is
ignored in anyway.  Kill it here, but there is no behavior change by
this patch, obviously.

Fixes: e5779998bf8b ('ALSA: usb-audio: refactor code')
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 sound/usb/card.c |    1 -
 1 file changed, 1 deletion(-)

--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -206,7 +206,6 @@ static int snd_usb_create_stream(struct
 	if (! snd_usb_parse_audio_interface(chip, interface)) {
 		usb_set_interface(dev, interface, 0); /* reset the current interface */
 		usb_driver_claim_interface(&usb_audio_driver, iface, (void *)-1L);
-		return -EINVAL;
 	}
 
 	return 0;

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 074/206] USB: serial: kl5kusb105: abort on open exception path
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (62 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 073/206] ALSA: usb-audio: Fix bogus error return in snd_usb_create_stream() Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 075/206] usb: gadget: Fix second argument of percpu_ida_alloc() Greg Kroah-Hartman
                     ` (125 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Pan Bian, Johan Hovold

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Pan Bian <bianpan2016@163.com>

commit 3c3dd1e058cb01e835dcade4b54a6f13ffaeaf7c upstream.

Function klsi_105_open() calls usb_control_msg() (to "enable read") and
checks its return value. When the return value is unexpected, it only
assigns the error code to the return variable retval, but does not
terminate the exception path. This patch fixes the bug by inserting
"goto err_generic_close;" when the call to usb_control_msg() fails.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Pan Bian <bianpan2016@163.com>
[johan: rebase on prerequisite fix and amend commit message]
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/serial/kl5kusb105.c |    2 ++
 1 file changed, 2 insertions(+)

--- a/drivers/usb/serial/kl5kusb105.c
+++ b/drivers/usb/serial/kl5kusb105.c
@@ -311,6 +311,7 @@ static int  klsi_105_open(struct tty_str
 	if (rc < 0) {
 		dev_err(&port->dev, "Enabling read failed (error = %d)\n", rc);
 		retval = rc;
+		goto err_generic_close;
 	} else
 		dev_dbg(&port->dev, "%s - enabled reading\n", __func__);
 
@@ -337,6 +338,7 @@ err_disable_read:
 			     0, /* index */
 			     NULL, 0,
 			     KLSI_TIMEOUT);
+err_generic_close:
 	usb_serial_generic_close(port);
 err_free_cfg:
 	kfree(cfg);

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 075/206] usb: gadget: Fix second argument of percpu_ida_alloc()
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (63 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 074/206] USB: serial: kl5kusb105: abort on open exception path Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:35   ` [PATCH 4.9 076/206] usb: gadget: fix request length error for isoc transfer Greg Kroah-Hartman
                     ` (124 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Bart Van Assche, Nicholas Bellinger,
	Andrzej Pietrasiewicz, Sebastian Andrzej Siewior, Felipe Balbi

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Bart Van Assche <bart.vanassche@sandisk.com>

commit 03274445c01562d5352ea522431ab8c6175e2bbf upstream.

Pass a task state as second argument to percpu_ida_alloc().

Fixes: commit 71e7ae8e1fb2 ("usb-gadget/tcm: Conversion to percpu_ida tag pre-allocation")
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Nicholas Bellinger <nab@linux-iscsi.org>
Cc: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/gadget/function/f_tcm.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/usb/gadget/function/f_tcm.c
+++ b/drivers/usb/gadget/function/f_tcm.c
@@ -1073,7 +1073,7 @@ static struct usbg_cmd *usbg_get_cmd(str
 	struct usbg_cmd *cmd;
 	int tag;
 
-	tag = percpu_ida_alloc(&se_sess->sess_tag_pool, GFP_ATOMIC);
+	tag = percpu_ida_alloc(&se_sess->sess_tag_pool, TASK_RUNNING);
 	if (tag < 0)
 		return ERR_PTR(-ENOMEM);
 

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 076/206] usb: gadget: fix request length error for isoc transfer
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (64 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 075/206] usb: gadget: Fix second argument of percpu_ida_alloc() Greg Kroah-Hartman
@ 2017-01-10 13:35   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 077/206] ARM: dts: r8a7794: Correct hsusb parent clock Greg Kroah-Hartman
                     ` (123 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:35 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Felipe F. Tonello, Felipe Balbi, Peter Chen

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Peter Chen <peter.chen@nxp.com>

commit 982555fc26f9d8bcdbd5f9db0378fe0682eb4188 upstream.

For isoc endpoint descriptor, the wMaxPacketSize is not real max packet
size (see Table 9-13. Standard Endpoint Descriptor, USB 2.0 specifcation),
it may contain the number of packet, so the real max packet should be
ep->desc->wMaxPacketSize && 0x7ff.

Cc: Felipe F. Tonello <eu@felipetonello.com>
Cc: Felipe Balbi <felipe.balbi@linux.intel.com>
Fixes: 16b114a6d797 ("usb: gadget: fix usb_ep_align_maybe
  endianness and new usb_ep_aligna")
Signed-off-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 include/linux/usb/gadget.h |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -429,7 +429,9 @@ static inline struct usb_gadget *dev_to_
  */
 static inline size_t usb_ep_align(struct usb_ep *ep, size_t len)
 {
-	return round_up(len, (size_t)le16_to_cpu(ep->desc->wMaxPacketSize));
+	int max_packet_size = (size_t)usb_endpoint_maxp(ep->desc) & 0x7ff;
+
+	return round_up(len, max_packet_size);
 }
 
 /**

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 077/206] ARM: dts: r8a7794: Correct hsusb parent clock
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (65 preceding siblings ...)
  2017-01-10 13:35   ` [PATCH 4.9 076/206] usb: gadget: fix request length error for isoc transfer Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 078/206] USB: phy: am335x-control: fix device and of_node leaks Greg Kroah-Hartman
                     ` (122 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Geert Uytterhoeven,
	Yoshihiro Shimoda, Simon Horman

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Geert Uytterhoeven <geert+renesas@glider.be>

commit dc8ee9dbdba509fb58e23ba79f2e6059fe5d8b3b upstream.

The parent clock of the HSUSB clock is the HP clock, not the MP clock.

Fixes: c7bab9f929e51761 ("ARM: shmobile: r8a7794: Add USB clocks to device tree")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/arm/boot/dts/r8a7794.dtsi |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/arch/arm/boot/dts/r8a7794.dtsi
+++ b/arch/arm/boot/dts/r8a7794.dtsi
@@ -1260,7 +1260,7 @@
 		mstp7_clks: mstp7_clks@e615014c {
 			compatible = "renesas,r8a7794-mstp-clocks", "renesas,cpg-mstp-clocks";
 			reg = <0 0xe615014c 0 4>, <0 0xe61501c4 0 4>;
-			clocks = <&mp_clk>, <&mp_clk>,
+			clocks = <&mp_clk>, <&hp_clk>,
 				 <&zs_clk>, <&p_clk>, <&p_clk>, <&zs_clk>,
 				 <&zs_clk>, <&p_clk>, <&p_clk>, <&p_clk>, <&p_clk>,
 				 <&zx_clk>;

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 078/206] USB: phy: am335x-control: fix device and of_node leaks
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (66 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 077/206] ARM: dts: r8a7794: Correct hsusb parent clock Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 079/206] arm64: dts: hip06: Correct hardware pin number of usb node Greg Kroah-Hartman
                     ` (121 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Bin Liu, Johan Hovold, Felipe Balbi

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Johan Hovold <johan@kernel.org>

commit 015105b12183556771e111e93f5266851e7c5582 upstream.

Make sure to drop the references taken by of_parse_phandle() and
bus_find_device() before returning from am335x_get_phy_control().

Note that there is no guarantee that the devres-managed struct
phy_control will be valid for the lifetime of the sibling phy device
regardless of this change.

Fixes: 3bb869c8b3f1 ("usb: phy: Add AM335x PHY driver")
Acked-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/phy/phy-am335x-control.c |    2 ++
 1 file changed, 2 insertions(+)

--- a/drivers/usb/phy/phy-am335x-control.c
+++ b/drivers/usb/phy/phy-am335x-control.c
@@ -134,10 +134,12 @@ struct phy_control *am335x_get_phy_contr
 		return NULL;
 
 	dev = bus_find_device(&platform_bus_type, NULL, node, match);
+	of_node_put(node);
 	if (!dev)
 		return NULL;
 
 	ctrl_usb = dev_get_drvdata(dev);
+	put_device(dev);
 	if (!ctrl_usb)
 		return NULL;
 	return &ctrl_usb->phy_ctrl;

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 079/206] arm64: dts: hip06: Correct hardware pin number of usb node
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (67 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 078/206] USB: phy: am335x-control: fix device and of_node leaks Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 080/206] ARM: dts: sun7i: bananapi-m1-plus: Enable USB PHY for USB host support Greg Kroah-Hartman
                     ` (120 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Kefeng Wang, Wei Xu

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Kefeng Wang <wangkefeng.wang@huawei.com>

commit 4d75a171b67ffc3f4dadbd654c9d281091300eb2 upstream.

The ohci/ehci hardware pin number should be 640/641, correct them.

Fixes: commit aa8d3e74f54d ("arm64: dts: Add initial dts for Hisilicon Hip06 D03 board")
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: Wei Xu <xuwei5@hisilicon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/arm64/boot/dts/hisilicon/hip06.dtsi |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/arch/arm64/boot/dts/hisilicon/hip06.dtsi
+++ b/arch/arm64/boot/dts/hisilicon/hip06.dtsi
@@ -322,7 +322,7 @@
 			compatible = "generic-ohci";
 			reg = <0x0 0xa7030000 0x0 0x10000>;
 			interrupt-parent = <&mbigen_usb>;
-			interrupts = <64 4>;
+			interrupts = <640 4>;
 			dma-coherent;
 			status = "disabled";
 		};
@@ -331,7 +331,7 @@
 			compatible = "generic-ehci";
 			reg = <0x0 0xa7020000 0x0 0x10000>;
 			interrupt-parent = <&mbigen_usb>;
-			interrupts = <65 4>;
+			interrupts = <641 4>;
 			dma-coherent;
 			status = "disabled";
 		};

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 080/206] ARM: dts: sun7i: bananapi-m1-plus: Enable USB PHY for USB host support
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (68 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 079/206] arm64: dts: hip06: Correct hardware pin number of usb node Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 081/206] [media] dibusb: fix possible memory leak in dibusb_rc_query() Greg Kroah-Hartman
                     ` (119 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Chen-Yu Tsai, Maxime Ripard

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Chen-Yu Tsai <wens@csie.org>

commit 0cff18cbab4f55581d9da86e4286655d9723d7d2 upstream.

The 2 USB host ports are directly tied to the 2 USB hosts in the SoC.
The 2 host pairs were already enabled, but the USB PHY wasn't.
VBUS on the 2 ports are always on.

Enable the USB PHY.

Fixes: 04c85ecad32a ("ARM: dts: sun7i: Add dts file for Bananapi M1 Plus
		      board")
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/arm/boot/dts/sun7i-a20-bananapi-m1-plus.dts |    5 +++++
 1 file changed, 5 insertions(+)

--- a/arch/arm/boot/dts/sun7i-a20-bananapi-m1-plus.dts
+++ b/arch/arm/boot/dts/sun7i-a20-bananapi-m1-plus.dts
@@ -227,3 +227,8 @@
 	pinctrl-0 = <&uart0_pins_a>;
 	status = "okay";
 };
+
+&usbphy {
+	/* VBUS on usb host ports are tied to DC5V and therefore always on */
+	status = "okay";
+};

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 081/206] [media] dibusb: fix possible memory leak in dibusb_rc_query()
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (69 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 080/206] ARM: dts: sun7i: bananapi-m1-plus: Enable USB PHY for USB host support Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 082/206] USB: serial: io_ti: bind to interface after fw download Greg Kroah-Hartman
                     ` (118 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Wei Yongjun, Mauro Carvalho Chehab

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Wei Yongjun <weiyongjun1@huawei.com>

commit 1f5ecaf985c46889278f51fcb7bc143f60f4eb14 upstream.

'buf' is malloced in dibusb_rc_query() and should be freed before
leaving from the error handling cases, otherwise it will cause
memory leak.

Fixes: ff1c123545d7 ("[media] dibusb: handle error code on RC query")

Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/media/usb/dvb-usb/dibusb-common.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/media/usb/dvb-usb/dibusb-common.c
+++ b/drivers/media/usb/dvb-usb/dibusb-common.c
@@ -382,9 +382,9 @@ int dibusb_rc_query(struct dvb_usb_devic
 	if (buf[0] != 0)
 		deb_info("key: %*ph\n", 5, buf);
 
+ret:
 	kfree(buf);
 
-ret:
 	return ret;
 }
 EXPORT_SYMBOL(dibusb_rc_query);

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 082/206] USB: serial: io_ti: bind to interface after fw download
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (70 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 081/206] [media] dibusb: fix possible memory leak in dibusb_rc_query() Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 083/206] mei: fix parameter rename KDoc Greg Kroah-Hartman
                     ` (117 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Johan Hovold

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Johan Hovold <johan@kernel.org>

commit e35d6d7c4e6532a89732cf4bace0e910ee684c88 upstream.

Bind to the interface, but do not register any ports, after having
downloaded the firmware. The device will still disconnect and
re-enumerate, but this way we avoid an error messages from being logged
as part of the process:

io_ti: probe of 1-1.3:1.0 failed with error -5

Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/serial/io_ti.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -1499,8 +1499,7 @@ static int do_boot_mode(struct edgeport_
 
 		dev_dbg(dev, "%s - Download successful -- Device rebooting...\n", __func__);
 
-		/* return an error on purpose */
-		return -ENODEV;
+		return 1;
 	}
 
 stayinbootmode:

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 083/206] mei: fix parameter rename KDoc
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (71 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 082/206] USB: serial: io_ti: bind to interface after fw download Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 084/206] mei: bus: fix mei_cldev_enable KDoc Greg Kroah-Hartman
                     ` (116 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Alexander Usyskin, Tomas Winkler

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Alexander Usyskin <alexander.usyskin@intel.com>

commit 967b274e02e18c9fbb4d19b96a89bd0afbc77b7a upstream.

Parameter renaming to fop_type was not reflected in KDoc

Fixes: 3030dc0564594 (mei: add wrapper for queuing control commands)
Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/misc/mei/client.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/misc/mei/client.c
+++ b/drivers/misc/mei/client.c
@@ -425,7 +425,7 @@ static inline void mei_io_list_free(stru
  *
  * @cl: host client
  * @length: size of the buffer
- * @type: operation type
+ * @fop_type: operation type
  * @fp: associated file pointer (might be NULL)
  *
  * Return: cb on success and NULL on failure
@@ -459,7 +459,7 @@ struct mei_cl_cb *mei_cl_alloc_cb(struct
  *
  * @cl: host client
  * @length: size of the buffer
- * @type: operation type
+ * @fop_type: operation type
  * @fp: associated file pointer (might be NULL)
  *
  * Return: cb on success and NULL on failure

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 084/206] mei: bus: fix mei_cldev_enable KDoc
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (72 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 083/206] mei: fix parameter rename KDoc Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 085/206] mei: move write cb to completion on credentials failures Greg Kroah-Hartman
                     ` (115 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Alexander Usyskin, Tomas Winkler

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Alexander Usyskin <alexander.usyskin@intel.com>

commit 5026c9cb0744a9cd40242743ca91a5d712f468c6 upstream.

Adjust function name in KDoc.

Fixes: d49dc5e76fc9 (mei: bus: use mei_cldev_ prefix for the API functions)
Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/misc/mei/bus.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/misc/mei/bus.c
+++ b/drivers/misc/mei/bus.c
@@ -408,7 +408,7 @@ bool mei_cldev_enabled(struct mei_cl_dev
 EXPORT_SYMBOL_GPL(mei_cldev_enabled);
 
 /**
- * mei_cldev_enable_device - enable me client device
+ * mei_cldev_enable - enable me client device
  *     create connection with me client
  *
  * @cldev: me client device

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 085/206] mei: move write cb to completion on credentials failures
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (73 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 084/206] mei: bus: fix mei_cldev_enable KDoc Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 086/206] staging: iio: ad7606: fix improper setting of oversampling pins Greg Kroah-Hartman
                     ` (114 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Alexander Usyskin, Tomas Winkler

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Alexander Usyskin <alexander.usyskin@intel.com>

commit e09ee853c92011860a4bd2fbdf6126f60fc16bd3 upstream.

The credentials handling was pushed to the write handlers
but error handling wasn't done properly.
Move write callbacks to completion queue to destroy them
and to notify a blocked writer about the failure

Fixes: 136698e535cd1 (mei: push credentials inside the irq write handler)
Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/misc/mei/client.c |   20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

--- a/drivers/misc/mei/client.c
+++ b/drivers/misc/mei/client.c
@@ -1536,7 +1536,7 @@ int mei_cl_irq_write(struct mei_cl *cl,
 
 	rets = first_chunk ? mei_cl_tx_flow_ctrl_creds(cl) : 1;
 	if (rets < 0)
-		return rets;
+		goto err;
 
 	if (rets == 0) {
 		cl_dbg(dev, cl, "No flow control credentials: not sending.\n");
@@ -1570,11 +1570,8 @@ int mei_cl_irq_write(struct mei_cl *cl,
 			cb->buf.size, cb->buf_idx);
 
 	rets = mei_write_message(dev, &mei_hdr, buf->data + cb->buf_idx);
-	if (rets) {
-		cl->status = rets;
-		list_move_tail(&cb->list, &cmpl_list->list);
-		return rets;
-	}
+	if (rets)
+		goto err;
 
 	cl->status = 0;
 	cl->writing_state = MEI_WRITING;
@@ -1582,14 +1579,21 @@ int mei_cl_irq_write(struct mei_cl *cl,
 	cb->completed = mei_hdr.msg_complete == 1;
 
 	if (first_chunk) {
-		if (mei_cl_tx_flow_ctrl_creds_reduce(cl))
-			return -EIO;
+		if (mei_cl_tx_flow_ctrl_creds_reduce(cl)) {
+			rets = -EIO;
+			goto err;
+		}
 	}
 
 	if (mei_hdr.msg_complete)
 		list_move_tail(&cb->list, &dev->write_waiting_list.list);
 
 	return 0;
+
+err:
+	cl->status = rets;
+	list_move_tail(&cb->list, &cmpl_list->list);
+	return rets;
 }
 
 /**

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 086/206] staging: iio: ad7606: fix improper setting of oversampling pins
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (74 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 085/206] mei: move write cb to completion on credentials failures Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 087/206] iio: accel: st_accel: fix LIS3LV02 reading and scaling Greg Kroah-Hartman
                     ` (113 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Eva Rachel Retuya,
	Lars-Peter Clausen, Jonathan Cameron

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Eva Rachel Retuya <eraretuya@gmail.com>

commit b321a38d2407c7e425c54bc09be909a34e49f740 upstream.

The oversampling ratio is controlled using the oversampling pins,
OS [2:0] with OS2 being the MSB control bit, and OS0 the LSB control
bit.

The gpio connected to the OS2 pin is not being set correctly, only OS0
and OS1 pins are being set. Fix the typo to allow proper control of the
oversampling pins.

Signed-off-by: Eva Rachel Retuya <eraretuya@gmail.com>
Fixes: b9618c0 ("staging: IIO: ADC: New driver for AD7606/AD7606-6/AD7606-4")
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/staging/iio/adc/ad7606_core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/staging/iio/adc/ad7606_core.c
+++ b/drivers/staging/iio/adc/ad7606_core.c
@@ -189,7 +189,7 @@ static ssize_t ad7606_store_oversampling
 	mutex_lock(&indio_dev->mlock);
 	gpio_set_value(st->pdata->gpio_os0, (ret >> 0) & 1);
 	gpio_set_value(st->pdata->gpio_os1, (ret >> 1) & 1);
-	gpio_set_value(st->pdata->gpio_os1, (ret >> 2) & 1);
+	gpio_set_value(st->pdata->gpio_os2, (ret >> 2) & 1);
 	st->oversampling = lval;
 	mutex_unlock(&indio_dev->mlock);
 

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 087/206] iio: accel: st_accel: fix LIS3LV02 reading and scaling
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (75 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 086/206] staging: iio: ad7606: fix improper setting of oversampling pins Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 088/206] usb: dwc3: ep0: add dwc3_ep0_prepare_one_trb() Greg Kroah-Hartman
                     ` (112 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Lorenzo Bianconi, Giuseppe Barba,
	Denis Ciocca, Linus Walleij, Jonathan Cameron

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Linus Walleij <linus.walleij@linaro.org>

commit 65e4345c8ef8811bbb4860fe5f2df10646b7f2e1 upstream.

The LIS3LV02 has a special bit that need to be set to get the
read values left aligned. Before this patch we get gibberish
like this:

iio_generic_buffer -a -c10 -n lis3lv02dl_accel
(...)
0.000000 -0.010042 -0.642688 19155832931907
0.000000 -0.010042 -0.642688 19155858751073

Which is because we read a raw value for 1g as 64 which is
the nominal 1024 for 1g shifted 4 bits to the left by being
right-aligned rather than left aligned.

Since all other sensors are left aligned, add some code to
set the special DAS (data alignment setting) bit to 1 so that
the right value is now read like this:

iio_generic_buffer -a -c10 -n lis3lv02dl_accel
(...)
0.000000 -0.147095 -10.120135 24761614364956
-0.029419 -0.176514 -10.120135 24761631624540

The scaling was weird as well: we have a gain of 1000 for 1g
and 3000 for 6g. I don't even remember how I came up with the
old values but they are wrong.

Fixes: 3acddf74f807 ("iio: st-sensors: add support for lis3lv02d accelerometer")
Cc: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Cc: Giuseppe Barba <giuseppe.barba@st.com>
Cc: Denis Ciocca <denis.ciocca@st.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/iio/accel/st_accel_core.c               |   12 ++++++++++--
 drivers/iio/common/st_sensors/st_sensors_core.c |    9 +++++++++
 include/linux/iio/common/st_sensors.h           |   12 ++++++++++++
 3 files changed, 31 insertions(+), 2 deletions(-)

--- a/drivers/iio/accel/st_accel_core.c
+++ b/drivers/iio/accel/st_accel_core.c
@@ -154,8 +154,8 @@
 #define ST_ACCEL_4_FS_MASK			0x80
 #define ST_ACCEL_4_FS_AVL_2_VAL			0X00
 #define ST_ACCEL_4_FS_AVL_6_VAL			0X01
-#define ST_ACCEL_4_FS_AVL_2_GAIN		IIO_G_TO_M_S_2(1024)
-#define ST_ACCEL_4_FS_AVL_6_GAIN		IIO_G_TO_M_S_2(340)
+#define ST_ACCEL_4_FS_AVL_2_GAIN		IIO_G_TO_M_S_2(1000)
+#define ST_ACCEL_4_FS_AVL_6_GAIN		IIO_G_TO_M_S_2(3000)
 #define ST_ACCEL_4_BDU_ADDR			0x21
 #define ST_ACCEL_4_BDU_MASK			0x40
 #define ST_ACCEL_4_DRDY_IRQ_ADDR		0x21
@@ -346,6 +346,14 @@ static const struct st_sensor_settings s
 			.addr = ST_ACCEL_1_BDU_ADDR,
 			.mask = ST_ACCEL_1_BDU_MASK,
 		},
+		/*
+		 * Data Alignment Setting - needs to be set to get
+		 * left-justified data like all other sensors.
+		 */
+		.das = {
+			.addr = 0x21,
+			.mask = 0x01,
+		},
 		.drdy_irq = {
 			.addr = ST_ACCEL_1_DRDY_IRQ_ADDR,
 			.mask_int1 = ST_ACCEL_1_DRDY_IRQ_INT1_MASK,
--- a/drivers/iio/common/st_sensors/st_sensors_core.c
+++ b/drivers/iio/common/st_sensors/st_sensors_core.c
@@ -401,6 +401,15 @@ int st_sensors_init_sensor(struct iio_de
 			return err;
 	}
 
+	/* set DAS */
+	if (sdata->sensor_settings->das.addr) {
+		err = st_sensors_write_data_with_mask(indio_dev,
+					sdata->sensor_settings->das.addr,
+					sdata->sensor_settings->das.mask, 1);
+		if (err < 0)
+			return err;
+	}
+
 	if (sdata->int_pin_open_drain) {
 		dev_info(&indio_dev->dev,
 			 "set interrupt line to open drain mode\n");
--- a/include/linux/iio/common/st_sensors.h
+++ b/include/linux/iio/common/st_sensors.h
@@ -116,6 +116,16 @@ struct st_sensor_bdu {
 };
 
 /**
+ * struct st_sensor_das - ST sensor device data alignment selection
+ * @addr: address of the register.
+ * @mask: mask to write the das flag for left alignment.
+ */
+struct st_sensor_das {
+	u8 addr;
+	u8 mask;
+};
+
+/**
  * struct st_sensor_data_ready_irq - ST sensor device data-ready interrupt
  * @addr: address of the register.
  * @mask_int1: mask to enable/disable IRQ on INT1 pin.
@@ -185,6 +195,7 @@ struct st_sensor_transfer_function {
  * @enable_axis: Enable one or more axis of the sensor.
  * @fs: Full scale register and full scale list available.
  * @bdu: Block data update register.
+ * @das: Data Alignment Selection register.
  * @drdy_irq: Data ready register of the sensor.
  * @multi_read_bit: Use or not particular bit for [I2C/SPI] multi-read.
  * @bootime: samples to discard when sensor passing from power-down to power-up.
@@ -200,6 +211,7 @@ struct st_sensor_settings {
 	struct st_sensor_axis enable_axis;
 	struct st_sensor_fullscale fs;
 	struct st_sensor_bdu bdu;
+	struct st_sensor_das das;
 	struct st_sensor_data_ready_irq drdy_irq;
 	bool multi_read_bit;
 	unsigned int bootime;

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 088/206] usb: dwc3: ep0: add dwc3_ep0_prepare_one_trb()
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (76 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 087/206] iio: accel: st_accel: fix LIS3LV02 reading and scaling Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 089/206] usb: dwc3: ep0: explicitly call dwc3_ep0_prepare_one_trb() Greg Kroah-Hartman
                     ` (111 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Janusz Dziedzic, Felipe Balbi

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Felipe Balbi <felipe.balbi@linux.intel.com>

commit 7931ec86c1b738e4e90e58c6d95e5f720d45ee56 upstream.

For now this is just a cleanup patch, no functional
changes. We will be using the new function to fix a
bug introduced long ago by commit 0416e494ce7d
("usb: dwc3: ep0: correct cache sync issue in case
of ep0_bounced") and further worsened by commit
c0bd5456a470 ("usb: dwc3: ep0: handle non maxpacket
aligned transfers > 512")

Reported-by: Janusz Dziedzic <januszx.dziedzic@linux.intel.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


---
 drivers/usb/dwc3/ep0.c |   30 ++++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)

--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -55,20 +55,13 @@ static const char *dwc3_ep0_state_string
 	}
 }
 
-static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum, dma_addr_t buf_dma,
-		u32 len, u32 type, bool chain)
+static void dwc3_ep0_prepare_one_trb(struct dwc3 *dwc, u8 epnum,
+		dma_addr_t buf_dma, u32 len, u32 type, bool chain)
 {
-	struct dwc3_gadget_ep_cmd_params params;
 	struct dwc3_trb			*trb;
 	struct dwc3_ep			*dep;
 
-	int				ret;
-
 	dep = dwc->eps[epnum];
-	if (dep->flags & DWC3_EP_BUSY) {
-		dwc3_trace(trace_dwc3_ep0, "%s still busy", dep->name);
-		return 0;
-	}
 
 	trb = &dwc->ep0_trb[dep->trb_enqueue];
 
@@ -89,15 +82,28 @@ static int dwc3_ep0_start_trans(struct d
 		trb->ctrl |= (DWC3_TRB_CTRL_IOC
 				| DWC3_TRB_CTRL_LST);
 
-	if (chain)
+	trace_dwc3_prepare_trb(dep, trb);
+}
+
+static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum, dma_addr_t buf_dma,
+		u32 len, u32 type, bool chain)
+{
+	struct dwc3_gadget_ep_cmd_params params;
+	struct dwc3_ep			*dep;
+	int				ret;
+
+	dep = dwc->eps[epnum];
+	if (dep->flags & DWC3_EP_BUSY) {
+		dwc3_trace(trace_dwc3_ep0, "%s still busy", dep->name);
 		return 0;
+	}
+
+	dwc3_ep0_prepare_one_trb(dwc, epnum, buf_dma, len, type, chain);
 
 	memset(&params, 0, sizeof(params));
 	params.param0 = upper_32_bits(dwc->ep0_trb_addr);
 	params.param1 = lower_32_bits(dwc->ep0_trb_addr);
 
-	trace_dwc3_prepare_trb(dep, trb);
-
 	ret = dwc3_send_gadget_ep_cmd(dep, DWC3_DEPCMD_STARTTRANSFER, &params);
 	if (ret < 0) {
 		dwc3_trace(trace_dwc3_ep0, "%s STARTTRANSFER failed",

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 089/206] usb: dwc3: ep0: explicitly call dwc3_ep0_prepare_one_trb()
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (77 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 088/206] usb: dwc3: ep0: add dwc3_ep0_prepare_one_trb() Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 090/206] usb: dwc3: gadget: always unmap EP0 requests Greg Kroah-Hartman
                     ` (110 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Janusz Dziedzic, Felipe Balbi

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Felipe Balbi <felipe.balbi@linux.intel.com>

commit 19ec31230eb3084431bc2e565fd085f79f564274 upstream.

Let's call dwc3_ep0_prepare_one_trb() explicitly
because there are occasions where we will need more
than one TRB to handle an EP0 transfer.

A follow-up patch will fix one bug related to
multiple-TRB Data Phases when it comes to
mapping/unmapping requests for DMA.

Reported-by: Janusz Dziedzic <januszx.dziedzic@linux.intel.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


---
 drivers/usb/dwc3/ep0.c |   28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -85,8 +85,7 @@ static void dwc3_ep0_prepare_one_trb(str
 	trace_dwc3_prepare_trb(dep, trb);
 }
 
-static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum, dma_addr_t buf_dma,
-		u32 len, u32 type, bool chain)
+static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum)
 {
 	struct dwc3_gadget_ep_cmd_params params;
 	struct dwc3_ep			*dep;
@@ -98,8 +97,6 @@ static int dwc3_ep0_start_trans(struct d
 		return 0;
 	}
 
-	dwc3_ep0_prepare_one_trb(dwc, epnum, buf_dma, len, type, chain);
-
 	memset(&params, 0, sizeof(params));
 	params.param0 = upper_32_bits(dwc->ep0_trb_addr);
 	params.param1 = lower_32_bits(dwc->ep0_trb_addr);
@@ -314,8 +311,9 @@ void dwc3_ep0_out_start(struct dwc3 *dwc
 {
 	int				ret;
 
-	ret = dwc3_ep0_start_trans(dwc, 0, dwc->ctrl_req_addr, 8,
+	dwc3_ep0_prepare_one_trb(dwc, 0, dwc->ctrl_req_addr, 8,
 			DWC3_TRBCTL_CONTROL_SETUP, false);
+	ret = dwc3_ep0_start_trans(dwc, 0);
 	WARN_ON(ret < 0);
 }
 
@@ -886,9 +884,9 @@ static void dwc3_ep0_complete_data(struc
 
 			dwc->ep0_next_event = DWC3_EP0_COMPLETE;
 
-			ret = dwc3_ep0_start_trans(dwc, epnum,
-					dwc->ctrl_req_addr, 0,
-					DWC3_TRBCTL_CONTROL_DATA, false);
+			dwc3_ep0_prepare_one_trb(dwc, epnum, dwc->ctrl_req_addr,
+					0, DWC3_TRBCTL_CONTROL_DATA, false);
+			ret = dwc3_ep0_start_trans(dwc, epnum);
 			WARN_ON(ret < 0);
 		}
 	}
@@ -972,9 +970,10 @@ static void __dwc3_ep0_do_control_data(s
 	req->direction = !!dep->number;
 
 	if (req->request.length == 0) {
-		ret = dwc3_ep0_start_trans(dwc, dep->number,
+		dwc3_ep0_prepare_one_trb(dwc, dep->number,
 				dwc->ctrl_req_addr, 0,
 				DWC3_TRBCTL_CONTROL_DATA, false);
+		ret = dwc3_ep0_start_trans(dwc, dep->number);
 	} else if (!IS_ALIGNED(req->request.length, dep->endpoint.maxpacket)
 			&& (dep->number == 0)) {
 		u32	transfer_size = 0;
@@ -992,7 +991,7 @@ static void __dwc3_ep0_do_control_data(s
 		if (req->request.length > DWC3_EP0_BOUNCE_SIZE) {
 			transfer_size = ALIGN(req->request.length - maxpacket,
 					      maxpacket);
-			ret = dwc3_ep0_start_trans(dwc, dep->number,
+			dwc3_ep0_prepare_one_trb(dwc, dep->number,
 						   req->request.dma,
 						   transfer_size,
 						   DWC3_TRBCTL_CONTROL_DATA,
@@ -1004,9 +1003,10 @@ static void __dwc3_ep0_do_control_data(s
 
 		dwc->ep0_bounced = true;
 
-		ret = dwc3_ep0_start_trans(dwc, dep->number,
+		dwc3_ep0_prepare_one_trb(dwc, dep->number,
 				dwc->ep0_bounce_addr, transfer_size,
 				DWC3_TRBCTL_CONTROL_DATA, false);
+		ret = dwc3_ep0_start_trans(dwc, dep->number);
 	} else {
 		ret = usb_gadget_map_request(&dwc->gadget, &req->request,
 				dep->number);
@@ -1015,9 +1015,10 @@ static void __dwc3_ep0_do_control_data(s
 			return;
 		}
 
-		ret = dwc3_ep0_start_trans(dwc, dep->number, req->request.dma,
+		dwc3_ep0_prepare_one_trb(dwc, dep->number, req->request.dma,
 				req->request.length, DWC3_TRBCTL_CONTROL_DATA,
 				false);
+		ret = dwc3_ep0_start_trans(dwc, dep->number);
 	}
 
 	WARN_ON(ret < 0);
@@ -1031,8 +1032,9 @@ static int dwc3_ep0_start_control_status
 	type = dwc->three_stage_setup ? DWC3_TRBCTL_CONTROL_STATUS3
 		: DWC3_TRBCTL_CONTROL_STATUS2;
 
-	return dwc3_ep0_start_trans(dwc, dep->number,
+	dwc3_ep0_prepare_one_trb(dwc, dep->number,
 			dwc->ctrl_req_addr, 0, type, false);
+	return dwc3_ep0_start_trans(dwc, dep->number);
 }
 
 static void __dwc3_ep0_do_control_status(struct dwc3 *dwc, struct dwc3_ep *dep)

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 090/206] usb: dwc3: gadget: always unmap EP0 requests
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (78 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 089/206] usb: dwc3: ep0: explicitly call dwc3_ep0_prepare_one_trb() Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 093/206] mac80211: fix tid_agg_rx NULL dereference Greg Kroah-Hartman
                     ` (109 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Tomasz Medrek, Janusz Dziedzic, Felipe Balbi

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Felipe Balbi <felipe.balbi@linux.intel.com>

commit d62145929992f331fdde924d5963ab49588ccc7d upstream.

commit 0416e494ce7d ("usb: dwc3: ep0: correct cache
sync issue in case of ep0_bounced") introduced a bug
where we would leak DMA resources which would cause
us to starve the system of them resulting in failing
DMA transfers.

Fix the bug by making sure that we always unmap EP0
requests since those are *always* mapped.

Fixes: 0416e494ce7d ("usb: dwc3: ep0: correct cache
	sync issue in case of ep0_bounced")
Cc: <stable@vger.kernel.org>
Tested-by: Tomasz Medrek <tomaszx.medrek@intel.com>
Reported-by: Janusz Dziedzic <januszx.dziedzic@linux.intel.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/dwc3/gadget.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -182,11 +182,11 @@ void dwc3_gadget_giveback(struct dwc3_ep
 	if (req->request.status == -EINPROGRESS)
 		req->request.status = status;
 
-	if (dwc->ep0_bounced && dep->number == 0)
+	if (dwc->ep0_bounced && dep->number <= 1)
 		dwc->ep0_bounced = false;
-	else
-		usb_gadget_unmap_request(&dwc->gadget, &req->request,
-				req->direction);
+
+	usb_gadget_unmap_request(&dwc->gadget, &req->request,
+			req->direction);
 
 	trace_dwc3_gadget_giveback(req);
 

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 093/206] mac80211: fix tid_agg_rx NULL dereference
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (79 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 090/206] usb: dwc3: gadget: always unmap EP0 requests Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 094/206] nl80211: Use different attrs for BSSID and random MAC addr in scan req Greg Kroah-Hartman
                     ` (108 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Emmanuel Grumbach, Johannes Berg

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Johannes Berg <johannes.berg@intel.com>

commit 1c3d185a9a0b136a58e73b02912d593d0303d1da upstream.

On drivers setting the SUPPORTS_REORDERING_BUFFER hardware flag,
we crash when the peer sends an AddBA request while we already
have a session open on the seame TID; this is because on those
drivers, the tid_agg_rx is left NULL even though the session is
valid, and the agg_session_valid bit is set.

To fix this, store the dialog tokens outside the tid_agg_rx to
be able to compare them to the received AddBA request.

Fixes: f89e07d4cf26 ("mac80211: agg-rx: refuse ADDBA Request with timeout update")
Reported-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 net/mac80211/agg-rx.c      |    8 ++------
 net/mac80211/debugfs_sta.c |    2 +-
 net/mac80211/sta_info.h    |    4 ++--
 3 files changed, 5 insertions(+), 9 deletions(-)

--- a/net/mac80211/agg-rx.c
+++ b/net/mac80211/agg-rx.c
@@ -315,11 +315,7 @@ void __ieee80211_start_rx_ba_session(str
 	mutex_lock(&sta->ampdu_mlme.mtx);
 
 	if (test_bit(tid, sta->ampdu_mlme.agg_session_valid)) {
-		tid_agg_rx = rcu_dereference_protected(
-				sta->ampdu_mlme.tid_rx[tid],
-				lockdep_is_held(&sta->ampdu_mlme.mtx));
-
-		if (tid_agg_rx->dialog_token == dialog_token) {
+		if (sta->ampdu_mlme.tid_rx_token[tid] == dialog_token) {
 			ht_dbg_ratelimited(sta->sdata,
 					   "updated AddBA Req from %pM on tid %u\n",
 					   sta->sta.addr, tid);
@@ -396,7 +392,6 @@ void __ieee80211_start_rx_ba_session(str
 	}
 
 	/* update data */
-	tid_agg_rx->dialog_token = dialog_token;
 	tid_agg_rx->ssn = start_seq_num;
 	tid_agg_rx->head_seq_num = start_seq_num;
 	tid_agg_rx->buf_size = buf_size;
@@ -418,6 +413,7 @@ end:
 	if (status == WLAN_STATUS_SUCCESS) {
 		__set_bit(tid, sta->ampdu_mlme.agg_session_valid);
 		__clear_bit(tid, sta->ampdu_mlme.unexpected_agg);
+		sta->ampdu_mlme.tid_rx_token[tid] = dialog_token;
 	}
 	mutex_unlock(&sta->ampdu_mlme.mtx);
 
--- a/net/mac80211/debugfs_sta.c
+++ b/net/mac80211/debugfs_sta.c
@@ -205,7 +205,7 @@ static ssize_t sta_agg_status_read(struc
 		p += scnprintf(p, sizeof(buf) + buf - p, "%02d", i);
 		p += scnprintf(p, sizeof(buf) + buf - p, "\t\t%x", !!tid_rx);
 		p += scnprintf(p, sizeof(buf) + buf - p, "\t%#.2x",
-				tid_rx ? tid_rx->dialog_token : 0);
+				tid_rx ? sta->ampdu_mlme.tid_rx_token[i] : 0);
 		p += scnprintf(p, sizeof(buf) + buf - p, "\t%#.3x",
 				tid_rx ? tid_rx->ssn : 0);
 
--- a/net/mac80211/sta_info.h
+++ b/net/mac80211/sta_info.h
@@ -184,7 +184,6 @@ struct tid_ampdu_tx {
  * @ssn: Starting Sequence Number expected to be aggregated.
  * @buf_size: buffer size for incoming A-MPDUs
  * @timeout: reset timer value (in TUs).
- * @dialog_token: dialog token for aggregation session
  * @rcu_head: RCU head used for freeing this struct
  * @reorder_lock: serializes access to reorder buffer, see below.
  * @auto_seq: used for offloaded BA sessions to automatically pick head_seq_and
@@ -213,7 +212,6 @@ struct tid_ampdu_rx {
 	u16 ssn;
 	u16 buf_size;
 	u16 timeout;
-	u8 dialog_token;
 	bool auto_seq;
 	bool removed;
 };
@@ -225,6 +223,7 @@ struct tid_ampdu_rx {
  *	to tid_tx[idx], which are protected by the sta spinlock)
  *	tid_start_tx is also protected by sta->lock.
  * @tid_rx: aggregation info for Rx per TID -- RCU protected
+ * @tid_rx_token: dialog tokens for valid aggregation sessions
  * @tid_rx_timer_expired: bitmap indicating on which TIDs the
  *	RX timer expired until the work for it runs
  * @tid_rx_stop_requested:  bitmap indicating which BA sessions per TID the
@@ -243,6 +242,7 @@ struct sta_ampdu_mlme {
 	struct mutex mtx;
 	/* rx */
 	struct tid_ampdu_rx __rcu *tid_rx[IEEE80211_NUM_TIDS];
+	u8 tid_rx_token[IEEE80211_NUM_TIDS];
 	unsigned long tid_rx_timer_expired[BITS_TO_LONGS(IEEE80211_NUM_TIDS)];
 	unsigned long tid_rx_stop_requested[BITS_TO_LONGS(IEEE80211_NUM_TIDS)];
 	unsigned long agg_session_valid[BITS_TO_LONGS(IEEE80211_NUM_TIDS)];

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 094/206] nl80211: Use different attrs for BSSID and random MAC addr in scan req
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (80 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 093/206] mac80211: fix tid_agg_rx NULL dereference Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-07-21  9:40     ` Krishna Vamsi
  2017-01-10 13:36   ` [PATCH 4.9 095/206] ath10k: fix failure to send NULL func frame for 10.4 Greg Kroah-Hartman
                     ` (107 subsequent siblings)
  189 siblings, 1 reply; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Vamsi Krishna, Jouni Malinen, Johannes Berg

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Vamsi Krishna <vamsin@qti.qualcomm.com>

commit 2fa436b3a2a7009c11a3bc03fe0ff4c26e80fd87 upstream.

NL80211_ATTR_MAC was used to set both the specific BSSID to be scanned
and the random MAC address to be used when privacy is enabled. When both
the features are enabled, both the BSSID and the local MAC address were
getting same value causing Probe Request frames to go with unintended
DA. Hence, this has been fixed by using a different NL80211_ATTR_BSSID
attribute to set the specific BSSID (which was the more recent addition
in cfg80211) for a scan.

Backwards compatibility with old userspace software is maintained to
some extent by allowing NL80211_ATTR_MAC to be used to set the specific
BSSID when scanning without enabling random MAC address use.

Scanning with random source MAC address was introduced by commit
ad2b26abc157 ("cfg80211: allow drivers to support random MAC addresses
for scan") and the issue was introduced with the addition of the second
user for the same attribute in commit 818965d39177 ("cfg80211: Allow a
scan request for a specific BSSID").

Fixes: 818965d39177 ("cfg80211: Allow a scan request for a specific BSSID")
Signed-off-by: Vamsi Krishna <vamsin@qti.qualcomm.com>
Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 include/uapi/linux/nl80211.h |    7 ++++++-
 net/wireless/nl80211.c       |   16 +++++++++++++++-
 2 files changed, 21 insertions(+), 2 deletions(-)

--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -323,7 +323,7 @@
  * @NL80211_CMD_GET_SCAN: get scan results
  * @NL80211_CMD_TRIGGER_SCAN: trigger a new scan with the given parameters
  *	%NL80211_ATTR_TX_NO_CCK_RATE is used to decide whether to send the
- *	probe requests at CCK rate or not. %NL80211_ATTR_MAC can be used to
+ *	probe requests at CCK rate or not. %NL80211_ATTR_BSSID can be used to
  *	specify a BSSID to scan for; if not included, the wildcard BSSID will
  *	be used.
  * @NL80211_CMD_NEW_SCAN_RESULTS: scan notification (as a reply to
@@ -1937,6 +1937,9 @@ enum nl80211_commands {
  * @NL80211_ATTR_NAN_MATCH: used to report a match. This is a nested attribute.
  *	See &enum nl80211_nan_match_attributes.
  *
+ * @NL80211_ATTR_BSSID: The BSSID of the AP. Note that %NL80211_ATTR_MAC is also
+ *	used in various commands/events for specifying the BSSID.
+ *
  * @NUM_NL80211_ATTR: total number of nl80211_attrs available
  * @NL80211_ATTR_MAX: highest attribute number currently defined
  * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -2336,6 +2339,8 @@ enum nl80211_attrs {
 	NL80211_ATTR_NAN_FUNC,
 	NL80211_ATTR_NAN_MATCH,
 
+	NL80211_ATTR_BSSID,
+
 	/* add attributes here, update the policy in nl80211.c */
 
 	__NL80211_ATTR_AFTER_LAST,
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -414,6 +414,7 @@ static const struct nla_policy nl80211_p
 	[NL80211_ATTR_NAN_MASTER_PREF] = { .type = NLA_U8 },
 	[NL80211_ATTR_NAN_DUAL] = { .type = NLA_U8 },
 	[NL80211_ATTR_NAN_FUNC] = { .type = NLA_NESTED },
+	[NL80211_ATTR_BSSID] = { .len = ETH_ALEN },
 };
 
 /* policy for the key attributes */
@@ -6677,7 +6678,20 @@ static int nl80211_trigger_scan(struct s
 	request->no_cck =
 		nla_get_flag(info->attrs[NL80211_ATTR_TX_NO_CCK_RATE]);
 
-	if (info->attrs[NL80211_ATTR_MAC])
+	/* Initial implementation used NL80211_ATTR_MAC to set the specific
+	 * BSSID to scan for. This was problematic because that same attribute
+	 * was already used for another purpose (local random MAC address). The
+	 * NL80211_ATTR_BSSID attribute was added to fix this. For backwards
+	 * compatibility with older userspace components, also use the
+	 * NL80211_ATTR_MAC value here if it can be determined to be used for
+	 * the specific BSSID use case instead of the random MAC address
+	 * (NL80211_ATTR_SCAN_FLAGS is used to enable random MAC address use).
+	 */
+	if (info->attrs[NL80211_ATTR_BSSID])
+		memcpy(request->bssid,
+		       nla_data(info->attrs[NL80211_ATTR_BSSID]), ETH_ALEN);
+	else if (!(request->flags & NL80211_SCAN_FLAG_RANDOM_ADDR) &&
+		 info->attrs[NL80211_ATTR_MAC])
 		memcpy(request->bssid, nla_data(info->attrs[NL80211_ATTR_MAC]),
 		       ETH_ALEN);
 	else

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 095/206] ath10k: fix failure to send NULL func frame for 10.4
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (81 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 094/206] nl80211: Use different attrs for BSSID and random MAC addr in scan req Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 096/206] mfd: tps65217: Fix page fault on unloading modules Greg Kroah-Hartman
                     ` (106 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Mohammed Shafi Shajakhan, Kalle Valo

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Mohammed Shafi Shajakhan <mohammed@qti.qualcomm.com>

commit fcf7cf1551cae54e747a771f5808240f2a37708f upstream.

This partially reverts 'commit 2cdce425aa33
("ath10k: Fix broken NULL func data frame status for 10.4")'
Unfortunately this breaks sending NULL func and the existing
issue of obtaining proper tx status for NULL function will be
fixed. Also update the comments for feature flag added to be
useless and not working

Fixes: 2cdce425aa33 "ath10k: Fix broken NULL func data frame status for
10.4"
Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qti.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/net/wireless/ath/ath10k/core.h |    6 ++----
 drivers/net/wireless/ath/ath10k/mac.c  |    2 --
 2 files changed, 2 insertions(+), 6 deletions(-)

--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -557,10 +557,8 @@ enum ath10k_fw_features {
 	 */
 	ATH10K_FW_FEATURE_BTCOEX_PARAM = 14,
 
-	/* Older firmware with HTT delivers incorrect tx status for null func
-	 * frames to driver, but this fixed in 10.2 and 10.4 firmware versions.
-	 * Also this workaround results in reporting of incorrect null func
-	 * status for 10.4. This flag is used to skip the workaround.
+	/* Unused flag and proven to be not working, enable this if you want
+	 * to experiment sending NULL func data frames in HTT TX
 	 */
 	ATH10K_FW_FEATURE_SKIP_NULL_FUNC_WAR = 15,
 
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -3255,8 +3255,6 @@ ath10k_mac_tx_h_get_txmode(struct ath10k
 	if (ar->htt.target_version_major < 3 &&
 	    (ieee80211_is_nullfunc(fc) || ieee80211_is_qos_nullfunc(fc)) &&
 	    !test_bit(ATH10K_FW_FEATURE_HAS_WMI_MGMT_TX,
-		      ar->running_fw->fw_file.fw_features) &&
-	    !test_bit(ATH10K_FW_FEATURE_SKIP_NULL_FUNC_WAR,
 		      ar->running_fw->fw_file.fw_features))
 		return ATH10K_HW_TXRX_MGMT;
 

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 096/206] mfd: tps65217: Fix page fault on unloading modules
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (82 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 095/206] ath10k: fix failure to send NULL func frame for 10.4 Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 097/206] ath10k: use the right length of "background" Greg Kroah-Hartman
                     ` (105 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Milo Kim, Lee Jones

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Milo Kim <woogyom.kim@gmail.com>

commit 40a50f8b307de8d08f3fa37c312fc16a7dd233e5 upstream.

TPS65217 IRQ domain should be removed and initialised as NULL when the
module is unloaded for the next use. When tps65217.ko is loaded again,
it causes the page fault. This patch fixes the error below.

root@arm:~# lsmod | grep "tps"
tps65217_charger        3538  0
tps65218_pwrbutton      2974  0
tps65217                6710  1 tps65217_charger

root@arm:~# modprobe -r tps65217_charger

root@arm:~# modprobe tps65217.ko
[   71.990277] Unable to handle kernel paging request at virtual address bf055944
[   71.998063] pgd = dd3a4000
[   72.000904] [bf055944] *pgd=9e6f7811, *pte=00000000, *ppte=00000000
[   72.007567] Internal error: Oops: 7 [#1] SMP ARM
[   72.012404] Modules linked in: tps65217(+) evdev musb_dsps musb_hdrc udc_core tps65218_pwrbutton usbcore phy_am335]
[   72.055700] CPU: 0 PID: 243 Comm: modprobe Not tainted 4.9.0-rc5-next-20161114 #3
[   72.063531] Hardware name: Generic AM33XX (Flattened Device Tree)
[   72.069899] task: de714380 task.stack: de7e6000
[   72.074655] PC is at irq_find_matching_fwspec+0x88/0x100
[   72.080211] LR is at 0xde7e79d8
[   72.083496] pc : [<c01a5d88>]    lr : [<de7e79d8>]    psr: 200e0013
[   72.083496] sp : de7e7a78  ip : 00000000  fp : dd138a68
[   72.095506] r10: c0ca04f8  r9 : 00000018  r8 : de7e7ab8
[   72.100973] r7 : 00000001  r6 : c0c4517c  r5 : df963f68  r4 : de321980
[   72.107797] r3 : bf055940  r2 : de714380  r1 : 00000000  r0 : 00000000
[   72.114633] Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
[   72.122084] Control: 10c5387d  Table: 9d3a4019  DAC: 00000051
[   72.128097] Process modprobe (pid: 243, stack limit = 0xde7e6218)
[   72.134489] Stack: (0xde7e7a78 to 0xde7e8000)
[   72.139060] 7a60:                                                       df963f68 de7e7ab8
[   72.147643] 7a80: 00000000 dd0e1000 dd491e20 c01a6ea0 600e0013 c01a5dc0 dd138a68 c0c45138
[   72.156216] 7aa0: df963f68 00000000 df963f68 dd0e1010 00000000 c01a71a4 df963f68 00000001
[   72.164800] 7ac0: 00000002 de7e7ac0 c80048b8 dd0adf00 df963f68 c0c4517c 00000000 de7e7b50
[   72.173369] 7ae0: 00000018 c0ca04f8 dd138a68 c01a5dc0 df963f68 dd0e1010 00000000 dd0e1000
[   72.181942] 7b00: dd491e20 c0653a70 df963f58 00000001 00000002 00000000 00000000 00000000
[   72.190522] 7b20: 600e0093 c0cbf8f0 c0c0512c c0193674 00000001 00000080 00000000 c0554984
[   72.199096] 7b40: 00000000 00000000 800e0013 c0553858 df963f68 00000000 00000000 00000000
[   72.207674] 7b60: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[   72.216239] 7b80: 00000000 00000000 00000000 00000000 00000000 00000000 dd0e1000 c0544d24
[   72.224816] 7ba0: dd491e10 dd0e1010 dd16e800 bf1d517c bf1d5620 dd0e1010 c1497ed4 bf1d5620
[   72.233398] 7bc0: dd0e1010 fffffdfb bf1d5620 bf1d5620 00000000 c054537c c0545330 dd0e1010
[   72.241967] 7be0: c1497ed4 00000000 bf1d5620 c05433ac 00000000 00000000 de7e7c28 c0543570
[   72.250537] 7c00: 00000001 c1497e90 00000000 c0541884 de080cd4 dd44b7d4 dd0e1010 dd0e1010
[   72.259109] 7c20: dd0e1044 c05430c8 dd0e1010 00000001 dd0e1010 dd0e1018 dd0e1010 c0c9e328
[   72.267676] 7c40: de5d4020 c0542760 dd0e1018 dd0e1010 00000000 c0540ba8 dd138a40 c048dec4
[   72.276253] 7c60: 00000000 dd0e1000 00000001 dd0e1000 dd0e1010 dd0e1000 bf233de0 dd138a40
[   72.284829] 7c80: dd0e1010 c05450a0 000000bf 00000000 dd138a60 00000001 dd0e1000 c0571240
[   72.293398] 7ca0: 00000000 dd1ce9c0 00000040 dd1ce9cc bf233de0 00000003 de5d4020 ffffffff
[   72.301969] 7cc0: 00000004 dd0adf00 00000000 c0571408 00000000 00000000 dd0adf00 de5d4020
[   72.310543] 7ce0: c057146c dd1ce9c0 bf233d14 de5d4020 de7fb3d0 00000004 bf233d14 ffffffff
[   72.319120] 7d00: 00000018 dd49bf30 c01cedc0 c05714d0 00000000 00000000 dd0adf00 de322810
[   72.327692] 7d20: de322810 00000000 dd033000 000000f0 00000001 bf2333fc 00000000 00000000
[   72.336269] 7d40: dd0adf00 de5d4020 000000b6 bf233e40 de5d4020 bf233968 de5d4004 de5d4000
[   72.344848] 7d60: bf233314 c06148ac de5d4020 c1497ed4 00000000 bf233e40 00000000 c05433ac
[   72.353422] 7d80: 00000000 de5d4020 bf233e40 de5d4054 00000000 bf236000 00000000 c0543538
[   72.362002] 7da0: 00000000 bf233e40 c0543484 c05417e4 de1442a4 de5d04d0 bf233e40 de321300
[   72.370582] 7dc0: c0caa5a4 c05429fc bf233be0 bf233e40 c0cbfa44 bf233e40 c0cbfa44 dd2f7740
[   72.379148] 7de0: bf233f00 c05442f0 bf233e8c bf233e24 c0cbfa44 c0615ae0 00000000 bf233f00
[   72.387718] 7e00: c0cbfa44 c010186c 200f0013 c0191650 de714380 00000000 600f0013 00000040
[   72.396286] 7e20: dd2f7740 c018f1ac 00000001 c0c8356c 024000c0 c01a8854 c0c56e0e c028225c
[   72.404863] 7e40: dd2f7740 c0191984 de714380 dd2f7740 00000001 bf233f00 bf233f00 c0cbfa44
[   72.413440] 7e60: dd2f7740 bf233f00 00000001 dd49bf08 dd49bf30 c0230998 00000001 c0c8356c
[   72.421997] 7e80: c0c4c536 c0cbfa44 c0c0512c c01d2070 bf233f0c 00007fff bf233f00 c01cf5b8
[   72.430570] 7ea0: 00000000 c1475134 c01cee34 bf23411c bf233f48 bf234054 bf234150 00000000
[   72.439144] 7ec0: 024002c2 de7fbf40 0009bc20 c02776ac ff800000 00000000 00000000 bf233670
[   72.447723] 7ee0: 00000004 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[   72.456298] 7f00: 00000000 00000000 00000000 00000000 c01d2590 0000aa41 00000000 00000000
[   72.464862] 7f20: 000b2549 e12c3a41 00000051 de7e6000 0009bc20 c01d2630 00000530 e12b9000
[   72.473438] 7f40: 0000aa41 e12c1434 e12c1211 e12c336c 00001150 00001620 00000000 00000000
[   72.482003] 7f60: 00000000 000010fc 00000035 00000036 0000001d 0000001a 00000017 00000000
[   72.490564] 7f80: de7e6000 3ba39a00 0009b008 0009b718 00000080 c0107704 de7e6000 00000000
[   72.499141] 7fa0: 0009f609 c0107560 3ba39a00 0009b008 000a7b08 0000aa41 0009bc20 0000aa41
[   72.507717] 7fc0: 3ba39a00 0009b008 0009b718 00000080 00000001 00000008 0009ab14 0009f609
[   72.516290] 7fe0: bea31ab8 bea31aa8 0001e5eb b6e83b42 800f0030 000a7b08 0000ffff 0840ffff
[   72.524883] [<c01a5d88>] (irq_find_matching_fwspec) from [<c01a6ea0>] (irq_create_fwspec_mapping+0x28/0x2e0)
[   72.535174] [<c01a6ea0>] (irq_create_fwspec_mapping) from [<c01a71a4>] (irq_create_of_mapping+0x4c/0x54)
[   72.545115] [<c01a71a4>] (irq_create_of_mapping) from [<c0653a70>] (of_irq_get+0x58/0x68)
[   72.553699] [<c0653a70>] (of_irq_get) from [<c0544d24>] (platform_get_irq+0x1c/0xec)
[   72.561828] [<c0544d24>] (platform_get_irq) from [<bf1d517c>] (tps6521x_pb_probe+0xd0/0x1a8 [tps65218_pwrbutton])
[   72.572581] [<bf1d517c>] (tps6521x_pb_probe [tps65218_pwrbutton]) from [<c054537c>] (platform_drv_probe+0x4c/0xac)
[   72.583426] [<c054537c>] (platform_drv_probe) from [<c05433ac>] (driver_probe_device+0x204/0x2dc)
[   72.592729] [<c05433ac>] (driver_probe_device) from [<c0541884>] (bus_for_each_drv+0x58/0x8c)
[   72.601657] [<c0541884>] (bus_for_each_drv) from [<c05430c8>] (__device_attach+0xb0/0x114)
[   72.610324] [<c05430c8>] (__device_attach) from [<c0542760>] (bus_probe_device+0x88/0x90)
[   72.618898] [<c0542760>] (bus_probe_device) from [<c0540ba8>] (device_add+0x3b8/0x560)
[   72.627203] [<c0540ba8>] (device_add) from [<c05450a0>] (platform_device_add+0xa8/0x208)
[   72.635693] [<c05450a0>] (platform_device_add) from [<c0571240>] (mfd_add_device+0x240/0x338)
[   72.644634] [<c0571240>] (mfd_add_device) from [<c0571408>] (mfd_add_devices+0xa0/0x104)
[   72.653120] [<c0571408>] (mfd_add_devices) from [<c05714d0>] (devm_mfd_add_devices+0x60/0xa8)
[   72.662077] [<c05714d0>] (devm_mfd_add_devices) from [<bf2333fc>] (tps65217_probe+0xe8/0x2ec [tps65217])
[   72.672026] [<bf2333fc>] (tps65217_probe [tps65217]) from [<c06148ac>] (i2c_device_probe+0x168/0x1f4)
[   72.681695] [<c06148ac>] (i2c_device_probe) from [<c05433ac>] (driver_probe_device+0x204/0x2dc)
[   72.690816] [<c05433ac>] (driver_probe_device) from [<c0543538>] (__driver_attach+0xb4/0xb8)
[   72.699657] [<c0543538>] (__driver_attach) from [<c05417e4>] (bus_for_each_dev+0x60/0x94)
[   72.708224] [<c05417e4>] (bus_for_each_dev) from [<c05429fc>] (bus_add_driver+0x18c/0x214)
[   72.716892] [<c05429fc>] (bus_add_driver) from [<c05442f0>] (driver_register+0x78/0xf8)
[   72.725280] [<c05442f0>] (driver_register) from [<c0615ae0>] (i2c_register_driver+0x38/0x80)
[   72.734120] [<c0615ae0>] (i2c_register_driver) from [<c010186c>] (do_one_initcall+0x3c/0x178)
[   72.743055] [<c010186c>] (do_one_initcall) from [<c0230998>] (do_init_module+0x5c/0x1d0)
[   72.751537] [<c0230998>] (do_init_module) from [<c01d2070>] (load_module+0x1d10/0x21c0)
[   72.759933] [<c01d2070>] (load_module) from [<c01d2630>] (SyS_init_module+0x110/0x154)
[   72.768242] [<c01d2630>] (SyS_init_module) from [<c0107560>] (ret_fast_syscall+0x0/0x1c)
[   72.776725] Code: e5944000 e1540006 0a00001b e594300c (e593c004)
[   72.783181] ---[ end trace 0278ec325f4689b8 ]---

Fixes: 6556bdacf646 ("mfd: tps65217: Add support for IRQs")
Signed-off-by: Milo Kim <woogyom.kim@gmail.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/mfd/tps65217.c |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

--- a/drivers/mfd/tps65217.c
+++ b/drivers/mfd/tps65217.c
@@ -424,6 +424,24 @@ static int tps65217_probe(struct i2c_cli
 	return 0;
 }
 
+static int tps65217_remove(struct i2c_client *client)
+{
+	struct tps65217 *tps = i2c_get_clientdata(client);
+	unsigned int virq;
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(tps65217_irqs); i++) {
+		virq = irq_find_mapping(tps->irq_domain, i);
+		if (virq)
+			irq_dispose_mapping(virq);
+	}
+
+	irq_domain_remove(tps->irq_domain);
+	tps->irq_domain = NULL;
+
+	return 0;
+}
+
 static const struct i2c_device_id tps65217_id_table[] = {
 	{"tps65217", TPS65217},
 	{ /* sentinel */ }
@@ -437,6 +455,7 @@ static struct i2c_driver tps65217_driver
 	},
 	.id_table	= tps65217_id_table,
 	.probe		= tps65217_probe,
+	.remove		= tps65217_remove,
 };
 
 static int __init tps65217_init(void)

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 097/206] ath10k: use the right length of "background"
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (83 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 096/206] mfd: tps65217: Fix page fault on unloading modules Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 098/206] cris: Only build flash rescue image if CONFIG_ETRAX_AXISFLASHMAP is selected Greg Kroah-Hartman
                     ` (104 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Nicolas Iooss, Kalle Valo

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Nicolas Iooss <nicolas.iooss_linux@m4x.org>

commit 31b239824ece321c09bdb8e61e1d14814eaba38b upstream.

The word "background" contains 10 characters so the third argument of
strncmp() need to be 10 in order to match this prefix correctly.

Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
Fixes: 855aed1220d2 ("ath10k: add spectral scan feature")
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/net/wireless/ath/ath10k/spectral.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/net/wireless/ath/ath10k/spectral.c
+++ b/drivers/net/wireless/ath/ath10k/spectral.c
@@ -338,7 +338,7 @@ static ssize_t write_file_spec_scan_ctl(
 		} else {
 			res = -EINVAL;
 		}
-	} else if (strncmp("background", buf, 9) == 0) {
+	} else if (strncmp("background", buf, 10) == 0) {
 		res = ath10k_spectral_scan_config(ar, SPECTRAL_BACKGROUND);
 	} else if (strncmp("manual", buf, 6) == 0) {
 		res = ath10k_spectral_scan_config(ar, SPECTRAL_MANUAL);

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 098/206] cris: Only build flash rescue image if CONFIG_ETRAX_AXISFLASHMAP is selected
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (84 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 097/206] ath10k: use the right length of "background" Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 099/206] efi/efivar_ssdt_load: Dont return success on allocation failure Greg Kroah-Hartman
                     ` (103 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, kbuild test robot, Guenter Roeck,
	Jesper Nilsson

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Guenter Roeck <linux@roeck-us.net>

commit 328cf6927bb72cadefddebbc9a23c793108147a2 upstream.

If CONFIG_ETRAX_AXISFLASHMAP is not configured, the flash rescue image
object file is empty. With recent versions of binutils, this results
in the following build error.

cris-linux-objcopy: error:
	the input file 'arch/cris/boot/rescue/rescue.o' has no sections

This is seen, for example, when trying to build cris:allnoconfig
with recently generated toolchains.

Since it does not make sense to build a flash rescue image if there is
no flash, only build it if CONFIG_ETRAX_AXISFLASHMAP is enabled.

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Fixes: 66ab3a74c5ce ("CRIS: Merge machine dependent boot/compressed ..")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/cris/boot/rescue/Makefile |    8 ++++++++
 1 file changed, 8 insertions(+)

--- a/arch/cris/boot/rescue/Makefile
+++ b/arch/cris/boot/rescue/Makefile
@@ -10,6 +10,9 @@
 
 asflags-y += $(LINUXINCLUDE)
 ccflags-y += -O2 $(LINUXINCLUDE)
+
+ifdef CONFIG_ETRAX_AXISFLASHMAP
+
 arch-$(CONFIG_ETRAX_ARCH_V10) = v10
 arch-$(CONFIG_ETRAX_ARCH_V32) = v32
 
@@ -28,6 +31,11 @@ $(obj)/rescue.bin: $(obj)/rescue.o FORCE
 	$(call if_changed,objcopy)
 	cp -p $(obj)/rescue.bin $(objtree)
 
+else
+$(obj)/rescue.bin:
+
+endif
+
 $(obj)/testrescue.bin: $(obj)/testrescue.o
 	$(OBJCOPY) $(OBJCOPYFLAGS) $(obj)/testrescue.o tr.bin
 # Pad it to 784 bytes

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 099/206] efi/efivar_ssdt_load: Dont return success on allocation failure
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (85 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 098/206] cris: Only build flash rescue image if CONFIG_ETRAX_AXISFLASHMAP is selected Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 100/206] clk: renesas: cpg-mssr: Fix inverted debug check Greg Kroah-Hartman
                     ` (102 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Dan Carpenter, Ard Biesheuvel,
	Linus Torvalds, Peter Zijlstra, Thomas Gleixner, linux-efi,
	Ingo Molnar

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Dan Carpenter <dan.carpenter@oracle.com>

commit a75dcb5848359f488c32c0aef8711d9bd37a77b8 upstream.

We should return -ENOMEM here, instead of success.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Fixes: 475fb4e8b2f4 ("efi / ACPI: load SSTDs from EFI variables")
Link: http://lkml.kernel.org/r/20161018143318.15673-9-matt@codeblueprint.co.uk
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/firmware/efi/efi.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -259,8 +259,10 @@ static __init int efivar_ssdt_load(void)
 		}
 
 		data = kmalloc(size, GFP_KERNEL);
-		if (!data)
+		if (!data) {
+			ret = -ENOMEM;
 			goto free_entry;
+		}
 
 		ret = efivar_entry_get(entry, NULL, &size, data);
 		if (ret) {

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 100/206] clk: renesas: cpg-mssr: Fix inverted debug check
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (86 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 099/206] efi/efivar_ssdt_load: Dont return success on allocation failure Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 102/206] x86/prctl/uapi: Remove #ifdef for CHECKPOINT_RESTORE Greg Kroah-Hartman
                     ` (101 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Geert Uytterhoeven

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Geert Uytterhoeven <geert+renesas@glider.be>

commit bc4725d9029e2c8205fbaf1105e193d1c4e463bb upstream.

The intention was to enable the checks if debugging is enabled, not
disabled.

Fixes: f793d1e51705b276 ("clk: shmobile: Add new CPG/MSSR driver core")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/clk/renesas/renesas-cpg-mssr.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/clk/renesas/renesas-cpg-mssr.c
+++ b/drivers/clk/renesas/renesas-cpg-mssr.c
@@ -33,9 +33,9 @@
 #include "clk-div6.h"
 
 #ifdef DEBUG
-#define WARN_DEBUG(x)	do { } while (0)
-#else
 #define WARN_DEBUG(x)	WARN_ON(x)
+#else
+#define WARN_DEBUG(x)	do { } while (0)
 #endif
 
 

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 102/206] x86/prctl/uapi: Remove #ifdef for CHECKPOINT_RESTORE
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (87 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 100/206] clk: renesas: cpg-mssr: Fix inverted debug check Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 103/206] x86/cpu: Probe CPUID leaf 6 even when cpuid_level == 6 Greg Kroah-Hartman
                     ` (100 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Paul Bolle, Dmitry Safonov,
	Andy Lutomirski, 0x7f454c46, Borislav Petkov, Brian Gerst,
	Cyrill Gorcunov, Denys Vlasenko, H. Peter Anvin, Josh Poimboeuf,
	Linus Torvalds, Peter Zijlstra, Thomas Gleixner, linux-mm, oleg,
	Ingo Molnar

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Dmitry Safonov <dsafonov@virtuozzo.com>

commit a01aa6c9f40fe03c82032e7f8b3bcf1e6c93ac0e upstream.

As userspace knows nothing about kernel config, thus #ifdefs
around ABI prctl constants makes them invisible to userspace.

Let it be clean'n'simple: remove #ifdefs.

If kernel has CONFIG_CHECKPOINT_RESTORE disabled, sys_prctl()
will return -EINVAL for those prctls.

Reported-by: Paul Bolle <pebolle@tiscali.nl>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Acked-by: Andy Lutomirski <luto@kernel.org>
Cc: 0x7f454c46@gmail.com
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-mm@kvack.org
Cc: oleg@redhat.com
Fixes: 2eefd8789698 ("x86/arch_prctl/vdso: Add ARCH_MAP_VDSO_*")
Link: http://lkml.kernel.org/r/20161027141516.28447-2-dsafonov@virtuozzo.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/x86/include/uapi/asm/prctl.h |    8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

--- a/arch/x86/include/uapi/asm/prctl.h
+++ b/arch/x86/include/uapi/asm/prctl.h
@@ -6,10 +6,8 @@
 #define ARCH_GET_FS 0x1003
 #define ARCH_GET_GS 0x1004
 
-#ifdef CONFIG_CHECKPOINT_RESTORE
-# define ARCH_MAP_VDSO_X32	0x2001
-# define ARCH_MAP_VDSO_32	0x2002
-# define ARCH_MAP_VDSO_64	0x2003
-#endif
+#define ARCH_MAP_VDSO_X32	0x2001
+#define ARCH_MAP_VDSO_32	0x2002
+#define ARCH_MAP_VDSO_64	0x2003
 
 #endif /* _ASM_X86_PRCTL_H */

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 103/206] x86/cpu: Probe CPUID leaf 6 even when cpuid_level == 6
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (88 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 102/206] x86/prctl/uapi: Remove #ifdef for CHECKPOINT_RESTORE Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 105/206] hwmon: (scpi) Fix module autoload Greg Kroah-Hartman
                     ` (99 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Andy Lutomirski, Borislav Petkov,
	Brian Gerst, Thomas Gleixner

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Andy Lutomirski <luto@kernel.org>

commit 3df8d9208569ef0b2313e516566222d745f3b94b upstream.

A typo (or mis-merge?) resulted in leaf 6 only being probed if
cpuid_level >= 7.

Fixes: 2ccd71f1b278 ("x86/cpufeature: Move some of the scattered feature bits to x86_capability")
Signed-off-by: Andy Lutomirski <luto@kernel.org>
Acked-by: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Link: http://lkml.kernel.org/r/6ea30c0e9daec21e488b54761881a6dfcf3e04d0.1481825597.git.luto@kernel.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/x86/kernel/cpu/common.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -667,13 +667,14 @@ void get_cpu_cap(struct cpuinfo_x86 *c)
 		c->x86_capability[CPUID_1_EDX] = edx;
 	}
 
+	/* Thermal and Power Management Leaf: level 0x00000006 (eax) */
+	if (c->cpuid_level >= 0x00000006)
+		c->x86_capability[CPUID_6_EAX] = cpuid_eax(0x00000006);
+
 	/* Additional Intel-defined flags: level 0x00000007 */
 	if (c->cpuid_level >= 0x00000007) {
 		cpuid_count(0x00000007, 0, &eax, &ebx, &ecx, &edx);
-
 		c->x86_capability[CPUID_7_0_EBX] = ebx;
-
-		c->x86_capability[CPUID_6_EAX] = cpuid_eax(0x00000006);
 		c->x86_capability[CPUID_7_ECX] = ecx;
 	}
 

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 105/206] hwmon: (scpi) Fix module autoload
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (89 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 103/206] x86/cpu: Probe CPUID leaf 6 even when cpuid_level == 6 Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 106/206] hwmon: (amc6821) sign extension temperature Greg Kroah-Hartman
                     ` (98 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Javier Martinez Canillas, Guenter Roeck

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Javier Martinez Canillas <javier@osg.samsung.com>

commit 13edb767aa609b6efb7c0c2b57fbd72a6ded0eed upstream.

If the driver is built as a module, autoload won't work because the module
alias information is not filled. So user-space can't match the registered
device with the corresponding module.

Export the module alias information using the MODULE_DEVICE_TABLE() macro.

Before this patch:

$ modinfo drivers/hwmon/scpi-hwmon.ko | grep alias
$

After this patch:

$ modinfo drivers/hwmon/scpi-hwmon.ko | grep alias
alias:          of:N*T*Carm,scpi-sensorsC*
alias:          of:N*T*Carm,scpi-sensors

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Fixes: ea98b29a05e9c ("hwmon: Support sensors exported via ARM SCP interface")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/hwmon/scpi-hwmon.c |    1 +
 1 file changed, 1 insertion(+)

--- a/drivers/hwmon/scpi-hwmon.c
+++ b/drivers/hwmon/scpi-hwmon.c
@@ -251,6 +251,7 @@ static const struct of_device_id scpi_of
 	{.compatible = "arm,scpi-sensors"},
 	{},
 };
+MODULE_DEVICE_TABLE(of, scpi_of_match);
 
 static struct platform_driver scpi_hwmon_platdrv = {
 	.driver = {

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 106/206] hwmon: (amc6821) sign extension temperature
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (90 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 105/206] hwmon: (scpi) Fix module autoload Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 107/206] hwmon: (ds620) Fix overflows seen when writing temperature limits Greg Kroah-Hartman
                     ` (97 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Jared Bents, Matt Weber, Guenter Roeck

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jared Bents <jared.bents@rockwellcollins.com>

commit 4538bfbf2d9f1fc48c07ac0cc0ee58716fe7fe96 upstream.

Converts the unsigned temperature values from the i2c read
to be sign extended as defined in the datasheet so that
negative temperatures are properly read.

Fixes: 28e6274d8fa67 ("hwmon: (amc6821) Avoid forward declaration")
Signed-off-by: Jared Bents <jared.bents@rockwellcollins.com>
Signed-off-by: Matt Weber <matthew.weber@rockwellcollins.com>
[groeck: Dropped unnecessary continuation line]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/hwmon/amc6821.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/hwmon/amc6821.c
+++ b/drivers/hwmon/amc6821.c
@@ -188,8 +188,8 @@ static struct amc6821_data *amc6821_upda
 			!data->valid) {
 
 		for (i = 0; i < TEMP_IDX_LEN; i++)
-			data->temp[i] = i2c_smbus_read_byte_data(client,
-				temp_reg[i]);
+			data->temp[i] = (int8_t)i2c_smbus_read_byte_data(
+				client, temp_reg[i]);
 
 		data->stat1 = i2c_smbus_read_byte_data(client,
 			AMC6821_REG_STAT1);

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 107/206] hwmon: (ds620) Fix overflows seen when writing temperature limits
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (91 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 106/206] hwmon: (amc6821) sign extension temperature Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 108/206] hwmon: (nct7802) Fix overflows seen when writing into limit attributes Greg Kroah-Hartman
                     ` (96 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Jean Delvare, Guenter Roeck

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Guenter Roeck <linux@roeck-us.net>

commit e36ce99ee0815d7919a7b589bfb66f3de50b6bc7 upstream.

Module test reports:

temp1_max: Suspected overflow: [160000 vs. 0]
temp1_min: Suspected overflow: [160000 vs. 0]

This is seen because the values passed when writing temperature limits
are unbound.

Reviewed-by: Jean Delvare <jdelvare@suse.de>
Fixes: 6099469805c2 ("hwmon: Support for Dallas Semiconductor DS620")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/hwmon/ds620.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/hwmon/ds620.c
+++ b/drivers/hwmon/ds620.c
@@ -166,7 +166,7 @@ static ssize_t set_temp(struct device *d
 	if (res)
 		return res;
 
-	val = (val * 10 / 625) * 8;
+	val = (clamp_val(val, -128000, 128000) * 10 / 625) * 8;
 
 	mutex_lock(&data->update_lock);
 	data->temp[attr->index] = val;

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 108/206] hwmon: (nct7802) Fix overflows seen when writing into limit attributes
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (92 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 107/206] hwmon: (ds620) Fix overflows seen when writing temperature limits Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 109/206] hwmon: (g762) Fix overflows and crash seen when writing " Greg Kroah-Hartman
                     ` (95 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Jean Delvare, Guenter Roeck

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Guenter Roeck <linux@roeck-us.net>

commit c0d04e9112ad59d73f23f3b0f6726c5e798dfcbf upstream.

Fix overflows seen when writing voltage and temperature limit attributes.

The value passed to DIV_ROUND_CLOSEST() needs to be clamped, and the
value parameter passed to nct7802_write_fan_min() is an unsigned long.

Also, writing values larger than 2700000 into a fan limit attribute results
in writing 0 into the chip's limit registers. The exact behavior when
writing this value is unspecified. For consistency, report a limit of
1350000 if the chip register reads 0. This may be wrong, and the chip
behavior should be verified with the actual chip, but it is better than
reporting a value of 0 (which, when written, results in writing a value
of 0x1fff into the chip register).

Fixes: 3434f3783580 ("hwmon: Driver for Nuvoton NCT7802Y")
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/hwmon/nct7802.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

--- a/drivers/hwmon/nct7802.c
+++ b/drivers/hwmon/nct7802.c
@@ -259,13 +259,15 @@ static int nct7802_read_fan_min(struct n
 		ret = 0;
 	else if (ret)
 		ret = DIV_ROUND_CLOSEST(1350000U, ret);
+	else
+		ret = 1350000U;
 abort:
 	mutex_unlock(&data->access_lock);
 	return ret;
 }
 
 static int nct7802_write_fan_min(struct nct7802_data *data, u8 reg_fan_low,
-				 u8 reg_fan_high, unsigned int limit)
+				 u8 reg_fan_high, unsigned long limit)
 {
 	int err;
 
@@ -326,8 +328,8 @@ static int nct7802_write_voltage(struct
 	int shift = 8 - REG_VOLTAGE_LIMIT_MSB_SHIFT[index - 1][nr];
 	int err;
 
+	voltage = clamp_val(voltage, 0, 0x3ff * nct7802_vmul[nr]);
 	voltage = DIV_ROUND_CLOSEST(voltage, nct7802_vmul[nr]);
-	voltage = clamp_val(voltage, 0, 0x3ff);
 
 	mutex_lock(&data->access_lock);
 	err = regmap_write(data->regmap,
@@ -402,7 +404,7 @@ static ssize_t store_temp(struct device
 	if (err < 0)
 		return err;
 
-	val = clamp_val(DIV_ROUND_CLOSEST(val, 1000), -128, 127);
+	val = DIV_ROUND_CLOSEST(clamp_val(val, -128000, 127000), 1000);
 
 	err = regmap_write(data->regmap, nr, val & 0xff);
 	return err ? : count;

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 109/206] hwmon: (g762) Fix overflows and crash seen when writing limit attributes
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (93 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 108/206] hwmon: (nct7802) Fix overflows seen when writing into limit attributes Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 110/206] hwmon: (lm90) fix temp1_max_alarm attribute Greg Kroah-Hartman
                     ` (94 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Arnaud Ebalard, Jean Delvare, Guenter Roeck

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Guenter Roeck <linux@roeck-us.net>

commit 4fccd4a1e8944033bcd7693ea4e8fb478cd2059a upstream.

Fix overflows seen when writing into fan speed limit attributes.
Also fix crash due to division by zero, seen when certain very
large values (such as 2147483648, or 0x80000000) are written
into fan speed limit attributes.

Fixes: 594fbe713bf60 ("Add support for GMT G762/G763 PWM fan controllers")
Cc: Arnaud Ebalard <arno@natisbad.org>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/hwmon/g762.c |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

--- a/drivers/hwmon/g762.c
+++ b/drivers/hwmon/g762.c
@@ -193,14 +193,17 @@ static inline unsigned int rpm_from_cnt(
  * Convert fan RPM value from sysfs into count value for fan controller
  * register (FAN_SET_CNT).
  */
-static inline unsigned char cnt_from_rpm(u32 rpm, u32 clk_freq, u16 p,
+static inline unsigned char cnt_from_rpm(unsigned long rpm, u32 clk_freq, u16 p,
 					 u8 clk_div, u8 gear_mult)
 {
-	if (!rpm)         /* to stop the fan, set cnt to 255 */
+	unsigned long f1 = clk_freq * 30 * gear_mult;
+	unsigned long f2 = p * clk_div;
+
+	if (!rpm)	/* to stop the fan, set cnt to 255 */
 		return 0xff;
 
-	return clamp_val(((clk_freq * 30 * gear_mult) / (rpm * p * clk_div)),
-			 0, 255);
+	rpm = clamp_val(rpm, f1 / (255 * f2), ULONG_MAX / f2);
+	return DIV_ROUND_CLOSEST(f1, rpm * f2);
 }
 
 /* helper to grab and cache data, at most one time per second */

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 110/206] hwmon: (lm90) fix temp1_max_alarm attribute
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (94 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 109/206] hwmon: (g762) Fix overflows and crash seen when writing " Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 111/206] Input: synaptics-rmi4 - unlock on error Greg Kroah-Hartman
                     ` (93 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Micehael Walle, Guenter Roeck

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Michael Walle <michael@walle.cc>

commit e9572fdd13e299cfba03abbfd2786c84ac055249 upstream.

Since commit commit eb1c8f4325d5 ("hwmon: (lm90) Convert to use new hwmon
registration API") the temp1_max_alarm and temp1_crit_alarm attributes are
mapped to the same alarm bit. Fix the typo.

Fixes: eb1c8f4325d5 ("hwmon: (lm90) Convert to use new hwmon registration API")
Signed-off-by: Micehael Walle <michael@walle.cc>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/hwmon/lm90.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -1036,7 +1036,7 @@ static const u8 lm90_temp_emerg_index[3]
 };
 
 static const u8 lm90_min_alarm_bits[3] = { 5, 3, 11 };
-static const u8 lm90_max_alarm_bits[3] = { 0, 4, 12 };
+static const u8 lm90_max_alarm_bits[3] = { 6, 4, 12 };
 static const u8 lm90_crit_alarm_bits[3] = { 0, 1, 9 };
 static const u8 lm90_emergency_alarm_bits[3] = { 15, 13, 14 };
 static const u8 lm90_fault_bits[3] = { 0, 2, 10 };

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 111/206] Input: synaptics-rmi4 - unlock on error
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (95 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 110/206] hwmon: (lm90) fix temp1_max_alarm attribute Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 112/206] clk: qcom: ipq806x: Fix board clk rates Greg Kroah-Hartman
                     ` (92 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Dan Carpenter, Dmitry Torokhov

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Dan Carpenter <dan.carpenter@oracle.com>

commit 792f497b22afd0563b94dd8fa129a05f762a2c25 upstream.

We should unlock before returning on this error path.

Fixes: 3a762dbd5347 ('[media] Input: synaptics-rmi4 - add support for F54 diagnostics')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/input/rmi4/rmi_f54.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

--- a/drivers/input/rmi4/rmi_f54.c
+++ b/drivers/input/rmi4/rmi_f54.c
@@ -200,7 +200,7 @@ static int rmi_f54_request_report(struct
 
 	error = rmi_write(rmi_dev, fn->fd.command_base_addr, F54_GET_REPORT);
 	if (error < 0)
-		return error;
+		goto unlock;
 
 	init_completion(&f54->cmd_done);
 
@@ -209,9 +209,10 @@ static int rmi_f54_request_report(struct
 
 	queue_delayed_work(f54->workqueue, &f54->work, 0);
 
+unlock:
 	mutex_unlock(&f54->data_mutex);
 
-	return 0;
+	return error;
 }
 
 static size_t rmi_f54_get_report_size(struct f54_data *f54)

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 112/206] clk: qcom: ipq806x: Fix board clk rates
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (96 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 111/206] Input: synaptics-rmi4 - unlock on error Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 113/206] clk: clk-wm831x: fix a logic error Greg Kroah-Hartman
                     ` (91 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Stephen Boyd

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Stephen Boyd <sboyd@codeaurora.org>

commit cbf2e548ca8ad4bb274d014e9a70bd841d29948e upstream.

The clocks on these boards run at 25 MHz, not 19.2 and 27 like
other platforms. Unfortunately I copy/pasted from other similar
SoCs but forgot this one is different. Fix it.

Fixes: a085f877a882 ("clk: qcom: Move cxo/pxo/xo into dt files")
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/clk/qcom/gcc-ipq806x.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/clk/qcom/gcc-ipq806x.c
+++ b/drivers/clk/qcom/gcc-ipq806x.c
@@ -2990,11 +2990,11 @@ static int gcc_ipq806x_probe(struct plat
 	struct regmap *regmap;
 	int ret;
 
-	ret = qcom_cc_register_board_clk(dev, "cxo_board", "cxo", 19200000);
+	ret = qcom_cc_register_board_clk(dev, "cxo_board", "cxo", 25000000);
 	if (ret)
 		return ret;
 
-	ret = qcom_cc_register_board_clk(dev, "pxo_board", "pxo", 27000000);
+	ret = qcom_cc_register_board_clk(dev, "pxo_board", "pxo", 25000000);
 	if (ret)
 		return ret;
 

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 113/206] clk: clk-wm831x: fix a logic error
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (97 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 112/206] clk: qcom: ipq806x: Fix board clk rates Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 114/206] clk: ti: dra7: fix "failed to lookup clock node gmac_gmii_ref_clk_div" boot message Greg Kroah-Hartman
                     ` (90 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Pan Bian, Charles Keepax, Stephen Boyd

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Pan Bian <bianpan2016@163.com>

commit 20979202ee6e4c68dab7bcf408787225a656d18e upstream.

Fix bug https://bugzilla.kernel.org/show_bug.cgi?id=188561. Function
wm831x_clkout_is_prepared() returns "true" when it fails to read
CLOCK_CONTROL_1. "true" means the device is already prepared. So
return "true" on the read failure seems improper.

Signed-off-by: Pan Bian <bianpan2016@163.com>
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Fixes: f05259a6ffa4 ("clk: wm831x: Add initial WM831x clock driver")
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/clk/clk-wm831x.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/clk/clk-wm831x.c
+++ b/drivers/clk/clk-wm831x.c
@@ -243,7 +243,7 @@ static int wm831x_clkout_is_prepared(str
 	if (ret < 0) {
 		dev_err(wm831x->dev, "Unable to read CLOCK_CONTROL_1: %d\n",
 			ret);
-		return true;
+		return false;
 	}
 
 	return (ret & WM831X_CLKOUT_ENA) != 0;

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 114/206] clk: ti: dra7: fix "failed to lookup clock node gmac_gmii_ref_clk_div" boot message
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (98 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 113/206] clk: clk-wm831x: fix a logic error Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 115/206] clk: sunxi-ng: sun8i-a23: Set CLK_SET_RATE_PARENT for audio module clocks Greg Kroah-Hartman
                     ` (89 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Grygorii Strashko, Stephen Boyd

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Grygorii Strashko <grygorii.strashko@ti.com>

commit f8d17344a60921c2387759fc0a85aa64299d1ec6 upstream.

Prevent creating clk alias for non existing gmac_gmii_ref_clk_div clock and,
this way, eliminate excessive error message during boot:

 "ti_dt_clocks_register: failed to lookup clock node gmac_gmii_ref_clk_div"

Fixes: c097338ebd3f ("ARM: dts: dra7: cpsw: fix clocks tree")
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/clk/ti/clk-7xx.c |    1 -
 1 file changed, 1 deletion(-)

--- a/drivers/clk/ti/clk-7xx.c
+++ b/drivers/clk/ti/clk-7xx.c
@@ -201,7 +201,6 @@ static struct ti_dt_clk dra7xx_clks[] =
 	DT_CLK(NULL, "atl_dpll_clk_mux", "atl_dpll_clk_mux"),
 	DT_CLK(NULL, "atl_gfclk_mux", "atl_gfclk_mux"),
 	DT_CLK(NULL, "dcan1_sys_clk_mux", "dcan1_sys_clk_mux"),
-	DT_CLK(NULL, "gmac_gmii_ref_clk_div", "gmac_gmii_ref_clk_div"),
 	DT_CLK(NULL, "gmac_rft_clk_mux", "gmac_rft_clk_mux"),
 	DT_CLK(NULL, "gpu_core_gclk_mux", "gpu_core_gclk_mux"),
 	DT_CLK(NULL, "gpu_hyd_gclk_mux", "gpu_hyd_gclk_mux"),

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 115/206] clk: sunxi-ng: sun8i-a23: Set CLK_SET_RATE_PARENT for audio module clocks
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (99 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 114/206] clk: ti: dra7: fix "failed to lookup clock node gmac_gmii_ref_clk_div" boot message Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 116/206] clk: sunxi-ng: sun8i-h3: " Greg Kroah-Hartman
                     ` (88 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Chen-Yu Tsai, Maxime Ripard

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Chen-Yu Tsai <wens@csie.org>

commit 937ff9ded8b6ebe8963ade55bdd77a61ded88075 upstream.

The audio module clocks are supposed to be set according to the sample
rate of the audio stream. The audio PLL provides the clock signal for
these module clocks, and only it is freely tunable.

Set CLK_SET_RATE_PARENT for the audio module clocks so their users can
properly tune the clock rate.

Fixes: 5690879d93e8 ("clk: sunxi-ng: Add A23 CCU")
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/clk/sunxi-ng/ccu-sun8i-a23.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- a/drivers/clk/sunxi-ng/ccu-sun8i-a23.c
+++ b/drivers/clk/sunxi-ng/ccu-sun8i-a23.c
@@ -344,10 +344,10 @@ static SUNXI_CCU_MP_WITH_MUX_GATE(spi1_c
 static const char * const i2s_parents[] = { "pll-audio-8x", "pll-audio-4x",
 					    "pll-audio-2x", "pll-audio" };
 static SUNXI_CCU_MUX_WITH_GATE(i2s0_clk, "i2s0", i2s_parents,
-			       0x0b0, 16, 2, BIT(31), 0);
+			       0x0b0, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
 
 static SUNXI_CCU_MUX_WITH_GATE(i2s1_clk, "i2s1", i2s_parents,
-			       0x0b4, 16, 2, BIT(31), 0);
+			       0x0b4, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
 
 /* TODO: the parent for most of the USB clocks is not known */
 static SUNXI_CCU_GATE(usb_phy0_clk,	"usb-phy0",	"osc24M",
@@ -415,7 +415,7 @@ static SUNXI_CCU_M_WITH_GATE(ve_clk, "ve
 			     0x13c, 16, 3, BIT(31), CLK_SET_RATE_PARENT);
 
 static SUNXI_CCU_GATE(ac_dig_clk,	"ac-dig",	"pll-audio",
-		      0x140, BIT(31), 0);
+		      0x140, BIT(31), CLK_SET_RATE_PARENT);
 static SUNXI_CCU_GATE(avs_clk,		"avs",		"osc24M",
 		      0x144, BIT(31), 0);
 

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 116/206] clk: sunxi-ng: sun8i-h3: Set CLK_SET_RATE_PARENT for audio module clocks
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (100 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 115/206] clk: sunxi-ng: sun8i-a23: Set CLK_SET_RATE_PARENT for audio module clocks Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 118/206] clk: renesas: mstp: Support 8-bit registers for r7s72100 Greg Kroah-Hartman
                     ` (87 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Chen-Yu Tsai, Maxime Ripard

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Chen-Yu Tsai <wens@csie.org>

commit 0f6f9302b819ca352cfd4f42c18ec08d521f9cae upstream.

The audio module clocks are supposed to be set according to the sample
rate of the audio stream. The audio PLL provides the clock signal for
these module clocks, and only it is freely tunable.

Set CLK_SET_RATE_PARENT for the audio module clocks so their users can
properly tune the clock rate.

Fixes: 0577e4853bfb ("clk: sunxi-ng: Add H3 clocks")
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/clk/sunxi-ng/ccu-sun8i-h3.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

--- a/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
+++ b/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
@@ -394,16 +394,16 @@ static SUNXI_CCU_MP_WITH_MUX_GATE(spi1_c
 static const char * const i2s_parents[] = { "pll-audio-8x", "pll-audio-4x",
 					    "pll-audio-2x", "pll-audio" };
 static SUNXI_CCU_MUX_WITH_GATE(i2s0_clk, "i2s0", i2s_parents,
-			       0x0b0, 16, 2, BIT(31), 0);
+			       0x0b0, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
 
 static SUNXI_CCU_MUX_WITH_GATE(i2s1_clk, "i2s1", i2s_parents,
-			       0x0b4, 16, 2, BIT(31), 0);
+			       0x0b4, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
 
 static SUNXI_CCU_MUX_WITH_GATE(i2s2_clk, "i2s2", i2s_parents,
-			       0x0b8, 16, 2, BIT(31), 0);
+			       0x0b8, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
 
 static SUNXI_CCU_M_WITH_GATE(spdif_clk, "spdif", "pll-audio",
-			     0x0c0, 0, 4, BIT(31), 0);
+			     0x0c0, 0, 4, BIT(31), CLK_SET_RATE_PARENT);
 
 static SUNXI_CCU_GATE(usb_phy0_clk,	"usb-phy0",	"osc24M",
 		      0x0cc, BIT(8), 0);
@@ -466,7 +466,7 @@ static SUNXI_CCU_M_WITH_GATE(ve_clk, "ve
 			     0x13c, 16, 3, BIT(31), 0);
 
 static SUNXI_CCU_GATE(ac_dig_clk,	"ac-dig",	"pll-audio",
-		      0x140, BIT(31), 0);
+		      0x140, BIT(31), CLK_SET_RATE_PARENT);
 static SUNXI_CCU_GATE(avs_clk,		"avs",		"osc24M",
 		      0x144, BIT(31), 0);
 

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 118/206] clk: renesas: mstp: Support 8-bit registers for r7s72100
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (101 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 116/206] clk: sunxi-ng: sun8i-h3: " Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 119/206] iommu/amd: Missing error code in amd_iommu_init_device() Greg Kroah-Hartman
                     ` (86 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Chris Brandt, Geert Uytterhoeven,
	Kuninori Morimoto, Stephen Boyd

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Chris Brandt <chris.brandt@renesas.com>

commit e2a33c34ddff22ee208d80abdd12b88a98d6cb60 upstream.

The RZ/A1 is different than the other Renesas SOCs because the MSTP
registers are 8-bit instead of 32-bit and if you try writing values as
32-bit nothing happens...meaning this driver never worked for r7s72100.

Fixes: b6face404f38 ("ARM: shmobile: r7s72100: add essential clock nodes to dtsi")
Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/clk/renesas/clk-mstp.c |   27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

--- a/drivers/clk/renesas/clk-mstp.c
+++ b/drivers/clk/renesas/clk-mstp.c
@@ -37,12 +37,14 @@
  * @smstpcr: module stop control register
  * @mstpsr: module stop status register (optional)
  * @lock: protects writes to SMSTPCR
+ * @width_8bit: registers are 8-bit, not 32-bit
  */
 struct mstp_clock_group {
 	struct clk_onecell_data data;
 	void __iomem *smstpcr;
 	void __iomem *mstpsr;
 	spinlock_t lock;
+	bool width_8bit;
 };
 
 /**
@@ -59,6 +61,18 @@ struct mstp_clock {
 
 #define to_mstp_clock(_hw) container_of(_hw, struct mstp_clock, hw)
 
+static inline u32 cpg_mstp_read(struct mstp_clock_group *group,
+				u32 __iomem *reg)
+{
+	return group->width_8bit ? readb(reg) : clk_readl(reg);
+}
+
+static inline void cpg_mstp_write(struct mstp_clock_group *group, u32 val,
+				  u32 __iomem *reg)
+{
+	group->width_8bit ? writeb(val, reg) : clk_writel(val, reg);
+}
+
 static int cpg_mstp_clock_endisable(struct clk_hw *hw, bool enable)
 {
 	struct mstp_clock *clock = to_mstp_clock(hw);
@@ -70,12 +84,12 @@ static int cpg_mstp_clock_endisable(stru
 
 	spin_lock_irqsave(&group->lock, flags);
 
-	value = clk_readl(group->smstpcr);
+	value = cpg_mstp_read(group, group->smstpcr);
 	if (enable)
 		value &= ~bitmask;
 	else
 		value |= bitmask;
-	clk_writel(value, group->smstpcr);
+	cpg_mstp_write(group, value, group->smstpcr);
 
 	spin_unlock_irqrestore(&group->lock, flags);
 
@@ -83,7 +97,7 @@ static int cpg_mstp_clock_endisable(stru
 		return 0;
 
 	for (i = 1000; i > 0; --i) {
-		if (!(clk_readl(group->mstpsr) & bitmask))
+		if (!(cpg_mstp_read(group, group->mstpsr) & bitmask))
 			break;
 		cpu_relax();
 	}
@@ -114,9 +128,9 @@ static int cpg_mstp_clock_is_enabled(str
 	u32 value;
 
 	if (group->mstpsr)
-		value = clk_readl(group->mstpsr);
+		value = cpg_mstp_read(group, group->mstpsr);
 	else
-		value = clk_readl(group->smstpcr);
+		value = cpg_mstp_read(group, group->smstpcr);
 
 	return !(value & BIT(clock->bit_index));
 }
@@ -188,6 +202,9 @@ static void __init cpg_mstp_clocks_init(
 		return;
 	}
 
+	if (of_device_is_compatible(np, "renesas,r7s72100-mstp-clocks"))
+		group->width_8bit = true;
+
 	for (i = 0; i < MSTP_MAX_CLOCKS; ++i)
 		clks[i] = ERR_PTR(-ENOENT);
 

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 119/206] iommu/amd: Missing error code in amd_iommu_init_device()
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (102 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 118/206] clk: renesas: mstp: Support 8-bit registers for r7s72100 Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 120/206] iommu/amd: Fix the left value check of cmd buffer Greg Kroah-Hartman
                     ` (85 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Dan Carpenter, Joerg Roedel

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Dan Carpenter <dan.carpenter@oracle.com>

commit 24c790fbf5d8f54c8c82979db11edea8855b74bf upstream.

We should set "ret" to -EINVAL if iommu_group_get() fails.

Fixes: 55c99a4dc50f ("iommu/amd: Use iommu_attach_group()")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/iommu/amd_iommu_v2.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/drivers/iommu/amd_iommu_v2.c
+++ b/drivers/iommu/amd_iommu_v2.c
@@ -805,8 +805,10 @@ int amd_iommu_init_device(struct pci_dev
 		goto out_free_domain;
 
 	group = iommu_group_get(&pdev->dev);
-	if (!group)
+	if (!group) {
+		ret = -EINVAL;
 		goto out_free_domain;
+	}
 
 	ret = iommu_attach_group(dev_state->domain, group);
 	if (ret != 0)

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 120/206] iommu/amd: Fix the left value check of cmd buffer
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (103 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 119/206] iommu/amd: Missing error code in amd_iommu_init_device() Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 121/206] iommu/vt-d: Fix pasid table size encoding Greg Kroah-Hartman
                     ` (84 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Huang Rui, Joerg Roedel

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Huang Rui <ray.huang@amd.com>

commit 432abf68a79332282329286d190e21fe3ac02a31 upstream.

The generic command buffer entry is 128 bits (16 bytes), so the offset
of tail and head pointer should be 16 bytes aligned and increased with
0x10 per command.

When cmd buf is full, head = (tail + 0x10) % CMD_BUFFER_SIZE.

So when left space of cmd buf should be able to store only two
command, we should be issued one COMPLETE_WAIT additionally to wait
all older commands completed. Then the left space should be increased
after IOMMU fetching from cmd buf.

So left check value should be left <= 0x20 (two commands).

Signed-off-by: Huang Rui <ray.huang@amd.com>
Fixes: ac0ea6e92b222 ('x86/amd-iommu: Improve handling of full command buffer')
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/iommu/amd_iommu.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -1021,7 +1021,7 @@ again:
 	next_tail = (tail + sizeof(*cmd)) % CMD_BUFFER_SIZE;
 	left      = (head - next_tail) % CMD_BUFFER_SIZE;
 
-	if (left <= 2) {
+	if (left <= 0x20) {
 		struct iommu_cmd sync_cmd;
 		int ret;
 

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 121/206] iommu/vt-d: Fix pasid table size encoding
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (104 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 120/206] iommu/amd: Fix the left value check of cmd buffer Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 122/206] iommu/vt-d: Flush old iommu caches for kdump when the device gets context mapped Greg Kroah-Hartman
                     ` (83 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Mika Kuoppala, Ashok Raj, Jacob Pan,
	Mika Kuoppala, Joerg Roedel

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jacob Pan <jacob.jun.pan@linux.intel.com>

commit 65ca7f5f7d1cdde6c25172fe6107cd16902f826f upstream.

Different encodings are used to represent supported PASID bits
and number of PASID table entries.
The current code assigns ecap_pss directly to extended context
table entry PTS which is wrong and could result in writing
non-zero bits to the reserved fields. IOMMU fault reason
11 will be reported when reserved bits are nonzero.
This patch converts ecap_pss to extend context entry pts encoding
based on VT-d spec. Chapter 9.4 as follows:
 - number of PASID bits = ecap_pss + 1
 - number of PASID table entries = 2^(pts + 5)
Software assigned limit of pasid_max value is also respected to
match the allocation limitation of PASID table.

cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
cc: Ashok Raj <ashok.raj@intel.com>
Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
Tested-by: Mika Kuoppala <mika.kuoppala@intel.com>
Fixes: 2f26e0a9c9860 ('iommu/vt-d: Add basic SVM PASID support')
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/iommu/intel-iommu.c |   23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -5197,6 +5197,25 @@ static void intel_iommu_remove_device(st
 }
 
 #ifdef CONFIG_INTEL_IOMMU_SVM
+#define MAX_NR_PASID_BITS (20)
+static inline unsigned long intel_iommu_get_pts(struct intel_iommu *iommu)
+{
+	/*
+	 * Convert ecap_pss to extend context entry pts encoding, also
+	 * respect the soft pasid_max value set by the iommu.
+	 * - number of PASID bits = ecap_pss + 1
+	 * - number of PASID table entries = 2^(pts + 5)
+	 * Therefore, pts = ecap_pss - 4
+	 * e.g. KBL ecap_pss = 0x13, PASID has 20 bits, pts = 15
+	 */
+	if (ecap_pss(iommu->ecap) < 5)
+		return 0;
+
+	/* pasid_max is encoded as actual number of entries not the bits */
+	return find_first_bit((unsigned long *)&iommu->pasid_max,
+			MAX_NR_PASID_BITS) - 5;
+}
+
 int intel_iommu_enable_pasid(struct intel_iommu *iommu, struct intel_svm_dev *sdev)
 {
 	struct device_domain_info *info;
@@ -5229,7 +5248,9 @@ int intel_iommu_enable_pasid(struct inte
 
 	if (!(ctx_lo & CONTEXT_PASIDE)) {
 		context[1].hi = (u64)virt_to_phys(iommu->pasid_state_table);
-		context[1].lo = (u64)virt_to_phys(iommu->pasid_table) | ecap_pss(iommu->ecap);
+		context[1].lo = (u64)virt_to_phys(iommu->pasid_table) |
+			intel_iommu_get_pts(iommu);
+
 		wmb();
 		/* CONTEXT_TT_MULTI_LEVEL and CONTEXT_TT_DEV_IOTLB are both
 		 * extended to permit requests-with-PASID if the PASIDE bit

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 122/206] iommu/vt-d: Flush old iommu caches for kdump when the device gets context mapped
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (105 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 121/206] iommu/vt-d: Fix pasid table size encoding Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 124/206] ASoC: cht_bsw_rt5645: Fix leftover kmalloc Greg Kroah-Hartman
                     ` (82 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Myron Stowe, Joseph Szczypek,
	Don Brace, Baoquan He, Dave Young, Xunlei Pang, Joerg Roedel

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Xunlei Pang <xlpang@redhat.com>

commit aec0e86172a79eb5e44aff1055bb953fe4d47c59 upstream.

We met the DMAR fault both on hpsa P420i and P421 SmartArray controllers
under kdump, it can be steadily reproduced on several different machines,
the dmesg log is like:
HP HPSA Driver (v 3.4.16-0)
hpsa 0000:02:00.0: using doorbell to reset controller
hpsa 0000:02:00.0: board ready after hard reset.
hpsa 0000:02:00.0: Waiting for controller to respond to no-op
DMAR: Setting identity map for device 0000:02:00.0 [0xe8000 - 0xe8fff]
DMAR: Setting identity map for device 0000:02:00.0 [0xf4000 - 0xf4fff]
DMAR: Setting identity map for device 0000:02:00.0 [0xbdf6e000 - 0xbdf6efff]
DMAR: Setting identity map for device 0000:02:00.0 [0xbdf6f000 - 0xbdf7efff]
DMAR: Setting identity map for device 0000:02:00.0 [0xbdf7f000 - 0xbdf82fff]
DMAR: Setting identity map for device 0000:02:00.0 [0xbdf83000 - 0xbdf84fff]
DMAR: DRHD: handling fault status reg 2
DMAR: [DMA Read] Request device [02:00.0] fault addr fffff000 [fault reason 06] PTE Read access is not set
hpsa 0000:02:00.0: controller message 03:00 timed out
hpsa 0000:02:00.0: no-op failed; re-trying

After some debugging, we found that the fault addr is from DMA initiated at
the driver probe stage after reset(not in-flight DMA), and the corresponding
pte entry value is correct, the fault is likely due to the old iommu caches
of the in-flight DMA before it.

Thus we need to flush the old cache after context mapping is setup for the
device, where the device is supposed to finish reset at its driver probe
stage and no in-flight DMA exists hereafter.

I'm not sure if the hardware is responsible for invalidating all the related
caches allocated in the iommu hardware before, but seems not the case for hpsa,
actually many device drivers have problems in properly resetting the hardware.
Anyway flushing (again) by software in kdump kernel when the device gets context
mapped which is a quite infrequent operation does little harm.

With this patch, the problematic machine can survive the kdump tests.

CC: Myron Stowe <myron.stowe@gmail.com>
CC: Joseph Szczypek <jszczype@redhat.com>
CC: Don Brace <don.brace@microsemi.com>
CC: Baoquan He <bhe@redhat.com>
CC: Dave Young <dyoung@redhat.com>
Fixes: 091d42e43d21 ("iommu/vt-d: Copy translation tables from old kernel")
Fixes: dbcd861f252d ("iommu/vt-d: Do not re-use domain-ids from the old kernel")
Fixes: cf484d0e6939 ("iommu/vt-d: Mark copied context entries")
Signed-off-by: Xunlei Pang <xlpang@redhat.com>
Tested-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/iommu/intel-iommu.c |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -2037,6 +2037,25 @@ static int domain_context_mapping_one(st
 	if (context_present(context))
 		goto out_unlock;
 
+	/*
+	 * For kdump cases, old valid entries may be cached due to the
+	 * in-flight DMA and copied pgtable, but there is no unmapping
+	 * behaviour for them, thus we need an explicit cache flush for
+	 * the newly-mapped device. For kdump, at this point, the device
+	 * is supposed to finish reset at its driver probe stage, so no
+	 * in-flight DMA will exist, and we don't need to worry anymore
+	 * hereafter.
+	 */
+	if (context_copied(context)) {
+		u16 did_old = context_domain_id(context);
+
+		if (did_old >= 0 && did_old < cap_ndoms(iommu->cap))
+			iommu->flush.flush_context(iommu, did_old,
+						   (((u16)bus) << 8) | devfn,
+						   DMA_CCMD_MASK_NOBIT,
+						   DMA_CCMD_DEVICE_INVL);
+	}
+
 	pgd = domain->pgd;
 
 	context_clear_entry(context);

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 124/206] ASoC: cht_bsw_rt5645: Fix leftover kmalloc
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (106 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 122/206] iommu/vt-d: Flush old iommu caches for kdump when the device gets context mapped Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 125/206] ASoC: Intel: Skylake: Fix a shift wrapping bug Greg Kroah-Hartman
                     ` (81 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Takashi Iwai, Mark Brown

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Takashi Iwai <tiwai@suse.de>

commit a823a17981a73faa115bc0f7eda0190763075e2c upstream.

cht_bsw_rt5645 driver allocates the own codec_id string but doesn't
release it.  For simplicity, put the string in cht_mc_private; then
the string is allocated in a shot and released altogether.

Fixes: c8560b7c917f ("ASoC: cht_bsw_rt5645: Fix writing to string literal")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 sound/soc/intel/boards/cht_bsw_rt5645.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- a/sound/soc/intel/boards/cht_bsw_rt5645.c
+++ b/sound/soc/intel/boards/cht_bsw_rt5645.c
@@ -44,6 +44,7 @@ struct cht_acpi_card {
 struct cht_mc_private {
 	struct snd_soc_jack jack;
 	struct cht_acpi_card *acpi_card;
+	char codec_name[16];
 };
 
 static inline struct snd_soc_dai *cht_get_codec_dai(struct snd_soc_card *card)
@@ -354,7 +355,6 @@ static int snd_cht_mc_probe(struct platf
 	int i;
 	struct cht_mc_private *drv;
 	struct snd_soc_card *card = snd_soc_cards[0].soc_card;
-	char codec_name[16];
 	struct sst_acpi_mach *mach;
 	const char *i2c_name = NULL;
 	int dai_index = 0;
@@ -374,12 +374,12 @@ static int snd_cht_mc_probe(struct platf
 	}
 	card->dev = &pdev->dev;
 	mach = card->dev->platform_data;
-	sprintf(codec_name, "i2c-%s:00", drv->acpi_card->codec_id);
+	sprintf(drv->codec_name, "i2c-%s:00", drv->acpi_card->codec_id);
 
 	/* set correct codec name */
 	for (i = 0; i < ARRAY_SIZE(cht_dailink); i++)
 		if (!strcmp(card->dai_link[i].codec_name, "i2c-10EC5645:00")) {
-			card->dai_link[i].codec_name = kstrdup(codec_name, GFP_KERNEL);
+			card->dai_link[i].codec_name = drv->codec_name;
 			dai_index = i;
 		}
 

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 125/206] ASoC: Intel: Skylake: Fix a shift wrapping bug
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (107 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 124/206] ASoC: cht_bsw_rt5645: Fix leftover kmalloc Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 126/206] ASoC: samsung: i2s: Fixup last IRQ unsafe spin lock call Greg Kroah-Hartman
                     ` (80 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Dan Carpenter, Vinod Koul, Kranthi G,
	Mark Brown

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Dan Carpenter <dan.carpenter@oracle.com>

commit c8eabf821cac120afb78ca251b07cbf520406a7e upstream.

"*val" is a u64.  It definitely looks like we intend to use the high 32
bits as well.

Fixes: 700a9a63f9c1 ("ASoC: Intel: Skylake: Add module instance id generation APIs")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Tested-by: Kranthi G <gudishax.kranthikumar@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 sound/soc/intel/skylake/skl-sst-utils.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/sound/soc/intel/skylake/skl-sst-utils.c
+++ b/sound/soc/intel/skylake/skl-sst-utils.c
@@ -179,7 +179,7 @@ static inline int skl_getid_32(struct uu
 		index = ffz(mask_val);
 		pvt_id = index + word1_mask + word2_mask;
 		if (pvt_id <= (max_inst - 1)) {
-			*val |= 1 << (index + word1_mask);
+			*val |= 1ULL << (index + word1_mask);
 			return pvt_id;
 		}
 	}

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 126/206] ASoC: samsung: i2s: Fixup last IRQ unsafe spin lock call
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (108 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 125/206] ASoC: Intel: Skylake: Fix a shift wrapping bug Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 127/206] scsi: g_NCR5380: Fix release_region in error handling Greg Kroah-Hartman
                     ` (79 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Charles Keepax, Krzysztof Kozlowski,
	Sylwester Nawrocki, Mark Brown

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>

commit 5faf071d08ddd1c1be66deaa93a09ccf43f5b538 upstream.

Unfortunately, I seem to have missed a case where an IRQ safe spinlock was
required, in samsung_i2s_dai_remove, when I fixed up the other calls in
this patch:

316fa9e09ad7 ("ASoC: samsung: Use IRQ safe spin lock calls")

This causes a lockdep warning when unbinding and rebinding the audio card:

[  104.357664]        CPU0                    CPU1
[  104.362174]        ----                    ----
[  104.366692]   lock(&(&pri_dai->spinlock)->rlock);
[  104.371372]                                local_irq_disable();
[  104.377283]                                lock(&(&substream->self_group.lock)->rlock);
[  104.385259]                                lock(&(&pri_dai->spinlock)->rlock);
[  104.392469]   <Interrupt>
[  104.395072]     lock(&(&substream->self_group.lock)->rlock);
[  104.400710]
[  104.400710]  *** DEADLOCK ***

Fixes: ce8bcdbb61d9 ("ASoC: samsung: i2s: Protect more registers with a spinlock")
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 sound/soc/samsung/i2s.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

--- a/sound/soc/samsung/i2s.c
+++ b/sound/soc/samsung/i2s.c
@@ -1029,12 +1029,13 @@ static int samsung_i2s_dai_probe(struct
 static int samsung_i2s_dai_remove(struct snd_soc_dai *dai)
 {
 	struct i2s_dai *i2s = snd_soc_dai_get_drvdata(dai);
+	unsigned long flags;
 
 	if (!is_secondary(i2s)) {
 		if (i2s->quirks & QUIRK_NEED_RSTCLR) {
-			spin_lock(i2s->lock);
+			spin_lock_irqsave(i2s->lock, flags);
 			writel(0, i2s->addr + I2SCON);
-			spin_unlock(i2s->lock);
+			spin_unlock_irqrestore(i2s->lock, flags);
 		}
 	}
 

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 127/206] scsi: g_NCR5380: Fix release_region in error handling
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (109 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 126/206] ASoC: samsung: i2s: Fixup last IRQ unsafe spin lock call Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 128/206] scsi: mvsas: fix command_active typo Greg Kroah-Hartman
                     ` (78 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Ondrej Zary, Finn Thain, Martin K. Petersen

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Ondrej Zary <linux@rainbow-software.org>

commit 7b93ca43b7e21fbe6fb1a6f4ecce4a2f70f424a0 upstream.

When a SW-configurable card is specified but not found, the driver
releases wrong region, causing the following message in kernel log:
Trying to free nonexistent resource <0000000000000000-000000000000000f>

Fix it by assigning base earlier.

Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
Fixes: a8cfbcaec0c1 ("scsi: g_NCR5380: Stop using scsi_module.c")
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/scsi/g_NCR5380.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- a/drivers/scsi/g_NCR5380.c
+++ b/drivers/scsi/g_NCR5380.c
@@ -170,12 +170,12 @@ static int generic_NCR5380_init_one(stru
 		if (ports[i]) {
 			/* At this point we have our region reserved */
 			magic_configure(i, 0, magic); /* no IRQ yet */
-			outb(0xc0, ports[i] + 9);
-			if (inb(ports[i] + 9) != 0x80) {
+			base = ports[i];
+			outb(0xc0, base + 9);
+			if (inb(base + 9) != 0x80) {
 				ret = -ENODEV;
 				goto out_release;
 			}
-			base = ports[i];
 			port_idx = i;
 		} else
 			return -EINVAL;

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 128/206] scsi: mvsas: fix command_active typo
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (110 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 127/206] scsi: g_NCR5380: Fix release_region in error handling Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 129/206] target/iscsi: Fix double free in lio_target_tiqn_addtpg() Greg Kroah-Hartman
                     ` (77 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Arnd Bergmann, Johannes Thumshirn,
	Martin K. Petersen

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Arnd Bergmann <arnd@arndb.de>

commit af15769ffab13d777e55fdef09d0762bf0c249c4 upstream.

gcc-7 notices that the condition in mvs_94xx_command_active looks
suspicious:

drivers/scsi/mvsas/mv_94xx.c: In function 'mvs_94xx_command_active':
drivers/scsi/mvsas/mv_94xx.c:671:15: error: '<<' in boolean context, did you mean '<' ? [-Werror=int-in-bool-context]

This was introduced when the mv_printk() statement got added, and leads
to the condition being ignored. This is probably harmless.

Changing '&&' to '&' makes the code look reasonable, as we check the
command bit before setting and printing it.

Fixes: a4632aae8b66 ("[SCSI] mvsas: Add new macros and functions")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/scsi/mvsas/mv_94xx.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/scsi/mvsas/mv_94xx.c
+++ b/drivers/scsi/mvsas/mv_94xx.c
@@ -668,7 +668,7 @@ static void mvs_94xx_command_active(stru
 {
 	u32 tmp;
 	tmp = mvs_cr32(mvi, MVS_COMMAND_ACTIVE+(slot_idx >> 3));
-	if (tmp && 1 << (slot_idx % 32)) {
+	if (tmp & 1 << (slot_idx % 32)) {
 		mv_printk("command active %08X,  slot [%x].\n", tmp, slot_idx);
 		mvs_cw32(mvi, MVS_COMMAND_ACTIVE + (slot_idx >> 3),
 			1 << (slot_idx % 32));

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 129/206] target/iscsi: Fix double free in lio_target_tiqn_addtpg()
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (111 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 128/206] scsi: mvsas: fix command_active typo Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 130/206] sbp-target: Fix second argument of percpu_ida_alloc() Greg Kroah-Hartman
                     ` (76 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Dan Carpenter, David Disseldorp,
	Bart Van Assche

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Dan Carpenter <dan.carpenter@oracle.com>

commit a91918cd3ea11f91c68e08e1e8ce1b560447a80e upstream.

This iscsit_tpg_add_portal_group() function is only called from
lio_target_tiqn_addtpg().  Both functions free the "tpg" pointer on
error so it's a double free bug.  The memory is allocated in the caller
so it should be freed in the caller and not here.

Fixes: e48354ce078c ("iscsi-target: Add iSCSI fabric support for target v4.1")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: David Disseldorp <ddiss@suse.de>
[ bvanassche: Added "Fix" at start of patch title ]
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/target/iscsi/iscsi_target_tpg.c |    1 -
 1 file changed, 1 deletion(-)

--- a/drivers/target/iscsi/iscsi_target_tpg.c
+++ b/drivers/target/iscsi/iscsi_target_tpg.c
@@ -260,7 +260,6 @@ err_out:
 		iscsi_release_param_list(tpg->param_list);
 		tpg->param_list = NULL;
 	}
-	kfree(tpg);
 	return -ENOMEM;
 }
 

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 130/206] sbp-target: Fix second argument of percpu_ida_alloc()
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (112 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 129/206] target/iscsi: Fix double free in lio_target_tiqn_addtpg() Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 131/206] relay: check array offset before using it Greg Kroah-Hartman
                     ` (75 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Bart Van Assche, Chris Boot

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Bart Van Assche <bart.vanassche@sandisk.com>

commit 8456066a57940b3884aa080c58b166567dc9de39 upstream.

Pass a task state as second argument to percpu_ida_alloc().

Fixes: commit 5a3ee221b543 ("sbp-target: Conversion to percpu_ida tag pre-allocation")
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Chris Boot <bootc@bootc.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/target/sbp/sbp_target.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/target/sbp/sbp_target.c
+++ b/drivers/target/sbp/sbp_target.c
@@ -928,7 +928,7 @@ static struct sbp_target_request *sbp_mg
 	struct sbp_target_request *req;
 	int tag;
 
-	tag = percpu_ida_alloc(&se_sess->sess_tag_pool, GFP_ATOMIC);
+	tag = percpu_ida_alloc(&se_sess->sess_tag_pool, TASK_RUNNING);
 	if (tag < 0)
 		return ERR_PTR(-ENOMEM);
 

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 131/206] relay: check array offset before using it
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (113 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 130/206] sbp-target: Fix second argument of percpu_ida_alloc() Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 132/206] ima: fix memory leak in ima_release_policy Greg Kroah-Hartman
                     ` (74 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Dan Carpenter, Andrew Morton, Linus Torvalds

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Dan Carpenter <dan.carpenter@oracle.com>

commit 9a29d0fbc2d9ad99fb8a981ab72548cc360e9d4c upstream.

Smatch complains that we started using the array offset before we
checked that it was valid.

Fixes: 017c59c042d0 ('relay: Use per CPU constructs for the relay channel buffer pointers')
Link: http://lkml.kernel.org/r/20161013084947.GC16198@mwanda
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 kernel/relay.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -809,11 +809,11 @@ void relay_subbufs_consumed(struct rchan
 {
 	struct rchan_buf *buf;
 
-	if (!chan)
+	if (!chan || cpu >= NR_CPUS)
 		return;
 
 	buf = *per_cpu_ptr(chan->buf, cpu);
-	if (cpu >= NR_CPUS || !buf || subbufs_consumed > chan->n_subbufs)
+	if (!buf || subbufs_consumed > chan->n_subbufs)
 		return;
 
 	if (subbufs_consumed > buf->subbufs_produced - buf->subbufs_consumed)

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 132/206] ima: fix memory leak in ima_release_policy
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (114 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 131/206] relay: check array offset before using it Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 133/206] PCI/MSI: Check for NULL affinity mask in pci_irq_get_affinity() Greg Kroah-Hartman
                     ` (73 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Colin Ian King, Eric Richter, Mimi Zohar

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Eric Richter <erichte@linux.vnet.ibm.com>

commit 9a11a18902bc3b904353063763d06480620245a6 upstream.

When the "policy" securityfs file is opened for read, it is opened as a
sequential file. However, when it is eventually released, there is no
cleanup for the sequential file, therefore some memory is leaked.

This patch adds a call to seq_release() in ima_release_policy() to clean up
the memory when the file is opened for read.

Fixes: 80eae209d63a IMA: allow reading back the current policy
Reported-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Eric Richter <erichte@linux.vnet.ibm.com>
Tested-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 security/integrity/ima/ima_fs.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/security/integrity/ima/ima_fs.c
+++ b/security/integrity/ima/ima_fs.c
@@ -401,7 +401,7 @@ static int ima_release_policy(struct ino
 	const char *cause = valid_policy ? "completed" : "failed";
 
 	if ((file->f_flags & O_ACCMODE) == O_RDONLY)
-		return 0;
+		return seq_release(inode, file);
 
 	if (valid_policy && ima_check_policy() < 0) {
 		cause = "failed";

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 133/206] PCI/MSI: Check for NULL affinity mask in pci_irq_get_affinity()
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (115 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 132/206] ima: fix memory leak in ima_release_policy Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 134/206] irqchip/bcm7038-l1: Implement irq_cpu_offline() callback Greg Kroah-Hartman
                     ` (72 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Jan Beulich, Bjorn Helgaas,
	Christoph Hellwig, Thomas Gleixner

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jan Beulich <JBeulich@suse.com>

commit d1d111e073840b8dbc1ae90ba3fc274736451bdc upstream.

If msi_setup_entry() fails to allocate an affinity mask, it logs a message
but continues on and allocates an MSI entry with entry->affinity == NULL.

Check for this case in pci_irq_get_affinity() so we don't try to
dereference a NULL pointer.

[bhelgaas: changelog]
Fixes: ee8d41e53efe "pci/msi: Retrieve affinity for a vector"
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
CC: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/pci/msi.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -1294,7 +1294,8 @@ const struct cpumask *pci_irq_get_affini
 	} else if (dev->msi_enabled) {
 		struct msi_desc *entry = first_pci_msi_entry(dev);
 
-		if (WARN_ON_ONCE(!entry || nr >= entry->nvec_used))
+		if (WARN_ON_ONCE(!entry || !entry->affinity ||
+				 nr >= entry->nvec_used))
 			return NULL;
 
 		return &entry->affinity[nr];

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 134/206] irqchip/bcm7038-l1: Implement irq_cpu_offline() callback
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (116 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 133/206] PCI/MSI: Check for NULL affinity mask in pci_irq_get_affinity() Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 135/206] PM / wakeirq: Fix dedicated wakeirq for drivers not using autosuspend Greg Kroah-Hartman
                     ` (71 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Florian Fainelli, linux-mips, jason,
	marc.zyngier, cernekee, jaedon.shin, ralf, justinpopo6,
	Thomas Gleixner

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Florian Fainelli <f.fainelli@gmail.com>

commit 34c535793bcbf9263cf22f8a52101f796cdfab8e upstream.

We did not implement an irq_cpu_offline callback for our irqchip, yet we
support setting a given IRQ's affinity. This resulted in interrupts
whose affinity mask included CPUs being taken offline not to work
correctly once the CPU had been put offline.

Fixes: 5f7f0317ed28 ("IRQCHIP: Add new driver for BCM7038-style level 1 interrupt controllers")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Cc: linux-mips@linux-mips.org
Cc: jason@lakedaemon.net
Cc: marc.zyngier@arm.com
Cc: cernekee@gmail.com
Cc: jaedon.shin@gmail.com
Cc: ralf@linux-mips.org
Cc: justinpopo6@gmail.com
Link: http://lkml.kernel.org/r/1477948656-12966-2-git-send-email-f.fainelli@gmail.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/irqchip/irq-bcm7038-l1.c |   26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

--- a/drivers/irqchip/irq-bcm7038-l1.c
+++ b/drivers/irqchip/irq-bcm7038-l1.c
@@ -215,6 +215,31 @@ static int bcm7038_l1_set_affinity(struc
 	return 0;
 }
 
+static void bcm7038_l1_cpu_offline(struct irq_data *d)
+{
+	struct cpumask *mask = irq_data_get_affinity_mask(d);
+	int cpu = smp_processor_id();
+	cpumask_t new_affinity;
+
+	/* This CPU was not on the affinity mask */
+	if (!cpumask_test_cpu(cpu, mask))
+		return;
+
+	if (cpumask_weight(mask) > 1) {
+		/*
+		 * Multiple CPU affinity, remove this CPU from the affinity
+		 * mask
+		 */
+		cpumask_copy(&new_affinity, mask);
+		cpumask_clear_cpu(cpu, &new_affinity);
+	} else {
+		/* Only CPU, put on the lowest online CPU */
+		cpumask_clear(&new_affinity);
+		cpumask_set_cpu(cpumask_first(cpu_online_mask), &new_affinity);
+	}
+	irq_set_affinity_locked(d, &new_affinity, false);
+}
+
 static int __init bcm7038_l1_init_one(struct device_node *dn,
 				      unsigned int idx,
 				      struct bcm7038_l1_chip *intc)
@@ -266,6 +291,7 @@ static struct irq_chip bcm7038_l1_irq_ch
 	.irq_mask		= bcm7038_l1_mask,
 	.irq_unmask		= bcm7038_l1_unmask,
 	.irq_set_affinity	= bcm7038_l1_set_affinity,
+	.irq_cpu_offline	= bcm7038_l1_cpu_offline,
 };
 
 static int bcm7038_l1_map(struct irq_domain *d, unsigned int virq,

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 135/206] PM / wakeirq: Fix dedicated wakeirq for drivers not using autosuspend
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (117 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 134/206] irqchip/bcm7038-l1: Implement irq_cpu_offline() callback Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:36   ` [PATCH 4.9 136/206] genirq/affinity: Fix node generation from cpumask Greg Kroah-Hartman
                     ` (70 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Tony Lindgren, Rafael J. Wysocki

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Tony Lindgren <tony@atomide.com>

commit bed570307ed78f21b77cb04a1df781dee4a8f05a upstream.

I noticed some wakeirq flakeyness with consumer drivers not using
autosuspend. For drivers not using autosuspend, the wakeirq may never
get unmasked in rpm_suspend() because of irq desc->depth.

We are configuring dedicated wakeirqs to start with IRQ_NOAUTOEN as we
naturally don't want them running until rpm_suspend() is called.

However, when a consumer driver initially calls pm_runtime_get(), we
now wrongly start with disable_irq_nosync() call on the dedicated
wakeirq that is disabled to start with.

This causes desc->depth to toggle between 1 and 2 instead of the usual
0 and 1. This can prevent enable_irq() from unmasking the wakeirq as
that only happens at desc->depth 1.

This does not necessarily show up with drivers using autosuspend as
there is time for disable_irq_nosync() before rpm_suspend() gets called
after the autosuspend timeout.

Let's fix the issue by adding wirq->status that lazily gets set on
the first rpm_suspend(). We also need PM runtime core private functions
for dev_pm_enable_wake_irq_check() and dev_pm_disable_wake_irq_check()
so we can enable the dedicated wakeirq on the first rpm_suspend().

While at it, let's also fix the comments for dev_pm_enable_wake_irq()
and dev_pm_disable_wake_irq(). Those can still be used by the consumer
drivers as needed because the IRQ core manages the interrupt usecount
for us.

Fixes: 4990d4fe327b (PM / Wakeirq: Add automated device wake IRQ handling)
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/base/power/power.h   |   19 ++++++++++
 drivers/base/power/runtime.c |    8 ++--
 drivers/base/power/wakeirq.c |   76 +++++++++++++++++++++++++++++++++++++------
 3 files changed, 88 insertions(+), 15 deletions(-)

--- a/drivers/base/power/power.h
+++ b/drivers/base/power/power.h
@@ -21,14 +21,22 @@ extern void pm_runtime_init(struct devic
 extern void pm_runtime_reinit(struct device *dev);
 extern void pm_runtime_remove(struct device *dev);
 
+#define WAKE_IRQ_DEDICATED_ALLOCATED	BIT(0)
+#define WAKE_IRQ_DEDICATED_MANAGED	BIT(1)
+#define WAKE_IRQ_DEDICATED_MASK		(WAKE_IRQ_DEDICATED_ALLOCATED | \
+					 WAKE_IRQ_DEDICATED_MANAGED)
+
 struct wake_irq {
 	struct device *dev;
+	unsigned int status;
 	int irq;
-	bool dedicated_irq:1;
 };
 
 extern void dev_pm_arm_wake_irq(struct wake_irq *wirq);
 extern void dev_pm_disarm_wake_irq(struct wake_irq *wirq);
+extern void dev_pm_enable_wake_irq_check(struct device *dev,
+					 bool can_change_status);
+extern void dev_pm_disable_wake_irq_check(struct device *dev);
 
 #ifdef CONFIG_PM_SLEEP
 
@@ -104,6 +112,15 @@ static inline void dev_pm_disarm_wake_ir
 {
 }
 
+static inline void dev_pm_enable_wake_irq_check(struct device *dev,
+						bool can_change_status)
+{
+}
+
+static inline void dev_pm_disable_wake_irq_check(struct device *dev)
+{
+}
+
 #endif
 
 #ifdef CONFIG_PM_SLEEP
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -515,7 +515,7 @@ static int rpm_suspend(struct device *de
 
 	callback = RPM_GET_CALLBACK(dev, runtime_suspend);
 
-	dev_pm_enable_wake_irq(dev);
+	dev_pm_enable_wake_irq_check(dev, true);
 	retval = rpm_callback(callback, dev);
 	if (retval)
 		goto fail;
@@ -554,7 +554,7 @@ static int rpm_suspend(struct device *de
 	return retval;
 
  fail:
-	dev_pm_disable_wake_irq(dev);
+	dev_pm_disable_wake_irq_check(dev);
 	__update_runtime_status(dev, RPM_ACTIVE);
 	dev->power.deferred_resume = false;
 	wake_up_all(&dev->power.wait_queue);
@@ -737,12 +737,12 @@ static int rpm_resume(struct device *dev
 
 	callback = RPM_GET_CALLBACK(dev, runtime_resume);
 
-	dev_pm_disable_wake_irq(dev);
+	dev_pm_disable_wake_irq_check(dev);
 	retval = rpm_callback(callback, dev);
 	if (retval) {
 		__update_runtime_status(dev, RPM_SUSPENDED);
 		pm_runtime_cancel_pending(dev);
-		dev_pm_enable_wake_irq(dev);
+		dev_pm_enable_wake_irq_check(dev, false);
 	} else {
  no_callback:
 		__update_runtime_status(dev, RPM_ACTIVE);
--- a/drivers/base/power/wakeirq.c
+++ b/drivers/base/power/wakeirq.c
@@ -110,8 +110,10 @@ void dev_pm_clear_wake_irq(struct device
 	dev->power.wakeirq = NULL;
 	spin_unlock_irqrestore(&dev->power.lock, flags);
 
-	if (wirq->dedicated_irq)
+	if (wirq->status & WAKE_IRQ_DEDICATED_ALLOCATED) {
 		free_irq(wirq->irq, wirq);
+		wirq->status &= ~WAKE_IRQ_DEDICATED_MASK;
+	}
 	kfree(wirq);
 }
 EXPORT_SYMBOL_GPL(dev_pm_clear_wake_irq);
@@ -179,7 +181,6 @@ int dev_pm_set_dedicated_wake_irq(struct
 
 	wirq->dev = dev;
 	wirq->irq = irq;
-	wirq->dedicated_irq = true;
 	irq_set_status_flags(irq, IRQ_NOAUTOEN);
 
 	/*
@@ -195,6 +196,8 @@ int dev_pm_set_dedicated_wake_irq(struct
 	if (err)
 		goto err_free_irq;
 
+	wirq->status = WAKE_IRQ_DEDICATED_ALLOCATED;
+
 	return err;
 
 err_free_irq:
@@ -210,9 +213,9 @@ EXPORT_SYMBOL_GPL(dev_pm_set_dedicated_w
  * dev_pm_enable_wake_irq - Enable device wake-up interrupt
  * @dev: Device
  *
- * Called from the bus code or the device driver for
- * runtime_suspend() to enable the wake-up interrupt while
- * the device is running.
+ * Optionally called from the bus code or the device driver for
+ * runtime_resume() to override the PM runtime core managed wake-up
+ * interrupt handling to enable the wake-up interrupt.
  *
  * Note that for runtime_suspend()) the wake-up interrupts
  * should be unconditionally enabled unlike for suspend()
@@ -222,7 +225,7 @@ void dev_pm_enable_wake_irq(struct devic
 {
 	struct wake_irq *wirq = dev->power.wakeirq;
 
-	if (wirq && wirq->dedicated_irq)
+	if (wirq && (wirq->status & WAKE_IRQ_DEDICATED_ALLOCATED))
 		enable_irq(wirq->irq);
 }
 EXPORT_SYMBOL_GPL(dev_pm_enable_wake_irq);
@@ -231,20 +234,73 @@ EXPORT_SYMBOL_GPL(dev_pm_enable_wake_irq
  * dev_pm_disable_wake_irq - Disable device wake-up interrupt
  * @dev: Device
  *
- * Called from the bus code or the device driver for
- * runtime_resume() to disable the wake-up interrupt while
- * the device is running.
+ * Optionally called from the bus code or the device driver for
+ * runtime_suspend() to override the PM runtime core managed wake-up
+ * interrupt handling to disable the wake-up interrupt.
  */
 void dev_pm_disable_wake_irq(struct device *dev)
 {
 	struct wake_irq *wirq = dev->power.wakeirq;
 
-	if (wirq && wirq->dedicated_irq)
+	if (wirq && (wirq->status & WAKE_IRQ_DEDICATED_ALLOCATED))
 		disable_irq_nosync(wirq->irq);
 }
 EXPORT_SYMBOL_GPL(dev_pm_disable_wake_irq);
 
 /**
+ * dev_pm_enable_wake_irq_check - Checks and enables wake-up interrupt
+ * @dev: Device
+ * @can_change_status: Can change wake-up interrupt status
+ *
+ * Enables wakeirq conditionally. We need to enable wake-up interrupt
+ * lazily on the first rpm_suspend(). This is needed as the consumer device
+ * starts in RPM_SUSPENDED state, and the the first pm_runtime_get() would
+ * otherwise try to disable already disabled wakeirq. The wake-up interrupt
+ * starts disabled with IRQ_NOAUTOEN set.
+ *
+ * Should be only called from rpm_suspend() and rpm_resume() path.
+ * Caller must hold &dev->power.lock to change wirq->status
+ */
+void dev_pm_enable_wake_irq_check(struct device *dev,
+				  bool can_change_status)
+{
+	struct wake_irq *wirq = dev->power.wakeirq;
+
+	if (!wirq || !((wirq->status & WAKE_IRQ_DEDICATED_MASK)))
+		return;
+
+	if (likely(wirq->status & WAKE_IRQ_DEDICATED_MANAGED)) {
+		goto enable;
+	} else if (can_change_status) {
+		wirq->status |= WAKE_IRQ_DEDICATED_MANAGED;
+		goto enable;
+	}
+
+	return;
+
+enable:
+	enable_irq(wirq->irq);
+}
+
+/**
+ * dev_pm_disable_wake_irq_check - Checks and disables wake-up interrupt
+ * @dev: Device
+ *
+ * Disables wake-up interrupt conditionally based on status.
+ * Should be only called from rpm_suspend() and rpm_resume() path.
+ */
+void dev_pm_disable_wake_irq_check(struct device *dev)
+{
+	struct wake_irq *wirq = dev->power.wakeirq;
+
+	if (!wirq || !((wirq->status & WAKE_IRQ_DEDICATED_MASK)))
+		return;
+
+	if (wirq->status & WAKE_IRQ_DEDICATED_MANAGED)
+		disable_irq_nosync(wirq->irq);
+}
+
+/**
  * dev_pm_arm_wake_irq - Arm device wake-up
  * @wirq: Device wake-up interrupt
  *

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 136/206] genirq/affinity: Fix node generation from cpumask
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (118 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 135/206] PM / wakeirq: Fix dedicated wakeirq for drivers not using autosuspend Greg Kroah-Hartman
@ 2017-01-10 13:36   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 137/206] mmc: mmc_test: Uninitialized return value Greg Kroah-Hartman
                     ` (69 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:36 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Gabriel Krisman Bertazi,
	Guilherme G. Piccoli, Christoph Hellwig, Gavin Shan, linux-pci,
	linuxppc-dev, Thomas Gleixner

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>

commit c0af52437254fda8b0cdbaae5a9b6d9327f1fcd5 upstream.

Commit 34c3d9819fda ("genirq/affinity: Provide smarter irq spreading
infrastructure") introduced a better IRQ spreading mechanism, taking
account of the available NUMA nodes in the machine.

Problem is that the algorithm of retrieving the nodemask iterates
"linearly" based on the number of online nodes - some architectures
present non-linear node distribution among the nodemask, like PowerPC.
If this is the case, the algorithm lead to a wrong node count number
and therefore to a bad/incomplete IRQ affinity distribution.

For example, this problem were found in a machine with 128 CPUs and two
nodes, namely nodes 0 and 8 (instead of 0 and 1, if it was linearly
distributed). This led to a wrong affinity distribution which then led to
a bad mq allocation for nvme driver.

Finally, we take the opportunity to fix a comment regarding the affinity
distribution when we have _more_ nodes than vectors.

Fixes: 34c3d9819fda ("genirq/affinity: Provide smarter irq spreading infrastructure")
Reported-by: Gabriel Krisman Bertazi <gabriel@krisman.be>
Signed-off-by: Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Gabriel Krisman Bertazi <gabriel@krisman.be>
Reviewed-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Cc: linux-pci@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: hch@lst.de
Link: http://lkml.kernel.org/r/1481738472-2671-1-git-send-email-gpiccoli@linux.vnet.ibm.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 kernel/irq/affinity.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- a/kernel/irq/affinity.c
+++ b/kernel/irq/affinity.c
@@ -37,10 +37,10 @@ static void irq_spread_init_one(struct c
 
 static int get_nodes_in_cpumask(const struct cpumask *mask, nodemask_t *nodemsk)
 {
-	int n, nodes;
+	int n, nodes = 0;
 
 	/* Calculate the number of nodes in the supplied affinity mask */
-	for (n = 0, nodes = 0; n < num_online_nodes(); n++) {
+	for_each_online_node(n) {
 		if (cpumask_intersects(mask, cpumask_of_node(n))) {
 			node_set(n, *nodemsk);
 			nodes++;
@@ -81,7 +81,7 @@ struct cpumask *irq_create_affinity_mask
 	nodes = get_nodes_in_cpumask(affinity, &nodemsk);
 
 	/*
-	 * If the number of nodes in the mask is less than or equal the
+	 * If the number of nodes in the mask is greater than or equal the
 	 * number of vectors we just spread the vectors across the nodes.
 	 */
 	if (nvec <= nodes) {

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 137/206] mmc: mmc_test: Uninitialized return value
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (119 preceding siblings ...)
  2017-01-10 13:36   ` [PATCH 4.9 136/206] genirq/affinity: Fix node generation from cpumask Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 138/206] rpmsg: qcom_smd: Correct return value for O_NONBLOCK Greg Kroah-Hartman
                     ` (68 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Dan Carpenter, Ulf Hansson

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Dan Carpenter <dan.carpenter@oracle.com>

commit 16652a936e96f5dae53c3fbd38a570497baadaa8 upstream.

We never set "ret" to RESULT_OK.

Fixes: 9f9c4180f88d ("mmc: mmc_test: add test for non-blocking transfers")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/mmc/card/mmc_test.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/mmc/card/mmc_test.c
+++ b/drivers/mmc/card/mmc_test.c
@@ -818,7 +818,7 @@ static int mmc_test_nonblock_transfer(st
 	struct mmc_async_req *cur_areq = &test_areq[0].areq;
 	struct mmc_async_req *other_areq = &test_areq[1].areq;
 	int i;
-	int ret;
+	int ret = RESULT_OK;
 
 	test_areq[0].test = test;
 	test_areq[1].test = test;

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 138/206] rpmsg: qcom_smd: Correct return value for O_NONBLOCK
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (120 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 137/206] mmc: mmc_test: Uninitialized return value Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 139/206] mm/hugetlb.c: use the right pte val for compare in hugetlb_cow Greg Kroah-Hartman
                     ` (67 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Bjorn Andersson

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Bjorn Andersson <bjorn.andersson@linaro.org>

commit 1d74e7ed5dc1903ac081574a9b6aa94e7ba4ad45 upstream.

qcom_smd_send() should return -EAGAIN for non-blocking channels with
insufficient space, so that we can propagate this event to user space.

Fixes: 53e2822e56c7 ("rpmsg: Introduce Qualcomm SMD backend")
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/rpmsg/qcom_smd.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/rpmsg/qcom_smd.c
+++ b/drivers/rpmsg/qcom_smd.c
@@ -739,7 +739,7 @@ static int __qcom_smd_send(struct qcom_s
 
 	while (qcom_smd_get_tx_avail(channel) < tlen) {
 		if (!wait) {
-			ret = -ENOMEM;
+			ret = -EAGAIN;
 			goto out;
 		}
 

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 139/206] mm/hugetlb.c: use the right pte val for compare in hugetlb_cow
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (121 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 138/206] rpmsg: qcom_smd: Correct return value for O_NONBLOCK Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 140/206] docs-rst: fix LaTeX \DURole renewcommand with Sphinx 1.3+ Greg Kroah-Hartman
                     ` (66 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Aneesh Kumar K.V, Jan Stancek,
	Hillf Danton, Mike Kravetz, Scott Wood, Michael Ellerman,
	Kirill A. Shutemov, Andrew Morton, Linus Torvalds

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>

commit 3999f52e3198e76607446ab1a4610c1ddc406c56 upstream.

We cannot use the pte value used in set_pte_at for pte_same comparison,
because archs like ppc64, filter/add new pte flag in set_pte_at.
Instead fetch the pte value inside hugetlb_cow.  We are comparing pte
value to make sure the pte didn't change since we dropped the page table
lock.  hugetlb_cow get called with page table lock held, and we can take
a copy of the pte value before we drop the page table lock.

With hugetlbfs, we optimize the MAP_PRIVATE write fault path with no
previous mapping (huge_pte_none entries), by forcing a cow in the fault
path.  This avoid take an addition fault to covert a read-only mapping
to read/write.  Here we were comparing a recently instantiated pte (via
set_pte_at) to the pte values from linux page table.  As explained above
on ppc64 such pte_same check returned wrong result, resulting in us
taking an additional fault on ppc64.

Fixes: 6a119eae942c ("powerpc/mm: Add a _PAGE_PTE bit")
Link: http://lkml.kernel.org/r/20161018154245.18023-1-aneesh.kumar@linux.vnet.ibm.com
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Reported-by: Jan Stancek <jstancek@redhat.com>
Acked-by: Hillf Danton <hillf.zj@alibaba-inc.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Scott Wood <scottwood@freescale.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 mm/hugetlb.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -3450,15 +3450,17 @@ static void unmap_ref_private(struct mm_
  * Keep the pte_same checks anyway to make transition from the mutex easier.
  */
 static int hugetlb_cow(struct mm_struct *mm, struct vm_area_struct *vma,
-			unsigned long address, pte_t *ptep, pte_t pte,
-			struct page *pagecache_page, spinlock_t *ptl)
+		       unsigned long address, pte_t *ptep,
+		       struct page *pagecache_page, spinlock_t *ptl)
 {
+	pte_t pte;
 	struct hstate *h = hstate_vma(vma);
 	struct page *old_page, *new_page;
 	int ret = 0, outside_reserve = 0;
 	unsigned long mmun_start;	/* For mmu_notifiers */
 	unsigned long mmun_end;		/* For mmu_notifiers */
 
+	pte = huge_ptep_get(ptep);
 	old_page = pte_page(pte);
 
 retry_avoidcopy:
@@ -3733,7 +3735,7 @@ retry:
 	hugetlb_count_add(pages_per_huge_page(h), mm);
 	if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
 		/* Optimization, do the COW without a second fault */
-		ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page, ptl);
+		ret = hugetlb_cow(mm, vma, address, ptep, page, ptl);
 	}
 
 	spin_unlock(ptl);
@@ -3888,8 +3890,8 @@ int hugetlb_fault(struct mm_struct *mm,
 
 	if (flags & FAULT_FLAG_WRITE) {
 		if (!huge_pte_write(entry)) {
-			ret = hugetlb_cow(mm, vma, address, ptep, entry,
-					pagecache_page, ptl);
+			ret = hugetlb_cow(mm, vma, address, ptep,
+					  pagecache_page, ptl);
 			goto out_put_page;
 		}
 		entry = huge_pte_mkdirty(entry);

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 140/206] docs-rst: fix LaTeX \DURole renewcommand with Sphinx 1.3+
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (122 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 139/206] mm/hugetlb.c: use the right pte val for compare in hugetlb_cow Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 141/206] mm: khugepaged: close use-after-free race during shmem collapsing Greg Kroah-Hartman
                     ` (65 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Mauro Carvalho Chehab, Jonathan Corbet

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

commit e2a91f4f42018994d7424d405900d17eba6555d0 upstream.

PDF build on Kernel 4.9-rc? returns an error with Sphinx 1.3.x
and Sphinx 1.4.x, when trying to solve some cross-references.

The solution is to redefine the \DURole macro.

However, this is redefined too late. Move such redefinition to
LaTeX preamble and bind it to just the Sphinx versions where the
error is known to be present.

Tested by building the documentation on interactive mode:
	make PDFLATEX=xelatex -C Documentation/output/./latex

Fixes: e61a39baf74d ("[media] index.rst: Fix LaTeX error in interactive mode on Sphinx 1.4.x")
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 Documentation/conf.py         |    6 +++++-
 Documentation/media/index.rst |    5 -----
 2 files changed, 5 insertions(+), 6 deletions(-)

--- a/Documentation/conf.py
+++ b/Documentation/conf.py
@@ -37,7 +37,7 @@ from load_config import loadConfig
 extensions = ['kernel-doc', 'rstFlatTable', 'kernel_include', 'cdomain']
 
 # The name of the math extension changed on Sphinx 1.4
-if minor > 3:
+if major == 1 and minor > 3:
     extensions.append("sphinx.ext.imgmath")
 else:
     extensions.append("sphinx.ext.pngmath")
@@ -332,6 +332,10 @@ latex_elements = {
      '''
 }
 
+# Fix reference escape troubles with Sphinx 1.4.x
+if major == 1 and minor > 3:
+    latex_elements['preamble']  += '\\renewcommand*{\\DUrole}[2]{ #2 }\n'
+
 # Grouping the document tree into LaTeX files. List of tuples
 # (source start file, target name, title,
 #  author, documentclass [howto, manual, or own class]).
--- a/Documentation/media/index.rst
+++ b/Documentation/media/index.rst
@@ -1,11 +1,6 @@
 Linux Media Subsystem Documentation
 ===================================
 
-.. Sphinx 1.4.x has a definition for DUrole that doesn't work on alltt blocks
-.. raw:: latex
-
-	\renewcommand*{\DUrole}[2]{ #2 }
-
 Contents:
 
 .. toctree::

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 141/206] mm: khugepaged: close use-after-free race during shmem collapsing
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (123 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 140/206] docs-rst: fix LaTeX \DURole renewcommand with Sphinx 1.3+ Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 142/206] mm: khugepaged: fix radix tree node leak in shmem collapse error path Greg Kroah-Hartman
                     ` (64 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Johannes Weiner, Kirill A. Shutemov,
	Jan Kara, Hugh Dickins, Matthew Wilcox, Andrew Morton,
	Linus Torvalds

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Johannes Weiner <hannes@cmpxchg.org>

commit 91a45f71078a6569ec3ca5bef74e1ab58121d80e upstream.

Patch series "mm: workingset: radix tree subtleties & single-page file
refaults", v3.

This is another revision of the radix tree / workingset patches based on
feedback from Jan and Kirill.

This is a follow-up to d3798ae8c6f3 ("mm: filemap: don't plant shadow
entries without radix tree node").  That patch fixed an issue that was
caused mainly by the page cache sneaking special shadow page entries
into the radix tree and relying on subtleties in the radix tree code to
make that work.  The fix also had to stop tracking refaults for
single-page files because shadow pages stored as direct pointers in
radix_tree_root->rnode weren't properly handled during tree extension.

These patches make the radix tree code explicitely support and track
such special entries, to eliminate the subtleties and to restore the
thrash detection for single-page files.

This patch (of 9):

When a radix tree iteration drops the tree lock, another thread might
swoop in and free the node holding the current slot.  The iteration
needs to do another tree lookup from the current index to continue.

[kirill.shutemov@linux.intel.com: re-lookup for replacement]
Fixes: f3f0e1d2150b ("khugepaged: add support of collapse for tmpfs/shmem pages")
Link: http://lkml.kernel.org/r/20161117191138.22769-2-hannes@cmpxchg.org
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Cc: Hugh Dickins <hughd@google.com>
Cc: Matthew Wilcox <mawilcox@linuxonhyperv.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 mm/khugepaged.c |    5 +++++
 1 file changed, 5 insertions(+)

--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -1403,6 +1403,9 @@ static void collapse_shmem(struct mm_str
 
 		spin_lock_irq(&mapping->tree_lock);
 
+		slot = radix_tree_lookup_slot(&mapping->page_tree, index);
+		VM_BUG_ON_PAGE(page != radix_tree_deref_slot_protected(slot,
+					&mapping->tree_lock), page);
 		VM_BUG_ON_PAGE(page_mapped(page), page);
 
 		/*
@@ -1426,6 +1429,7 @@ static void collapse_shmem(struct mm_str
 		radix_tree_replace_slot(slot,
 				new_page + (index % HPAGE_PMD_NR));
 
+		slot = radix_tree_iter_next(&iter);
 		index++;
 		continue;
 out_lru:
@@ -1537,6 +1541,7 @@ tree_unlocked:
 			putback_lru_page(page);
 			unlock_page(page);
 			spin_lock_irq(&mapping->tree_lock);
+			slot = radix_tree_iter_next(&iter);
 		}
 		VM_BUG_ON(nr_none);
 		spin_unlock_irq(&mapping->tree_lock);

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 142/206] mm: khugepaged: fix radix tree node leak in shmem collapse error path
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (124 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 141/206] mm: khugepaged: close use-after-free race during shmem collapsing Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 143/206] mm, compaction: fix NR_ISOLATED_* stats for pfn based migration Greg Kroah-Hartman
                     ` (63 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Johannes Weiner, Jan Kara,
	Kirill A. Shutemov, Hugh Dickins, Matthew Wilcox, Andrew Morton,
	Linus Torvalds

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Johannes Weiner <hannes@cmpxchg.org>

commit 59749e6ce53735d8b696763742225f126e94603f upstream.

The radix tree counts valid entries in each tree node.  Entries stored
in the tree cannot be removed by simpling storing NULL in the slot or
the internal counters will be off and the node never gets freed again.

When collapsing a shmem page fails, restore the holes that were filled
with radix_tree_insert() with a proper radix tree deletion.

Fixes: f3f0e1d2150b ("khugepaged: add support of collapse for tmpfs/shmem pages")
Link: http://lkml.kernel.org/r/20161117191138.22769-3-hannes@cmpxchg.org
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Reported-by: Jan Kara <jack@suse.cz>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Cc: Hugh Dickins <hughd@google.com>
Cc: Matthew Wilcox <mawilcox@linuxonhyperv.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 mm/khugepaged.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -1525,9 +1525,11 @@ tree_unlocked:
 			if (!page || iter.index < page->index) {
 				if (!nr_none)
 					break;
-				/* Put holes back where they were */
-				radix_tree_replace_slot(slot, NULL);
 				nr_none--;
+				/* Put holes back where they were */
+				radix_tree_delete(&mapping->page_tree,
+						  iter.index);
+				slot = radix_tree_iter_next(&iter);
 				continue;
 			}
 

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 143/206] mm, compaction: fix NR_ISOLATED_* stats for pfn based migration
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (125 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 142/206] mm: khugepaged: fix radix tree node leak in shmem collapse error path Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 144/206] s390/crypto: unlock on error in prng_tdes_read() Greg Kroah-Hartman
                     ` (62 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Ming Ling, Michal Hocko, Minchan Kim,
	Vlastimil Babka, Mel Gorman, Joonsoo Kim, Andrew Morton,
	Linus Torvalds

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Ming Ling <ming.ling@spreadtrum.com>

commit 6afcf8ef0ca0a69d014f8edb613d94821f0ae700 upstream.

Since commit bda807d44454 ("mm: migrate: support non-lru movable page
migration") isolate_migratepages_block) can isolate !PageLRU pages which
would acct_isolated account as NR_ISOLATED_*.  Accounting these non-lru
pages NR_ISOLATED_{ANON,FILE} doesn't make any sense and it can misguide
heuristics based on those counters such as pgdat_reclaimable_pages resp.
too_many_isolated which would lead to unexpected stalls during the
direct reclaim without any good reason.  Note that
__alloc_contig_migrate_range can isolate a lot of pages at once.

On mobile devices such as 512M ram android Phone, it may use a big zram
swap.  In some cases zram(zsmalloc) uses too many non-lru but
migratedable pages, such as:

      MemTotal: 468148 kB
      Normal free:5620kB
      Free swap:4736kB
      Total swap:409596kB
      ZRAM: 164616kB(zsmalloc non-lru pages)
      active_anon:60700kB
      inactive_anon:60744kB
      active_file:34420kB
      inactive_file:37532kB

Fix this by only accounting lru pages to NR_ISOLATED_* in
isolate_migratepages_block right after they were isolated and we still
know they were on LRU.  Drop acct_isolated because it is called after
the fact and we've lost that information.  Batching per-cpu counter
doesn't make much improvement anyway.  Also make sure that we uncharge
only LRU pages when putting them back on the LRU in
putback_movable_pages resp.  when unmap_and_move migrates the page.

[mhocko@suse.com: replace acct_isolated() with direct counting]
Fixes: bda807d44454 ("mm: migrate: support non-lru movable page migration")
Link: http://lkml.kernel.org/r/20161019080240.9682-1-mhocko@kernel.org
Signed-off-by: Ming Ling <ming.ling@spreadtrum.com>
Signed-off-by: Michal Hocko <mhocko@suse.com>
Acked-by: Minchan Kim <minchan@kernel.org>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Joonsoo Kim <js1304@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 mm/compaction.c |   25 +++----------------------
 mm/migrate.c    |   15 +++++++++++----
 2 files changed, 14 insertions(+), 26 deletions(-)

--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -634,22 +634,6 @@ isolate_freepages_range(struct compact_c
 	return pfn;
 }
 
-/* Update the number of anon and file isolated pages in the zone */
-static void acct_isolated(struct zone *zone, struct compact_control *cc)
-{
-	struct page *page;
-	unsigned int count[2] = { 0, };
-
-	if (list_empty(&cc->migratepages))
-		return;
-
-	list_for_each_entry(page, &cc->migratepages, lru)
-		count[!!page_is_file_cache(page)]++;
-
-	mod_node_page_state(zone->zone_pgdat, NR_ISOLATED_ANON, count[0]);
-	mod_node_page_state(zone->zone_pgdat, NR_ISOLATED_FILE, count[1]);
-}
-
 /* Similar to reclaim, but different enough that they don't share logic */
 static bool too_many_isolated(struct zone *zone)
 {
@@ -866,6 +850,8 @@ isolate_migratepages_block(struct compac
 
 		/* Successfully isolated */
 		del_page_from_lru_list(page, lruvec, page_lru(page));
+		inc_node_page_state(page,
+				NR_ISOLATED_ANON + page_is_file_cache(page));
 
 isolate_success:
 		list_add(&page->lru, &cc->migratepages);
@@ -902,7 +888,6 @@ isolate_fail:
 				spin_unlock_irqrestore(zone_lru_lock(zone), flags);
 				locked = false;
 			}
-			acct_isolated(zone, cc);
 			putback_movable_pages(&cc->migratepages);
 			cc->nr_migratepages = 0;
 			cc->last_migrated_pfn = 0;
@@ -988,7 +973,6 @@ isolate_migratepages_range(struct compac
 		if (cc->nr_migratepages == COMPACT_CLUSTER_MAX)
 			break;
 	}
-	acct_isolated(cc->zone, cc);
 
 	return pfn;
 }
@@ -1258,10 +1242,8 @@ static isolate_migrate_t isolate_migrate
 		low_pfn = isolate_migratepages_block(cc, low_pfn,
 						block_end_pfn, isolate_mode);
 
-		if (!low_pfn || cc->contended) {
-			acct_isolated(zone, cc);
+		if (!low_pfn || cc->contended)
 			return ISOLATE_ABORT;
-		}
 
 		/*
 		 * Either we isolated something and proceed with migration. Or
@@ -1271,7 +1253,6 @@ static isolate_migrate_t isolate_migrate
 		break;
 	}
 
-	acct_isolated(zone, cc);
 	/* Record where migration scanner will be restarted. */
 	cc->migrate_pfn = low_pfn;
 
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -168,8 +168,6 @@ void putback_movable_pages(struct list_h
 			continue;
 		}
 		list_del(&page->lru);
-		dec_node_page_state(page, NR_ISOLATED_ANON +
-				page_is_file_cache(page));
 		/*
 		 * We isolated non-lru movable page so here we can use
 		 * __PageMovable because LRU page's mapping cannot have
@@ -186,6 +184,8 @@ void putback_movable_pages(struct list_h
 			put_page(page);
 		} else {
 			putback_lru_page(page);
+			dec_node_page_state(page, NR_ISOLATED_ANON +
+					page_is_file_cache(page));
 		}
 	}
 }
@@ -1121,8 +1121,15 @@ out:
 		 * restored.
 		 */
 		list_del(&page->lru);
-		dec_node_page_state(page, NR_ISOLATED_ANON +
-				page_is_file_cache(page));
+
+		/*
+		 * Compaction can migrate also non-LRU pages which are
+		 * not accounted to NR_ISOLATED_*. They can be recognized
+		 * as __PageMovable
+		 */
+		if (likely(!__PageMovable(page)))
+			dec_node_page_state(page, NR_ISOLATED_ANON +
+					page_is_file_cache(page));
 	}
 
 	/*

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 144/206] s390/crypto: unlock on error in prng_tdes_read()
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (126 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 143/206] mm, compaction: fix NR_ISOLATED_* stats for pfn based migration Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 145/206] crypto: arm64/sha2-ce - fix for big endian Greg Kroah-Hartman
                     ` (61 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Dan Carpenter, Martin Schwidefsky

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Dan Carpenter <dan.carpenter@oracle.com>

commit 9e6e7c74315095fd40f41003850690c711e44420 upstream.

We added some new locking but forgot to unlock on error.

Fixes: 57127645d79d ("s390/zcrypt: Introduce new SHA-512 based Pseudo Random Generator.")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/s390/crypto/prng.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

--- a/arch/s390/crypto/prng.c
+++ b/arch/s390/crypto/prng.c
@@ -507,8 +507,10 @@ static ssize_t prng_tdes_read(struct fil
 		prng_data->prngws.byte_counter += n;
 		prng_data->prngws.reseed_counter += n;
 
-		if (copy_to_user(ubuf, prng_data->buf, chunk))
-			return -EFAULT;
+		if (copy_to_user(ubuf, prng_data->buf, chunk)) {
+			ret = -EFAULT;
+			break;
+		}
 
 		nbytes -= chunk;
 		ret += chunk;

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 145/206] crypto: arm64/sha2-ce - fix for big endian
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (127 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 144/206] s390/crypto: unlock on error in prng_tdes_read() Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 146/206] crypto: arm64/ghash-ce " Greg Kroah-Hartman
                     ` (60 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Ard Biesheuvel, Herbert Xu

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Ard Biesheuvel <ard.biesheuvel@linaro.org>

commit 174122c39c369ed924d2608fc0be0171997ce800 upstream.

The SHA256 digest is an array of 8 32-bit quantities, so we should refer
to them as such in order for this code to work correctly when built for
big endian. So replace 16 byte scalar loads and stores with 4x32 vector
ones where appropriate.

Fixes: 6ba6c74dfc6b ("arm64/crypto: SHA-224/SHA-256 using ARMv8 Crypto Extensions")
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/arm64/crypto/sha2-ce-core.S |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/arch/arm64/crypto/sha2-ce-core.S
+++ b/arch/arm64/crypto/sha2-ce-core.S
@@ -85,7 +85,7 @@ ENTRY(sha2_ce_transform)
 	ld1		{v12.4s-v15.4s}, [x8]
 
 	/* load state */
-	ldp		dga, dgb, [x0]
+	ld1		{dgav.4s, dgbv.4s}, [x0]
 
 	/* load sha256_ce_state::finalize */
 	ldr		w4, [x0, #:lo12:sha256_ce_offsetof_finalize]
@@ -148,6 +148,6 @@ CPU_LE(	rev32		v19.16b, v19.16b	)
 	b		1b
 
 	/* store new state */
-3:	stp		dga, dgb, [x0]
+3:	st1		{dgav.4s, dgbv.4s}, [x0]
 	ret
 ENDPROC(sha2_ce_transform)

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 146/206] crypto: arm64/ghash-ce - fix for big endian
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (128 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 145/206] crypto: arm64/sha2-ce - fix for big endian Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 147/206] crypto: arm/aes-ce " Greg Kroah-Hartman
                     ` (59 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Ard Biesheuvel, Herbert Xu

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Ard Biesheuvel <ard.biesheuvel@linaro.org>

commit 9c433ad5083fd4a4a3c721d86cbfbd0b2a2326a5 upstream.

The GHASH key and digest are both pairs of 64-bit quantities, but the
GHASH code does not always refer to them as such, causing failures when
built for big endian. So replace the 16x1 loads and stores with 2x8 ones.

Fixes: b913a6404ce2 ("arm64/crypto: improve performance of GHASH algorithm")
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/arm64/crypto/ghash-ce-core.S |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- a/arch/arm64/crypto/ghash-ce-core.S
+++ b/arch/arm64/crypto/ghash-ce-core.S
@@ -29,8 +29,8 @@
 	 *			   struct ghash_key const *k, const char *head)
 	 */
 ENTRY(pmull_ghash_update)
-	ld1		{SHASH.16b}, [x3]
-	ld1		{XL.16b}, [x1]
+	ld1		{SHASH.2d}, [x3]
+	ld1		{XL.2d}, [x1]
 	movi		MASK.16b, #0xe1
 	ext		SHASH2.16b, SHASH.16b, SHASH.16b, #8
 	shl		MASK.2d, MASK.2d, #57
@@ -74,6 +74,6 @@ CPU_LE(	rev64		T1.16b, T1.16b	)
 
 	cbnz		w0, 0b
 
-	st1		{XL.16b}, [x1]
+	st1		{XL.2d}, [x1]
 	ret
 ENDPROC(pmull_ghash_update)

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 147/206] crypto: arm/aes-ce - fix for big endian
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (129 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 146/206] crypto: arm64/ghash-ce " Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 148/206] crypto: arm64/aes-ccm-ce: " Greg Kroah-Hartman
                     ` (58 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Ard Biesheuvel, Herbert Xu

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Ard Biesheuvel <ard.biesheuvel@linaro.org>

commit 58010fa6f71c9577922b22e46014b95a4ec80fa0 upstream.

The AES key schedule generation is mostly endian agnostic, with the
exception of the rotation and the incorporation of the round constant
at the start of each round. So implement a big endian specific version
of that part to make the whole routine big endian compatible.

Fixes: 86464859cc77 ("crypto: arm - AES in ECB/CBC/CTR/XTS modes using ARMv8 Crypto Extensions")
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/arm/crypto/aes-ce-glue.c |    5 +++++
 1 file changed, 5 insertions(+)

--- a/arch/arm/crypto/aes-ce-glue.c
+++ b/arch/arm/crypto/aes-ce-glue.c
@@ -88,8 +88,13 @@ static int ce_aes_expandkey(struct crypt
 		u32 *rki = ctx->key_enc + (i * kwords);
 		u32 *rko = rki + kwords;
 
+#ifndef CONFIG_CPU_BIG_ENDIAN
 		rko[0] = ror32(ce_aes_sub(rki[kwords - 1]), 8);
 		rko[0] = rko[0] ^ rki[0] ^ rcon[i];
+#else
+		rko[0] = rol32(ce_aes_sub(rki[kwords - 1]), 8);
+		rko[0] = rko[0] ^ rki[0] ^ (rcon[i] << 24);
+#endif
 		rko[1] = rko[0] ^ rki[1];
 		rko[2] = rko[1] ^ rki[2];
 		rko[3] = rko[2] ^ rki[3];

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 148/206] crypto: arm64/aes-ccm-ce: fix for big endian
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (130 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 147/206] crypto: arm/aes-ce " Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 149/206] crypto: arm64/aes-neon - " Greg Kroah-Hartman
                     ` (57 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Ard Biesheuvel, Herbert Xu

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Ard Biesheuvel <ard.biesheuvel@linaro.org>

commit 56e4e76c68fcb51547b5299e5b66a135935ff414 upstream.

The AES-CCM implementation that uses ARMv8 Crypto Extensions instructions
refers to the AES round keys as pairs of 64-bit quantities, which causes
failures when building the code for big endian. In addition, it byte swaps
the input counter unconditionally, while this is only required for little
endian builds. So fix both issues.

Fixes: 12ac3efe74f8 ("arm64/crypto: use crypto instructions to generate AES key schedule")
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/arm64/crypto/aes-ce-ccm-core.S |   53 ++++++++++++++++++------------------
 1 file changed, 27 insertions(+), 26 deletions(-)

--- a/arch/arm64/crypto/aes-ce-ccm-core.S
+++ b/arch/arm64/crypto/aes-ce-ccm-core.S
@@ -9,6 +9,7 @@
  */
 
 #include <linux/linkage.h>
+#include <asm/assembler.h>
 
 	.text
 	.arch	armv8-a+crypto
@@ -19,7 +20,7 @@
 	 */
 ENTRY(ce_aes_ccm_auth_data)
 	ldr	w8, [x3]			/* leftover from prev round? */
-	ld1	{v0.2d}, [x0]			/* load mac */
+	ld1	{v0.16b}, [x0]			/* load mac */
 	cbz	w8, 1f
 	sub	w8, w8, #16
 	eor	v1.16b, v1.16b, v1.16b
@@ -31,7 +32,7 @@ ENTRY(ce_aes_ccm_auth_data)
 	beq	8f				/* out of input? */
 	cbnz	w8, 0b
 	eor	v0.16b, v0.16b, v1.16b
-1:	ld1	{v3.2d}, [x4]			/* load first round key */
+1:	ld1	{v3.16b}, [x4]			/* load first round key */
 	prfm	pldl1strm, [x1]
 	cmp	w5, #12				/* which key size? */
 	add	x6, x4, #16
@@ -41,17 +42,17 @@ ENTRY(ce_aes_ccm_auth_data)
 	mov	v5.16b, v3.16b
 	b	4f
 2:	mov	v4.16b, v3.16b
-	ld1	{v5.2d}, [x6], #16		/* load 2nd round key */
+	ld1	{v5.16b}, [x6], #16		/* load 2nd round key */
 3:	aese	v0.16b, v4.16b
 	aesmc	v0.16b, v0.16b
-4:	ld1	{v3.2d}, [x6], #16		/* load next round key */
+4:	ld1	{v3.16b}, [x6], #16		/* load next round key */
 	aese	v0.16b, v5.16b
 	aesmc	v0.16b, v0.16b
-5:	ld1	{v4.2d}, [x6], #16		/* load next round key */
+5:	ld1	{v4.16b}, [x6], #16		/* load next round key */
 	subs	w7, w7, #3
 	aese	v0.16b, v3.16b
 	aesmc	v0.16b, v0.16b
-	ld1	{v5.2d}, [x6], #16		/* load next round key */
+	ld1	{v5.16b}, [x6], #16		/* load next round key */
 	bpl	3b
 	aese	v0.16b, v4.16b
 	subs	w2, w2, #16			/* last data? */
@@ -60,7 +61,7 @@ ENTRY(ce_aes_ccm_auth_data)
 	ld1	{v1.16b}, [x1], #16		/* load next input block */
 	eor	v0.16b, v0.16b, v1.16b		/* xor with mac */
 	bne	1b
-6:	st1	{v0.2d}, [x0]			/* store mac */
+6:	st1	{v0.16b}, [x0]			/* store mac */
 	beq	10f
 	adds	w2, w2, #16
 	beq	10f
@@ -79,7 +80,7 @@ ENTRY(ce_aes_ccm_auth_data)
 	adds	w7, w7, #1
 	bne	9b
 	eor	v0.16b, v0.16b, v1.16b
-	st1	{v0.2d}, [x0]
+	st1	{v0.16b}, [x0]
 10:	str	w8, [x3]
 	ret
 ENDPROC(ce_aes_ccm_auth_data)
@@ -89,27 +90,27 @@ ENDPROC(ce_aes_ccm_auth_data)
 	 * 			 u32 rounds);
 	 */
 ENTRY(ce_aes_ccm_final)
-	ld1	{v3.2d}, [x2], #16		/* load first round key */
-	ld1	{v0.2d}, [x0]			/* load mac */
+	ld1	{v3.16b}, [x2], #16		/* load first round key */
+	ld1	{v0.16b}, [x0]			/* load mac */
 	cmp	w3, #12				/* which key size? */
 	sub	w3, w3, #2			/* modified # of rounds */
-	ld1	{v1.2d}, [x1]			/* load 1st ctriv */
+	ld1	{v1.16b}, [x1]			/* load 1st ctriv */
 	bmi	0f
 	bne	3f
 	mov	v5.16b, v3.16b
 	b	2f
 0:	mov	v4.16b, v3.16b
-1:	ld1	{v5.2d}, [x2], #16		/* load next round key */
+1:	ld1	{v5.16b}, [x2], #16		/* load next round key */
 	aese	v0.16b, v4.16b
 	aesmc	v0.16b, v0.16b
 	aese	v1.16b, v4.16b
 	aesmc	v1.16b, v1.16b
-2:	ld1	{v3.2d}, [x2], #16		/* load next round key */
+2:	ld1	{v3.16b}, [x2], #16		/* load next round key */
 	aese	v0.16b, v5.16b
 	aesmc	v0.16b, v0.16b
 	aese	v1.16b, v5.16b
 	aesmc	v1.16b, v1.16b
-3:	ld1	{v4.2d}, [x2], #16		/* load next round key */
+3:	ld1	{v4.16b}, [x2], #16		/* load next round key */
 	subs	w3, w3, #3
 	aese	v0.16b, v3.16b
 	aesmc	v0.16b, v0.16b
@@ -120,47 +121,47 @@ ENTRY(ce_aes_ccm_final)
 	aese	v1.16b, v4.16b
 	/* final round key cancels out */
 	eor	v0.16b, v0.16b, v1.16b		/* en-/decrypt the mac */
-	st1	{v0.2d}, [x0]			/* store result */
+	st1	{v0.16b}, [x0]			/* store result */
 	ret
 ENDPROC(ce_aes_ccm_final)
 
 	.macro	aes_ccm_do_crypt,enc
 	ldr	x8, [x6, #8]			/* load lower ctr */
-	ld1	{v0.2d}, [x5]			/* load mac */
-	rev	x8, x8				/* keep swabbed ctr in reg */
+	ld1	{v0.16b}, [x5]			/* load mac */
+CPU_LE(	rev	x8, x8			)	/* keep swabbed ctr in reg */
 0:	/* outer loop */
-	ld1	{v1.1d}, [x6]			/* load upper ctr */
+	ld1	{v1.8b}, [x6]			/* load upper ctr */
 	prfm	pldl1strm, [x1]
 	add	x8, x8, #1
 	rev	x9, x8
 	cmp	w4, #12				/* which key size? */
 	sub	w7, w4, #2			/* get modified # of rounds */
 	ins	v1.d[1], x9			/* no carry in lower ctr */
-	ld1	{v3.2d}, [x3]			/* load first round key */
+	ld1	{v3.16b}, [x3]			/* load first round key */
 	add	x10, x3, #16
 	bmi	1f
 	bne	4f
 	mov	v5.16b, v3.16b
 	b	3f
 1:	mov	v4.16b, v3.16b
-	ld1	{v5.2d}, [x10], #16		/* load 2nd round key */
+	ld1	{v5.16b}, [x10], #16		/* load 2nd round key */
 2:	/* inner loop: 3 rounds, 2x interleaved */
 	aese	v0.16b, v4.16b
 	aesmc	v0.16b, v0.16b
 	aese	v1.16b, v4.16b
 	aesmc	v1.16b, v1.16b
-3:	ld1	{v3.2d}, [x10], #16		/* load next round key */
+3:	ld1	{v3.16b}, [x10], #16		/* load next round key */
 	aese	v0.16b, v5.16b
 	aesmc	v0.16b, v0.16b
 	aese	v1.16b, v5.16b
 	aesmc	v1.16b, v1.16b
-4:	ld1	{v4.2d}, [x10], #16		/* load next round key */
+4:	ld1	{v4.16b}, [x10], #16		/* load next round key */
 	subs	w7, w7, #3
 	aese	v0.16b, v3.16b
 	aesmc	v0.16b, v0.16b
 	aese	v1.16b, v3.16b
 	aesmc	v1.16b, v1.16b
-	ld1	{v5.2d}, [x10], #16		/* load next round key */
+	ld1	{v5.16b}, [x10], #16		/* load next round key */
 	bpl	2b
 	aese	v0.16b, v4.16b
 	aese	v1.16b, v4.16b
@@ -177,14 +178,14 @@ ENDPROC(ce_aes_ccm_final)
 	eor	v0.16b, v0.16b, v2.16b		/* xor mac with pt ^ rk[last] */
 	st1	{v1.16b}, [x0], #16		/* write output block */
 	bne	0b
-	rev	x8, x8
-	st1	{v0.2d}, [x5]			/* store mac */
+CPU_LE(	rev	x8, x8			)
+	st1	{v0.16b}, [x5]			/* store mac */
 	str	x8, [x6, #8]			/* store lsb end of ctr (BE) */
 5:	ret
 
 6:	eor	v0.16b, v0.16b, v5.16b		/* final round mac */
 	eor	v1.16b, v1.16b, v5.16b		/* final round enc */
-	st1	{v0.2d}, [x5]			/* store mac */
+	st1	{v0.16b}, [x5]			/* store mac */
 	add	w2, w2, #16			/* process partial tail block */
 7:	ldrb	w9, [x1], #1			/* get 1 byte of input */
 	umov	w6, v1.b[0]			/* get top crypted ctr byte */

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 149/206] crypto: arm64/aes-neon - fix for big endian
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (131 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 148/206] crypto: arm64/aes-ccm-ce: " Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 150/206] crypto: arm64/sha1-ce " Greg Kroah-Hartman
                     ` (56 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Ard Biesheuvel, Herbert Xu

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Ard Biesheuvel <ard.biesheuvel@linaro.org>

commit a2c435cc99862fd3d165e1b66bf48ac72c839c62 upstream.

The AES implementation using pure NEON instructions relies on the generic
AES key schedule generation routines, which store the round keys as arrays
of 32-bit quantities stored in memory using native endianness. This means
we should refer to these round keys using 4x4 loads rather than 16x1 loads.
In addition, the ShiftRows tables are loading using a single scalar load,
which is also affected by endianness, so emit these tables in the correct
order depending on whether we are building for big endian or not.

Fixes: 49788fe2a128 ("arm64/crypto: AES-ECB/CBC/CTR/XTS using ARMv8 NEON and Crypto Extensions")
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/arm64/crypto/aes-neon.S |   25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

--- a/arch/arm64/crypto/aes-neon.S
+++ b/arch/arm64/crypto/aes-neon.S
@@ -9,6 +9,7 @@
  */
 
 #include <linux/linkage.h>
+#include <asm/assembler.h>
 
 #define AES_ENTRY(func)		ENTRY(neon_ ## func)
 #define AES_ENDPROC(func)	ENDPROC(neon_ ## func)
@@ -83,13 +84,13 @@
 	.endm
 
 	.macro		do_block, enc, in, rounds, rk, rkp, i
-	ld1		{v15.16b}, [\rk]
+	ld1		{v15.4s}, [\rk]
 	add		\rkp, \rk, #16
 	mov		\i, \rounds
 1111:	eor		\in\().16b, \in\().16b, v15.16b		/* ^round key */
 	tbl		\in\().16b, {\in\().16b}, v13.16b	/* ShiftRows */
 	sub_bytes	\in
-	ld1		{v15.16b}, [\rkp], #16
+	ld1		{v15.4s}, [\rkp], #16
 	subs		\i, \i, #1
 	beq		2222f
 	.if		\enc == 1
@@ -229,7 +230,7 @@
 	.endm
 
 	.macro		do_block_2x, enc, in0, in1 rounds, rk, rkp, i
-	ld1		{v15.16b}, [\rk]
+	ld1		{v15.4s}, [\rk]
 	add		\rkp, \rk, #16
 	mov		\i, \rounds
 1111:	eor		\in0\().16b, \in0\().16b, v15.16b	/* ^round key */
@@ -237,7 +238,7 @@
 	sub_bytes_2x	\in0, \in1
 	tbl		\in0\().16b, {\in0\().16b}, v13.16b	/* ShiftRows */
 	tbl		\in1\().16b, {\in1\().16b}, v13.16b	/* ShiftRows */
-	ld1		{v15.16b}, [\rkp], #16
+	ld1		{v15.4s}, [\rkp], #16
 	subs		\i, \i, #1
 	beq		2222f
 	.if		\enc == 1
@@ -254,7 +255,7 @@
 	.endm
 
 	.macro		do_block_4x, enc, in0, in1, in2, in3, rounds, rk, rkp, i
-	ld1		{v15.16b}, [\rk]
+	ld1		{v15.4s}, [\rk]
 	add		\rkp, \rk, #16
 	mov		\i, \rounds
 1111:	eor		\in0\().16b, \in0\().16b, v15.16b	/* ^round key */
@@ -266,7 +267,7 @@
 	tbl		\in1\().16b, {\in1\().16b}, v13.16b	/* ShiftRows */
 	tbl		\in2\().16b, {\in2\().16b}, v13.16b	/* ShiftRows */
 	tbl		\in3\().16b, {\in3\().16b}, v13.16b	/* ShiftRows */
-	ld1		{v15.16b}, [\rkp], #16
+	ld1		{v15.4s}, [\rkp], #16
 	subs		\i, \i, #1
 	beq		2222f
 	.if		\enc == 1
@@ -306,12 +307,16 @@
 	.text
 	.align		4
 .LForward_ShiftRows:
-	.byte		0x0, 0x5, 0xa, 0xf, 0x4, 0x9, 0xe, 0x3
-	.byte		0x8, 0xd, 0x2, 0x7, 0xc, 0x1, 0x6, 0xb
+CPU_LE(	.byte		0x0, 0x5, 0xa, 0xf, 0x4, 0x9, 0xe, 0x3	)
+CPU_LE(	.byte		0x8, 0xd, 0x2, 0x7, 0xc, 0x1, 0x6, 0xb	)
+CPU_BE(	.byte		0xb, 0x6, 0x1, 0xc, 0x7, 0x2, 0xd, 0x8	)
+CPU_BE(	.byte		0x3, 0xe, 0x9, 0x4, 0xf, 0xa, 0x5, 0x0	)
 
 .LReverse_ShiftRows:
-	.byte		0x0, 0xd, 0xa, 0x7, 0x4, 0x1, 0xe, 0xb
-	.byte		0x8, 0x5, 0x2, 0xf, 0xc, 0x9, 0x6, 0x3
+CPU_LE(	.byte		0x0, 0xd, 0xa, 0x7, 0x4, 0x1, 0xe, 0xb	)
+CPU_LE(	.byte		0x8, 0x5, 0x2, 0xf, 0xc, 0x9, 0x6, 0x3	)
+CPU_BE(	.byte		0x3, 0x6, 0x9, 0xc, 0xf, 0x2, 0x5, 0x8	)
+CPU_BE(	.byte		0xb, 0xe, 0x1, 0x4, 0x7, 0xa, 0xd, 0x0	)
 
 .LForward_Sbox:
 	.byte		0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 150/206] crypto: arm64/sha1-ce - fix for big endian
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (132 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 149/206] crypto: arm64/aes-neon - " Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 151/206] crypto: arm64/aes-xts-ce: " Greg Kroah-Hartman
                     ` (55 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Ard Biesheuvel, Herbert Xu

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Ard Biesheuvel <ard.biesheuvel@linaro.org>

commit ee71e5f1e7d25543ee63a80451871f8985b8d431 upstream.

The SHA1 digest is an array of 5 32-bit quantities, so we should refer
to them as such in order for this code to work correctly when built for
big endian. So replace 16 byte scalar loads and stores with 4x4 vector
ones where appropriate.

Fixes: 2c98833a42cd ("arm64/crypto: SHA-1 using ARMv8 Crypto Extensions")
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/arm64/crypto/sha1-ce-core.S |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/arch/arm64/crypto/sha1-ce-core.S
+++ b/arch/arm64/crypto/sha1-ce-core.S
@@ -78,7 +78,7 @@ ENTRY(sha1_ce_transform)
 	ld1r		{k3.4s}, [x6]
 
 	/* load state */
-	ldr		dga, [x0]
+	ld1		{dgav.4s}, [x0]
 	ldr		dgb, [x0, #16]
 
 	/* load sha1_ce_state::finalize */
@@ -144,7 +144,7 @@ CPU_LE(	rev32		v11.16b, v11.16b	)
 	b		1b
 
 	/* store new state */
-3:	str		dga, [x0]
+3:	st1		{dgav.4s}, [x0]
 	str		dgb, [x0, #16]
 	ret
 ENDPROC(sha1_ce_transform)

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 151/206] crypto: arm64/aes-xts-ce: fix for big endian
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (133 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 150/206] crypto: arm64/sha1-ce " Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 152/206] crypto: arm64/aes-ce - " Greg Kroah-Hartman
                     ` (54 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Ard Biesheuvel, Herbert Xu

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Ard Biesheuvel <ard.biesheuvel@linaro.org>

commit caf4b9e2b326cc2a5005a5c557274306536ace61 upstream.

Emit the XTS tweak literal constants in the appropriate order for a
single 128-bit scalar literal load.

Fixes: 49788fe2a128 ("arm64/crypto: AES-ECB/CBC/CTR/XTS using ARMv8 NEON and Crypto Extensions")
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/arm64/crypto/aes-ce.S    |    1 +
 arch/arm64/crypto/aes-modes.S |    3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

--- a/arch/arm64/crypto/aes-ce.S
+++ b/arch/arm64/crypto/aes-ce.S
@@ -10,6 +10,7 @@
  */
 
 #include <linux/linkage.h>
+#include <asm/assembler.h>
 
 #define AES_ENTRY(func)		ENTRY(ce_ ## func)
 #define AES_ENDPROC(func)	ENDPROC(ce_ ## func)
--- a/arch/arm64/crypto/aes-modes.S
+++ b/arch/arm64/crypto/aes-modes.S
@@ -386,7 +386,8 @@ AES_ENDPROC(aes_ctr_encrypt)
 	.endm
 
 .Lxts_mul_x:
-	.word		1, 0, 0x87, 0
+CPU_LE(	.quad		1, 0x87		)
+CPU_BE(	.quad		0x87, 1		)
 
 AES_ENTRY(aes_xts_encrypt)
 	FRAME_PUSH

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 152/206] crypto: arm64/aes-ce - fix for big endian
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (134 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 151/206] crypto: arm64/aes-xts-ce: " Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 153/206] md: MD_RECOVERY_NEEDED is set for mddev->recovery Greg Kroah-Hartman
                     ` (53 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Ard Biesheuvel, Herbert Xu

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Ard Biesheuvel <ard.biesheuvel@linaro.org>

commit 1803b9a52c4e5a5dbb8a27126f6bc06939359753 upstream.

The core AES cipher implementation that uses ARMv8 Crypto Extensions
instructions erroneously loads the round keys as 64-bit quantities,
which causes the algorithm to fail when built for big endian. In
addition, the key schedule generation routine fails to take endianness
into account as well, when loading the combining the input key with
the round constants. So fix both issues.

Fixes: 12ac3efe74f8 ("arm64/crypto: use crypto instructions to generate AES key schedule")
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/arm64/crypto/aes-ce-cipher.c |   25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

--- a/arch/arm64/crypto/aes-ce-cipher.c
+++ b/arch/arm64/crypto/aes-ce-cipher.c
@@ -47,24 +47,24 @@ static void aes_cipher_encrypt(struct cr
 	kernel_neon_begin_partial(4);
 
 	__asm__("	ld1	{v0.16b}, %[in]			;"
-		"	ld1	{v1.2d}, [%[key]], #16		;"
+		"	ld1	{v1.16b}, [%[key]], #16		;"
 		"	cmp	%w[rounds], #10			;"
 		"	bmi	0f				;"
 		"	bne	3f				;"
 		"	mov	v3.16b, v1.16b			;"
 		"	b	2f				;"
 		"0:	mov	v2.16b, v1.16b			;"
-		"	ld1	{v3.2d}, [%[key]], #16		;"
+		"	ld1	{v3.16b}, [%[key]], #16		;"
 		"1:	aese	v0.16b, v2.16b			;"
 		"	aesmc	v0.16b, v0.16b			;"
-		"2:	ld1	{v1.2d}, [%[key]], #16		;"
+		"2:	ld1	{v1.16b}, [%[key]], #16		;"
 		"	aese	v0.16b, v3.16b			;"
 		"	aesmc	v0.16b, v0.16b			;"
-		"3:	ld1	{v2.2d}, [%[key]], #16		;"
+		"3:	ld1	{v2.16b}, [%[key]], #16		;"
 		"	subs	%w[rounds], %w[rounds], #3	;"
 		"	aese	v0.16b, v1.16b			;"
 		"	aesmc	v0.16b, v0.16b			;"
-		"	ld1	{v3.2d}, [%[key]], #16		;"
+		"	ld1	{v3.16b}, [%[key]], #16		;"
 		"	bpl	1b				;"
 		"	aese	v0.16b, v2.16b			;"
 		"	eor	v0.16b, v0.16b, v3.16b		;"
@@ -92,24 +92,24 @@ static void aes_cipher_decrypt(struct cr
 	kernel_neon_begin_partial(4);
 
 	__asm__("	ld1	{v0.16b}, %[in]			;"
-		"	ld1	{v1.2d}, [%[key]], #16		;"
+		"	ld1	{v1.16b}, [%[key]], #16		;"
 		"	cmp	%w[rounds], #10			;"
 		"	bmi	0f				;"
 		"	bne	3f				;"
 		"	mov	v3.16b, v1.16b			;"
 		"	b	2f				;"
 		"0:	mov	v2.16b, v1.16b			;"
-		"	ld1	{v3.2d}, [%[key]], #16		;"
+		"	ld1	{v3.16b}, [%[key]], #16		;"
 		"1:	aesd	v0.16b, v2.16b			;"
 		"	aesimc	v0.16b, v0.16b			;"
-		"2:	ld1	{v1.2d}, [%[key]], #16		;"
+		"2:	ld1	{v1.16b}, [%[key]], #16		;"
 		"	aesd	v0.16b, v3.16b			;"
 		"	aesimc	v0.16b, v0.16b			;"
-		"3:	ld1	{v2.2d}, [%[key]], #16		;"
+		"3:	ld1	{v2.16b}, [%[key]], #16		;"
 		"	subs	%w[rounds], %w[rounds], #3	;"
 		"	aesd	v0.16b, v1.16b			;"
 		"	aesimc	v0.16b, v0.16b			;"
-		"	ld1	{v3.2d}, [%[key]], #16		;"
+		"	ld1	{v3.16b}, [%[key]], #16		;"
 		"	bpl	1b				;"
 		"	aesd	v0.16b, v2.16b			;"
 		"	eor	v0.16b, v0.16b, v3.16b		;"
@@ -173,7 +173,12 @@ int ce_aes_expandkey(struct crypto_aes_c
 		u32 *rki = ctx->key_enc + (i * kwords);
 		u32 *rko = rki + kwords;
 
+#ifndef CONFIG_CPU_BIG_ENDIAN
 		rko[0] = ror32(aes_sub(rki[kwords - 1]), 8) ^ rcon[i] ^ rki[0];
+#else
+		rko[0] = rol32(aes_sub(rki[kwords - 1]), 8) ^ (rcon[i] << 24) ^
+			 rki[0];
+#endif
 		rko[1] = rko[0] ^ rki[1];
 		rko[2] = rko[1] ^ rki[2];
 		rko[3] = rko[2] ^ rki[3];

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 153/206] md: MD_RECOVERY_NEEDED is set for mddev->recovery
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (135 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 152/206] crypto: arm64/aes-ce - " Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 154/206] md: fix refcount problem on mddev when stopping array Greg Kroah-Hartman
                     ` (52 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, NeilBrown, Shaohua Li

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Shaohua Li <shli@fb.com>

commit 82a301cb0ea2df8a5c88213094a01660067c7fb4 upstream.

Fixes: 90f5f7ad4f38("md: Wait for md_check_recovery before attempting device
removal.")

Reviewed-by: NeilBrown <neilb@suse.com>
Signed-off-by: Shaohua Li <shli@fb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/md/md.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -6829,7 +6829,7 @@ static int md_ioctl(struct block_device
 		/* need to ensure recovery thread has run */
 		wait_event_interruptible_timeout(mddev->sb_wait,
 						 !test_bit(MD_RECOVERY_NEEDED,
-							   &mddev->flags),
+							   &mddev->recovery),
 						 msecs_to_jiffies(5000));
 	if (cmd == STOP_ARRAY || cmd == STOP_ARRAY_RO) {
 		/* Need to flush page cache, and ensure no-one else opens

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 154/206] md: fix refcount problem on mddev when stopping array.
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (136 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 153/206] md: MD_RECOVERY_NEEDED is set for mddev->recovery Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 155/206] f2fs: remove percpu_count due to performance regression Greg Kroah-Hartman
                     ` (51 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Marc Smith, NeilBrown, Guoqing Jiang,
	Shaohua Li

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: NeilBrown <neilb@suse.com>

commit e2342ca832726a840ca6bd196dd2cc073815b08a upstream.

md_open() gets a counted reference on an mddev using mddev_find().
If it ends up returning an error, it must drop this reference.

There are two error paths where the reference is not dropped.
One only happens if the process is signalled and an awkward time,
which is quite unlikely.
The other was introduced recently in commit af8d8e6f0.

Change the code to ensure the drop the reference when returning an error,
and make it harded to re-introduce this sort of bug in the future.

Reported-by: Marc Smith <marc.smith@mcc.edu>
Fixes: af8d8e6f0315 ("md: changes for MD_STILL_CLOSED flag")
Signed-off-by: NeilBrown <neilb@suse.com>
Acked-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: Shaohua Li <shli@fb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/md/md.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -7092,7 +7092,8 @@ static int md_open(struct block_device *
 
 	if (test_bit(MD_CLOSING, &mddev->flags)) {
 		mutex_unlock(&mddev->open_mutex);
-		return -ENODEV;
+		err = -ENODEV;
+		goto out;
 	}
 
 	err = 0;
@@ -7101,6 +7102,8 @@ static int md_open(struct block_device *
 
 	check_disk_change(bdev);
  out:
+	if (err)
+		mddev_put(mddev);
 	return err;
 }
 

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 155/206] f2fs: remove percpu_count due to performance regression
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (137 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 154/206] md: fix refcount problem on mddev when stopping array Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 157/206] [media] staging: media: davinci_vpfe: unlock on error in vpfe_reqbufs() Greg Kroah-Hartman
                     ` (50 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Jaegeuk Kim

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jaegeuk Kim <jaegeuk@kernel.org>

commit 35782b233f37e48ecc469d9c7232f3f6a7fad41a upstream.

This patch removes percpu_count usage due to performance regression in iozone.

Fixes: 523be8a6b3 ("f2fs: use percpu_counter for page counters")
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/f2fs/debug.c |   12 ++++++------
 fs/f2fs/f2fs.h  |   12 ++++++------
 fs/f2fs/super.c |   16 +++++-----------
 3 files changed, 17 insertions(+), 23 deletions(-)

--- a/fs/f2fs/debug.c
+++ b/fs/f2fs/debug.c
@@ -310,17 +310,17 @@ static int stat_show(struct seq_file *s,
 		seq_printf(s, "  - Inner Struct Count: tree: %d(%d), node: %d\n",
 				si->ext_tree, si->zombie_tree, si->ext_node);
 		seq_puts(s, "\nBalancing F2FS Async:\n");
-		seq_printf(s, "  - inmem: %4lld, wb_bios: %4d\n",
+		seq_printf(s, "  - inmem: %4d, wb_bios: %4d\n",
 			   si->inmem_pages, si->wb_bios);
-		seq_printf(s, "  - nodes: %4lld in %4d\n",
+		seq_printf(s, "  - nodes: %4d in %4d\n",
 			   si->ndirty_node, si->node_pages);
-		seq_printf(s, "  - dents: %4lld in dirs:%4d (%4d)\n",
+		seq_printf(s, "  - dents: %4d in dirs:%4d (%4d)\n",
 			   si->ndirty_dent, si->ndirty_dirs, si->ndirty_all);
-		seq_printf(s, "  - datas: %4lld in files:%4d\n",
+		seq_printf(s, "  - datas: %4d in files:%4d\n",
 			   si->ndirty_data, si->ndirty_files);
-		seq_printf(s, "  - meta: %4lld in %4d\n",
+		seq_printf(s, "  - meta: %4d in %4d\n",
 			   si->ndirty_meta, si->meta_pages);
-		seq_printf(s, "  - imeta: %4lld\n",
+		seq_printf(s, "  - imeta: %4d\n",
 			   si->ndirty_imeta);
 		seq_printf(s, "  - NATs: %9d/%9d\n  - SITs: %9d/%9d\n",
 			   si->dirty_nats, si->nats, si->dirty_sits, si->sits);
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -819,7 +819,7 @@ struct f2fs_sb_info {
 	atomic_t nr_wb_bios;			/* # of writeback bios */
 
 	/* # of pages, see count_type */
-	struct percpu_counter nr_pages[NR_COUNT_TYPE];
+	atomic_t nr_pages[NR_COUNT_TYPE];
 	/* # of allocated blocks */
 	struct percpu_counter alloc_valid_block_count;
 
@@ -1233,7 +1233,7 @@ static inline void dec_valid_block_count
 
 static inline void inc_page_count(struct f2fs_sb_info *sbi, int count_type)
 {
-	percpu_counter_inc(&sbi->nr_pages[count_type]);
+	atomic_inc(&sbi->nr_pages[count_type]);
 
 	if (count_type == F2FS_DIRTY_DATA || count_type == F2FS_INMEM_PAGES)
 		return;
@@ -1250,7 +1250,7 @@ static inline void inode_inc_dirty_pages
 
 static inline void dec_page_count(struct f2fs_sb_info *sbi, int count_type)
 {
-	percpu_counter_dec(&sbi->nr_pages[count_type]);
+	atomic_dec(&sbi->nr_pages[count_type]);
 }
 
 static inline void inode_dec_dirty_pages(struct inode *inode)
@@ -1266,7 +1266,7 @@ static inline void inode_dec_dirty_pages
 
 static inline s64 get_pages(struct f2fs_sb_info *sbi, int count_type)
 {
-	return percpu_counter_sum_positive(&sbi->nr_pages[count_type]);
+	return atomic_read(&sbi->nr_pages[count_type]);
 }
 
 static inline int get_dirty_pages(struct inode *inode)
@@ -2187,8 +2187,8 @@ struct f2fs_stat_info {
 	unsigned long long hit_largest, hit_cached, hit_rbtree;
 	unsigned long long hit_total, total_ext;
 	int ext_tree, zombie_tree, ext_node;
-	s64 ndirty_node, ndirty_dent, ndirty_meta, ndirty_data, ndirty_imeta;
-	s64 inmem_pages;
+	int ndirty_node, ndirty_dent, ndirty_meta, ndirty_data, ndirty_imeta;
+	int inmem_pages;
 	unsigned int ndirty_dirs, ndirty_files, ndirty_all;
 	int nats, dirty_nats, sits, dirty_sits, fnids;
 	int total_count, utilization;
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -688,10 +688,6 @@ static void f2fs_destroy_inode(struct in
 
 static void destroy_percpu_info(struct f2fs_sb_info *sbi)
 {
-	int i;
-
-	for (i = 0; i < NR_COUNT_TYPE; i++)
-		percpu_counter_destroy(&sbi->nr_pages[i]);
 	percpu_counter_destroy(&sbi->alloc_valid_block_count);
 	percpu_counter_destroy(&sbi->total_valid_inode_count);
 }
@@ -1442,6 +1438,7 @@ int sanity_check_ckpt(struct f2fs_sb_inf
 static void init_sb_info(struct f2fs_sb_info *sbi)
 {
 	struct f2fs_super_block *raw_super = sbi->raw_super;
+	int i;
 
 	sbi->log_sectors_per_block =
 		le32_to_cpu(raw_super->log_sectors_per_block);
@@ -1466,6 +1463,9 @@ static void init_sb_info(struct f2fs_sb_
 	sbi->interval_time[REQ_TIME] = DEF_IDLE_INTERVAL;
 	clear_sbi_flag(sbi, SBI_NEED_FSCK);
 
+	for (i = 0; i < NR_COUNT_TYPE; i++)
+		atomic_set(&sbi->nr_pages[i], 0);
+
 	INIT_LIST_HEAD(&sbi->s_list);
 	mutex_init(&sbi->umount_mutex);
 	mutex_init(&sbi->wio_mutex[NODE]);
@@ -1481,13 +1481,7 @@ static void init_sb_info(struct f2fs_sb_
 
 static int init_percpu_info(struct f2fs_sb_info *sbi)
 {
-	int i, err;
-
-	for (i = 0; i < NR_COUNT_TYPE; i++) {
-		err = percpu_counter_init(&sbi->nr_pages[i], 0, GFP_KERNEL);
-		if (err)
-			return err;
-	}
+	int err;
 
 	err = percpu_counter_init(&sbi->alloc_valid_block_count, 0, GFP_KERNEL);
 	if (err)

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 157/206] [media] staging: media: davinci_vpfe: unlock on error in vpfe_reqbufs()
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (138 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 155/206] f2fs: remove percpu_count due to performance regression Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 158/206] PCI: rockchip: Fix negotiated lanes calculation Greg Kroah-Hartman
                     ` (49 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Dan Carpenter, Laurent Pinchart,
	Mauro Carvalho Chehab

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Dan Carpenter <dan.carpenter@oracle.com>

commit c4a407b91f4b644145492e28723f9f880efb1da0 upstream.

We should unlock before returning this error code in vpfe_reqbufs().

Fixes: 622897da67b3 ("[media] davinci: vpfe: add v4l2 video driver support")

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/staging/media/davinci_vpfe/vpfe_video.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/staging/media/davinci_vpfe/vpfe_video.c
+++ b/drivers/staging/media/davinci_vpfe/vpfe_video.c
@@ -1362,7 +1362,7 @@ static int vpfe_reqbufs(struct file *fil
 	ret = vb2_queue_init(q);
 	if (ret) {
 		v4l2_err(&vpfe_dev->v4l2_dev, "vb2_queue_init() failed\n");
-		return ret;
+		goto unlock_out;
 	}
 
 	fh->io_allowed = 1;

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 158/206] PCI: rockchip: Fix negotiated lanes calculation
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (139 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 157/206] [media] staging: media: davinci_vpfe: unlock on error in vpfe_reqbufs() Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 159/206] PCI: rockchip: Correct the use of FTS mask Greg Kroah-Hartman
                     ` (48 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Shawn Lin, Bjorn Helgaas

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Shawn Lin <shawn.lin@rock-chips.com>

commit 45e9320f3a4ef9588ee50a2eb1891c4bfdbb07df upstream.

The calculation of negotiated lanes is wrong: it should be shifted by
PCIE_CORE_PL_CONF_LANE_SHIFT, but it is shifted by
PCIE_CORE_PL_CONF_LANE_MASK instead.  Let's fix it.

Fixes: e77f847df54c ("PCI: rockchip: Add Rockchip PCIe controller support")
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/pci/host/pcie-rockchip.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/pci/host/pcie-rockchip.c
+++ b/drivers/pci/host/pcie-rockchip.c
@@ -590,8 +590,8 @@ static int rockchip_pcie_init_port(struc
 
 	/* Check the final link width from negotiated lane counter from MGMT */
 	status = rockchip_pcie_read(rockchip, PCIE_CORE_CTRL);
-	status =  0x1 << ((status & PCIE_CORE_PL_CONF_LANE_MASK) >>
-			  PCIE_CORE_PL_CONF_LANE_MASK);
+	status = 0x1 << ((status & PCIE_CORE_PL_CONF_LANE_MASK) >>
+			  PCIE_CORE_PL_CONF_LANE_SHIFT);
 	dev_dbg(dev, "current link width is x%d\n", status);
 
 	rockchip_pcie_write(rockchip, ROCKCHIP_VENDOR_ID,

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 159/206] PCI: rockchip: Correct the use of FTS mask
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (140 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 158/206] PCI: rockchip: Fix negotiated lanes calculation Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 160/206] PCI: Add Mellanox device IDs Greg Kroah-Hartman
                     ` (47 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Brian Norris, Bjorn Helgaas, Shawn Lin

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Brian Norris <briannorris@chromium.org>

commit a45e2611b9bbd81288d97d02ce7e74a60a698d43 upstream.

We're trying to mask out bits[23:8] while retaining [32:24, 7:0], but we're
doing the inverse.  That doesn't have too much effect, since we're setting
all the [23:8] bits to 1, and the other bits are only relevant for modes
we're currently not using.  But we should get this right.

Fixes: ca1989084054 ("PCI: rockchip: Fix wrong transmitted FTS count")
Signed-off-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/pci/host/pcie-rockchip.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/pci/host/pcie-rockchip.c
+++ b/drivers/pci/host/pcie-rockchip.c
@@ -533,7 +533,7 @@ static int rockchip_pcie_init_port(struc
 
 	/* Fix the transmitted FTS count desired to exit from L0s. */
 	status = rockchip_pcie_read(rockchip, PCIE_CORE_CTRL_PLC1);
-	status = (status & PCIE_CORE_CTRL_PLC1_FTS_MASK) |
+	status = (status & ~PCIE_CORE_CTRL_PLC1_FTS_MASK) |
 		 (PCIE_CORE_CTRL_PLC1_FTS_CNT << PCIE_CORE_CTRL_PLC1_FTS_SHIFT);
 	rockchip_pcie_write(rockchip, status, PCIE_CORE_CTRL_PLC1);
 

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 160/206] PCI: Add Mellanox device IDs
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (141 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 159/206] PCI: rockchip: Correct the use of FTS mask Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 161/206] PCI: Convert broken INTx masking quirks from HEADER to FINAL Greg Kroah-Hartman
                     ` (46 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Noa Osherovich, Bjorn Helgaas

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Noa Osherovich <noaos@mellanox.com>

commit 7254383341bc6e1a61996accd836009f0c922b21 upstream.

Add Mellanox device IDs for use by the mlx4 driver and INTx quirks.

[bhelgaas: sorted and adapted from
http://lkml.kernel.org/r/1478011644-12080-1-git-send-email-noaos@mellanox.com]
Signed-off-by: Noa Osherovich <noaos@mellanox.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 include/linux/pci_ids.h |   27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -2256,12 +2256,29 @@
 #define PCI_DEVICE_ID_ZOLTRIX_2BD0	0x2bd0
 
 #define PCI_VENDOR_ID_MELLANOX		0x15b3
-#define PCI_DEVICE_ID_MELLANOX_TAVOR	0x5a44
+#define PCI_DEVICE_ID_MELLANOX_CONNECTX3	0x1003
+#define PCI_DEVICE_ID_MELLANOX_CONNECTX3_PRO	0x1007
+#define PCI_DEVICE_ID_MELLANOX_CONNECTIB	0x1011
+#define PCI_DEVICE_ID_MELLANOX_CONNECTX4	0x1013
+#define PCI_DEVICE_ID_MELLANOX_CONNECTX4_LX	0x1015
+#define PCI_DEVICE_ID_MELLANOX_TAVOR		0x5a44
 #define PCI_DEVICE_ID_MELLANOX_TAVOR_BRIDGE	0x5a46
-#define PCI_DEVICE_ID_MELLANOX_ARBEL_COMPAT 0x6278
-#define PCI_DEVICE_ID_MELLANOX_ARBEL	0x6282
-#define PCI_DEVICE_ID_MELLANOX_SINAI_OLD 0x5e8c
-#define PCI_DEVICE_ID_MELLANOX_SINAI	0x6274
+#define PCI_DEVICE_ID_MELLANOX_SINAI_OLD	0x5e8c
+#define PCI_DEVICE_ID_MELLANOX_SINAI		0x6274
+#define PCI_DEVICE_ID_MELLANOX_ARBEL_COMPAT	0x6278
+#define PCI_DEVICE_ID_MELLANOX_ARBEL		0x6282
+#define PCI_DEVICE_ID_MELLANOX_HERMON_SDR	0x6340
+#define PCI_DEVICE_ID_MELLANOX_HERMON_DDR	0x634a
+#define PCI_DEVICE_ID_MELLANOX_HERMON_QDR	0x6354
+#define PCI_DEVICE_ID_MELLANOX_HERMON_EN	0x6368
+#define PCI_DEVICE_ID_MELLANOX_CONNECTX_EN	0x6372
+#define PCI_DEVICE_ID_MELLANOX_HERMON_DDR_GEN2	0x6732
+#define PCI_DEVICE_ID_MELLANOX_HERMON_QDR_GEN2	0x673c
+#define PCI_DEVICE_ID_MELLANOX_CONNECTX_EN_5_GEN2 0x6746
+#define PCI_DEVICE_ID_MELLANOX_HERMON_EN_GEN2	0x6750
+#define PCI_DEVICE_ID_MELLANOX_CONNECTX_EN_T_GEN2 0x675a
+#define PCI_DEVICE_ID_MELLANOX_CONNECTX_EN_GEN2	0x6764
+#define PCI_DEVICE_ID_MELLANOX_CONNECTX2	0x676e
 
 #define PCI_VENDOR_ID_DFI		0x15bd
 

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 161/206] PCI: Convert broken INTx masking quirks from HEADER to FINAL
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (142 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 160/206] PCI: Add Mellanox device IDs Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 162/206] PCI: Convert Mellanox broken INTx quirks to be for listed devices only Greg Kroah-Hartman
                     ` (45 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Noa Osherovich, Bjorn Helgaas, Gavin Shan

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Noa Osherovich <noaos@mellanox.com>

commit b88214ce4d7064992452765028bd50702414f15f upstream.

Convert all quirk_broken_intx_masking() quirks from HEADER to FINAL.

The quirk sets dev->broken_intx_masking, which is only used by
pci_intx_mask_supported(), which is not needed until after FINAL
quirks have been run.

[bhelgaas: changelog]
Signed-off-by: Noa Osherovich <noaos@mellanox.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/pci/quirks.c |   72 +++++++++++++++++++++++++--------------------------
 1 file changed, 36 insertions(+), 36 deletions(-)

--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -3146,53 +3146,53 @@ static void quirk_broken_intx_masking(st
 {
 	dev->broken_intx_masking = 1;
 }
-DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_CHELSIO, 0x0030,
-			 quirk_broken_intx_masking);
-DECLARE_PCI_FIXUP_HEADER(0x1814, 0x0601, /* Ralink RT2800 802.11n PCI */
-			 quirk_broken_intx_masking);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x0030,
+			quirk_broken_intx_masking);
+DECLARE_PCI_FIXUP_FINAL(0x1814, 0x0601, /* Ralink RT2800 802.11n PCI */
+			quirk_broken_intx_masking);
 /*
  * Realtek RTL8169 PCI Gigabit Ethernet Controller (rev 10)
  * Subsystem: Realtek RTL8169/8110 Family PCI Gigabit Ethernet NIC
  *
  * RTL8110SC - Fails under PCI device assignment using DisINTx masking.
  */
-DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_REALTEK, 0x8169,
-			 quirk_broken_intx_masking);
-DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MELLANOX, PCI_ANY_ID,
-			 quirk_broken_intx_masking);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_REALTEK, 0x8169,
+			quirk_broken_intx_masking);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MELLANOX, PCI_ANY_ID,
+			quirk_broken_intx_masking);
 
 /*
  * Intel i40e (XL710/X710) 10/20/40GbE NICs all have broken INTx masking,
  * DisINTx can be set but the interrupt status bit is non-functional.
  */
-DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x1572,
-			 quirk_broken_intx_masking);
-DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x1574,
-			 quirk_broken_intx_masking);
-DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x1580,
-			 quirk_broken_intx_masking);
-DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x1581,
-			 quirk_broken_intx_masking);
-DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x1583,
-			 quirk_broken_intx_masking);
-DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x1584,
-			 quirk_broken_intx_masking);
-DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x1585,
-			 quirk_broken_intx_masking);
-DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x1586,
-			 quirk_broken_intx_masking);
-DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x1587,
-			 quirk_broken_intx_masking);
-DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x1588,
-			 quirk_broken_intx_masking);
-DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x1589,
-			 quirk_broken_intx_masking);
-DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x37d0,
-			 quirk_broken_intx_masking);
-DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x37d1,
-			 quirk_broken_intx_masking);
-DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x37d2,
-			 quirk_broken_intx_masking);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1572,
+			quirk_broken_intx_masking);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1574,
+			quirk_broken_intx_masking);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1580,
+			quirk_broken_intx_masking);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1581,
+			quirk_broken_intx_masking);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1583,
+			quirk_broken_intx_masking);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1584,
+			quirk_broken_intx_masking);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1585,
+			quirk_broken_intx_masking);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1586,
+			quirk_broken_intx_masking);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1587,
+			quirk_broken_intx_masking);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1588,
+			quirk_broken_intx_masking);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1589,
+			quirk_broken_intx_masking);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x37d0,
+			quirk_broken_intx_masking);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x37d1,
+			quirk_broken_intx_masking);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x37d2,
+			quirk_broken_intx_masking);
 
 static void quirk_no_bus_reset(struct pci_dev *dev)
 {

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 162/206] PCI: Convert Mellanox broken INTx quirks to be for listed devices only
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (143 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 161/206] PCI: Convert broken INTx masking quirks from HEADER to FINAL Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 163/206] PCI: Support INTx masking on ConnectX-4 with firmware x.14.1100+ Greg Kroah-Hartman
                     ` (44 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Noa Osherovich, Bjorn Helgaas,
	Or Gerlitz, Gavin Shan

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Noa Osherovich <noaos@mellanox.com>

commit d76d2fe05fd93673d184af77255bbbc63780f4ea upstream.

Change Mellanox's broken_intx_masking() quirk from an "all Mellanox
devices" to a quirk for listed devices only.

[bhelgaas: remove #defines, reorder to keep other quirks together]
Signed-off-by: Noa Osherovich <noaos@mellanox.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com>
Reviewed-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/pci/quirks.c |   40 +++++++++++++++++++++++++++++++++++++---
 1 file changed, 37 insertions(+), 3 deletions(-)

--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -3137,8 +3137,9 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_IN
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x22b7, quirk_remove_d3_delay);
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x2298, quirk_remove_d3_delay);
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x229c, quirk_remove_d3_delay);
+
 /*
- * Some devices may pass our check in pci_intx_mask_supported if
+ * Some devices may pass our check in pci_intx_mask_supported() if
  * PCI_COMMAND_INTX_DISABLE works though they actually do not properly
  * support this feature.
  */
@@ -3150,6 +3151,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CH
 			quirk_broken_intx_masking);
 DECLARE_PCI_FIXUP_FINAL(0x1814, 0x0601, /* Ralink RT2800 802.11n PCI */
 			quirk_broken_intx_masking);
+
 /*
  * Realtek RTL8169 PCI Gigabit Ethernet Controller (rev 10)
  * Subsystem: Realtek RTL8169/8110 Family PCI Gigabit Ethernet NIC
@@ -3158,8 +3160,6 @@ DECLARE_PCI_FIXUP_FINAL(0x1814, 0x0601,
  */
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_REALTEK, 0x8169,
 			quirk_broken_intx_masking);
-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MELLANOX, PCI_ANY_ID,
-			quirk_broken_intx_masking);
 
 /*
  * Intel i40e (XL710/X710) 10/20/40GbE NICs all have broken INTx masking,
@@ -3194,6 +3194,40 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_IN
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x37d2,
 			quirk_broken_intx_masking);
 
+static u16 mellanox_broken_intx_devs[] = {
+	PCI_DEVICE_ID_MELLANOX_HERMON_SDR,
+	PCI_DEVICE_ID_MELLANOX_HERMON_DDR,
+	PCI_DEVICE_ID_MELLANOX_HERMON_QDR,
+	PCI_DEVICE_ID_MELLANOX_HERMON_DDR_GEN2,
+	PCI_DEVICE_ID_MELLANOX_HERMON_QDR_GEN2,
+	PCI_DEVICE_ID_MELLANOX_HERMON_EN,
+	PCI_DEVICE_ID_MELLANOX_HERMON_EN_GEN2,
+	PCI_DEVICE_ID_MELLANOX_CONNECTX_EN,
+	PCI_DEVICE_ID_MELLANOX_CONNECTX_EN_T_GEN2,
+	PCI_DEVICE_ID_MELLANOX_CONNECTX_EN_GEN2,
+	PCI_DEVICE_ID_MELLANOX_CONNECTX_EN_5_GEN2,
+	PCI_DEVICE_ID_MELLANOX_CONNECTX2,
+	PCI_DEVICE_ID_MELLANOX_CONNECTX3,
+	PCI_DEVICE_ID_MELLANOX_CONNECTX3_PRO,
+	PCI_DEVICE_ID_MELLANOX_CONNECTIB,
+	PCI_DEVICE_ID_MELLANOX_CONNECTX4,
+	PCI_DEVICE_ID_MELLANOX_CONNECTX4_LX,
+};
+
+static void mellanox_check_broken_intx_masking(struct pci_dev *pdev)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(mellanox_broken_intx_devs); i++) {
+		if (pdev->device == mellanox_broken_intx_devs[i]) {
+			pdev->broken_intx_masking = 1;
+			return;
+		}
+	}
+}
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MELLANOX, PCI_ANY_ID,
+			mellanox_check_broken_intx_masking);
+
 static void quirk_no_bus_reset(struct pci_dev *dev)
 {
 	dev->dev_flags |= PCI_DEV_FLAGS_NO_BUS_RESET;

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 163/206] PCI: Support INTx masking on ConnectX-4 with firmware x.14.1100+
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (144 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 162/206] PCI: Convert Mellanox broken INTx quirks to be for listed devices only Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 164/206] PCI: Enable access to non-standard VPD for Chelsio devices (cxgb3) Greg Kroah-Hartman
                     ` (43 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Noa Osherovich, Bjorn Helgaas,
	Or Gerlitz, Gavin Shan

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Noa Osherovich <noaos@mellanox.com>

commit 1600f62534b7b3da7978b43b52231a54c24df287 upstream.

Mellanox devices were marked as having INTx masking ability broken.  As a
result, the VFIO driver fails to start when more than one device function
is passed-through to a VM if both have the same INTx pin.

Prior to Connect-IB, Mellanox devices exposed to the operating system one
PCI function per all ports.  Starting from Connect-IB, the devices are
function-per-port.  When passing the second function to a VM, VFIO will
fail to start.

Exclude ConnectX-4, ConnectX4-Lx and Connect-IB from the list of Mellanox
devices marked as having broken INTx masking:

- ConnectX-4 and ConnectX4-LX firmware version is checked. If INTx
  masking is supported, we unmark the broken INTx masking.
- Connect-IB does not support INTx currently so will not cause any
  problem.

[bhelgaas: call pci_disable_device() always, after iounmap()]
Fixes: 11e42532ada3 ("PCI: Assume all Mellanox devices have broken INTx masking")
Signed-off-by: Noa Osherovich <noaos@mellanox.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com>
Reviewed-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/pci/quirks.c |   59 ++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 56 insertions(+), 3 deletions(-)

--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -3209,13 +3209,25 @@ static u16 mellanox_broken_intx_devs[] =
 	PCI_DEVICE_ID_MELLANOX_CONNECTX2,
 	PCI_DEVICE_ID_MELLANOX_CONNECTX3,
 	PCI_DEVICE_ID_MELLANOX_CONNECTX3_PRO,
-	PCI_DEVICE_ID_MELLANOX_CONNECTIB,
-	PCI_DEVICE_ID_MELLANOX_CONNECTX4,
-	PCI_DEVICE_ID_MELLANOX_CONNECTX4_LX,
 };
 
+#define CONNECTX_4_CURR_MAX_MINOR 99
+#define CONNECTX_4_INTX_SUPPORT_MINOR 14
+
+/*
+ * Check ConnectX-4/LX FW version to see if it supports legacy interrupts.
+ * If so, don't mark it as broken.
+ * FW minor > 99 means older FW version format and no INTx masking support.
+ * FW minor < 14 means new FW version format and no INTx masking support.
+ */
 static void mellanox_check_broken_intx_masking(struct pci_dev *pdev)
 {
+	__be32 __iomem *fw_ver;
+	u16 fw_major;
+	u16 fw_minor;
+	u16 fw_subminor;
+	u32 fw_maj_min;
+	u32 fw_sub_min;
 	int i;
 
 	for (i = 0; i < ARRAY_SIZE(mellanox_broken_intx_devs); i++) {
@@ -3224,6 +3236,47 @@ static void mellanox_check_broken_intx_m
 			return;
 		}
 	}
+
+	/* Getting here means Connect-IB cards and up. Connect-IB has no INTx
+	 * support so shouldn't be checked further
+	 */
+	if (pdev->device == PCI_DEVICE_ID_MELLANOX_CONNECTIB)
+		return;
+
+	if (pdev->device != PCI_DEVICE_ID_MELLANOX_CONNECTX4 &&
+	    pdev->device != PCI_DEVICE_ID_MELLANOX_CONNECTX4_LX)
+		return;
+
+	/* For ConnectX-4 and ConnectX-4LX, need to check FW support */
+	if (pci_enable_device_mem(pdev)) {
+		dev_warn(&pdev->dev, "Can't enable device memory\n");
+		return;
+	}
+
+	fw_ver = ioremap(pci_resource_start(pdev, 0), 4);
+	if (!fw_ver) {
+		dev_warn(&pdev->dev, "Can't map ConnectX-4 initialization segment\n");
+		goto out;
+	}
+
+	/* Reading from resource space should be 32b aligned */
+	fw_maj_min = ioread32be(fw_ver);
+	fw_sub_min = ioread32be(fw_ver + 1);
+	fw_major = fw_maj_min & 0xffff;
+	fw_minor = fw_maj_min >> 16;
+	fw_subminor = fw_sub_min & 0xffff;
+	if (fw_minor > CONNECTX_4_CURR_MAX_MINOR ||
+	    fw_minor < CONNECTX_4_INTX_SUPPORT_MINOR) {
+		dev_warn(&pdev->dev, "ConnectX-4: FW %u.%u.%u doesn't support INTx masking, disabling. Please upgrade FW to %d.14.1100 and up for INTx support\n",
+			 fw_major, fw_minor, fw_subminor, pdev->device ==
+			 PCI_DEVICE_ID_MELLANOX_CONNECTX4 ? 12 : 14);
+		pdev->broken_intx_masking = 1;
+	}
+
+	iounmap(fw_ver);
+
+out:
+	pci_disable_device(pdev);
 }
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MELLANOX, PCI_ANY_ID,
 			mellanox_check_broken_intx_masking);

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 164/206] PCI: Enable access to non-standard VPD for Chelsio devices (cxgb3)
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (145 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 163/206] PCI: Support INTx masking on ConnectX-4 with firmware x.14.1100+ Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 165/206] powerpc/pci/rpadlpar: Fix device reference leaks Greg Kroah-Hartman
                     ` (42 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Alexey Kardashevskiy, Bjorn Helgaas

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Alexey Kardashevskiy <aik@ozlabs.ru>

commit 1c7de2b4ff886a45fbd2f4c3d4627e0f37a9dd77 upstream.

There is at least one Chelsio 10Gb card which uses VPD area to store some
non-standard blocks (example below).  However pci_vpd_size() returns the
length of the first block only assuming that there can be only one VPD "End
Tag".

Since 4e1a635552d3 ("vfio/pci: Use kernel VPD access functions"), VFIO
blocks access beyond that offset, which prevents the guest "cxgb3" driver
from probing the device.  The host system does not have this problem as its
driver accesses the config space directly without pci_read_vpd().

Add a quirk to override the VPD size to a bigger value.  The maximum size
is taken from EEPROMSIZE in drivers/net/ethernet/chelsio/cxgb3/common.h.
We do not read the tag as the cxgb3 driver does as the driver supports
writing to EEPROM/VPD and when it writes, it only checks for 8192 bytes
boundary.  The quirk is registered for all devices supported by the cxgb3
driver.

This adds a quirk to the PCI layer (not to the cxgb3 driver) as the cxgb3
driver itself accesses VPD directly and the problem only exists with the
vfio-pci driver (when cxgb3 is not running on the host and may not be even
loaded) which blocks accesses beyond the first block of VPD data.  However
vfio-pci itself does not have quirks mechanism so we add it to PCI.

This is the controller:
Ethernet controller [0200]: Chelsio Communications Inc T310 10GbE Single Port Adapter [1425:0030]

This is what I parsed from its VPD:
===
b'\x82*\x0010 Gigabit Ethernet-SR PCI Express Adapter\x90J\x00EC\x07D76809 FN\x0746K'
 0000 Large item 42 bytes; name 0x2 Identifier String
	b'10 Gigabit Ethernet-SR PCI Express Adapter'
 002d Large item 74 bytes; name 0x10
	#00 [EC] len=7: b'D76809 '
	#0a [FN] len=7: b'46K7897'
	#14 [PN] len=7: b'46K7897'
	#1e [MN] len=4: b'1037'
	#25 [FC] len=4: b'5769'
	#2c [SN] len=12: b'YL102035603V'
	#3b [NA] len=12: b'00145E992ED1'
 007a Small item 1 bytes; name 0xf End Tag

 0c00 Large item 16 bytes; name 0x2 Identifier String
	b'S310E-SR-X      '
 0c13 Large item 234 bytes; name 0x10
	#00 [PN] len=16: b'TBD             '
	#13 [EC] len=16: b'110107730D2     '
	#26 [SN] len=16: b'97YL102035603V  '
	#39 [NA] len=12: b'00145E992ED1'
	#48 [V0] len=6: b'175000'
	#51 [V1] len=6: b'266666'
	#5a [V2] len=6: b'266666'
	#63 [V3] len=6: b'2000  '
	#6c [V4] len=2: b'1 '
	#71 [V5] len=6: b'c2    '
	#7a [V6] len=6: b'0     '
	#83 [V7] len=2: b'1 '
	#88 [V8] len=2: b'0 '
	#8d [V9] len=2: b'0 '
	#92 [VA] len=2: b'0 '
	#97 [RV] len=80: b's\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'...
 0d00 Large item 252 bytes; name 0x11
	#00 [VC] len=16: b'122310_1222 dp  '
	#13 [VD] len=16: b'610-0001-00 H1\x00\x00'
	#26 [VE] len=16: b'122310_1353 fp  '
	#39 [VF] len=16: b'610-0001-00 H1\x00\x00'
	#4c [RW] len=173: b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'...
 0dff Small item 0 bytes; name 0xf End Tag

10f3 Large item 13315 bytes; name 0x62
!!! unknown item name 98: b'\xd0\x03\x00@`\x0c\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00'
===

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/pci/quirks.c |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -3342,6 +3342,25 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_IN
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PORT_RIDGE,
 			quirk_thunderbolt_hotplug_msi);
 
+static void quirk_chelsio_extend_vpd(struct pci_dev *dev)
+{
+	pci_set_vpd_size(dev, 8192);
+}
+
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x20, quirk_chelsio_extend_vpd);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x21, quirk_chelsio_extend_vpd);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x22, quirk_chelsio_extend_vpd);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x23, quirk_chelsio_extend_vpd);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x24, quirk_chelsio_extend_vpd);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x25, quirk_chelsio_extend_vpd);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x26, quirk_chelsio_extend_vpd);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x30, quirk_chelsio_extend_vpd);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x31, quirk_chelsio_extend_vpd);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x32, quirk_chelsio_extend_vpd);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x35, quirk_chelsio_extend_vpd);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x36, quirk_chelsio_extend_vpd);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x37, quirk_chelsio_extend_vpd);
+
 #ifdef CONFIG_ACPI
 /*
  * Apple: Shutdown Cactus Ridge Thunderbolt controller.

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 165/206] powerpc/pci/rpadlpar: Fix device reference leaks
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (146 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 164/206] PCI: Enable access to non-standard VPD for Chelsio devices (cxgb3) Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 166/206] s390/topology: always use s390 specific sched_domain_topology_level Greg Kroah-Hartman
                     ` (41 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Johan Hovold, Michael Ellerman

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Johan Hovold <johan@kernel.org>

commit 99e5cde5eae78bef95bfe7c16ccda87fb070149b upstream.

Make sure to drop any device reference taken by vio_find_node() when
adding and removing virtual I/O slots.

Fixes: 5eeb8c63a38f ("[PATCH] PCI Hotplug: rpaphp: Move VIO registration")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/pci/hotplug/rpadlpar_core.c |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

--- a/drivers/pci/hotplug/rpadlpar_core.c
+++ b/drivers/pci/hotplug/rpadlpar_core.c
@@ -257,8 +257,13 @@ static int dlpar_add_phb(char *drc_name,
 
 static int dlpar_add_vio_slot(char *drc_name, struct device_node *dn)
 {
-	if (vio_find_node(dn))
+	struct vio_dev *vio_dev;
+
+	vio_dev = vio_find_node(dn);
+	if (vio_dev) {
+		put_device(&vio_dev->dev);
 		return -EINVAL;
+	}
 
 	if (!vio_register_device_node(dn)) {
 		printk(KERN_ERR
@@ -334,6 +339,9 @@ static int dlpar_remove_vio_slot(char *d
 		return -EINVAL;
 
 	vio_unregister_device(vio_dev);
+
+	put_device(&vio_dev->dev);
+
 	return 0;
 }
 

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 166/206] s390/topology: always use s390 specific sched_domain_topology_level
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (147 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 165/206] powerpc/pci/rpadlpar: Fix device reference leaks Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 167/206] s390/pci: fix dma address calculation in map_sg Greg Kroah-Hartman
                     ` (40 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Heiko Carstens, Martin Schwidefsky

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Heiko Carstens <heiko.carstens@de.ibm.com>

commit ebb299a51059017ec253bd30781a83d1f6e11b24 upstream.

The s390 specific sched_domain_topology_level should always be used,
not only if the machine provides topology information. Luckily this
odd behaviour, that was by accident introduced with git commit
d05d15da18f5 ("s390/topology: delay initialization of topology cpu
masks") has currently no side effect.

Fixes: d05d15da18f5 ("s390/topology: delay initialization of topology cpumasks")
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/s390/kernel/topology.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/arch/s390/kernel/topology.c
+++ b/arch/s390/kernel/topology.c
@@ -448,6 +448,7 @@ static int __init s390_topology_init(voi
 	struct sysinfo_15_1_x *info;
 	int i;
 
+	set_sched_topology(s390_topology);
 	if (!MACHINE_HAS_TOPOLOGY)
 		return 0;
 	tl_info = (struct sysinfo_15_1_x *)__get_free_page(GFP_KERNEL);
@@ -460,7 +461,6 @@ static int __init s390_topology_init(voi
 	alloc_masks(info, &socket_info, 1);
 	alloc_masks(info, &book_info, 2);
 	alloc_masks(info, &drawer_info, 3);
-	set_sched_topology(s390_topology);
 	return 0;
 }
 early_initcall(s390_topology_init);

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 167/206] s390/pci: fix dma address calculation in map_sg
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (148 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 166/206] s390/topology: always use s390 specific sched_domain_topology_level Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 169/206] drm/i915: disable PSR by default on HSW/BDW Greg Kroah-Hartman
                     ` (39 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Sebastian Ott, Gerald Schaefer,
	Martin Schwidefsky

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Sebastian Ott <sebott@linux.vnet.ibm.com>

commit 6b7df3ce92ac82ec3f4a2953b6fed77da7b38aaa upstream.

__s390_dma_map_sg maps a dma-contiguous area. Although we only map
whole pages we have to take into account that the area doesn't start
or stop at a page boundary because we use the dma address to loop
over the individual sg entries. Failing to do that might lead to an
access of the wrong sg entry.

Fixes: ee877b81c6b9 ("s390/pci_dma: improve map_sg")
Reported-and-tested-by: Christoph Raisch <raisch@de.ibm.com>
Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Reviewed-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/s390/pci/pci_dma.c |   15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

--- a/arch/s390/pci/pci_dma.c
+++ b/arch/s390/pci/pci_dma.c
@@ -419,6 +419,7 @@ static int __s390_dma_map_sg(struct devi
 			     size_t size, dma_addr_t *handle,
 			     enum dma_data_direction dir)
 {
+	unsigned long nr_pages = PAGE_ALIGN(size) >> PAGE_SHIFT;
 	struct zpci_dev *zdev = to_zpci(to_pci_dev(dev));
 	dma_addr_t dma_addr_base, dma_addr;
 	int flags = ZPCI_PTE_VALID;
@@ -426,8 +427,7 @@ static int __s390_dma_map_sg(struct devi
 	unsigned long pa = 0;
 	int ret;
 
-	size = PAGE_ALIGN(size);
-	dma_addr_base = dma_alloc_address(dev, size >> PAGE_SHIFT);
+	dma_addr_base = dma_alloc_address(dev, nr_pages);
 	if (dma_addr_base == DMA_ERROR_CODE)
 		return -ENOMEM;
 
@@ -436,26 +436,27 @@ static int __s390_dma_map_sg(struct devi
 		flags |= ZPCI_TABLE_PROTECTED;
 
 	for (s = sg; dma_addr < dma_addr_base + size; s = sg_next(s)) {
-		pa = page_to_phys(sg_page(s)) + s->offset;
-		ret = __dma_update_trans(zdev, pa, dma_addr, s->length, flags);
+		pa = page_to_phys(sg_page(s));
+		ret = __dma_update_trans(zdev, pa, dma_addr,
+					 s->offset + s->length, flags);
 		if (ret)
 			goto unmap;
 
-		dma_addr += s->length;
+		dma_addr += s->offset + s->length;
 	}
 	ret = __dma_purge_tlb(zdev, dma_addr_base, size, flags);
 	if (ret)
 		goto unmap;
 
 	*handle = dma_addr_base;
-	atomic64_add(size >> PAGE_SHIFT, &zdev->mapped_pages);
+	atomic64_add(nr_pages, &zdev->mapped_pages);
 
 	return ret;
 
 unmap:
 	dma_update_trans(zdev, 0, dma_addr_base, dma_addr - dma_addr_base,
 			 ZPCI_PTE_INVALID);
-	dma_free_address(dev, dma_addr_base, size >> PAGE_SHIFT);
+	dma_free_address(dev, dma_addr_base, nr_pages);
 	zpci_err("map error:\n");
 	zpci_err_dma(ret, pa);
 	return ret;

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 169/206] drm/i915: disable PSR by default on HSW/BDW
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (149 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 167/206] s390/pci: fix dma address calculation in map_sg Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 170/206] drm/i915/gen9: unconditionally apply the memory bandwidth WA Greg Kroah-Hartman
                     ` (38 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Rodrigo Vivi, Jim Bride,
	Paulo Zanoni, Jani Nikula

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Paulo Zanoni <paulo.r.zanoni@intel.com>

commit 1c4672ce4eeaeaadeea8adabaad21262b7172607 upstream.

We've been ignoring the poor bugzilla reporters that say PSR causes
system lockups and all other sorts of problems. The earliest bug
report is from April, so I think we can use the "revert the offending
commit if no fixes are presented within 8 months" rule here.

Fixes: 9b58e352b463 ("drm/i915: Enable PSR by default on Haswell and Broadwell.")
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97602
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97515
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=96736
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=96704
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=96569
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=95176
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94985
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Jim Bride <jim.bride@linux.intel.com>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Acked-by: Jani Nikula <jani.nikula@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1481662664-18986-1-git-send-email-paulo.r.zanoni@intel.com
(cherry picked from commit 2ee7dc497e348eecbb82adbb1ea9e9a7e29fe921)
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/gpu/drm/i915/intel_psr.c |   10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

After we merged this, we closed even more fd.o bugs...

--- a/drivers/gpu/drm/i915/intel_psr.c
+++ b/drivers/gpu/drm/i915/intel_psr.c
@@ -825,13 +825,9 @@ void intel_psr_init(struct drm_device *d
 	dev_priv->psr_mmio_base = IS_HASWELL(dev_priv) ?
 		HSW_EDP_PSR_BASE : BDW_EDP_PSR_BASE;
 
-	/* Per platform default */
-	if (i915.enable_psr == -1) {
-		if (IS_HASWELL(dev) || IS_BROADWELL(dev))
-			i915.enable_psr = 1;
-		else
-			i915.enable_psr = 0;
-	}
+	/* Per platform default: all disabled. */
+	if (i915.enable_psr == -1)
+		i915.enable_psr = 0;
 
 	/* Set link_standby x link_off defaults */
 	if (IS_HASWELL(dev) || IS_BROADWELL(dev))

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 170/206] drm/i915/gen9: unconditionally apply the memory bandwidth WA
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (150 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 169/206] drm/i915: disable PSR by default on HSW/BDW Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 171/206] drm/i915/gen9: fix the WM memory bandwidth WA for Y tiling cases Greg Kroah-Hartman
                     ` (37 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Mahesh Kumar, Lyude,
	Dhinakaran Pandiyan, Paulo Zanoni

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Paulo Zanoni <paulo.r.zanoni@intel.com>

commit ee3d532fcb64872bc20be0ee58f7afdb9fa82abe upstream.

Mahesh Kumar is already working on a proper implementation for the
workaround, but while we still don't have it, let's just
unconditionally apply the workaround for everybody and we hope we can
close all those numerous bugzilla tickets. Also, I'm not sure how easy
it will be to backport the final implementation to the stable Kernels,
and this patch here is probably easier to backport.

At the present moment I still don't have confirmation that this patch
fixes any of the bugs listed below, but we should definitely try
testing all of them again.

v2: s/intel_needs_memory_bw_wa/skl_needs_memory_bw_wa/ (Lyude).
v3: Rebase (dev -> dev_priv change on ilk_wm_max_level).

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94337
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94605
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94884
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=95010
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=96226
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=96828
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97450
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97830
Cc: Mahesh Kumar <mahesh1.kumar@intel.com>
Cc: Lyude <cpaul@redhat.com>
Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Reviewed-by: Lyude <cpaul@redhat.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1476210338-9797-1-git-send-email-paulo.r.zanoni@intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/gpu/drm/i915/intel_pm.c |   49 +++++++++++++++++++++++++++++++++-------
 1 file changed, 41 insertions(+), 8 deletions(-)

--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -2879,6 +2879,21 @@ skl_wm_plane_id(const struct intel_plane
 	}
 }
 
+/*
+ * FIXME: We still don't have the proper code detect if we need to apply the WA,
+ * so assume we'll always need it in order to avoid underruns.
+ */
+static bool skl_needs_memory_bw_wa(struct intel_atomic_state *state)
+{
+	struct drm_i915_private *dev_priv = to_i915(state->base.dev);
+
+	if (IS_SKYLAKE(dev_priv) || IS_BROXTON(dev_priv) ||
+	    IS_KABYLAKE(dev_priv))
+		return true;
+
+	return false;
+}
+
 static bool
 intel_has_sagv(struct drm_i915_private *dev_priv)
 {
@@ -2999,9 +3014,10 @@ bool intel_can_enable_sagv(struct drm_at
 	struct drm_device *dev = state->dev;
 	struct drm_i915_private *dev_priv = to_i915(dev);
 	struct intel_atomic_state *intel_state = to_intel_atomic_state(state);
-	struct drm_crtc *crtc;
+	struct intel_crtc *crtc;
+	struct intel_plane *plane;
 	enum pipe pipe;
-	int level, plane;
+	int level, id, latency;
 
 	if (!intel_has_sagv(dev_priv))
 		return false;
@@ -3019,27 +3035,36 @@ bool intel_can_enable_sagv(struct drm_at
 
 	/* Since we're now guaranteed to only have one active CRTC... */
 	pipe = ffs(intel_state->active_crtcs) - 1;
-	crtc = dev_priv->pipe_to_crtc_mapping[pipe];
+	crtc = to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]);
 
-	if (crtc->state->mode.flags & DRM_MODE_FLAG_INTERLACE)
+	if (crtc->base.state->mode.flags & DRM_MODE_FLAG_INTERLACE)
 		return false;
 
-	for_each_plane(dev_priv, pipe, plane) {
+	for_each_intel_plane_on_crtc(dev, crtc, plane) {
+		id = skl_wm_plane_id(plane);
+
 		/* Skip this plane if it's not enabled */
-		if (intel_state->wm_results.plane[pipe][plane][0] == 0)
+		if (intel_state->wm_results.plane[pipe][id][0] == 0)
 			continue;
 
 		/* Find the highest enabled wm level for this plane */
 		for (level = ilk_wm_max_level(dev);
-		     intel_state->wm_results.plane[pipe][plane][level] == 0; --level)
+		     intel_state->wm_results.plane[pipe][id][level] == 0; --level)
 		     { }
 
+		latency = dev_priv->wm.skl_latency[level];
+
+		if (skl_needs_memory_bw_wa(intel_state) &&
+		    plane->base.state->fb->modifier[0] ==
+		    I915_FORMAT_MOD_X_TILED)
+			latency += 15;
+
 		/*
 		 * If any of the planes on this pipe don't enable wm levels
 		 * that incur memory latencies higher then 30µs we can't enable
 		 * the SAGV
 		 */
-		if (dev_priv->wm.skl_latency[level] < SKL_SAGV_BLOCK_TIME)
+		if (latency < SKL_SAGV_BLOCK_TIME)
 			return false;
 	}
 
@@ -3549,12 +3574,18 @@ static int skl_compute_plane_wm(const st
 	uint32_t width = 0, height = 0;
 	uint32_t plane_pixel_rate;
 	uint32_t y_tile_minimum, y_min_scanlines;
+	struct intel_atomic_state *state =
+		to_intel_atomic_state(cstate->base.state);
+	bool apply_memory_bw_wa = skl_needs_memory_bw_wa(state);
 
 	if (latency == 0 || !cstate->base.active || !intel_pstate->base.visible) {
 		*enabled = false;
 		return 0;
 	}
 
+	if (apply_memory_bw_wa && fb->modifier[0] == I915_FORMAT_MOD_X_TILED)
+		latency += 15;
+
 	width = drm_rect_width(&intel_pstate->base.src) >> 16;
 	height = drm_rect_height(&intel_pstate->base.src) >> 16;
 
@@ -3606,6 +3637,8 @@ static int skl_compute_plane_wm(const st
 				 plane_blocks_per_line);
 
 	y_tile_minimum = plane_blocks_per_line * y_min_scanlines;
+	if (apply_memory_bw_wa)
+		y_tile_minimum *= 2;
 
 	if (fb->modifier[0] == I915_FORMAT_MOD_Y_TILED ||
 	    fb->modifier[0] == I915_FORMAT_MOD_Yf_TILED) {

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 171/206] drm/i915/gen9: fix the WM memory bandwidth WA for Y tiling cases
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (151 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 170/206] drm/i915/gen9: unconditionally apply the memory bandwidth WA Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 172/206] tpm_tis: Check return values from get_burstcount Greg Kroah-Hartman
                     ` (36 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Mahesh Kumar, Paulo Zanoni, Matt Roper

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Paulo Zanoni <paulo.r.zanoni@intel.com>

commit 2ef32dee97fcf41987722a37eb6ff1a983915e99 upstream.

The previous spec version said "double Ytile planes minimum lines",
and I interpreted this as referring to what the spec calls "Y tile
minimum", but in fact it was referring to what the spec calls "Minimum
Scanlines for Y tile". I noticed that Mahesh Kumar had a different
interpretation, so I sent and email to the spec authors and got
clarification on the correct meaning. Also, BSpec was updated and
should be clear now.

Fixes: ee3d532fcb64 ("drm/i915/gen9: unconditionally apply the memory bandwidth WA")
Cc: stable@vger.kernel.org
Cc: Mahesh Kumar <mahesh1.kumar@intel.com>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1478636531-6081-1-git-send-email-paulo.r.zanoni@intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/gpu/drm/i915/intel_pm.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -3617,6 +3617,9 @@ static int skl_compute_plane_wm(const st
 		y_min_scanlines = 4;
 	}
 
+	if (apply_memory_bw_wa)
+		y_min_scanlines *= 2;
+
 	plane_bytes_per_line = width * cpp;
 	if (fb->modifier[0] == I915_FORMAT_MOD_Y_TILED ||
 	    fb->modifier[0] == I915_FORMAT_MOD_Yf_TILED) {
@@ -3637,8 +3640,6 @@ static int skl_compute_plane_wm(const st
 				 plane_blocks_per_line);
 
 	y_tile_minimum = plane_blocks_per_line * y_min_scanlines;
-	if (apply_memory_bw_wa)
-		y_tile_minimum *= 2;
 
 	if (fb->modifier[0] == I915_FORMAT_MOD_Y_TILED ||
 	    fb->modifier[0] == I915_FORMAT_MOD_Yf_TILED) {

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 172/206] tpm_tis: Check return values from get_burstcount.
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (152 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 171/206] drm/i915/gen9: fix the WM memory bandwidth WA for Y tiling cases Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 173/206] xfs: dont call xfs_sb_quota_from_disk twice Greg Kroah-Hartman
                     ` (35 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Josh Zimmerman, Jarkko Sakkinen

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Josh Zimmerman <joshz@google.com>

commit 26a137e31ffe6fbfdb008554a8d9b3d55bd5c86e upstream.

If the TPM we're connecting to uses a static burst count, it will report
a burst count of zero throughout the response read. However, get_burstcount
assumes that a response of zero indicates that the TPM is not ready to
receive more data. In this case, it returns a negative error code, which
is passed on to tpm_tis_{write,read}_bytes as a u16, causing
them to read/write far too many bytes.

This patch checks for negative return codes and bails out from recv_data
and tpm_tis_send_data.

Fixes: 1107d065fdf1 (tpm_tis: Introduce intermediate layer for TPM access)
Signed-off-by: Josh Zimmerman <joshz@google.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


---
 drivers/char/tpm/tpm_tis_core.c |   15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -185,7 +185,12 @@ static int recv_data(struct tpm_chip *ch
 				 TPM_STS_DATA_AVAIL | TPM_STS_VALID,
 				 chip->timeout_c,
 				 &priv->read_queue, true) == 0) {
-		burstcnt = min_t(int, get_burstcount(chip), count - size);
+		burstcnt = get_burstcount(chip);
+		if (burstcnt < 0) {
+			dev_err(&chip->dev, "Unable to read burstcount\n");
+			return burstcnt;
+		}
+		burstcnt = min_t(int, burstcnt, count - size);
 
 		rc = tpm_tis_read_bytes(priv, TPM_DATA_FIFO(priv->locality),
 					burstcnt, buf + size);
@@ -271,7 +276,13 @@ static int tpm_tis_send_data(struct tpm_
 	}
 
 	while (count < len - 1) {
-		burstcnt = min_t(int, get_burstcount(chip), len - count - 1);
+		burstcnt = get_burstcount(chip);
+		if (burstcnt < 0) {
+			dev_err(&chip->dev, "Unable to read burstcount\n");
+			rc = burstcnt;
+			goto out_err;
+		}
+		burstcnt = min_t(int, burstcnt, len - count - 1);
 		rc = tpm_tis_write_bytes(priv, TPM_DATA_FIFO(priv->locality),
 					 burstcnt, buf + count);
 		if (rc < 0)

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 173/206] xfs: dont call xfs_sb_quota_from_disk twice
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (153 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 172/206] tpm_tis: Check return values from get_burstcount Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 174/206] xfs: check return value of _trans_reserve_quota_nblks Greg Kroah-Hartman
                     ` (34 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Greg Kroah-Hartman, Eryu Guan, Eric Sandeen, Carlos Maiolino,
	Dave Chinner, Christoph Hellwig

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------


From: Eric Sandeen <sandeen@redhat.com>

commit e6fc6fcf4447c9266038c55c25e4c7c14bee110c upstream.

Source xfsprogs commit: ee3754254e8c186c99b6cdd4d59f741759d04acb

Kernel commit 5ef828c4 ("xfs: avoid false quotacheck after unclean
shutdown") made xfs_sb_from_disk() also call xfs_sb_quota_from_disk
by default.

However, when this was merged to libxfs, existing separate
calls to libxfs_sb_quota_from_disk remained, and calling it
twice in a row on a V4 superblock leads to issues, because:

        if (sbp->sb_qflags & XFS_PQUOTA_ACCT)  {
...
                sbp->sb_pquotino = sbp->sb_gquotino;
                sbp->sb_gquotino = NULLFSINO;

and after the second call, we have set both pquotino and gquotino
to NULLFSINO.

Fix this by making it safe to call twice, and also remove the extra
calls to libxfs_sb_quota_from_disk.

This is only spotted when running xfstests with "-m crc=0" because
the sb_from_disk change came about after V5 became default, and
the above behavior only exists on a V4 superblock.

Reported-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/xfs/libxfs/xfs_sb.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

--- a/fs/xfs/libxfs/xfs_sb.c
+++ b/fs/xfs/libxfs/xfs_sb.c
@@ -338,13 +338,16 @@ xfs_sb_quota_from_disk(struct xfs_sb *sb
 					XFS_PQUOTA_CHKD : XFS_GQUOTA_CHKD;
 	sbp->sb_qflags &= ~(XFS_OQUOTA_ENFD | XFS_OQUOTA_CHKD);
 
-	if (sbp->sb_qflags & XFS_PQUOTA_ACCT)  {
+	if (sbp->sb_qflags & XFS_PQUOTA_ACCT &&
+	    sbp->sb_gquotino != NULLFSINO)  {
 		/*
 		 * In older version of superblock, on-disk superblock only
 		 * has sb_gquotino, and in-core superblock has both sb_gquotino
 		 * and sb_pquotino. But, only one of them is supported at any
 		 * point of time. So, if PQUOTA is set in disk superblock,
-		 * copy over sb_gquotino to sb_pquotino.
+		 * copy over sb_gquotino to sb_pquotino.  The NULLFSINO test
+		 * above is to make sure we don't do this twice and wipe them
+		 * both out!
 		 */
 		sbp->sb_pquotino = sbp->sb_gquotino;
 		sbp->sb_gquotino = NULLFSINO;

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 174/206] xfs: check return value of _trans_reserve_quota_nblks
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (154 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 173/206] xfs: dont call xfs_sb_quota_from_disk twice Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 175/206] xfs: dont skip cow forks w/ delalloc blocks in cowblocks scan Greg Kroah-Hartman
                     ` (33 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Greg Kroah-Hartman, Darrick J. Wong, Dave Chinner, Dave Chinner,
	Christoph Hellwig

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------


From: "Darrick J. Wong" <darrick.wong@oracle.com>

commit 4fd29ec47212c8cbf98916af519019ccc5e58e49 upstream.

Check the return value of xfs_trans_reserve_quota_nblks for errors.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/xfs/libxfs/xfs_bmap.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -4902,8 +4902,11 @@ xfs_bmap_del_extent_delay(
 	 * sb counters as we might have to borrow some blocks for the
 	 * indirect block accounting.
 	 */
-	xfs_trans_reserve_quota_nblks(NULL, ip, -((long)del->br_blockcount), 0,
+	error = xfs_trans_reserve_quota_nblks(NULL, ip,
+			-((long)del->br_blockcount), 0,
 			isrt ? XFS_QMOPT_RES_RTBLKS : XFS_QMOPT_RES_REGBLKS);
+	if (error)
+		return error;
 	ip->i_delayed_blks -= del->br_blockcount;
 
 	if (whichfork == XFS_COW_FORK)

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 175/206] xfs: dont skip cow forks w/ delalloc blocks in cowblocks scan
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (155 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 174/206] xfs: check return value of _trans_reserve_quota_nblks Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 176/206] xfs: dont BUG() on mixed direct and mapped I/O Greg Kroah-Hartman
                     ` (32 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Greg Kroah-Hartman, Brian Foster, Darrick J. Wong, Dave Chinner,
	Christoph Hellwig

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------


From: Brian Foster <bfoster@redhat.com>

commit 399372349a7f9b2d7e56e4fa4467c69822d07024 upstream.

The cowblocks background scanner currently clears the cowblocks tag
for inodes without any real allocations in the cow fork. This
excludes inodes with only delalloc blocks in the cow fork. While we
might never expect to clear delalloc blocks from the cow fork in the
background scanner, it is not necessarily correct to clear the
cowblocks tag from such inodes.

For example, if the background scanner happens to process an inode
between a buffered write and writeback, the scanner catches the
inode in a state after delalloc blocks have been allocated to the
cow fork but before the delalloc blocks have been converted to real
blocks by writeback. The background scanner then incorrectly clears
the cowblocks tag, even if part of the aforementioned delalloc
reservation will not be remapped to the data fork (i.e., extra
blocks due to the cowextsize hint). This means that any such
additional blocks in the cow fork might never be reclaimed by the
background scanner and could persist until the inode itself is
reclaimed.

To address this problem, only skip and clear inodes without any cow
fork allocations whatsoever from the background scanner. While we
generally do not want to cancel delalloc reservations from the
background scanner, the pagecache dirty check following the
cowblocks check should prevent that situation. If we do end up with
delalloc cow fork blocks without a dirty address space mapping, this
is probably an indication that something has gone wrong and the
blocks should be reclaimed, as they may never be converted to a real
allocation.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/xfs/xfs_icache.c  |    7 ++++++-
 fs/xfs/xfs_reflink.c |   34 ----------------------------------
 fs/xfs/xfs_reflink.h |    2 --
 3 files changed, 6 insertions(+), 37 deletions(-)

--- a/fs/xfs/xfs_icache.c
+++ b/fs/xfs/xfs_icache.c
@@ -1580,10 +1580,15 @@ xfs_inode_free_cowblocks(
 	struct xfs_eofblocks *eofb = args;
 	bool need_iolock = true;
 	int match;
+	struct xfs_ifork	*ifp = XFS_IFORK_PTR(ip, XFS_COW_FORK);
 
 	ASSERT(!eofb || (eofb && eofb->eof_scan_owner != 0));
 
-	if (!xfs_reflink_has_real_cow_blocks(ip)) {
+	/*
+	 * Just clear the tag if we have an empty cow fork or none at all. It's
+	 * possible the inode was fully unshared since it was originally tagged.
+	 */
+	if (!xfs_is_reflink_inode(ip) || !ifp->if_bytes) {
 		trace_xfs_inode_free_cowblocks_invalid(ip);
 		xfs_inode_clear_cowblocks_tag(ip);
 		return 0;
--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
@@ -1697,37 +1697,3 @@ out:
 	trace_xfs_reflink_unshare_error(ip, error, _RET_IP_);
 	return error;
 }
-
-/*
- * Does this inode have any real CoW reservations?
- */
-bool
-xfs_reflink_has_real_cow_blocks(
-	struct xfs_inode		*ip)
-{
-	struct xfs_bmbt_irec		irec;
-	struct xfs_ifork		*ifp;
-	struct xfs_bmbt_rec_host	*gotp;
-	xfs_extnum_t			idx;
-
-	if (!xfs_is_reflink_inode(ip))
-		return false;
-
-	/* Go find the old extent in the CoW fork. */
-	ifp = XFS_IFORK_PTR(ip, XFS_COW_FORK);
-	gotp = xfs_iext_bno_to_ext(ifp, 0, &idx);
-	while (gotp) {
-		xfs_bmbt_get_all(gotp, &irec);
-
-		if (!isnullstartblock(irec.br_startblock))
-			return true;
-
-		/* Roll on... */
-		idx++;
-		if (idx >= ifp->if_bytes / sizeof(xfs_bmbt_rec_t))
-			break;
-		gotp = xfs_iext_get_ext(ifp, idx);
-	}
-
-	return false;
-}
--- a/fs/xfs/xfs_reflink.h
+++ b/fs/xfs/xfs_reflink.h
@@ -50,6 +50,4 @@ extern int xfs_reflink_clear_inode_flag(
 extern int xfs_reflink_unshare(struct xfs_inode *ip, xfs_off_t offset,
 		xfs_off_t len);
 
-extern bool xfs_reflink_has_real_cow_blocks(struct xfs_inode *ip);
-
 #endif /* __XFS_REFLINK_H */

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 176/206] xfs: dont BUG() on mixed direct and mapped I/O
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (156 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 175/206] xfs: dont skip cow forks w/ delalloc blocks in cowblocks scan Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 177/206] xfs: provide helper for counting extents from if_bytes Greg Kroah-Hartman
                     ` (31 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Greg Kroah-Hartman, Brian Foster, Dave Chinner, Dave Chinner,
	Christoph Hellwig

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------


From: Brian Foster <bfoster@redhat.com>

commit 04197b341f23b908193308b8d63d17ff23232598 upstream.

We've had reports of generic/095 causing XFS to BUG() in
__xfs_get_blocks() due to the existence of delalloc blocks on a
direct I/O read. generic/095 issues a mix of various types of I/O,
including direct and memory mapped I/O to a single file. This is
clearly not supported behavior and is known to lead to such
problems. E.g., the lack of exclusion between the direct I/O and
write fault paths means that a write fault can allocate delalloc
blocks in a region of a file that was previously a hole after the
direct read has attempted to flush/inval the file range, but before
it actually reads the block mapping. In turn, the direct read
discovers a delalloc extent and cannot proceed.

While the appropriate solution here is to not mix direct and memory
mapped I/O to the same regions of the same file, the current
BUG_ON() behavior is probably overkill as it can crash the entire
system.  Instead, localize the failure to the I/O in question by
returning an error for a direct I/O that cannot be handled safely
due to delalloc blocks. Be careful to allow the case of a direct
write to post-eof delalloc blocks. This can occur due to speculative
preallocation and is safe as post-eof blocks are not accompanied by
dirty pages in pagecache (conversely, preallocation within eof must
have been zeroed, and thus dirtied, before the inode size could have
been increased beyond said blocks).

Finally, provide an additional warning if a direct I/O write occurs
while the file is memory mapped. This may not catch all problematic
scenarios, but provides a hint that some known-to-be-problematic I/O
methods are in use.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/xfs/xfs_aops.c |   22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -1361,6 +1361,26 @@ __xfs_get_blocks(
 	if (error)
 		goto out_unlock;
 
+	/*
+	 * The only time we can ever safely find delalloc blocks on direct I/O
+	 * is a dio write to post-eof speculative preallocation. All other
+	 * scenarios are indicative of a problem or misuse (such as mixing
+	 * direct and mapped I/O).
+	 *
+	 * The file may be unmapped by the time we get here so we cannot
+	 * reliably fail the I/O based on mapping. Instead, fail the I/O if this
+	 * is a read or a write within eof. Otherwise, carry on but warn as a
+	 * precuation if the file happens to be mapped.
+	 */
+	if (direct && imap.br_startblock == DELAYSTARTBLOCK) {
+		if (!create || offset < i_size_read(VFS_I(ip))) {
+			WARN_ON_ONCE(1);
+			error = -EIO;
+			goto out_unlock;
+		}
+		WARN_ON_ONCE(mapping_mapped(VFS_I(ip)->i_mapping));
+	}
+
 	/* for DAX, we convert unwritten extents directly */
 	if (create &&
 	    (!nimaps ||
@@ -1450,8 +1470,6 @@ __xfs_get_blocks(
 	     (new || ISUNWRITTEN(&imap))))
 		set_buffer_new(bh_result);
 
-	BUG_ON(direct && imap.br_startblock == DELAYSTARTBLOCK);
-
 	return 0;
 
 out_unlock:

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 177/206] xfs: provide helper for counting extents from if_bytes
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (157 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 176/206] xfs: dont BUG() on mixed direct and mapped I/O Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 178/206] xfs: check minimum block size for CRC filesystems Greg Kroah-Hartman
                     ` (30 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Greg Kroah-Hartman, Eric Sandeen, Brian Foster, Dave Chinner,
	Christoph Hellwig

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------


From: Eric Sandeen <sandeen@sandeen.net>

commit 5d829300bee000980a09ac2ccb761cb25867b67c upstream.

The open-coded pattern:

ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t)

is all over the xfs code; provide a new helper
xfs_iext_count(ifp) to count the number of inline extents
in an inode fork.

[dchinner: pick up several missed conversions]

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/xfs/libxfs/xfs_bmap.c       |   49 +++++++++++++++++++----------------------
 fs/xfs/libxfs/xfs_inode_fork.c |   31 +++++++++++++++----------
 fs/xfs/libxfs/xfs_inode_fork.h |    1 
 fs/xfs/xfs_bmap_util.c         |   34 +++++++++++-----------------
 fs/xfs/xfs_inode_item.c        |    4 +--
 fs/xfs/xfs_ioctl.c             |    6 +----
 fs/xfs/xfs_qm.c                |    2 -
 fs/xfs/xfs_reflink.c           |    4 +--
 8 files changed, 64 insertions(+), 67 deletions(-)

--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -515,7 +515,7 @@ xfs_bmap_trace_exlist(
 		state |= BMAP_ATTRFORK;
 
 	ifp = XFS_IFORK_PTR(ip, whichfork);
-	ASSERT(cnt == (ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t)));
+	ASSERT(cnt == xfs_iext_count(ifp));
 	for (idx = 0; idx < cnt; idx++)
 		trace_xfs_extlist(ip, idx, whichfork, caller_ip);
 }
@@ -811,7 +811,7 @@ try_another_ag:
 				XFS_BTREE_LONG_PTRS);
 
 	arp = XFS_BMBT_REC_ADDR(mp, ablock, 1);
-	nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
+	nextents =  xfs_iext_count(ifp);
 	for (cnt = i = 0; i < nextents; i++) {
 		ep = xfs_iext_get_ext(ifp, i);
 		if (!isnullstartblock(xfs_bmbt_get_startblock(ep))) {
@@ -1296,7 +1296,7 @@ xfs_bmap_read_extents(
 	/*
 	 * Here with bp and block set to the leftmost leaf node in the tree.
 	 */
-	room = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
+	room = xfs_iext_count(ifp);
 	i = 0;
 	/*
 	 * Loop over all leaf nodes.  Copy information to the extent records.
@@ -1361,7 +1361,7 @@ xfs_bmap_read_extents(
 			return error;
 		block = XFS_BUF_TO_BLOCK(bp);
 	}
-	ASSERT(i == (ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t)));
+	ASSERT(i == xfs_iext_count(ifp));
 	ASSERT(i == XFS_IFORK_NEXTENTS(ip, whichfork));
 	XFS_BMAP_TRACE_EXLIST(ip, i, whichfork);
 	return 0;
@@ -1404,7 +1404,7 @@ xfs_bmap_search_multi_extents(
 	if (lastx > 0) {
 		xfs_bmbt_get_all(xfs_iext_get_ext(ifp, lastx - 1), prevp);
 	}
-	if (lastx < (ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t))) {
+	if (lastx < xfs_iext_count(ifp)) {
 		xfs_bmbt_get_all(ep, gotp);
 		*eofp = 0;
 	} else {
@@ -1497,7 +1497,7 @@ xfs_bmap_first_unused(
 	    (error = xfs_iread_extents(tp, ip, whichfork)))
 		return error;
 	lowest = *first_unused;
-	nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
+	nextents = xfs_iext_count(ifp);
 	for (idx = 0, lastaddr = 0, max = lowest; idx < nextents; idx++) {
 		xfs_bmbt_rec_host_t *ep = xfs_iext_get_ext(ifp, idx);
 		off = xfs_bmbt_get_startoff(ep);
@@ -1582,7 +1582,7 @@ xfs_bmap_last_extent(
 			return error;
 	}
 
-	nextents = ifp->if_bytes / sizeof(xfs_bmbt_rec_t);
+	nextents = xfs_iext_count(ifp);
 	if (nextents == 0) {
 		*is_empty = 1;
 		return 0;
@@ -1735,7 +1735,7 @@ xfs_bmap_add_extent_delay_real(
 						&bma->ip->i_d.di_nextents);
 
 	ASSERT(bma->idx >= 0);
-	ASSERT(bma->idx <= ifp->if_bytes / sizeof(struct xfs_bmbt_rec));
+	ASSERT(bma->idx <= xfs_iext_count(ifp));
 	ASSERT(!isnullstartblock(new->br_startblock));
 	ASSERT(!bma->cur ||
 	       (bma->cur->bc_private.b.flags & XFS_BTCUR_BPRV_WASDEL));
@@ -1794,7 +1794,7 @@ xfs_bmap_add_extent_delay_real(
 	 * Don't set contiguous if the combined extent would be too large.
 	 * Also check for all-three-contiguous being too large.
 	 */
-	if (bma->idx < ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t) - 1) {
+	if (bma->idx < xfs_iext_count(ifp) - 1) {
 		state |= BMAP_RIGHT_VALID;
 		xfs_bmbt_get_all(xfs_iext_get_ext(ifp, bma->idx + 1), &RIGHT);
 
@@ -2300,7 +2300,7 @@ xfs_bmap_add_extent_unwritten_real(
 	ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
 
 	ASSERT(*idx >= 0);
-	ASSERT(*idx <= ifp->if_bytes / sizeof(struct xfs_bmbt_rec));
+	ASSERT(*idx <= xfs_iext_count(ifp));
 	ASSERT(!isnullstartblock(new->br_startblock));
 
 	XFS_STATS_INC(mp, xs_add_exlist);
@@ -2356,7 +2356,7 @@ xfs_bmap_add_extent_unwritten_real(
 	 * Don't set contiguous if the combined extent would be too large.
 	 * Also check for all-three-contiguous being too large.
 	 */
-	if (*idx < ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t) - 1) {
+	if (*idx < xfs_iext_count(&ip->i_df) - 1) {
 		state |= BMAP_RIGHT_VALID;
 		xfs_bmbt_get_all(xfs_iext_get_ext(ifp, *idx + 1), &RIGHT);
 		if (isnullstartblock(RIGHT.br_startblock))
@@ -2836,7 +2836,7 @@ xfs_bmap_add_extent_hole_delay(
 	 * Check and set flags if the current (right) segment exists.
 	 * If it doesn't exist, we're converting the hole at end-of-file.
 	 */
-	if (*idx < ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t)) {
+	if (*idx < xfs_iext_count(ifp)) {
 		state |= BMAP_RIGHT_VALID;
 		xfs_bmbt_get_all(xfs_iext_get_ext(ifp, *idx), &right);
 
@@ -2966,7 +2966,7 @@ xfs_bmap_add_extent_hole_real(
 	ifp = XFS_IFORK_PTR(bma->ip, whichfork);
 
 	ASSERT(bma->idx >= 0);
-	ASSERT(bma->idx <= ifp->if_bytes / sizeof(struct xfs_bmbt_rec));
+	ASSERT(bma->idx <= xfs_iext_count(ifp));
 	ASSERT(!isnullstartblock(new->br_startblock));
 	ASSERT(!bma->cur ||
 	       !(bma->cur->bc_private.b.flags & XFS_BTCUR_BPRV_WASDEL));
@@ -2992,7 +2992,7 @@ xfs_bmap_add_extent_hole_real(
 	 * Check and set flags if this segment has a current value.
 	 * Not true if we're inserting into the "hole" at eof.
 	 */
-	if (bma->idx < ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t)) {
+	if (bma->idx < xfs_iext_count(ifp)) {
 		state |= BMAP_RIGHT_VALID;
 		xfs_bmbt_get_all(xfs_iext_get_ext(ifp, bma->idx), &right);
 		if (isnullstartblock(right.br_startblock))
@@ -4221,7 +4221,7 @@ xfs_bmapi_read(
 			break;
 
 		/* Else go on to the next record. */
-		if (++lastx < ifp->if_bytes / sizeof(xfs_bmbt_rec_t))
+		if (++lastx < xfs_iext_count(ifp))
 			xfs_bmbt_get_all(xfs_iext_get_ext(ifp, lastx), &got);
 		else
 			eof = 1;
@@ -4733,7 +4733,7 @@ xfs_bmapi_write(
 
 		/* Else go on to the next record. */
 		bma.prev = bma.got;
-		if (++bma.idx < ifp->if_bytes / sizeof(xfs_bmbt_rec_t)) {
+		if (++bma.idx < xfs_iext_count(ifp)) {
 			xfs_bmbt_get_all(xfs_iext_get_ext(ifp, bma.idx),
 					 &bma.got);
 		} else
@@ -4885,7 +4885,7 @@ xfs_bmap_del_extent_delay(
 	da_new = 0;
 
 	ASSERT(*idx >= 0);
-	ASSERT(*idx < ifp->if_bytes / sizeof(struct xfs_bmbt_rec));
+	ASSERT(*idx <= xfs_iext_count(ifp));
 	ASSERT(del->br_blockcount > 0);
 	ASSERT(got->br_startoff <= del->br_startoff);
 	ASSERT(got_endoff >= del_endoff);
@@ -5016,7 +5016,7 @@ xfs_bmap_del_extent_cow(
 	got_endoff = got->br_startoff + got->br_blockcount;
 
 	ASSERT(*idx >= 0);
-	ASSERT(*idx < ifp->if_bytes / sizeof(struct xfs_bmbt_rec));
+	ASSERT(*idx <= xfs_iext_count(ifp));
 	ASSERT(del->br_blockcount > 0);
 	ASSERT(got->br_startoff <= del->br_startoff);
 	ASSERT(got_endoff >= del_endoff);
@@ -5122,8 +5122,7 @@ xfs_bmap_del_extent(
 		state |= BMAP_COWFORK;
 
 	ifp = XFS_IFORK_PTR(ip, whichfork);
-	ASSERT((*idx >= 0) && (*idx < ifp->if_bytes /
-		(uint)sizeof(xfs_bmbt_rec_t)));
+	ASSERT((*idx >= 0) && (*idx < xfs_iext_count(ifp)));
 	ASSERT(del->br_blockcount > 0);
 	ep = xfs_iext_get_ext(ifp, *idx);
 	xfs_bmbt_get_all(ep, &got);
@@ -5448,7 +5447,6 @@ __xfs_bunmapi(
 	int			logflags;	/* transaction logging flags */
 	xfs_extlen_t		mod;		/* rt extent offset */
 	xfs_mount_t		*mp;		/* mount structure */
-	xfs_extnum_t		nextents;	/* number of file extents */
 	xfs_bmbt_irec_t		prev;		/* previous extent record */
 	xfs_fileoff_t		start;		/* first file offset deleted */
 	int			tmp_logflags;	/* partial logging flags */
@@ -5480,8 +5478,7 @@ __xfs_bunmapi(
 	if (!(ifp->if_flags & XFS_IFEXTENTS) &&
 	    (error = xfs_iread_extents(tp, ip, whichfork)))
 		return error;
-	nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
-	if (nextents == 0) {
+	if (xfs_iext_count(ifp) == 0) {
 		*rlen = 0;
 		return 0;
 	}
@@ -5966,7 +5963,7 @@ xfs_bmse_shift_one(
 
 	mp = ip->i_mount;
 	ifp = XFS_IFORK_PTR(ip, whichfork);
-	total_extents = ifp->if_bytes / sizeof(xfs_bmbt_rec_t);
+	total_extents = xfs_iext_count(ifp);
 
 	xfs_bmbt_get_all(gotp, &got);
 
@@ -6143,7 +6140,7 @@ xfs_bmap_shift_extents(
 	 * are collapsing out, so we cannot use the count of real extents here.
 	 * Instead we have to calculate it from the incore fork.
 	 */
-	total_extents = ifp->if_bytes / sizeof(xfs_bmbt_rec_t);
+	total_extents = xfs_iext_count(ifp);
 	if (total_extents == 0) {
 		*done = 1;
 		goto del_cursor;
@@ -6203,7 +6200,7 @@ xfs_bmap_shift_extents(
 		 * count can change. Update the total and grade the next record.
 		 */
 		if (direction == SHIFT_LEFT) {
-			total_extents = ifp->if_bytes / sizeof(xfs_bmbt_rec_t);
+			total_extents = xfs_iext_count(ifp);
 			stop_extent = total_extents;
 		}
 
--- a/fs/xfs/libxfs/xfs_inode_fork.c
+++ b/fs/xfs/libxfs/xfs_inode_fork.c
@@ -775,6 +775,13 @@ xfs_idestroy_fork(
 	}
 }
 
+/* Count number of incore extents based on if_bytes */
+xfs_extnum_t
+xfs_iext_count(struct xfs_ifork *ifp)
+{
+	return ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
+}
+
 /*
  * Convert in-core extents to on-disk form
  *
@@ -803,7 +810,7 @@ xfs_iextents_copy(
 	ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED));
 	ASSERT(ifp->if_bytes > 0);
 
-	nrecs = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
+	nrecs = xfs_iext_count(ifp);
 	XFS_BMAP_TRACE_EXLIST(ip, nrecs, whichfork);
 	ASSERT(nrecs > 0);
 
@@ -941,7 +948,7 @@ xfs_iext_get_ext(
 	xfs_extnum_t	idx)		/* index of target extent */
 {
 	ASSERT(idx >= 0);
-	ASSERT(idx < ifp->if_bytes / sizeof(xfs_bmbt_rec_t));
+	ASSERT(idx < xfs_iext_count(ifp));
 
 	if ((ifp->if_flags & XFS_IFEXTIREC) && (idx == 0)) {
 		return ifp->if_u1.if_ext_irec->er_extbuf;
@@ -1017,7 +1024,7 @@ xfs_iext_add(
 	int		new_size;	/* size of extents after adding */
 	xfs_extnum_t	nextents;	/* number of extents in file */
 
-	nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
+	nextents = xfs_iext_count(ifp);
 	ASSERT((idx >= 0) && (idx <= nextents));
 	byte_diff = ext_diff * sizeof(xfs_bmbt_rec_t);
 	new_size = ifp->if_bytes + byte_diff;
@@ -1241,7 +1248,7 @@ xfs_iext_remove(
 	trace_xfs_iext_remove(ip, idx, state, _RET_IP_);
 
 	ASSERT(ext_diff > 0);
-	nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
+	nextents = xfs_iext_count(ifp);
 	new_size = (nextents - ext_diff) * sizeof(xfs_bmbt_rec_t);
 
 	if (new_size == 0) {
@@ -1270,7 +1277,7 @@ xfs_iext_remove_inline(
 
 	ASSERT(!(ifp->if_flags & XFS_IFEXTIREC));
 	ASSERT(idx < XFS_INLINE_EXTS);
-	nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
+	nextents = xfs_iext_count(ifp);
 	ASSERT(((nextents - ext_diff) > 0) &&
 		(nextents - ext_diff) < XFS_INLINE_EXTS);
 
@@ -1309,7 +1316,7 @@ xfs_iext_remove_direct(
 	ASSERT(!(ifp->if_flags & XFS_IFEXTIREC));
 	new_size = ifp->if_bytes -
 		(ext_diff * sizeof(xfs_bmbt_rec_t));
-	nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
+	nextents = xfs_iext_count(ifp);
 
 	if (new_size == 0) {
 		xfs_iext_destroy(ifp);
@@ -1546,7 +1553,7 @@ xfs_iext_indirect_to_direct(
 	int		size;		/* size of file extents */
 
 	ASSERT(ifp->if_flags & XFS_IFEXTIREC);
-	nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
+	nextents = xfs_iext_count(ifp);
 	ASSERT(nextents <= XFS_LINEAR_EXTS);
 	size = nextents * sizeof(xfs_bmbt_rec_t);
 
@@ -1620,7 +1627,7 @@ xfs_iext_bno_to_ext(
 	xfs_extnum_t	nextents;	/* number of file extents */
 	xfs_fileoff_t	startoff = 0;	/* start offset of extent */
 
-	nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
+	nextents = xfs_iext_count(ifp);
 	if (nextents == 0) {
 		*idxp = 0;
 		return NULL;
@@ -1733,8 +1740,8 @@ xfs_iext_idx_to_irec(
 
 	ASSERT(ifp->if_flags & XFS_IFEXTIREC);
 	ASSERT(page_idx >= 0);
-	ASSERT(page_idx <= ifp->if_bytes / sizeof(xfs_bmbt_rec_t));
-	ASSERT(page_idx < ifp->if_bytes / sizeof(xfs_bmbt_rec_t) || realloc);
+	ASSERT(page_idx <= xfs_iext_count(ifp));
+	ASSERT(page_idx < xfs_iext_count(ifp) || realloc);
 
 	nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ;
 	erp_idx = 0;
@@ -1782,7 +1789,7 @@ xfs_iext_irec_init(
 	xfs_extnum_t	nextents;	/* number of extents in file */
 
 	ASSERT(!(ifp->if_flags & XFS_IFEXTIREC));
-	nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
+	nextents = xfs_iext_count(ifp);
 	ASSERT(nextents <= XFS_LINEAR_EXTS);
 
 	erp = kmem_alloc(sizeof(xfs_ext_irec_t), KM_NOFS);
@@ -1906,7 +1913,7 @@ xfs_iext_irec_compact(
 
 	ASSERT(ifp->if_flags & XFS_IFEXTIREC);
 	nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ;
-	nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
+	nextents = xfs_iext_count(ifp);
 
 	if (nextents == 0) {
 		xfs_iext_destroy(ifp);
--- a/fs/xfs/libxfs/xfs_inode_fork.h
+++ b/fs/xfs/libxfs/xfs_inode_fork.h
@@ -152,6 +152,7 @@ void		xfs_init_local_fork(struct xfs_ino
 
 struct xfs_bmbt_rec_host *
 		xfs_iext_get_ext(struct xfs_ifork *, xfs_extnum_t);
+xfs_extnum_t	xfs_iext_count(struct xfs_ifork *);
 void		xfs_iext_insert(struct xfs_inode *, xfs_extnum_t, xfs_extnum_t,
 				struct xfs_bmbt_irec *, int);
 void		xfs_iext_add(struct xfs_ifork *, xfs_extnum_t, int);
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -359,9 +359,7 @@ xfs_bmap_count_blocks(
 	mp = ip->i_mount;
 	ifp = XFS_IFORK_PTR(ip, whichfork);
 	if ( XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_EXTENTS ) {
-		xfs_bmap_count_leaves(ifp, 0,
-			ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t),
-			count);
+		xfs_bmap_count_leaves(ifp, 0, xfs_iext_count(ifp), count);
 		return 0;
 	}
 
@@ -426,7 +424,7 @@ xfs_getbmapx_fix_eof_hole(
 		ifp = XFS_IFORK_PTR(ip, whichfork);
 		if (!moretocome &&
 		    xfs_iext_bno_to_ext(ifp, fileblock, &lastx) &&
-		   (lastx == (ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t))-1))
+		   (lastx == xfs_iext_count(ifp) - 1))
 			out->bmv_oflags |= BMV_OF_LAST;
 	}
 
@@ -1878,15 +1876,13 @@ xfs_swap_extent_forks(
 
 	switch (ip->i_d.di_format) {
 	case XFS_DINODE_FMT_EXTENTS:
-		/* If the extents fit in the inode, fix the
-		 * pointer.  Otherwise it's already NULL or
-		 * pointing to the extent.
+		/*
+		 * If the extents fit in the inode, fix the pointer.  Otherwise
+		 * it's already NULL or pointing to the extent.
 		 */
-		nextents = ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
-		if (nextents <= XFS_INLINE_EXTS) {
-			ifp->if_u1.if_extents =
-				ifp->if_u2.if_inline_ext;
-		}
+		nextents = xfs_iext_count(&ip->i_df);
+		if (nextents <= XFS_INLINE_EXTS)
+			ifp->if_u1.if_extents = ifp->if_u2.if_inline_ext;
 		(*src_log_flags) |= XFS_ILOG_DEXT;
 		break;
 	case XFS_DINODE_FMT_BTREE:
@@ -1898,15 +1894,13 @@ xfs_swap_extent_forks(
 
 	switch (tip->i_d.di_format) {
 	case XFS_DINODE_FMT_EXTENTS:
-		/* If the extents fit in the inode, fix the
-		 * pointer.  Otherwise it's already NULL or
-		 * pointing to the extent.
+		/*
+		 * If the extents fit in the inode, fix the pointer.  Otherwise
+		 * it's already NULL or pointing to the extent.
 		 */
-		nextents = tip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
-		if (nextents <= XFS_INLINE_EXTS) {
-			tifp->if_u1.if_extents =
-				tifp->if_u2.if_inline_ext;
-		}
+		nextents = xfs_iext_count(&tip->i_df);
+		if (nextents <= XFS_INLINE_EXTS)
+			tifp->if_u1.if_extents = tifp->if_u2.if_inline_ext;
 		(*target_log_flags) |= XFS_ILOG_DEXT;
 		break;
 	case XFS_DINODE_FMT_BTREE:
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -164,7 +164,7 @@ xfs_inode_item_format_data_fork(
 			struct xfs_bmbt_rec *p;
 
 			ASSERT(ip->i_df.if_u1.if_extents != NULL);
-			ASSERT(ip->i_df.if_bytes / sizeof(xfs_bmbt_rec_t) > 0);
+			ASSERT(xfs_iext_count(&ip->i_df) > 0);
 
 			p = xlog_prepare_iovec(lv, vecp, XLOG_REG_TYPE_IEXT);
 			data_bytes = xfs_iextents_copy(ip, p, XFS_DATA_FORK);
@@ -261,7 +261,7 @@ xfs_inode_item_format_attr_fork(
 		    ip->i_afp->if_bytes > 0) {
 			struct xfs_bmbt_rec *p;
 
-			ASSERT(ip->i_afp->if_bytes / sizeof(xfs_bmbt_rec_t) ==
+			ASSERT(xfs_iext_count(ip->i_afp) ==
 				ip->i_d.di_anextents);
 			ASSERT(ip->i_afp->if_u1.if_extents != NULL);
 
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -910,16 +910,14 @@ xfs_ioc_fsgetxattr(
 	if (attr) {
 		if (ip->i_afp) {
 			if (ip->i_afp->if_flags & XFS_IFEXTENTS)
-				fa.fsx_nextents = ip->i_afp->if_bytes /
-							sizeof(xfs_bmbt_rec_t);
+				fa.fsx_nextents = xfs_iext_count(ip->i_afp);
 			else
 				fa.fsx_nextents = ip->i_d.di_anextents;
 		} else
 			fa.fsx_nextents = 0;
 	} else {
 		if (ip->i_df.if_flags & XFS_IFEXTENTS)
-			fa.fsx_nextents = ip->i_df.if_bytes /
-						sizeof(xfs_bmbt_rec_t);
+			fa.fsx_nextents = xfs_iext_count(&ip->i_df);
 		else
 			fa.fsx_nextents = ip->i_d.di_nextents;
 	}
--- a/fs/xfs/xfs_qm.c
+++ b/fs/xfs/xfs_qm.c
@@ -1135,7 +1135,7 @@ xfs_qm_get_rtblks(
 			return error;
 	}
 	rtblks = 0;
-	nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
+	nextents = xfs_iext_count(ifp);
 	for (idx = 0; idx < nextents; idx++)
 		rtblks += xfs_bmbt_get_blockcount(xfs_iext_get_ext(ifp, idx));
 	*O_rtblks = (xfs_qcnt_t)rtblks;
--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
@@ -486,7 +486,7 @@ xfs_reflink_trim_irec_to_next_cow(
 	/* This is the extent before; try sliding up one. */
 	if (irec.br_startoff < offset_fsb) {
 		idx++;
-		if (idx >= ifp->if_bytes / sizeof(xfs_bmbt_rec_t))
+		if (idx >= xfs_iext_count(ifp))
 			return 0;
 		gotp = xfs_iext_get_ext(ifp, idx);
 		xfs_bmbt_get_all(gotp, &irec);
@@ -566,7 +566,7 @@ xfs_reflink_cancel_cow_blocks(
 			xfs_bmap_del_extent_cow(ip, &idx, &got, &del);
 		}
 
-		if (++idx >= ifp->if_bytes / sizeof(struct xfs_bmbt_rec))
+		if (++idx >= xfs_iext_count(ifp))
 			break;
 		xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx), &got);
 	}

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 178/206] xfs: check minimum block size for CRC filesystems
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (158 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 177/206] xfs: provide helper for counting extents from if_bytes Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 179/206] xfs: fix unbalanced inode reclaim flush locking Greg Kroah-Hartman
                     ` (29 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Greg Kroah-Hartman, Darrick J. Wong, Dave Chinner, Dave Chinner,
	Christoph Hellwig

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------


From: "Darrick J. Wong" <darrick.wong@oracle.com>

commit bec9d48d7a303a5bb95c05961ff07ec7eeb59058 upstream.

Check the minimum block size on v5 filesystems.

[dchinner: cleaned up XFS_MIN_CRC_BLOCKSIZE check]

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/xfs/libxfs/xfs_sb.c    |    6 ++++++
 fs/xfs/libxfs/xfs_types.h |    3 +++
 2 files changed, 9 insertions(+)

--- a/fs/xfs/libxfs/xfs_sb.c
+++ b/fs/xfs/libxfs/xfs_sb.c
@@ -262,6 +262,12 @@ xfs_mount_validate_sb(
 		return -EFSCORRUPTED;
 	}
 
+	if (xfs_sb_version_hascrc(&mp->m_sb) &&
+	    sbp->sb_blocksize < XFS_MIN_CRC_BLOCKSIZE) {
+		xfs_notice(mp, "v5 SB sanity check failed");
+		return -EFSCORRUPTED;
+	}
+
 	/*
 	 * Until this is fixed only page-sized or smaller data blocks work.
 	 */
--- a/fs/xfs/libxfs/xfs_types.h
+++ b/fs/xfs/libxfs/xfs_types.h
@@ -75,11 +75,14 @@ typedef __int64_t	xfs_sfiloff_t;	/* sign
  * Minimum and maximum blocksize and sectorsize.
  * The blocksize upper limit is pretty much arbitrary.
  * The sectorsize upper limit is due to sizeof(sb_sectsize).
+ * CRC enable filesystems use 512 byte inodes, meaning 512 byte block sizes
+ * cannot be used.
  */
 #define XFS_MIN_BLOCKSIZE_LOG	9	/* i.e. 512 bytes */
 #define XFS_MAX_BLOCKSIZE_LOG	16	/* i.e. 65536 bytes */
 #define XFS_MIN_BLOCKSIZE	(1 << XFS_MIN_BLOCKSIZE_LOG)
 #define XFS_MAX_BLOCKSIZE	(1 << XFS_MAX_BLOCKSIZE_LOG)
+#define XFS_MIN_CRC_BLOCKSIZE	(1 << (XFS_MIN_BLOCKSIZE_LOG + 1))
 #define XFS_MIN_SECTORSIZE_LOG	9	/* i.e. 512 bytes */
 #define XFS_MAX_SECTORSIZE_LOG	15	/* i.e. 32768 bytes */
 #define XFS_MIN_SECTORSIZE	(1 << XFS_MIN_SECTORSIZE_LOG)

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 179/206] xfs: fix unbalanced inode reclaim flush locking
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (159 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 178/206] xfs: check minimum block size for CRC filesystems Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 180/206] xfs: new inode extent list lookup helpers Greg Kroah-Hartman
                     ` (28 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Greg Kroah-Hartman, Zorro Lang, Brian Foster, Dave Chinner,
	Dave Chinner, Christoph Hellwig

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------


From: Brian Foster <bfoster@redhat.com>

commit 98efe8af1c9ffac47e842b7a75ded903e2f028da upstream.

Filesystem shutdown testing on an older distro kernel has uncovered an
imbalanced locking pattern for the inode flush lock in
xfs_reclaim_inode(). Specifically, there is a double unlock sequence
between the call to xfs_iflush_abort() and xfs_reclaim_inode() at the
"reclaim:" label.

This actually does not cause obvious problems on current kernels due to
the current flush lock implementation. Older kernels use a counting
based flush lock mechanism, however, which effectively breaks the lock
indefinitely when an already unlocked flush lock is repeatedly unlocked.
Though this only currently occurs on filesystem shutdown, it has
reproduced the effect of elevating an fs shutdown to a system-wide crash
or hang.

As it turns out, the flush lock is not actually required for the reclaim
logic in xfs_reclaim_inode() because by that time we have already cycled
the flush lock once while holding ILOCK_EXCL. Therefore, remove the
additional flush lock/unlock cycle around the 'reclaim:' label and
update branches into this label to release the flush lock where
appropriate. Add an assert to xfs_ifunlock() to help prevent future
occurences of the same problem.

Reported-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/xfs/xfs_icache.c |   27 ++++++++++++++-------------
 fs/xfs/xfs_inode.h  |   11 ++++++-----
 2 files changed, 20 insertions(+), 18 deletions(-)

--- a/fs/xfs/xfs_icache.c
+++ b/fs/xfs/xfs_icache.c
@@ -123,7 +123,6 @@ __xfs_inode_free(
 {
 	/* asserts to verify all state is correct here */
 	ASSERT(atomic_read(&ip->i_pincount) == 0);
-	ASSERT(!xfs_isiflocked(ip));
 	XFS_STATS_DEC(ip->i_mount, vn_active);
 
 	call_rcu(&VFS_I(ip)->i_rcu, xfs_inode_free_callback);
@@ -133,6 +132,8 @@ void
 xfs_inode_free(
 	struct xfs_inode	*ip)
 {
+	ASSERT(!xfs_isiflocked(ip));
+
 	/*
 	 * Because we use RCU freeing we need to ensure the inode always
 	 * appears to be reclaimed with an invalid inode number when in the
@@ -981,6 +982,7 @@ restart:
 
 	if (XFS_FORCED_SHUTDOWN(ip->i_mount)) {
 		xfs_iunpin_wait(ip);
+		/* xfs_iflush_abort() drops the flush lock */
 		xfs_iflush_abort(ip, false);
 		goto reclaim;
 	}
@@ -989,10 +991,10 @@ restart:
 			goto out_ifunlock;
 		xfs_iunpin_wait(ip);
 	}
-	if (xfs_iflags_test(ip, XFS_ISTALE))
-		goto reclaim;
-	if (xfs_inode_clean(ip))
+	if (xfs_iflags_test(ip, XFS_ISTALE) || xfs_inode_clean(ip)) {
+		xfs_ifunlock(ip);
 		goto reclaim;
+	}
 
 	/*
 	 * Never flush out dirty data during non-blocking reclaim, as it would
@@ -1030,25 +1032,24 @@ restart:
 		xfs_buf_relse(bp);
 	}
 
-	xfs_iflock(ip);
 reclaim:
+	ASSERT(!xfs_isiflocked(ip));
+
 	/*
 	 * Because we use RCU freeing we need to ensure the inode always appears
 	 * to be reclaimed with an invalid inode number when in the free state.
-	 * We do this as early as possible under the ILOCK and flush lock so
-	 * that xfs_iflush_cluster() can be guaranteed to detect races with us
-	 * here. By doing this, we guarantee that once xfs_iflush_cluster has
-	 * locked both the XFS_ILOCK and the flush lock that it will see either
-	 * a valid, flushable inode that will serialise correctly against the
-	 * locks below, or it will see a clean (and invalid) inode that it can
-	 * skip.
+	 * We do this as early as possible under the ILOCK so that
+	 * xfs_iflush_cluster() can be guaranteed to detect races with us here.
+	 * By doing this, we guarantee that once xfs_iflush_cluster has locked
+	 * XFS_ILOCK that it will see either a valid, flushable inode that will
+	 * serialise correctly, or it will see a clean (and invalid) inode that
+	 * it can skip.
 	 */
 	spin_lock(&ip->i_flags_lock);
 	ip->i_flags = XFS_IRECLAIM;
 	ip->i_ino = 0;
 	spin_unlock(&ip->i_flags_lock);
 
-	xfs_ifunlock(ip);
 	xfs_iunlock(ip, XFS_ILOCK_EXCL);
 
 	XFS_STATS_INC(ip->i_mount, xs_ig_reclaims);
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -246,6 +246,11 @@ static inline bool xfs_is_reflink_inode(
  * Synchronize processes attempting to flush the in-core inode back to disk.
  */
 
+static inline int xfs_isiflocked(struct xfs_inode *ip)
+{
+	return xfs_iflags_test(ip, XFS_IFLOCK);
+}
+
 extern void __xfs_iflock(struct xfs_inode *ip);
 
 static inline int xfs_iflock_nowait(struct xfs_inode *ip)
@@ -261,16 +266,12 @@ static inline void xfs_iflock(struct xfs
 
 static inline void xfs_ifunlock(struct xfs_inode *ip)
 {
+	ASSERT(xfs_isiflocked(ip));
 	xfs_iflags_clear(ip, XFS_IFLOCK);
 	smp_mb();
 	wake_up_bit(&ip->i_flags, __XFS_IFLOCK_BIT);
 }
 
-static inline int xfs_isiflocked(struct xfs_inode *ip)
-{
-	return xfs_iflags_test(ip, XFS_IFLOCK);
-}
-
 /*
  * Flags for inode locking.
  * Bit ranges:	1<<1  - 1<<16-1 -- iolock/ilock modes (bitfield)

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 180/206] xfs: new inode extent list lookup helpers
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (160 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 179/206] xfs: fix unbalanced inode reclaim flush locking Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 181/206] xfs: factor rmap btree size into the indlen calculations Greg Kroah-Hartman
                     ` (27 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Greg Kroah-Hartman, linux-xfs@vger.kernel.org, Dave Chinner,
	Christoph Hellwig, Brian Foster, Dave Chinner

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------


commit 93533c7855c3c78c8a900cac65c8d669bb14935d upstream.

xfs_iext_lookup_extent looks up a single extent at the passed in offset,
and returns the extent covering the area, or the one behind it in case
of a hole, as well as the index of the returned extent in arguments,
as well as a simple bool as return value that is set to false if no
extent could be found because the offset is behind EOF.  It is a simpler
replacement for xfs_bmap_search_extent that leaves looking up the rarely
needed previous extent to the caller and has a nicer calling convention.

xfs_iext_get_extent is a helper for iterating over the extent list,
it takes an extent index as input, and returns the extent at that index
in it's expanded form in an argument if it exists.  The actual return
value is a bool whether the index is valid or not.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/xfs/libxfs/xfs_inode_fork.c |   46 +++++++++++++++++++++++++++++++++++++++++
 fs/xfs/libxfs/xfs_inode_fork.h |    6 +++++
 2 files changed, 52 insertions(+)

--- a/fs/xfs/libxfs/xfs_inode_fork.c
+++ b/fs/xfs/libxfs/xfs_inode_fork.c
@@ -2003,3 +2003,49 @@ xfs_ifork_init_cow(
 	ip->i_cformat = XFS_DINODE_FMT_EXTENTS;
 	ip->i_cnextents = 0;
 }
+
+/*
+ * Lookup the extent covering bno.
+ *
+ * If there is an extent covering bno return the extent index, and store the
+ * expanded extent structure in *gotp, and the extent index in *idx.
+ * If there is no extent covering bno, but there is an extent after it (e.g.
+ * it lies in a hole) return that extent in *gotp and its index in *idx
+ * instead.
+ * If bno is beyond the last extent return false, and return the index after
+ * the last valid index in *idxp.
+ */
+bool
+xfs_iext_lookup_extent(
+	struct xfs_inode	*ip,
+	struct xfs_ifork	*ifp,
+	xfs_fileoff_t		bno,
+	xfs_extnum_t		*idxp,
+	struct xfs_bmbt_irec	*gotp)
+{
+	struct xfs_bmbt_rec_host *ep;
+
+	XFS_STATS_INC(ip->i_mount, xs_look_exlist);
+
+	ep = xfs_iext_bno_to_ext(ifp, bno, idxp);
+	if (!ep)
+		return false;
+	xfs_bmbt_get_all(ep, gotp);
+	return true;
+}
+
+/*
+ * Return true if there is an extent at index idx, and return the expanded
+ * extent structure at idx in that case.  Else return false.
+ */
+bool
+xfs_iext_get_extent(
+	struct xfs_ifork	*ifp,
+	xfs_extnum_t		idx,
+	struct xfs_bmbt_irec	*gotp)
+{
+	if (idx < 0 || idx >= xfs_iext_count(ifp))
+		return false;
+	xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx), gotp);
+	return true;
+}
--- a/fs/xfs/libxfs/xfs_inode_fork.h
+++ b/fs/xfs/libxfs/xfs_inode_fork.h
@@ -182,6 +182,12 @@ void		xfs_iext_irec_compact_pages(struct
 void		xfs_iext_irec_compact_full(struct xfs_ifork *);
 void		xfs_iext_irec_update_extoffs(struct xfs_ifork *, int, int);
 
+bool		xfs_iext_lookup_extent(struct xfs_inode *ip,
+			struct xfs_ifork *ifp, xfs_fileoff_t bno,
+			xfs_extnum_t *idxp, struct xfs_bmbt_irec *gotp);
+bool		xfs_iext_get_extent(struct xfs_ifork *ifp, xfs_extnum_t idx,
+			struct xfs_bmbt_irec *gotp);
+
 extern struct kmem_zone	*xfs_ifork_zone;
 
 extern void xfs_ifork_init_cow(struct xfs_inode *ip);

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 181/206] xfs: factor rmap btree size into the indlen calculations
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (161 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 180/206] xfs: new inode extent list lookup helpers Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 182/206] xfs: always succeed when deduping zero bytes Greg Kroah-Hartman
                     ` (26 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Greg Kroah-Hartman, Eryu Guan, Darrick J. Wong, Dave Chinner,
	Dave Chinner, Christoph Hellwig

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------


From: "Darrick J. Wong" <darrick.wong@oracle.com>

commit fd26a88093bab6529ea2de819114ca92dbd1d71d upstream.

When we're estimating the amount of space it's going to take to satisfy
a delalloc reservation, we need to include the space that we might need
to grow the rmapbt.  This helps us to avoid running out of space later
when _iomap_write_allocate needs more space than we reserved.  Eryu Guan
observed this happening on generic/224 when sunit/swidth were set.

Reported-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/xfs/libxfs/xfs_bmap.c |   17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -49,6 +49,7 @@
 #include "xfs_rmap.h"
 #include "xfs_ag_resv.h"
 #include "xfs_refcount.h"
+#include "xfs_rmap_btree.h"
 
 
 kmem_zone_t		*xfs_bmap_free_item_zone;
@@ -190,8 +191,12 @@ xfs_bmap_worst_indlen(
 	int		maxrecs;	/* maximum record count at this level */
 	xfs_mount_t	*mp;		/* mount structure */
 	xfs_filblks_t	rval;		/* return value */
+	xfs_filblks_t   orig_len;
 
 	mp = ip->i_mount;
+
+	/* Calculate the worst-case size of the bmbt. */
+	orig_len = len;
 	maxrecs = mp->m_bmap_dmxr[0];
 	for (level = 0, rval = 0;
 	     level < XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK);
@@ -199,12 +204,20 @@ xfs_bmap_worst_indlen(
 		len += maxrecs - 1;
 		do_div(len, maxrecs);
 		rval += len;
-		if (len == 1)
-			return rval + XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) -
+		if (len == 1) {
+			rval += XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) -
 				level - 1;
+			break;
+		}
 		if (level == 0)
 			maxrecs = mp->m_bmap_dmxr[1];
 	}
+
+	/* Calculate the worst-case size of the rmapbt. */
+	if (xfs_sb_version_hasrmapbt(&mp->m_sb))
+		rval += 1 + xfs_rmapbt_calc_size(mp, orig_len) +
+				mp->m_rmap_maxlevels;
+
 	return rval;
 }
 

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 182/206] xfs: always succeed when deduping zero bytes
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (162 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 181/206] xfs: factor rmap btree size into the indlen calculations Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 183/206] xfs: remove prev argument to xfs_bmapi_reserve_delalloc Greg Kroah-Hartman
                     ` (25 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Greg Kroah-Hartman, Darrick J. Wong, Dave Chinner, Dave Chinner,
	Christoph Hellwig

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------


From: "Darrick J. Wong" <darrick.wong@oracle.com>

commit fba3e594ef0ad911fa8f559732d588172f212d71 upstream.

It turns out that btrfs and xfs had differing interpretations of what
to do when the dedupe length is zero.  Change xfs to follow btrfs'
semantics so that the userland interface is consistent.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/xfs/xfs_reflink.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
@@ -1345,8 +1345,14 @@ xfs_reflink_remap_range(
 		goto out_unlock;
 	}
 
-	if (len == 0)
+	/* Zero length dedupe exits immediately; reflink goes to EOF. */
+	if (len == 0) {
+		if (is_dedupe) {
+			ret = 0;
+			goto out_unlock;
+		}
 		len = isize - pos_in;
+	}
 
 	/* Ensure offsets don't wrap and the input is inside i_size */
 	if (pos_in + len < pos_in || pos_out + len < pos_out ||

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 183/206] xfs: remove prev argument to xfs_bmapi_reserve_delalloc
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (163 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 182/206] xfs: always succeed when deduping zero bytes Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 184/206] xfs: track preallocation separately in xfs_bmapi_reserve_delalloc() Greg Kroah-Hartman
                     ` (24 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Greg Kroah-Hartman, linux-xfs@vger.kernel.org, Dave Chinner,
	Christoph Hellwig, Brian Foster, Dave Chinner

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------


commit 65c5f419788d623a0410eca1866134f5e4628594 upstream.

We can easily lookup the previous extent for the cases where we need it,
which saves the callers from looking it up for us later in the series.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/xfs/libxfs/xfs_bmap.c |    8 ++++++--
 fs/xfs/libxfs/xfs_bmap.h |    3 +--
 fs/xfs/xfs_iomap.c       |    3 +--
 fs/xfs/xfs_reflink.c     |    2 +-
 4 files changed, 9 insertions(+), 7 deletions(-)

--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -4250,7 +4250,6 @@ xfs_bmapi_reserve_delalloc(
 	xfs_fileoff_t		aoff,
 	xfs_filblks_t		len,
 	struct xfs_bmbt_irec	*got,
-	struct xfs_bmbt_irec	*prev,
 	xfs_extnum_t		*lastx,
 	int			eof)
 {
@@ -4272,7 +4271,12 @@ xfs_bmapi_reserve_delalloc(
 	else
 		extsz = xfs_get_extsz_hint(ip);
 	if (extsz) {
-		error = xfs_bmap_extsize_align(mp, got, prev, extsz, rt, eof,
+		struct xfs_bmbt_irec	prev;
+
+		if (!xfs_iext_get_extent(ifp, *lastx - 1, &prev))
+			prev.br_startoff = NULLFILEOFF;
+
+		error = xfs_bmap_extsize_align(mp, got, &prev, extsz, rt, eof,
 					       1, 0, &aoff, &alen);
 		ASSERT(!error);
 	}
--- a/fs/xfs/libxfs/xfs_bmap.h
+++ b/fs/xfs/libxfs/xfs_bmap.h
@@ -243,8 +243,7 @@ struct xfs_bmbt_rec_host *
 		struct xfs_bmbt_irec *gotp, struct xfs_bmbt_irec *prevp);
 int	xfs_bmapi_reserve_delalloc(struct xfs_inode *ip, int whichfork,
 		xfs_fileoff_t aoff, xfs_filblks_t len,
-		struct xfs_bmbt_irec *got, struct xfs_bmbt_irec *prev,
-		xfs_extnum_t *lastx, int eof);
+		struct xfs_bmbt_irec *got, xfs_extnum_t *lastx, int eof);
 
 enum xfs_bmap_intent_type {
 	XFS_BMAP_MAP = 1,
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -622,8 +622,7 @@ xfs_file_iomap_begin_delay(
 
 retry:
 	error = xfs_bmapi_reserve_delalloc(ip, XFS_DATA_FORK, offset_fsb,
-			end_fsb - offset_fsb, &got,
-			&prev, &idx, eof);
+			end_fsb - offset_fsb, &got, &idx, eof);
 	switch (error) {
 	case 0:
 		break;
--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
@@ -293,7 +293,7 @@ xfs_reflink_reserve_cow(
 
 retry:
 	error = xfs_bmapi_reserve_delalloc(ip, XFS_COW_FORK, imap->br_startoff,
-			end_fsb - imap->br_startoff, &got, &prev, &idx, eof);
+			end_fsb - imap->br_startoff, &got, &idx, eof);
 	switch (error) {
 	case 0:
 		break;

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 184/206] xfs: track preallocation separately in xfs_bmapi_reserve_delalloc()
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (164 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 183/206] xfs: remove prev argument to xfs_bmapi_reserve_delalloc Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 185/206] xfs: use new extent lookup helpers in __xfs_reflink_reserve_cow Greg Kroah-Hartman
                     ` (23 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Greg Kroah-Hartman, Brian Foster, Dave Chinner, Dave Chinner,
	Christoph Hellwig

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------


From: Brian Foster <bfoster@redhat.com>

commit 974ae922efd93b07b6cdf989ae959883f6f05fd8 upstream.

Speculative preallocation is currently processed entirely by the callers
of xfs_bmapi_reserve_delalloc(). The caller determines how much
preallocation to include, adjusts the extent length and passes down the
resulting request.

While this works fine for post-eof speculative preallocation, it is not
as reliable for COW fork preallocation. COW fork preallocation is
implemented via the cowextszhint, which aligns the start offset as well
as the length of the extent. Further, it is difficult for the caller to
accurately identify when preallocation occurs because the returned
extent could have been merged with neighboring extents in the fork.

To simplify this situation and facilitate further COW fork preallocation
enhancements, update xfs_bmapi_reserve_delalloc() to take a separate
preallocation parameter to incorporate into the allocation request. The
preallocation blocks value is tacked onto the end of the request and
adjusted to accommodate neighboring extents and extent size limits.
Since xfs_bmapi_reserve_delalloc() now knows precisely how much
preallocation was included in the allocation, it can also tag the inodes
appropriately to support preallocation reclaim.

Note that xfs_bmapi_reserve_delalloc() callers are not yet updated to
use the preallocation mechanism. This patch should not change behavior
outside of correctly tagging reflink inodes when start offset
preallocation occurs (which the caller does not handle correctly).

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/xfs/libxfs/xfs_bmap.c |   23 +++++++++++++++++++++--
 fs/xfs/libxfs/xfs_bmap.h |    2 +-
 fs/xfs/xfs_iomap.c       |    2 +-
 fs/xfs/xfs_reflink.c     |    2 +-
 4 files changed, 24 insertions(+), 5 deletions(-)

--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -50,6 +50,7 @@
 #include "xfs_ag_resv.h"
 #include "xfs_refcount.h"
 #include "xfs_rmap_btree.h"
+#include "xfs_icache.h"
 
 
 kmem_zone_t		*xfs_bmap_free_item_zone;
@@ -4247,8 +4248,9 @@ int
 xfs_bmapi_reserve_delalloc(
 	struct xfs_inode	*ip,
 	int			whichfork,
-	xfs_fileoff_t		aoff,
+	xfs_fileoff_t		off,
 	xfs_filblks_t		len,
+	xfs_filblks_t		prealloc,
 	struct xfs_bmbt_irec	*got,
 	xfs_extnum_t		*lastx,
 	int			eof)
@@ -4260,10 +4262,17 @@ xfs_bmapi_reserve_delalloc(
 	char			rt = XFS_IS_REALTIME_INODE(ip);
 	xfs_extlen_t		extsz;
 	int			error;
+	xfs_fileoff_t		aoff = off;
 
-	alen = XFS_FILBLKS_MIN(len, MAXEXTLEN);
+	/*
+	 * Cap the alloc length. Keep track of prealloc so we know whether to
+	 * tag the inode before we return.
+	 */
+	alen = XFS_FILBLKS_MIN(len + prealloc, MAXEXTLEN);
 	if (!eof)
 		alen = XFS_FILBLKS_MIN(alen, got->br_startoff - aoff);
+	if (prealloc && alen >= len)
+		prealloc = alen - len;
 
 	/* Figure out the extent size, adjust alen */
 	if (whichfork == XFS_COW_FORK)
@@ -4329,6 +4338,16 @@ xfs_bmapi_reserve_delalloc(
 	 */
 	xfs_bmbt_get_all(xfs_iext_get_ext(ifp, *lastx), got);
 
+	/*
+	 * Tag the inode if blocks were preallocated. Note that COW fork
+	 * preallocation can occur at the start or end of the extent, even when
+	 * prealloc == 0, so we must also check the aligned offset and length.
+	 */
+	if (whichfork == XFS_DATA_FORK && prealloc)
+		xfs_inode_set_eofblocks_tag(ip);
+	if (whichfork == XFS_COW_FORK && (prealloc || aoff < off || alen > len))
+		xfs_inode_set_cowblocks_tag(ip);
+
 	ASSERT(got->br_startoff <= aoff);
 	ASSERT(got->br_startoff + got->br_blockcount >= aoff + alen);
 	ASSERT(isnullstartblock(got->br_startblock));
--- a/fs/xfs/libxfs/xfs_bmap.h
+++ b/fs/xfs/libxfs/xfs_bmap.h
@@ -242,7 +242,7 @@ struct xfs_bmbt_rec_host *
 		int fork, int *eofp, xfs_extnum_t *lastxp,
 		struct xfs_bmbt_irec *gotp, struct xfs_bmbt_irec *prevp);
 int	xfs_bmapi_reserve_delalloc(struct xfs_inode *ip, int whichfork,
-		xfs_fileoff_t aoff, xfs_filblks_t len,
+		xfs_fileoff_t off, xfs_filblks_t len, xfs_filblks_t prealloc,
 		struct xfs_bmbt_irec *got, xfs_extnum_t *lastx, int eof);
 
 enum xfs_bmap_intent_type {
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -622,7 +622,7 @@ xfs_file_iomap_begin_delay(
 
 retry:
 	error = xfs_bmapi_reserve_delalloc(ip, XFS_DATA_FORK, offset_fsb,
-			end_fsb - offset_fsb, &got, &idx, eof);
+			end_fsb - offset_fsb, 0, &got, &idx, eof);
 	switch (error) {
 	case 0:
 		break;
--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
@@ -293,7 +293,7 @@ xfs_reflink_reserve_cow(
 
 retry:
 	error = xfs_bmapi_reserve_delalloc(ip, XFS_COW_FORK, imap->br_startoff,
-			end_fsb - imap->br_startoff, &got, &idx, eof);
+			end_fsb - imap->br_startoff, 0, &got, &idx, eof);
 	switch (error) {
 	case 0:
 		break;

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 185/206] xfs: use new extent lookup helpers in __xfs_reflink_reserve_cow
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (165 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 184/206] xfs: track preallocation separately in xfs_bmapi_reserve_delalloc() Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 186/206] xfs: clean up cow fork reservation and tag inodes correctly Greg Kroah-Hartman
                     ` (22 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Greg Kroah-Hartman, linux-xfs@vger.kernel.org, Dave Chinner,
	Christoph Hellwig, Brian Foster, Dave Chinner

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------


commit 2755fc4438501c8c28e7783df890e889f6772bee upstream.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/xfs/xfs_reflink.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
@@ -243,10 +243,11 @@ xfs_reflink_reserve_cow(
 	struct xfs_bmbt_irec	*imap,
 	bool			*shared)
 {
-	struct xfs_bmbt_irec	got, prev;
+	struct xfs_ifork	*ifp = XFS_IFORK_PTR(ip, XFS_COW_FORK);
+	struct xfs_bmbt_irec	got;
 	xfs_fileoff_t		end_fsb, orig_end_fsb;
-	int			eof = 0, error = 0;
-	bool			trimmed;
+	int			error = 0;
+	bool			eof = false, trimmed;
 	xfs_extnum_t		idx;
 	xfs_extlen_t		align;
 
@@ -258,8 +259,9 @@ xfs_reflink_reserve_cow(
 	 * extent list is generally faster than going out to the shared extent
 	 * tree.
 	 */
-	xfs_bmap_search_extents(ip, imap->br_startoff, XFS_COW_FORK, &eof, &idx,
-			&got, &prev);
+
+	if (!xfs_iext_lookup_extent(ip, ifp, imap->br_startoff, &idx, &got))
+		eof = true;
 	if (!eof && got.br_startoff <= imap->br_startoff) {
 		trace_xfs_reflink_cow_found(ip, imap);
 		xfs_trim_extent(imap, got.br_startoff, got.br_blockcount);

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 186/206] xfs: clean up cow fork reservation and tag inodes correctly
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (166 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 185/206] xfs: use new extent lookup helpers in __xfs_reflink_reserve_cow Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 187/206] xfs: use new extent lookup helpers xfs_file_iomap_begin_delay Greg Kroah-Hartman
                     ` (21 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Greg Kroah-Hartman, Brian Foster, Dave Chinner, Dave Chinner,
	Christoph Hellwig

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------


From: Brian Foster <bfoster@redhat.com>

commit 0260d8ff5f76617e3a55a1c471383ecb4404c3ad upstream.

COW fork reservation is implemented via delayed allocation. The code is
modeled after the traditional delalloc allocation code, but is slightly
different in terms of how preallocation occurs. Rather than post-eof
speculative preallocation, COW fork preallocation is implemented via a
COW extent size hint that is designed to minimize fragmentation as a
reflinked file is split over time.

xfs_reflink_reserve_cow() still uses logic that is oriented towards
dealing with post-eof speculative preallocation, however, and is stale
or not necessarily correct. First, the EOF alignment to the COW extent
size hint is implemented in xfs_bmapi_reserve_delalloc() (which does so
correctly by aligning the start and end offsets) and so is not necessary
in xfs_reflink_reserve_cow(). The backoff and retry logic on ENOSPC is
also ineffective for the same reason, as xfs_bmapi_reserve_delalloc()
will simply perform the same allocation request on the retry. Finally,
since the COW extent size hint aligns the start and end offset of the
range to allocate, the end_fsb != orig_end_fsb logic is not sufficient.
Indeed, if a write request happens to end on an aligned offset, it is
possible that we do not tag the inode for COW preallocation even though
xfs_bmapi_reserve_delalloc() may have preallocated at the start offset.

Kill the unnecessary, duplicate code in xfs_reflink_reserve_cow().
Remove the inode tag logic as well since xfs_bmapi_reserve_delalloc()
has been updated to tag the inode correctly.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/xfs/xfs_reflink.c |   29 +++--------------------------
 1 file changed, 3 insertions(+), 26 deletions(-)

--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
@@ -245,11 +245,9 @@ xfs_reflink_reserve_cow(
 {
 	struct xfs_ifork	*ifp = XFS_IFORK_PTR(ip, XFS_COW_FORK);
 	struct xfs_bmbt_irec	got;
-	xfs_fileoff_t		end_fsb, orig_end_fsb;
 	int			error = 0;
 	bool			eof = false, trimmed;
 	xfs_extnum_t		idx;
-	xfs_extlen_t		align;
 
 	/*
 	 * Search the COW fork extent list first.  This serves two purposes:
@@ -287,33 +285,12 @@ xfs_reflink_reserve_cow(
 	if (error)
 		return error;
 
-	end_fsb = orig_end_fsb = imap->br_startoff + imap->br_blockcount;
-
-	align = xfs_eof_alignment(ip, xfs_get_cowextsz_hint(ip));
-	if (align)
-		end_fsb = roundup_64(end_fsb, align);
-
-retry:
 	error = xfs_bmapi_reserve_delalloc(ip, XFS_COW_FORK, imap->br_startoff,
-			end_fsb - imap->br_startoff, 0, &got, &idx, eof);
-	switch (error) {
-	case 0:
-		break;
-	case -ENOSPC:
-	case -EDQUOT:
-		/* retry without any preallocation */
+			imap->br_blockcount, 0, &got, &idx, eof);
+	if (error == -ENOSPC || error == -EDQUOT)
 		trace_xfs_reflink_cow_enospc(ip, imap);
-		if (end_fsb != orig_end_fsb) {
-			end_fsb = orig_end_fsb;
-			goto retry;
-		}
-		/*FALLTHRU*/
-	default:
+	if (error)
 		return error;
-	}
-
-	if (end_fsb != orig_end_fsb)
-		xfs_inode_set_cowblocks_tag(ip);
 
 	trace_xfs_reflink_cow_alloc(ip, &got);
 	return 0;

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 187/206] xfs: use new extent lookup helpers xfs_file_iomap_begin_delay
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (167 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 186/206] xfs: clean up cow fork reservation and tag inodes correctly Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 188/206] xfs: pass post-eof speculative prealloc blocks to bmapi Greg Kroah-Hartman
                     ` (20 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Greg Kroah-Hartman, linux-xfs@vger.kernel.org, Dave Chinner,
	Christoph Hellwig, Brian Foster, Dave Chinner

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------


commit 656152e552e5cbe0c11ad261b524376217c2fb13 upstream.

And only lookup the previous extent inside xfs_iomap_prealloc_size
if we actually need it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/xfs/xfs_iomap.c |   20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -395,11 +395,12 @@ xfs_iomap_prealloc_size(
 	struct xfs_inode	*ip,
 	loff_t			offset,
 	loff_t			count,
-	xfs_extnum_t		idx,
-	struct xfs_bmbt_irec	*prev)
+	xfs_extnum_t		idx)
 {
 	struct xfs_mount	*mp = ip->i_mount;
+	struct xfs_ifork	*ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
 	xfs_fileoff_t		offset_fsb = XFS_B_TO_FSBT(mp, offset);
+	struct xfs_bmbt_irec	prev;
 	int			shift = 0;
 	int64_t			freesp;
 	xfs_fsblock_t		qblocks;
@@ -419,8 +420,8 @@ xfs_iomap_prealloc_size(
 	 */
 	if ((mp->m_flags & XFS_MOUNT_DFLT_IOSIZE) ||
 	    XFS_ISIZE(ip) < XFS_FSB_TO_B(mp, mp->m_dalign) ||
-	    idx == 0 ||
-	    prev->br_startoff + prev->br_blockcount < offset_fsb)
+	    !xfs_iext_get_extent(ifp, idx - 1, &prev) ||
+	    prev.br_startoff + prev.br_blockcount < offset_fsb)
 		return mp->m_writeio_blocks;
 
 	/*
@@ -439,8 +440,8 @@ xfs_iomap_prealloc_size(
 	 * always extends to MAXEXTLEN rather than falling short due to things
 	 * like stripe unit/width alignment of real extents.
 	 */
-	if (prev->br_blockcount <= (MAXEXTLEN >> 1))
-		alloc_blocks = prev->br_blockcount << 1;
+	if (prev.br_blockcount <= (MAXEXTLEN >> 1))
+		alloc_blocks = prev.br_blockcount << 1;
 	else
 		alloc_blocks = XFS_B_TO_FSB(mp, offset);
 	if (!alloc_blocks)
@@ -538,7 +539,6 @@ xfs_file_iomap_begin_delay(
 	xfs_fileoff_t		end_fsb, orig_end_fsb;
 	int			error = 0, eof = 0;
 	struct xfs_bmbt_irec	got;
-	struct xfs_bmbt_irec	prev;
 	xfs_extnum_t		idx;
 
 	ASSERT(!XFS_IS_REALTIME_INODE(ip));
@@ -563,8 +563,7 @@ xfs_file_iomap_begin_delay(
 			goto out_unlock;
 	}
 
-	xfs_bmap_search_extents(ip, offset_fsb, XFS_DATA_FORK, &eof, &idx,
-			&got, &prev);
+	eof = !xfs_iext_lookup_extent(ip, ifp, offset_fsb, &idx, &got);
 	if (!eof && got.br_startoff <= offset_fsb) {
 		if (xfs_is_reflink_inode(ip)) {
 			bool		shared;
@@ -601,8 +600,7 @@ xfs_file_iomap_begin_delay(
 	if (eof) {
 		xfs_fsblock_t	prealloc_blocks;
 
-		prealloc_blocks =
-			xfs_iomap_prealloc_size(ip, offset, count, idx, &prev);
+		prealloc_blocks = xfs_iomap_prealloc_size(ip, offset, count, idx);
 		if (prealloc_blocks) {
 			xfs_extlen_t	align;
 			xfs_off_t	end_offset;

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 188/206] xfs: pass post-eof speculative prealloc blocks to bmapi
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (168 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 187/206] xfs: use new extent lookup helpers xfs_file_iomap_begin_delay Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 189/206] xfs: Move AGI buffer type setting to xfs_read_agi Greg Kroah-Hartman
                     ` (19 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Greg Kroah-Hartman, Brian Foster, Dave Chinner, Dave Chinner,
	Christoph Hellwig

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------


From: Brian Foster <bfoster@redhat.com>

commit f782088c9e5d08e9494c63e68b4e85716df3e5f8 upstream.

xfs_file_iomap_begin_delay() implements post-eof speculative
preallocation by extending the block count of the requested delayed
allocation. Now that xfs_bmapi_reserve_delalloc() has been updated to
handle prealloc blocks separately and tag the inode, update
xfs_file_iomap_begin_delay() to use the new parameter and rely on the
former to tag the inode.

Note that this patch does not change behavior.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/xfs/xfs_iomap.c |   33 +++++++++++++--------------------
 1 file changed, 13 insertions(+), 20 deletions(-)

--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -536,10 +536,11 @@ xfs_file_iomap_begin_delay(
 	xfs_fileoff_t		offset_fsb = XFS_B_TO_FSBT(mp, offset);
 	xfs_fileoff_t		maxbytes_fsb =
 		XFS_B_TO_FSB(mp, mp->m_super->s_maxbytes);
-	xfs_fileoff_t		end_fsb, orig_end_fsb;
+	xfs_fileoff_t		end_fsb;
 	int			error = 0, eof = 0;
 	struct xfs_bmbt_irec	got;
 	xfs_extnum_t		idx;
+	xfs_fsblock_t		prealloc_blocks = 0;
 
 	ASSERT(!XFS_IS_REALTIME_INODE(ip));
 	ASSERT(!xfs_get_extsz_hint(ip));
@@ -594,33 +595,32 @@ xfs_file_iomap_begin_delay(
 	 * the lower level functions are updated.
 	 */
 	count = min_t(loff_t, count, 1024 * PAGE_SIZE);
-	end_fsb = orig_end_fsb =
-		min(XFS_B_TO_FSB(mp, offset + count), maxbytes_fsb);
+	end_fsb = min(XFS_B_TO_FSB(mp, offset + count), maxbytes_fsb);
 
 	if (eof) {
-		xfs_fsblock_t	prealloc_blocks;
-
 		prealloc_blocks = xfs_iomap_prealloc_size(ip, offset, count, idx);
 		if (prealloc_blocks) {
 			xfs_extlen_t	align;
 			xfs_off_t	end_offset;
+			xfs_fileoff_t	p_end_fsb;
 
 			end_offset = XFS_WRITEIO_ALIGN(mp, offset + count - 1);
-			end_fsb = XFS_B_TO_FSBT(mp, end_offset) +
-				prealloc_blocks;
+			p_end_fsb = XFS_B_TO_FSBT(mp, end_offset) +
+					prealloc_blocks;
 
 			align = xfs_eof_alignment(ip, 0);
 			if (align)
-				end_fsb = roundup_64(end_fsb, align);
+				p_end_fsb = roundup_64(p_end_fsb, align);
 
-			end_fsb = min(end_fsb, maxbytes_fsb);
-			ASSERT(end_fsb > offset_fsb);
+			p_end_fsb = min(p_end_fsb, maxbytes_fsb);
+			ASSERT(p_end_fsb > offset_fsb);
+			prealloc_blocks = p_end_fsb - end_fsb;
 		}
 	}
 
 retry:
 	error = xfs_bmapi_reserve_delalloc(ip, XFS_DATA_FORK, offset_fsb,
-			end_fsb - offset_fsb, 0, &got, &idx, eof);
+			end_fsb - offset_fsb, prealloc_blocks, &got, &idx, eof);
 	switch (error) {
 	case 0:
 		break;
@@ -628,8 +628,8 @@ retry:
 	case -EDQUOT:
 		/* retry without any preallocation */
 		trace_xfs_delalloc_enospc(ip, offset, count);
-		if (end_fsb != orig_end_fsb) {
-			end_fsb = orig_end_fsb;
+		if (prealloc_blocks) {
+			prealloc_blocks = 0;
 			goto retry;
 		}
 		/*FALLTHRU*/
@@ -637,13 +637,6 @@ retry:
 		goto out_unlock;
 	}
 
-	/*
-	 * Tag the inode as speculatively preallocated so we can reclaim this
-	 * space on demand, if necessary.
-	 */
-	if (end_fsb != orig_end_fsb)
-		xfs_inode_set_eofblocks_tag(ip);
-
 	trace_xfs_iomap_alloc(ip, offset, count, 0, &got);
 done:
 	if (isnullstartblock(got.br_startblock))

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 189/206] xfs: Move AGI buffer type setting to xfs_read_agi
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (169 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 188/206] xfs: pass post-eof speculative prealloc blocks to bmapi Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 190/206] xfs: pass state not whichfork to trace_xfs_extlist Greg Kroah-Hartman
                     ` (18 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Greg Kroah-Hartman, Eric Sandeen, Brian Foster,
	Christoph Hellwig, Dave Chinner

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------


From: Eric Sandeen <sandeen@sandeen.net>

commit 200237d6746faaeaf7f4ff4abbf13f3917cee60a upstream.

We've missed properly setting the buffer type for
an AGI transaction in 3 spots now, so just move it
into xfs_read_agi() and set it if we are in a transaction
to avoid the problem in the future.

This is similar to how it is done in i.e. the dir3
and attr3 read functions.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/xfs/libxfs/xfs_ialloc.c |    4 ++--
 fs/xfs/xfs_inode.c         |    2 --
 fs/xfs/xfs_log_recover.c   |    1 -
 3 files changed, 2 insertions(+), 5 deletions(-)

--- a/fs/xfs/libxfs/xfs_ialloc.c
+++ b/fs/xfs/libxfs/xfs_ialloc.c
@@ -2450,8 +2450,6 @@ xfs_ialloc_log_agi(
 	ASSERT(agi->agi_magicnum == cpu_to_be32(XFS_AGI_MAGIC));
 #endif
 
-	xfs_trans_buf_set_type(tp, bp, XFS_BLFT_AGI_BUF);
-
 	/*
 	 * Compute byte offsets for the first and last fields in the first
 	 * region and log the agi buffer. This only logs up through
@@ -2592,6 +2590,8 @@ xfs_read_agi(
 			XFS_FSS_TO_BB(mp, 1), 0, bpp, &xfs_agi_buf_ops);
 	if (error)
 		return error;
+	if (tp)
+		xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_AGI_BUF);
 
 	xfs_buf_set_ref(*bpp, XFS_AGI_REF);
 	return 0;
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -2041,7 +2041,6 @@ xfs_iunlink(
 	agi->agi_unlinked[bucket_index] = cpu_to_be32(agino);
 	offset = offsetof(xfs_agi_t, agi_unlinked) +
 		(sizeof(xfs_agino_t) * bucket_index);
-	xfs_trans_buf_set_type(tp, agibp, XFS_BLFT_AGI_BUF);
 	xfs_trans_log_buf(tp, agibp, offset,
 			  (offset + sizeof(xfs_agino_t) - 1));
 	return 0;
@@ -2133,7 +2132,6 @@ xfs_iunlink_remove(
 		agi->agi_unlinked[bucket_index] = cpu_to_be32(next_agino);
 		offset = offsetof(xfs_agi_t, agi_unlinked) +
 			(sizeof(xfs_agino_t) * bucket_index);
-		xfs_trans_buf_set_type(tp, agibp, XFS_BLFT_AGI_BUF);
 		xfs_trans_log_buf(tp, agibp, offset,
 				  (offset + sizeof(xfs_agino_t) - 1));
 	} else {
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -4929,7 +4929,6 @@ xlog_recover_clear_agi_bucket(
 	agi->agi_unlinked[bucket] = cpu_to_be32(NULLAGINO);
 	offset = offsetof(xfs_agi_t, agi_unlinked) +
 		 (sizeof(xfs_agino_t) * bucket);
-	xfs_trans_buf_set_type(tp, agibp, XFS_BLFT_AGI_BUF);
 	xfs_trans_log_buf(tp, agibp, offset,
 			  (offset + sizeof(xfs_agino_t) - 1));
 

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 190/206] xfs: pass state not whichfork to trace_xfs_extlist
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (170 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 189/206] xfs: Move AGI buffer type setting to xfs_read_agi Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 191/206] xfs: handle cow fork in xfs_bmap_trace_exlist Greg Kroah-Hartman
                     ` (17 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Greg Kroah-Hartman, Eric Sandeen, Christoph Hellwig, Dave Chinner

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------


From: Eric Sandeen <sandeen@sandeen.net>

commit 7710517fc37b1899722707883b54694ea710b3c0 upstream.

When xfs_bmap_trace_exlist called trace_xfs_extlist,
it sent in the "whichfork" var instead of the bmap "state"
as expected (even though state was already set up for this
purpose).

As a result, the xfs_bmap_class in tracing code used
"whichfork" not state in xfs_iext_state_to_fork(), and got
the wrong ifork pointer.  It all goes downhill from
there, including an ASSERT when ifp_bytes is empty
by the time it reaches xfs_iext_get_ext():

XFS: Assertion failed: idx < ifp->if_bytes / sizeof(xfs_bmbt_rec_t)

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/xfs/libxfs/xfs_bmap.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -531,7 +531,7 @@ xfs_bmap_trace_exlist(
 	ifp = XFS_IFORK_PTR(ip, whichfork);
 	ASSERT(cnt == xfs_iext_count(ifp));
 	for (idx = 0; idx < cnt; idx++)
-		trace_xfs_extlist(ip, idx, whichfork, caller_ip);
+		trace_xfs_extlist(ip, idx, state, caller_ip);
 }
 
 /*

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 191/206] xfs: handle cow fork in xfs_bmap_trace_exlist
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (171 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 190/206] xfs: pass state not whichfork to trace_xfs_extlist Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 192/206] xfs: forbid AG btrees with level == 0 Greg Kroah-Hartman
                     ` (16 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Greg Kroah-Hartman, Eric Sandeen, Christoph Hellwig, Dave Chinner

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------


From: Eric Sandeen <sandeen@sandeen.net>

commit c44a1f22626c153976289e1cd67bdcdfefc16e1f upstream.

By inspection, xfs_bmap_trace_exlist isn't handling cow forks,
and will trace the data fork instead.

Fix this by setting state appropriately if whichfork
== XFS_COW_FORK.

()___()
< @ @ >
 |   |
 {o_o}
  (|)

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/xfs/libxfs/xfs_bmap.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -518,7 +518,7 @@ void
 xfs_bmap_trace_exlist(
 	xfs_inode_t	*ip,		/* incore inode pointer */
 	xfs_extnum_t	cnt,		/* count of entries in the list */
-	int		whichfork,	/* data or attr fork */
+	int		whichfork,	/* data or attr or cow fork */
 	unsigned long	caller_ip)
 {
 	xfs_extnum_t	idx;		/* extent record index */
@@ -527,6 +527,8 @@ xfs_bmap_trace_exlist(
 
 	if (whichfork == XFS_ATTR_FORK)
 		state |= BMAP_ATTRFORK;
+	else if (whichfork == XFS_COW_FORK)
+		state |= BMAP_COWFORK;
 
 	ifp = XFS_IFORK_PTR(ip, whichfork);
 	ASSERT(cnt == xfs_iext_count(ifp));

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 192/206] xfs: forbid AG btrees with level == 0
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (172 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 191/206] xfs: handle cow fork in xfs_bmap_trace_exlist Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 193/206] xfs: check for bogus values in btree block headers Greg Kroah-Hartman
                     ` (15 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Greg Kroah-Hartman, Darrick J. Wong, Dave Chinner, Dave Chinner,
	Christoph Hellwig

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------


From: "Darrick J. Wong" <darrick.wong@oracle.com>

commit d2a047f31e86941fa896e0e3271536d50aba415e upstream.

There is no such thing as a zero-level AG btree since even a single-node
zero-records btree has one level.  Btree cursor constructors read
cur_nlevels straight from disk and then access things like
cur_bufs[cur_nlevels - 1] which is /really/ bad if cur_nlevels is zero!
Therefore, strengthen the verifiers to prevent this possibility.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/xfs/libxfs/xfs_alloc.c  |   10 +++++++---
 fs/xfs/libxfs/xfs_ialloc.c |    9 ++++++++-
 2 files changed, 15 insertions(+), 4 deletions(-)

--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -2455,12 +2455,15 @@ xfs_agf_verify(
 	      be32_to_cpu(agf->agf_flcount) <= XFS_AGFL_SIZE(mp)))
 		return false;
 
-	if (be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNO]) > XFS_BTREE_MAXLEVELS ||
+	if (be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNO]) < 1 ||
+	    be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNT]) < 1 ||
+	    be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNO]) > XFS_BTREE_MAXLEVELS ||
 	    be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNT]) > XFS_BTREE_MAXLEVELS)
 		return false;
 
 	if (xfs_sb_version_hasrmapbt(&mp->m_sb) &&
-	    be32_to_cpu(agf->agf_levels[XFS_BTNUM_RMAP]) > XFS_BTREE_MAXLEVELS)
+	    (be32_to_cpu(agf->agf_levels[XFS_BTNUM_RMAP]) < 1 ||
+	     be32_to_cpu(agf->agf_levels[XFS_BTNUM_RMAP]) > XFS_BTREE_MAXLEVELS))
 		return false;
 
 	/*
@@ -2477,7 +2480,8 @@ xfs_agf_verify(
 		return false;
 
 	if (xfs_sb_version_hasreflink(&mp->m_sb) &&
-	    be32_to_cpu(agf->agf_refcount_level) > XFS_BTREE_MAXLEVELS)
+	    (be32_to_cpu(agf->agf_refcount_level) < 1 ||
+	     be32_to_cpu(agf->agf_refcount_level) > XFS_BTREE_MAXLEVELS))
 		return false;
 
 	return true;;
--- a/fs/xfs/libxfs/xfs_ialloc.c
+++ b/fs/xfs/libxfs/xfs_ialloc.c
@@ -2510,8 +2510,15 @@ xfs_agi_verify(
 	if (!XFS_AGI_GOOD_VERSION(be32_to_cpu(agi->agi_versionnum)))
 		return false;
 
-	if (be32_to_cpu(agi->agi_level) > XFS_BTREE_MAXLEVELS)
+	if (be32_to_cpu(agi->agi_level) < 1 ||
+	    be32_to_cpu(agi->agi_level) > XFS_BTREE_MAXLEVELS)
 		return false;
+
+	if (xfs_sb_version_hasfinobt(&mp->m_sb) &&
+	    (be32_to_cpu(agi->agi_free_level) < 1 ||
+	     be32_to_cpu(agi->agi_free_level) > XFS_BTREE_MAXLEVELS))
+		return false;
+
 	/*
 	 * during growfs operations, the perag is not fully initialised,
 	 * so we can't use it for any useful checking. growfs ensures we can't

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 193/206] xfs: check for bogus values in btree block headers
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (173 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 192/206] xfs: forbid AG btrees with level == 0 Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 194/206] xfs: complain if we dont get nextents bmap records Greg Kroah-Hartman
                     ` (14 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Greg Kroah-Hartman, Darrick J. Wong, Dave Chinner, Dave Chinner,
	Christoph Hellwig

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: "Darrick J. Wong" <darrick.wong@oracle.com>

commit bb3be7e7c1c18e1b141d4cadeb98cc89ecf78099 upstream.

When we're reading a btree block, make sure that what we retrieved
matches the owner and level; and has a plausible number of records.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/xfs/libxfs/xfs_btree.c |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

--- a/fs/xfs/libxfs/xfs_btree.c
+++ b/fs/xfs/libxfs/xfs_btree.c
@@ -1769,8 +1769,28 @@ xfs_btree_lookup_get_block(
 	if (error)
 		return error;
 
+	/* Check the inode owner since the verifiers don't. */
+	if (xfs_sb_version_hascrc(&cur->bc_mp->m_sb) &&
+	    (cur->bc_flags & XFS_BTREE_LONG_PTRS) &&
+	    be64_to_cpu((*blkp)->bb_u.l.bb_owner) !=
+			cur->bc_private.b.ip->i_ino)
+		goto out_bad;
+
+	/* Did we get the level we were looking for? */
+	if (be16_to_cpu((*blkp)->bb_level) != level)
+		goto out_bad;
+
+	/* Check that internal nodes have at least one record. */
+	if (level != 0 && be16_to_cpu((*blkp)->bb_numrecs) == 0)
+		goto out_bad;
+
 	xfs_btree_setbuf(cur, level, bp);
 	return 0;
+
+out_bad:
+	*blkp = NULL;
+	xfs_trans_brelse(cur->bc_tp, bp);
+	return -EFSCORRUPTED;
 }
 
 /*

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 194/206] xfs: complain if we dont get nextents bmap records
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (174 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 193/206] xfs: check for bogus values in btree block headers Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 195/206] xfs: dont crash if reading a directory results in an unexpected hole Greg Kroah-Hartman
                     ` (13 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Greg Kroah-Hartman, Darrick J. Wong, Dave Chinner, Dave Chinner,
	Christoph Hellwig

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------


From: "Darrick J. Wong" <darrick.wong@oracle.com>

commit 356a3225222e5bc4df88aef3419fb6424f18ab69 upstream.

When reading into memory all extents of a btree-format inode fork,
complain if the number of extents we find is not the same as the number
of extents reported in the inode core.  This is needed to stop an IO
action from accessing the garbage areas of the in-core fork.

[dchinner: removed redundant assert]

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/xfs/libxfs/xfs_bmap.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -1377,8 +1377,9 @@ xfs_bmap_read_extents(
 			return error;
 		block = XFS_BUF_TO_BLOCK(bp);
 	}
+	if (i != XFS_IFORK_NEXTENTS(ip, whichfork))
+		return -EFSCORRUPTED;
 	ASSERT(i == xfs_iext_count(ifp));
-	ASSERT(i == XFS_IFORK_NEXTENTS(ip, whichfork));
 	XFS_BMAP_TRACE_EXLIST(ip, i, whichfork);
 	return 0;
 error0:

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 195/206] xfs: dont crash if reading a directory results in an unexpected hole
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (175 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 194/206] xfs: complain if we dont get nextents bmap records Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:37   ` [PATCH 4.9 196/206] xfs: error out if trying to add attrs and anextents > 0 Greg Kroah-Hartman
                     ` (12 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Greg Kroah-Hartman, Darrick J. Wong, Dave Chinner, Dave Chinner,
	Christoph Hellwig

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------


From: "Darrick J. Wong" <darrick.wong@oracle.com>

commit 96a3aefb8ffde23180130460b0b2407b328eb727 upstream.

In xfs_dir3_data_read, we can encounter the situation where err == 0 and
*bpp == NULL if the given bno offset happens to be a hole; this leads to
a crash if we try to set the buffer type after the _da_read_buf call.
Holes can happen due to corrupt or malicious entries in the bmbt data,
so be a little more careful when we're handling buffers.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/xfs/libxfs/xfs_dir2_data.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/fs/xfs/libxfs/xfs_dir2_data.c
+++ b/fs/xfs/libxfs/xfs_dir2_data.c
@@ -329,7 +329,7 @@ xfs_dir3_data_read(
 
 	err = xfs_da_read_buf(tp, dp, bno, mapped_bno, bpp,
 				XFS_DATA_FORK, &xfs_dir3_data_buf_ops);
-	if (!err && tp)
+	if (!err && tp && *bpp)
 		xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_DIR_DATA_BUF);
 	return err;
 }

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 196/206] xfs: error out if trying to add attrs and anextents > 0
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (176 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 195/206] xfs: dont crash if reading a directory results in an unexpected hole Greg Kroah-Hartman
@ 2017-01-10 13:37   ` Greg Kroah-Hartman
  2017-01-10 13:38   ` [PATCH 4.9 197/206] xfs: dont allow di_size with high bit set Greg Kroah-Hartman
                     ` (11 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:37 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Greg Kroah-Hartman, Darrick J. Wong, Dave Chinner, Dave Chinner,
	Christoph Hellwig

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------


From: "Darrick J. Wong" <darrick.wong@oracle.com>

commit 0f352f8ee8412bd9d34fb2a6411241da61175c0e upstream.

We shouldn't assert if somehow we end up trying to add an attr fork to
an inode that apparently already has attr extents because this is an
indication of on-disk corruption.  Instead, return an error code to
userspace.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/xfs/libxfs/xfs_bmap.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -1153,6 +1153,10 @@ xfs_bmap_add_attrfork(
 		goto trans_cancel;
 	if (XFS_IFORK_Q(ip))
 		goto trans_cancel;
+	if (ip->i_d.di_anextents != 0) {
+		error = -EFSCORRUPTED;
+		goto trans_cancel;
+	}
 	if (ip->i_d.di_aformat != XFS_DINODE_FMT_EXTENTS) {
 		/*
 		 * For inodes coming from pre-6.2 filesystems.
@@ -1160,7 +1164,6 @@ xfs_bmap_add_attrfork(
 		ASSERT(ip->i_d.di_aformat == 0);
 		ip->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS;
 	}
-	ASSERT(ip->i_d.di_anextents == 0);
 
 	xfs_trans_ijoin(tp, ip, 0);
 	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 197/206] xfs: dont allow di_size with high bit set
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (177 preceding siblings ...)
  2017-01-10 13:37   ` [PATCH 4.9 196/206] xfs: error out if trying to add attrs and anextents > 0 Greg Kroah-Hartman
@ 2017-01-10 13:38   ` Greg Kroah-Hartman
  2017-01-10 13:38   ` [PATCH 4.9 198/206] xfs: dont cap maximum dedupe request length Greg Kroah-Hartman
                     ` (10 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:38 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Greg Kroah-Hartman, Darrick J. Wong, Dave Chinner, Dave Chinner,
	Christoph Hellwig

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------


From: "Darrick J. Wong" <darrick.wong@oracle.com>

commit ef388e2054feedaeb05399ed654bdb06f385d294 upstream.

The on-disk field di_size is used to set i_size, which is a signed
integer of loff_t.  If the high bit of di_size is set, we'll end up with
a negative i_size, which will cause all sorts of problems.  Since the
VFS won't let us create a file with such length, we should catch them
here in the verifier too.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/xfs/libxfs/xfs_inode_buf.c |    8 ++++++++
 1 file changed, 8 insertions(+)

--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -392,6 +392,14 @@ xfs_dinode_verify(
 	if (dip->di_magic != cpu_to_be16(XFS_DINODE_MAGIC))
 		return false;
 
+	/* don't allow invalid i_size */
+	if (be64_to_cpu(dip->di_size) & (1ULL << 63))
+		return false;
+
+	/* No zero-length symlinks. */
+	if (S_ISLNK(be16_to_cpu(dip->di_mode)) && dip->di_size == 0)
+		return false;
+
 	/* only version 3 or greater inodes are extensively verified here */
 	if (dip->di_version < 3)
 		return true;

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 198/206] xfs: dont cap maximum dedupe request length
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (178 preceding siblings ...)
  2017-01-10 13:38   ` [PATCH 4.9 197/206] xfs: dont allow di_size with high bit set Greg Kroah-Hartman
@ 2017-01-10 13:38   ` Greg Kroah-Hartman
  2017-01-10 13:38   ` [PATCH 4.9 199/206] xfs: ignore leaf attr ichdr.count in verifier during log replay Greg Kroah-Hartman
                     ` (9 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:38 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Greg Kroah-Hartman, Darrick J. Wong, Dave Chinner, Dave Chinner,
	Christoph Hellwig

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------


From: "Darrick J. Wong" <darrick.wong@oracle.com>

commit 1bb33a98702d8360947f18a44349df75ba555d5d upstream.

After various discussions on linux-fsdevel, it has been decided that it
is not necessary to cap the length of a dedupe request, and that
correctly-written userspace client programs will be able to absorb the
change.  Therefore, remove the length clamping behavior.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/xfs/xfs_file.c |    9 ---------
 1 file changed, 9 deletions(-)

--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -939,7 +939,6 @@ xfs_file_clone_range(
 				     len, false);
 }
 
-#define XFS_MAX_DEDUPE_LEN	(16 * 1024 * 1024)
 STATIC ssize_t
 xfs_file_dedupe_range(
 	struct file	*src_file,
@@ -950,14 +949,6 @@ xfs_file_dedupe_range(
 {
 	int		error;
 
-	/*
-	 * Limit the total length we will dedupe for each operation.
-	 * This is intended to bound the total time spent in this
-	 * ioctl to something sane.
-	 */
-	if (len > XFS_MAX_DEDUPE_LEN)
-		len = XFS_MAX_DEDUPE_LEN;
-
 	error = xfs_reflink_remap_range(src_file, loff, dst_file, dst_loff,
 				     len, true);
 	if (error)

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 199/206] xfs: ignore leaf attr ichdr.count in verifier during log replay
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (179 preceding siblings ...)
  2017-01-10 13:38   ` [PATCH 4.9 198/206] xfs: dont cap maximum dedupe request length Greg Kroah-Hartman
@ 2017-01-10 13:38   ` Greg Kroah-Hartman
  2017-01-10 13:38   ` [PATCH 4.9 200/206] xfs: use GPF_NOFS when allocating btree cursors Greg Kroah-Hartman
                     ` (8 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:38 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Greg Kroah-Hartman, Eric Sandeen, Christoph Hellwig, Dave Chinner

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------


From: Eric Sandeen <sandeen@redhat.com>

commit 2e1d23370e75d7d89350d41b4ab58c7f6a0e26b2 upstream.

When we create a new attribute, we first create a shortform
attribute, and try to fit the new attribute into it.
If that fails, we copy the (empty) attribute into a leaf attribute,
and do the copy again.  Thus there can be a transient state where
we have an empty leaf attribute.

If we encounter this during log replay, the verifier will fail.
So add a test to ignore this part of the leaf attr verification
during log replay.

Thanks as usual to dchinner for spotting the problem.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/xfs/libxfs/xfs_attr_leaf.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

--- a/fs/xfs/libxfs/xfs_attr_leaf.c
+++ b/fs/xfs/libxfs/xfs_attr_leaf.c
@@ -253,6 +253,7 @@ xfs_attr3_leaf_verify(
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
 	struct xfs_attr_leafblock *leaf = bp->b_addr;
+	struct xfs_perag *pag = bp->b_pag;
 	struct xfs_attr3_icleaf_hdr ichdr;
 
 	xfs_attr3_leaf_hdr_from_disk(mp->m_attr_geo, &ichdr, leaf);
@@ -273,7 +274,12 @@ xfs_attr3_leaf_verify(
 		if (ichdr.magic != XFS_ATTR_LEAF_MAGIC)
 			return false;
 	}
-	if (ichdr.count == 0)
+	/*
+	 * In recovery there is a transient state where count == 0 is valid
+	 * because we may have transitioned an empty shortform attr to a leaf
+	 * if the attr didn't fit in shortform.
+	 */
+	if (pag && pag->pagf_init && ichdr.count == 0)
 		return false;
 
 	/* XXX: need to range check rest of attr header values */

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 200/206] xfs: use GPF_NOFS when allocating btree cursors
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (180 preceding siblings ...)
  2017-01-10 13:38   ` [PATCH 4.9 199/206] xfs: ignore leaf attr ichdr.count in verifier during log replay Greg Kroah-Hartman
@ 2017-01-10 13:38   ` Greg Kroah-Hartman
  2017-01-10 13:38   ` [PATCH 4.9 201/206] xfs: fix double-cleanup when CUI recovery fails Greg Kroah-Hartman
                     ` (7 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:38 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Greg Kroah-Hartman, Darrick J. Wong, Dave Chinner, Dave Chinner,
	Christoph Hellwig

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------


From: "Darrick J. Wong" <darrick.wong@oracle.com>

commit b24a978c377be5f14e798cb41238e66fe51aab2f upstream.

Use NOFS for allocating btree cursors, since they can be called
under the ilock.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/xfs/libxfs/xfs_alloc_btree.c  |    2 +-
 fs/xfs/libxfs/xfs_bmap_btree.c   |    2 +-
 fs/xfs/libxfs/xfs_ialloc_btree.c |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

--- a/fs/xfs/libxfs/xfs_alloc_btree.c
+++ b/fs/xfs/libxfs/xfs_alloc_btree.c
@@ -421,7 +421,7 @@ xfs_allocbt_init_cursor(
 
 	ASSERT(btnum == XFS_BTNUM_BNO || btnum == XFS_BTNUM_CNT);
 
-	cur = kmem_zone_zalloc(xfs_btree_cur_zone, KM_SLEEP);
+	cur = kmem_zone_zalloc(xfs_btree_cur_zone, KM_NOFS);
 
 	cur->bc_tp = tp;
 	cur->bc_mp = mp;
--- a/fs/xfs/libxfs/xfs_bmap_btree.c
+++ b/fs/xfs/libxfs/xfs_bmap_btree.c
@@ -796,7 +796,7 @@ xfs_bmbt_init_cursor(
 	struct xfs_btree_cur	*cur;
 	ASSERT(whichfork != XFS_COW_FORK);
 
-	cur = kmem_zone_zalloc(xfs_btree_cur_zone, KM_SLEEP);
+	cur = kmem_zone_zalloc(xfs_btree_cur_zone, KM_NOFS);
 
 	cur->bc_tp = tp;
 	cur->bc_mp = mp;
--- a/fs/xfs/libxfs/xfs_ialloc_btree.c
+++ b/fs/xfs/libxfs/xfs_ialloc_btree.c
@@ -357,7 +357,7 @@ xfs_inobt_init_cursor(
 	struct xfs_agi		*agi = XFS_BUF_TO_AGI(agbp);
 	struct xfs_btree_cur	*cur;
 
-	cur = kmem_zone_zalloc(xfs_btree_cur_zone, KM_SLEEP);
+	cur = kmem_zone_zalloc(xfs_btree_cur_zone, KM_NOFS);
 
 	cur->bc_tp = tp;
 	cur->bc_mp = mp;

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 201/206] xfs: fix double-cleanup when CUI recovery fails
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (181 preceding siblings ...)
  2017-01-10 13:38   ` [PATCH 4.9 200/206] xfs: use GPF_NOFS when allocating btree cursors Greg Kroah-Hartman
@ 2017-01-10 13:38   ` Greg Kroah-Hartman
  2017-01-10 13:38   ` [PATCH 4.9 202/206] xfs: use the actual AG length when reserving blocks Greg Kroah-Hartman
                     ` (6 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:38 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Greg Kroah-Hartman, linux-xfs, Darrick J. Wong, Dan Carpenter,
	Christoph Hellwig

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------


From: "Darrick J. Wong" <darrick.wong@oracle.com>

commit 7a21272b088894070391a94fdd1c67014020fa1d upstream.

Dan Carpenter reported a double-free of rcur if _defer_finish fails
while we're recovering CUI items.  Fix the error recovery to prevent
this.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/xfs/xfs_refcount_item.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/fs/xfs/xfs_refcount_item.c
+++ b/fs/xfs/xfs_refcount_item.c
@@ -526,13 +526,14 @@ xfs_cui_recover(
 	xfs_refcount_finish_one_cleanup(tp, rcur, error);
 	error = xfs_defer_finish(&tp, &dfops, NULL);
 	if (error)
-		goto abort_error;
+		goto abort_defer;
 	set_bit(XFS_CUI_RECOVERED, &cuip->cui_flags);
 	error = xfs_trans_commit(tp);
 	return error;
 
 abort_error:
 	xfs_refcount_finish_one_cleanup(tp, rcur, error);
+abort_defer:
 	xfs_defer_cancel(&dfops);
 	xfs_trans_cancel(tp);
 	return error;

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 202/206] xfs: use the actual AG length when reserving blocks
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (182 preceding siblings ...)
  2017-01-10 13:38   ` [PATCH 4.9 201/206] xfs: fix double-cleanup when CUI recovery fails Greg Kroah-Hartman
@ 2017-01-10 13:38   ` Greg Kroah-Hartman
  2017-01-10 13:38   ` [PATCH 4.9 203/206] xfs: fix crash and data corruption due to removal of busy COW extents Greg Kroah-Hartman
                     ` (5 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:38 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Greg Kroah-Hartman, linux-xfs, Darrick J. Wong, Christoph Hellwig

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------


From: "Darrick J. Wong" <darrick.wong@oracle.com>

commit 20e73b000bcded44a91b79429d8fa743247602ad upstream.

We need to use the actual AG length when making per-AG reservations,
since we could otherwise end up reserving more blocks out of the last
AG than there are actual blocks.

Complained-about-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/xfs/libxfs/xfs_ag_resv.c        |    3 +++
 fs/xfs/libxfs/xfs_refcount_btree.c |    9 ++++++---
 fs/xfs/libxfs/xfs_refcount_btree.h |    3 ++-
 fs/xfs/libxfs/xfs_rmap_btree.c     |   14 +++++++-------
 fs/xfs/libxfs/xfs_rmap_btree.h     |    3 ++-
 fs/xfs/xfs_fsops.c                 |   14 ++++++++++++++
 6 files changed, 34 insertions(+), 12 deletions(-)

--- a/fs/xfs/libxfs/xfs_ag_resv.c
+++ b/fs/xfs/libxfs/xfs_ag_resv.c
@@ -256,6 +256,9 @@ xfs_ag_resv_init(
 			goto out;
 	}
 
+	ASSERT(xfs_perag_resv(pag, XFS_AG_RESV_METADATA)->ar_reserved +
+	       xfs_perag_resv(pag, XFS_AG_RESV_AGFL)->ar_reserved <=
+	       pag->pagf_freeblks + pag->pagf_flcount);
 out:
 	return error;
 }
--- a/fs/xfs/libxfs/xfs_refcount_btree.c
+++ b/fs/xfs/libxfs/xfs_refcount_btree.c
@@ -408,13 +408,14 @@ xfs_refcountbt_calc_size(
  */
 xfs_extlen_t
 xfs_refcountbt_max_size(
-	struct xfs_mount	*mp)
+	struct xfs_mount	*mp,
+	xfs_agblock_t		agblocks)
 {
 	/* Bail out if we're uninitialized, which can happen in mkfs. */
 	if (mp->m_refc_mxr[0] == 0)
 		return 0;
 
-	return xfs_refcountbt_calc_size(mp, mp->m_sb.sb_agblocks);
+	return xfs_refcountbt_calc_size(mp, agblocks);
 }
 
 /*
@@ -429,22 +430,24 @@ xfs_refcountbt_calc_reserves(
 {
 	struct xfs_buf		*agbp;
 	struct xfs_agf		*agf;
+	xfs_agblock_t		agblocks;
 	xfs_extlen_t		tree_len;
 	int			error;
 
 	if (!xfs_sb_version_hasreflink(&mp->m_sb))
 		return 0;
 
-	*ask += xfs_refcountbt_max_size(mp);
 
 	error = xfs_alloc_read_agf(mp, NULL, agno, 0, &agbp);
 	if (error)
 		return error;
 
 	agf = XFS_BUF_TO_AGF(agbp);
+	agblocks = be32_to_cpu(agf->agf_length);
 	tree_len = be32_to_cpu(agf->agf_refcount_blocks);
 	xfs_buf_relse(agbp);
 
+	*ask += xfs_refcountbt_max_size(mp, agblocks);
 	*used += tree_len;
 
 	return error;
--- a/fs/xfs/libxfs/xfs_refcount_btree.h
+++ b/fs/xfs/libxfs/xfs_refcount_btree.h
@@ -66,7 +66,8 @@ extern void xfs_refcountbt_compute_maxle
 
 extern xfs_extlen_t xfs_refcountbt_calc_size(struct xfs_mount *mp,
 		unsigned long long len);
-extern xfs_extlen_t xfs_refcountbt_max_size(struct xfs_mount *mp);
+extern xfs_extlen_t xfs_refcountbt_max_size(struct xfs_mount *mp,
+		xfs_agblock_t agblocks);
 
 extern int xfs_refcountbt_calc_reserves(struct xfs_mount *mp,
 		xfs_agnumber_t agno, xfs_extlen_t *ask, xfs_extlen_t *used);
--- a/fs/xfs/libxfs/xfs_rmap_btree.c
+++ b/fs/xfs/libxfs/xfs_rmap_btree.c
@@ -549,13 +549,14 @@ xfs_rmapbt_calc_size(
  */
 xfs_extlen_t
 xfs_rmapbt_max_size(
-	struct xfs_mount	*mp)
+	struct xfs_mount	*mp,
+	xfs_agblock_t		agblocks)
 {
 	/* Bail out if we're uninitialized, which can happen in mkfs. */
 	if (mp->m_rmap_mxr[0] == 0)
 		return 0;
 
-	return xfs_rmapbt_calc_size(mp, mp->m_sb.sb_agblocks);
+	return xfs_rmapbt_calc_size(mp, agblocks);
 }
 
 /*
@@ -570,25 +571,24 @@ xfs_rmapbt_calc_reserves(
 {
 	struct xfs_buf		*agbp;
 	struct xfs_agf		*agf;
-	xfs_extlen_t		pool_len;
+	xfs_agblock_t		agblocks;
 	xfs_extlen_t		tree_len;
 	int			error;
 
 	if (!xfs_sb_version_hasrmapbt(&mp->m_sb))
 		return 0;
 
-	/* Reserve 1% of the AG or enough for 1 block per record. */
-	pool_len = max(mp->m_sb.sb_agblocks / 100, xfs_rmapbt_max_size(mp));
-	*ask += pool_len;
-
 	error = xfs_alloc_read_agf(mp, NULL, agno, 0, &agbp);
 	if (error)
 		return error;
 
 	agf = XFS_BUF_TO_AGF(agbp);
+	agblocks = be32_to_cpu(agf->agf_length);
 	tree_len = be32_to_cpu(agf->agf_rmap_blocks);
 	xfs_buf_relse(agbp);
 
+	/* Reserve 1% of the AG or enough for 1 block per record. */
+	*ask += max(agblocks / 100, xfs_rmapbt_max_size(mp, agblocks));
 	*used += tree_len;
 
 	return error;
--- a/fs/xfs/libxfs/xfs_rmap_btree.h
+++ b/fs/xfs/libxfs/xfs_rmap_btree.h
@@ -60,7 +60,8 @@ extern void xfs_rmapbt_compute_maxlevels
 
 extern xfs_extlen_t xfs_rmapbt_calc_size(struct xfs_mount *mp,
 		unsigned long long len);
-extern xfs_extlen_t xfs_rmapbt_max_size(struct xfs_mount *mp);
+extern xfs_extlen_t xfs_rmapbt_max_size(struct xfs_mount *mp,
+		xfs_agblock_t agblocks);
 
 extern int xfs_rmapbt_calc_reserves(struct xfs_mount *mp,
 		xfs_agnumber_t agno, xfs_extlen_t *ask, xfs_extlen_t *used);
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -631,6 +631,20 @@ xfs_growfs_data_private(
 	xfs_set_low_space_thresholds(mp);
 	mp->m_alloc_set_aside = xfs_alloc_set_aside(mp);
 
+	/*
+	 * If we expanded the last AG, free the per-AG reservation
+	 * so we can reinitialize it with the new size.
+	 */
+	if (new) {
+		struct xfs_perag	*pag;
+
+		pag = xfs_perag_get(mp, agno);
+		error = xfs_ag_resv_free(pag);
+		xfs_perag_put(pag);
+		if (error)
+			goto out;
+	}
+
 	/* Reserve AG metadata blocks. */
 	error = xfs_fs_reserve_ag_blocks(mp);
 	if (error && error != -ENOSPC)

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 203/206] xfs: fix crash and data corruption due to removal of busy COW extents
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (183 preceding siblings ...)
  2017-01-10 13:38   ` [PATCH 4.9 202/206] xfs: use the actual AG length when reserving blocks Greg Kroah-Hartman
@ 2017-01-10 13:38   ` Greg Kroah-Hartman
  2017-01-10 13:38   ` [PATCH 4.9 204/206] xfs: fix max_retries _show and _store functions Greg Kroah-Hartman
                     ` (4 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:38 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Greg Kroah-Hartman, linux-xfs, Darrick J. Wong, Christoph Hellwig

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------


commit a1b7a4dea6166cf46be895bce4aac67ea5160fe8 upstream.

There is a race window between write_cache_pages calling
clear_page_dirty_for_io and XFS calling set_page_writeback, in which
the mapping for an inode is tagged neither as dirty, nor as writeback.

If the COW shrinker hits in exactly that window we'll remove the delayed
COW extents and writepages trying to write it back, which in release
kernels will manifest as corruption of the bmap btree, and in debug
kernels will trip the ASSERT about now calling xfs_bmapi_write with the
COWFORK flag for holes.  A complex customer load manages to hit this
window fairly reliably, probably by always having COW writeback in flight
while the cow shrinker runs.

This patch adds another check for having the I_DIRTY_PAGES flag set,
which is still set during this race window.  While this fixes the problem
I'm still not overly happy about the way the COW shrinker works as it
still seems a bit fragile.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/xfs/xfs_icache.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/fs/xfs/xfs_icache.c
+++ b/fs/xfs/xfs_icache.c
@@ -1599,7 +1599,8 @@ xfs_inode_free_cowblocks(
 	 * If the mapping is dirty or under writeback we cannot touch the
 	 * CoW fork.  Leave it alone if we're in the midst of a directio.
 	 */
-	if (mapping_tagged(VFS_I(ip)->i_mapping, PAGECACHE_TAG_DIRTY) ||
+	if ((VFS_I(ip)->i_state & I_DIRTY_PAGES) ||
+	    mapping_tagged(VFS_I(ip)->i_mapping, PAGECACHE_TAG_DIRTY) ||
 	    mapping_tagged(VFS_I(ip)->i_mapping, PAGECACHE_TAG_WRITEBACK) ||
 	    atomic_read(&VFS_I(ip)->i_dio_count))
 		return 0;

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 204/206] xfs: fix max_retries _show and _store functions
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (184 preceding siblings ...)
  2017-01-10 13:38   ` [PATCH 4.9 203/206] xfs: fix crash and data corruption due to removal of busy COW extents Greg Kroah-Hartman
@ 2017-01-10 13:38   ` Greg Kroah-Hartman
  2017-01-10 13:38   ` [PATCH 4.9 205/206] clocksource/dummy_timer: Move hotplug callback after the real timers Greg Kroah-Hartman
                     ` (3 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:38 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Greg Kroah-Hartman, Carlos Maiolino, Eric Sandeen,
	Darrick J. Wong, Christoph Hellwig

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------


From: Carlos Maiolino <cmaiolino@redhat.com>

commit ff97f2399edac1e0fb3fa7851d5fbcbdf04717cf upstream.

max_retries _show and _store functions should test against cfg->max_retries,
not cfg->retry_timeout

Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/xfs/xfs_sysfs.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/fs/xfs/xfs_sysfs.c
+++ b/fs/xfs/xfs_sysfs.c
@@ -396,7 +396,7 @@ max_retries_show(
 	int		retries;
 	struct xfs_error_cfg *cfg = to_error_cfg(kobject);
 
-	if (cfg->retry_timeout == XFS_ERR_RETRY_FOREVER)
+	if (cfg->max_retries == XFS_ERR_RETRY_FOREVER)
 		retries = -1;
 	else
 		retries = cfg->max_retries;
@@ -422,7 +422,7 @@ max_retries_store(
 		return -EINVAL;
 
 	if (val == -1)
-		cfg->retry_timeout = XFS_ERR_RETRY_FOREVER;
+		cfg->max_retries = XFS_ERR_RETRY_FOREVER;
 	else
 		cfg->max_retries = val;
 	return count;

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 205/206] clocksource/dummy_timer: Move hotplug callback after the real timers
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (185 preceding siblings ...)
  2017-01-10 13:38   ` [PATCH 4.9 204/206] xfs: fix max_retries _show and _store functions Greg Kroah-Hartman
@ 2017-01-10 13:38   ` Greg Kroah-Hartman
  2017-01-10 13:38   ` [PATCH 4.9 206/206] tick/broadcast: Prevent NULL pointer dereference Greg Kroah-Hartman
                     ` (2 subsequent siblings)
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:38 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Thomas Gleixner, Mark Rutland,
	Anna-Maria Gleixner, Richard Cochran, Sebastian Andrzej Siewior,
	Daniel Lezcano, Sebastian Frias, Thibaud Cornic, Robin Murphy,
	Peter Zijlstra

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Thomas Gleixner <tglx@linutronix.de>

commit 9bf11ecce5a2758e5a097c2f3a13d08552d0d6f9 upstream.

When the dummy timer callback is invoked before the real timer callbacks,
then it tries to install that timer for the starting CPU. If the platform
does not have a broadcast timer installed the installation fails with a
kernel crash. The crash happens due to a unconditional deference of the non
available broadcast device. This needs to be fixed in the timer core code.

But even when this is fixed in the core code then installing the dummy
timer before the real timers is a pointless exercise.

Move it to the end of the callback list.

Fixes: 00c1d17aab51 ("clocksource/dummy_timer: Convert to hotplug state machine")
Reported-and-tested-by: Mason <slash.tmp@free.fr>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Anna-Maria Gleixner <anna-maria@linutronix.de>
Cc: Richard Cochran <rcochran@linutronix.de>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
Cc: Sebastian Frias <sf84@laposte.net>
Cc: Thibaud Cornic <thibaud_cornic@sigmadesigns.com>
Cc: Robin Murphy <robin.murphy@arm.com>
Link: http://lkml.kernel.org/r/1147ef90-7877-e4d2-bb2b-5c4fa8d3144b@free.fr
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 include/linux/cpuhotplug.h |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -80,7 +80,6 @@ enum cpuhp_state {
 	CPUHP_AP_ARM_L2X0_STARTING,
 	CPUHP_AP_ARM_ARCH_TIMER_STARTING,
 	CPUHP_AP_ARM_GLOBAL_TIMER_STARTING,
-	CPUHP_AP_DUMMY_TIMER_STARTING,
 	CPUHP_AP_JCORE_TIMER_STARTING,
 	CPUHP_AP_EXYNOS4_MCT_TIMER_STARTING,
 	CPUHP_AP_ARM_TWD_STARTING,
@@ -94,6 +93,8 @@ enum cpuhp_state {
 	CPUHP_AP_KVM_ARM_VGIC_INIT_STARTING,
 	CPUHP_AP_KVM_ARM_VGIC_STARTING,
 	CPUHP_AP_KVM_ARM_TIMER_STARTING,
+	/* Must be the last timer callback */
+	CPUHP_AP_DUMMY_TIMER_STARTING,
 	CPUHP_AP_ARM_XEN_STARTING,
 	CPUHP_AP_ARM_CORESIGHT_STARTING,
 	CPUHP_AP_ARM_CORESIGHT4_STARTING,

^ permalink raw reply	[flat|nested] 196+ messages in thread

* [PATCH 4.9 206/206] tick/broadcast: Prevent NULL pointer dereference
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (186 preceding siblings ...)
  2017-01-10 13:38   ` [PATCH 4.9 205/206] clocksource/dummy_timer: Move hotplug callback after the real timers Greg Kroah-Hartman
@ 2017-01-10 13:38   ` Greg Kroah-Hartman
  2017-01-10 17:33   ` [PATCH 4.9 000/206] 4.9.3-stable review Shuah Khan
  2017-01-10 22:28   ` Guenter Roeck
  189 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 13:38 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Mason, Thomas Gleixner, Mark Rutland,
	Anna-Maria Gleixner, Richard Cochran, Sebastian Andrzej Siewior,
	Daniel Lezcano, Sebastian Frias, Thibaud Cornic, Robin Murphy,
	Peter Zijlstra

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Thomas Gleixner <tglx@linutronix.de>

commit c1a9eeb938b5433947e5ea22f89baff3182e7075 upstream.

When a disfunctional timer, e.g. dummy timer, is installed, the tick core
tries to setup the broadcast timer.

If no broadcast device is installed, the kernel crashes with a NULL pointer
dereference in tick_broadcast_setup_oneshot() because the function has no
sanity check.

Reported-by: Mason <slash.tmp@free.fr>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Anna-Maria Gleixner <anna-maria@linutronix.de>
Cc: Richard Cochran <rcochran@linutronix.de>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
Cc: Sebastian Frias <sf84@laposte.net>
Cc: Thibaud Cornic <thibaud_cornic@sigmadesigns.com>
Cc: Robin Murphy <robin.murphy@arm.com>
Link: http://lkml.kernel.org/r/1147ef90-7877-e4d2-bb2b-5c4fa8d3144b@free.fr
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 kernel/time/tick-broadcast.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/kernel/time/tick-broadcast.c
+++ b/kernel/time/tick-broadcast.c
@@ -871,6 +871,9 @@ void tick_broadcast_setup_oneshot(struct
 {
 	int cpu = smp_processor_id();
 
+	if (!bc)
+		return;
+
 	/* Set it up only once ! */
 	if (bc->event_handler != tick_handle_oneshot_broadcast) {
 		int was_periodic = clockevent_state_periodic(bc);

^ permalink raw reply	[flat|nested] 196+ messages in thread

* Re: [PATCH 4.9 000/206] 4.9.3-stable review
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (187 preceding siblings ...)
  2017-01-10 13:38   ` [PATCH 4.9 206/206] tick/broadcast: Prevent NULL pointer dereference Greg Kroah-Hartman
@ 2017-01-10 17:33   ` Shuah Khan
  2017-01-10 17:40     ` Greg Kroah-Hartman
  2017-01-10 22:28   ` Guenter Roeck
  189 siblings, 1 reply; 196+ messages in thread
From: Shuah Khan @ 2017-01-10 17:33 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: torvalds, akpm, linux, patches, ben.hutchings, stable, Shuah Khan

On 01/10/2017 06:34 AM, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 4.9.3 release.
> There are 206 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Thu Jan 12 13:14:24 UTC 2017.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
> 	kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.9.3-rc1.gz
> or in the git tree and branch at:
>   git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.9.y
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h
> 

Compiled and booted on my test system. No dmesg regressions.

thanks,
-- Shuah


-- 
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America(Silicon Valley)
shuah.kh@samsung.com

^ permalink raw reply	[flat|nested] 196+ messages in thread

* Re: [PATCH 4.9 000/206] 4.9.3-stable review
  2017-01-10 17:33   ` [PATCH 4.9 000/206] 4.9.3-stable review Shuah Khan
@ 2017-01-10 17:40     ` Greg Kroah-Hartman
  0 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-10 17:40 UTC (permalink / raw)
  To: Shuah Khan
  Cc: linux-kernel, torvalds, akpm, linux, patches, ben.hutchings, stable

On Tue, Jan 10, 2017 at 10:33:04AM -0700, Shuah Khan wrote:
> On 01/10/2017 06:34 AM, Greg Kroah-Hartman wrote:
> > This is the start of the stable review cycle for the 4.9.3 release.
> > There are 206 patches in this series, all will be posted as a response
> > to this one.  If anyone has any issues with these being applied, please
> > let me know.
> > 
> > Responses should be made by Thu Jan 12 13:14:24 UTC 2017.
> > Anything received after that time might be too late.
> > 
> > The whole patch series can be found in one patch at:
> > 	kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.9.3-rc1.gz
> > or in the git tree and branch at:
> >   git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.9.y
> > and the diffstat can be found below.
> > 
> > thanks,
> > 
> > greg k-h
> > 
> 
> Compiled and booted on my test system. No dmesg regressions.

Great, thanks for testing these and letting me know.

greg k-h

^ permalink raw reply	[flat|nested] 196+ messages in thread

* Re: [PATCH 4.9 000/206] 4.9.3-stable review
  2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
                     ` (188 preceding siblings ...)
  2017-01-10 17:33   ` [PATCH 4.9 000/206] 4.9.3-stable review Shuah Khan
@ 2017-01-10 22:28   ` Guenter Roeck
  2017-01-11  6:51     ` Greg Kroah-Hartman
  189 siblings, 1 reply; 196+ messages in thread
From: Guenter Roeck @ 2017-01-10 22:28 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, torvalds, akpm, shuah.kh, patches, ben.hutchings, stable

On Tue, Jan 10, 2017 at 02:34:43PM +0100, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 4.9.3 release.
> There are 206 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Thu Jan 12 13:14:24 UTC 2017.
> Anything received after that time might be too late.
> 

Build results:
	total: 150 pass: 149 fail: 1
Failed builds:
	avr32:merisc_defconfig
Qemu test results:
	total: 122 pass: 122 fail: 0

Details are available at http://kerneltests.org/builders.

Guenter

^ permalink raw reply	[flat|nested] 196+ messages in thread

* Re: [PATCH 4.9 000/206] 4.9.3-stable review
  2017-01-10 22:28   ` Guenter Roeck
@ 2017-01-11  6:51     ` Greg Kroah-Hartman
  2017-01-11 11:05       ` Guenter Roeck
  0 siblings, 1 reply; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-11  6:51 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: linux-kernel, torvalds, akpm, shuah.kh, patches, ben.hutchings, stable

On Tue, Jan 10, 2017 at 02:28:07PM -0800, Guenter Roeck wrote:
> On Tue, Jan 10, 2017 at 02:34:43PM +0100, Greg Kroah-Hartman wrote:
> > This is the start of the stable review cycle for the 4.9.3 release.
> > There are 206 patches in this series, all will be posted as a response
> > to this one.  If anyone has any issues with these being applied, please
> > let me know.
> > 
> > Responses should be made by Thu Jan 12 13:14:24 UTC 2017.
> > Anything received after that time might be too late.
> > 
> 
> Build results:
> 	total: 150 pass: 149 fail: 1
> Failed builds:
> 	avr32:merisc_defconfig
> Qemu test results:
> 	total: 122 pass: 122 fail: 0
> 
> Details are available at http://kerneltests.org/builders.

This is the "known to fail" failure, correct?

Thanks for testing these and letting me know.

greg k-h

^ permalink raw reply	[flat|nested] 196+ messages in thread

* Re: [PATCH 4.9 000/206] 4.9.3-stable review
  2017-01-11  6:51     ` Greg Kroah-Hartman
@ 2017-01-11 11:05       ` Guenter Roeck
  0 siblings, 0 replies; 196+ messages in thread
From: Guenter Roeck @ 2017-01-11 11:05 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, torvalds, akpm, shuah.kh, patches, ben.hutchings, stable

On 01/10/2017 10:51 PM, Greg Kroah-Hartman wrote:
> On Tue, Jan 10, 2017 at 02:28:07PM -0800, Guenter Roeck wrote:
>> On Tue, Jan 10, 2017 at 02:34:43PM +0100, Greg Kroah-Hartman wrote:
>>> This is the start of the stable review cycle for the 4.9.3 release.
>>> There are 206 patches in this series, all will be posted as a response
>>> to this one.  If anyone has any issues with these being applied, please
>>> let me know.
>>>
>>> Responses should be made by Thu Jan 12 13:14:24 UTC 2017.
>>> Anything received after that time might be too late.
>>>
>>
>> Build results:
>> 	total: 150 pass: 149 fail: 1
>> Failed builds:
>> 	avr32:merisc_defconfig
>> Qemu test results:
>> 	total: 122 pass: 122 fail: 0
>>
>> Details are available at http://kerneltests.org/builders.
>
> This is the "known to fail" failure, correct?
>

Yes, sorry, I didn't bother to spell it out.

Guenter

^ permalink raw reply	[flat|nested] 196+ messages in thread

* RE: [PATCH 4.9 094/206] nl80211: Use different attrs for BSSID and random MAC addr in scan req
  2017-01-10 13:36   ` [PATCH 4.9 094/206] nl80211: Use different attrs for BSSID and random MAC addr in scan req Greg Kroah-Hartman
@ 2017-07-21  9:40     ` Krishna Vamsi
  2017-07-21 10:22       ` Greg Kroah-Hartman
  0 siblings, 1 reply; 196+ messages in thread
From: Krishna Vamsi @ 2017-07-21  9:40 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel; +Cc: stable, Jouni Malinen, Johannes Berg

Hello Greg,

Really sorry that I couldn't find this earlier but there is one issue with this cherry-pick. In "enum nl80211_commands", there are more variables between NL80211_ATTR_NAN_MATCH and NL80211_ATTR_BSSID. But they are missing in this cherry-pick. The missing variables are 
NL80211_ATTR_FILS_KEK, NL80211_ATTR_FILS_NONCES andNL80211_ATTR_MULTICAST_TO_UNICAST_ENABLED. Because of this NL80211_ATTR_BSSID value might not be consistent across different releases. Could you please let me know the next steps on this?

Thanks,
Vamsi

> -----Original Message-----
> From: Greg Kroah-Hartman [mailto:gregkh@linuxfoundation.org]
> Sent: Tuesday, January 10, 2017 7:06 PM
> To: linux-kernel@vger.kernel.org
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>;
> stable@vger.kernel.org; Vamsi, Krishna <vamsin@qti.qualcomm.com>;
> Malinen, Jouni <jouni@qca.qualcomm.com>; Johannes Berg
> <johannes.berg@intel.com>
> Subject: [PATCH 4.9 094/206] nl80211: Use different attrs for BSSID and
> random MAC addr in scan req
> 
> 4.9-stable review patch.  If anyone has any objections, please let me know.
> 
> ------------------
> 
> From: Vamsi Krishna <vamsin@qti.qualcomm.com>
> 
> commit 2fa436b3a2a7009c11a3bc03fe0ff4c26e80fd87 upstream.
> 
> NL80211_ATTR_MAC was used to set both the specific BSSID to be scanned and
> the random MAC address to be used when privacy is enabled. When both the
> features are enabled, both the BSSID and the local MAC address were getting
> same value causing Probe Request frames to go with unintended DA. Hence,
> this has been fixed by using a different NL80211_ATTR_BSSID attribute to set
> the specific BSSID (which was the more recent addition in cfg80211) for a scan.
> 
> Backwards compatibility with old userspace software is maintained to some
> extent by allowing NL80211_ATTR_MAC to be used to set the specific BSSID
> when scanning without enabling random MAC address use.
> 
> Scanning with random source MAC address was introduced by commit
> ad2b26abc157 ("cfg80211: allow drivers to support random MAC addresses for
> scan") and the issue was introduced with the addition of the second user for the
> same attribute in commit 818965d39177 ("cfg80211: Allow a scan request for a
> specific BSSID").
> 
> Fixes: 818965d39177 ("cfg80211: Allow a scan request for a specific BSSID")
> Signed-off-by: Vamsi Krishna <vamsin@qti.qualcomm.com>
> Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> 
> ---
>  include/uapi/linux/nl80211.h |    7 ++++++-
>  net/wireless/nl80211.c       |   16 +++++++++++++++-
>  2 files changed, 21 insertions(+), 2 deletions(-)
> 
> --- a/include/uapi/linux/nl80211.h
> +++ b/include/uapi/linux/nl80211.h
> @@ -323,7 +323,7 @@
>   * @NL80211_CMD_GET_SCAN: get scan results
>   * @NL80211_CMD_TRIGGER_SCAN: trigger a new scan with the given
> parameters
>   *	%NL80211_ATTR_TX_NO_CCK_RATE is used to decide whether to send
> the
> - *	probe requests at CCK rate or not. %NL80211_ATTR_MAC can be used
> to
> + *	probe requests at CCK rate or not. %NL80211_ATTR_BSSID can be used
> to
>   *	specify a BSSID to scan for; if not included, the wildcard BSSID will
>   *	be used.
>   * @NL80211_CMD_NEW_SCAN_RESULTS: scan notification (as a reply to @@
> -1937,6 +1937,9 @@ enum nl80211_commands {
>   * @NL80211_ATTR_NAN_MATCH: used to report a match. This is a nested
> attribute.
>   *	See &enum nl80211_nan_match_attributes.
>   *
> + * @NL80211_ATTR_BSSID: The BSSID of the AP. Note that
> %NL80211_ATTR_MAC is also
> + *	used in various commands/events for specifying the BSSID.
> + *
>   * @NUM_NL80211_ATTR: total number of nl80211_attrs available
>   * @NL80211_ATTR_MAX: highest attribute number currently defined
>   * @__NL80211_ATTR_AFTER_LAST: internal use @@ -2336,6 +2339,8 @@
> enum nl80211_attrs {
>  	NL80211_ATTR_NAN_FUNC,
>  	NL80211_ATTR_NAN_MATCH,
> 
> +	NL80211_ATTR_BSSID,
> +
>  	/* add attributes here, update the policy in nl80211.c */
> 
>  	__NL80211_ATTR_AFTER_LAST,
> --- a/net/wireless/nl80211.c
> +++ b/net/wireless/nl80211.c
> @@ -414,6 +414,7 @@ static const struct nla_policy nl80211_p
>  	[NL80211_ATTR_NAN_MASTER_PREF] = { .type = NLA_U8 },
>  	[NL80211_ATTR_NAN_DUAL] = { .type = NLA_U8 },
>  	[NL80211_ATTR_NAN_FUNC] = { .type = NLA_NESTED },
> +	[NL80211_ATTR_BSSID] = { .len = ETH_ALEN },
>  };
> 
>  /* policy for the key attributes */
> @@ -6677,7 +6678,20 @@ static int nl80211_trigger_scan(struct s
>  	request->no_cck =
>  		nla_get_flag(info->attrs[NL80211_ATTR_TX_NO_CCK_RATE]);
> 
> -	if (info->attrs[NL80211_ATTR_MAC])
> +	/* Initial implementation used NL80211_ATTR_MAC to set the specific
> +	 * BSSID to scan for. This was problematic because that same attribute
> +	 * was already used for another purpose (local random MAC address).
> The
> +	 * NL80211_ATTR_BSSID attribute was added to fix this. For backwards
> +	 * compatibility with older userspace components, also use the
> +	 * NL80211_ATTR_MAC value here if it can be determined to be used
> for
> +	 * the specific BSSID use case instead of the random MAC address
> +	 * (NL80211_ATTR_SCAN_FLAGS is used to enable random MAC
> address use).
> +	 */
> +	if (info->attrs[NL80211_ATTR_BSSID])
> +		memcpy(request->bssid,
> +		       nla_data(info->attrs[NL80211_ATTR_BSSID]), ETH_ALEN);
> +	else if (!(request->flags & NL80211_SCAN_FLAG_RANDOM_ADDR) &&
> +		 info->attrs[NL80211_ATTR_MAC])
>  		memcpy(request->bssid, nla_data(info-
> >attrs[NL80211_ATTR_MAC]),
>  		       ETH_ALEN);
>  	else
> 

^ permalink raw reply	[flat|nested] 196+ messages in thread

* Re: [PATCH 4.9 094/206] nl80211: Use different attrs for BSSID and random MAC addr in scan req
  2017-07-21  9:40     ` Krishna Vamsi
@ 2017-07-21 10:22       ` Greg Kroah-Hartman
  0 siblings, 0 replies; 196+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-21 10:22 UTC (permalink / raw)
  To: Krishna Vamsi; +Cc: linux-kernel, stable, Jouni Malinen, Johannes Berg

On Fri, Jul 21, 2017 at 09:40:02AM +0000, Krishna Vamsi wrote:
> Hello Greg,
> 
> Really sorry that I couldn't find this earlier but there is one issue with this cherry-pick. In "enum nl80211_commands", there are more variables between NL80211_ATTR_NAN_MATCH and NL80211_ATTR_BSSID. But they are missing in this cherry-pick. The missing variables are 
> NL80211_ATTR_FILS_KEK, NL80211_ATTR_FILS_NONCES andNL80211_ATTR_MULTICAST_TO_UNICAST_ENABLED. Because of this NL80211_ATTR_BSSID value might not be consistent across different releases. Could you please let me know the next steps on this?

Can you send me a fix-up patch for this?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 196+ messages in thread

end of thread, other threads:[~2017-07-21 10:23 UTC | newest]

Thread overview: 196+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20170110134513epcas2p2c646e3ea1a7830fa21492a70ab52e81a@epcas2p2.samsung.com>
2017-01-10 13:34 ` [PATCH 4.9 000/206] 4.9.3-stable review Greg Kroah-Hartman
2017-01-10 13:34   ` [PATCH 4.9 001/206] iio: common: st_sensors: fix channel data parsing Greg Kroah-Hartman
2017-01-10 13:34   ` [PATCH 4.9 002/206] iio: max44000: correct value in illuminance_integration_time_available Greg Kroah-Hartman
2017-01-10 13:34   ` [PATCH 4.9 003/206] iio: bmi160: Fix time needed to sleep after command execution Greg Kroah-Hartman
2017-01-10 13:34   ` [PATCH 4.9 004/206] staging: octeon: Call SET_NETDEV_DEV() Greg Kroah-Hartman
2017-01-10 13:34   ` [PATCH 4.9 005/206] ALSA: hda - Fix up GPIO for ASUS ROG Ranger Greg Kroah-Hartman
2017-01-10 13:34   ` [PATCH 4.9 006/206] ALSA: hda - Apply asus-mode8 fixup to ASUS X71SL Greg Kroah-Hartman
2017-01-10 13:34   ` [PATCH 4.9 007/206] ALSA: usb-audio: Fix irq/process data synchronization Greg Kroah-Hartman
2017-01-10 13:34   ` [PATCH 4.9 008/206] fscrypt: fix renaming and linking special files Greg Kroah-Hartman
2017-01-10 13:34   ` [PATCH 4.9 009/206] parisc: Add line-break when printing segfault info Greg Kroah-Hartman
2017-01-10 13:34   ` [PATCH 4.9 010/206] parisc: Mark cr16 clocksource unstable on SMP systems Greg Kroah-Hartman
2017-01-10 13:34   ` [PATCH 4.9 011/206] HID: sensor-hub: Move the memset to sensor_hub_get_feature() Greg Kroah-Hartman
2017-01-10 13:34   ` [PATCH 4.9 012/206] ARM: davinci: da850: dont add emac clock to lookup table twice Greg Kroah-Hartman
2017-01-10 13:34   ` [PATCH 4.9 013/206] pinctrl/amd: Set the level based on ACPI tables Greg Kroah-Hartman
2017-01-10 13:34   ` [PATCH 4.9 014/206] mac80211: initialize fast-xmit info later Greg Kroah-Hartman
2017-01-10 13:34   ` [PATCH 4.9 016/206] gcc-plugins: update gcc-common.h for gcc-7 Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 021/206] KVM: x86: reset MMU on KVM_SET_VCPU_EVENTS Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 024/206] usb: musb: core: add clear_ep_rxintr() to musb_platform_ops Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 025/206] usb: musb: dsps: implement clear_ep_rxintr() callback Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 026/206] usb: storage: unusual_uas: Add JMicron JMS56x to unusual device Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 027/206] usb: gadgetfs: restrict upper bound on device configuration size Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 028/206] USB: gadgetfs: fix unbounded memory allocation bug Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 029/206] USB: gadgetfs: fix use-after-free bug Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 030/206] USB: gadgetfs: fix checks of wTotalLength in config descriptors Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 031/206] USB: fix problems with duplicate endpoint addresses Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 032/206] USB: dummy-hcd: fix bug in stop_activity (handle ep0) Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 033/206] usb: gadget: composite: Test get_alt() presence instead of set_alt() Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 034/206] usb: dwc3: core: avoid Overflow events Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 035/206] usb: xhci: fix possible wild pointer Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 036/206] usb: xhci: apply XHCI_PME_STUCK_QUIRK to Intel Apollo Lake Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 037/206] xhci: free xhci virtual devices with leaf nodes first Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 038/206] usb: xhci: fix return value of xhci_setup_device() Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 039/206] usb: host: xhci: Fix possible wild pointer when handling abort command Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 040/206] xhci: Handle command completion and timeout race Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 041/206] usb: xhci: hold lock over xhci_abort_cmd_ring() Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 042/206] usb: return error code when platform_get_irq fails Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 043/206] USB: serial: omninet: fix NULL-derefs at open and disconnect Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 044/206] USB: serial: quatech2: fix sleep-while-atomic in close Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 045/206] USB: serial: pl2303: fix NULL-deref at open Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 046/206] USB: serial: keyspan_pda: verify endpoints at probe Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 047/206] USB: serial: spcp8x5: fix NULL-deref at open Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 048/206] USB: serial: io_ti: " Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 049/206] USB: serial: io_ti: fix another " Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 050/206] USB: serial: io_ti: fix I/O after disconnect Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 051/206] USB: serial: iuu_phoenix: fix NULL-deref at open Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 052/206] USB: serial: garmin_gps: fix memory leak on failed URB submit Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 053/206] USB: serial: ti_usb_3410_5052: fix NULL-deref at open Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 054/206] USB: serial: io_edgeport: " Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 055/206] USB: serial: oti6858: " Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 056/206] USB: serial: cyberjack: " Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 057/206] USB: serial: kobil_sct: fix NULL-deref in write Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 058/206] USB: serial: mos7840: fix NULL-deref at open Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 059/206] USB: serial: mos7720: " Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 060/206] USB: serial: mos7720: fix use-after-free on probe errors Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 061/206] USB: serial: mos7720: fix parport " Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 062/206] USB: serial: mos7720: fix parallel probe Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 063/206] usb: xhci-mem: use passed in GFP flags instead of GFP_KERNEL Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 064/206] xhci: Use delayed_work instead of timer for command timeout Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 065/206] xhci: Fix race related to abort operation Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 066/206] usb: dwc3: pci: add Intel Gemini Lake PCI ID Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 067/206] usb: dwc3: pci: Fix dr_mode misspelling Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 068/206] usb: dwc3: gadget: Fix full speed mode Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 069/206] usb: musb: Fix trying to free already-free IRQ 4 Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 073/206] ALSA: usb-audio: Fix bogus error return in snd_usb_create_stream() Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 074/206] USB: serial: kl5kusb105: abort on open exception path Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 075/206] usb: gadget: Fix second argument of percpu_ida_alloc() Greg Kroah-Hartman
2017-01-10 13:35   ` [PATCH 4.9 076/206] usb: gadget: fix request length error for isoc transfer Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 077/206] ARM: dts: r8a7794: Correct hsusb parent clock Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 078/206] USB: phy: am335x-control: fix device and of_node leaks Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 079/206] arm64: dts: hip06: Correct hardware pin number of usb node Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 080/206] ARM: dts: sun7i: bananapi-m1-plus: Enable USB PHY for USB host support Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 081/206] [media] dibusb: fix possible memory leak in dibusb_rc_query() Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 082/206] USB: serial: io_ti: bind to interface after fw download Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 083/206] mei: fix parameter rename KDoc Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 084/206] mei: bus: fix mei_cldev_enable KDoc Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 085/206] mei: move write cb to completion on credentials failures Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 086/206] staging: iio: ad7606: fix improper setting of oversampling pins Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 087/206] iio: accel: st_accel: fix LIS3LV02 reading and scaling Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 088/206] usb: dwc3: ep0: add dwc3_ep0_prepare_one_trb() Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 089/206] usb: dwc3: ep0: explicitly call dwc3_ep0_prepare_one_trb() Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 090/206] usb: dwc3: gadget: always unmap EP0 requests Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 093/206] mac80211: fix tid_agg_rx NULL dereference Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 094/206] nl80211: Use different attrs for BSSID and random MAC addr in scan req Greg Kroah-Hartman
2017-07-21  9:40     ` Krishna Vamsi
2017-07-21 10:22       ` Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 095/206] ath10k: fix failure to send NULL func frame for 10.4 Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 096/206] mfd: tps65217: Fix page fault on unloading modules Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 097/206] ath10k: use the right length of "background" Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 098/206] cris: Only build flash rescue image if CONFIG_ETRAX_AXISFLASHMAP is selected Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 099/206] efi/efivar_ssdt_load: Dont return success on allocation failure Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 100/206] clk: renesas: cpg-mssr: Fix inverted debug check Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 102/206] x86/prctl/uapi: Remove #ifdef for CHECKPOINT_RESTORE Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 103/206] x86/cpu: Probe CPUID leaf 6 even when cpuid_level == 6 Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 105/206] hwmon: (scpi) Fix module autoload Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 106/206] hwmon: (amc6821) sign extension temperature Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 107/206] hwmon: (ds620) Fix overflows seen when writing temperature limits Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 108/206] hwmon: (nct7802) Fix overflows seen when writing into limit attributes Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 109/206] hwmon: (g762) Fix overflows and crash seen when writing " Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 110/206] hwmon: (lm90) fix temp1_max_alarm attribute Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 111/206] Input: synaptics-rmi4 - unlock on error Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 112/206] clk: qcom: ipq806x: Fix board clk rates Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 113/206] clk: clk-wm831x: fix a logic error Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 114/206] clk: ti: dra7: fix "failed to lookup clock node gmac_gmii_ref_clk_div" boot message Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 115/206] clk: sunxi-ng: sun8i-a23: Set CLK_SET_RATE_PARENT for audio module clocks Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 116/206] clk: sunxi-ng: sun8i-h3: " Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 118/206] clk: renesas: mstp: Support 8-bit registers for r7s72100 Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 119/206] iommu/amd: Missing error code in amd_iommu_init_device() Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 120/206] iommu/amd: Fix the left value check of cmd buffer Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 121/206] iommu/vt-d: Fix pasid table size encoding Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 122/206] iommu/vt-d: Flush old iommu caches for kdump when the device gets context mapped Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 124/206] ASoC: cht_bsw_rt5645: Fix leftover kmalloc Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 125/206] ASoC: Intel: Skylake: Fix a shift wrapping bug Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 126/206] ASoC: samsung: i2s: Fixup last IRQ unsafe spin lock call Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 127/206] scsi: g_NCR5380: Fix release_region in error handling Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 128/206] scsi: mvsas: fix command_active typo Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 129/206] target/iscsi: Fix double free in lio_target_tiqn_addtpg() Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 130/206] sbp-target: Fix second argument of percpu_ida_alloc() Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 131/206] relay: check array offset before using it Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 132/206] ima: fix memory leak in ima_release_policy Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 133/206] PCI/MSI: Check for NULL affinity mask in pci_irq_get_affinity() Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 134/206] irqchip/bcm7038-l1: Implement irq_cpu_offline() callback Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 135/206] PM / wakeirq: Fix dedicated wakeirq for drivers not using autosuspend Greg Kroah-Hartman
2017-01-10 13:36   ` [PATCH 4.9 136/206] genirq/affinity: Fix node generation from cpumask Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 137/206] mmc: mmc_test: Uninitialized return value Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 138/206] rpmsg: qcom_smd: Correct return value for O_NONBLOCK Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 139/206] mm/hugetlb.c: use the right pte val for compare in hugetlb_cow Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 140/206] docs-rst: fix LaTeX \DURole renewcommand with Sphinx 1.3+ Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 141/206] mm: khugepaged: close use-after-free race during shmem collapsing Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 142/206] mm: khugepaged: fix radix tree node leak in shmem collapse error path Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 143/206] mm, compaction: fix NR_ISOLATED_* stats for pfn based migration Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 144/206] s390/crypto: unlock on error in prng_tdes_read() Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 145/206] crypto: arm64/sha2-ce - fix for big endian Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 146/206] crypto: arm64/ghash-ce " Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 147/206] crypto: arm/aes-ce " Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 148/206] crypto: arm64/aes-ccm-ce: " Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 149/206] crypto: arm64/aes-neon - " Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 150/206] crypto: arm64/sha1-ce " Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 151/206] crypto: arm64/aes-xts-ce: " Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 152/206] crypto: arm64/aes-ce - " Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 153/206] md: MD_RECOVERY_NEEDED is set for mddev->recovery Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 154/206] md: fix refcount problem on mddev when stopping array Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 155/206] f2fs: remove percpu_count due to performance regression Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 157/206] [media] staging: media: davinci_vpfe: unlock on error in vpfe_reqbufs() Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 158/206] PCI: rockchip: Fix negotiated lanes calculation Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 159/206] PCI: rockchip: Correct the use of FTS mask Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 160/206] PCI: Add Mellanox device IDs Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 161/206] PCI: Convert broken INTx masking quirks from HEADER to FINAL Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 162/206] PCI: Convert Mellanox broken INTx quirks to be for listed devices only Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 163/206] PCI: Support INTx masking on ConnectX-4 with firmware x.14.1100+ Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 164/206] PCI: Enable access to non-standard VPD for Chelsio devices (cxgb3) Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 165/206] powerpc/pci/rpadlpar: Fix device reference leaks Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 166/206] s390/topology: always use s390 specific sched_domain_topology_level Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 167/206] s390/pci: fix dma address calculation in map_sg Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 169/206] drm/i915: disable PSR by default on HSW/BDW Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 170/206] drm/i915/gen9: unconditionally apply the memory bandwidth WA Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 171/206] drm/i915/gen9: fix the WM memory bandwidth WA for Y tiling cases Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 172/206] tpm_tis: Check return values from get_burstcount Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 173/206] xfs: dont call xfs_sb_quota_from_disk twice Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 174/206] xfs: check return value of _trans_reserve_quota_nblks Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 175/206] xfs: dont skip cow forks w/ delalloc blocks in cowblocks scan Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 176/206] xfs: dont BUG() on mixed direct and mapped I/O Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 177/206] xfs: provide helper for counting extents from if_bytes Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 178/206] xfs: check minimum block size for CRC filesystems Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 179/206] xfs: fix unbalanced inode reclaim flush locking Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 180/206] xfs: new inode extent list lookup helpers Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 181/206] xfs: factor rmap btree size into the indlen calculations Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 182/206] xfs: always succeed when deduping zero bytes Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 183/206] xfs: remove prev argument to xfs_bmapi_reserve_delalloc Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 184/206] xfs: track preallocation separately in xfs_bmapi_reserve_delalloc() Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 185/206] xfs: use new extent lookup helpers in __xfs_reflink_reserve_cow Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 186/206] xfs: clean up cow fork reservation and tag inodes correctly Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 187/206] xfs: use new extent lookup helpers xfs_file_iomap_begin_delay Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 188/206] xfs: pass post-eof speculative prealloc blocks to bmapi Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 189/206] xfs: Move AGI buffer type setting to xfs_read_agi Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 190/206] xfs: pass state not whichfork to trace_xfs_extlist Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 191/206] xfs: handle cow fork in xfs_bmap_trace_exlist Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 192/206] xfs: forbid AG btrees with level == 0 Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 193/206] xfs: check for bogus values in btree block headers Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 194/206] xfs: complain if we dont get nextents bmap records Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 195/206] xfs: dont crash if reading a directory results in an unexpected hole Greg Kroah-Hartman
2017-01-10 13:37   ` [PATCH 4.9 196/206] xfs: error out if trying to add attrs and anextents > 0 Greg Kroah-Hartman
2017-01-10 13:38   ` [PATCH 4.9 197/206] xfs: dont allow di_size with high bit set Greg Kroah-Hartman
2017-01-10 13:38   ` [PATCH 4.9 198/206] xfs: dont cap maximum dedupe request length Greg Kroah-Hartman
2017-01-10 13:38   ` [PATCH 4.9 199/206] xfs: ignore leaf attr ichdr.count in verifier during log replay Greg Kroah-Hartman
2017-01-10 13:38   ` [PATCH 4.9 200/206] xfs: use GPF_NOFS when allocating btree cursors Greg Kroah-Hartman
2017-01-10 13:38   ` [PATCH 4.9 201/206] xfs: fix double-cleanup when CUI recovery fails Greg Kroah-Hartman
2017-01-10 13:38   ` [PATCH 4.9 202/206] xfs: use the actual AG length when reserving blocks Greg Kroah-Hartman
2017-01-10 13:38   ` [PATCH 4.9 203/206] xfs: fix crash and data corruption due to removal of busy COW extents Greg Kroah-Hartman
2017-01-10 13:38   ` [PATCH 4.9 204/206] xfs: fix max_retries _show and _store functions Greg Kroah-Hartman
2017-01-10 13:38   ` [PATCH 4.9 205/206] clocksource/dummy_timer: Move hotplug callback after the real timers Greg Kroah-Hartman
2017-01-10 13:38   ` [PATCH 4.9 206/206] tick/broadcast: Prevent NULL pointer dereference Greg Kroah-Hartman
2017-01-10 17:33   ` [PATCH 4.9 000/206] 4.9.3-stable review Shuah Khan
2017-01-10 17:40     ` Greg Kroah-Hartman
2017-01-10 22:28   ` Guenter Roeck
2017-01-11  6:51     ` Greg Kroah-Hartman
2017-01-11 11:05       ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).