Merge tag 'pci-v4.12-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaa...
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 9 May 2017 02:03:25 +0000 (19:03 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 9 May 2017 02:03:25 +0000 (19:03 -0700)
Pull PCI updates from Bjorn Helgaas:

 - add framework for supporting PCIe devices in Endpoint mode (Kishon
   Vijay Abraham I)

 - use non-postable PCI config space mappings when possible (Lorenzo
   Pieralisi)

 - clean up and unify mmap of PCI BARs (David Woodhouse)

 - export and unify Function Level Reset support (Christoph Hellwig)

 - avoid FLR for Intel 82579 NICs (Sasha Neftin)

 - add pci_request_irq() and pci_free_irq() helpers (Christoph Hellwig)

 - short-circuit config access failures for disconnected devices (Keith
   Busch)

 - remove D3 sleep delay when possible (Adrian Hunter)

 - freeze PME scan before suspending devices (Lukas Wunner)

 - stop disabling MSI/MSI-X in pci_device_shutdown() (Prarit Bhargava)

 - disable boot interrupt quirk for ASUS M2N-LR (Stefan Assmann)

 - add arch-specific alignment control to improve device passthrough by
   avoiding multiple BARs in a page (Yongji Xie)

 - add sysfs sriov_drivers_autoprobe to control VF driver binding
   (Bodong Wang)

 - allow slots below PCI-to-PCIe "reverse bridges" (Bjorn Helgaas)

 - fix crashes when unbinding host controllers that don't support
   removal (Brian Norris)

 - add driver for MicroSemi Switchtec management interface (Logan
   Gunthorpe)

 - add driver for Faraday Technology FTPCI100 host bridge (Linus
   Walleij)

 - add i.MX7D support (Andrey Smirnov)

 - use generic MSI support for Aardvark (Thomas Petazzoni)

 - make Rockchip driver modular (Brian Norris)

 - advertise 128-byte Read Completion Boundary support for Rockchip
   (Shawn Lin)

 - advertise PCI_EXP_LNKSTA_SLC for Rockchip root port (Shawn Lin)

 - convert atomic_t to refcount_t in HV driver (Elena Reshetova)

 - add CPU IRQ affinity in HV driver (K. Y. Srinivasan)

 - fix PCI bus removal in HV driver (Long Li)

 - add support for ThunderX2 DMA alias topology (Jayachandran C)

 - add ThunderX pass2.x 2nd node MCFG quirk (Tomasz Nowicki)

 - add ITE 8893 bridge DMA alias quirk (Jarod Wilson)

 - restrict Cavium ACS quirk only to CN81xx/CN83xx/CN88xx devices
   (Manish Jaggi)

* tag 'pci-v4.12-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci: (146 commits)
  PCI: Don't allow unbinding host controllers that aren't prepared
  ARM: DRA7: clockdomain: Change the CLKTRCTRL of CM_PCIE_CLKSTCTRL to SW_WKUP
  MAINTAINERS: Add PCI Endpoint maintainer
  Documentation: PCI: Add userguide for PCI endpoint test function
  tools: PCI: Add sample test script to invoke pcitest
  tools: PCI: Add a userspace tool to test PCI endpoint
  Documentation: misc-devices: Add Documentation for pci-endpoint-test driver
  misc: Add host side PCI driver for PCI test function device
  PCI: Add device IDs for DRA74x and DRA72x
  dt-bindings: PCI: dra7xx: Add DT bindings to enable unaligned access
  PCI: dwc: dra7xx: Workaround for errata id i870
  dt-bindings: PCI: dra7xx: Add DT bindings for PCI dra7xx EP mode
  PCI: dwc: dra7xx: Add EP mode support
  PCI: dwc: dra7xx: Facilitate wrapper and MSI interrupts to be enabled independently
  dt-bindings: PCI: Add DT bindings for PCI designware EP mode
  PCI: dwc: designware: Add EP mode support
  Documentation: PCI: Add binding documentation for pci-test endpoint function
  ixgbe: Use pcie_flr() instead of duplicating it
  IB/hfi1: Use pcie_flr() instead of duplicating it
  PCI: imx6: Fix spelling mistake: "contol" -> "control"
  ...

23 files changed:
1  2 
Documentation/ABI/testing/sysfs-bus-pci
Documentation/ioctl/ioctl-number.txt
MAINTAINERS
arch/arm/mm/nommu.c
arch/powerpc/platforms/powernv/pci-ioda.c
arch/x86/pci/i386.c
drivers/Makefile
drivers/infiniband/hw/hfi1/chip.c
drivers/infiniband/hw/hfi1/hfi.h
drivers/infiniband/hw/hfi1/pcie.c
drivers/misc/Kconfig
drivers/misc/Makefile
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
drivers/nvme/host/pci.c
drivers/pci/dwc/pcie-hisi.c
drivers/pci/irq.c
drivers/pci/msi.c
drivers/pci/pci.h
drivers/pci/probe.c
include/linux/pci.h
include/uapi/linux/Kbuild
include/uapi/linux/pci_regs.h
kernel/irq/manage.c

index e4e90104d7c38ff89bae718df7485337ee3e9108,b728f700340d0021c2f3a562e49dacdeac5fb02b..44d4b2be92fd4a56ab2420944f76669a2466a304
@@@ -299,5 -299,27 +299,27 @@@ What:            /sys/bus/pci/devices/.../revisio
  Date:         November 2016
  Contact:      Emil Velikov <emil.l.velikov@gmail.com>
  Description:
 -              This file contains the revision field of the the PCI device.
 +              This file contains the revision field of the PCI device.
                The value comes from device config space. The file is read only.
+ What:         /sys/bus/pci/devices/.../sriov_drivers_autoprobe
+ Date:         April 2017
+ Contact:      Bodong Wang<bodong@mellanox.com>
+ Description:
+               This file is associated with the PF of a device that
+               supports SR-IOV.  It determines whether newly-enabled VFs
+               are immediately bound to a driver.  It initially contains
+               1, which means the kernel automatically binds VFs to a
+               compatible driver immediately after they are enabled.  If
+               an application writes 0 to the file before enabling VFs,
+               the kernel will not bind VFs to a driver.
+               A typical use case is to write 0 to this file, then enable
+               VFs, then assign the newly-created VFs to virtual machines.
+               Note that changing this file does not affect already-
+               enabled VFs.  In this scenario, the user must first disable
+               the VFs, write 0 to sriov_drivers_autoprobe, then re-enable
+               the VFs.
+               This is similar to /sys/bus/pci/drivers_autoprobe, but
+               affects only the VFs associated with a specific PF.
index a77ead911956be7f5902b9f53da0c526119aaaf1,0682bd3eaa8a974b33dd565db978a251e13121af..eccb675a285259391f7bfb4213acc218e77b6c5f
@@@ -191,6 -191,7 +191,7 @@@ Code  Seq#(hex)    Include File            Comment
  'W'   00-1F   linux/watchdog.h        conflict!
  'W'   00-1F   linux/wanrouter.h       conflict!               (pre 3.9)
  'W'   00-3F   sound/asound.h          conflict!
+ 'W'   40-5F   drivers/pci/switch/switchtec.c
  'X'   all     fs/xfs/xfs_fs.h         conflict!
                and fs/xfs/linux-2.6/xfs_ioctl32.h
                and include/linux/falloc.h
  'c'   00-1F   linux/chio.h            conflict!
  'c'   80-9F   arch/s390/include/asm/chsc.h    conflict!
  'c'   A0-AF   arch/x86/include/asm/msr.h      conflict!
 -'d'   00-FF   linux/char/drm/drm/h    conflict!
 +'d'   00-FF   linux/char/drm/drm.h    conflict!
  'd'   02-40   pcmcia/ds.h             conflict!
  'd'   F0-FF   linux/digi1.h
  'e'   all     linux/digi1.h           conflict!
diff --combined MAINTAINERS
index 56b1111cc9c1d3e106862a961bca05f1b0ee6c40,196728ea3cf238ea9843eac13d9bf21f6acc829f..a4a9e31fed72f174d0b217f72744363d38bc2ea8
@@@ -813,7 -813,6 +813,7 @@@ W: http://wiki.analog.com
  W:    http://ez.analog.com/community/linux-device-drivers
  S:    Supported
  F:    drivers/iio/*/ad*
 +F:    drivers/iio/adc/ltc2497*
  X:    drivers/iio/*/adjd*
  F:    drivers/staging/iio/*/ad*
  F:    drivers/staging/iio/trigger/iio-trig-bfin-timer.c
@@@ -897,19 -896,12 +897,19 @@@ F:      arch/arm64/boot/dts/apm
  APPLIED MICRO (APM) X-GENE SOC ETHERNET DRIVER
  M:    Iyappan Subramanian <isubramanian@apm.com>
  M:    Keyur Chudgar <kchudgar@apm.com>
 +M:    Quan Nguyen <qnguyen@apm.com>
  S:    Supported
  F:    drivers/net/ethernet/apm/xgene/
  F:    drivers/net/phy/mdio-xgene.c
  F:    Documentation/devicetree/bindings/net/apm-xgene-enet.txt
  F:    Documentation/devicetree/bindings/net/apm-xgene-mdio.txt
  
 +APPLIED MICRO (APM) X-GENE SOC ETHERNET (V2) DRIVER
 +M:    Iyappan Subramanian <isubramanian@apm.com>
 +M:    Keyur Chudgar <kchudgar@apm.com>
 +S:    Supported
 +F:    drivers/net/ethernet/apm/xgene-v2/
 +
  APPLIED MICRO (APM) X-GENE SOC PMU
  M:    Tai Nguyen <ttnguyen@apm.com>
  S:    Supported
@@@ -984,7 -976,6 +984,7 @@@ F: arch/arm*/include/asm/perf_event.
  F:    drivers/perf/*
  F:    include/linux/perf/arm_pmu.h
  F:    Documentation/devicetree/bindings/arm/pmu.txt
 +F:    Documentation/devicetree/bindings/perf/
  
  ARM PORT
  M:    Russell King <linux@armlinux.org.uk>
@@@ -1097,8 -1088,6 +1097,8 @@@ L:      linux-arm-kernel@axis.co
  F:    arch/arm/mach-artpec
  F:    arch/arm/boot/dts/artpec6*
  F:    drivers/clk/axis
 +F:    drivers/pinctrl/pinctrl-artpec*
 +F:    Documentation/devicetree/bindings/pinctrl/axis,artpec6-pinctrl.txt
  
  ARM/ASPEED MACHINE SUPPORT
  M:    Joel Stanley <joel@jms.id.au>
@@@ -2235,7 -2224,7 +2235,7 @@@ ATMEL ISI DRIVE
  M:    Ludovic Desroches <ludovic.desroches@microchip.com>
  L:    linux-media@vger.kernel.org
  S:    Supported
 -F:    drivers/media/platform/soc_camera/atmel-isi.c
 +F:    drivers/media/platform/atmel/atmel-isi.c
  F:    include/media/atmel-isi.h
  
  ATMEL LCDFB DRIVER
@@@ -2338,6 -2327,21 +2338,6 @@@ S:     Maintaine
  F:    drivers/auxdisplay/
  F:    include/linux/cfag12864b.h
  
 -AVR32 ARCHITECTURE
 -M:    Haavard Skinnemoen <hskinnemoen@gmail.com>
 -M:    Hans-Christian Egtvedt <egtvedt@samfundet.no>
 -W:    http://www.atmel.com/products/AVR32/
 -W:    http://mirror.egtvedt.no/avr32linux.org/
 -W:    http://avrfreaks.net/
 -S:    Maintained
 -F:    arch/avr32/
 -
 -AVR32/AT32AP MACHINE SUPPORT
 -M:    Haavard Skinnemoen <hskinnemoen@gmail.com>
 -M:    Hans-Christian Egtvedt <egtvedt@samfundet.no>
 -S:    Maintained
 -F:    arch/avr32/mach-at32ap/
 -
  AX.25 NETWORK LAYER
  M:    Ralf Baechle <ralf@linux-mips.org>
  L:    linux-hams@vger.kernel.org
@@@ -2540,14 -2544,6 +2540,14 @@@ F:    block
  F:    kernel/trace/blktrace.c
  F:    lib/sbitmap.c
  
 +BFQ I/O SCHEDULER
 +M:    Paolo Valente <paolo.valente@linaro.org>
 +M:    Jens Axboe <axboe@kernel.dk>
 +L:    linux-block@vger.kernel.org
 +S:    Maintained
 +F:    block/bfq-*
 +F:    Documentation/block/bfq-iosched.txt
 +
  BLOCK2MTD DRIVER
  M:    Joern Engel <joern@lazybastard.org>
  L:    linux-mtd@lists.infradead.org
@@@ -2589,26 -2585,12 +2589,26 @@@ F:   include/uapi/linux/if_bonding.
  
  BPF (Safe dynamic programs and tools)
  M:    Alexei Starovoitov <ast@kernel.org>
 +M:    Daniel Borkmann <daniel@iogearbox.net>
  L:    netdev@vger.kernel.org
  L:    linux-kernel@vger.kernel.org
  S:    Supported
 +F:    arch/x86/net/bpf_jit*
 +F:    Documentation/networking/filter.txt
 +F:    include/linux/bpf*
 +F:    include/linux/filter.h
 +F:    include/uapi/linux/bpf*
 +F:    include/uapi/linux/filter.h
  F:    kernel/bpf/
 -F:    tools/testing/selftests/bpf/
 +F:    kernel/trace/bpf_trace.c
  F:    lib/test_bpf.c
 +F:    net/bpf/
 +F:    net/core/filter.c
 +F:    net/sched/act_bpf.c
 +F:    net/sched/cls_bpf.c
 +F:    samples/bpf/
 +F:    tools/net/bpf*
 +F:    tools/testing/selftests/bpf/
  
  BROADCOM B44 10/100 ETHERNET DRIVER
  M:    Michael Chan <michael.chan@broadcom.com>
@@@ -2955,15 -2937,6 +2955,15 @@@ W:    http://www.linux-c6x.org/wiki/index.
  S:    Maintained
  F:    arch/c6x/
  
 +CA8210 IEEE-802.15.4 RADIO DRIVER
 +M:    Harry Morris <h.morris@cascoda.com>
 +M:    linuxdev@cascoda.com
 +L:    linux-wpan@vger.kernel.org
 +W:    https://github.com/Cascoda/ca8210-linux.git
 +S:    Maintained
 +F:    drivers/net/ieee802154/ca8210.c
 +F:    Documentation/devicetree/bindings/net/ieee802154/ca8210.txt
 +
  CACHEFILES: FS-CACHE BACKEND FOR CACHING ON MOUNTED FILESYSTEMS
  M:    David Howells <dhowells@redhat.com>
  L:    linux-cachefs@redhat.com (moderated for non-subscribers)
@@@ -3051,6 -3024,7 +3051,6 @@@ CAPELLA MICROSYSTEMS LIGHT SENSOR DRIVE
  M:    Kevin Tsai <ktsai@capellamicro.com>
  S:    Maintained
  F:    drivers/iio/light/cm*
 -F:    Documentation/devicetree/bindings/i2c/trivial-admin-guide/devices.rst
  
  CAVIUM THUNDERX2 ARM64 SOC
  M:    Jayachandran C <jnair@caviumnetworks.com>
@@@ -3067,14 -3041,6 +3067,14 @@@ S:    Supporte
  F:    drivers/i2c/busses/i2c-octeon*
  F:    drivers/i2c/busses/i2c-thunderx*
  
 +CAVIUM MMC DRIVER
 +M:    Jan Glauber <jglauber@cavium.com>
 +M:    David Daney <david.daney@cavium.com>
 +M:    Steven J. Hill <Steven.Hill@cavium.com>
 +W:    http://www.cavium.com
 +S:    Supported
 +F:    drivers/mmc/host/cavium*
 +
  CAVIUM LIQUIDIO NETWORK DRIVER
  M:     Derek Chickles <derek.chickles@caviumnetworks.com>
  M:     Satanand Burla <satananda.burla@caviumnetworks.com>
@@@ -3100,7 -3066,7 +3100,7 @@@ F:      drivers/net/ieee802154/cc2520.
  F:    include/linux/spi/cc2520.h
  F:    Documentation/devicetree/bindings/net/ieee802154/cc2520.txt
  
 -CEC DRIVER
 +CEC FRAMEWORK
  M:    Hans Verkuil <hans.verkuil@cisco.com>
  L:    linux-media@vger.kernel.org
  T:    git git://linuxtv.org/media_tree.git
@@@ -3109,9 -3075,10 +3109,9 @@@ S:     Supporte
  F:    Documentation/media/kapi/cec-core.rst
  F:    Documentation/media/uapi/cec
  F:    drivers/media/cec/
 -F:    drivers/media/cec-edid.c
  F:    drivers/media/rc/keymaps/rc-cec.c
  F:    include/media/cec.h
 -F:    include/media/cec-edid.h
 +F:    include/media/cec-notifier.h
  F:    include/uapi/linux/cec.h
  F:    include/uapi/linux/cec-funcs.h
  
@@@ -3249,6 -3216,7 +3249,6 @@@ F:      drivers/platform/chrome
  
  CISCO VIC ETHERNET NIC DRIVER
  M:    Christian Benvenuti <benve@cisco.com>
 -M:    Sujith Sankar <ssujith@cisco.com>
  M:    Govindarajulu Varadarajan <_govind@gmx.com>
  M:    Neel Patel <neepatel@cisco.com>
  S:    Supported
@@@ -3482,7 -3450,6 +3482,7 @@@ T:      git git://git.kernel.org/pub/scm/lin
  T:    git git://git.linaro.org/people/vireshk/linux.git (For ARM Updates)
  B:    https://bugzilla.kernel.org
  F:    Documentation/cpu-freq/
 +F:    Documentation/devicetree/bindings/cpufreq/
  F:    drivers/cpufreq/
  F:    include/linux/cpufreq.h
  F:    tools/testing/selftests/cpufreq/
@@@ -3886,12 -3853,6 +3886,12 @@@ T:    git git://git.kernel.org/pub/scm/lin
  S:    Maintained
  F:    drivers/usb/dwc3/
  
 +DEVANTECH SRF ULTRASONIC RANGER IIO DRIVER
 +M:    Andreas Klinger <ak@it-klinger.de>
 +L:    linux-iio@vger.kernel.org
 +S:    Maintained
 +F:    drivers/iio/proximity/srf*.c
 +
  DEVICE COREDUMP (DEV_COREDUMP)
  M:    Johannes Berg <johannes@sipsolutions.net>
  L:    linux-kernel@vger.kernel.org
@@@ -4137,18 -4098,6 +4137,18 @@@ S:    Maintaine
  F:    drivers/char/dtlk.c
  F:    include/linux/dtlk.h
  
 +DPAA2 DATAPATH I/O (DPIO) DRIVER
 +M:    Roy Pledge <Roy.Pledge@nxp.com>
 +L:    linux-kernel@vger.kernel.org
 +S:    Maintained
 +F:    drivers/staging/fsl-mc/bus/dpio
 +
 +DPAA2 ETHERNET DRIVER
 +M:    Ioana Radulescu <ruxandra.radulescu@nxp.com>
 +L:    linux-kernel@vger.kernel.org
 +S:    Maintained
 +F:    drivers/staging/fsl-dpaa2/ethernet
 +
  DPT_I2O SCSI RAID DRIVER
  M:    Adaptec OEM Raid Solutions <aacraid@adaptec.com>
  L:    linux-scsi@vger.kernel.org
@@@ -4169,13 -4118,14 +4169,13 @@@ F:   drivers/block/drbd
  F:    lib/lru_cache.c
  F:    Documentation/blockdev/drbd/
  
 -DRIVER CORE, KOBJECTS, DEBUGFS, KERNFS AND SYSFS
 +DRIVER CORE, KOBJECTS, DEBUGFS AND SYSFS
  M:    Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  T:    git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git
  S:    Supported
  F:    Documentation/kobject.txt
  F:    drivers/base/
  F:    fs/debugfs/
 -F:    fs/kernfs/
  F:    fs/sysfs/
  F:    include/linux/debugfs.h
  F:    include/linux/kobj*
@@@ -4196,7 -4146,6 +4196,7 @@@ F:      Documentation/devicetree/bindings/vi
  F:    Documentation/gpu/
  F:    include/drm/
  F:    include/uapi/drm/
 +F:    include/linux/vga*
  
  DRM DRIVERS AND MISC GPU PATCHES
  M:    Daniel Vetter <daniel.vetter@intel.com>
@@@ -4210,7 -4159,6 +4210,7 @@@ F:      drivers/gpu/vga
  F:    drivers/gpu/drm/*
  F:    include/drm/drm*
  F:    include/uapi/drm/drm*
 +F:    include/linux/vga*
  
  DRM DRIVER FOR AST SERVER GRAPHICS CHIPS
  M:    Dave Airlie <airlied@redhat.com>
@@@ -4226,7 -4174,7 +4226,7 @@@ F:      drivers/gpu/drm/bridge
  DRM DRIVER FOR BOCHS VIRTUAL GPU
  M:    Gerd Hoffmann <kraxel@redhat.com>
  L:    virtualization@lists.linux-foundation.org
 -T:    git git://git.kraxel.org/linux drm-qemu
 +T:    git git://anongit.freedesktop.org/drm/drm-misc
  S:    Maintained
  F:    drivers/gpu/drm/bochs/
  
@@@ -4234,7 -4182,7 +4234,7 @@@ DRM DRIVER FOR QEMU'S CIRRUS DEVIC
  M:    Dave Airlie <airlied@redhat.com>
  M:    Gerd Hoffmann <kraxel@redhat.com>
  L:    virtualization@lists.linux-foundation.org
 -T:    git git://git.kraxel.org/linux drm-qemu
 +T:    git git://anongit.freedesktop.org/drm/drm-misc
  S:    Obsolete
  W:    https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
  F:    drivers/gpu/drm/cirrus/
@@@ -4291,7 -4239,6 +4291,7 @@@ L:      dri-devel@lists.freedesktop.or
  S:    Supported
  F:    drivers/gpu/drm/atmel-hlcdc/
  F:    Documentation/devicetree/bindings/drm/atmel/
 +T:    git git://anongit.freedesktop.org/drm/drm-misc
  
  DRM DRIVERS FOR ALLWINNER A10
  M:    Maxime Ripard  <maxime.ripard@free-electrons.com>
@@@ -4299,7 -4246,6 +4299,7 @@@ L:      dri-devel@lists.freedesktop.or
  S:    Supported
  F:    drivers/gpu/drm/sun4i/
  F:    Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt
 +T:    git git://git.kernel.org/pub/scm/linux/kernel/git/mripard/linux.git
  
  DRM DRIVERS FOR AMLOGIC SOCS
  M:    Neil Armstrong <narmstrong@baylibre.com>
@@@ -4309,9 -4255,6 +4309,9 @@@ W:      http://linux-meson.com
  S:    Supported
  F:    drivers/gpu/drm/meson/
  F:    Documentation/devicetree/bindings/display/amlogic,meson-vpu.txt
 +F:    Documentation/devicetree/bindings/display/amlogic,meson-dw-hdmi.txt
 +F:    Documentation/gpu/meson.rst
 +T:    git git://anongit.freedesktop.org/drm/drm-misc
  
  DRM DRIVERS FOR EXYNOS
  M:    Inki Dae <inki.dae@samsung.com>
@@@ -4436,14 -4379,13 +4436,14 @@@ S:   Supporte
  F:    drivers/gpu/drm/rcar-du/
  F:    drivers/gpu/drm/shmobile/
  F:    include/linux/platform_data/shmob_drm.h
 +F:    Documentation/devicetree/bindings/display/bridge/renesas,dw-hdmi.txt
  F:    Documentation/devicetree/bindings/display/renesas,du.txt
  
  DRM DRIVER FOR QXL VIRTUAL GPU
  M:    Dave Airlie <airlied@redhat.com>
  M:    Gerd Hoffmann <kraxel@redhat.com>
  L:    virtualization@lists.linux-foundation.org
 -T:    git git://git.kraxel.org/linux drm-qemu
 +T:    git git://anongit.freedesktop.org/drm/drm-misc
  S:    Maintained
  F:    drivers/gpu/drm/qxl/
  F:    include/uapi/drm/qxl_drm.h
@@@ -4454,7 -4396,6 +4454,7 @@@ L:      dri-devel@lists.freedesktop.or
  S:    Maintained
  F:    drivers/gpu/drm/rockchip/
  F:    Documentation/devicetree/bindings/display/rockchip/
 +T:    git git://anongit.freedesktop.org/drm/drm-misc
  
  DRM DRIVER FOR SAVAGE VIDEO CARDS
  S:    Orphan / Obsolete
@@@ -4470,7 -4411,7 +4470,7 @@@ DRM DRIVERS FOR ST
  M:    Benjamin Gaignard <benjamin.gaignard@linaro.org>
  M:    Vincent Abriou <vincent.abriou@st.com>
  L:    dri-devel@lists.freedesktop.org
 -T:    git http://git.linaro.org/people/benjamin.gaignard/kernel.git
 +T:    git git://anongit.freedesktop.org/drm/drm-misc
  S:    Maintained
  F:    drivers/gpu/drm/sti
  F:    Documentation/devicetree/bindings/display/st,stih4xx.txt
@@@ -4513,7 -4454,6 +4513,7 @@@ S:      Supporte
  F:    drivers/gpu/drm/vc4/
  F:    include/uapi/drm/vc4_drm.h
  F:    Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt
 +T:    git git://anongit.freedesktop.org/drm/drm-misc
  
  DRM DRIVERS FOR TI OMAP
  M:    Tomi Valkeinen <tomi.valkeinen@ti.com>
@@@ -4536,7 -4476,6 +4536,7 @@@ L:      dri-devel@lists.freedesktop.or
  S:    Maintained
  F:    drivers/gpu/drm/zte/
  F:    Documentation/devicetree/bindings/display/zte,vou.txt
 +T:    git git://anongit.freedesktop.org/drm/drm-misc
  
  DSBR100 USB FM RADIO DRIVER
  M:    Alexey Klimov <klimov.linux@gmail.com>
@@@ -4756,7 -4695,6 +4756,7 @@@ L:      linux-edac@vger.kernel.or
  L:    linux-mips@linux-mips.org
  S:    Supported
  F:    drivers/edac/octeon_edac*
 +F:    drivers/edac/thunderx_edac*
  
  EDAC-E752X
  M:    Mark Gross <mark.gross@intel.com>
@@@ -4838,12 -4776,6 +4838,12 @@@ L:    linux-edac@vger.kernel.or
  S:    Maintained
  F:    drivers/edac/mpc85xx_edac.[ch]
  
 +EDAC-PND2
 +M:    Tony Luck <tony.luck@intel.com>
 +L:    linux-edac@vger.kernel.org
 +S:    Maintained
 +F:    drivers/edac/pnd2_edac.[ch]
 +
  EDAC-PASEMI
  M:    Egor Martovetsky <egor@pasemi.com>
  L:    linux-edac@vger.kernel.org
@@@ -4991,7 -4923,6 +4991,7 @@@ F:      include/linux/netfilter_bridge
  F:    net/bridge/
  
  ETHERNET PHY LIBRARY
 +M:    Andrew Lunn <andrew@lunn.ch>
  M:    Florian Fainelli <f.fainelli@gmail.com>
  L:    netdev@vger.kernel.org
  S:    Maintained
@@@ -5179,6 -5110,7 +5179,6 @@@ F:      include/uapi/linux/firewire*.
  F:    tools/firewire/
  
  FIRMWARE LOADER (request_firmware)
 -M:    Ming Lei <ming.lei@canonical.com>
  M:    Luis R. Rodriguez <mcgrof@kernel.org>
  L:    linux-kernel@vger.kernel.org
  S:    Maintained
@@@ -5208,15 -5140,13 +5208,15 @@@ F:   include/linux/ipmi-fru.
  K:    fmc_d.*register
  
  FPGA MANAGER FRAMEWORK
 -M:    Alan Tull <atull@opensource.altera.com>
 +M:    Alan Tull <atull@kernel.org>
  R:    Moritz Fischer <moritz.fischer@ettus.com>
  L:    linux-fpga@vger.kernel.org
  S:    Maintained
  T:    git git://git.kernel.org/pub/scm/linux/kernel/git/atull/linux-fpga.git
 +F:    Documentation/fpga/
 +F:    Documentation/devicetree/bindings/fpga/
  F:    drivers/fpga/
 -F:    include/linux/fpga/fpga-mgr.h
 +F:    include/linux/fpga/
  W:    http://www.rocketboards.org
  
  FPU EMULATOR
@@@ -5328,7 -5258,6 +5328,7 @@@ M:      Scott Wood <oss@buserror.net
  L:    linuxppc-dev@lists.ozlabs.org
  L:    linux-arm-kernel@lists.infradead.org
  S:    Maintained
 +F:    Documentation/devicetree/bindings/powerpc/fsl/
  F:    drivers/soc/fsl/
  F:    include/linux/fsl/
  
@@@ -5417,12 -5346,10 +5417,12 @@@ F:   Documentation/filesystems/caching
  F:    fs/fscache/
  F:    include/linux/fscache*.h
  
 -FS-CRYPTO: FILE SYSTEM LEVEL ENCRYPTION SUPPORT
 +FSCRYPT: FILE SYSTEM LEVEL ENCRYPTION SUPPORT
  M:    Theodore Y. Ts'o <tytso@mit.edu>
  M:    Jaegeuk Kim <jaegeuk@kernel.org>
 -L:    linux-fsdevel@vger.kernel.org
 +L:    linux-fscrypt@vger.kernel.org
 +Q:    https://patchwork.kernel.org/project/linux-fscrypt/list/
 +T:    git git://git.kernel.org/pub/scm/linux/kernel/git/tytso/fscrypt.git
  S:    Supported
  F:    fs/crypto/
  F:    include/linux/fscrypt*.h
@@@ -5474,23 -5401,6 +5474,23 @@@ F:    fs/fuse
  F:    include/uapi/linux/fuse.h
  F:    Documentation/filesystems/fuse.txt
  
 +FUTEX SUBSYSTEM
 +M:    Thomas Gleixner <tglx@linutronix.de>
 +M:    Ingo Molnar <mingo@redhat.com>
 +R:    Peter Zijlstra <peterz@infradead.org>
 +R:    Darren Hart <dvhart@infradead.org>
 +L:    linux-kernel@vger.kernel.org
 +T:    git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git locking/core
 +S:    Maintained
 +F:    kernel/futex.c
 +F:    kernel/futex_compat.c
 +F:    include/asm-generic/futex.h
 +F:    include/linux/futex.h
 +F:    include/uapi/linux/futex.h
 +F:    tools/testing/selftests/futex/
 +F:    tools/perf/bench/futex*
 +F:    Documentation/*futex*
 +
  FUTURE DOMAIN TMC-16x0 SCSI DRIVER (16-bit)
  M:    Rik Faith <faith@cs.unc.edu>
  L:    linux-scsi@vger.kernel.org
@@@ -5933,13 -5843,6 +5933,13 @@@ F:    drivers/block/cciss
  F:    include/linux/cciss_ioctl.h
  F:    include/uapi/linux/cciss_ioctl.h
  
 +OPA-VNIC DRIVER
 +M:    Dennis Dalessandro <dennis.dalessandro@intel.com>
 +M:    Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>
 +L:    linux-rdma@vger.kernel.org
 +S:    Supported
 +F:    drivers/infiniband/ulp/opa_vnic
 +
  HFI1 DRIVER
  M:    Mike Marciniszyn <mike.marciniszyn@intel.com>
  M:    Dennis Dalessandro <dennis.dalessandro@intel.com>
@@@ -6102,7 -6005,7 +6102,7 @@@ M:      Sebastian Reichel <sre@kernel.org
  T:    git git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-hsi.git
  S:    Maintained
  F:    Documentation/ABI/testing/sysfs-bus-hsi
 -F:    Documentation/device-drivers/serial-interfaces.rst
 +F:    Documentation/driver-api/hsi.rst
  F:    drivers/hsi/
  F:    include/linux/hsi/
  F:    include/uapi/linux/hsi/
@@@ -6308,7 -6211,7 +6308,7 @@@ F:      drivers/crypto/nx/nx_csbcpb.
  F:    drivers/crypto/nx/nx_debugfs.h
  
  IBM Power 842 compression accelerator
 -M:    Dan Streetman <ddstreet@ieee.org>
 +M:    Haren Myneni <haren@us.ibm.com>
  S:    Supported
  F:    drivers/crypto/nx/Makefile
  F:    drivers/crypto/nx/Kconfig
@@@ -6548,7 -6451,6 +6548,7 @@@ W:      http://www.openfabrics.org
  Q:    http://patchwork.kernel.org/project/linux-rdma/list/
  T:    git git://git.kernel.org/pub/scm/linux/kernel/git/dledford/rdma.git
  S:    Supported
 +F:    Documentation/devicetree/bindings/infiniband/
  F:    Documentation/infiniband/
  F:    drivers/infiniband/
  F:    include/uapi/linux/if_infiniband.h
@@@ -6581,7 -6483,7 +6581,7 @@@ INPUT MULTITOUCH (MT) PROTOCO
  M:    Henrik Rydberg <rydberg@bitmath.org>
  L:    linux-input@vger.kernel.org
  S:    Odd fixes
 -F:    Documentation/input/multi-touch-protocol.txt
 +F:    Documentation/input/multi-touch-protocol.rst
  F:    drivers/input/input-mt.c
  K:    \b(ABS|SYN)_MT_
  
@@@ -6862,8 -6764,6 +6862,8 @@@ T:      git git://git.kernel.org/pub/scm/lin
  S:    Maintained
  F:    Documentation/devicetree/bindings/iommu/
  F:    drivers/iommu/
 +F:    include/linux/iommu.h
 +F:    include/linux/iova.h
  
  IP MASQUERADING
  M:    Juanjo Ciarlante <jjciarla@raiz.uncu.edu.ar>
@@@ -7184,9 -7084,9 +7184,9 @@@ S:      Maintaine
  F:    fs/autofs4/
  
  KERNEL BUILD + files below scripts/ (unless maintained elsewhere)
 +M:    Masahiro Yamada <yamada.masahiro@socionext.com>
  M:    Michal Marek <mmarek@suse.com>
 -T:    git git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild.git for-next
 -T:    git git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild.git rc-fixes
 +T:    git git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git
  L:    linux-kbuild@vger.kernel.org
  S:    Maintained
  F:    Documentation/kbuild/
@@@ -7270,7 -7170,6 +7270,7 @@@ S:      Supporte
  F:    Documentation/s390/kvm.txt
  F:    arch/s390/include/asm/kvm*
  F:    arch/s390/kvm/
 +F:    arch/s390/mm/gmap.c
  
  KERNEL VIRTUAL MACHINE (KVM) FOR ARM
  M:    Christoffer Dall <christoffer.dall@linaro.org>
@@@ -7304,14 -7203,6 +7304,14 @@@ F:    arch/mips/include/uapi/asm/kvm
  F:    arch/mips/include/asm/kvm*
  F:    arch/mips/kvm/
  
 +KERNFS
 +M:    Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 +M:    Tejun Heo <tj@kernel.org>
 +T:    git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git
 +S:    Supported
 +F:    include/linux/kernfs.h
 +F:    fs/kernfs/
 +
  KEXEC
  M:    Eric Biederman <ebiederm@xmission.com>
  W:    http://kernel.org/pub/linux/utils/kernel/kexec/
@@@ -7591,7 -7482,7 +7591,7 @@@ Q:      http://patchwork.ozlabs.org/project/
  T:    git git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git
  S:    Supported
  F:    Documentation/ABI/stable/sysfs-firmware-opal-*
 -F:    Documentation/devicetree/bindings/powerpc/opal/
 +F:    Documentation/devicetree/bindings/powerpc/
  F:    Documentation/devicetree/bindings/rtc/rtc-opal.txt
  F:    Documentation/devicetree/bindings/i2c/i2c-opal.txt
  F:    Documentation/powerpc/
@@@ -7807,14 -7698,6 +7807,14 @@@ S:    Maintaine
  F:    Documentation/hwmon/ltc4261
  F:    drivers/hwmon/ltc4261.c
  
 +LTC4306 I2C MULTIPLEXER DRIVER
 +M:    Michael Hennerich <michael.hennerich@analog.com>
 +W:    http://ez.analog.com/community/linux-device-drivers
 +L:    linux-i2c@vger.kernel.org
 +S:    Supported
 +F:    drivers/i2c/muxes/i2c-mux-ltc4306.c
 +F:    Documentation/devicetree/bindings/i2c/i2c-mux-ltc4306.txt
 +
  LTP (Linux Test Project)
  M:    Mike Frysinger <vapier@gentoo.org>
  M:    Cyril Hrubis <chrubis@suse.cz>
@@@ -7891,6 -7774,13 +7891,6 @@@ F:     include/net/mac80211.
  F:    net/mac80211/
  F:    drivers/net/wireless/mac80211_hwsim.[ch]
  
 -MACVLAN DRIVER
 -M:    Patrick McHardy <kaber@trash.net>
 -L:    netdev@vger.kernel.org
 -S:    Maintained
 -F:    drivers/net/macvlan.c
 -F:    include/linux/if_macvlan.h
 -
  MAILBOX API
  M:    Jassi Brar <jassisinghbrar@gmail.com>
  L:    linux-kernel@vger.kernel.org
@@@ -7961,10 -7851,8 +7961,10 @@@ S:    Maintaine
  F:    drivers/net/ethernet/marvell/mvneta.*
  
  MARVELL MWIFIEX WIRELESS DRIVER
 -M:    Amitkumar Karwar <akarwar@marvell.com>
 +M:    Amitkumar Karwar <amitkarwar@gmail.com>
  M:    Nishant Sarmukadam <nishants@marvell.com>
 +M:    Ganapathi Bhat <gbhat@marvell.com>
 +M:    Xinming Hu <huxm@marvell.com>
  L:    linux-wireless@vger.kernel.org
  S:    Maintained
  F:    drivers/net/wireless/marvell/mwifiex/
@@@ -7980,13 -7868,6 +7980,13 @@@ M:    Nicolas Pitre <nico@fluxnic.net
  S:    Odd Fixes
  F:    drivers/mmc/host/mvsdio.*
  
 +MARVELL XENON MMC/SD/SDIO HOST CONTROLLER DRIVER
 +M:    Hu Ziji <huziji@marvell.com>
 +L:    linux-mmc@vger.kernel.org
 +S:    Supported
 +F:    drivers/mmc/host/sdhci-xenon*
 +F:    Documentation/devicetree/bindings/mmc/marvell,xenon-sdhci.txt
 +
  MATROX FRAMEBUFFER DRIVER
  L:    linux-fbdev@vger.kernel.org
  S:    Orphan
@@@ -8192,7 -8073,6 +8192,7 @@@ W:      https://linuxtv.or
  Q:    http://patchwork.kernel.org/project/linux-media/list/
  T:    git git://linuxtv.org/media_tree.git
  S:    Maintained
 +F:    Documentation/devicetree/bindings/media/
  F:    Documentation/media/
  F:    drivers/media/
  F:    drivers/staging/media/
@@@ -8213,13 -8093,6 +8213,13 @@@ L:    netdev@vger.kernel.or
  S:    Maintained
  F:    drivers/net/ethernet/mediatek/
  
 +MEDIATEK JPEG DRIVER
 +M:    Rick Chang <rick.chang@mediatek.com>
 +M:    Bin Liu <bin.liu@mediatek.com>
 +S:    Supported
 +F:    drivers/media/platform/mtk-jpeg/
 +F:    Documentation/devicetree/bindings/media/mediatek-jpeg-decoder.txt
 +
  MEDIATEK MEDIA DRIVER
  M:    Tiffany Lin <tiffany.lin@mediatek.com>
  M:    Andrew-CT Chen <andrew-ct.chen@mediatek.com>
@@@ -8244,14 -8117,6 +8244,14 @@@ L:    linux-wireless@vger.kernel.or
  S:    Maintained
  F:    drivers/net/wireless/mediatek/mt7601u/
  
 +MEGACHIPS STDPXXXX-GE-B850V3-FW LVDS/DP++ BRIDGES
 +M:    Peter Senna Tschudin <peter.senna@collabora.com>
 +M:    Martin Donnelly <martin.donnelly@ge.com>
 +M:    Martyn Welch <martyn.welch@collabora.co.uk>
 +S:    Maintained
 +F:    drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c
 +F:    Documentation/devicetree/bindings/video/bridge/megachips-stdpxxxx-ge-b850v3-fw.txt
 +
  MEGARAID SCSI/SAS DRIVERS
  M:    Kashyap Desai <kashyap.desai@broadcom.com>
  M:    Sumit Saxena <sumit.saxena@broadcom.com>
@@@ -8418,7 -8283,7 +8418,7 @@@ MICROCHIP / ATMEL AT91 / AT32 SERIAL DR
  M:    Richard Genoud <richard.genoud@gmail.com>
  S:    Maintained
  F:    drivers/tty/serial/atmel_serial.c
 -F:    include/linux/atmel_serial.h
 +F:    drivers/tty/serial/atmel_serial.h
  
  MICROCHIP / ATMEL DMA DRIVER
  M:    Ludovic Desroches <ludovic.desroches@microchip.com>
@@@ -8442,6 -8307,7 +8442,6 @@@ M:      Richard Leitner <richard.leitner@ski
  L:    linux-usb@vger.kernel.org
  S:    Maintained
  F:    drivers/usb/misc/usb251xb.c
 -F:    include/linux/platform_data/usb251xb.h
  F:    Documentation/devicetree/bindings/usb/usb251xb.txt
  
  MICROSOFT SURFACE PRO 3 BUTTON DRIVER
@@@ -8814,16 -8680,14 +8814,16 @@@ F:   drivers/net/ethernet/neterion
  NETFILTER
  M:    Pablo Neira Ayuso <pablo@netfilter.org>
  M:    Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
 +M:    Florian Westphal <fw@strlen.de>
  L:    netfilter-devel@vger.kernel.org
  L:    coreteam@netfilter.org
  W:    http://www.netfilter.org/
  W:    http://www.iptables.org/
 +W:    http://www.nftables.org/
  Q:    http://patchwork.ozlabs.org/project/netfilter-devel/list/
  T:    git git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git
  T:    git git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next.git
 -S:    Supported
 +S:    Maintained
  F:    include/linux/netfilter*
  F:    include/linux/netfilter/
  F:    include/net/netfilter/
@@@ -8890,7 -8754,6 +8890,7 @@@ W:      http://www.linuxfoundation.org/en/Ne
  Q:    http://patchwork.ozlabs.org/project/netdev/list/
  T:    git git://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git
  T:    git git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git
 +B:    mailto:netdev@vger.kernel.org
  S:    Maintained
  F:    net/
  F:    include/net/
@@@ -8931,12 -8794,12 +8931,12 @@@ F:   net/core/flow.
  F:    net/xfrm/
  F:    net/key/
  F:    net/ipv4/xfrm*
 -F:    net/ipv4/esp4.c
 +F:    net/ipv4/esp4*
  F:    net/ipv4/ah4.c
  F:    net/ipv4/ipcomp.c
  F:    net/ipv4/ip_vti.c
  F:    net/ipv6/xfrm*
 -F:    net/ipv6/esp6.c
 +F:    net/ipv6/esp6*
  F:    net/ipv6/ah6.c
  F:    net/ipv6/ipcomp6.c
  F:    net/ipv6/ip6_vti.c
@@@ -8990,6 -8853,8 +8990,6 @@@ S:      Supporte
  F:    drivers/net/ethernet/qlogic/netxen/
  
  NFC SUBSYSTEM
 -M:    Lauro Ramos Venancio <lauro.venancio@openbossa.org>
 -M:    Aloisio Almeida Jr <aloisio.almeida@openbossa.org>
  M:    Samuel Ortiz <sameo@linux.intel.com>
  L:    linux-wireless@vger.kernel.org
  L:    linux-nfc@lists.01.org (subscribers-only)
@@@ -9163,6 -9028,7 +9163,6 @@@ F:      drivers/nvme/target/fcloop.
  
  NVMEM FRAMEWORK
  M:    Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
 -M:    Maxime Ripard <maxime.ripard@free-electrons.com>
  S:    Maintained
  F:    drivers/nvmem/
  F:    Documentation/devicetree/bindings/nvmem/
@@@ -9394,20 -9260,12 +9394,20 @@@ M:   Harald Welte <laforge@gnumonks.org
  S:    Maintained
  F:    drivers/char/pcmcia/cm4040_cs.*
  
 +OMNIVISION OV5647 SENSOR DRIVER
 +M:    Ramiro Oliveira <roliveir@synopsys.com>
 +L:    linux-media@vger.kernel.org
 +T:    git git://linuxtv.org/media_tree.git
 +S:    Maintained
 +F:    drivers/media/i2c/ov5647.c
 +
  OMNIVISION OV7670 SENSOR DRIVER
  M:    Jonathan Corbet <corbet@lwn.net>
  L:    linux-media@vger.kernel.org
  T:    git git://linuxtv.org/media_tree.git
  S:    Maintained
  F:    drivers/media/i2c/ov7670.c
 +F:    Documentation/devicetree/bindings/media/i2c/ov7670.txt
  
  ONENAND FLASH DRIVER
  M:    Kyungmin Park <kyungmin.park@samsung.com>
@@@ -9723,6 -9581,15 +9723,15 @@@ F:    include/linux/pci
  F:    arch/x86/pci/
  F:    arch/x86/kernel/quirks.c
  
+ PCI ENDPOINT SUBSYSTEM
+ M:    Kishon Vijay Abraham I <kishon@ti.com>
+ L:    linux-pci@vger.kernel.org
+ T:    git git://git.kernel.org/pub/scm/linux/kernel/git/kishon/pci-endpoint.git
+ S:    Supported
+ F:    drivers/pci/endpoint/
+ F:    drivers/misc/pci_endpoint_test.c
+ F:    tools/pci/
  PCI DRIVER FOR ALTERA PCIE IP
  M:    Ley Foon Tan <lftan@altera.com>
  L:    rfi@lists.rocketboards.org (moderated for non-subscribers)
@@@ -9797,6 -9664,17 +9806,17 @@@ S:    Maintaine
  F:    Documentation/devicetree/bindings/pci/aardvark-pci.txt
  F:    drivers/pci/host/pci-aardvark.c
  
+ PCI DRIVER FOR MICROSEMI SWITCHTEC
+ M:    Kurt Schwemmer <kurt.schwemmer@microsemi.com>
+ M:    Stephen Bates <stephen.bates@microsemi.com>
+ M:    Logan Gunthorpe <logang@deltatee.com>
+ L:    linux-pci@vger.kernel.org
+ S:    Maintained
+ F:    Documentation/switchtec.txt
+ F:    Documentation/ABI/testing/sysfs-class-switchtec
+ F:    drivers/pci/switch/switchtec*
+ F:    include/uapi/linux/switchtec_ioctl.h
  PCI DRIVER FOR NVIDIA TEGRA
  M:    Thierry Reding <thierry.reding@gmail.com>
  L:    linux-tegra@vger.kernel.org
@@@ -10051,8 -9929,6 +10071,8 @@@ M:    Krzysztof Kozlowski <krzk@kernel.org
  M:    Sylwester Nawrocki <s.nawrocki@samsung.com>
  L:    linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
  L:    linux-samsung-soc@vger.kernel.org (moderated for non-subscribers)
 +Q:    https://patchwork.kernel.org/project/linux-samsung-soc/list/
 +T:    git git://git.kernel.org/pub/scm/linux/kernel/git/pinctrl/samsung.git
  S:    Maintained
  F:    drivers/pinctrl/samsung/
  F:    include/dt-bindings/pinctrl/samsung.h
@@@ -10120,6 -9996,7 +10140,6 @@@ F:    drivers/scsi/pmcraid.
  PMC SIERRA PM8001 DRIVER
  M:    Jack Wang <jinpu.wang@profitbricks.com>
  M:    lindar_liu@usish.com
 -L:    pmchba@pmcs.com
  L:    linux-scsi@vger.kernel.org
  S:    Supported
  F:    drivers/scsi/pm8001/
@@@ -10218,7 -10095,7 +10238,7 @@@ W:   http://sourceforge.net/projects/acce
  PREEMPTIBLE KERNEL
  M:    Robert Love <rml@tech9.net>
  L:    kpreempt-tech@lists.sourceforge.net
 -W:    ftp://ftp.kernel.org/pub/linux/kernel/people/rml/preempt-kernel
 +W:    https://www.kernel.org/pub/linux/kernel/people/rml/preempt-kernel
  S:    Supported
  F:    Documentation/preempt-locking.txt
  F:    include/linux/preempt.h
@@@ -10355,8 -10232,6 +10375,8 @@@ F:   include/linux/pwm.
  F:    drivers/pwm/
  F:    drivers/video/backlight/pwm_bl.c
  F:    include/linux/pwm_backlight.h
 +F:    drivers/gpio/gpio-mvebu.c
 +F:    Documentation/devicetree/bindings/gpio/gpio-mvebu.txt
  
  PXA2xx/PXA3xx SUPPORT
  M:    Daniel Mack <daniel@zonque.org>
@@@ -10594,13 -10469,6 +10614,13 @@@ L: linux-fbdev@vger.kernel.or
  S:    Maintained
  F:    drivers/video/fbdev/aty/aty128fb.c
  
 +RAINSHADOW-CEC DRIVER
 +M:    Hans Verkuil <hverkuil@xs4all.nl>
 +L:    linux-media@vger.kernel.org
 +T:    git git://linuxtv.org/media_tree.git
 +S:    Maintained
 +F:    drivers/media/usb/rainshadow-cec/*
 +
  RALINK MIPS ARCHITECTURE
  M:    John Crispin <john@phrozen.org>
  L:    linux-mips@linux-mips.org
@@@ -10967,7 -10835,6 +10987,7 @@@ F:   drivers/s390/block/dasd
  F:    block/partitions/ibm.c
  
  S390 NETWORK DRIVERS
 +M:    Julian Wiedmann <jwi@linux.vnet.ibm.com>
  M:    Ursula Braun <ubraun@linux.vnet.ibm.com>
  L:    linux-s390@vger.kernel.org
  W:    http://www.ibm.com/developerworks/linux/linux390/
@@@ -10998,7 -10865,6 +11018,7 @@@ S:   Supporte
  F:    drivers/s390/scsi/zfcp_*
  
  S390 IUCV NETWORK LAYER
 +M:    Julian Wiedmann <jwi@linux.vnet.ibm.com>
  M:    Ursula Braun <ubraun@linux.vnet.ibm.com>
  L:    linux-s390@vger.kernel.org
  W:    http://www.ibm.com/developerworks/linux/linux390/
@@@ -11014,16 -10880,6 +11034,16 @@@ W: http://www.ibm.com/developerworks/li
  S:    Supported
  F:    drivers/iommu/s390-iommu.c
  
 +S390 VFIO-CCW DRIVER
 +M:    Cornelia Huck <cornelia.huck@de.ibm.com>
 +M:    Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>
 +L:    linux-s390@vger.kernel.org
 +L:    kvm@vger.kernel.org
 +S:    Supported
 +F:    drivers/s390/cio/vfio_ccw*
 +F:    Documentation/s390/vfio-ccw.txt
 +F:    include/uapi/linux/vfio_ccw.h
 +
  S3C24XX SD/MMC Driver
  M:    Ben Dooks <ben-linux@fluff.org>
  L:    linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
@@@ -11071,14 -10927,6 +11091,14 @@@ L: alsa-devel@alsa-project.org (moderat
  S:    Supported
  F:    sound/soc/samsung/
  
 +SAMSUNG EXYNOS PSEUDO RANDOM NUMBER GENERATOR (RNG) DRIVER
 +M:    Krzysztof Kozlowski <krzk@kernel.org>
 +L:    linux-crypto@vger.kernel.org
 +L:    linux-samsung-soc@vger.kernel.org
 +S:    Maintained
 +F:    drivers/crypto/exynos-rng.c
 +F:    Documentation/devicetree/bindings/rng/samsung,exynos-rng4.txt
 +
  SAMSUNG FRAMEBUFFER DRIVER
  M:    Jingoo Han <jingoohan1@gmail.com>
  L:    linux-fbdev@vger.kernel.org
@@@ -11103,14 -10951,6 +11123,14 @@@ F: Documentation/devicetree/bindings/re
  F:    Documentation/devicetree/bindings/regulator/samsung,s5m*.txt
  F:    Documentation/devicetree/bindings/clock/samsung,s2mps11.txt
  
 +SAMSUNG S5P Security SubSystem (SSS) DRIVER
 +M:    Krzysztof Kozlowski <krzk@kernel.org>
 +M:    Vladimir Zapolskiy <vz@mleia.com>
 +L:    linux-crypto@vger.kernel.org
 +L:    linux-samsung-soc@vger.kernel.org
 +S:    Maintained
 +F:    drivers/crypto/s5p-sss.c
 +
  SAMSUNG S5P/EXYNOS4 SOC SERIES CAMERA SUBSYSTEM DRIVERS
  M:    Kyungmin Park <kyungmin.park@samsung.com>
  M:    Sylwester Nawrocki <s.nawrocki@samsung.com>
@@@ -11242,12 -11082,6 +11262,12 @@@ F: include/linux/dma/dw.
  F:    include/linux/platform_data/dma-dw.h
  F:    drivers/dma/dw/
  
 +SYNOPSYS DESIGNWARE ENTERPRISE ETHERNET DRIVER
 +M:    Jie Deng <jiedeng@synopsys.com>
 +L:    netdev@vger.kernel.org
 +S:    Supported
 +F:    drivers/net/ethernet/synopsys/
 +
  SYNOPSYS DESIGNWARE I2C DRIVER
  M:    Jarkko Nikula <jarkko.nikula@linux.intel.com>
  R:    Andy Shevchenko <andriy.shevchenko@linux.intel.com>
@@@ -11286,7 -11120,6 +11306,7 @@@ F:   drivers/power/supply/bq27xxx_battery
  TIMEKEEPING, CLOCKSOURCE CORE, NTP, ALARMTIMER
  M:    John Stultz <john.stultz@linaro.org>
  M:    Thomas Gleixner <tglx@linutronix.de>
 +R:    Stephen Boyd <sboyd@codeaurora.org>
  L:    linux-kernel@vger.kernel.org
  T:    git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git timers/core
  S:    Supported
@@@ -11546,11 -11379,11 +11566,11 @@@ S:        Supporte
  F:    drivers/net/ethernet/emulex/benet/
  
  EMULEX ONECONNECT ROCE DRIVER
 -M:    Selvin Xavier <selvin.xavier@avagotech.com>
 -M:    Devesh Sharma <devesh.sharma@avagotech.com>
 +M:    Selvin Xavier <selvin.xavier@broadcom.com>
 +M:    Devesh Sharma <devesh.sharma@broadcom.com>
  L:    linux-rdma@vger.kernel.org
 -W:    http://www.emulex.com
 -S:    Supported
 +W:    http://www.broadcom.com
 +S:    Odd Fixes
  F:    drivers/infiniband/hw/ocrdma/
  F:    include/uapi/rdma/ocrdma-abi.h
  
@@@ -12352,19 -12185,12 +12372,19 @@@ F:        Documentation/accounting/taskstats
  F:    include/linux/taskstats*
  F:    kernel/taskstats.c
  
 -TC CLASSIFIER
 +TC subsystem
  M:    Jamal Hadi Salim <jhs@mojatatu.com>
 +M:    Cong Wang <xiyou.wangcong@gmail.com>
 +M:    Jiri Pirko <jiri@resnulli.us>
  L:    netdev@vger.kernel.org
  S:    Maintained
  F:    include/net/pkt_cls.h
 +F:    include/net/pkt_sched.h
 +F:    include/net/tc_act/
  F:    include/uapi/linux/pkt_cls.h
 +F:    include/uapi/linux/pkt_sched.h
 +F:    include/uapi/linux/tc_act/
 +F:    include/uapi/linux/tc_ematch/
  F:    net/sched/
  
  TCP LOW PRIORITY MODULE
@@@ -12649,6 -12475,7 +12669,6 @@@ F:   drivers/clk/ti
  F:    include/linux/clk/ti.h
  
  TI ETHERNET SWITCH DRIVER (CPSW)
 -M:    Mugunthan V N <mugunthanvnm@ti.com>
  R:    Grygorii Strashko <grygorii.strashko@ti.com>
  L:    linux-omap@vger.kernel.org
  L:    netdev@vger.kernel.org
@@@ -13294,15 -13121,6 +13314,15 @@@ F: drivers/usb
  F:    include/linux/usb.h
  F:    include/linux/usb/
  
 +USB TYPEC SUBSYSTEM
 +M:    Heikki Krogerus <heikki.krogerus@linux.intel.com>
 +L:    linux-usb@vger.kernel.org
 +S:    Maintained
 +F:    Documentation/ABI/testing/sysfs-class-typec
 +F:    Documentation/usb/typec.rst
 +F:    drivers/usb/typec/
 +F:    include/linux/usb/typec.h
 +
  USB UHCI DRIVER
  M:    Alan Stern <stern@rowland.harvard.edu>
  L:    linux-usb@vger.kernel.org
@@@ -13452,14 -13270,6 +13472,14 @@@ L: kvm@vger.kernel.or
  S:    Maintained
  F:    drivers/vfio/platform/
  
 +VGA_SWITCHEROO
 +R:    Lukas Wunner <lukas@wunner.de>
 +S:    Maintained
 +F:    Documentation/gpu/vga-switcheroo.rst
 +F:    drivers/gpu/vga/vga_switcheroo.c
 +F:    include/linux/vga_switcheroo.h
 +T:    git git://anongit.freedesktop.org/drm/drm-misc
 +
  VIDEOBUF2 FRAMEWORK
  M:    Pawel Osciak <pawel@osciak.com>
  M:    Marek Szyprowski <m.szyprowski@samsung.com>
@@@ -13477,11 -13287,8 +13497,11 @@@ L: netdev@vger.kernel.or
  S:    Maintained
  F:    include/linux/virtio_vsock.h
  F:    include/uapi/linux/virtio_vsock.h
 +F:    include/uapi/linux/vsockmon.h
 +F:    net/vmw_vsock/af_vsock_tap.c
  F:    net/vmw_vsock/virtio_transport_common.c
  F:    net/vmw_vsock/virtio_transport.c
 +F:    drivers/net/vsockmon.c
  F:    drivers/vhost/vsock.c
  F:    drivers/vhost/vsock.h
  
@@@ -13509,7 -13316,7 +13529,7 @@@ F:   drivers/virtio
  F:    tools/virtio/
  F:    drivers/net/virtio_net.c
  F:    drivers/block/virtio_blk.c
 -F:    include/linux/virtio_*.h
 +F:    include/linux/virtio*.h
  F:    include/uapi/linux/virtio_*.h
  F:    drivers/crypto/virtio/
  
@@@ -13527,7 -13334,7 +13547,7 @@@ M:   David Airlie <airlied@linux.ie
  M:    Gerd Hoffmann <kraxel@redhat.com>
  L:    dri-devel@lists.freedesktop.org
  L:    virtualization@lists.linux-foundation.org
 -T:    git git://git.kraxel.org/linux drm-qemu
 +T:    git git://anongit.freedesktop.org/drm/drm-misc
  S:    Maintained
  F:    drivers/gpu/drm/virtio/
  F:    include/uapi/linux/virtio_gpu.h
@@@ -13597,13 -13404,13 +13617,13 @@@ W:        https://linuxtv.or
  S:    Maintained
  F:    drivers/media/platform/vivid/*
  
 -VLAN (802.1Q)
 -M:    Patrick McHardy <kaber@trash.net>
 -L:    netdev@vger.kernel.org
 +VIMC VIRTUAL MEDIA CONTROLLER DRIVER
 +M:    Helen Koike <helen.koike@collabora.com>
 +L:    linux-media@vger.kernel.org
 +T:    git git://linuxtv.org/media_tree.git
 +W:    https://linuxtv.org
  S:    Maintained
 -F:    drivers/net/macvlan.c
 -F:    include/linux/if_*vlan.h
 -F:    net/8021q/
 +F:    drivers/media/platform/vimc/*
  
  VLYNQ BUS
  M:    Florian Fainelli <f.fainelli@gmail.com>
@@@ -13813,7 -13620,6 +13833,7 @@@ F:   Documentation/hwmon/wm83?
  F:    Documentation/devicetree/bindings/extcon/extcon-arizona.txt
  F:    Documentation/devicetree/bindings/regulator/arizona-regulator.txt
  F:    Documentation/devicetree/bindings/mfd/arizona.txt
 +F:    Documentation/devicetree/bindings/mfd/wm831x.txt
  F:    arch/arm/mach-s3c64xx/mach-crag6410*
  F:    drivers/clk/clk-wm83*.c
  F:    drivers/extcon/extcon-arizona.c
@@@ -13830,14 -13636,12 +13850,14 @@@ F:        drivers/mfd/cs47l24
  F:    drivers/power/supply/wm83*.c
  F:    drivers/rtc/rtc-wm83*.c
  F:    drivers/regulator/wm8*.c
 +F:    drivers/regulator/arizona*
  F:    drivers/video/backlight/wm83*_bl.c
  F:    drivers/watchdog/wm83*_wdt.c
  F:    include/linux/mfd/arizona/
  F:    include/linux/mfd/wm831x/
  F:    include/linux/mfd/wm8350/
  F:    include/linux/mfd/wm8400*
 +F:    include/linux/regulator/arizona*
  F:    include/linux/wm97xx.h
  F:    include/sound/wm????.h
  F:    sound/soc/codecs/arizona.?
@@@ -14037,7 -13841,7 +14057,7 @@@ YEALINK PHONE DRIVE
  M:    Henk Vergonet <Henk.Vergonet@gmail.com>
  L:    usbb2k-api-dev@nongnu.org
  S:    Maintained
 -F:    Documentation/input/yealink.txt
 +F:    Documentation/input/yealink.rst
  F:    drivers/input/misc/yealink.*
  
  Z8530 DRIVER FOR AX.25
diff --combined arch/arm/mm/nommu.c
index 33a45bd9686012c2547b218133f59a0169fea33d,2a3f6002efbc9882647d0fbc2363eda504ac7b1b..3b8e728cc9443975c6cd66c63350a2074df310b7
@@@ -303,10 -303,7 +303,10 @@@ static inline void set_vbar(unsigned lo
   */
  static inline bool security_extensions_enabled(void)
  {
 -      return !!cpuid_feature_extract(CPUID_EXT_PFR1, 4);
 +      /* Check CPUID Identification Scheme before ID_PFR1 read */
 +      if ((read_cpuid_id() & 0x000f0000) == 0x000f0000)
 +              return !!cpuid_feature_extract(CPUID_EXT_PFR1, 4);
 +      return 0;
  }
  
  static unsigned long __init setup_vectors_base(void)
@@@ -436,6 -433,18 +436,18 @@@ void __iomem *ioremap_wc(resource_size_
  }
  EXPORT_SYMBOL(ioremap_wc);
  
+ #ifdef CONFIG_PCI
+ #include <asm/mach/map.h>
+ void __iomem *pci_remap_cfgspace(resource_size_t res_cookie, size_t size)
+ {
+       return arch_ioremap_caller(res_cookie, size, MT_UNCACHED,
+                                  __builtin_return_address(0));
+ }
+ EXPORT_SYMBOL_GPL(pci_remap_cfgspace);
+ #endif
  void *arch_memremap_wb(phys_addr_t phys_addr, size_t size)
  {
        return (void *)phys_addr;
index 6fdbd383f67665b09c79675c95d98682d9340007,0529d5630afd8784a3e8df3f575b42239a7676af..283caf1070c95ee7c60d354e18cce8178440bc95
@@@ -14,6 -14,7 +14,6 @@@
  #include <linux/kernel.h>
  #include <linux/pci.h>
  #include <linux/crash_dump.h>
 -#include <linux/debugfs.h>
  #include <linux/delay.h>
  #include <linux/string.h>
  #include <linux/init.h>
@@@ -37,7 -38,7 +37,7 @@@
  #include <asm/iommu.h>
  #include <asm/tce.h>
  #include <asm/xics.h>
 -#include <asm/debug.h>
 +#include <asm/debugfs.h>
  #include <asm/firmware.h>
  #include <asm/pnv-pci.h>
  #include <asm/mmzone.h>
@@@ -1261,8 -1262,6 +1261,8 @@@ static void pnv_pci_ioda_setup_PEs(void
                        /* PE#0 is needed for error reporting */
                        pnv_ioda_reserve_pe(phb, 0);
                        pnv_ioda_setup_npu_PEs(hose->bus);
 +                      if (phb->model == PNV_PHB_MODEL_NPU2)
 +                              pnv_npu2_init(phb);
                }
        }
  }
@@@ -1425,7 -1424,8 +1425,7 @@@ static void pnv_pci_ioda2_release_dma_p
                iommu_group_put(pe->table_group.group);
                BUG_ON(pe->table_group.group);
        }
 -      pnv_pci_ioda2_table_free_pages(tbl);
 -      iommu_free_table(tbl, of_node_full_name(dev->dev.of_node));
 +      iommu_tce_table_put(tbl);
  }
  
  static void pnv_ioda_release_vf_PE(struct pci_dev *pdev)
@@@ -1775,20 -1775,17 +1775,20 @@@ static u64 pnv_pci_ioda_dma_get_require
  }
  
  static void pnv_ioda_setup_bus_dma(struct pnv_ioda_pe *pe,
 -                                 struct pci_bus *bus)
 +                                 struct pci_bus *bus,
 +                                 bool add_to_group)
  {
        struct pci_dev *dev;
  
        list_for_each_entry(dev, &bus->devices, bus_list) {
                set_iommu_table_base(&dev->dev, pe->table_group.tables[0]);
                set_dma_offset(&dev->dev, pe->tce_bypass_base);
 -              iommu_add_device(&dev->dev);
 +              if (add_to_group)
 +                      iommu_add_device(&dev->dev);
  
                if ((pe->flags & PNV_IODA_PE_BUS_ALL) && dev->subordinate)
 -                      pnv_ioda_setup_bus_dma(pe, dev->subordinate);
 +                      pnv_ioda_setup_bus_dma(pe, dev->subordinate,
 +                                      add_to_group);
        }
  }
  
@@@ -1860,17 -1857,6 +1860,17 @@@ static int pnv_ioda1_tce_xchg(struct io
  
        return ret;
  }
 +
 +static int pnv_ioda1_tce_xchg_rm(struct iommu_table *tbl, long index,
 +              unsigned long *hpa, enum dma_data_direction *direction)
 +{
 +      long ret = pnv_tce_xchg(tbl, index, hpa, direction);
 +
 +      if (!ret)
 +              pnv_pci_p7ioc_tce_invalidate(tbl, index, 1, true);
 +
 +      return ret;
 +}
  #endif
  
  static void pnv_ioda1_tce_free(struct iommu_table *tbl, long index,
@@@ -1885,7 -1871,6 +1885,7 @@@ static struct iommu_table_ops pnv_ioda1
        .set = pnv_ioda1_tce_build,
  #ifdef CONFIG_IOMMU_API
        .exchange = pnv_ioda1_tce_xchg,
 +      .exchange_rm = pnv_ioda1_tce_xchg_rm,
  #endif
        .clear = pnv_ioda1_tce_free,
        .get = pnv_tce_get,
  #define PHB3_TCE_KILL_INVAL_PE                PPC_BIT(1)
  #define PHB3_TCE_KILL_INVAL_ONE               PPC_BIT(2)
  
 -void pnv_pci_phb3_tce_invalidate_entire(struct pnv_phb *phb, bool rm)
 +static void pnv_pci_phb3_tce_invalidate_entire(struct pnv_phb *phb, bool rm)
  {
        __be64 __iomem *invalidate = pnv_ioda_get_inval_reg(phb, rm);
        const unsigned long val = PHB3_TCE_KILL_INVAL_ALL;
@@@ -1960,7 -1945,7 +1960,7 @@@ static void pnv_pci_ioda2_tce_invalidat
  {
        struct iommu_table_group_link *tgl;
  
 -      list_for_each_entry_rcu(tgl, &tbl->it_group_list, next) {
 +      list_for_each_entry_lockless(tgl, &tbl->it_group_list, next) {
                struct pnv_ioda_pe *pe = container_of(tgl->table_group,
                                struct pnv_ioda_pe, table_group);
                struct pnv_phb *phb = pe->phb;
        }
  }
  
 +void pnv_pci_ioda2_tce_invalidate_entire(struct pnv_phb *phb, bool rm)
 +{
 +      if (phb->model == PNV_PHB_MODEL_NPU || phb->model == PNV_PHB_MODEL_PHB3)
 +              pnv_pci_phb3_tce_invalidate_entire(phb, rm);
 +      else
 +              opal_pci_tce_kill(phb->opal_id, OPAL_PCI_TCE_KILL, 0, 0, 0, 0);
 +}
 +
  static int pnv_ioda2_tce_build(struct iommu_table *tbl, long index,
                long npages, unsigned long uaddr,
                enum dma_data_direction direction,
@@@ -2024,17 -2001,6 +2024,17 @@@ static int pnv_ioda2_tce_xchg(struct io
  
        return ret;
  }
 +
 +static int pnv_ioda2_tce_xchg_rm(struct iommu_table *tbl, long index,
 +              unsigned long *hpa, enum dma_data_direction *direction)
 +{
 +      long ret = pnv_tce_xchg(tbl, index, hpa, direction);
 +
 +      if (!ret)
 +              pnv_pci_ioda2_tce_invalidate(tbl, index, 1, true);
 +
 +      return ret;
 +}
  #endif
  
  static void pnv_ioda2_tce_free(struct iommu_table *tbl, long index,
  static void pnv_ioda2_table_free(struct iommu_table *tbl)
  {
        pnv_pci_ioda2_table_free_pages(tbl);
 -      iommu_free_table(tbl, "pnv");
  }
  
  static struct iommu_table_ops pnv_ioda2_iommu_ops = {
        .set = pnv_ioda2_tce_build,
  #ifdef CONFIG_IOMMU_API
        .exchange = pnv_ioda2_tce_xchg,
 +      .exchange_rm = pnv_ioda2_tce_xchg_rm,
  #endif
        .clear = pnv_ioda2_tce_free,
        .get = pnv_tce_get,
@@@ -2159,9 -2125,6 +2159,9 @@@ static void pnv_pci_ioda1_setup_dma_pe(
  
  found:
        tbl = pnv_pci_table_alloc(phb->hose->node);
 +      if (WARN_ON(!tbl))
 +              return;
 +
        iommu_register_group(&pe->table_group, phb->hose->global_number,
                        pe->pe_number);
        pnv_pci_link_table_and_group(phb->hose->node, 0, tbl, &pe->table_group);
                set_iommu_table_base(&pe->pdev->dev, tbl);
                iommu_add_device(&pe->pdev->dev);
        } else if (pe->flags & (PNV_IODA_PE_BUS | PNV_IODA_PE_BUS_ALL))
 -              pnv_ioda_setup_bus_dma(pe, pe->pbus);
 +              pnv_ioda_setup_bus_dma(pe, pe->pbus, true);
  
        return;
   fail:
                __free_pages(tce_mem, get_order(tce32_segsz * segs));
        if (tbl) {
                pnv_pci_unlink_table_and_group(tbl, &pe->table_group);
 -              iommu_free_table(tbl, "pnv");
 +              iommu_tce_table_put(tbl);
        }
  }
  
@@@ -2327,16 -2290,16 +2327,16 @@@ static long pnv_pci_ioda2_create_table(
        if (!tbl)
                return -ENOMEM;
  
 +      tbl->it_ops = &pnv_ioda2_iommu_ops;
 +
        ret = pnv_pci_ioda2_table_alloc_pages(nid,
                        bus_offset, page_shift, window_size,
                        levels, tbl);
        if (ret) {
 -              iommu_free_table(tbl, "pnv");
 +              iommu_tce_table_put(tbl);
                return ret;
        }
  
 -      tbl->it_ops = &pnv_ioda2_iommu_ops;
 -
        *ptbl = tbl;
  
        return 0;
@@@ -2377,7 -2340,7 +2377,7 @@@ static long pnv_pci_ioda2_setup_default
        if (rc) {
                pe_err(pe, "Failed to configure 32-bit TCE table, err %ld\n",
                                rc);
 -              pnv_ioda2_table_free(tbl);
 +              iommu_tce_table_put(tbl);
                return rc;
        }
  
@@@ -2448,8 -2411,7 +2448,8 @@@ static unsigned long pnv_pci_ioda2_get_
  
                tce_table_size /= direct_table_size;
                tce_table_size <<= 3;
 -              tce_table_size = _ALIGN_UP(tce_table_size, direct_table_size);
 +              tce_table_size = max_t(unsigned long,
 +                              tce_table_size, direct_table_size);
        }
  
        return bytes;
@@@ -2464,9 -2426,7 +2464,9 @@@ static void pnv_ioda2_take_ownership(st
  
        pnv_pci_ioda2_set_bypass(pe, false);
        pnv_pci_ioda2_unset_window(&pe->table_group, 0);
 -      pnv_ioda2_table_free(tbl);
 +      if (pe->pbus)
 +              pnv_ioda_setup_bus_dma(pe, pe->pbus, false);
 +      iommu_tce_table_put(tbl);
  }
  
  static void pnv_ioda2_release_ownership(struct iommu_table_group *table_group)
                                                table_group);
  
        pnv_pci_ioda2_setup_default_config(pe);
 +      if (pe->pbus)
 +              pnv_ioda_setup_bus_dma(pe, pe->pbus, false);
  }
  
  static struct iommu_table_group_ops pnv_pci_ioda2_ops = {
@@@ -2666,9 -2624,6 +2666,9 @@@ static long pnv_pci_ioda2_table_alloc_p
        level_shift = entries_shift + 3;
        level_shift = max_t(unsigned, level_shift, PAGE_SHIFT);
  
 +      if ((level_shift - 3) * levels + page_shift >= 60)
 +              return -EINVAL;
 +
        /* Allocate TCE table */
        addr = pnv_pci_ioda2_table_do_alloc_pages(nid, level_shift,
                        levels, tce_table_size, &offset, &total_allocated);
@@@ -2770,8 -2725,10 +2770,8 @@@ static void pnv_pci_ioda2_setup_dma_pe(
        if (rc)
                return;
  
 -      if (pe->flags & PNV_IODA_PE_DEV)
 -              iommu_add_device(&pe->pdev->dev);
 -      else if (pe->flags & (PNV_IODA_PE_BUS | PNV_IODA_PE_BUS_ALL))
 -              pnv_ioda_setup_bus_dma(pe, pe->pbus);
 +      if (pe->flags & (PNV_IODA_PE_BUS | PNV_IODA_PE_BUS_ALL))
 +              pnv_ioda_setup_bus_dma(pe, pe->pbus, true);
  }
  
  #ifdef CONFIG_PCI_MSI
@@@ -3330,6 -3287,11 +3330,11 @@@ static void pnv_pci_setup_bridge(struc
        }
  }
  
+ static resource_size_t pnv_pci_default_alignment(void)
+ {
+       return PAGE_SIZE;
+ }
  #ifdef CONFIG_PCI_IOV
  static resource_size_t pnv_pci_iov_resource_alignment(struct pci_dev *pdev,
                                                      int resno)
@@@ -3439,7 -3401,7 +3444,7 @@@ static void pnv_pci_ioda1_release_pe_dm
        }
  
        free_pages(tbl->it_base, get_order(tbl->it_size << 3));
 -      iommu_free_table(tbl, "pnv");
 +      iommu_tce_table_put(tbl);
  }
  
  static void pnv_pci_ioda2_release_pe_dma(struct pnv_ioda_pe *pe)
        }
  
        pnv_pci_ioda2_table_free_pages(tbl);
 -      iommu_free_table(tbl, "pnv");
 +      iommu_tce_table_put(tbl);
  }
  
  static void pnv_ioda_free_pe_seg(struct pnv_ioda_pe *pe,
@@@ -3863,6 -3825,8 +3868,8 @@@ static void __init pnv_pci_init_ioda_ph
                hose->controller_ops = pnv_pci_ioda_controller_ops;
        }
  
+       ppc_md.pcibios_default_alignment = pnv_pci_default_alignment;
  #ifdef CONFIG_PCI_IOV
        ppc_md.pcibios_fixup_sriov = pnv_pci_ioda_fixup_iov_resources;
        ppc_md.pcibios_iov_resource_alignment = pnv_pci_iov_resource_alignment;
diff --combined arch/x86/pci/i386.c
index 6fa84d531f4feabb5d695dae191b61d1f79cd6b3,68499cf82ccf241448b71fbd329e0fbee196fe7f..7b4307163eacc8f120983948c634d83c90155328
@@@ -34,7 -34,7 +34,7 @@@
  #include <linux/bootmem.h>
  
  #include <asm/pat.h>
 -#include <asm/e820.h>
 +#include <asm/e820/api.h>
  #include <asm/pci_x86.h>
  #include <asm/io_apic.h>
  
@@@ -398,7 -398,7 +398,7 @@@ void __init pcibios_resource_survey(voi
        list_for_each_entry(bus, &pci_root_buses, node)
                pcibios_allocate_resources(bus, 1);
  
 -      e820_reserve_resources_late();
 +      e820__reserve_resources_late();
        /*
         * Insert the IO APIC resources after PCI initialization has
         * occurred to handle IO APICS that are mapped in on a BAR in
         */
        ioapic_insert_resources();
  }
- static const struct vm_operations_struct pci_mmap_ops = {
-       .access = generic_access_phys,
- };
- int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
-                       enum pci_mmap_state mmap_state, int write_combine)
- {
-       unsigned long prot;
-       /* I/O space cannot be accessed via normal processor loads and
-        * stores on this platform.
-        */
-       if (mmap_state == pci_mmap_io)
-               return -EINVAL;
-       prot = pgprot_val(vma->vm_page_prot);
-       /*
-        * Return error if pat is not enabled and write_combine is requested.
-        * Caller can followup with UC MINUS request and add a WC mtrr if there
-        * is a free mtrr slot.
-        */
-       if (!pat_enabled() && write_combine)
-               return -EINVAL;
-       if (pat_enabled() && write_combine)
-               prot |= cachemode2protval(_PAGE_CACHE_MODE_WC);
-       else if (pat_enabled() || boot_cpu_data.x86 > 3)
-               /*
-                * ioremap() and ioremap_nocache() defaults to UC MINUS for now.
-                * To avoid attribute conflicts, request UC MINUS here
-                * as well.
-                */
-               prot |= cachemode2protval(_PAGE_CACHE_MODE_UC_MINUS);
-       vma->vm_page_prot = __pgprot(prot);
-       if (io_remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
-                              vma->vm_end - vma->vm_start,
-                              vma->vm_page_prot))
-               return -EAGAIN;
-       vma->vm_ops = &pci_mmap_ops;
-       return 0;
- }
diff --combined drivers/Makefile
index 903b19199b695410d7dff701a97c56d056bc839a,a5f8e43b2c4dc69ade5b8e4a7fdfd7ad543935f6..edba1edc66549c4b80c5cfde88f4cf8633d3e743
@@@ -14,7 -14,9 +14,9 @@@ obj-$(CONFIG_GENERIC_PHY)     += phy
  obj-$(CONFIG_PINCTRL)         += pinctrl/
  obj-$(CONFIG_GPIOLIB)         += gpio/
  obj-y                         += pwm/
  obj-$(CONFIG_PCI)             += pci/
+ obj-$(CONFIG_PCI_ENDPOINT)    += pci/endpoint/
  # PCI dwc controller drivers
  obj-y                         += pci/dwc/
  
@@@ -71,7 -73,7 +73,7 @@@ obj-$(CONFIG_PARPORT)         += parport
  obj-$(CONFIG_NVM)             += lightnvm/
  obj-y                         += base/ block/ misc/ mfd/ nfc/
  obj-$(CONFIG_LIBNVDIMM)               += nvdimm/
 -obj-$(CONFIG_DEV_DAX)         += dax/
 +obj-$(CONFIG_DAX)             += dax/
  obj-$(CONFIG_DMA_SHARED_BUFFER) += dma-buf/
  obj-$(CONFIG_NUBUS)           += nubus/
  obj-y                         += macintosh/
@@@ -104,7 -106,6 +106,7 @@@ obj-$(CONFIG_USB_PHY)              += usb
  obj-$(CONFIG_USB)             += usb/
  obj-$(CONFIG_PCI)             += usb/
  obj-$(CONFIG_USB_GADGET)      += usb/
 +obj-$(CONFIG_OF)              += usb/
  obj-$(CONFIG_SERIO)           += input/serio/
  obj-$(CONFIG_GAMEPORT)                += input/gameport/
  obj-$(CONFIG_INPUT)           += input/
index 0f6916d2d5499cc8ba02202ecfd47afd14ab93a8,d037f72e4d9603172aaf2ff8545385a9498fdc45..39279fd630bc161a5d812071bda754dd85d811a9
@@@ -1,5 -1,5 +1,5 @@@
  /*
 - * Copyright(c) 2015, 2016 Intel Corporation.
 + * Copyright(c) 2015 - 2017 Intel Corporation.
   *
   * This file is provided under a dual BSD/GPLv2 license.  When using or
   * redistributing this file, you may do so under either license.
@@@ -64,7 -64,6 +64,7 @@@
  #include "platform.h"
  #include "aspm.h"
  #include "affinity.h"
 +#include "debugfs.h"
  
  #define NUM_IB_PORTS 1
  
@@@ -126,16 -125,9 +126,16 @@@ struct flag_table 
  #define DEFAULT_KRCVQS                  2
  #define MIN_KERNEL_KCTXTS         2
  #define FIRST_KERNEL_KCTXT        1
 -/* sizes for both the QP and RSM map tables */
 -#define NUM_MAP_ENTRIES               256
 -#define NUM_MAP_REGS             32
 +
 +/*
 + * RSM instance allocation
 + *   0 - Verbs
 + *   1 - User Fecn Handling
 + *   2 - Vnic
 + */
 +#define RSM_INS_VERBS             0
 +#define RSM_INS_FECN              1
 +#define RSM_INS_VNIC              2
  
  /* Bit offset into the GUID which carries HFI id information */
  #define GUID_HFI_INDEX_SHIFT     39
  #define is_emulator_p(dd) ((((dd)->irev) & 0xf) == 3)
  #define is_emulator_s(dd) ((((dd)->irev) & 0xf) == 4)
  
 -/* RSM fields */
 -
 +/* RSM fields for Verbs */
  /* packet type */
  #define IB_PACKET_TYPE         2ull
  #define QW_SHIFT               6ull
  /* QPN[m+n:1] QW 1, OFFSET 1 */
  #define QPN_SELECT_OFFSET      ((1ull << QW_SHIFT) | (1ull))
  
 +/* RSM fields for Vnic */
 +/* L2_TYPE: QW 0, OFFSET 61 - for match */
 +#define L2_TYPE_QW             0ull
 +#define L2_TYPE_BIT_OFFSET     61ull
 +#define L2_TYPE_OFFSET(off)    ((L2_TYPE_QW << QW_SHIFT) | (off))
 +#define L2_TYPE_MATCH_OFFSET   L2_TYPE_OFFSET(L2_TYPE_BIT_OFFSET)
 +#define L2_TYPE_MASK           3ull
 +#define L2_16B_VALUE           2ull
 +
 +/* L4_TYPE QW 1, OFFSET 0 - for match */
 +#define L4_TYPE_QW              1ull
 +#define L4_TYPE_BIT_OFFSET      0ull
 +#define L4_TYPE_OFFSET(off)     ((L4_TYPE_QW << QW_SHIFT) | (off))
 +#define L4_TYPE_MATCH_OFFSET    L4_TYPE_OFFSET(L4_TYPE_BIT_OFFSET)
 +#define L4_16B_TYPE_MASK        0xFFull
 +#define L4_16B_ETH_VALUE        0x78ull
 +
 +/* 16B VESWID - for select */
 +#define L4_16B_HDR_VESWID_OFFSET  ((2 << QW_SHIFT) | (16ull))
 +/* 16B ENTROPY - for select */
 +#define L2_16B_ENTROPY_OFFSET     ((1 << QW_SHIFT) | (32ull))
 +
  /* defines to build power on SC2VL table */
  #define SC2VL_VAL( \
        num, \
@@@ -1074,8 -1045,6 +1074,8 @@@ static void dc_start(struct hfi1_devdat
  static int qos_rmt_entries(struct hfi1_devdata *dd, unsigned int *mp,
                           unsigned int *np);
  static void clear_full_mgmt_pkey(struct hfi1_pportdata *ppd);
 +static int wait_link_transfer_active(struct hfi1_devdata *dd, int wait_ms);
 +static void clear_rsm_rule(struct hfi1_devdata *dd, u8 rule_index);
  
  /*
   * Error interrupt table entry.  This is used as input to the interrupt
@@@ -6410,17 -6379,18 +6410,17 @@@ static void lcb_shutdown(struct hfi1_de
   *
   * The expectation is that the caller of this routine would have taken
   * care of properly transitioning the link into the correct state.
 + * NOTE: the caller needs to acquire the dd->dc8051_lock lock
 + *       before calling this function.
   */
 -static void dc_shutdown(struct hfi1_devdata *dd)
 +static void _dc_shutdown(struct hfi1_devdata *dd)
  {
 -      unsigned long flags;
 +      lockdep_assert_held(&dd->dc8051_lock);
  
 -      spin_lock_irqsave(&dd->dc8051_lock, flags);
 -      if (dd->dc_shutdown) {
 -              spin_unlock_irqrestore(&dd->dc8051_lock, flags);
 +      if (dd->dc_shutdown)
                return;
 -      }
 +
        dd->dc_shutdown = 1;
 -      spin_unlock_irqrestore(&dd->dc8051_lock, flags);
        /* Shutdown the LCB */
        lcb_shutdown(dd, 1);
        /*
        write_csr(dd, DC_DC8051_CFG_RST, 0x1);
  }
  
 +static void dc_shutdown(struct hfi1_devdata *dd)
 +{
 +      mutex_lock(&dd->dc8051_lock);
 +      _dc_shutdown(dd);
 +      mutex_unlock(&dd->dc8051_lock);
 +}
 +
  /*
   * Calling this after the DC has been brought out of reset should not
   * do any damage.
 + * NOTE: the caller needs to acquire the dd->dc8051_lock lock
 + *       before calling this function.
   */
 -static void dc_start(struct hfi1_devdata *dd)
 +static void _dc_start(struct hfi1_devdata *dd)
  {
 -      unsigned long flags;
 -      int ret;
 +      lockdep_assert_held(&dd->dc8051_lock);
  
 -      spin_lock_irqsave(&dd->dc8051_lock, flags);
        if (!dd->dc_shutdown)
 -              goto done;
 -      spin_unlock_irqrestore(&dd->dc8051_lock, flags);
 +              return;
 +
        /* Take the 8051 out of reset */
        write_csr(dd, DC_DC8051_CFG_RST, 0ull);
        /* Wait until 8051 is ready */
 -      ret = wait_fm_ready(dd, TIMEOUT_8051_START);
 -      if (ret) {
 +      if (wait_fm_ready(dd, TIMEOUT_8051_START))
                dd_dev_err(dd, "%s: timeout starting 8051 firmware\n",
                           __func__);
 -      }
 +
        /* Take away reset for LCB and RX FPE (set in lcb_shutdown). */
        write_csr(dd, DCC_CFG_RESET, 0x10);
        /* lcb_shutdown() with abort=1 does not restore these */
        write_csr(dd, DC_LCB_ERR_EN, dd->lcb_err_en);
 -      spin_lock_irqsave(&dd->dc8051_lock, flags);
        dd->dc_shutdown = 0;
 -done:
 -      spin_unlock_irqrestore(&dd->dc8051_lock, flags);
 +}
 +
 +static void dc_start(struct hfi1_devdata *dd)
 +{
 +      mutex_lock(&dd->dc8051_lock);
 +      _dc_start(dd);
 +      mutex_unlock(&dd->dc8051_lock);
  }
  
  /*
@@@ -6741,13 -6701,7 +6741,13 @@@ static void rxe_kernel_unfreeze(struct 
        int i;
  
        /* enable all kernel contexts */
 -      for (i = 0; i < dd->n_krcv_queues; i++) {
 +      for (i = 0; i < dd->num_rcv_contexts; i++) {
 +              struct hfi1_ctxtdata *rcd = dd->rcd[i];
 +
 +              /* Ensure all non-user contexts(including vnic) are enabled */
 +              if (!rcd || !rcd->sc || (rcd->sc->type == SC_USER))
 +                      continue;
 +
                rcvmask = HFI1_RCVCTRL_CTXT_ENB;
                /* HFI1_RCVCTRL_TAILUPD_[ENB|DIS] needs to be set explicitly */
                rcvmask |= HFI1_CAP_KGET_MASK(dd->rcd[i]->flags, DMA_RTAIL) ?
@@@ -7123,7 -7077,7 +7123,7 @@@ static void add_full_mgmt_pkey(struct h
  {
        struct hfi1_devdata *dd = ppd->dd;
  
 -      /* Sanity check - ppd->pkeys[2] should be 0, or already initalized */
 +      /* Sanity check - ppd->pkeys[2] should be 0, or already initialized */
        if (!((ppd->pkeys[2] == 0) || (ppd->pkeys[2] == FULL_MGMT_P_KEY)))
                dd_dev_warn(dd, "%s pkey[2] already set to 0x%x, resetting it to 0x%x\n",
                            __func__, ppd->pkeys[2], FULL_MGMT_P_KEY);
@@@ -7211,7 -7165,7 +7211,7 @@@ static void get_link_widths(struct hfi1
         * set the max_rate field in handle_verify_cap until v0.19.
         */
        if ((dd->icode == ICODE_RTL_SILICON) &&
 -          (dd->dc8051_ver < dc8051_ver(0, 19))) {
 +          (dd->dc8051_ver < dc8051_ver(0, 19, 0))) {
                /* max_rate: 0 = 12.5G, 1 = 25G */
                switch (max_rate) {
                case 0:
@@@ -7323,6 -7277,15 +7323,6 @@@ void handle_verify_cap(struct work_stru
        lcb_shutdown(dd, 0);
        adjust_lcb_for_fpga_serdes(dd);
  
 -      /*
 -       * These are now valid:
 -       *      remote VerifyCap fields in the general LNI config
 -       *      CSR DC8051_STS_REMOTE_GUID
 -       *      CSR DC8051_STS_REMOTE_NODE_TYPE
 -       *      CSR DC8051_STS_REMOTE_FM_SECURITY
 -       *      CSR DC8051_STS_REMOTE_PORT_NO
 -       */
 -
        read_vc_remote_phy(dd, &power_management, &continious);
        read_vc_remote_fabric(dd, &vau, &z, &vcu, &vl15buf,
                              &partner_supported_crc);
        }
  
        ppd->link_speed_active = 0;     /* invalid value */
 -      if (dd->dc8051_ver < dc8051_ver(0, 20)) {
 +      if (dd->dc8051_ver < dc8051_ver(0, 20, 0)) {
                /* remote_tx_rate: 0 = 12.5G, 1 = 25G */
                switch (remote_tx_rate) {
                case 0:
        write_csr(dd, DC_LCB_ERR_EN, 0); /* mask LCB errors */
        set_8051_lcb_access(dd);
  
 -      ppd->neighbor_guid =
 -              read_csr(dd, DC_DC8051_STS_REMOTE_GUID);
 -      ppd->neighbor_port_number = read_csr(dd, DC_DC8051_STS_REMOTE_PORT_NO) &
 -                                      DC_DC8051_STS_REMOTE_PORT_NO_VAL_SMASK;
 -      ppd->neighbor_type =
 -              read_csr(dd, DC_DC8051_STS_REMOTE_NODE_TYPE) &
 -              DC_DC8051_STS_REMOTE_NODE_TYPE_VAL_MASK;
 -      ppd->neighbor_fm_security =
 -              read_csr(dd, DC_DC8051_STS_REMOTE_FM_SECURITY) &
 -              DC_DC8051_STS_LOCAL_FM_SECURITY_DISABLED_MASK;
 -      dd_dev_info(dd,
 -                  "Neighbor Guid: %llx Neighbor type %d MgmtAllowed %d FM security bypass %d\n",
 -                  ppd->neighbor_guid, ppd->neighbor_type,
 -                  ppd->mgmt_allowed, ppd->neighbor_fm_security);
        if (ppd->mgmt_allowed)
                add_full_mgmt_pkey(ppd);
  
@@@ -7920,9 -7897,6 +7920,9 @@@ static void handle_dcc_err(struct hfi1_
                reg &= ~DCC_ERR_FLG_EN_CSR_ACCESS_BLOCKED_HOST_SMASK;
        }
  
 +      if (unlikely(hfi1_dbg_fault_suppress_err(&dd->verbs_dev)))
 +              reg &= ~DCC_ERR_FLG_LATE_EBP_ERR_SMASK;
 +
        /* report any remaining errors */
        if (reg)
                dd_dev_info_ratelimited(dd, "DCC Error: %s\n",
@@@ -8021,9 -7995,7 +8021,9 @@@ static void is_rcv_avail_int(struct hfi
        if (likely(source < dd->num_rcv_contexts)) {
                rcd = dd->rcd[source];
                if (rcd) {
 -                      if (source < dd->first_user_ctxt)
 +                      /* Check for non-user contexts, including vnic */
 +                      if ((source < dd->first_dyn_alloc_ctxt) ||
 +                          (rcd->sc && (rcd->sc->type == SC_KERNEL)))
                                rcd->do_interrupt(rcd, 0);
                        else
                                handle_user_interrupt(rcd);
@@@ -8051,8 -8023,7 +8051,8 @@@ static void is_rcv_urgent_int(struct hf
                rcd = dd->rcd[source];
                if (rcd) {
                        /* only pay attention to user urgent interrupts */
 -                      if (source >= dd->first_user_ctxt)
 +                      if ((source >= dd->first_dyn_alloc_ctxt) &&
 +                          (!rcd->sc || (rcd->sc->type == SC_USER)))
                                handle_user_interrupt(rcd);
                        return; /* OK */
                }
@@@ -8185,10 -8156,10 +8185,10 @@@ static irqreturn_t sdma_interrupt(int i
  
                /* handle the interrupt(s) */
                sdma_engine_interrupt(sde, status);
 -      } else
 +      } else {
                dd_dev_err(dd, "SDMA engine %u interrupt, but no status bits set\n",
                           sde->this_idx);
 -
 +      }
        return IRQ_HANDLED;
  }
  
@@@ -8372,52 -8343,6 +8372,52 @@@ static int read_lcb_via_8051(struct hfi
        return 0;
  }
  
 +/*
 + * Provide a cache for some of the LCB registers in case the LCB is
 + * unavailable.
 + * (The LCB is unavailable in certain link states, for example.)
 + */
 +struct lcb_datum {
 +      u32 off;
 +      u64 val;
 +};
 +
 +static struct lcb_datum lcb_cache[] = {
 +      { DC_LCB_ERR_INFO_RX_REPLAY_CNT, 0},
 +      { DC_LCB_ERR_INFO_SEQ_CRC_CNT, 0 },
 +      { DC_LCB_ERR_INFO_REINIT_FROM_PEER_CNT, 0 },
 +};
 +
 +static void update_lcb_cache(struct hfi1_devdata *dd)
 +{
 +      int i;
 +      int ret;
 +      u64 val;
 +
 +      for (i = 0; i < ARRAY_SIZE(lcb_cache); i++) {
 +              ret = read_lcb_csr(dd, lcb_cache[i].off, &val);
 +
 +              /* Update if we get good data */
 +              if (likely(ret != -EBUSY))
 +                      lcb_cache[i].val = val;
 +      }
 +}
 +
 +static int read_lcb_cache(u32 off, u64 *val)
 +{
 +      int i;
 +
 +      for (i = 0; i < ARRAY_SIZE(lcb_cache); i++) {
 +              if (lcb_cache[i].off == off) {
 +                      *val = lcb_cache[i].val;
 +                      return 0;
 +              }
 +      }
 +
 +      pr_warn("%s bad offset 0x%x\n", __func__, off);
 +      return -1;
 +}
 +
  /*
   * Read an LCB CSR.  Access may not be in host control, so check.
   * Return 0 on success, -EBUSY on failure.
@@@ -8429,13 -8354,9 +8429,13 @@@ int read_lcb_csr(struct hfi1_devdata *d
        /* if up, go through the 8051 for the value */
        if (ppd->host_link_state & HLS_UP)
                return read_lcb_via_8051(dd, addr, data);
 -      /* if going up or down, no access */
 -      if (ppd->host_link_state & (HLS_GOING_UP | HLS_GOING_OFFLINE))
 -              return -EBUSY;
 +      /* if going up or down, check the cache, otherwise, no access */
 +      if (ppd->host_link_state & (HLS_GOING_UP | HLS_GOING_OFFLINE)) {
 +              if (read_lcb_cache(addr, data))
 +                      return -EBUSY;
 +              return 0;
 +      }
 +
        /* otherwise, host has access */
        *data = read_csr(dd, addr);
        return 0;
@@@ -8450,7 -8371,7 +8450,7 @@@ static int write_lcb_via_8051(struct hf
        int ret;
  
        if (dd->icode == ICODE_FUNCTIONAL_SIMULATOR ||
 -          (dd->dc8051_ver < dc8051_ver(0, 20))) {
 +          (dd->dc8051_ver < dc8051_ver(0, 20, 0))) {
                if (acquire_lcb_access(dd, 0) == 0) {
                        write_csr(dd, addr, data);
                        release_lcb_access(dd, 0);
@@@ -8499,11 -8420,16 +8499,11 @@@ static int do_8051_command
  {
        u64 reg, completed;
        int return_code;
 -      unsigned long flags;
        unsigned long timeout;
  
        hfi1_cdbg(DC8051, "type %d, data 0x%012llx", type, in_data);
  
 -      /*
 -       * Alternative to holding the lock for a long time:
 -       * - keep busy wait - have other users bounce off
 -       */
 -      spin_lock_irqsave(&dd->dc8051_lock, flags);
 +      mutex_lock(&dd->dc8051_lock);
  
        /* We can't send any commands to the 8051 if it's in reset */
        if (dd->dc_shutdown) {
                        return_code = -ENXIO;
                        goto fail;
                }
 -              spin_unlock_irqrestore(&dd->dc8051_lock, flags);
 -              dc_shutdown(dd);
 -              dc_start(dd);
 -              spin_lock_irqsave(&dd->dc8051_lock, flags);
 +              _dc_shutdown(dd);
 +              _dc_start(dd);
        }
  
        /*
        write_csr(dd, DC_DC8051_CFG_HOST_CMD_0, 0);
  
  fail:
 -      spin_unlock_irqrestore(&dd->dc8051_lock, flags);
 -
 +      mutex_unlock(&dd->dc8051_lock);
        return return_code;
  }
  
@@@ -8748,20 -8677,13 +8748,20 @@@ static void read_remote_device_id(struc
                        & REMOTE_DEVICE_REV_MASK;
  }
  
 -void read_misc_status(struct hfi1_devdata *dd, u8 *ver_a, u8 *ver_b)
 +void read_misc_status(struct hfi1_devdata *dd, u8 *ver_major, u8 *ver_minor,
 +                    u8 *ver_patch)
  {
        u32 frame;
  
        read_8051_config(dd, MISC_STATUS, GENERAL_CONFIG, &frame);
 -      *ver_a = (frame >> STS_FM_VERSION_A_SHIFT) & STS_FM_VERSION_A_MASK;
 -      *ver_b = (frame >> STS_FM_VERSION_B_SHIFT) & STS_FM_VERSION_B_MASK;
 +      *ver_major = (frame >> STS_FM_VERSION_MAJOR_SHIFT) &
 +              STS_FM_VERSION_MAJOR_MASK;
 +      *ver_minor = (frame >> STS_FM_VERSION_MINOR_SHIFT) &
 +              STS_FM_VERSION_MINOR_MASK;
 +
 +      read_8051_config(dd, VERSION_PATCH, GENERAL_CONFIG, &frame);
 +      *ver_patch = (frame >> STS_FM_VERSION_PATCH_SHIFT) &
 +              STS_FM_VERSION_PATCH_MASK;
  }
  
  static void read_vc_remote_phy(struct hfi1_devdata *dd, u8 *power_management,
@@@ -8969,6 -8891,8 +8969,6 @@@ int send_idle_sma(struct hfi1_devdata *
   */
  static int do_quick_linkup(struct hfi1_devdata *dd)
  {
 -      u64 reg;
 -      unsigned long timeout;
        int ret;
  
        lcb_shutdown(dd, 0);
                write_csr(dd, DC_LCB_CFG_RUN,
                          1ull << DC_LCB_CFG_RUN_EN_SHIFT);
  
 -              /* watch LCB_STS_LINK_TRANSFER_ACTIVE */
 -              timeout = jiffies + msecs_to_jiffies(10);
 -              while (1) {
 -                      reg = read_csr(dd, DC_LCB_STS_LINK_TRANSFER_ACTIVE);
 -                      if (reg)
 -                              break;
 -                      if (time_after(jiffies, timeout)) {
 -                              dd_dev_err(dd,
 -                                         "timeout waiting for LINK_TRANSFER_ACTIVE\n");
 -                              return -ETIMEDOUT;
 -                      }
 -                      udelay(2);
 -              }
 +              ret = wait_link_transfer_active(dd, 10);
 +              if (ret)
 +                      return ret;
  
                write_csr(dd, DC_LCB_CFG_ALLOW_LINK_UP,
                          1ull << DC_LCB_CFG_ALLOW_LINK_UP_VAL_SHIFT);
@@@ -9157,7 -9091,7 +9157,7 @@@ static int set_local_link_attributes(st
        if (ret)
                goto set_local_link_attributes_fail;
  
 -      if (dd->dc8051_ver < dc8051_ver(0, 20)) {
 +      if (dd->dc8051_ver < dc8051_ver(0, 20, 0)) {
                /* set the tx rate to the fastest enabled */
                if (ppd->link_speed_enabled & OPA_LINK_SPEED_25G)
                        ppd->local_tx_rate = 1;
@@@ -9340,7 -9274,7 +9340,7 @@@ static int handle_qsfp_error_conditions
  
        if ((qsfp_interrupt_status[0] & QSFP_HIGH_TEMP_ALARM) ||
            (qsfp_interrupt_status[0] & QSFP_HIGH_TEMP_WARNING))
 -              dd_dev_info(dd, "%s: QSFP cable on fire\n",
 +              dd_dev_info(dd, "%s: QSFP cable temperature too high\n",
                            __func__);
  
        if ((qsfp_interrupt_status[0] & QSFP_LOW_TEMP_ALARM) ||
@@@ -9560,11 -9494,8 +9560,11 @@@ static int test_qsfp_read(struct hfi1_p
        int ret;
        u8 status;
  
 -      /* report success if not a QSFP */
 -      if (ppd->port_type != PORT_TYPE_QSFP)
 +      /*
 +       * Report success if not a QSFP or, if it is a QSFP, but the cable is
 +       * not present
 +       */
 +      if (ppd->port_type != PORT_TYPE_QSFP || !qsfp_mod_present(ppd))
                return 0;
  
        /* read byte 2, the status byte */
@@@ -10151,64 -10082,6 +10151,64 @@@ static void check_lni_states(struct hfi
        decode_state_complete(ppd, last_remote_state, "received");
  }
  
 +/* wait for wait_ms for LINK_TRANSFER_ACTIVE to go to 1 */
 +static int wait_link_transfer_active(struct hfi1_devdata *dd, int wait_ms)
 +{
 +      u64 reg;
 +      unsigned long timeout;
 +
 +      /* watch LCB_STS_LINK_TRANSFER_ACTIVE */
 +      timeout = jiffies + msecs_to_jiffies(wait_ms);
 +      while (1) {
 +              reg = read_csr(dd, DC_LCB_STS_LINK_TRANSFER_ACTIVE);
 +              if (reg)
 +                      break;
 +              if (time_after(jiffies, timeout)) {
 +                      dd_dev_err(dd,
 +                                 "timeout waiting for LINK_TRANSFER_ACTIVE\n");
 +                      return -ETIMEDOUT;
 +              }
 +              udelay(2);
 +      }
 +      return 0;
 +}
 +
 +/* called when the logical link state is not down as it should be */
 +static void force_logical_link_state_down(struct hfi1_pportdata *ppd)
 +{
 +      struct hfi1_devdata *dd = ppd->dd;
 +
 +      /*
 +       * Bring link up in LCB loopback
 +       */
 +      write_csr(dd, DC_LCB_CFG_TX_FIFOS_RESET, 1);
 +      write_csr(dd, DC_LCB_CFG_IGNORE_LOST_RCLK,
 +                DC_LCB_CFG_IGNORE_LOST_RCLK_EN_SMASK);
 +
 +      write_csr(dd, DC_LCB_CFG_LANE_WIDTH, 0);
 +      write_csr(dd, DC_LCB_CFG_REINIT_AS_SLAVE, 0);
 +      write_csr(dd, DC_LCB_CFG_CNT_FOR_SKIP_STALL, 0x110);
 +      write_csr(dd, DC_LCB_CFG_LOOPBACK, 0x2);
 +
 +      write_csr(dd, DC_LCB_CFG_TX_FIFOS_RESET, 0);
 +      (void)read_csr(dd, DC_LCB_CFG_TX_FIFOS_RESET);
 +      udelay(3);
 +      write_csr(dd, DC_LCB_CFG_ALLOW_LINK_UP, 1);
 +      write_csr(dd, DC_LCB_CFG_RUN, 1ull << DC_LCB_CFG_RUN_EN_SHIFT);
 +
 +      wait_link_transfer_active(dd, 100);
 +
 +      /*
 +       * Bring the link down again.
 +       */
 +      write_csr(dd, DC_LCB_CFG_TX_FIFOS_RESET, 1);
 +      write_csr(dd, DC_LCB_CFG_ALLOW_LINK_UP, 0);
 +      write_csr(dd, DC_LCB_CFG_IGNORE_LOST_RCLK, 0);
 +
 +      /* call again to adjust ppd->statusp, if needed */
 +      get_logical_state(ppd);
 +}
 +
  /*
   * Helper for set_link_state().  Do not call except from that routine.
   * Expects ppd->hls_mutex to be held.
@@@ -10225,8 -10098,6 +10225,8 @@@ static int goto_offline(struct hfi1_ppo
        int do_transition;
        int do_wait;
  
 +      update_lcb_cache(dd);
 +
        previous_state = ppd->host_link_state;
        ppd->host_link_state = HLS_GOING_OFFLINE;
        pstate = read_physical_state(dd);
                        return ret;
        }
  
 -      /* make sure the logical state is also down */
 -      wait_logical_linkstate(ppd, IB_PORT_DOWN, 1000);
 -
        /*
         * Now in charge of LCB - must be after the physical state is
         * offline.quiet and before host_link_state is changed.
         */
        set_host_lcb_access(dd);
        write_csr(dd, DC_LCB_ERR_EN, ~0ull); /* watch LCB errors */
 +
 +      /* make sure the logical state is also down */
 +      ret = wait_logical_linkstate(ppd, IB_PORT_DOWN, 1000);
 +      if (ret)
 +              force_logical_link_state_down(ppd);
 +
        ppd->host_link_state = HLS_LINK_COOLDOWN; /* LCB access allowed */
  
        if (ppd->port_type == PORT_TYPE_QSFP &&
@@@ -10512,8 -10380,11 +10512,8 @@@ int set_link_state(struct hfi1_pportdat
                        goto unexpected;
                }
  
 -              ppd->host_link_state = HLS_UP_INIT;
                ret = wait_logical_linkstate(ppd, IB_PORT_INIT, 1000);
                if (ret) {
 -                      /* logical state didn't change, stay at going_up */
 -                      ppd->host_link_state = HLS_GOING_UP;
                        dd_dev_err(dd,
                                   "%s: logical state did not change to INIT\n",
                                   __func__);
                        add_rcvctrl(dd, RCV_CTRL_RCV_PORT_ENABLE_SMASK);
  
                        handle_linkup_change(dd, 1);
 +                      ppd->host_link_state = HLS_UP_INIT;
                }
                break;
        case HLS_UP_ARMED:
@@@ -11983,10 -11853,6 +11983,10 @@@ static void free_cntrs(struct hfi1_devd
        dd->scntrs = NULL;
        kfree(dd->cntrnames);
        dd->cntrnames = NULL;
 +      if (dd->update_cntr_wq) {
 +              destroy_workqueue(dd->update_cntr_wq);
 +              dd->update_cntr_wq = NULL;
 +      }
  }
  
  static u64 read_dev_port_cntr(struct hfi1_devdata *dd, struct cntr_entry *entry,
@@@ -12142,7 -12008,7 +12142,7 @@@ u64 write_port_cntr(struct hfi1_pportda
        return write_dev_port_cntr(ppd->dd, entry, sval, ppd, vl, data);
  }
  
 -static void update_synth_timer(unsigned long opaque)
 +static void do_update_synth_timer(struct work_struct *work)
  {
        u64 cur_tx;
        u64 cur_rx;
        int i, j, vl;
        struct hfi1_pportdata *ppd;
        struct cntr_entry *entry;
 -
 -      struct hfi1_devdata *dd = (struct hfi1_devdata *)opaque;
 +      struct hfi1_devdata *dd = container_of(work, struct hfi1_devdata,
 +                                             update_cntr_work);
  
        /*
         * Rather than keep beating on the CSRs pick a minimal set that we can
        } else {
                hfi1_cdbg(CNTR, "[%d] No update necessary", dd->unit);
        }
 +}
  
 +static void update_synth_timer(unsigned long opaque)
 +{
 +      struct hfi1_devdata *dd = (struct hfi1_devdata *)opaque;
 +
 +      queue_work(dd->update_cntr_wq, &dd->update_cntr_work);
        mod_timer(&dd->synth_stats_timer, jiffies + HZ * SYNTH_CNT_TIME);
  }
  
@@@ -12477,13 -12337,6 +12477,13 @@@ static int init_cntrs(struct hfi1_devda
        if (init_cpu_counters(dd))
                goto bail;
  
 +      dd->update_cntr_wq = alloc_ordered_workqueue("hfi1_update_cntr_%d",
 +                                                   WQ_MEM_RECLAIM, dd->unit);
 +      if (!dd->update_cntr_wq)
 +              goto bail;
 +
 +      INIT_WORK(&dd->update_cntr_work, do_update_synth_timer);
 +
        mod_timer(&dd->synth_stats_timer, jiffies + HZ * SYNTH_CNT_TIME);
        return 0;
  bail:
@@@ -12873,10 -12726,7 +12873,10 @@@ static int request_msix_irqs(struct hfi
        first_sdma = last_general;
        last_sdma = first_sdma + dd->num_sdma;
        first_rx = last_sdma;
 -      last_rx = first_rx + dd->n_krcv_queues;
 +      last_rx = first_rx + dd->n_krcv_queues + HFI1_NUM_VNIC_CTXT;
 +
 +      /* VNIC MSIx interrupts get mapped when VNIC contexts are created */
 +      dd->first_dyn_msix_idx = first_rx + dd->n_krcv_queues;
  
        /*
         * Sanity check - the code expects all SDMA chip source
                const char *err_info;
                irq_handler_t handler;
                irq_handler_t thread = NULL;
 -              void *arg;
 +              void *arg = NULL;
                int idx;
                struct hfi1_ctxtdata *rcd = NULL;
                struct sdma_engine *sde = NULL;
                } else if (first_rx <= i && i < last_rx) {
                        idx = i - first_rx;
                        rcd = dd->rcd[idx];
 -                      /* no interrupt if no rcd */
 -                      if (!rcd)
 -                              continue;
 -                      /*
 -                       * Set the interrupt register and mask for this
 -                       * context's interrupt.
 -                       */
 -                      rcd->ireg = (IS_RCVAVAIL_START + idx) / 64;
 -                      rcd->imask = ((u64)1) <<
 -                                      ((IS_RCVAVAIL_START + idx) % 64);
 -                      handler = receive_context_interrupt;
 -                      thread = receive_context_thread;
 -                      arg = rcd;
 -                      snprintf(me->name, sizeof(me->name),
 -                               DRIVER_NAME "_%d kctxt%d", dd->unit, idx);
 -                      err_info = "receive context";
 -                      remap_intr(dd, IS_RCVAVAIL_START + idx, i);
 -                      me->type = IRQ_RCVCTXT;
 +                      if (rcd) {
 +                              /*
 +                               * Set the interrupt register and mask for this
 +                               * context's interrupt.
 +                               */
 +                              rcd->ireg = (IS_RCVAVAIL_START + idx) / 64;
 +                              rcd->imask = ((u64)1) <<
 +                                        ((IS_RCVAVAIL_START + idx) % 64);
 +                              handler = receive_context_interrupt;
 +                              thread = receive_context_thread;
 +                              arg = rcd;
 +                              snprintf(me->name, sizeof(me->name),
 +                                       DRIVER_NAME "_%d kctxt%d",
 +                                       dd->unit, idx);
 +                              err_info = "receive context";
 +                              remap_intr(dd, IS_RCVAVAIL_START + idx, i);
 +                              me->type = IRQ_RCVCTXT;
 +                              rcd->msix_intr = i;
 +                      }
                } else {
                        /* not in our expected range - complain, then
                         * ignore it
        return ret;
  }
  
 +void hfi1_vnic_synchronize_irq(struct hfi1_devdata *dd)
 +{
 +      int i;
 +
 +      if (!dd->num_msix_entries) {
 +              synchronize_irq(dd->pcidev->irq);
 +              return;
 +      }
 +
 +      for (i = 0; i < dd->vnic.num_ctxt; i++) {
 +              struct hfi1_ctxtdata *rcd = dd->vnic.ctxt[i];
 +              struct hfi1_msix_entry *me = &dd->msix_entries[rcd->msix_intr];
 +
 +              synchronize_irq(me->msix.vector);
 +      }
 +}
 +
 +void hfi1_reset_vnic_msix_info(struct hfi1_ctxtdata *rcd)
 +{
 +      struct hfi1_devdata *dd = rcd->dd;
 +      struct hfi1_msix_entry *me = &dd->msix_entries[rcd->msix_intr];
 +
 +      if (!me->arg) /* => no irq, no affinity */
 +              return;
 +
 +      hfi1_put_irq_affinity(dd, me);
 +      free_irq(me->msix.vector, me->arg);
 +
 +      me->arg = NULL;
 +}
 +
 +void hfi1_set_vnic_msix_info(struct hfi1_ctxtdata *rcd)
 +{
 +      struct hfi1_devdata *dd = rcd->dd;
 +      struct hfi1_msix_entry *me;
 +      int idx = rcd->ctxt;
 +      void *arg = rcd;
 +      int ret;
 +
 +      rcd->msix_intr = dd->vnic.msix_idx++;
 +      me = &dd->msix_entries[rcd->msix_intr];
 +
 +      /*
 +       * Set the interrupt register and mask for this
 +       * context's interrupt.
 +       */
 +      rcd->ireg = (IS_RCVAVAIL_START + idx) / 64;
 +      rcd->imask = ((u64)1) <<
 +                ((IS_RCVAVAIL_START + idx) % 64);
 +
 +      snprintf(me->name, sizeof(me->name),
 +               DRIVER_NAME "_%d kctxt%d", dd->unit, idx);
 +      me->name[sizeof(me->name) - 1] = 0;
 +      me->type = IRQ_RCVCTXT;
 +
 +      remap_intr(dd, IS_RCVAVAIL_START + idx, rcd->msix_intr);
 +
 +      ret = request_threaded_irq(me->msix.vector, receive_context_interrupt,
 +                                 receive_context_thread, 0, me->name, arg);
 +      if (ret) {
 +              dd_dev_err(dd, "vnic irq request (vector %d, idx %d) fail %d\n",
 +                         me->msix.vector, idx, ret);
 +              return;
 +      }
 +      /*
 +       * assign arg after request_irq call, so it will be
 +       * cleaned up
 +       */
 +      me->arg = arg;
 +
 +      ret = hfi1_get_irq_affinity(dd, me);
 +      if (ret) {
 +              dd_dev_err(dd,
 +                         "unable to pin IRQ %d\n", ret);
 +              free_irq(me->msix.vector, me->arg);
 +      }
 +}
 +
  /*
   * Set the general handler to accept all interrupts, remap all
   * chip interrupts back to MSI-X 0.
@@@ -13082,7 -12853,7 +13082,7 @@@ static int set_up_interrupts(struct hfi
         *      N interrupts - one per used SDMA engine
         *      M interrupt - one per kernel receive context
         */
 -      total = 1 + dd->num_sdma + dd->n_krcv_queues;
 +      total = 1 + dd->num_sdma + dd->n_krcv_queues + HFI1_NUM_VNIC_CTXT;
  
        entries = kcalloc(total, sizeof(*entries), GFP_KERNEL);
        if (!entries) {
@@@ -13147,8 -12918,7 +13147,8 @@@ fail
   *
   *    num_rcv_contexts - number of contexts being used
   *    n_krcv_queues - number of kernel contexts
 - *    first_user_ctxt - first non-kernel context in array of contexts
 + *    first_dyn_alloc_ctxt - first dynamically allocated context
 + *                             in array of contexts
   *    freectxts  - number of free user contexts
   *    num_send_contexts - number of PIO send contexts being used
   */
@@@ -13225,14 -12995,10 +13225,14 @@@ static int set_up_context_variables(str
                total_contexts = num_kernel_contexts + num_user_contexts;
        }
  
 -      /* the first N are kernel contexts, the rest are user contexts */
 +      /* Accommodate VNIC contexts */
 +      if ((total_contexts + HFI1_NUM_VNIC_CTXT) <= dd->chip_rcv_contexts)
 +              total_contexts += HFI1_NUM_VNIC_CTXT;
 +
 +      /* the first N are kernel contexts, the rest are user/vnic contexts */
        dd->num_rcv_contexts = total_contexts;
        dd->n_krcv_queues = num_kernel_contexts;
 -      dd->first_user_ctxt = num_kernel_contexts;
 +      dd->first_dyn_alloc_ctxt = num_kernel_contexts;
        dd->num_user_contexts = num_user_contexts;
        dd->freectxts = num_user_contexts;
        dd_dev_info(dd,
@@@ -13688,8 -13454,11 +13688,8 @@@ static void reset_rxe_csrs(struct hfi1_
                write_csr(dd, RCV_COUNTER_ARRAY32 + (8 * i), 0);
        for (i = 0; i < RXE_NUM_64_BIT_COUNTERS; i++)
                write_csr(dd, RCV_COUNTER_ARRAY64 + (8 * i), 0);
 -      for (i = 0; i < RXE_NUM_RSM_INSTANCES; i++) {
 -              write_csr(dd, RCV_RSM_CFG + (8 * i), 0);
 -              write_csr(dd, RCV_RSM_SELECT + (8 * i), 0);
 -              write_csr(dd, RCV_RSM_MATCH + (8 * i), 0);
 -      }
 +      for (i = 0; i < RXE_NUM_RSM_INSTANCES; i++)
 +              clear_rsm_rule(dd, i);
        for (i = 0; i < 32; i++)
                write_csr(dd, RCV_RSM_MAP_TABLE + (8 * i), 0);
  
@@@ -13841,14 -13610,14 +13841,14 @@@ static void init_chip(struct hfi1_devda
                dd_dev_info(dd, "Resetting CSRs with FLR\n");
  
                /* do the FLR, the DC reset will remain */
-               hfi1_pcie_flr(dd);
+               pcie_flr(dd->pcidev);
  
                /* restore command and BARs */
                restore_pci_variables(dd);
  
                if (is_ax(dd)) {
                        dd_dev_info(dd, "Resetting CSRs with FLR\n");
-                       hfi1_pcie_flr(dd);
+                       pcie_flr(dd->pcidev);
                        restore_pci_variables(dd);
                }
        } else {
@@@ -14048,16 -13817,6 +14048,16 @@@ static void add_rsm_rule(struct hfi1_de
                  (u64)rrd->value2 << RCV_RSM_MATCH_VALUE2_SHIFT);
  }
  
 +/*
 + * Clear a receive side mapping rule.
 + */
 +static void clear_rsm_rule(struct hfi1_devdata *dd, u8 rule_index)
 +{
 +      write_csr(dd, RCV_RSM_CFG + (8 * rule_index), 0);
 +      write_csr(dd, RCV_RSM_SELECT + (8 * rule_index), 0);
 +      write_csr(dd, RCV_RSM_MATCH + (8 * rule_index), 0);
 +}
 +
  /* return the number of RSM map table entries that will be used for QOS */
  static int qos_rmt_entries(struct hfi1_devdata *dd, unsigned int *mp,
                           unsigned int *np)
@@@ -14173,7 -13932,7 +14173,7 @@@ static void init_qos(struct hfi1_devdat
        rrd.value2 = LRH_SC_VALUE;
  
        /* add rule 0 */
 -      add_rsm_rule(dd, 0, &rrd);
 +      add_rsm_rule(dd, RSM_INS_VERBS, &rrd);
  
        /* mark RSM map entries as used */
        rmt->used += rmt_entries;
@@@ -14203,7 -13962,7 +14203,7 @@@ static void init_user_fecn_handling(str
        /*
         * RSM will extract the destination context as an index into the
         * map table.  The destination contexts are a sequential block
 -       * in the range first_user_ctxt...num_rcv_contexts-1 (inclusive).
 +       * in the range first_dyn_alloc_ctxt...num_rcv_contexts-1 (inclusive).
         * Map entries are accessed as offset + extracted value.  Adjust
         * the added offset so this sequence can be placed anywhere in
         * the table - as long as the entries themselves do not wrap.
         * start with that to allow for a "negative" offset.
         */
        offset = (u8)(NUM_MAP_ENTRIES + (int)rmt->used -
 -                                              (int)dd->first_user_ctxt);
 +                                              (int)dd->first_dyn_alloc_ctxt);
  
 -      for (i = dd->first_user_ctxt, idx = rmt->used;
 +      for (i = dd->first_dyn_alloc_ctxt, idx = rmt->used;
                                i < dd->num_rcv_contexts; i++, idx++) {
                /* replace with identity mapping */
                regoff = (idx % 8) * 8;
        rrd.value2 = 1;
  
        /* add rule 1 */
 -      add_rsm_rule(dd, 1, &rrd);
 +      add_rsm_rule(dd, RSM_INS_FECN, &rrd);
  
        rmt->used += dd->num_user_contexts;
  }
  
 +/* Initialize RSM for VNIC */
 +void hfi1_init_vnic_rsm(struct hfi1_devdata *dd)
 +{
 +      u8 i, j;
 +      u8 ctx_id = 0;
 +      u64 reg;
 +      u32 regoff;
 +      struct rsm_rule_data rrd;
 +
 +      if (hfi1_vnic_is_rsm_full(dd, NUM_VNIC_MAP_ENTRIES)) {
 +              dd_dev_err(dd, "Vnic RSM disabled, rmt entries used = %d\n",
 +                         dd->vnic.rmt_start);
 +              return;
 +      }
 +
 +      dev_dbg(&(dd)->pcidev->dev, "Vnic rsm start = %d, end %d\n",
 +              dd->vnic.rmt_start,
 +              dd->vnic.rmt_start + NUM_VNIC_MAP_ENTRIES);
 +
 +      /* Update RSM mapping table, 32 regs, 256 entries - 1 ctx per byte */
 +      regoff = RCV_RSM_MAP_TABLE + (dd->vnic.rmt_start / 8) * 8;
 +      reg = read_csr(dd, regoff);
 +      for (i = 0; i < NUM_VNIC_MAP_ENTRIES; i++) {
 +              /* Update map register with vnic context */
 +              j = (dd->vnic.rmt_start + i) % 8;
 +              reg &= ~(0xffllu << (j * 8));
 +              reg |= (u64)dd->vnic.ctxt[ctx_id++]->ctxt << (j * 8);
 +              /* Wrap up vnic ctx index */
 +              ctx_id %= dd->vnic.num_ctxt;
 +              /* Write back map register */
 +              if (j == 7 || ((i + 1) == NUM_VNIC_MAP_ENTRIES)) {
 +                      dev_dbg(&(dd)->pcidev->dev,
 +                              "Vnic rsm map reg[%d] =0x%llx\n",
 +                              regoff - RCV_RSM_MAP_TABLE, reg);
 +
 +                      write_csr(dd, regoff, reg);
 +                      regoff += 8;
 +                      if (i < (NUM_VNIC_MAP_ENTRIES - 1))
 +                              reg = read_csr(dd, regoff);
 +              }
 +      }
 +
 +      /* Add rule for vnic */
 +      rrd.offset = dd->vnic.rmt_start;
 +      rrd.pkt_type = 4;
 +      /* Match 16B packets */
 +      rrd.field1_off = L2_TYPE_MATCH_OFFSET;
 +      rrd.mask1 = L2_TYPE_MASK;
 +      rrd.value1 = L2_16B_VALUE;
 +      /* Match ETH L4 packets */
 +      rrd.field2_off = L4_TYPE_MATCH_OFFSET;
 +      rrd.mask2 = L4_16B_TYPE_MASK;
 +      rrd.value2 = L4_16B_ETH_VALUE;
 +      /* Calc context from veswid and entropy */
 +      rrd.index1_off = L4_16B_HDR_VESWID_OFFSET;
 +      rrd.index1_width = ilog2(NUM_VNIC_MAP_ENTRIES);
 +      rrd.index2_off = L2_16B_ENTROPY_OFFSET;
 +      rrd.index2_width = ilog2(NUM_VNIC_MAP_ENTRIES);
 +      add_rsm_rule(dd, RSM_INS_VNIC, &rrd);
 +
 +      /* Enable RSM if not already enabled */
 +      add_rcvctrl(dd, RCV_CTRL_RCV_RSM_ENABLE_SMASK);
 +}
 +
 +void hfi1_deinit_vnic_rsm(struct hfi1_devdata *dd)
 +{
 +      clear_rsm_rule(dd, RSM_INS_VNIC);
 +
 +      /* Disable RSM if used only by vnic */
 +      if (dd->vnic.rmt_start == 0)
 +              clear_rcvctrl(dd, RCV_CTRL_RCV_RSM_ENABLE_SMASK);
 +}
 +
  static void init_rxe(struct hfi1_devdata *dd)
  {
        struct rsm_map_table *rmt;
        init_qos(dd, rmt);
        init_user_fecn_handling(dd, rmt);
        complete_rsm_map_table(dd, rmt);
 +      /* record number of used rsm map entries for vnic */
 +      dd->vnic.rmt_start = rmt->used;
        kfree(rmt);
  
        /*
index f06674317abfcd010b192b57ebed503ad59e6e3c,40d7559fa723f59ca59ebe2fa63ff594a5275adb..14063bd30c2a1618d8c821aed325117db29478df
@@@ -1,7 -1,7 +1,7 @@@
  #ifndef _HFI1_KERNEL_H
  #define _HFI1_KERNEL_H
  /*
 - * Copyright(c) 2015, 2016 Intel Corporation.
 + * Copyright(c) 2015-2017 Intel Corporation.
   *
   * This file is provided under a dual BSD/GPLv2 license.  When using or
   * redistributing this file, you may do so under either license.
@@@ -54,7 -54,6 +54,7 @@@
  #include <linux/list.h>
  #include <linux/scatterlist.h>
  #include <linux/slab.h>
 +#include <linux/idr.h>
  #include <linux/io.h>
  #include <linux/fs.h>
  #include <linux/completion.h>
@@@ -67,7 -66,6 +67,7 @@@
  #include <linux/i2c-algo-bit.h>
  #include <rdma/ib_hdrs.h>
  #include <linux/rhashtable.h>
 +#include <linux/netdevice.h>
  #include <rdma/rdma_vt.h>
  
  #include "chip_registers.h"
@@@ -280,8 -278,6 +280,8 @@@ struct hfi1_ctxtdata 
        struct hfi1_devdata *dd;
        /* so functions that need physical port can get it easily */
        struct hfi1_pportdata *ppd;
 +      /* associated msix interrupt */
 +      u32 msix_intr;
        /* A page of memory for rcvhdrhead, rcvegrhead, rcvegrtail * N */
        void *subctxt_uregbase;
        /* An array of pages for the eager receive buffers * N */
         * packets with the wrong interrupt handler.
         */
        int (*do_interrupt)(struct hfi1_ctxtdata *rcd, int threaded);
 +
 +      /* Indicates that this is vnic context */
 +      bool is_vnic;
 +
 +      /* vnic queue index this context is mapped to */
 +      u8 vnic_q_idx;
  };
  
  /*
@@@ -484,7 -474,7 +484,7 @@@ struct rvt_sge_state
  #define HFI1_PART_ENFORCE_OUT 0x2
  
  /* how often we check for synthetic counter wrap around */
 -#define SYNTH_CNT_TIME 2
 +#define SYNTH_CNT_TIME 3
  
  /* Counter flags */
  #define CNTR_NORMAL           0x0 /* Normal counters, just read register */
@@@ -818,32 -808,6 +818,32 @@@ struct hfi1_asic_data 
        struct hfi1_i2c_bus *i2c_bus1;
  };
  
 +/* sizes for both the QP and RSM map tables */
 +#define NUM_MAP_ENTRIES        256
 +#define NUM_MAP_REGS      32
 +
 +/*
 + * Number of VNIC contexts used. Ensure it is less than or equal to
 + * max queues supported by VNIC (HFI1_VNIC_MAX_QUEUE).
 + */
 +#define HFI1_NUM_VNIC_CTXT   8
 +
 +/* Number of VNIC RSM entries */
 +#define NUM_VNIC_MAP_ENTRIES 8
 +
 +/* Virtual NIC information */
 +struct hfi1_vnic_data {
 +      struct hfi1_ctxtdata *ctxt[HFI1_NUM_VNIC_CTXT];
 +      struct kmem_cache *txreq_cache;
 +      u8 num_vports;
 +      struct idr vesw_idr;
 +      u8 rmt_start;
 +      u8 num_ctxt;
 +      u32 msix_idx;
 +};
 +
 +struct hfi1_vnic_vport_info;
 +
  /* device data struct now contains only "general per-device" info.
   * fields related to a physical IB port are in a hfi1_pportdata struct.
   */
@@@ -962,9 -926,8 +962,9 @@@ struct hfi1_devdata 
        spinlock_t rcvctrl_lock; /* protect changes to RcvCtrl */
        /* around rcd and (user ctxts) ctxt_cnt use (intr vs free) */
        spinlock_t uctxt_lock; /* rcd and user context changes */
 -      /* exclusive access to 8051 */
 -      spinlock_t dc8051_lock;
 +      struct mutex dc8051_lock; /* exclusive access to 8051 */
 +      struct workqueue_struct *update_cntr_wq;
 +      struct work_struct update_cntr_work;
        /* exclusive access to 8051 memory */
        spinlock_t dc8051_memlock;
        int dc8051_timed_out;   /* remember if the 8051 timed out */
        u8 qos_shift;
  
        u16 irev;       /* implementation revision */
 -      u16 dc8051_ver; /* 8051 firmware version */
 +      u32 dc8051_ver; /* 8051 firmware version */
  
        spinlock_t hfi1_diag_trans_lock; /* protect diag observer ops */
        struct platform_config platform_config;
        /* MSI-X information */
        struct hfi1_msix_entry *msix_entries;
        u32 num_msix_entries;
 +      u32 first_dyn_msix_idx;
  
        /* INTx information */
        u32 requested_intx_irq;         /* did we request one? */
        send_routine process_dma_send;
        void (*pio_inline_send)(struct hfi1_devdata *dd, struct pio_buf *pbuf,
                                u64 pbc, const void *from, size_t count);
 +      int (*process_vnic_dma_send)(struct hfi1_devdata *dd, u8 q_idx,
 +                                   struct hfi1_vnic_vport_info *vinfo,
 +                                   struct sk_buff *skb, u64 pbc, u8 plen);
        /* hfi1_pportdata, points to array of (physical) port-specific
         * data structs, indexed by pidx (0..n-1)
         */
        u16 flags;
        /* Number of physical ports available */
        u8 num_pports;
 -      /* Lowest context number which can be used by user processes */
 -      u8 first_user_ctxt;
 +      /* Lowest context number which can be used by user processes or VNIC */
 +      u8 first_dyn_alloc_ctxt;
        /* adding a new field here would make it part of this cacheline */
  
        /* seqlock for sc2vl */
        bool eprom_available;   /* true if EPROM is available for this device */
        bool aspm_supported;    /* Does HW support ASPM */
        bool aspm_enabled;      /* ASPM state: enabled/disabled */
 -      struct rhashtable sdma_rht;
 +      struct rhashtable *sdma_rht;
  
        struct kobject kobj;
 +
 +      /* vnic data */
 +      struct hfi1_vnic_data vnic;
  };
  
 +static inline bool hfi1_vnic_is_rsm_full(struct hfi1_devdata *dd, int spare)
 +{
 +      return (dd->vnic.rmt_start + spare) > NUM_MAP_ENTRIES;
 +}
 +
  /* 8051 firmware version helper */
 -#define dc8051_ver(a, b) ((a) << 8 | (b))
 -#define dc8051_ver_maj(a) ((a & 0xff00) >> 8)
 -#define dc8051_ver_min(a)  (a & 0x00ff)
 +#define dc8051_ver(a, b, c) ((a) << 16 | (b) << 8 | (c))
 +#define dc8051_ver_maj(a) (((a) & 0xff0000) >> 16)
 +#define dc8051_ver_min(a) (((a) & 0x00ff00) >> 8)
 +#define dc8051_ver_patch(a) ((a) & 0x0000ff)
  
  /* f_put_tid types */
  #define PT_EXPECTED 0
@@@ -1285,9 -1235,6 +1285,9 @@@ int handle_receive_interrupt(struct hfi
  int handle_receive_interrupt_nodma_rtail(struct hfi1_ctxtdata *, int);
  int handle_receive_interrupt_dma_rtail(struct hfi1_ctxtdata *, int);
  void set_all_slowpath(struct hfi1_devdata *dd);
 +void hfi1_vnic_synchronize_irq(struct hfi1_devdata *dd);
 +void hfi1_set_vnic_msix_info(struct hfi1_ctxtdata *rcd);
 +void hfi1_reset_vnic_msix_info(struct hfi1_ctxtdata *rcd);
  
  extern const struct pci_device_id hfi1_pci_tbl[];
  
@@@ -1307,24 -1254,16 +1307,24 @@@ int hfi1_reset_device(int)
  /* return the driver's idea of the logical OPA port state */
  static inline u32 driver_lstate(struct hfi1_pportdata *ppd)
  {
 -      return ppd->lstate; /* use the cached value */
 +      /*
 +       * The driver does some processing from the time the logical
 +       * link state is at INIT to the time the SM can be notified
 +       * as such. Return IB_PORT_DOWN until the software state
 +       * is ready.
 +       */
 +      if (ppd->lstate == IB_PORT_INIT && !(ppd->host_link_state & HLS_UP))
 +              return IB_PORT_DOWN;
 +      else
 +              return ppd->lstate;
  }
  
  void receive_interrupt_work(struct work_struct *work);
  
  /* extract service channel from header and rhf */
 -static inline int hdr2sc(struct ib_header *hdr, u64 rhf)
 +static inline int hfi1_9B_get_sc5(struct ib_header *hdr, u64 rhf)
  {
 -      return ((be16_to_cpu(hdr->lrh[0]) >> 12) & 0xf) |
 -             ((!!(rhf_dc_info(rhf))) << 4);
 +      return ib_get_sc(hdr) | ((!!(rhf_dc_info(rhf))) << 4);
  }
  
  #define HFI1_JKEY_WIDTH       16
@@@ -1658,9 -1597,9 +1658,9 @@@ static inline bool process_ecn(struct r
        u32 bth1;
  
        bth1 = be32_to_cpu(ohdr->bth[1]);
 -      if (unlikely(bth1 & (HFI1_BECN_SMASK | HFI1_FECN_SMASK))) {
 +      if (unlikely(bth1 & (IB_BECN_SMASK | IB_FECN_SMASK))) {
                hfi1_process_ecn_slowpath(qp, pkt, do_cnp);
 -              return bth1 & HFI1_FECN_SMASK;
 +              return !!(bth1 & IB_FECN_SMASK);
        }
        return false;
  }
@@@ -1825,7 -1764,6 +1825,6 @@@ int hfi1_pcie_init(struct pci_dev *, co
  void hfi1_pcie_cleanup(struct pci_dev *);
  int hfi1_pcie_ddinit(struct hfi1_devdata *, struct pci_dev *);
  void hfi1_pcie_ddcleanup(struct hfi1_devdata *);
- void hfi1_pcie_flr(struct hfi1_devdata *);
  int pcie_speeds(struct hfi1_devdata *);
  void request_msix(struct hfi1_devdata *, u32 *, struct hfi1_msix_entry *);
  void hfi1_enable_intx(struct pci_dev *);
index e39e01b793823cad3274429cfe1115337c6bdf0a,c81556e848310886f6d9b97650cd5c4050f523d5..93faf86d54b620fb2cc621844932d811c17868dd
@@@ -240,36 -240,6 +240,6 @@@ void hfi1_pcie_ddcleanup(struct hfi1_de
                iounmap(dd->piobase);
  }
  
- /*
-  * Do a Function Level Reset (FLR) on the device.
-  * Based on static function drivers/pci/pci.c:pcie_flr().
-  */
- void hfi1_pcie_flr(struct hfi1_devdata *dd)
- {
-       int i;
-       u16 status;
-       /* no need to check for the capability - we know the device has it */
-       /* wait for Transaction Pending bit to clear, at most a few ms */
-       for (i = 0; i < 4; i++) {
-               if (i)
-                       msleep((1 << (i - 1)) * 100);
-               pcie_capability_read_word(dd->pcidev, PCI_EXP_DEVSTA, &status);
-               if (!(status & PCI_EXP_DEVSTA_TRPND))
-                       goto clear;
-       }
-       dd_dev_err(dd, "Transaction Pending bit is not clearing, proceeding with reset anyway\n");
- clear:
-       pcie_capability_set_word(dd->pcidev, PCI_EXP_DEVCTL,
-                                PCI_EXP_DEVCTL_BCR_FLR);
-       /* PCIe spec requires the function to be back within 100ms */
-       msleep(100);
- }
  static void msix_setup(struct hfi1_devdata *dd, int pos, u32 *msixcnt,
                       struct hfi1_msix_entry *hfi1_msix_entry)
  {
@@@ -583,7 -553,7 +553,7 @@@ pci_mmio_enabled(struct pci_dev *pdev
                if (words == ~0ULL)
                        ret = PCI_ERS_RESULT_NEED_RESET;
                dd_dev_info(dd,
 -                          "HFI1 mmio_enabled function called, read wordscntr %Lx, returning %d\n",
 +                          "HFI1 mmio_enabled function called, read wordscntr %llx, returning %d\n",
                            words, ret);
        }
        return  ret;
diff --combined drivers/misc/Kconfig
index 39d1acb2745263d361306e0aeb9672e6d68ce310,527b115c4e232b165be1d4b801f6e0cd70e598ec..2cba76e6fa3cb0bd8b2148bdd472c44f5abaf0d7
@@@ -419,6 -419,16 +419,6 @@@ config VMWARE_BALLOO
          To compile this driver as a module, choose M here: the
          module will be called vmw_balloon.
  
 -config ARM_CHARLCD
 -      bool "ARM Ltd. Character LCD Driver"
 -      depends on PLAT_VERSATILE
 -      help
 -        This is a driver for the character LCD found on the ARM Ltd.
 -        Versatile and RealView Platform Baseboards. It doesn't do
 -        very much more than display the text "ARM Linux" on the first
 -        line and the Linux version on the second line, but that's
 -        still useful.
 -
  config PCH_PHUB
        tristate "Intel EG20T PCH/LAPIS Semicon IOH(ML7213/ML7223/ML7831) PHUB"
        select GENERIC_NET_UTILS
@@@ -482,14 -492,292 +482,21 @@@ config VEXPRESS_SYSCF
          bus. System Configuration interface is one of the possible means
          of generating transactions on this bus.
  
 -config PANEL
 -      tristate "Parallel port LCD/Keypad Panel support"
 -      depends on PARPORT
 -      ---help---
 -        Say Y here if you have an HD44780 or KS-0074 LCD connected to your
 -        parallel port. This driver also features 4 and 6-key keypads. The LCD
 -        is accessible through the /dev/lcd char device (10, 156), and the
 -        keypad through /dev/keypad (10, 185). This code can either be
 -        compiled as a module, or linked into the kernel and started at boot.
 -        If you don't understand what all this is about, say N.
 -
 -if PANEL
 -
 -config PANEL_PARPORT
 -      int "Default parallel port number (0=LPT1)"
 -      range 0 255
 -      default "0"
 -      ---help---
 -        This is the index of the parallel port the panel is connected to. One
 -        driver instance only supports one parallel port, so if your keypad
 -        and LCD are connected to two separate ports, you have to start two
 -        modules with different arguments. Numbering starts with '0' for LPT1,
 -        and so on.
 -
 -config PANEL_PROFILE
 -      int "Default panel profile (0-5, 0=custom)"
 -      range 0 5
 -      default "5"
 -      ---help---
 -        To ease configuration, the driver supports different configuration
 -        profiles for past and recent wirings. These profiles can also be
 -        used to define an approximative configuration, completed by a few
 -        other options. Here are the profiles :
 -
 -          0 = custom (see further)
 -          1 = 2x16 parallel LCD, old keypad
 -          2 = 2x16 serial LCD (KS-0074), new keypad
 -          3 = 2x16 parallel LCD (Hantronix), no keypad
 -          4 = 2x16 parallel LCD (Nexcom NSA1045) with Nexcom's keypad
 -          5 = 2x40 parallel LCD (old one), with old keypad
 -
 -        Custom configurations allow you to define how your display is
 -        wired to the parallel port, and how it works. This is only intended
 -        for experts.
 -
 -config PANEL_KEYPAD
 -      depends on PANEL_PROFILE="0"
 -      int "Keypad type (0=none, 1=old 6 keys, 2=new 6 keys, 3=Nexcom 4 keys)"
 -      range 0 3
 -      default 0
 -      ---help---
 -        This enables and configures a keypad connected to the parallel port.
 -        The keys will be read from character device 10,185. Valid values are :
 -
 -          0 : do not enable this driver
 -          1 : old 6 keys keypad
 -          2 : new 6 keys keypad, as used on the server at www.ant-computing.com
 -          3 : Nexcom NSA1045's 4 keys keypad
 -
 -        New profiles can be described in the driver source. The driver also
 -        supports simultaneous keys pressed when the keypad supports them.
 -
 -config PANEL_LCD
 -      depends on PANEL_PROFILE="0"
 -      int "LCD type (0=none, 1=custom, 2=old //, 3=ks0074, 4=hantronix, 5=Nexcom)"
 -      range 0 5
 -      default 0
 -      ---help---
 -         This enables and configures an LCD connected to the parallel port.
 -         The driver includes an interpreter for escape codes starting with
 -         '\e[L' which are specific to the LCD, and a few ANSI codes. The
 -         driver will be registered as character device 10,156, usually
 -         under the name '/dev/lcd'. There are a total of 6 supported types :
 -
 -           0 : do not enable the driver
 -           1 : custom configuration and wiring (see further)
 -           2 : 2x16 & 2x40 parallel LCD (old wiring)
 -           3 : 2x16 serial LCD (KS-0074 based)
 -           4 : 2x16 parallel LCD (Hantronix wiring)
 -           5 : 2x16 parallel LCD (Nexcom wiring)
 -
 -         When type '1' is specified, other options will appear to configure
 -         more precise aspects (wiring, dimensions, protocol, ...). Please note
 -         that those values changed from the 2.4 driver for better consistency.
 -
 -config PANEL_LCD_HEIGHT
 -      depends on PANEL_PROFILE="0" && PANEL_LCD="1"
 -      int "Number of lines on the LCD (1-2)"
 -      range 1 2
 -      default 2
 -      ---help---
 -        This is the number of visible character lines on the LCD in custom profile.
 -        It can either be 1 or 2.
 -
 -config PANEL_LCD_WIDTH
 -      depends on PANEL_PROFILE="0" && PANEL_LCD="1"
 -      int "Number of characters per line on the LCD (1-40)"
 -      range 1 40
 -      default 40
 -      ---help---
 -        This is the number of characters per line on the LCD in custom profile.
 -        Common values are 16,20,24,40.
 -
 -config PANEL_LCD_BWIDTH
 -      depends on PANEL_PROFILE="0" && PANEL_LCD="1"
 -      int "Internal LCD line width (1-40, 40 by default)"
 -      range 1 40
 -      default 40
 -      ---help---
 -        Most LCDs use a standard controller which supports hardware lines of 40
 -        characters, although sometimes only 16, 20 or 24 of them are really wired
 -        to the terminal. This results in some non-visible but addressable characters,
 -        and is the case for most parallel LCDs. Other LCDs, and some serial ones,
 -        however, use the same line width internally as what is visible. The KS0074
 -        for example, uses 16 characters per line for 16 visible characters per line.
 -
 -        This option lets you configure the value used by your LCD in 'custom' profile.
 -        If you don't know, put '40' here.
 -
 -config PANEL_LCD_HWIDTH
 -      depends on PANEL_PROFILE="0" && PANEL_LCD="1"
 -      int "Hardware LCD line width (1-64, 64 by default)"
 -      range 1 64
 -      default 64
 -      ---help---
 -        Most LCDs use a single address bit to differentiate line 0 and line 1. Since
 -        some of them need to be able to address 40 chars with the lower bits, they
 -        often use the immediately superior power of 2, which is 64, to address the
 -        next line.
 -
 -        If you don't know what your LCD uses, in doubt let 16 here for a 2x16, and
 -        64 here for a 2x40.
 -
 -config PANEL_LCD_CHARSET
 -      depends on PANEL_PROFILE="0" && PANEL_LCD="1"
 -      int "LCD character set (0=normal, 1=KS0074)"
 -      range 0 1
 -      default 0
 -      ---help---
 -        Some controllers such as the KS0074 use a somewhat strange character set
 -        where many symbols are at unusual places. The driver knows how to map
 -        'standard' ASCII characters to the character sets used by these controllers.
 -        Valid values are :
 -
 -           0 : normal (untranslated) character set
 -           1 : KS0074 character set
 -
 -        If you don't know, use the normal one (0).
 -
 -config PANEL_LCD_PROTO
 -      depends on PANEL_PROFILE="0" && PANEL_LCD="1"
 -      int "LCD communication mode (0=parallel 8 bits, 1=serial)"
 -      range 0 1
 -      default 0
 -      ---help---
 -        This driver now supports any serial or parallel LCD wired to a parallel
 -        port. But before assigning signals, the driver needs to know if it will
 -        be driving a serial LCD or a parallel one. Serial LCDs only use 2 wires
 -        (SDA/SCL), while parallel ones use 2 or 3 wires for the control signals
 -        (E, RS, sometimes RW), and 4 or 8 for the data. Use 0 here for a 8 bits
 -        parallel LCD, and 1 for a serial LCD.
 -
 -config PANEL_LCD_PIN_E
 -      depends on PANEL_PROFILE="0" && PANEL_LCD="1" && PANEL_LCD_PROTO="0"
 -        int "Parallel port pin number & polarity connected to the LCD E signal (-17...17) "
 -      range -17 17
 -      default 14
 +config ASPEED_LPC_CTRL
 +      depends on (ARCH_ASPEED || COMPILE_TEST) && REGMAP && MFD_SYSCON
 +      tristate "Aspeed ast2400/2500 HOST LPC to BMC bridge control"
        ---help---
 -        This describes the number of the parallel port pin to which the LCD 'E'
 -        signal has been connected. It can be :
 -
 -                0 : no connection (eg: connected to ground)
 -            1..17 : directly connected to any of these pins on the DB25 plug
 -          -1..-17 : connected to the same pin through an inverter (eg: transistor).
 -
 -        Default for the 'E' pin in custom profile is '14' (AUTOFEED).
 -
 -config PANEL_LCD_PIN_RS
 -      depends on PANEL_PROFILE="0" && PANEL_LCD="1" && PANEL_LCD_PROTO="0"
 -        int "Parallel port pin number & polarity connected to the LCD RS signal (-17...17) "
 -      range -17 17
 -      default 17
 -      ---help---
 -        This describes the number of the parallel port pin to which the LCD 'RS'
 -        signal has been connected. It can be :
 -
 -                0 : no connection (eg: connected to ground)
 -            1..17 : directly connected to any of these pins on the DB25 plug
 -          -1..-17 : connected to the same pin through an inverter (eg: transistor).
 -
 -        Default for the 'RS' pin in custom profile is '17' (SELECT IN).
 -
 -config PANEL_LCD_PIN_RW
 -      depends on PANEL_PROFILE="0" && PANEL_LCD="1" && PANEL_LCD_PROTO="0"
 -        int "Parallel port pin number & polarity connected to the LCD RW signal (-17...17) "
 -      range -17 17
 -      default 16
 -      ---help---
 -        This describes the number of the parallel port pin to which the LCD 'RW'
 -        signal has been connected. It can be :
 -
 -                0 : no connection (eg: connected to ground)
 -            1..17 : directly connected to any of these pins on the DB25 plug
 -          -1..-17 : connected to the same pin through an inverter (eg: transistor).
 -
 -        Default for the 'RW' pin in custom profile is '16' (INIT).
 -
 -config PANEL_LCD_PIN_SCL
 -      depends on PANEL_PROFILE="0" && PANEL_LCD="1" && PANEL_LCD_PROTO!="0"
 -        int "Parallel port pin number & polarity connected to the LCD SCL signal (-17...17) "
 -      range -17 17
 -      default 1
 -      ---help---
 -        This describes the number of the parallel port pin to which the serial
 -        LCD 'SCL' signal has been connected. It can be :
 -
 -                0 : no connection (eg: connected to ground)
 -            1..17 : directly connected to any of these pins on the DB25 plug
 -          -1..-17 : connected to the same pin through an inverter (eg: transistor).
 -
 -        Default for the 'SCL' pin in custom profile is '1' (STROBE).
 -
 -config PANEL_LCD_PIN_SDA
 -      depends on PANEL_PROFILE="0" && PANEL_LCD="1" && PANEL_LCD_PROTO!="0"
 -        int "Parallel port pin number & polarity connected to the LCD SDA signal (-17...17) "
 -      range -17 17
 -      default 2
 -      ---help---
 -        This describes the number of the parallel port pin to which the serial
 -        LCD 'SDA' signal has been connected. It can be :
 -
 -                0 : no connection (eg: connected to ground)
 -            1..17 : directly connected to any of these pins on the DB25 plug
 -          -1..-17 : connected to the same pin through an inverter (eg: transistor).
 -
 -        Default for the 'SDA' pin in custom profile is '2' (D0).
 -
 -config PANEL_LCD_PIN_BL
 -      depends on PANEL_PROFILE="0" && PANEL_LCD="1"
 -        int "Parallel port pin number & polarity connected to the LCD backlight signal (-17...17) "
 -      range -17 17
 -      default 0
 -      ---help---
 -        This describes the number of the parallel port pin to which the LCD 'BL' signal
 -          has been connected. It can be :
 -
 -                0 : no connection (eg: connected to ground)
 -            1..17 : directly connected to any of these pins on the DB25 plug
 -          -1..-17 : connected to the same pin through an inverter (eg: transistor).
 -
 -        Default for the 'BL' pin in custom profile is '0' (uncontrolled).
 -
 -config PANEL_CHANGE_MESSAGE
 -      bool "Change LCD initialization message ?"
 -      default "n"
 -      ---help---
 -        This allows you to replace the boot message indicating the kernel version
 -        and the driver version with a custom message. This is useful on appliances
 -        where a simple 'Starting system' message can be enough to stop a customer
 -        from worrying.
 -
 -        If you say 'Y' here, you'll be able to choose a message yourself. Otherwise,
 -        say 'N' and keep the default message with the version.
 -
 -config PANEL_BOOT_MESSAGE
 -      depends on PANEL_CHANGE_MESSAGE="y"
 -      string "New initialization message"
 -      default ""
 -      ---help---
 -        This allows you to replace the boot message indicating the kernel version
 -        and the driver version with a custom message. This is useful on appliances
 -        where a simple 'Starting system' message can be enough to stop a customer
 -        from worrying.
 -
 -        An empty message will only clear the display at driver init time. Any other
 -        printf()-formatted message is valid with newline and escape codes.
 -
 -endif # PANEL
 +        Control Aspeed ast2400/2500 HOST LPC to BMC mappings through
 +        ioctl()s, the driver also provides a read/write interface to a BMC ram
 +        region where the host LPC read/write region can be buffered.
  
+ config PCI_ENDPOINT_TEST
+       depends on PCI
+       tristate "PCI Endpoint Test driver"
+       ---help---
+            Enable this configuration option to enable the host side test driver
+            for PCI Endpoint.
  source "drivers/misc/c2port/Kconfig"
  source "drivers/misc/eeprom/Kconfig"
  source "drivers/misc/cb710/Kconfig"
diff --combined drivers/misc/Makefile
index 4fb10af2ea1c635bf2096590b9a994500484579c,6e139cd704212e297968f004a17f90adb3a8360e..81ef3e67acc96a6dde7d5a0227760f399bb902ad
@@@ -37,6 -37,7 +37,6 @@@ obj-y                         += eeprom
  obj-y                         += cb710/
  obj-$(CONFIG_SPEAR13XX_PCIE_GADGET)   += spear13xx_pcie_gadget.o
  obj-$(CONFIG_VMWARE_BALLOON)  += vmw_balloon.o
 -obj-$(CONFIG_ARM_CHARLCD)     += arm-charlcd.o
  obj-$(CONFIG_PCH_PHUB)                += pch_phub.o
  obj-y                         += ti-st/
  obj-y                         += lis3lv02d/
@@@ -52,7 -53,8 +52,8 @@@ obj-$(CONFIG_GENWQE)          += genwqe
  obj-$(CONFIG_ECHO)            += echo/
  obj-$(CONFIG_VEXPRESS_SYSCFG) += vexpress-syscfg.o
  obj-$(CONFIG_CXL_BASE)                += cxl/
 -obj-$(CONFIG_PANEL)             += panel.o
 +obj-$(CONFIG_ASPEED_LPC_CTRL) += aspeed-lpc-ctrl.o
+ obj-$(CONFIG_PCI_ENDPOINT_TEST)       += pci_endpoint_test.o
  
  lkdtm-$(CONFIG_LKDTM)         += lkdtm_core.o
  lkdtm-$(CONFIG_LKDTM)         += lkdtm_bugs.o
@@@ -61,8 -63,6 +62,8 @@@ lkdtm-$(CONFIG_LKDTM)         += lkdtm_perms.
  lkdtm-$(CONFIG_LKDTM)         += lkdtm_rodata_objcopy.o
  lkdtm-$(CONFIG_LKDTM)         += lkdtm_usercopy.o
  
 +KCOV_INSTRUMENT_lkdtm_rodata.o        := n
 +
  OBJCOPYFLAGS :=
  OBJCOPYFLAGS_lkdtm_rodata_objcopy.o := \
                        --set-section-flags .text=alloc,readonly \
index 22a29df1d29eab871818353111e6abc9197e73bf,543ddde5f8e27f585c7aa3b6468e7a6b1539a53c..d39cba214320bd2565d6ad072610b48178897733
@@@ -49,9 -49,6 +49,9 @@@
  #include <linux/if_macvlan.h>
  #include <linux/if_bridge.h>
  #include <linux/prefetch.h>
 +#include <linux/bpf.h>
 +#include <linux/bpf_trace.h>
 +#include <linux/atomic.h>
  #include <scsi/fc/fc_fcoe.h>
  #include <net/udp_tunnel.h>
  #include <net/pkt_cls.h>
@@@ -88,7 -85,6 +88,7 @@@ static const struct ixgbe_info *ixgbe_i
        [board_X540]            = &ixgbe_X540_info,
        [board_X550]            = &ixgbe_X550_info,
        [board_X550EM_x]        = &ixgbe_X550EM_x_info,
 +      [board_x550em_x_fw]     = &ixgbe_x550em_x_fw_info,
        [board_x550em_a]        = &ixgbe_x550em_a_info,
        [board_x550em_a_fw]     = &ixgbe_x550em_a_fw_info,
  };
@@@ -135,11 -131,9 +135,11 @@@ static const struct pci_device_id ixgbe
        {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_X550T), board_X550},
        {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_X550T1), board_X550},
        {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_X550EM_X_KX4), board_X550EM_x},
 +      {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_X550EM_X_XFI), board_X550EM_x},
        {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_X550EM_X_KR), board_X550EM_x},
        {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_X550EM_X_10G_T), board_X550EM_x},
        {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_X550EM_X_SFP), board_X550EM_x},
 +      {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_X550EM_X_1G_T), board_x550em_x_fw},
        {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_X550EM_A_KR), board_x550em_a },
        {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_X550EM_A_KR_L), board_x550em_a },
        {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_X550EM_A_SFP_N), board_x550em_a },
@@@ -514,7 -508,7 +514,7 @@@ static const struct ixgbe_reg_info ixgb
   */
  static void ixgbe_regdump(struct ixgbe_hw *hw, struct ixgbe_reg_info *reginfo)
  {
 -      int i = 0, j = 0;
 +      int i;
        char rname[16];
        u32 regs[64];
  
                        regs[i] = IXGBE_READ_REG(hw, IXGBE_TXDCTL(i));
                break;
        default:
 -              pr_info("%-15s %08x\n", reginfo->name,
 -                      IXGBE_READ_REG(hw, reginfo->ofs));
 +              pr_info("%-15s %08x\n",
 +                      reginfo->name, IXGBE_READ_REG(hw, reginfo->ofs));
                return;
        }
  
 -      for (i = 0; i < 8; i++) {
 -              snprintf(rname, 16, "%s[%d-%d]", reginfo->name, i*8, i*8+7);
 -              pr_err("%-15s", rname);
 +      i = 0;
 +      while (i < 64) {
 +              int j;
 +              char buf[9 * 8 + 1];
 +              char *p = buf;
 +
 +              snprintf(rname, 16, "%s[%d-%d]", reginfo->name, i, i + 7);
                for (j = 0; j < 8; j++)
 -                      pr_cont(" %08x", regs[i*8+j]);
 -              pr_cont("\n");
 +                      p += sprintf(p, " %08x", regs[i++]);
 +              pr_err("%-15s%s\n", rname, buf);
        }
  
  }
  
 +static void ixgbe_print_buffer(struct ixgbe_ring *ring, int n)
 +{
 +      struct ixgbe_tx_buffer *tx_buffer;
 +
 +      tx_buffer = &ring->tx_buffer_info[ring->next_to_clean];
 +      pr_info(" %5d %5X %5X %016llX %08X %p %016llX\n",
 +              n, ring->next_to_use, ring->next_to_clean,
 +              (u64)dma_unmap_addr(tx_buffer, dma),
 +              dma_unmap_len(tx_buffer, len),
 +              tx_buffer->next_to_watch,
 +              (u64)tx_buffer->time_stamp);
 +}
 +
  /*
   * ixgbe_dump - Print registers, tx-rings and rx-rings
   */
@@@ -617,13 -594,14 +617,13 @@@ static void ixgbe_dump(struct ixgbe_ada
        struct ixgbe_hw *hw = &adapter->hw;
        struct ixgbe_reg_info *reginfo;
        int n = 0;
 -      struct ixgbe_ring *tx_ring;
 +      struct ixgbe_ring *ring;
        struct ixgbe_tx_buffer *tx_buffer;
        union ixgbe_adv_tx_desc *tx_desc;
        struct my_u0 { u64 a; u64 b; } *u0;
        struct ixgbe_ring *rx_ring;
        union ixgbe_adv_rx_desc *rx_desc;
        struct ixgbe_rx_buffer *rx_buffer_info;
 -      u32 staterr;
        int i = 0;
  
        if (!netif_msg_hw(adapter))
                "Queue [NTU] [NTC] [bi(ntc)->dma  ]",
                "leng", "ntw", "timestamp");
        for (n = 0; n < adapter->num_tx_queues; n++) {
 -              tx_ring = adapter->tx_ring[n];
 -              tx_buffer = &tx_ring->tx_buffer_info[tx_ring->next_to_clean];
 -              pr_info(" %5d %5X %5X %016llX %08X %p %016llX\n",
 -                         n, tx_ring->next_to_use, tx_ring->next_to_clean,
 -                         (u64)dma_unmap_addr(tx_buffer, dma),
 -                         dma_unmap_len(tx_buffer, len),
 -                         tx_buffer->next_to_watch,
 -                         (u64)tx_buffer->time_stamp);
 +              ring = adapter->tx_ring[n];
 +              ixgbe_print_buffer(ring, n);
 +      }
 +
 +      for (n = 0; n < adapter->num_xdp_queues; n++) {
 +              ring = adapter->xdp_ring[n];
 +              ixgbe_print_buffer(ring, n);
        }
  
        /* Print TX Rings */
         */
  
        for (n = 0; n < adapter->num_tx_queues; n++) {
 -              tx_ring = adapter->tx_ring[n];
 +              ring = adapter->tx_ring[n];
                pr_info("------------------------------------\n");
 -              pr_info("TX QUEUE INDEX = %d\n", tx_ring->queue_index);
 +              pr_info("TX QUEUE INDEX = %d\n", ring->queue_index);
                pr_info("------------------------------------\n");
                pr_info("%s%s    %s              %s        %s          %s\n",
                        "T [desc]     [address 63:0  ] ",
                        "[PlPOIdStDDt Ln] [bi->dma       ] ",
                        "leng", "ntw", "timestamp", "bi->skb");
  
 -              for (i = 0; tx_ring->desc && (i < tx_ring->count); i++) {
 -                      tx_desc = IXGBE_TX_DESC(tx_ring, i);
 -                      tx_buffer = &tx_ring->tx_buffer_info[i];
 +              for (i = 0; ring->desc && (i < ring->count); i++) {
 +                      tx_desc = IXGBE_TX_DESC(ring, i);
 +                      tx_buffer = &ring->tx_buffer_info[i];
                        u0 = (struct my_u0 *)tx_desc;
                        if (dma_unmap_len(tx_buffer, len) > 0) {
 -                              pr_info("T [0x%03X]    %016llX %016llX %016llX %08X %p %016llX %p",
 +                              const char *ring_desc;
 +
 +                              if (i == ring->next_to_use &&
 +                                  i == ring->next_to_clean)
 +                                      ring_desc = " NTC/U";
 +                              else if (i == ring->next_to_use)
 +                                      ring_desc = " NTU";
 +                              else if (i == ring->next_to_clean)
 +                                      ring_desc = " NTC";
 +                              else
 +                                      ring_desc = "";
 +                              pr_info("T [0x%03X]    %016llX %016llX %016llX %08X %p %016llX %p%s",
                                        i,
                                        le64_to_cpu(u0->a),
                                        le64_to_cpu(u0->b),
                                        dma_unmap_len(tx_buffer, len),
                                        tx_buffer->next_to_watch,
                                        (u64)tx_buffer->time_stamp,
 -                                      tx_buffer->skb);
 -                              if (i == tx_ring->next_to_use &&
 -                                      i == tx_ring->next_to_clean)
 -                                      pr_cont(" NTC/U\n");
 -                              else if (i == tx_ring->next_to_use)
 -                                      pr_cont(" NTU\n");
 -                              else if (i == tx_ring->next_to_clean)
 -                                      pr_cont(" NTC\n");
 -                              else
 -                                      pr_cont("\n");
 +                                      tx_buffer->skb,
 +                                      ring_desc);
  
                                if (netif_msg_pktdata(adapter) &&
                                    tx_buffer->skb)
@@@ -821,44 -797,34 +821,44 @@@ rx_ring_summary
                pr_info("------------------------------------\n");
                pr_info("RX QUEUE INDEX = %d\n", rx_ring->queue_index);
                pr_info("------------------------------------\n");
 -              pr_info("%s%s%s",
 +              pr_info("%s%s%s\n",
                        "R  [desc]      [ PktBuf     A0] ",
                        "[  HeadBuf   DD] [bi->dma       ] [bi->skb       ] ",
 -                      "<-- Adv Rx Read format\n");
 -              pr_info("%s%s%s",
 +                      "<-- Adv Rx Read format");
 +              pr_info("%s%s%s\n",
                        "RWB[desc]      [PcsmIpSHl PtRs] ",
                        "[vl er S cks ln] ---------------- [bi->skb       ] ",
 -                      "<-- Adv Rx Write-Back format\n");
 +                      "<-- Adv Rx Write-Back format");
  
                for (i = 0; i < rx_ring->count; i++) {
 +                      const char *ring_desc;
 +
 +                      if (i == rx_ring->next_to_use)
 +                              ring_desc = " NTU";
 +                      else if (i == rx_ring->next_to_clean)
 +                              ring_desc = " NTC";
 +                      else
 +                              ring_desc = "";
 +
                        rx_buffer_info = &rx_ring->rx_buffer_info[i];
                        rx_desc = IXGBE_RX_DESC(rx_ring, i);
                        u0 = (struct my_u0 *)rx_desc;
 -                      staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
 -                      if (staterr & IXGBE_RXD_STAT_DD) {
 +                      if (rx_desc->wb.upper.length) {
                                /* Descriptor Done */
 -                              pr_info("RWB[0x%03X]     %016llX "
 -                                      "%016llX ---------------- %p", i,
 +                              pr_info("RWB[0x%03X]     %016llX %016llX ---------------- %p%s\n",
 +                                      i,
                                        le64_to_cpu(u0->a),
                                        le64_to_cpu(u0->b),
 -                                      rx_buffer_info->skb);
 +                                      rx_buffer_info->skb,
 +                                      ring_desc);
                        } else {
 -                              pr_info("R  [0x%03X]     %016llX "
 -                                      "%016llX %016llX %p", i,
 +                              pr_info("R  [0x%03X]     %016llX %016llX %016llX %p%s\n",
 +                                      i,
                                        le64_to_cpu(u0->a),
                                        le64_to_cpu(u0->b),
                                        (u64)rx_buffer_info->dma,
 -                                      rx_buffer_info->skb);
 +                                      rx_buffer_info->skb,
 +                                      ring_desc);
  
                                if (netif_msg_pktdata(adapter) &&
                                    rx_buffer_info->dma) {
                                           ixgbe_rx_bufsz(rx_ring), true);
                                }
                        }
 -
 -                      if (i == rx_ring->next_to_use)
 -                              pr_cont(" NTU\n");
 -                      else if (i == rx_ring->next_to_clean)
 -                              pr_cont(" NTC\n");
 -                      else
 -                              pr_cont("\n");
 -
                }
        }
  }
@@@ -998,10 -972,6 +998,10 @@@ static void ixgbe_update_xoff_rx_lfc(st
        for (i = 0; i < adapter->num_tx_queues; i++)
                clear_bit(__IXGBE_HANG_CHECK_ARMED,
                          &adapter->tx_ring[i]->state);
 +
 +      for (i = 0; i < adapter->num_xdp_queues; i++)
 +              clear_bit(__IXGBE_HANG_CHECK_ARMED,
 +                        &adapter->xdp_ring[i]->state);
  }
  
  static void ixgbe_update_xoff_received(struct ixgbe_adapter *adapter)
                if (xoff[tc])
                        clear_bit(__IXGBE_HANG_CHECK_ARMED, &tx_ring->state);
        }
 +
 +      for (i = 0; i < adapter->num_xdp_queues; i++) {
 +              struct ixgbe_ring *xdp_ring = adapter->xdp_ring[i];
 +
 +              tc = xdp_ring->dcb_tc;
 +              if (xoff[tc])
 +                      clear_bit(__IXGBE_HANG_CHECK_ARMED, &xdp_ring->state);
 +      }
  }
  
  static u64 ixgbe_get_tx_completed(struct ixgbe_ring *ring)
@@@ -1205,10 -1167,7 +1205,10 @@@ static bool ixgbe_clean_tx_irq(struct i
                total_packets += tx_buffer->gso_segs;
  
                /* free the skb */
 -              napi_consume_skb(tx_buffer->skb, napi_budget);
 +              if (ring_is_xdp(tx_ring))
 +                      page_frag_free(tx_buffer->data);
 +              else
 +                      napi_consume_skb(tx_buffer->skb, napi_budget);
  
                /* unmap skb header data */
                dma_unmap_single(tx_ring->dev,
        if (check_for_tx_hang(tx_ring) && ixgbe_check_tx_hang(tx_ring)) {
                /* schedule immediate reset if we believe we hung */
                struct ixgbe_hw *hw = &adapter->hw;
 -              e_err(drv, "Detected Tx Unit Hang\n"
 +              e_err(drv, "Detected Tx Unit Hang %s\n"
                        "  Tx Queue             <%d>\n"
                        "  TDH, TDT             <%x>, <%x>\n"
                        "  next_to_use          <%x>\n"
                        "tx_buffer_info[next_to_clean]\n"
                        "  time_stamp           <%lx>\n"
                        "  jiffies              <%lx>\n",
 +                      ring_is_xdp(tx_ring) ? "(XDP)" : "",
                        tx_ring->queue_index,
                        IXGBE_READ_REG(hw, IXGBE_TDH(tx_ring->reg_idx)),
                        IXGBE_READ_REG(hw, IXGBE_TDT(tx_ring->reg_idx)),
                        tx_ring->next_to_use, i,
                        tx_ring->tx_buffer_info[i].time_stamp, jiffies);
  
 -              netif_stop_subqueue(tx_ring->netdev, tx_ring->queue_index);
 +              if (!ring_is_xdp(tx_ring))
 +                      netif_stop_subqueue(tx_ring->netdev,
 +                                          tx_ring->queue_index);
  
                e_info(probe,
                       "tx hang %d detected on queue %d, resetting adapter\n",
                return true;
        }
  
 +      if (ring_is_xdp(tx_ring))
 +              return !!budget;
 +
        netdev_tx_completed_queue(txring_txq(tx_ring),
                                  total_packets, total_bytes);
  
@@@ -1893,10 -1846,6 +1893,10 @@@ static void ixgbe_dma_sync_frag(struct 
   * @rx_desc: pointer to the EOP Rx descriptor
   * @skb: pointer to current skb being fixed
   *
 + * Check if the skb is valid in the XDP case it will be an error pointer.
 + * Return true in this case to abort processing and advance to next
 + * descriptor.
 + *
   * Check for corrupted packet headers caused by senders on the local L2
   * embedded NIC switch not setting up their Tx Descriptors right.  These
   * should be very rare.
@@@ -1915,10 -1864,6 +1915,10 @@@ static bool ixgbe_cleanup_headers(struc
  {
        struct net_device *netdev = rx_ring->netdev;
  
 +      /* XDP packets use error pointer so abort at this point */
 +      if (IS_ERR(skb))
 +              return true;
 +
        /* verify that the packet does not have any known errors */
        if (unlikely(ixgbe_test_staterr(rx_desc,
                                        IXGBE_RXDADV_ERR_FRAME_ERR_MASK) &&
@@@ -2094,7 -2039,7 +2094,7 @@@ static void ixgbe_put_rx_buffer(struct 
                /* hand second half of page back to the ring */
                ixgbe_reuse_rx_page(rx_ring, rx_buffer);
        } else {
 -              if (IXGBE_CB(skb)->dma == rx_buffer->dma) {
 +              if (!IS_ERR(skb) && IXGBE_CB(skb)->dma == rx_buffer->dma) {
                        /* the page has been released from the ring */
                        IXGBE_CB(skb)->page_released = true;
                } else {
  
  static struct sk_buff *ixgbe_construct_skb(struct ixgbe_ring *rx_ring,
                                           struct ixgbe_rx_buffer *rx_buffer,
 -                                         union ixgbe_adv_rx_desc *rx_desc,
 -                                         unsigned int size)
 +                                         struct xdp_buff *xdp,
 +                                         union ixgbe_adv_rx_desc *rx_desc)
  {
 -      void *va = page_address(rx_buffer->page) + rx_buffer->page_offset;
 +      unsigned int size = xdp->data_end - xdp->data;
  #if (PAGE_SIZE < 8192)
        unsigned int truesize = ixgbe_rx_pg_size(rx_ring) / 2;
  #else
 -      unsigned int truesize = SKB_DATA_ALIGN(size);
 +      unsigned int truesize = SKB_DATA_ALIGN(xdp->data_end -
 +                                             xdp->data_hard_start);
  #endif
        struct sk_buff *skb;
  
        /* prefetch first cache line of first page */
 -      prefetch(va);
 +      prefetch(xdp->data);
  #if L1_CACHE_BYTES < 128
 -      prefetch(va + L1_CACHE_BYTES);
 +      prefetch(xdp->data + L1_CACHE_BYTES);
  #endif
  
        /* allocate a skb to store the frags */
                        IXGBE_CB(skb)->dma = rx_buffer->dma;
  
                skb_add_rx_frag(skb, 0, rx_buffer->page,
 -                              rx_buffer->page_offset,
 +                              xdp->data - page_address(rx_buffer->page),
                                size, truesize);
  #if (PAGE_SIZE < 8192)
                rx_buffer->page_offset ^= truesize;
                rx_buffer->page_offset += truesize;
  #endif
        } else {
 -              memcpy(__skb_put(skb, size), va, ALIGN(size, sizeof(long)));
 +              memcpy(__skb_put(skb, size),
 +                     xdp->data, ALIGN(size, sizeof(long)));
                rx_buffer->pagecnt_bias++;
        }
  
  
  static struct sk_buff *ixgbe_build_skb(struct ixgbe_ring *rx_ring,
                                       struct ixgbe_rx_buffer *rx_buffer,
 -                                     union ixgbe_adv_rx_desc *rx_desc,
 -                                     unsigned int size)
 +                                     struct xdp_buff *xdp,
 +                                     union ixgbe_adv_rx_desc *rx_desc)
  {
 -      void *va = page_address(rx_buffer->page) + rx_buffer->page_offset;
  #if (PAGE_SIZE < 8192)
        unsigned int truesize = ixgbe_rx_pg_size(rx_ring) / 2;
  #else
        unsigned int truesize = SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) +
 -                              SKB_DATA_ALIGN(IXGBE_SKB_PAD + size);
 +                              SKB_DATA_ALIGN(xdp->data_end -
 +                                             xdp->data_hard_start);
  #endif
        struct sk_buff *skb;
  
        /* prefetch first cache line of first page */
 -      prefetch(va);
 +      prefetch(xdp->data);
  #if L1_CACHE_BYTES < 128
 -      prefetch(va + L1_CACHE_BYTES);
 +      prefetch(xdp->data + L1_CACHE_BYTES);
  #endif
  
        /* build an skb to around the page buffer */
 -      skb = build_skb(va - IXGBE_SKB_PAD, truesize);
 +      skb = build_skb(xdp->data_hard_start, truesize);
        if (unlikely(!skb))
                return NULL;
  
        /* update pointers within the skb to store the data */
 -      skb_reserve(skb, IXGBE_SKB_PAD);
 -      __skb_put(skb, size);
 +      skb_reserve(skb, xdp->data - xdp->data_hard_start);
 +      __skb_put(skb, xdp->data_end - xdp->data);
  
        /* record DMA address if this is the start of a chain of buffers */
        if (!ixgbe_test_staterr(rx_desc, IXGBE_RXD_STAT_EOP))
        return skb;
  }
  
 +#define IXGBE_XDP_PASS 0
 +#define IXGBE_XDP_CONSUMED 1
 +#define IXGBE_XDP_TX 2
 +
 +static int ixgbe_xmit_xdp_ring(struct ixgbe_adapter *adapter,
 +                             struct xdp_buff *xdp);
 +
 +static struct sk_buff *ixgbe_run_xdp(struct ixgbe_adapter *adapter,
 +                                   struct ixgbe_ring *rx_ring,
 +                                   struct xdp_buff *xdp)
 +{
 +      int result = IXGBE_XDP_PASS;
 +      struct bpf_prog *xdp_prog;
 +      u32 act;
 +
 +      rcu_read_lock();
 +      xdp_prog = READ_ONCE(rx_ring->xdp_prog);
 +
 +      if (!xdp_prog)
 +              goto xdp_out;
 +
 +      act = bpf_prog_run_xdp(xdp_prog, xdp);
 +      switch (act) {
 +      case XDP_PASS:
 +              break;
 +      case XDP_TX:
 +              result = ixgbe_xmit_xdp_ring(adapter, xdp);
 +              break;
 +      default:
 +              bpf_warn_invalid_xdp_action(act);
 +      case XDP_ABORTED:
 +              trace_xdp_exception(rx_ring->netdev, xdp_prog, act);
 +              /* fallthrough -- handle aborts by dropping packet */
 +      case XDP_DROP:
 +              result = IXGBE_XDP_CONSUMED;
 +              break;
 +      }
 +xdp_out:
 +      rcu_read_unlock();
 +      return ERR_PTR(-result);
 +}
 +
 +static void ixgbe_rx_buffer_flip(struct ixgbe_ring *rx_ring,
 +                               struct ixgbe_rx_buffer *rx_buffer,
 +                               unsigned int size)
 +{
 +#if (PAGE_SIZE < 8192)
 +      unsigned int truesize = ixgbe_rx_pg_size(rx_ring) / 2;
 +
 +      rx_buffer->page_offset ^= truesize;
 +#else
 +      unsigned int truesize = ring_uses_build_skb(rx_ring) ?
 +                              SKB_DATA_ALIGN(IXGBE_SKB_PAD + size) :
 +                              SKB_DATA_ALIGN(size);
 +
 +      rx_buffer->page_offset += truesize;
 +#endif
 +}
 +
  /**
   * ixgbe_clean_rx_irq - Clean completed descriptors from Rx ring - bounce buf
   * @q_vector: structure containing interrupt and ring information
@@@ -2279,19 -2163,17 +2279,19 @@@ static int ixgbe_clean_rx_irq(struct ix
                               const int budget)
  {
        unsigned int total_rx_bytes = 0, total_rx_packets = 0;
 -#ifdef IXGBE_FCOE
        struct ixgbe_adapter *adapter = q_vector->adapter;
 +#ifdef IXGBE_FCOE
        int ddp_bytes;
        unsigned int mss = 0;
  #endif /* IXGBE_FCOE */
        u16 cleaned_count = ixgbe_desc_unused(rx_ring);
 +      bool xdp_xmit = false;
  
        while (likely(total_rx_packets < budget)) {
                union ixgbe_adv_rx_desc *rx_desc;
                struct ixgbe_rx_buffer *rx_buffer;
                struct sk_buff *skb;
 +              struct xdp_buff xdp;
                unsigned int size;
  
                /* return some buffers to hardware, one at a time is too slow */
                rx_buffer = ixgbe_get_rx_buffer(rx_ring, rx_desc, &skb, size);
  
                /* retrieve a buffer from the ring */
 -              if (skb)
 +              if (!skb) {
 +                      xdp.data = page_address(rx_buffer->page) +
 +                                 rx_buffer->page_offset;
 +                      xdp.data_hard_start = xdp.data -
 +                                            ixgbe_rx_offset(rx_ring);
 +                      xdp.data_end = xdp.data + size;
 +
 +                      skb = ixgbe_run_xdp(adapter, rx_ring, &xdp);
 +              }
 +
 +              if (IS_ERR(skb)) {
 +                      if (PTR_ERR(skb) == -IXGBE_XDP_TX) {
 +                              xdp_xmit = true;
 +                              ixgbe_rx_buffer_flip(rx_ring, rx_buffer, size);
 +                      } else {
 +                              rx_buffer->pagecnt_bias++;
 +                      }
 +                      total_rx_packets++;
 +                      total_rx_bytes += size;
 +              } else if (skb) {
                        ixgbe_add_rx_frag(rx_ring, rx_buffer, skb, size);
 -              else if (ring_uses_build_skb(rx_ring))
 +              } else if (ring_uses_build_skb(rx_ring)) {
                        skb = ixgbe_build_skb(rx_ring, rx_buffer,
 -                                            rx_desc, size);
 -              else
 +                                            &xdp, rx_desc);
 +              } else {
                        skb = ixgbe_construct_skb(rx_ring, rx_buffer,
 -                                                rx_desc, size);
 +                                                &xdp, rx_desc);
 +              }
  
                /* exit if we failed to retrieve a buffer */
                if (!skb) {
                total_rx_packets++;
        }
  
 +      if (xdp_xmit) {
 +              struct ixgbe_ring *ring = adapter->xdp_ring[smp_processor_id()];
 +
 +              /* Force memory writes to complete before letting h/w
 +               * know there are new descriptors to fetch.
 +               */
 +              wmb();
 +              writel(ring->next_to_use, ring->tail);
 +      }
 +
        u64_stats_update_begin(&rx_ring->syncp);
        rx_ring->stats.packets += total_rx_packets;
        rx_ring->stats.bytes += total_rx_bytes;
@@@ -3512,8 -3364,6 +3512,8 @@@ static void ixgbe_configure_tx(struct i
        /* Setup the HW Tx Head and Tail descriptor pointers */
        for (i = 0; i < adapter->num_tx_queues; i++)
                ixgbe_configure_tx_ring(adapter, adapter->tx_ring[i]);
 +      for (i = 0; i < adapter->num_xdp_queues; i++)
 +              ixgbe_configure_tx_ring(adapter, adapter->xdp_ring[i]);
  }
  
  static void ixgbe_enable_rx_drop(struct ixgbe_adapter *adapter,
@@@ -3638,28 -3488,6 +3638,28 @@@ void ixgbe_store_key(struct ixgbe_adapt
                IXGBE_WRITE_REG(hw, IXGBE_RSSRK(i), adapter->rss_key[i]);
  }
  
 +/**
 + * ixgbe_init_rss_key - Initialize adapter RSS key
 + * @adapter: device handle
 + *
 + * Allocates and initializes the RSS key if it is not allocated.
 + **/
 +static inline int ixgbe_init_rss_key(struct ixgbe_adapter *adapter)
 +{
 +      u32 *rss_key;
 +
 +      if (!adapter->rss_key) {
 +              rss_key = kzalloc(IXGBE_RSS_KEY_SIZE, GFP_KERNEL);
 +              if (unlikely(!rss_key))
 +                      return -ENOMEM;
 +
 +              netdev_rss_key_fill(rss_key, IXGBE_RSS_KEY_SIZE);
 +              adapter->rss_key = rss_key;
 +      }
 +
 +      return 0;
 +}
 +
  /**
   * ixgbe_store_reta - Write the RETA table to HW
   * @adapter: device handle
@@@ -3762,7 -3590,7 +3762,7 @@@ static void ixgbe_setup_vfreta(struct i
        /* Fill out hash function seeds */
        for (i = 0; i < 10; i++)
                IXGBE_WRITE_REG(hw, IXGBE_PFVFRSSRK(i, pf_pool),
 -                              adapter->rss_key[i]);
 +                              *(adapter->rss_key + i));
  
        /* Fill out the redirection table */
        for (i = 0, j = 0; i < 64; i++, j++) {
@@@ -3823,6 -3651,7 +3823,6 @@@ static void ixgbe_setup_mrqc(struct ixg
        if (adapter->flags2 & IXGBE_FLAG2_RSS_FIELD_IPV6_UDP)
                rss_field |= IXGBE_MRQC_RSS_FIELD_IPV6_UDP;
  
 -      netdev_rss_key_fill(adapter->rss_key, sizeof(adapter->rss_key));
        if ((hw->mac.type >= ixgbe_mac_X550) &&
            (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED)) {
                unsigned int pf_pool = adapter->num_vfs;
@@@ -3973,7 -3802,7 +3973,7 @@@ void ixgbe_configure_rx_ring(struct ixg
                /* Limit the maximum frame size so we don't overrun the skb */
                if (ring_uses_build_skb(ring) &&
                    !test_bit(__IXGBE_RX_3K_BUFFER, &ring->state))
 -                      rxdctl |= IXGBE_MAX_FRAME_BUILD_SKB |
 +                      rxdctl |= IXGBE_MAX_2K_FRAME_BUILD_SKB |
                                  IXGBE_RXDCTL_RLPML_EN;
  #endif
        }
@@@ -4143,8 -3972,8 +4143,8 @@@ static void ixgbe_set_rx_buffer_len(str
                if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED)
                        set_bit(__IXGBE_RX_3K_BUFFER, &rx_ring->state);
  
 -              if ((max_frame > (ETH_FRAME_LEN + ETH_FCS_LEN)) ||
 -                  (max_frame > IXGBE_MAX_FRAME_BUILD_SKB))
 +              if (IXGBE_2K_TOO_SMALL_WITH_PADDING ||
 +                  (max_frame > (ETH_FRAME_LEN + ETH_FCS_LEN)))
                        set_bit(__IXGBE_RX_3K_BUFFER, &rx_ring->state);
  #endif
        }
@@@ -5676,10 -5505,7 +5676,10 @@@ static void ixgbe_clean_tx_ring(struct 
                union ixgbe_adv_tx_desc *eop_desc, *tx_desc;
  
                /* Free all the Tx ring sk_buffs */
 -              dev_kfree_skb_any(tx_buffer->skb);
 +              if (ring_is_xdp(tx_ring))
 +                      page_frag_free(tx_buffer->data);
 +              else
 +                      dev_kfree_skb_any(tx_buffer->skb);
  
                /* unmap skb header data */
                dma_unmap_single(tx_ring->dev,
        }
  
        /* reset BQL for queue */
 -      netdev_tx_reset_queue(txring_txq(tx_ring));
 +      if (!ring_is_xdp(tx_ring))
 +              netdev_tx_reset_queue(txring_txq(tx_ring));
  
        /* reset next_to_use and next_to_clean */
        tx_ring->next_to_use = 0;
@@@ -5750,8 -5575,6 +5750,8 @@@ static void ixgbe_clean_all_tx_rings(st
  
        for (i = 0; i < adapter->num_tx_queues; i++)
                ixgbe_clean_tx_ring(adapter->tx_ring[i]);
 +      for (i = 0; i < adapter->num_xdp_queues; i++)
 +              ixgbe_clean_tx_ring(adapter->xdp_ring[i]);
  }
  
  static void ixgbe_fdir_filter_exit(struct ixgbe_adapter *adapter)
@@@ -5846,11 -5669,6 +5846,11 @@@ void ixgbe_down(struct ixgbe_adapter *a
                u8 reg_idx = adapter->tx_ring[i]->reg_idx;
                IXGBE_WRITE_REG(hw, IXGBE_TXDCTL(reg_idx), IXGBE_TXDCTL_SWFLSH);
        }
 +      for (i = 0; i < adapter->num_xdp_queues; i++) {
 +              u8 reg_idx = adapter->xdp_ring[i]->reg_idx;
 +
 +              IXGBE_WRITE_REG(hw, IXGBE_TXDCTL(reg_idx), IXGBE_TXDCTL_SWFLSH);
 +      }
  
        /* Disable the Tx DMA engine on 82599 and later MAC */
        switch (hw->mac.type) {
@@@ -6036,9 -5854,6 +6036,9 @@@ static int ixgbe_sw_init(struct ixgbe_a
        if (!adapter->mac_table)
                return -ENOMEM;
  
 +      if (ixgbe_init_rss_key(adapter))
 +              return -ENOMEM;
 +
        /* Set MAC specific capability flags and exceptions */
        switch (hw->mac.type) {
        case ixgbe_mac_82598EB:
        /* assign number of SR-IOV VFs */
        if (hw->mac.type != ixgbe_mac_82598EB) {
                if (max_vfs > IXGBE_MAX_VFS_DRV_LIMIT) {
 -                      adapter->num_vfs = 0;
 +                      max_vfs = 0;
                        e_dev_warn("max_vfs parameter out of range. Not assigning any SR-IOV VFs\n");
 -              } else {
 -                      adapter->num_vfs = max_vfs;
                }
        }
  #endif /* CONFIG_PCI_IOV */
@@@ -6224,7 -6041,7 +6224,7 @@@ err
   **/
  static int ixgbe_setup_all_tx_resources(struct ixgbe_adapter *adapter)
  {
 -      int i, err = 0;
 +      int i, j = 0, err = 0;
  
        for (i = 0; i < adapter->num_tx_queues; i++) {
                err = ixgbe_setup_tx_resources(adapter->tx_ring[i]);
                e_err(probe, "Allocation for Tx Queue %u failed\n", i);
                goto err_setup_tx;
        }
 +      for (j = 0; j < adapter->num_xdp_queues; j++) {
 +              err = ixgbe_setup_tx_resources(adapter->xdp_ring[j]);
 +              if (!err)
 +                      continue;
 +
 +              e_err(probe, "Allocation for Tx Queue %u failed\n", j);
 +              goto err_setup_tx;
 +      }
  
        return 0;
  err_setup_tx:
        /* rewind the index freeing the rings as we go */
 +      while (j--)
 +              ixgbe_free_tx_resources(adapter->xdp_ring[j]);
        while (i--)
                ixgbe_free_tx_resources(adapter->tx_ring[i]);
        return err;
   *
   * Returns 0 on success, negative on failure
   **/
 -int ixgbe_setup_rx_resources(struct ixgbe_ring *rx_ring)
 +int ixgbe_setup_rx_resources(struct ixgbe_adapter *adapter,
 +                           struct ixgbe_ring *rx_ring)
  {
        struct device *dev = rx_ring->dev;
        int orig_node = dev_to_node(dev);
        rx_ring->next_to_clean = 0;
        rx_ring->next_to_use = 0;
  
 +      rx_ring->xdp_prog = adapter->xdp_prog;
 +
        return 0;
  err:
        vfree(rx_ring->rx_buffer_info);
@@@ -6324,7 -6128,7 +6324,7 @@@ static int ixgbe_setup_all_rx_resources
        int i, err = 0;
  
        for (i = 0; i < adapter->num_rx_queues; i++) {
 -              err = ixgbe_setup_rx_resources(adapter->rx_ring[i]);
 +              err = ixgbe_setup_rx_resources(adapter, adapter->rx_ring[i]);
                if (!err)
                        continue;
  
@@@ -6380,9 -6184,6 +6380,9 @@@ static void ixgbe_free_all_tx_resources
        for (i = 0; i < adapter->num_tx_queues; i++)
                if (adapter->tx_ring[i]->desc)
                        ixgbe_free_tx_resources(adapter->tx_ring[i]);
 +      for (i = 0; i < adapter->num_xdp_queues; i++)
 +              if (adapter->xdp_ring[i]->desc)
 +                      ixgbe_free_tx_resources(adapter->xdp_ring[i]);
  }
  
  /**
@@@ -6395,7 -6196,6 +6395,7 @@@ void ixgbe_free_rx_resources(struct ixg
  {
        ixgbe_clean_rx_ring(rx_ring);
  
 +      rx_ring->xdp_prog = NULL;
        vfree(rx_ring->rx_buffer_info);
        rx_ring->rx_buffer_info = NULL;
  
@@@ -6802,14 -6602,6 +6802,14 @@@ void ixgbe_update_stats(struct ixgbe_ad
                bytes += tx_ring->stats.bytes;
                packets += tx_ring->stats.packets;
        }
 +      for (i = 0; i < adapter->num_xdp_queues; i++) {
 +              struct ixgbe_ring *xdp_ring = adapter->xdp_ring[i];
 +
 +              restart_queue += xdp_ring->tx_stats.restart_queue;
 +              tx_busy += xdp_ring->tx_stats.tx_busy;
 +              bytes += xdp_ring->stats.bytes;
 +              packets += xdp_ring->stats.packets;
 +      }
        adapter->restart_queue = restart_queue;
        adapter->tx_busy = tx_busy;
        netdev->stats.tx_bytes = bytes;
@@@ -7003,9 -6795,6 +7003,9 @@@ static void ixgbe_fdir_reinit_subtask(s
                for (i = 0; i < adapter->num_tx_queues; i++)
                        set_bit(__IXGBE_TX_FDIR_INIT_DONE,
                                &(adapter->tx_ring[i]->state));
 +              for (i = 0; i < adapter->num_xdp_queues; i++)
 +                      set_bit(__IXGBE_TX_FDIR_INIT_DONE,
 +                              &adapter->xdp_ring[i]->state);
                /* re-enable flow director interrupts */
                IXGBE_WRITE_REG(hw, IXGBE_EIMS, IXGBE_EIMS_FLOW_DIR);
        } else {
@@@ -7039,8 -6828,6 +7039,8 @@@ static void ixgbe_check_hang_subtask(st
        if (netif_carrier_ok(adapter->netdev)) {
                for (i = 0; i < adapter->num_tx_queues; i++)
                        set_check_for_tx_hang(adapter->tx_ring[i]);
 +              for (i = 0; i < adapter->num_xdp_queues; i++)
 +                      set_check_for_tx_hang(adapter->xdp_ring[i]);
        }
  
        if (!(adapter->flags & IXGBE_FLAG_MSIX_ENABLED)) {
@@@ -7271,13 -7058,6 +7271,13 @@@ static bool ixgbe_ring_tx_pending(struc
                        return true;
        }
  
 +      for (i = 0; i < adapter->num_xdp_queues; i++) {
 +              struct ixgbe_ring *ring = adapter->xdp_ring[i];
 +
 +              if (ring->next_to_use != ring->next_to_clean)
 +                      return true;
 +      }
 +
        return false;
  }
  
@@@ -7332,18 -7112,6 +7332,6 @@@ static void ixgbe_watchdog_flush_tx(str
  }
  
  #ifdef CONFIG_PCI_IOV
- static inline void ixgbe_issue_vf_flr(struct ixgbe_adapter *adapter,
-                                     struct pci_dev *vfdev)
- {
-       if (!pci_wait_for_pending_transaction(vfdev))
-               e_dev_warn("Issuing VFLR with pending transactions\n");
-       e_dev_err("Issuing VFLR for VF %s\n", pci_name(vfdev));
-       pcie_capability_set_word(vfdev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_BCR_FLR);
-       msleep(100);
- }
  static void ixgbe_check_for_bad_vf(struct ixgbe_adapter *adapter)
  {
        struct ixgbe_hw *hw = &adapter->hw;
                pci_read_config_word(vfdev, PCI_STATUS, &status_reg);
                if (status_reg != IXGBE_FAILED_READ_CFG_WORD &&
                    status_reg & PCI_STATUS_REC_MASTER_ABORT)
-                       ixgbe_issue_vf_flr(adapter, vfdev);
+                       pcie_flr(vfdev);
        }
  }
  
@@@ -8235,62 -8003,6 +8223,62 @@@ static u16 ixgbe_select_queue(struct ne
  #endif
  }
  
 +static int ixgbe_xmit_xdp_ring(struct ixgbe_adapter *adapter,
 +                             struct xdp_buff *xdp)
 +{
 +      struct ixgbe_ring *ring = adapter->xdp_ring[smp_processor_id()];
 +      struct ixgbe_tx_buffer *tx_buffer;
 +      union ixgbe_adv_tx_desc *tx_desc;
 +      u32 len, cmd_type;
 +      dma_addr_t dma;
 +      u16 i;
 +
 +      len = xdp->data_end - xdp->data;
 +
 +      if (unlikely(!ixgbe_desc_unused(ring)))
 +              return IXGBE_XDP_CONSUMED;
 +
 +      dma = dma_map_single(ring->dev, xdp->data, len, DMA_TO_DEVICE);
 +      if (dma_mapping_error(ring->dev, dma))
 +              return IXGBE_XDP_CONSUMED;
 +
 +      /* record the location of the first descriptor for this packet */
 +      tx_buffer = &ring->tx_buffer_info[ring->next_to_use];
 +      tx_buffer->bytecount = len;
 +      tx_buffer->gso_segs = 1;
 +      tx_buffer->protocol = 0;
 +
 +      i = ring->next_to_use;
 +      tx_desc = IXGBE_TX_DESC(ring, i);
 +
 +      dma_unmap_len_set(tx_buffer, len, len);
 +      dma_unmap_addr_set(tx_buffer, dma, dma);
 +      tx_buffer->data = xdp->data;
 +      tx_desc->read.buffer_addr = cpu_to_le64(dma);
 +
 +      /* put descriptor type bits */
 +      cmd_type = IXGBE_ADVTXD_DTYP_DATA |
 +                 IXGBE_ADVTXD_DCMD_DEXT |
 +                 IXGBE_ADVTXD_DCMD_IFCS;
 +      cmd_type |= len | IXGBE_TXD_CMD;
 +      tx_desc->read.cmd_type_len = cpu_to_le32(cmd_type);
 +      tx_desc->read.olinfo_status =
 +              cpu_to_le32(len << IXGBE_ADVTXD_PAYLEN_SHIFT);
 +
 +      /* Avoid any potential race with xdp_xmit and cleanup */
 +      smp_wmb();
 +
 +      /* set next_to_watch value indicating a packet is present */
 +      i++;
 +      if (i == ring->count)
 +              i = 0;
 +
 +      tx_buffer->next_to_watch = tx_desc;
 +      ring->next_to_use = i;
 +
 +      return IXGBE_XDP_TX;
 +}
 +
  netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb,
                          struct ixgbe_adapter *adapter,
                          struct ixgbe_ring *tx_ring)
@@@ -8582,23 -8294,6 +8570,23 @@@ static void ixgbe_netpoll(struct net_de
  
  #endif
  
 +static void ixgbe_get_ring_stats64(struct rtnl_link_stats64 *stats,
 +                                 struct ixgbe_ring *ring)
 +{
 +      u64 bytes, packets;
 +      unsigned int start;
 +
 +      if (ring) {
 +              do {
 +                      start = u64_stats_fetch_begin_irq(&ring->syncp);
 +                      packets = ring->stats.packets;
 +                      bytes   = ring->stats.bytes;
 +              } while (u64_stats_fetch_retry_irq(&ring->syncp, start));
 +              stats->tx_packets += packets;
 +              stats->tx_bytes   += bytes;
 +      }
 +}
 +
  static void ixgbe_get_stats64(struct net_device *netdev,
                              struct rtnl_link_stats64 *stats)
  {
  
        for (i = 0; i < adapter->num_tx_queues; i++) {
                struct ixgbe_ring *ring = ACCESS_ONCE(adapter->tx_ring[i]);
 -              u64 bytes, packets;
 -              unsigned int start;
  
 -              if (ring) {
 -                      do {
 -                              start = u64_stats_fetch_begin_irq(&ring->syncp);
 -                              packets = ring->stats.packets;
 -                              bytes   = ring->stats.bytes;
 -                      } while (u64_stats_fetch_retry_irq(&ring->syncp, start));
 -                      stats->tx_packets += packets;
 -                      stats->tx_bytes   += bytes;
 -              }
 +              ixgbe_get_ring_stats64(stats, ring);
 +      }
 +      for (i = 0; i < adapter->num_xdp_queues; i++) {
 +              struct ixgbe_ring *ring = ACCESS_ONCE(adapter->xdp_ring[i]);
 +
 +              ixgbe_get_ring_stats64(stats, ring);
        }
        rcu_read_unlock();
  
@@@ -9236,9 -8936,7 +9224,9 @@@ static int __ixgbe_setup_tc(struct net_
        if (tc->type != TC_SETUP_MQPRIO)
                return -EINVAL;
  
 -      return ixgbe_setup_tc(dev, tc->tc);
 +      tc->mqprio->hw = TC_MQPRIO_HW_OFFLOAD_TCS;
 +
 +      return ixgbe_setup_tc(dev, tc->mqprio->num_tc);
  }
  
  #ifdef CONFIG_PCI_IOV
@@@ -9749,68 -9447,6 +9737,68 @@@ ixgbe_features_check(struct sk_buff *sk
        return features;
  }
  
 +static int ixgbe_xdp_setup(struct net_device *dev, struct bpf_prog *prog)
 +{
 +      int i, frame_size = dev->mtu + ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN;
 +      struct ixgbe_adapter *adapter = netdev_priv(dev);
 +      struct bpf_prog *old_prog;
 +
 +      if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED)
 +              return -EINVAL;
 +
 +      if (adapter->flags & IXGBE_FLAG_DCB_ENABLED)
 +              return -EINVAL;
 +
 +      /* verify ixgbe ring attributes are sufficient for XDP */
 +      for (i = 0; i < adapter->num_rx_queues; i++) {
 +              struct ixgbe_ring *ring = adapter->rx_ring[i];
 +
 +              if (ring_is_rsc_enabled(ring))
 +                      return -EINVAL;
 +
 +              if (frame_size > ixgbe_rx_bufsz(ring))
 +                      return -EINVAL;
 +      }
 +
 +      if (nr_cpu_ids > MAX_XDP_QUEUES)
 +              return -ENOMEM;
 +
 +      old_prog = xchg(&adapter->xdp_prog, prog);
 +
 +      /* If transitioning XDP modes reconfigure rings */
 +      if (!!prog != !!old_prog) {
 +              int err = ixgbe_setup_tc(dev, netdev_get_num_tc(dev));
 +
 +              if (err) {
 +                      rcu_assign_pointer(adapter->xdp_prog, old_prog);
 +                      return -EINVAL;
 +              }
 +      } else {
 +              for (i = 0; i < adapter->num_rx_queues; i++)
 +                      xchg(&adapter->rx_ring[i]->xdp_prog, adapter->xdp_prog);
 +      }
 +
 +      if (old_prog)
 +              bpf_prog_put(old_prog);
 +
 +      return 0;
 +}
 +
 +static int ixgbe_xdp(struct net_device *dev, struct netdev_xdp *xdp)
 +{
 +      struct ixgbe_adapter *adapter = netdev_priv(dev);
 +
 +      switch (xdp->command) {
 +      case XDP_SETUP_PROG:
 +              return ixgbe_xdp_setup(dev, xdp->prog);
 +      case XDP_QUERY_PROG:
 +              xdp->prog_attached = !!(adapter->xdp_prog);
 +              return 0;
 +      default:
 +              return -EINVAL;
 +      }
 +}
 +
  static const struct net_device_ops ixgbe_netdev_ops = {
        .ndo_open               = ixgbe_open,
        .ndo_stop               = ixgbe_close,
        .ndo_udp_tunnel_add     = ixgbe_add_udp_tunnel_port,
        .ndo_udp_tunnel_del     = ixgbe_del_udp_tunnel_port,
        .ndo_features_check     = ixgbe_features_check,
 +      .ndo_xdp                = ixgbe_xdp,
  };
  
  /**
@@@ -10161,7 -9796,7 +10149,7 @@@ static int ixgbe_probe(struct pci_dev *
        ixgbe_init_mbx_params_pf(hw);
        hw->mbx.ops = ii->mbx_ops;
        pci_sriov_set_totalvfs(pdev, IXGBE_MAX_VFS_DRV_LIMIT);
 -      ixgbe_enable_sriov(adapter);
 +      ixgbe_enable_sriov(adapter, max_vfs);
  skip_sriov:
  
  #endif
        if (err)
                goto err_sw_init;
  
 +      for (i = 0; i < adapter->num_xdp_queues; i++)
 +              u64_stats_init(&adapter->xdp_ring[i]->syncp);
 +
        /* WOL not supported for all devices */
        adapter->wol = 0;
        hw->eeprom.ops.read(hw, 0x2c, &adapter->eeprom_cap);
@@@ -10415,7 -10047,6 +10403,7 @@@ err_sw_init
        iounmap(adapter->io_addr);
        kfree(adapter->jump_tables[0]);
        kfree(adapter->mac_table);
 +      kfree(adapter->rss_key);
  err_ioremap:
        disable_dev = !test_and_set_bit(__IXGBE_DISABLED, &adapter->state);
        free_netdev(netdev);
@@@ -10500,7 -10131,6 +10488,7 @@@ static void ixgbe_remove(struct pci_de
        }
  
        kfree(adapter->mac_table);
 +      kfree(adapter->rss_key);
        disable_dev = !test_and_set_bit(__IXGBE_DISABLED, &adapter->state);
        free_netdev(netdev);
  
@@@ -10602,7 -10232,7 +10590,7 @@@ static pci_ers_result_t ixgbe_io_error_
                 * VFLR.  Just clean up the AER in that case.
                 */
                if (vfdev) {
-                       ixgbe_issue_vf_flr(adapter, vfdev);
+                       pcie_flr(vfdev);
                        /* Free device reference count */
                        pci_dev_put(vfdev);
                }
diff --combined drivers/nvme/host/pci.c
index 56a315bd4d9627213e8a49a13ade68da74007a88,925997127a6b5fa3800e94fb7d3bbacff2cc944d..fed803232edccbdf63139d89028c694efff52409
@@@ -19,7 -19,6 +19,7 @@@
  #include <linux/blk-mq-pci.h>
  #include <linux/cpu.h>
  #include <linux/delay.h>
 +#include <linux/dmi.h>
  #include <linux/errno.h>
  #include <linux/fs.h>
  #include <linux/genhd.h>
@@@ -104,22 -103,8 +104,22 @@@ struct nvme_dev 
        u32 cmbloc;
        struct nvme_ctrl ctrl;
        struct completion ioq_wait;
 +      u32 *dbbuf_dbs;
 +      dma_addr_t dbbuf_dbs_dma_addr;
 +      u32 *dbbuf_eis;
 +      dma_addr_t dbbuf_eis_dma_addr;
  };
  
 +static inline unsigned int sq_idx(unsigned int qid, u32 stride)
 +{
 +      return qid * 2 * stride;
 +}
 +
 +static inline unsigned int cq_idx(unsigned int qid, u32 stride)
 +{
 +      return (qid * 2 + 1) * stride;
 +}
 +
  static inline struct nvme_dev *to_nvme_dev(struct nvme_ctrl *ctrl)
  {
        return container_of(ctrl, struct nvme_dev, ctrl);
  struct nvme_queue {
        struct device *q_dmadev;
        struct nvme_dev *dev;
-       char irqname[24];       /* nvme4294967295-65535\0 */
        spinlock_t q_lock;
        struct nvme_command *sq_cmds;
        struct nvme_command __iomem *sq_cmds_io;
        u16 qid;
        u8 cq_phase;
        u8 cqe_seen;
 +      u32 *dbbuf_sq_db;
 +      u32 *dbbuf_cq_db;
 +      u32 *dbbuf_sq_ei;
 +      u32 *dbbuf_cq_ei;
  };
  
  /*
@@@ -190,112 -170,6 +189,112 @@@ static inline void _nvme_check_size(voi
        BUILD_BUG_ON(sizeof(struct nvme_id_ns) != 4096);
        BUILD_BUG_ON(sizeof(struct nvme_lba_range_type) != 64);
        BUILD_BUG_ON(sizeof(struct nvme_smart_log) != 512);
 +      BUILD_BUG_ON(sizeof(struct nvme_dbbuf) != 64);
 +}
 +
 +static inline unsigned int nvme_dbbuf_size(u32 stride)
 +{
 +      return ((num_possible_cpus() + 1) * 8 * stride);
 +}
 +
 +static int nvme_dbbuf_dma_alloc(struct nvme_dev *dev)
 +{
 +      unsigned int mem_size = nvme_dbbuf_size(dev->db_stride);
 +
 +      if (dev->dbbuf_dbs)
 +              return 0;
 +
 +      dev->dbbuf_dbs = dma_alloc_coherent(dev->dev, mem_size,
 +                                          &dev->dbbuf_dbs_dma_addr,
 +                                          GFP_KERNEL);
 +      if (!dev->dbbuf_dbs)
 +              return -ENOMEM;
 +      dev->dbbuf_eis = dma_alloc_coherent(dev->dev, mem_size,
 +                                          &dev->dbbuf_eis_dma_addr,
 +                                          GFP_KERNEL);
 +      if (!dev->dbbuf_eis) {
 +              dma_free_coherent(dev->dev, mem_size,
 +                                dev->dbbuf_dbs, dev->dbbuf_dbs_dma_addr);
 +              dev->dbbuf_dbs = NULL;
 +              return -ENOMEM;
 +      }
 +
 +      return 0;
 +}
 +
 +static void nvme_dbbuf_dma_free(struct nvme_dev *dev)
 +{
 +      unsigned int mem_size = nvme_dbbuf_size(dev->db_stride);
 +
 +      if (dev->dbbuf_dbs) {
 +              dma_free_coherent(dev->dev, mem_size,
 +                                dev->dbbuf_dbs, dev->dbbuf_dbs_dma_addr);
 +              dev->dbbuf_dbs = NULL;
 +      }
 +      if (dev->dbbuf_eis) {
 +              dma_free_coherent(dev->dev, mem_size,
 +                                dev->dbbuf_eis, dev->dbbuf_eis_dma_addr);
 +              dev->dbbuf_eis = NULL;
 +      }
 +}
 +
 +static void nvme_dbbuf_init(struct nvme_dev *dev,
 +                          struct nvme_queue *nvmeq, int qid)
 +{
 +      if (!dev->dbbuf_dbs || !qid)
 +              return;
 +
 +      nvmeq->dbbuf_sq_db = &dev->dbbuf_dbs[sq_idx(qid, dev->db_stride)];
 +      nvmeq->dbbuf_cq_db = &dev->dbbuf_dbs[cq_idx(qid, dev->db_stride)];
 +      nvmeq->dbbuf_sq_ei = &dev->dbbuf_eis[sq_idx(qid, dev->db_stride)];
 +      nvmeq->dbbuf_cq_ei = &dev->dbbuf_eis[cq_idx(qid, dev->db_stride)];
 +}
 +
 +static void nvme_dbbuf_set(struct nvme_dev *dev)
 +{
 +      struct nvme_command c;
 +
 +      if (!dev->dbbuf_dbs)
 +              return;
 +
 +      memset(&c, 0, sizeof(c));
 +      c.dbbuf.opcode = nvme_admin_dbbuf;
 +      c.dbbuf.prp1 = cpu_to_le64(dev->dbbuf_dbs_dma_addr);
 +      c.dbbuf.prp2 = cpu_to_le64(dev->dbbuf_eis_dma_addr);
 +
 +      if (nvme_submit_sync_cmd(dev->ctrl.admin_q, &c, NULL, 0)) {
 +              dev_warn(dev->dev, "unable to set dbbuf\n");
 +              /* Free memory and continue on */
 +              nvme_dbbuf_dma_free(dev);
 +      }
 +}
 +
 +static inline int nvme_dbbuf_need_event(u16 event_idx, u16 new_idx, u16 old)
 +{
 +      return (u16)(new_idx - event_idx - 1) < (u16)(new_idx - old);
 +}
 +
 +/* Update dbbuf and return true if an MMIO is required */
 +static bool nvme_dbbuf_update_and_check_event(u16 value, u32 *dbbuf_db,
 +                                            volatile u32 *dbbuf_ei)
 +{
 +      if (dbbuf_db) {
 +              u16 old_value;
 +
 +              /*
 +               * Ensure that the queue is written before updating
 +               * the doorbell in memory
 +               */
 +              wmb();
 +
 +              old_value = *dbbuf_db;
 +              *dbbuf_db = value;
 +
 +              if (!nvme_dbbuf_need_event(*dbbuf_ei, value, old_value))
 +                      return false;
 +      }
 +
 +      return true;
  }
  
  /*
@@@ -329,11 -203,6 +328,6 @@@ static unsigned int nvme_cmd_size(struc
                nvme_iod_alloc_size(dev, NVME_INT_BYTES(dev), NVME_INT_PAGES);
  }
  
- static int nvmeq_irq(struct nvme_queue *nvmeq)
- {
-       return pci_irq_vector(to_pci_dev(nvmeq->dev->dev), nvmeq->cq_vector);
- }
  static int nvme_admin_init_hctx(struct blk_mq_hw_ctx *hctx, void *data,
                                unsigned int hctx_idx)
  {
@@@ -356,11 -225,11 +350,11 @@@ static void nvme_admin_exit_hctx(struc
        nvmeq->tags = NULL;
  }
  
 -static int nvme_admin_init_request(void *data, struct request *req,
 -                              unsigned int hctx_idx, unsigned int rq_idx,
 -                              unsigned int numa_node)
 +static int nvme_admin_init_request(struct blk_mq_tag_set *set,
 +              struct request *req, unsigned int hctx_idx,
 +              unsigned int numa_node)
  {
 -      struct nvme_dev *dev = data;
 +      struct nvme_dev *dev = set->driver_data;
        struct nvme_iod *iod = blk_mq_rq_to_pdu(req);
        struct nvme_queue *nvmeq = dev->queues[0];
  
@@@ -383,10 -252,11 +377,10 @@@ static int nvme_init_hctx(struct blk_mq
        return 0;
  }
  
 -static int nvme_init_request(void *data, struct request *req,
 -                              unsigned int hctx_idx, unsigned int rq_idx,
 -                              unsigned int numa_node)
 +static int nvme_init_request(struct blk_mq_tag_set *set, struct request *req,
 +              unsigned int hctx_idx, unsigned int numa_node)
  {
 -      struct nvme_dev *dev = data;
 +      struct nvme_dev *dev = set->driver_data;
        struct nvme_iod *iod = blk_mq_rq_to_pdu(req);
        struct nvme_queue *nvmeq = dev->queues[hctx_idx + 1];
  
@@@ -421,9 -291,7 +415,9 @@@ static void __nvme_submit_cmd(struct nv
  
        if (++tail == nvmeq->q_depth)
                tail = 0;
 -      writel(tail, nvmeq->q_db);
 +      if (nvme_dbbuf_update_and_check_event(tail, nvmeq->dbbuf_sq_db,
 +                                            nvmeq->dbbuf_sq_ei))
 +              writel(tail, nvmeq->q_db);
        nvmeq->sq_tail = tail;
  }
  
@@@ -452,6 -320,10 +446,6 @@@ static int nvme_init_iod(struct reques
        iod->nents = 0;
        iod->length = size;
  
 -      if (!(rq->rq_flags & RQF_DONTPREP)) {
 -              rq->retries = 0;
 -              rq->rq_flags |= RQF_DONTPREP;
 -      }
        return BLK_MQ_RQ_QUEUE_OK;
  }
  
@@@ -750,12 -622,34 +744,12 @@@ out_free_cmd
        return ret;
  }
  
 -static void nvme_complete_rq(struct request *req)
 +static void nvme_pci_complete_rq(struct request *req)
  {
        struct nvme_iod *iod = blk_mq_rq_to_pdu(req);
 -      struct nvme_dev *dev = iod->nvmeq->dev;
 -      int error = 0;
 -
 -      nvme_unmap_data(dev, req);
 -
 -      if (unlikely(req->errors)) {
 -              if (nvme_req_needs_retry(req, req->errors)) {
 -                      req->retries++;
 -                      nvme_requeue_req(req);
 -                      return;
 -              }
 -
 -              if (blk_rq_is_passthrough(req))
 -                      error = req->errors;
 -              else
 -                      error = nvme_error_status(req->errors);
 -      }
 -
 -      if (unlikely(iod->aborted)) {
 -              dev_warn(dev->ctrl.device,
 -                      "completing aborted command with status: %04x\n",
 -                      req->errors);
 -      }
  
 -      blk_mq_end_request(req, error);
 +      nvme_unmap_data(iod->nvmeq->dev, req);
 +      nvme_complete_rq(req);
  }
  
  /* We read the CQE phase first to check if the rest of the entry is valid */
@@@ -805,16 -699,15 +799,16 @@@ static void __nvme_process_cq(struct nv
                }
  
                req = blk_mq_tag_to_rq(*nvmeq->tags, cqe.command_id);
 -              nvme_req(req)->result = cqe.result;
 -              blk_mq_complete_request(req, le16_to_cpu(cqe.status) >> 1);
 +              nvme_end_request(req, cqe.status, cqe.result);
        }
  
        if (head == nvmeq->cq_head && phase == nvmeq->cq_phase)
                return;
  
        if (likely(nvmeq->cq_vector >= 0))
 -              writel(head, nvmeq->q_db + nvmeq->dev->db_stride);
 +              if (nvme_dbbuf_update_and_check_event(head, nvmeq->dbbuf_cq_db,
 +                                                    nvmeq->dbbuf_cq_ei))
 +                      writel(head, nvmeq->q_db + nvmeq->dev->db_stride);
        nvmeq->cq_head = head;
        nvmeq->cq_phase = phase;
  
@@@ -846,8 -739,10 +840,8 @@@ static irqreturn_t nvme_irq_check(int i
        return IRQ_NONE;
  }
  
 -static int nvme_poll(struct blk_mq_hw_ctx *hctx, unsigned int tag)
 +static int __nvme_poll(struct nvme_queue *nvmeq, unsigned int tag)
  {
 -      struct nvme_queue *nvmeq = hctx->driver_data;
 -
        if (nvme_cqe_valid(nvmeq, nvmeq->cq_head, nvmeq->cq_phase)) {
                spin_lock_irq(&nvmeq->q_lock);
                __nvme_process_cq(nvmeq, &tag);
        return 0;
  }
  
 +static int nvme_poll(struct blk_mq_hw_ctx *hctx, unsigned int tag)
 +{
 +      struct nvme_queue *nvmeq = hctx->driver_data;
 +
 +      return __nvme_poll(nvmeq, tag);
 +}
 +
  static void nvme_pci_submit_async_event(struct nvme_ctrl *ctrl, int aer_idx)
  {
        struct nvme_dev *dev = to_nvme_dev(ctrl);
@@@ -918,7 -806,7 +912,7 @@@ static int adapter_alloc_sq(struct nvme
                                                struct nvme_queue *nvmeq)
  {
        struct nvme_command c;
 -      int flags = NVME_QUEUE_PHYS_CONTIG | NVME_SQ_PRIO_MEDIUM;
 +      int flags = NVME_QUEUE_PHYS_CONTIG;
  
        /*
         * Note: we (ab)use the fact the the prp fields survive if no data
@@@ -949,9 -837,9 +943,9 @@@ static void abort_endio(struct request 
  {
        struct nvme_iod *iod = blk_mq_rq_to_pdu(req);
        struct nvme_queue *nvmeq = iod->nvmeq;
 -      u16 status = req->errors;
  
 -      dev_warn(nvmeq->dev->ctrl.device, "Abort status: 0x%x", status);
 +      dev_warn(nvmeq->dev->ctrl.device,
 +               "Abort status: 0x%x", nvme_req(req)->status);
        atomic_inc(&nvmeq->dev->ctrl.abort_limit);
        blk_mq_free_request(req);
  }
@@@ -964,16 -852,6 +958,16 @@@ static enum blk_eh_timer_return nvme_ti
        struct request *abort_req;
        struct nvme_command cmd;
  
 +      /*
 +       * Did we miss an interrupt?
 +       */
 +      if (__nvme_poll(nvmeq, req->tag)) {
 +              dev_warn(dev->ctrl.device,
 +                       "I/O %d QID %d timeout, completion polled\n",
 +                       req->tag, nvmeq->qid);
 +              return BLK_EH_HANDLED;
 +      }
 +
        /*
         * Shutdown immediately if controller times out while starting. The
         * reset work will see the pci device disabled when it gets the forced
                         "I/O %d QID %d timeout, disable controller\n",
                         req->tag, nvmeq->qid);
                nvme_dev_disable(dev, false);
 -              req->errors = NVME_SC_CANCELLED;
 +              nvme_req(req)->flags |= NVME_REQ_CANCELLED;
                return BLK_EH_HANDLED;
        }
  
                 * Mark the request as handled, since the inline shutdown
                 * forces all outstanding requests to complete.
                 */
 -              req->errors = NVME_SC_CANCELLED;
 +              nvme_req(req)->flags |= NVME_REQ_CANCELLED;
                return BLK_EH_HANDLED;
        }
  
@@@ -1078,7 -956,7 +1072,7 @@@ static int nvme_suspend_queue(struct nv
                spin_unlock_irq(&nvmeq->q_lock);
                return 1;
        }
-       vector = nvmeq_irq(nvmeq);
+       vector = nvmeq->cq_vector;
        nvmeq->dev->online_queues--;
        nvmeq->cq_vector = -1;
        spin_unlock_irq(&nvmeq->q_lock);
        if (!nvmeq->qid && nvmeq->dev->ctrl.admin_q)
                blk_mq_stop_hw_queues(nvmeq->dev->ctrl.admin_q);
  
-       free_irq(vector, nvmeq);
+       pci_free_irq(to_pci_dev(nvmeq->dev->dev), vector, nvmeq);
  
        return 0;
  }
@@@ -1171,8 -1049,6 +1165,6 @@@ static struct nvme_queue *nvme_alloc_qu
  
        nvmeq->q_dmadev = dev->dev;
        nvmeq->dev = dev;
-       snprintf(nvmeq->irqname, sizeof(nvmeq->irqname), "nvme%dq%d",
-                       dev->ctrl.instance, qid);
        spin_lock_init(&nvmeq->q_lock);
        nvmeq->cq_head = 0;
        nvmeq->cq_phase = 1;
  
  static int queue_request_irq(struct nvme_queue *nvmeq)
  {
-       if (use_threaded_interrupts)
-               return request_threaded_irq(nvmeq_irq(nvmeq), nvme_irq_check,
-                               nvme_irq, IRQF_SHARED, nvmeq->irqname, nvmeq);
-       else
-               return request_irq(nvmeq_irq(nvmeq), nvme_irq, IRQF_SHARED,
-                               nvmeq->irqname, nvmeq);
+       struct pci_dev *pdev = to_pci_dev(nvmeq->dev->dev);
+       int nr = nvmeq->dev->ctrl.instance;
+       if (use_threaded_interrupts) {
+               return pci_request_irq(pdev, nvmeq->cq_vector, nvme_irq_check,
+                               nvme_irq, nvmeq, "nvme%dq%d", nr, nvmeq->qid);
+       } else {
+               return pci_request_irq(pdev, nvmeq->cq_vector, nvme_irq,
+                               NULL, nvmeq, "nvme%dq%d", nr, nvmeq->qid);
+       }
  }
  
  static void nvme_init_queue(struct nvme_queue *nvmeq, u16 qid)
        nvmeq->cq_phase = 1;
        nvmeq->q_db = &dev->dbs[qid * 2 * dev->db_stride];
        memset((void *)nvmeq->cqes, 0, CQ_SIZE(nvmeq->q_depth));
 +      nvme_dbbuf_init(dev, nvmeq, qid);
        dev->online_queues++;
        spin_unlock_irq(&nvmeq->q_lock);
  }
@@@ -1246,18 -1125,18 +1242,18 @@@ static int nvme_create_queue(struct nvm
        return result;
  }
  
 -static struct blk_mq_ops nvme_mq_admin_ops = {
 +static const struct blk_mq_ops nvme_mq_admin_ops = {
        .queue_rq       = nvme_queue_rq,
 -      .complete       = nvme_complete_rq,
 +      .complete       = nvme_pci_complete_rq,
        .init_hctx      = nvme_admin_init_hctx,
        .exit_hctx      = nvme_admin_exit_hctx,
        .init_request   = nvme_admin_init_request,
        .timeout        = nvme_timeout,
  };
  
 -static struct blk_mq_ops nvme_mq_ops = {
 +static const struct blk_mq_ops nvme_mq_ops = {
        .queue_rq       = nvme_queue_rq,
 -      .complete       = nvme_complete_rq,
 +      .complete       = nvme_pci_complete_rq,
        .init_hctx      = nvme_init_hctx,
        .init_request   = nvme_init_request,
        .map_queues     = nvme_pci_map_queues,
@@@ -1557,7 -1436,7 +1553,7 @@@ static int nvme_setup_io_queues(struct 
        }
  
        /* Deregister the admin queue's interrupt */
-       free_irq(pci_irq_vector(pdev, 0), adminq);
+       pci_free_irq(pdev, 0, adminq);
  
        /*
         * If we enable msix early due to not intx, disable it again before
@@@ -1686,8 -1565,6 +1682,8 @@@ static int nvme_dev_add(struct nvme_de
                if (blk_mq_alloc_tag_set(&dev->tagset))
                        return 0;
                dev->ctrl.tagset = &dev->tagset;
 +
 +              nvme_dbbuf_set(dev);
        } else {
                blk_mq_update_nr_hw_queues(&dev->tagset, dev->online_queues - 1);
  
@@@ -1874,7 -1751,6 +1870,7 @@@ static void nvme_pci_free_ctrl(struct n
  {
        struct nvme_dev *dev = to_nvme_dev(ctrl);
  
 +      nvme_dbbuf_dma_free(dev);
        put_device(dev->dev);
        if (dev->tagset.tags)
                blk_mq_free_tag_set(&dev->tagset);
@@@ -1942,13 -1818,6 +1938,13 @@@ static void nvme_reset_work(struct work
                dev->ctrl.opal_dev = NULL;
        }
  
 +      if (dev->ctrl.oacs & NVME_CTRL_OACS_DBBUF_SUPP) {
 +              result = nvme_dbbuf_dma_alloc(dev);
 +              if (result)
 +                      dev_warn(dev->dev,
 +                               "unable to allocate dma for dbbuf\n");
 +      }
 +
        result = nvme_setup_io_queues(dev);
        if (result)
                goto out;
@@@ -2070,31 -1939,10 +2066,31 @@@ static int nvme_dev_map(struct nvme_de
        return -ENODEV;
  }
  
 +static unsigned long check_dell_samsung_bug(struct pci_dev *pdev)
 +{
 +      if (pdev->vendor == 0x144d && pdev->device == 0xa802) {
 +              /*
 +               * Several Samsung devices seem to drop off the PCIe bus
 +               * randomly when APST is on and uses the deepest sleep state.
 +               * This has been observed on a Samsung "SM951 NVMe SAMSUNG
 +               * 256GB", a "PM951 NVMe SAMSUNG 512GB", and a "Samsung SSD
 +               * 950 PRO 256GB", but it seems to be restricted to two Dell
 +               * laptops.
 +               */
 +              if (dmi_match(DMI_SYS_VENDOR, "Dell Inc.") &&
 +                  (dmi_match(DMI_PRODUCT_NAME, "XPS 15 9550") ||
 +                   dmi_match(DMI_PRODUCT_NAME, "Precision 5510")))
 +                      return NVME_QUIRK_NO_DEEPEST_PS;
 +      }
 +
 +      return 0;
 +}
 +
  static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
  {
        int node, result = -ENOMEM;
        struct nvme_dev *dev;
 +      unsigned long quirks = id->driver_data;
  
        node = dev_to_node(&pdev->dev);
        if (node == NUMA_NO_NODE)
        if (result)
                goto put_pci;
  
 +      quirks |= check_dell_samsung_bug(pdev);
 +
        result = nvme_init_ctrl(&dev->ctrl, &pdev->dev, &nvme_pci_ctrl_ops,
 -                      id->driver_data);
 +                      quirks);
        if (result)
                goto release_pools;
  
@@@ -2285,13 -2131,13 +2281,13 @@@ static const struct pci_error_handlers 
  static const struct pci_device_id nvme_id_table[] = {
        { PCI_VDEVICE(INTEL, 0x0953),
                .driver_data = NVME_QUIRK_STRIPE_SIZE |
 -                              NVME_QUIRK_DISCARD_ZEROES, },
 +                              NVME_QUIRK_DEALLOCATE_ZEROES, },
        { PCI_VDEVICE(INTEL, 0x0a53),
                .driver_data = NVME_QUIRK_STRIPE_SIZE |
 -                              NVME_QUIRK_DISCARD_ZEROES, },
 +                              NVME_QUIRK_DEALLOCATE_ZEROES, },
        { PCI_VDEVICE(INTEL, 0x0a54),
                .driver_data = NVME_QUIRK_STRIPE_SIZE |
 -                              NVME_QUIRK_DISCARD_ZEROES, },
 +                              NVME_QUIRK_DEALLOCATE_ZEROES, },
        { PCI_VDEVICE(INTEL, 0x5845),   /* Qemu emulated controller */
                .driver_data = NVME_QUIRK_IDENTIFY_CNS, },
        { PCI_DEVICE(0x1c58, 0x0003),   /* HGST adapter */
index cf9d6a9d9fd4fc17afd19d0e659f5e7cff0a3ca8,18af8057cdc44eb94ef2c7a5af3e3ac85527dc24..e51acee0ddf3b8598bf2044f50e94fc50b1fd513
@@@ -99,7 -99,7 +99,7 @@@ static int hisi_pcie_init(struct pci_co
                return -ENOMEM;
        }
  
-       reg_base = devm_ioremap(dev, res->start, resource_size(res));
+       reg_base = devm_pci_remap_cfgspace(dev, res->start, resource_size(res));
        if (!reg_base)
                return -ENOMEM;
  
@@@ -296,10 -296,9 +296,9 @@@ static int hisi_pcie_probe(struct platf
        }
  
        reg = platform_get_resource_byname(pdev, IORESOURCE_MEM, "rc_dbi");
-       pci->dbi_base = devm_ioremap_resource(dev, reg);
+       pci->dbi_base = devm_pci_remap_cfg_resource(dev, reg);
        if (IS_ERR(pci->dbi_base))
                return PTR_ERR(pci->dbi_base);
        platform_set_drvdata(pdev, hisi_pcie);
  
        ret = hisi_add_pcie_port(hisi_pcie, pdev);
@@@ -334,6 -333,7 +333,7 @@@ static struct platform_driver hisi_pcie
        .driver = {
                   .name = "hisi-pcie",
                   .of_match_table = hisi_pcie_of_match,
+                  .suppress_bind_attrs = true,
        },
  };
  builtin_platform_driver(hisi_pcie_driver);
@@@ -360,7 -360,7 +360,7 @@@ static int hisi_pcie_platform_init(stru
                return -EINVAL;
        }
  
-       reg_base = devm_ioremap(dev, res->start, resource_size(res));
+       reg_base = devm_pci_remap_cfgspace(dev, res->start, resource_size(res));
        if (!reg_base)
                return -ENOMEM;
  
@@@ -380,13 -380,9 +380,13 @@@ struct pci_ecam_ops hisi_pcie_platform_
  
  static const struct of_device_id hisi_pcie_almost_ecam_of_match[] = {
        {
 -              .compatible = "hisilicon,pcie-almost-ecam",
 +              .compatible =  "hisilicon,hip06-pcie-ecam",
                .data       = (void *) &hisi_pcie_platform_ops,
        },
 +      {
 +              .compatible =  "hisilicon,hip07-pcie-ecam",
 +              .data       = (void *) &hisi_pcie_platform_ops,
 +      },
        {},
  };
  
@@@ -395,6 -391,7 +395,7 @@@ static struct platform_driver hisi_pcie
        .driver = {
                   .name = "hisi-pcie-almost-ecam",
                   .of_match_table = hisi_pcie_almost_ecam_of_match,
+                  .suppress_bind_attrs = true,
        },
  };
  builtin_platform_driver(hisi_pcie_almost_ecam_driver);
diff --combined drivers/pci/irq.c
index f9f2a0324ecc31097e4e0785933f92da37feba9f,f1e46d255c5fb5ac5332610bf4fb668880876ba1..83d30953ce195d46ad4e5f11f740084593b23a88
@@@ -1,7 -1,8 +1,8 @@@
  /*
-  * PCI IRQ failure handing code
+  * PCI IRQ handling code
   *
   * Copyright (c) 2008 James Bottomley <James.Bottomley@HansenPartnership.com>
+  * Copyright (C) 2017 Christoph Hellwig.
   */
  
  #include <linux/acpi.h>
@@@ -31,7 -32,7 +32,7 @@@ static void pci_note_irq_problem(struc
   * driver).
   *
   * Returns:
 - *  a suggestion for fixing it (although the driver is not required to
 + * a suggestion for fixing it (although the driver is not required to
   * act on this).
   */
  enum pci_lost_interrupt_reason pci_lost_interrupt(struct pci_dev *pdev)
        return PCI_LOST_IRQ_NO_INFORMATION;
  }
  EXPORT_SYMBOL(pci_lost_interrupt);
+ /**
+  * pci_request_irq - allocate an interrupt line for a PCI device
+  * @dev:      PCI device to operate on
+  * @nr:               device-relative interrupt vector index (0-based).
+  * @handler:  Function to be called when the IRQ occurs.
+  *            Primary handler for threaded interrupts.
+  *            If NULL and thread_fn != NULL the default primary handler is
+  *            installed.
+  * @thread_fn:        Function called from the IRQ handler thread
+  *            If NULL, no IRQ thread is created
+  * @dev_id:   Cookie passed back to the handler function
+  * @fmt:      Printf-like format string naming the handler
+  *
+  * This call allocates interrupt resources and enables the interrupt line and
+  * IRQ handling. From the point this call is made @handler and @thread_fn may
+  * be invoked.  All interrupts requested using this function might be shared.
+  *
+  * @dev_id must not be NULL and must be globally unique.
+  */
+ int pci_request_irq(struct pci_dev *dev, unsigned int nr, irq_handler_t handler,
+               irq_handler_t thread_fn, void *dev_id, const char *fmt, ...)
+ {
+       va_list ap;
+       int ret;
+       char *devname;
+       va_start(ap, fmt);
+       devname = kvasprintf(GFP_KERNEL, fmt, ap);
+       va_end(ap);
+       ret = request_threaded_irq(pci_irq_vector(dev, nr), handler, thread_fn,
+                       IRQF_SHARED, devname, dev_id);
+       if (ret)
+               kfree(devname);
+       return ret;
+ }
+ EXPORT_SYMBOL(pci_request_irq);
+ /**
+  * pci_free_irq - free an interrupt allocated with pci_request_irq
+  * @dev:      PCI device to operate on
+  * @nr:               device-relative interrupt vector index (0-based).
+  * @dev_id:   Device identity to free
+  *
+  * Remove an interrupt handler. The handler is removed and if the interrupt
+  * line is no longer in use by any driver it is disabled.  The caller must
+  * ensure the interrupt is disabled on the device before calling this function.
+  * The function does not return until any executing interrupts for this IRQ
+  * have completed.
+  *
+  * This function must not be called from interrupt context.
+  */
+ void pci_free_irq(struct pci_dev *dev, unsigned int nr, void *dev_id)
+ {
+       kfree(free_irq(pci_irq_vector(dev, nr), dev_id));
+ }
+ EXPORT_SYMBOL(pci_free_irq);
diff --combined drivers/pci/msi.c
index 0042c365b29b9b94c791ca99d00dc7263354bb71,6b5eaf500a2462a65d381c8b0b6ea358820562f4..ba44fdfda66bb5caba6c74d9ad056b34a2d01068
@@@ -298,7 -298,7 +298,7 @@@ void __pci_write_msi_msg(struct msi_des
  {
        struct pci_dev *dev = msi_desc_to_pci_dev(entry);
  
-       if (dev->current_state != PCI_D0) {
+       if (dev->current_state != PCI_D0 || pci_dev_is_disconnected(dev)) {
                /* Don't touch the hardware now */
        } else if (entry->msi_attrib.is_msix) {
                void __iomem *base = pci_msix_desc_addr(entry);
@@@ -541,7 -541,8 +541,8 @@@ msi_setup_entry(struct pci_dev *dev, in
        if (affd) {
                masks = irq_create_affinity_masks(nvec, affd);
                if (!masks)
-                       pr_err("Unable to allocate affinity masks, ignoring\n");
+                       dev_err(&dev->dev, "can't allocate MSI affinity masks for %d vectors\n",
+                               nvec);
        }
  
        /* MSI Entry Initialization */
@@@ -681,7 -682,8 +682,8 @@@ static int msix_setup_entries(struct pc
        if (affd) {
                masks = irq_create_affinity_masks(nvec, affd);
                if (!masks)
-                       pr_err("Unable to allocate affinity masks, ignoring\n");
+                       dev_err(&dev->dev, "can't allocate MSI-X affinity masks for %d vectors\n",
+                               nvec);
        }
  
        for (i = 0, curmsk = masks; i < nvec; i++) {
@@@ -882,7 -884,7 +884,7 @@@ int pci_msi_vec_count(struct pci_dev *d
  }
  EXPORT_SYMBOL(pci_msi_vec_count);
  
- void pci_msi_shutdown(struct pci_dev *dev)
static void pci_msi_shutdown(struct pci_dev *dev)
  {
        struct msi_desc *desc;
        u32 mask;
@@@ -973,13 -975,39 +975,18 @@@ static int __pci_enable_msix(struct pci
        return msix_capability_init(dev, entries, nvec, affd);
  }
  
- void pci_msix_shutdown(struct pci_dev *dev)
 -/**
 - * pci_enable_msix - configure device's MSI-X capability structure
 - * @dev: pointer to the pci_dev data structure of MSI-X device function
 - * @entries: pointer to an array of MSI-X entries (optional)
 - * @nvec: number of MSI-X irqs requested for allocation by device driver
 - *
 - * Setup the MSI-X capability structure of device function with the number
 - * of requested irqs upon its software driver call to request for
 - * MSI-X mode enabled on its hardware device function. A return of zero
 - * indicates the successful configuration of MSI-X capability structure
 - * with new allocated MSI-X irqs. A return of < 0 indicates a failure.
 - * Or a return of > 0 indicates that driver request is exceeding the number
 - * of irqs or MSI-X vectors available. Driver should use the returned value to
 - * re-send its request.
 - **/
 -int pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries, int nvec)
 -{
 -      return __pci_enable_msix(dev, entries, nvec, NULL);
 -}
 -EXPORT_SYMBOL(pci_enable_msix);
 -
+ static void pci_msix_shutdown(struct pci_dev *dev)
  {
        struct msi_desc *entry;
  
        if (!pci_msi_enable || !dev || !dev->msix_enabled)
                return;
  
+       if (pci_dev_is_disconnected(dev)) {
+               dev->msix_enabled = 0;
+               return;
+       }
        /* Return the device with MSI-X masked as initial states */
        for_each_pci_msi_entry(entry, dev) {
                /* Keep cached states to be restored */
diff --combined drivers/pci/pci.h
index 4dbf9f96ae5ba31d761b30ee43c11d2f053140fe,586e63f5501366b288b9df8207b3043751ec143b..f8113e5b98129026e6c100b7b8f803a74507a442
@@@ -3,8 -3,6 +3,8 @@@
  
  #define PCI_FIND_CAP_TTL      48
  
 +#define PCI_VSEC_ID_INTEL_TBT 0x1234  /* Thunderbolt */
 +
  extern const unsigned char pcie_link_speed[];
  
  bool pcie_cap_has_lnkctl(const struct pci_dev *dev);
@@@ -23,14 -21,14 +23,14 @@@ void pci_create_firmware_label_files(st
  void pci_remove_firmware_label_files(struct pci_dev *pdev);
  #endif
  void pci_cleanup_rom(struct pci_dev *dev);
- #ifdef HAVE_PCI_MMAP
  enum pci_mmap_api {
        PCI_MMAP_SYSFS, /* mmap on /sys/bus/pci/devices/<BDF>/resource<N> */
        PCI_MMAP_PROCFS /* mmap on /proc/bus/pci/<BDF> */
  };
  int pci_mmap_fits(struct pci_dev *pdev, int resno, struct vm_area_struct *vmai,
                  enum pci_mmap_api mmap_api);
- #endif
  int pci_probe_reset_function(struct pci_dev *dev);
  
  /**
@@@ -274,8 -272,23 +274,23 @@@ struct pci_sriov 
        struct pci_dev *self;   /* this PF */
        struct mutex lock;      /* lock for setting sriov_numvfs in sysfs */
        resource_size_t barsz[PCI_SRIOV_NUM_BARS];      /* VF BAR size */
+       bool drivers_autoprobe; /* auto probing of VFs by driver */
  };
  
+ /* pci_dev priv_flags */
+ #define PCI_DEV_DISCONNECTED 0
+ static inline int pci_dev_set_disconnected(struct pci_dev *dev, void *unused)
+ {
+       set_bit(PCI_DEV_DISCONNECTED, &dev->priv_flags);
+       return 0;
+ }
+ static inline bool pci_dev_is_disconnected(const struct pci_dev *dev)
+ {
+       return test_bit(PCI_DEV_DISCONNECTED, &dev->priv_flags);
+ }
  #ifdef CONFIG_PCI_ATS
  void pci_restore_ats_state(struct pci_dev *dev);
  #else
diff --combined drivers/pci/probe.c
index 90592d424e9b67458ad740ddb3b09d50f5ec30ff,5548044afb5b68e0bb665672f384f862cb344606..01eb8038fceb2b5455c21d9d33849592d4db670d
@@@ -175,7 -175,7 +175,7 @@@ static inline unsigned long decode_bar(
  int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
                    struct resource *res, unsigned int pos)
  {
-       u32 l, sz, mask;
+       u32 l = 0, sz = 0, mask;
        u64 l64, sz64, mask64;
        u16 orig_cmd;
        struct pci_bus_region region, inverted_region;
                        res->flags |= IORESOURCE_ROM_ENABLE;
                l64 = l & PCI_ROM_ADDRESS_MASK;
                sz64 = sz & PCI_ROM_ADDRESS_MASK;
-               mask64 = (u32)PCI_ROM_ADDRESS_MASK;
+               mask64 = PCI_ROM_ADDRESS_MASK;
        }
  
        if (res->flags & IORESOURCE_MEM_64) {
@@@ -1208,24 -1208,6 +1208,24 @@@ void set_pcie_hotplug_bridge(struct pci
                pdev->is_hotplug_bridge = 1;
  }
  
 +static void set_pcie_thunderbolt(struct pci_dev *dev)
 +{
 +      int vsec = 0;
 +      u32 header;
 +
 +      while ((vsec = pci_find_next_ext_capability(dev, vsec,
 +                                                  PCI_EXT_CAP_ID_VNDR))) {
 +              pci_read_config_dword(dev, vsec + PCI_VNDR_HEADER, &header);
 +
 +              /* Is the device part of a Thunderbolt controller? */
 +              if (dev->vendor == PCI_VENDOR_ID_INTEL &&
 +                  PCI_VNDR_HEADER_ID(header) == PCI_VSEC_ID_INTEL_TBT) {
 +                      dev->is_thunderbolt = 1;
 +                      return;
 +              }
 +      }
 +}
 +
  /**
   * pci_ext_cfg_is_aliased - is ext config space just an alias of std config?
   * @dev: PCI device
@@@ -1378,9 -1360,6 +1378,9 @@@ int pci_setup_device(struct pci_dev *de
        /* need to have dev->class ready */
        dev->cfg_size = pci_cfg_space_size(dev);
  
 +      /* need to have dev->cfg_size ready */
 +      set_pcie_thunderbolt(dev);
 +
        /* "Unknown power state" */
        dev->current_state = PCI_UNKNOWN;
  
diff --combined include/linux/pci.h
index f27be8432e82b3a76c1fa58e30321cd48a28b91c,88185ffcbf47c18756aba77915066d3413fd10bd..33c2b0b77429d09aaa31cb9735458db5762e08a7
@@@ -28,6 -28,7 +28,7 @@@
  #include <linux/kobject.h>
  #include <linux/atomic.h>
  #include <linux/device.h>
+ #include <linux/interrupt.h>
  #include <linux/io.h>
  #include <linux/resource_ext.h>
  #include <uapi/linux/pci.h>
@@@ -178,6 -179,10 +179,10 @@@ enum pci_dev_flags 
        PCI_DEV_FLAGS_NO_PM_RESET = (__force pci_dev_flags_t) (1 << 7),
        /* Get VPD from function 0 VPD */
        PCI_DEV_FLAGS_VPD_REF_F0 = (__force pci_dev_flags_t) (1 << 8),
+       /* a non-root bridge where translation occurs, stop alias search here */
+       PCI_DEV_FLAGS_BRIDGE_XLATE_ROOT = (__force pci_dev_flags_t) (1 << 9),
+       /* Do not use FLR even if device advertises PCI_AF_CAP */
+       PCI_DEV_FLAGS_NO_FLR_RESET = (__force pci_dev_flags_t) (1 << 10),
  };
  
  enum pci_irq_reroute_variant {
@@@ -358,7 -363,6 +363,7 @@@ struct pci_dev 
        unsigned int    is_virtfn:1;
        unsigned int    reset_fn:1;
        unsigned int    is_hotplug_bridge:1;
 +      unsigned int    is_thunderbolt:1; /* Thunderbolt controller */
        unsigned int    __aer_firmware_first_valid:1;
        unsigned int    __aer_firmware_first:1;
        unsigned int    broken_intx_masking:1;
        phys_addr_t rom; /* Physical address of ROM if it's not from the BAR */
        size_t romlen; /* Length of ROM if it's not from the BAR */
        char *driver_override; /* Driver name to force a match */
+       unsigned long priv_flags; /* Private flags for the pci driver */
  };
  
  static inline struct pci_dev *pci_physfn(struct pci_dev *dev)
@@@ -941,32 -947,12 +948,12 @@@ int pci_generic_config_write32(struct p
  
  struct pci_ops *pci_bus_set_ops(struct pci_bus *bus, struct pci_ops *ops);
  
- static inline int pci_read_config_byte(const struct pci_dev *dev, int where, u8 *val)
- {
-       return pci_bus_read_config_byte(dev->bus, dev->devfn, where, val);
- }
- static inline int pci_read_config_word(const struct pci_dev *dev, int where, u16 *val)
- {
-       return pci_bus_read_config_word(dev->bus, dev->devfn, where, val);
- }
- static inline int pci_read_config_dword(const struct pci_dev *dev, int where,
-                                       u32 *val)
- {
-       return pci_bus_read_config_dword(dev->bus, dev->devfn, where, val);
- }
- static inline int pci_write_config_byte(const struct pci_dev *dev, int where, u8 val)
- {
-       return pci_bus_write_config_byte(dev->bus, dev->devfn, where, val);
- }
- static inline int pci_write_config_word(const struct pci_dev *dev, int where, u16 val)
- {
-       return pci_bus_write_config_word(dev->bus, dev->devfn, where, val);
- }
- static inline int pci_write_config_dword(const struct pci_dev *dev, int where,
-                                        u32 val)
- {
-       return pci_bus_write_config_dword(dev->bus, dev->devfn, where, val);
- }
+ int pci_read_config_byte(const struct pci_dev *dev, int where, u8 *val);
+ int pci_read_config_word(const struct pci_dev *dev, int where, u16 *val);
+ int pci_read_config_dword(const struct pci_dev *dev, int where, u32 *val);
+ int pci_write_config_byte(const struct pci_dev *dev, int where, u8 val);
+ int pci_write_config_word(const struct pci_dev *dev, int where, u16 val);
+ int pci_write_config_dword(const struct pci_dev *dev, int where, u32 val);
  
  int pcie_capability_read_word(struct pci_dev *dev, int pos, u16 *val);
  int pcie_capability_read_dword(struct pci_dev *dev, int pos, u32 *val);
@@@ -1053,6 -1039,7 +1040,7 @@@ int pcie_get_mps(struct pci_dev *dev)
  int pcie_set_mps(struct pci_dev *dev, int mps);
  int pcie_get_minimum_link(struct pci_dev *dev, enum pci_bus_speed *speed,
                          enum pcie_link_width *width);
+ void pcie_flr(struct pci_dev *dev);
  int __pci_reset_function(struct pci_dev *dev);
  int __pci_reset_function_locked(struct pci_dev *dev);
  int pci_reset_function(struct pci_dev *dev);
@@@ -1073,6 -1060,11 +1061,11 @@@ int pci_select_bars(struct pci_dev *dev
  bool pci_device_is_present(struct pci_dev *pdev);
  void pci_ignore_hotplug(struct pci_dev *dev);
  
+ int __printf(6, 7) pci_request_irq(struct pci_dev *dev, unsigned int nr,
+               irq_handler_t handler, irq_handler_t thread_fn, void *dev_id,
+               const char *fmt, ...);
+ void pci_free_irq(struct pci_dev *dev, unsigned int nr, void *dev_id);
  /* ROM control related routines */
  int pci_enable_rom(struct pci_dev *pdev);
  void pci_disable_rom(struct pci_dev *pdev);
@@@ -1200,6 -1192,11 +1193,11 @@@ unsigned long pci_address_to_pio(phys_a
  phys_addr_t pci_pio_to_address(unsigned long pio);
  int pci_remap_iospace(const struct resource *res, phys_addr_t phys_addr);
  void pci_unmap_iospace(struct resource *res);
+ void __iomem *devm_pci_remap_cfgspace(struct device *dev,
+                                     resource_size_t offset,
+                                     resource_size_t size);
+ void __iomem *devm_pci_remap_cfg_resource(struct device *dev,
+                                         struct resource *res);
  
  static inline pci_bus_addr_t pci_bus_address(struct pci_dev *pdev, int bar)
  {
@@@ -1298,10 -1295,9 +1296,8 @@@ struct msix_entry 
  
  #ifdef CONFIG_PCI_MSI
  int pci_msi_vec_count(struct pci_dev *dev);
- void pci_msi_shutdown(struct pci_dev *dev);
  void pci_disable_msi(struct pci_dev *dev);
  int pci_msix_vec_count(struct pci_dev *dev);
- void pci_msix_shutdown(struct pci_dev *dev);
 -int pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries, int nvec);
  void pci_disable_msix(struct pci_dev *dev);
  void pci_restore_msi_state(struct pci_dev *dev);
  int pci_msi_enabled(void);
@@@ -1327,10 -1323,11 +1323,8 @@@ int pci_irq_get_node(struct pci_dev *pd
  
  #else
  static inline int pci_msi_vec_count(struct pci_dev *dev) { return -ENOSYS; }
- static inline void pci_msi_shutdown(struct pci_dev *dev) { }
  static inline void pci_disable_msi(struct pci_dev *dev) { }
  static inline int pci_msix_vec_count(struct pci_dev *dev) { return -ENOSYS; }
- static inline void pci_msix_shutdown(struct pci_dev *dev) { }
 -static inline int pci_enable_msix(struct pci_dev *dev,
 -                                struct msix_entry *entries, int nvec)
 -{ return -ENOSYS; }
  static inline void pci_disable_msix(struct pci_dev *dev) { }
  static inline void pci_restore_msi_state(struct pci_dev *dev) { }
  static inline int pci_msi_enabled(void) { return 0; }
@@@ -1623,6 -1620,36 +1617,36 @@@ static inline int pci_get_new_domain_nr
  
  #include <asm/pci.h>
  
+ /* These two functions provide almost identical functionality. Depennding
+  * on the architecture, one will be implemented as a wrapper around the
+  * other (in drivers/pci/mmap.c).
+  *
+  * pci_mmap_resource_range() maps a specific BAR, and vm->vm_pgoff
+  * is expected to be an offset within that region.
+  *
+  * pci_mmap_page_range() is the legacy architecture-specific interface,
+  * which accepts a "user visible" resource address converted by
+  * pci_resource_to_user(), as used in the legacy mmap() interface in
+  * /proc/bus/pci/.
+  */
+ int pci_mmap_resource_range(struct pci_dev *dev, int bar,
+                           struct vm_area_struct *vma,
+                           enum pci_mmap_state mmap_state, int write_combine);
+ int pci_mmap_page_range(struct pci_dev *pdev, int bar,
+                       struct vm_area_struct *vma,
+                       enum pci_mmap_state mmap_state, int write_combine);
+ #ifndef arch_can_pci_mmap_wc
+ #define arch_can_pci_mmap_wc()                0
+ #endif
+ #ifndef arch_can_pci_mmap_io
+ #define arch_can_pci_mmap_io()                0
+ #define pci_iobar_pfn(pdev, bar, vma) (-EINVAL)
+ #else
+ int pci_iobar_pfn(struct pci_dev *pdev, int bar, struct vm_area_struct *vma);
+ #endif
  #ifndef pci_root_bus_fwnode
  #define pci_root_bus_fwnode(bus)      NULL
  #endif
@@@ -2157,28 -2184,6 +2181,28 @@@ static inline bool pci_ari_enabled(stru
        return bus->self && bus->self->ari_enabled;
  }
  
 +/**
 + * pci_is_thunderbolt_attached - whether device is on a Thunderbolt daisy chain
 + * @pdev: PCI device to check
 + *
 + * Walk upwards from @pdev and check for each encountered bridge if it's part
 + * of a Thunderbolt controller.  Reaching the host bridge means @pdev is not
 + * Thunderbolt-attached.  (But rather soldered to the mainboard usually.)
 + */
 +static inline bool pci_is_thunderbolt_attached(struct pci_dev *pdev)
 +{
 +      struct pci_dev *parent = pdev;
 +
 +      if (pdev->is_thunderbolt)
 +              return true;
 +
 +      while ((parent = pci_upstream_bridge(parent)))
 +              if (parent->is_thunderbolt)
 +                      return true;
 +
 +      return false;
 +}
 +
  /* provide the legacy pci_dma_* API */
  #include <linux/pci-dma-compat.h>
  
index 6b0e2758585f83b186a253c9f7b7ca492754c6d0,baee6db082870f59132927640eee6f07082eddb7..662c592b74ddac954f2db1ed03f3328eead9fb4e
@@@ -333,6 -333,7 +333,7 @@@ header-y += parport.
  header-y += patchkey.h
  header-y += pci.h
  header-y += pci_regs.h
+ header-y += pcitest.h
  header-y += perf_event.h
  header-y += personality.h
  header-y += pfkeyv2.h
@@@ -445,7 -446,6 +446,7 @@@ header-y += unistd.
  header-y += unix_diag.h
  header-y += usbdevice_fs.h
  header-y += usbip.h
 +header-y += userio.h
  header-y += utime.h
  header-y += utsname.h
  header-y += uuid.h
@@@ -477,7 -477,6 +478,7 @@@ header-y += virtio_types.
  header-y += virtio_vsock.h
  header-y += virtio_crypto.h
  header-y += vm_sockets.h
 +header-y += vsockmon.h
  header-y += vt.h
  header-y += vtpm_proxy.h
  header-y += wait.h
index 18a26c16bd808204c5155af45ba5686a1d8795dd,fff521c9458ca678f953dff0e41f5edc0fa32f3a..d56bb005100949516c0ab59e964bf1c135899bb2
  #define PCI_SUBSYSTEM_ID      0x2e
  #define PCI_ROM_ADDRESS               0x30    /* Bits 31..11 are address, 10..1 reserved */
  #define  PCI_ROM_ADDRESS_ENABLE       0x01
- #define PCI_ROM_ADDRESS_MASK  (~0x7ffUL)
+ #define PCI_ROM_ADDRESS_MASK  (~0x7ffU)
  
  #define PCI_CAPABILITY_LIST   0x34    /* Offset of first capability list entry */
  
  #define  PCI_EXP_DEVCTL2_COMP_TIMEOUT 0x000f  /* Completion Timeout Value */
  #define  PCI_EXP_DEVCTL2_ARI          0x0020  /* Alternative Routing-ID */
  #define PCI_EXP_DEVCTL2_ATOMIC_REQ    0x0040  /* Set Atomic requests */
 +#define PCI_EXP_DEVCTL2_ATOMIC_EGRESS_BLOCK 0x0080 /* Block atomic egress */
  #define  PCI_EXP_DEVCTL2_IDO_REQ_EN   0x0100  /* Allow IDO for requests */
  #define  PCI_EXP_DEVCTL2_IDO_CMP_EN   0x0200  /* Allow IDO for completions */
  #define  PCI_EXP_DEVCTL2_LTR_EN               0x0400  /* Enable LTR mechanism */
diff --combined kernel/irq/manage.c
index ae1c90f203814e8f42819eb5b1aae70eeb834a8a,e688e7e067727bd509cf662c6c249cf885010f34..070be980c37a57d91f86099d2be1b81db80176bc
@@@ -852,7 -852,7 +852,7 @@@ irq_thread_check_affinity(struct irq_de
         * This code is triggered unconditionally. Check the affinity
         * mask pointer. For CPU_MASK_OFFSTACK=n this is optimized out.
         */
 -      if (desc->irq_common_data.affinity)
 +      if (cpumask_available(desc->irq_common_data.affinity))
                cpumask_copy(mask, desc->irq_common_data.affinity);
        else
                valid = false;
@@@ -1212,10 -1212,8 +1212,10 @@@ __setup_irq(unsigned int irq, struct ir
                 * set the trigger type must match. Also all must
                 * agree on ONESHOT.
                 */
 +              unsigned int oldtype = irqd_get_trigger_type(&desc->irq_data);
 +
                if (!((old->flags & new->flags) & IRQF_SHARED) ||
 -                  ((old->flags ^ new->flags) & IRQF_TRIGGER_MASK) ||
 +                  (oldtype != (new->flags & IRQF_TRIGGER_MASK)) ||
                    ((old->flags ^ new->flags) & IRQF_ONESHOT))
                        goto mismatch;
  
@@@ -1559,7 -1557,7 +1559,7 @@@ void remove_irq(unsigned int irq, struc
        struct irq_desc *desc = irq_to_desc(irq);
  
        if (desc && !WARN_ON(irq_settings_is_per_cpu_devid(desc)))
-           __free_irq(irq, act->dev_id);
+               __free_irq(irq, act->dev_id);
  }
  EXPORT_SYMBOL_GPL(remove_irq);
  
   *    have completed.
   *
   *    This function must not be called from interrupt context.
+  *
+  *    Returns the devname argument passed to request_irq.
   */
void free_irq(unsigned int irq, void *dev_id)
const void *free_irq(unsigned int irq, void *dev_id)
  {
        struct irq_desc *desc = irq_to_desc(irq);
+       struct irqaction *action;
+       const char *devname;
  
        if (!desc || WARN_ON(irq_settings_is_per_cpu_devid(desc)))
-               return;
+               return NULL;
  
  #ifdef CONFIG_SMP
        if (WARN_ON(desc->affinity_notify))
                desc->affinity_notify = NULL;
  #endif
  
-       kfree(__free_irq(irq, dev_id));
+       action = __free_irq(irq, dev_id);
+       devname = action->name;
+       kfree(action);
+       return devname;
  }
  EXPORT_SYMBOL(free_irq);