aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/acpi/namespace.txt9
-rw-r--r--Documentation/devicetree/bindings/clock/exynos5250-clock.txt2
-rw-r--r--MAINTAINERS2
-rw-r--r--Makefile2
-rw-r--r--arch/arm/boot/dts/exynos5250.dtsi2
-rw-r--r--arch/arm/crypto/aesbs-core.S_shipped2
-rw-r--r--arch/arm/crypto/bsaes-armv7.pl2
-rw-r--r--arch/arm/include/asm/io.h2
-rw-r--r--arch/arm/include/asm/memory.h3
-rw-r--r--arch/arm/include/asm/xen/page.h2
-rw-r--r--arch/arm/kernel/traps.c8
-rw-r--r--arch/arm/mach-footbridge/dc21285-timer.c5
-rw-r--r--arch/arm/mach-shmobile/board-armadillo800eva.c4
-rw-r--r--arch/arm/mach-shmobile/board-kzm9g.c2
-rw-r--r--arch/arm/mach-shmobile/board-mackerel.c4
-rw-r--r--arch/arm/mm/flush.c6
-rw-r--r--arch/ia64/hp/common/aml_nfw.c3
-rw-r--r--arch/ia64/kernel/acpi.c1
-rw-r--r--arch/parisc/include/asm/cacheflush.h12
-rw-r--r--arch/parisc/include/asm/page.h5
-rw-r--r--arch/parisc/kernel/cache.c35
-rw-r--r--arch/sparc/include/asm/uaccess_64.h4
-rw-r--r--arch/sparc/kernel/iommu.c2
-rw-r--r--arch/sparc/kernel/ioport.c5
-rw-r--r--arch/sparc/kernel/kgdb_64.c1
-rw-r--r--arch/sparc/kernel/smp_64.c3
-rw-r--r--arch/x86/kernel/acpi/boot.c3
-rw-r--r--arch/x86/kernel/apic/apic_flat_64.c4
-rw-r--r--arch/x86/kernel/apic/io_apic.c3
-rw-r--r--arch/x86/pci/mmconfig-shared.c1
-rw-r--r--arch/x86/pci/mmconfig_32.c1
-rw-r--r--arch/x86/platform/olpc/olpc-xo15-sci.c3
-rw-r--r--drivers/acpi/ac.c3
-rw-r--r--drivers/acpi/acpi_extlog.c62
-rw-r--r--drivers/acpi/acpi_memhotplug.c15
-rw-r--r--drivers/acpi/acpi_pad.c3
-rw-r--r--drivers/acpi/acpi_processor.c26
-rw-r--r--drivers/acpi/acpica/acdebug.h1
-rw-r--r--drivers/acpi/acpica/acevents.h9
-rw-r--r--drivers/acpi/acpica/acglobal.h30
-rw-r--r--drivers/acpi/acpica/aclocal.h9
-rw-r--r--drivers/acpi/acpica/dsfield.c2
-rw-r--r--drivers/acpi/acpica/dsutils.c19
-rw-r--r--drivers/acpi/acpica/dswload.c4
-rw-r--r--drivers/acpi/acpica/evgpeblk.c8
-rw-r--r--drivers/acpi/acpica/evgpeutil.c24
-rw-r--r--drivers/acpi/acpica/exresnte.c3
-rw-r--r--drivers/acpi/acpica/nsxfeval.c23
-rw-r--r--drivers/acpi/acpica/psopinfo.c51
-rw-r--r--drivers/acpi/acpica/tbfadt.c335
-rw-r--r--drivers/acpi/acpica/tbutils.c214
-rw-r--r--drivers/acpi/acpica/utaddress.c19
-rw-r--r--drivers/acpi/acpica/utalloc.c10
-rw-r--r--drivers/acpi/acpica/utcache.c12
-rw-r--r--drivers/acpi/acpica/utdebug.c4
-rw-r--r--drivers/acpi/acpica/utglobal.c4
-rw-r--r--drivers/acpi/acpica/utxfinit.c12
-rw-r--r--drivers/acpi/apei/apei-base.c1
-rw-r--r--drivers/acpi/apei/apei-internal.h1
-rw-r--r--drivers/acpi/apei/einj.c1
-rw-r--r--drivers/acpi/apei/ghes.c1
-rw-r--r--drivers/acpi/battery.c3
-rw-r--r--drivers/acpi/blacklist.c51
-rw-r--r--drivers/acpi/bus.c77
-rw-r--r--drivers/acpi/button.c21
-rw-r--r--drivers/acpi/container.c55
-rw-r--r--drivers/acpi/custom_method.c2
-rw-r--r--drivers/acpi/debugfs.c2
-rw-r--r--drivers/acpi/device_pm.c22
-rw-r--r--drivers/acpi/dock.c16
-rw-r--r--drivers/acpi/ec.c32
-rw-r--r--drivers/acpi/ec_sys.c2
-rw-r--r--drivers/acpi/event.c2
-rw-r--r--drivers/acpi/fan.c3
-rw-r--r--drivers/acpi/glue.c165
-rw-r--r--drivers/acpi/hed.c2
-rw-r--r--drivers/acpi/internal.h19
-rw-r--r--drivers/acpi/numa.c1
-rw-r--r--drivers/acpi/nvs.c3
-rw-r--r--drivers/acpi/osl.c14
-rw-r--r--drivers/acpi/pci_irq.c2
-rw-r--r--drivers/acpi/pci_link.c4
-rw-r--r--drivers/acpi/pci_root.c126
-rw-r--r--drivers/acpi/pci_slot.c1
-rw-r--r--drivers/acpi/power.c3
-rw-r--r--drivers/acpi/proc.c5
-rw-r--r--drivers/acpi/processor_core.c3
-rw-r--r--drivers/acpi/processor_driver.c8
-rw-r--r--drivers/acpi/processor_idle.c8
-rw-r--r--drivers/acpi/processor_perflib.c7
-rw-r--r--drivers/acpi/processor_thermal.c11
-rw-r--r--drivers/acpi/processor_throttling.c7
-rw-r--r--drivers/acpi/sbshc.c3
-rw-r--r--drivers/acpi/scan.c547
-rw-r--r--drivers/acpi/sleep.c14
-rw-r--r--drivers/acpi/sysfs.c2
-rw-r--r--drivers/acpi/tables.c11
-rw-r--r--drivers/acpi/thermal.c7
-rw-r--r--drivers/acpi/utils.c99
-rw-r--r--drivers/acpi/video.c5
-rw-r--r--drivers/acpi/video_detect.c2
-rw-r--r--drivers/acpi/wakeup.c1
-rw-r--r--drivers/ata/ahci.c3
-rw-r--r--drivers/ata/libata-acpi.c28
-rw-r--r--drivers/ata/pata_acpi.c5
-rw-r--r--drivers/ata/sata_sis.c4
-rw-r--r--drivers/base/Makefile2
-rw-r--r--drivers/base/base.h1
-rw-r--r--drivers/base/container.c44
-rw-r--r--drivers/base/init.c1
-rw-r--r--drivers/base/power/generic_ops.c4
-rw-r--r--drivers/block/null_blk.c10
-rw-r--r--drivers/char/hpet.c7
-rw-r--r--drivers/char/tpm/tpm_acpi.c2
-rw-r--r--drivers/char/tpm/tpm_ppi.c406
-rw-r--r--drivers/clk/clk-divider.c2
-rw-r--r--drivers/clk/samsung/clk-exynos-audss.c10
-rw-r--r--drivers/clk/samsung/clk-exynos4.c2
-rw-r--r--drivers/clk/samsung/clk-exynos5250.c14
-rw-r--r--drivers/firmware/Kconfig2
-rw-r--r--drivers/gpu/drm/gma500/opregion.c1
-rw-r--r--drivers/gpu/drm/i915/Makefile3
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h3
-rw-r--r--drivers/gpu/drm/i915/i915_gem_gtt.c2
-rw-r--r--drivers/gpu/drm/i915/intel_acpi.c146
-rw-r--r--drivers/gpu/drm/i915/intel_display.c19
-rw-r--r--drivers/gpu/drm/i915/intel_opregion.c1
-rw-r--r--drivers/gpu/drm/nouveau/core/core/subdev.c3
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/device/base.c2
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/device/nvc0.c2
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/graph/nvc0.c2
-rw-r--r--drivers/gpu/drm/nouveau/core/include/subdev/fb.h5
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/bios/init.c14
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/mxm/base.c48
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_abi16.c2
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_acpi.c138
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_display.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_acpi.c6
-rw-r--r--drivers/hid/i2c-hid/i2c-hid.c26
-rw-r--r--drivers/hv/vmbus_drv.c2
-rw-r--r--drivers/hwmon/acpi_power_meter.c3
-rw-r--r--drivers/hwmon/asus_atk0110.c6
-rw-r--r--drivers/ide/ide-acpi.c12
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_netlink.c3
-rw-r--r--drivers/input/misc/atlas_btns.c2
-rw-r--r--drivers/iommu/amd_iommu_init.c1
-rw-r--r--drivers/iommu/intel_irq_remapping.c4
-rw-r--r--drivers/isdn/hisax/hfc_pci.c4
-rw-r--r--drivers/isdn/hisax/telespci.c4
-rw-r--r--drivers/leds/leds-lp5521.c12
-rw-r--r--drivers/leds/leds-lp5523.c12
-rw-r--r--drivers/mfd/rtsx_pcr.c10
-rw-r--r--drivers/mmc/core/sdio_bus.c2
-rw-r--r--drivers/mtd/maps/pxa2xx-flash.c2
-rw-r--r--drivers/net/bonding/bond_main.c3
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x.h51
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c28
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h3
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c94
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c6
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h1
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c15
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h7
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c254
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h1
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c26
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/sge.c2
-rw-r--r--drivers/net/ethernet/emulex/benet/be.h3
-rw-r--r--drivers/net/ethernet/emulex/benet/be_cmds.c33
-rw-r--r--drivers/net/ethernet/emulex/benet/be_main.c29
-rw-r--r--drivers/net/ethernet/freescale/fec_main.c14
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_main.c33
-rw-r--r--drivers/net/ethernet/lantiq_etop.c3
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_tx.c3
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/mlx4_en.h3
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic.h6
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c7
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c41
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c4
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c12
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c7
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c3
-rw-r--r--drivers/net/ethernet/tile/tilegx.c3
-rw-r--r--drivers/net/macvlan.c14
-rw-r--r--drivers/net/team/team.c3
-rw-r--r--drivers/net/tun.c3
-rw-r--r--drivers/net/usb/hso.c13
-rw-r--r--drivers/net/usb/mcs7830.c19
-rw-r--r--drivers/net/virtio_net.c11
-rw-r--r--drivers/net/vxlan.c3
-rw-r--r--drivers/net/wireless/iwlwifi/pcie/drv.c10
-rw-r--r--drivers/net/wireless/mac80211_hwsim.c2
-rw-r--r--drivers/net/wireless/mwifiex/main.c3
-rw-r--r--drivers/net/xen-netback/interface.c1
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c2
-rw-r--r--drivers/pci/hotplug/acpiphp_ibm.c3
-rw-r--r--drivers/pci/hotplug/pciehp.h2
-rw-r--r--drivers/pci/ioapic.c1
-rw-r--r--drivers/pci/pci-acpi.c17
-rw-r--r--drivers/pci/pci-label.c130
-rw-r--r--drivers/platform/x86/acer-wmi.c2
-rw-r--r--drivers/platform/x86/asus-laptop.c3
-rw-r--r--drivers/platform/x86/asus-wmi.c3
-rw-r--r--drivers/platform/x86/classmate-laptop.c3
-rw-r--r--drivers/platform/x86/dell-wmi-aio.c1
-rw-r--r--drivers/platform/x86/dell-wmi.c1
-rw-r--r--drivers/platform/x86/eeepc-laptop.c3
-rw-r--r--drivers/platform/x86/eeepc-wmi.c2
-rw-r--r--drivers/platform/x86/hp_accel.c2
-rw-r--r--drivers/platform/x86/ideapad-laptop.c3
-rw-r--r--drivers/platform/x86/intel-rst.c2
-rw-r--r--drivers/platform/x86/intel-smartconnect.c2
-rw-r--r--drivers/platform/x86/intel_menlow.c4
-rw-r--r--drivers/platform/x86/intel_oaktrail.c3
-rw-r--r--drivers/platform/x86/mxm-wmi.c3
-rw-r--r--drivers/platform/x86/panasonic-laptop.c4
-rw-r--r--drivers/platform/x86/pvpanic.c3
-rw-r--r--drivers/platform/x86/samsung-q10.c2
-rw-r--r--drivers/platform/x86/sony-laptop.c4
-rw-r--r--drivers/platform/x86/tc1100-wmi.c4
-rw-r--r--drivers/platform/x86/thinkpad_acpi.c14
-rw-r--r--drivers/platform/x86/toshiba_acpi.c4
-rw-r--r--drivers/platform/x86/toshiba_bluetooth.c4
-rw-r--r--drivers/platform/x86/wmi.c2
-rw-r--r--drivers/platform/x86/xo15-ebook.c3
-rw-r--r--drivers/pnp/card.c1
-rw-r--r--drivers/pnp/pnpacpi/core.c33
-rw-r--r--drivers/pnp/pnpacpi/pnpacpi.h1
-rw-r--r--drivers/pnp/pnpbios/core.c12
-rw-r--r--drivers/pnp/resource.c2
-rw-r--r--drivers/sfi/sfi_acpi.c4
-rw-r--r--drivers/staging/bcm/Bcmnet.c3
-rw-r--r--drivers/staging/netlogic/xlr_net.c3
-rw-r--r--drivers/staging/quickstart/quickstart.c2
-rw-r--r--drivers/staging/rtl8188eu/os_dep/os_intfs.c3
-rw-r--r--drivers/usb/core/usb-acpi.c41
-rw-r--r--drivers/xen/xen-acpi-cpuhotplug.c11
-rw-r--r--drivers/xen/xen-acpi-memhotplug.c8
-rw-r--r--drivers/xen/xen-acpi-pad.c5
-rw-r--r--drivers/xen/xen-acpi-processor.c4
-rw-r--r--fs/ext4/extents.c2
-rw-r--r--fs/xfs/xfs_attr_remote.c2
-rw-r--r--fs/xfs/xfs_bmap_util.c1
-rw-r--r--include/acpi/acpi_bus.h64
-rw-r--r--include/acpi/acpi_drivers.h3
-rw-r--r--include/acpi/acpi_io.h (renamed from include/linux/acpi_io.h)1
-rw-r--r--include/acpi/acpixf.h39
-rw-r--r--include/acpi/actbl.h3
-rw-r--r--include/acpi/actbl1.h10
-rw-r--r--include/acpi/actbl2.h5
-rw-r--r--include/acpi/actbl3.h15
-rw-r--r--include/acpi/actypes.h12
-rw-r--r--include/acpi/platform/acenv.h20
-rw-r--r--include/acpi/platform/aclinux.h4
-rw-r--r--include/linux/acpi.h9
-rw-r--r--include/linux/container.h25
-rw-r--r--include/linux/ide.h8
-rw-r--r--include/linux/iscsi_ibft.h2
-rw-r--r--include/linux/netdevice.h34
-rw-r--r--include/linux/pci_hotplug.h3
-rw-r--r--include/linux/pm.h21
-rw-r--r--include/linux/pm_runtime.h12
-rw-r--r--include/linux/sfi_acpi.h5
-rw-r--r--include/linux/tboot.h2
-rw-r--r--include/net/llc_pdu.h2
-rw-r--r--include/net/sctp/structs.h3
-rw-r--r--kernel/power/hibernate.c7
-rw-r--r--mm/huge_memory.c6
-rw-r--r--net/8021q/vlan_dev.c19
-rw-r--r--net/bridge/br_multicast.c4
-rw-r--r--net/core/dev.c29
-rw-r--r--net/core/flow_dissector.c10
-rw-r--r--net/core/neighbour.c2
-rw-r--r--net/core/netpoll.c13
-rw-r--r--net/ieee802154/6lowpan.c2
-rw-r--r--net/ipv4/gre_offload.c11
-rw-r--r--net/ipv4/udp.c6
-rw-r--r--net/ipv4/udp_offload.c37
-rw-r--r--net/ipv6/addrconf.c23
-rw-r--r--net/ipv6/ip6_tunnel.c21
-rw-r--r--net/ipv6/ip6_vti.c30
-rw-r--r--net/ipv6/sit.c2
-rw-r--r--net/llc/af_llc.c5
-rw-r--r--net/mac80211/iface.c6
-rw-r--r--net/mac80211/tx.c23
-rw-r--r--net/netfilter/nf_conntrack_seqadj.c2
-rw-r--r--net/netfilter/nf_nat_irc.c32
-rw-r--r--net/nfc/core.c2
-rw-r--r--net/sched/sch_generic.c2
-rw-r--r--net/sctp/outqueue.c32
-rw-r--r--net/tipc/link.c1
-rw-r--r--security/selinux/hooks.c20
-rw-r--r--security/selinux/include/objsec.h5
-rw-r--r--tools/power/cpupower/debug/kernel/cpufreq-test_tsc.c5
294 files changed, 2685 insertions, 2593 deletions
diff --git a/Documentation/acpi/namespace.txt b/Documentation/acpi/namespace.txt
index 260f6a3661fa..1860cb3865c6 100644
--- a/Documentation/acpi/namespace.txt
+++ b/Documentation/acpi/namespace.txt
@@ -235,10 +235,6 @@ Wysocki <rafael.j.wysocki@intel.com>.
235 named object's type in the second column). In that case the object's 235 named object's type in the second column). In that case the object's
236 directory in sysfs will contain the 'path' attribute whose value is 236 directory in sysfs will contain the 'path' attribute whose value is
237 the full path to the node from the namespace root. 237 the full path to the node from the namespace root.
238 struct acpi_device objects are created for the ACPI namespace nodes
239 whose _STA control methods return PRESENT or FUNCTIONING. The power
240 resource nodes or nodes without _STA are assumed to be both PRESENT
241 and FUNCTIONING.
242 F: 238 F:
243 The struct acpi_device object is created for a fixed hardware 239 The struct acpi_device object is created for a fixed hardware
244 feature (as indicated by the fixed feature flag's name in the second 240 feature (as indicated by the fixed feature flag's name in the second
@@ -340,7 +336,7 @@ Wysocki <rafael.j.wysocki@intel.com>.
340 | +-------------+-------+----------------+ 336 | +-------------+-------+----------------+
341 | | 337 | |
342 | | +- - - - - - - +- - - - - - +- - - - - - - -+ 338 | | +- - - - - - - +- - - - - - +- - - - - - - -+
343 | +-| * PNP0C0D:00 | \_SB_.LID0 | acpi:PNP0C0D: | 339 | +-| PNP0C0D:00 | \_SB_.LID0 | acpi:PNP0C0D: |
344 | | +- - - - - - - +- - - - - - +- - - - - - - -+ 340 | | +- - - - - - - +- - - - - - +- - - - - - - -+
345 | | 341 | |
346 | | +------------+------------+-----------------------+ 342 | | +------------+------------+-----------------------+
@@ -390,6 +386,3 @@ Wysocki <rafael.j.wysocki@intel.com>.
390 attribute (as described earlier in this document). 386 attribute (as described earlier in this document).
391 NOTE: N/A indicates the device object does not have the 'path' or the 387 NOTE: N/A indicates the device object does not have the 'path' or the
392 'modalias' attribute. 388 'modalias' attribute.
393 NOTE: The PNP0C0D device listed above is highlighted (marked by "*")
394 to indicate it will be created only when its _STA methods return
395 PRESENT or FUNCTIONING.
diff --git a/Documentation/devicetree/bindings/clock/exynos5250-clock.txt b/Documentation/devicetree/bindings/clock/exynos5250-clock.txt
index 46f5c791ea0d..0f2f920e8734 100644
--- a/Documentation/devicetree/bindings/clock/exynos5250-clock.txt
+++ b/Documentation/devicetree/bindings/clock/exynos5250-clock.txt
@@ -159,6 +159,8 @@ clock which they consume.
159 mixer 343 159 mixer 343
160 hdmi 344 160 hdmi 344
161 g2d 345 161 g2d 345
162 mdma0 346
163 smmu_mdma0 347
162 164
163 165
164 [Clock Muxes] 166 [Clock Muxes]
diff --git a/MAINTAINERS b/MAINTAINERS
index 6c2079270791..31a046213274 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2828,8 +2828,10 @@ F: include/uapi/drm/
2828 2828
2829INTEL DRM DRIVERS (excluding Poulsbo, Moorestown and derivative chipsets) 2829INTEL DRM DRIVERS (excluding Poulsbo, Moorestown and derivative chipsets)
2830M: Daniel Vetter <daniel.vetter@ffwll.ch> 2830M: Daniel Vetter <daniel.vetter@ffwll.ch>
2831M: Jani Nikula <jani.nikula@linux.intel.com>
2831L: intel-gfx@lists.freedesktop.org 2832L: intel-gfx@lists.freedesktop.org
2832L: dri-devel@lists.freedesktop.org 2833L: dri-devel@lists.freedesktop.org
2834Q: http://patchwork.freedesktop.org/project/intel-gfx/
2833T: git git://people.freedesktop.org/~danvet/drm-intel 2835T: git git://people.freedesktop.org/~danvet/drm-intel
2834S: Supported 2836S: Supported
2835F: drivers/gpu/drm/i915/ 2837F: drivers/gpu/drm/i915/
diff --git a/Makefile b/Makefile
index ae1a55ad687c..eeec740776f3 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 3 1VERSION = 3
2PATCHLEVEL = 13 2PATCHLEVEL = 13
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc7 4EXTRAVERSION = -rc8
5NAME = One Giant Leap for Frogkind 5NAME = One Giant Leap for Frogkind
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi
index 9db5047812f3..177becde7a26 100644
--- a/arch/arm/boot/dts/exynos5250.dtsi
+++ b/arch/arm/boot/dts/exynos5250.dtsi
@@ -559,7 +559,7 @@
559 compatible = "arm,pl330", "arm,primecell"; 559 compatible = "arm,pl330", "arm,primecell";
560 reg = <0x10800000 0x1000>; 560 reg = <0x10800000 0x1000>;
561 interrupts = <0 33 0>; 561 interrupts = <0 33 0>;
562 clocks = <&clock 271>; 562 clocks = <&clock 346>;
563 clock-names = "apb_pclk"; 563 clock-names = "apb_pclk";
564 #dma-cells = <1>; 564 #dma-cells = <1>;
565 #dma-channels = <8>; 565 #dma-channels = <8>;
diff --git a/arch/arm/crypto/aesbs-core.S_shipped b/arch/arm/crypto/aesbs-core.S_shipped
index 64205d453260..71e5fc7cfb18 100644
--- a/arch/arm/crypto/aesbs-core.S_shipped
+++ b/arch/arm/crypto/aesbs-core.S_shipped
@@ -58,7 +58,7 @@
58# define VFP_ABI_FRAME 0 58# define VFP_ABI_FRAME 0
59# define BSAES_ASM_EXTENDED_KEY 59# define BSAES_ASM_EXTENDED_KEY
60# define XTS_CHAIN_TWEAK 60# define XTS_CHAIN_TWEAK
61# define __ARM_ARCH__ __LINUX_ARM_ARCH__ 61# define __ARM_ARCH__ 7
62#endif 62#endif
63 63
64#ifdef __thumb__ 64#ifdef __thumb__
diff --git a/arch/arm/crypto/bsaes-armv7.pl b/arch/arm/crypto/bsaes-armv7.pl
index f3d96d932573..be068db960ee 100644
--- a/arch/arm/crypto/bsaes-armv7.pl
+++ b/arch/arm/crypto/bsaes-armv7.pl
@@ -701,7 +701,7 @@ $code.=<<___;
701# define VFP_ABI_FRAME 0 701# define VFP_ABI_FRAME 0
702# define BSAES_ASM_EXTENDED_KEY 702# define BSAES_ASM_EXTENDED_KEY
703# define XTS_CHAIN_TWEAK 703# define XTS_CHAIN_TWEAK
704# define __ARM_ARCH__ __LINUX_ARM_ARCH__ 704# define __ARM_ARCH__ 7
705#endif 705#endif
706 706
707#ifdef __thumb__ 707#ifdef __thumb__
diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h
index 3c597c222ef2..fbeb39c869e9 100644
--- a/arch/arm/include/asm/io.h
+++ b/arch/arm/include/asm/io.h
@@ -329,7 +329,7 @@ extern void _memset_io(volatile void __iomem *, int, size_t);
329 */ 329 */
330#define ioremap(cookie,size) __arm_ioremap((cookie), (size), MT_DEVICE) 330#define ioremap(cookie,size) __arm_ioremap((cookie), (size), MT_DEVICE)
331#define ioremap_nocache(cookie,size) __arm_ioremap((cookie), (size), MT_DEVICE) 331#define ioremap_nocache(cookie,size) __arm_ioremap((cookie), (size), MT_DEVICE)
332#define ioremap_cached(cookie,size) __arm_ioremap((cookie), (size), MT_DEVICE_CACHED) 332#define ioremap_cache(cookie,size) __arm_ioremap((cookie), (size), MT_DEVICE_CACHED)
333#define ioremap_wc(cookie,size) __arm_ioremap((cookie), (size), MT_DEVICE_WC) 333#define ioremap_wc(cookie,size) __arm_ioremap((cookie), (size), MT_DEVICE_WC)
334#define iounmap __arm_iounmap 334#define iounmap __arm_iounmap
335 335
diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
index 6976b03e5213..8756e4bcdba0 100644
--- a/arch/arm/include/asm/memory.h
+++ b/arch/arm/include/asm/memory.h
@@ -347,7 +347,8 @@ static inline __deprecated void *bus_to_virt(unsigned long x)
347#define ARCH_PFN_OFFSET PHYS_PFN_OFFSET 347#define ARCH_PFN_OFFSET PHYS_PFN_OFFSET
348 348
349#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT) 349#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
350#define virt_addr_valid(kaddr) ((unsigned long)(kaddr) >= PAGE_OFFSET && (unsigned long)(kaddr) < (unsigned long)high_memory) 350#define virt_addr_valid(kaddr) (((unsigned long)(kaddr) >= PAGE_OFFSET && (unsigned long)(kaddr) < (unsigned long)high_memory) \
351 && pfn_valid(__pa(kaddr) >> PAGE_SHIFT) )
351 352
352#endif 353#endif
353 354
diff --git a/arch/arm/include/asm/xen/page.h b/arch/arm/include/asm/xen/page.h
index 75579a9d6f76..3759cacdd7f8 100644
--- a/arch/arm/include/asm/xen/page.h
+++ b/arch/arm/include/asm/xen/page.h
@@ -117,6 +117,6 @@ static inline bool set_phys_to_machine(unsigned long pfn, unsigned long mfn)
117 return __set_phys_to_machine(pfn, mfn); 117 return __set_phys_to_machine(pfn, mfn);
118} 118}
119 119
120#define xen_remap(cookie, size) ioremap_cached((cookie), (size)); 120#define xen_remap(cookie, size) ioremap_cache((cookie), (size));
121 121
122#endif /* _ASM_ARM_XEN_PAGE_H */ 122#endif /* _ASM_ARM_XEN_PAGE_H */
diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
index 7940241f0576..6eda3bf85c52 100644
--- a/arch/arm/kernel/traps.c
+++ b/arch/arm/kernel/traps.c
@@ -36,7 +36,13 @@
36#include <asm/system_misc.h> 36#include <asm/system_misc.h>
37#include <asm/opcodes.h> 37#include <asm/opcodes.h>
38 38
39static const char *handler[]= { "prefetch abort", "data abort", "address exception", "interrupt" }; 39static const char *handler[]= {
40 "prefetch abort",
41 "data abort",
42 "address exception",
43 "interrupt",
44 "undefined instruction",
45};
40 46
41void *vectors_page; 47void *vectors_page;
42 48
diff --git a/arch/arm/mach-footbridge/dc21285-timer.c b/arch/arm/mach-footbridge/dc21285-timer.c
index 9ee78f7b4990..782f6c71fa0a 100644
--- a/arch/arm/mach-footbridge/dc21285-timer.c
+++ b/arch/arm/mach-footbridge/dc21285-timer.c
@@ -96,11 +96,12 @@ static struct irqaction footbridge_timer_irq = {
96void __init footbridge_timer_init(void) 96void __init footbridge_timer_init(void)
97{ 97{
98 struct clock_event_device *ce = &ckevt_dc21285; 98 struct clock_event_device *ce = &ckevt_dc21285;
99 unsigned rate = DIV_ROUND_CLOSEST(mem_fclk_21285, 16);
99 100
100 clocksource_register_hz(&cksrc_dc21285, (mem_fclk_21285 + 8) / 16); 101 clocksource_register_hz(&cksrc_dc21285, rate);
101 102
102 setup_irq(ce->irq, &footbridge_timer_irq); 103 setup_irq(ce->irq, &footbridge_timer_irq);
103 104
104 ce->cpumask = cpumask_of(smp_processor_id()); 105 ce->cpumask = cpumask_of(smp_processor_id());
105 clockevents_config_and_register(ce, mem_fclk_21285, 0x4, 0xffffff); 106 clockevents_config_and_register(ce, rate, 0x4, 0xffffff);
106} 107}
diff --git a/arch/arm/mach-shmobile/board-armadillo800eva.c b/arch/arm/mach-shmobile/board-armadillo800eva.c
index c18689123023..8ea87bd45c33 100644
--- a/arch/arm/mach-shmobile/board-armadillo800eva.c
+++ b/arch/arm/mach-shmobile/board-armadillo800eva.c
@@ -483,7 +483,7 @@ static struct platform_device lcdc0_device = {
483 .id = 0, 483 .id = 0,
484 .dev = { 484 .dev = {
485 .platform_data = &lcdc0_info, 485 .platform_data = &lcdc0_info,
486 .coherent_dma_mask = ~0, 486 .coherent_dma_mask = DMA_BIT_MASK(32),
487 }, 487 },
488}; 488};
489 489
@@ -580,7 +580,7 @@ static struct platform_device hdmi_lcdc_device = {
580 .id = 1, 580 .id = 1,
581 .dev = { 581 .dev = {
582 .platform_data = &hdmi_lcdc_info, 582 .platform_data = &hdmi_lcdc_info,
583 .coherent_dma_mask = ~0, 583 .coherent_dma_mask = DMA_BIT_MASK(32),
584 }, 584 },
585}; 585};
586 586
diff --git a/arch/arm/mach-shmobile/board-kzm9g.c b/arch/arm/mach-shmobile/board-kzm9g.c
index fe689b7fdc9e..bc40b853ffd3 100644
--- a/arch/arm/mach-shmobile/board-kzm9g.c
+++ b/arch/arm/mach-shmobile/board-kzm9g.c
@@ -334,7 +334,7 @@ static struct platform_device lcdc_device = {
334 .resource = lcdc_resources, 334 .resource = lcdc_resources,
335 .dev = { 335 .dev = {
336 .platform_data = &lcdc_info, 336 .platform_data = &lcdc_info,
337 .coherent_dma_mask = ~0, 337 .coherent_dma_mask = DMA_BIT_MASK(32),
338 }, 338 },
339}; 339};
340 340
diff --git a/arch/arm/mach-shmobile/board-mackerel.c b/arch/arm/mach-shmobile/board-mackerel.c
index af06753eb809..e721d2ccceae 100644
--- a/arch/arm/mach-shmobile/board-mackerel.c
+++ b/arch/arm/mach-shmobile/board-mackerel.c
@@ -409,7 +409,7 @@ static struct platform_device lcdc_device = {
409 .resource = lcdc_resources, 409 .resource = lcdc_resources,
410 .dev = { 410 .dev = {
411 .platform_data = &lcdc_info, 411 .platform_data = &lcdc_info,
412 .coherent_dma_mask = ~0, 412 .coherent_dma_mask = DMA_BIT_MASK(32),
413 }, 413 },
414}; 414};
415 415
@@ -499,7 +499,7 @@ static struct platform_device hdmi_lcdc_device = {
499 .id = 1, 499 .id = 1,
500 .dev = { 500 .dev = {
501 .platform_data = &hdmi_lcdc_info, 501 .platform_data = &hdmi_lcdc_info,
502 .coherent_dma_mask = ~0, 502 .coherent_dma_mask = DMA_BIT_MASK(32),
503 }, 503 },
504}; 504};
505 505
diff --git a/arch/arm/mm/flush.c b/arch/arm/mm/flush.c
index 6d5ba9afb16a..3387e60e4ea3 100644
--- a/arch/arm/mm/flush.c
+++ b/arch/arm/mm/flush.c
@@ -175,16 +175,16 @@ void __flush_dcache_page(struct address_space *mapping, struct page *page)
175 unsigned long i; 175 unsigned long i;
176 if (cache_is_vipt_nonaliasing()) { 176 if (cache_is_vipt_nonaliasing()) {
177 for (i = 0; i < (1 << compound_order(page)); i++) { 177 for (i = 0; i < (1 << compound_order(page)); i++) {
178 void *addr = kmap_atomic(page); 178 void *addr = kmap_atomic(page + i);
179 __cpuc_flush_dcache_area(addr, PAGE_SIZE); 179 __cpuc_flush_dcache_area(addr, PAGE_SIZE);
180 kunmap_atomic(addr); 180 kunmap_atomic(addr);
181 } 181 }
182 } else { 182 } else {
183 for (i = 0; i < (1 << compound_order(page)); i++) { 183 for (i = 0; i < (1 << compound_order(page)); i++) {
184 void *addr = kmap_high_get(page); 184 void *addr = kmap_high_get(page + i);
185 if (addr) { 185 if (addr) {
186 __cpuc_flush_dcache_area(addr, PAGE_SIZE); 186 __cpuc_flush_dcache_area(addr, PAGE_SIZE);
187 kunmap_high(page); 187 kunmap_high(page + i);
188 } 188 }
189 } 189 }
190 } 190 }
diff --git a/arch/ia64/hp/common/aml_nfw.c b/arch/ia64/hp/common/aml_nfw.c
index 916ffe770bcf..84715fcbba08 100644
--- a/arch/ia64/hp/common/aml_nfw.c
+++ b/arch/ia64/hp/common/aml_nfw.c
@@ -23,8 +23,7 @@
23 */ 23 */
24 24
25#include <linux/module.h> 25#include <linux/module.h>
26#include <acpi/acpi_bus.h> 26#include <linux/acpi.h>
27#include <acpi/acpi_drivers.h>
28#include <asm/sal.h> 27#include <asm/sal.h>
29 28
30MODULE_AUTHOR("Bjorn Helgaas <bjorn.helgaas@hp.com>"); 29MODULE_AUTHOR("Bjorn Helgaas <bjorn.helgaas@hp.com>");
diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c
index 59d52e3aef12..28dc6ba6690a 100644
--- a/arch/ia64/kernel/acpi.c
+++ b/arch/ia64/kernel/acpi.c
@@ -61,7 +61,6 @@
61 61
62#define PREFIX "ACPI: " 62#define PREFIX "ACPI: "
63 63
64u32 acpi_rsdt_forced;
65unsigned int acpi_cpei_override; 64unsigned int acpi_cpei_override;
66unsigned int acpi_cpei_phys_cpuid; 65unsigned int acpi_cpei_phys_cpuid;
67 66
diff --git a/arch/parisc/include/asm/cacheflush.h b/arch/parisc/include/asm/cacheflush.h
index f0e2784e7cca..2f9b751878ba 100644
--- a/arch/parisc/include/asm/cacheflush.h
+++ b/arch/parisc/include/asm/cacheflush.h
@@ -125,42 +125,38 @@ flush_anon_page(struct vm_area_struct *vma, struct page *page, unsigned long vma
125void mark_rodata_ro(void); 125void mark_rodata_ro(void);
126#endif 126#endif
127 127
128#ifdef CONFIG_PA8X00
129/* Only pa8800, pa8900 needs this */
130
131#include <asm/kmap_types.h> 128#include <asm/kmap_types.h>
132 129
133#define ARCH_HAS_KMAP 130#define ARCH_HAS_KMAP
134 131
135void kunmap_parisc(void *addr);
136
137static inline void *kmap(struct page *page) 132static inline void *kmap(struct page *page)
138{ 133{
139 might_sleep(); 134 might_sleep();
135 flush_dcache_page(page);
140 return page_address(page); 136 return page_address(page);
141} 137}
142 138
143static inline void kunmap(struct page *page) 139static inline void kunmap(struct page *page)
144{ 140{
145 kunmap_parisc(page_address(page)); 141 flush_kernel_dcache_page_addr(page_address(page));
146} 142}
147 143
148static inline void *kmap_atomic(struct page *page) 144static inline void *kmap_atomic(struct page *page)
149{ 145{
150 pagefault_disable(); 146 pagefault_disable();
147 flush_dcache_page(page);
151 return page_address(page); 148 return page_address(page);
152} 149}
153 150
154static inline void __kunmap_atomic(void *addr) 151static inline void __kunmap_atomic(void *addr)
155{ 152{
156 kunmap_parisc(addr); 153 flush_kernel_dcache_page_addr(addr);
157 pagefault_enable(); 154 pagefault_enable();
158} 155}
159 156
160#define kmap_atomic_prot(page, prot) kmap_atomic(page) 157#define kmap_atomic_prot(page, prot) kmap_atomic(page)
161#define kmap_atomic_pfn(pfn) kmap_atomic(pfn_to_page(pfn)) 158#define kmap_atomic_pfn(pfn) kmap_atomic(pfn_to_page(pfn))
162#define kmap_atomic_to_page(ptr) virt_to_page(ptr) 159#define kmap_atomic_to_page(ptr) virt_to_page(ptr)
163#endif
164 160
165#endif /* _PARISC_CACHEFLUSH_H */ 161#endif /* _PARISC_CACHEFLUSH_H */
166 162
diff --git a/arch/parisc/include/asm/page.h b/arch/parisc/include/asm/page.h
index b7adb2ac049c..c53fc63149e8 100644
--- a/arch/parisc/include/asm/page.h
+++ b/arch/parisc/include/asm/page.h
@@ -28,9 +28,8 @@ struct page;
28 28
29void clear_page_asm(void *page); 29void clear_page_asm(void *page);
30void copy_page_asm(void *to, void *from); 30void copy_page_asm(void *to, void *from);
31void clear_user_page(void *vto, unsigned long vaddr, struct page *pg); 31#define clear_user_page(vto, vaddr, page) clear_page_asm(vto)
32void copy_user_page(void *vto, void *vfrom, unsigned long vaddr, 32#define copy_user_page(vto, vfrom, vaddr, page) copy_page_asm(vto, vfrom)
33 struct page *pg);
34 33
35/* #define CONFIG_PARISC_TMPALIAS */ 34/* #define CONFIG_PARISC_TMPALIAS */
36 35
diff --git a/arch/parisc/kernel/cache.c b/arch/parisc/kernel/cache.c
index c035673209f7..a72545554a31 100644
--- a/arch/parisc/kernel/cache.c
+++ b/arch/parisc/kernel/cache.c
@@ -388,41 +388,6 @@ void flush_kernel_dcache_page_addr(void *addr)
388} 388}
389EXPORT_SYMBOL(flush_kernel_dcache_page_addr); 389EXPORT_SYMBOL(flush_kernel_dcache_page_addr);
390 390
391void clear_user_page(void *vto, unsigned long vaddr, struct page *page)
392{
393 clear_page_asm(vto);
394 if (!parisc_requires_coherency())
395 flush_kernel_dcache_page_asm(vto);
396}
397EXPORT_SYMBOL(clear_user_page);
398
399void copy_user_page(void *vto, void *vfrom, unsigned long vaddr,
400 struct page *pg)
401{
402 /* Copy using kernel mapping. No coherency is needed
403 (all in kmap/kunmap) on machines that don't support
404 non-equivalent aliasing. However, the `from' page
405 needs to be flushed before it can be accessed through
406 the kernel mapping. */
407 preempt_disable();
408 flush_dcache_page_asm(__pa(vfrom), vaddr);
409 preempt_enable();
410 copy_page_asm(vto, vfrom);
411 if (!parisc_requires_coherency())
412 flush_kernel_dcache_page_asm(vto);
413}
414EXPORT_SYMBOL(copy_user_page);
415
416#ifdef CONFIG_PA8X00
417
418void kunmap_parisc(void *addr)
419{
420 if (parisc_requires_coherency())
421 flush_kernel_dcache_page_addr(addr);
422}
423EXPORT_SYMBOL(kunmap_parisc);
424#endif
425
426void purge_tlb_entries(struct mm_struct *mm, unsigned long addr) 391void purge_tlb_entries(struct mm_struct *mm, unsigned long addr)
427{ 392{
428 unsigned long flags; 393 unsigned long flags;
diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
index e562d3caee57..ad7e178337f1 100644
--- a/arch/sparc/include/asm/uaccess_64.h
+++ b/arch/sparc/include/asm/uaccess_64.h
@@ -262,8 +262,8 @@ extern unsigned long __must_check __clear_user(void __user *, unsigned long);
262extern __must_check long strlen_user(const char __user *str); 262extern __must_check long strlen_user(const char __user *str);
263extern __must_check long strnlen_user(const char __user *str, long n); 263extern __must_check long strnlen_user(const char __user *str, long n);
264 264
265#define __copy_to_user_inatomic ___copy_to_user 265#define __copy_to_user_inatomic __copy_to_user
266#define __copy_from_user_inatomic ___copy_from_user 266#define __copy_from_user_inatomic __copy_from_user
267 267
268struct pt_regs; 268struct pt_regs;
269extern unsigned long compute_effective_address(struct pt_regs *, 269extern unsigned long compute_effective_address(struct pt_regs *,
diff --git a/arch/sparc/kernel/iommu.c b/arch/sparc/kernel/iommu.c
index 070ed141aac7..76663b019eb5 100644
--- a/arch/sparc/kernel/iommu.c
+++ b/arch/sparc/kernel/iommu.c
@@ -854,7 +854,7 @@ int dma_supported(struct device *dev, u64 device_mask)
854 return 1; 854 return 1;
855 855
856#ifdef CONFIG_PCI 856#ifdef CONFIG_PCI
857 if (dev->bus == &pci_bus_type) 857 if (dev_is_pci(dev))
858 return pci64_dma_supported(to_pci_dev(dev), device_mask); 858 return pci64_dma_supported(to_pci_dev(dev), device_mask);
859#endif 859#endif
860 860
diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c
index 2096468de9b2..e7e215dfa866 100644
--- a/arch/sparc/kernel/ioport.c
+++ b/arch/sparc/kernel/ioport.c
@@ -666,10 +666,9 @@ EXPORT_SYMBOL(dma_ops);
666 */ 666 */
667int dma_supported(struct device *dev, u64 mask) 667int dma_supported(struct device *dev, u64 mask)
668{ 668{
669#ifdef CONFIG_PCI 669 if (dev_is_pci(dev))
670 if (dev->bus == &pci_bus_type)
671 return 1; 670 return 1;
672#endif 671
673 return 0; 672 return 0;
674} 673}
675EXPORT_SYMBOL(dma_supported); 674EXPORT_SYMBOL(dma_supported);
diff --git a/arch/sparc/kernel/kgdb_64.c b/arch/sparc/kernel/kgdb_64.c
index 60b19f50c80a..b45fe3fb4d2c 100644
--- a/arch/sparc/kernel/kgdb_64.c
+++ b/arch/sparc/kernel/kgdb_64.c
@@ -6,6 +6,7 @@
6#include <linux/kgdb.h> 6#include <linux/kgdb.h>
7#include <linux/kdebug.h> 7#include <linux/kdebug.h>
8#include <linux/ftrace.h> 8#include <linux/ftrace.h>
9#include <linux/context_tracking.h>
9 10
10#include <asm/cacheflush.h> 11#include <asm/cacheflush.h>
11#include <asm/kdebug.h> 12#include <asm/kdebug.h>
diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
index b66a5338231e..b085311dcd0e 100644
--- a/arch/sparc/kernel/smp_64.c
+++ b/arch/sparc/kernel/smp_64.c
@@ -123,11 +123,12 @@ void smp_callin(void)
123 rmb(); 123 rmb();
124 124
125 set_cpu_online(cpuid, true); 125 set_cpu_online(cpuid, true);
126 local_irq_enable();
127 126
128 /* idle thread is expected to have preempt disabled */ 127 /* idle thread is expected to have preempt disabled */
129 preempt_disable(); 128 preempt_disable();
130 129
130 local_irq_enable();
131
131 cpu_startup_entry(CPUHP_ONLINE); 132 cpu_startup_entry(CPUHP_ONLINE);
132} 133}
133 134
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 6c0b43bd024b..0b0b91b83d51 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -46,7 +46,6 @@
46 46
47#include "sleep.h" /* To include x86_acpi_suspend_lowlevel */ 47#include "sleep.h" /* To include x86_acpi_suspend_lowlevel */
48static int __initdata acpi_force = 0; 48static int __initdata acpi_force = 0;
49u32 acpi_rsdt_forced;
50int acpi_disabled; 49int acpi_disabled;
51EXPORT_SYMBOL(acpi_disabled); 50EXPORT_SYMBOL(acpi_disabled);
52 51
@@ -1564,7 +1563,7 @@ static int __init parse_acpi(char *arg)
1564 } 1563 }
1565 /* acpi=rsdt use RSDT instead of XSDT */ 1564 /* acpi=rsdt use RSDT instead of XSDT */
1566 else if (strcmp(arg, "rsdt") == 0) { 1565 else if (strcmp(arg, "rsdt") == 0) {
1567 acpi_rsdt_forced = 1; 1566 acpi_gbl_do_not_use_xsdt = TRUE;
1568 } 1567 }
1569 /* "acpi=noirq" disables ACPI interrupt routing */ 1568 /* "acpi=noirq" disables ACPI interrupt routing */
1570 else if (strcmp(arg, "noirq") == 0) { 1569 else if (strcmp(arg, "noirq") == 0) {
diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
index 00c77cf78e9e..ccbf857d1d55 100644
--- a/arch/x86/kernel/apic/apic_flat_64.c
+++ b/arch/x86/kernel/apic/apic_flat_64.c
@@ -21,9 +21,7 @@
21#include <asm/apic.h> 21#include <asm/apic.h>
22#include <asm/ipi.h> 22#include <asm/ipi.h>
23 23
24#ifdef CONFIG_ACPI 24#include <linux/acpi.h>
25#include <acpi/acpi_bus.h>
26#endif
27 25
28static struct apic apic_physflat; 26static struct apic apic_physflat;
29static struct apic apic_flat; 27static struct apic apic_flat;
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index e63a5bd2a78f..4d67a7531d45 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -37,9 +37,6 @@
37#include <linux/kthread.h> 37#include <linux/kthread.h>
38#include <linux/jiffies.h> /* time_after() */ 38#include <linux/jiffies.h> /* time_after() */
39#include <linux/slab.h> 39#include <linux/slab.h>
40#ifdef CONFIG_ACPI
41#include <acpi/acpi_bus.h>
42#endif
43#include <linux/bootmem.h> 40#include <linux/bootmem.h>
44#include <linux/dmar.h> 41#include <linux/dmar.h>
45#include <linux/hpet.h> 42#include <linux/hpet.h>
diff --git a/arch/x86/pci/mmconfig-shared.c b/arch/x86/pci/mmconfig-shared.c
index 082e88129712..248642f4bab7 100644
--- a/arch/x86/pci/mmconfig-shared.c
+++ b/arch/x86/pci/mmconfig-shared.c
@@ -12,7 +12,6 @@
12 12
13#include <linux/pci.h> 13#include <linux/pci.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/acpi.h>
16#include <linux/sfi_acpi.h> 15#include <linux/sfi_acpi.h>
17#include <linux/bitmap.h> 16#include <linux/bitmap.h>
18#include <linux/dmi.h> 17#include <linux/dmi.h>
diff --git a/arch/x86/pci/mmconfig_32.c b/arch/x86/pci/mmconfig_32.c
index 5c90975cdf0f..43984bc1665a 100644
--- a/arch/x86/pci/mmconfig_32.c
+++ b/arch/x86/pci/mmconfig_32.c
@@ -14,7 +14,6 @@
14#include <linux/rcupdate.h> 14#include <linux/rcupdate.h>
15#include <asm/e820.h> 15#include <asm/e820.h>
16#include <asm/pci_x86.h> 16#include <asm/pci_x86.h>
17#include <acpi/acpi.h>
18 17
19/* Assume systems with more busses have correct MCFG */ 18/* Assume systems with more busses have correct MCFG */
20#define mmcfg_virt_addr ((void __iomem *) fix_to_virt(FIX_PCIE_MCFG)) 19#define mmcfg_virt_addr ((void __iomem *) fix_to_virt(FIX_PCIE_MCFG))
diff --git a/arch/x86/platform/olpc/olpc-xo15-sci.c b/arch/x86/platform/olpc/olpc-xo15-sci.c
index 649a12befba9..08e350e757dc 100644
--- a/arch/x86/platform/olpc/olpc-xo15-sci.c
+++ b/arch/x86/platform/olpc/olpc-xo15-sci.c
@@ -15,8 +15,7 @@
15#include <linux/power_supply.h> 15#include <linux/power_supply.h>
16#include <linux/olpc-ec.h> 16#include <linux/olpc-ec.h>
17 17
18#include <acpi/acpi_bus.h> 18#include <linux/acpi.h>
19#include <acpi/acpi_drivers.h>
20#include <asm/olpc.h> 19#include <asm/olpc.h>
21 20
22#define DRV_NAME "olpc-xo15-sci" 21#define DRV_NAME "olpc-xo15-sci"
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index 3c2e4aa529c4..e7515aa43d6b 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -32,8 +32,7 @@
32#include <linux/delay.h> 32#include <linux/delay.h>
33#include <linux/platform_device.h> 33#include <linux/platform_device.h>
34#include <linux/power_supply.h> 34#include <linux/power_supply.h>
35#include <acpi/acpi_bus.h> 35#include <linux/acpi.h>
36#include <acpi/acpi_drivers.h>
37 36
38#define PREFIX "ACPI: " 37#define PREFIX "ACPI: "
39 38
diff --git a/drivers/acpi/acpi_extlog.c b/drivers/acpi/acpi_extlog.c
index a6869e110ce5..94166680b3a3 100644
--- a/drivers/acpi/acpi_extlog.c
+++ b/drivers/acpi/acpi_extlog.c
@@ -9,7 +9,6 @@
9 9
10#include <linux/module.h> 10#include <linux/module.h>
11#include <linux/acpi.h> 11#include <linux/acpi.h>
12#include <acpi/acpi_bus.h>
13#include <linux/cper.h> 12#include <linux/cper.h>
14#include <linux/ratelimit.h> 13#include <linux/ratelimit.h>
15#include <asm/cpu.h> 14#include <asm/cpu.h>
@@ -20,11 +19,9 @@
20#define EXT_ELOG_ENTRY_MASK GENMASK_ULL(51, 0) /* elog entry address mask */ 19#define EXT_ELOG_ENTRY_MASK GENMASK_ULL(51, 0) /* elog entry address mask */
21 20
22#define EXTLOG_DSM_REV 0x0 21#define EXTLOG_DSM_REV 0x0
23#define EXTLOG_FN_QUERY 0x0
24#define EXTLOG_FN_ADDR 0x1 22#define EXTLOG_FN_ADDR 0x1
25 23
26#define FLAG_OS_OPTIN BIT(0) 24#define FLAG_OS_OPTIN BIT(0)
27#define EXTLOG_QUERY_L1_EXIST BIT(1)
28#define ELOG_ENTRY_VALID (1ULL<<63) 25#define ELOG_ENTRY_VALID (1ULL<<63)
29#define ELOG_ENTRY_LEN 0x1000 26#define ELOG_ENTRY_LEN 0x1000
30 27
@@ -43,7 +40,7 @@ struct extlog_l1_head {
43 u8 rev1[12]; 40 u8 rev1[12];
44}; 41};
45 42
46static u8 extlog_dsm_uuid[] = "663E35AF-CC10-41A4-88EA-5470AF055295"; 43static u8 extlog_dsm_uuid[] __initdata = "663E35AF-CC10-41A4-88EA-5470AF055295";
47 44
48/* L1 table related physical address */ 45/* L1 table related physical address */
49static u64 elog_base; 46static u64 elog_base;
@@ -153,62 +150,27 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,
153 return NOTIFY_DONE; 150 return NOTIFY_DONE;
154} 151}
155 152
156static int extlog_get_dsm(acpi_handle handle, int rev, int func, u64 *ret) 153static bool __init extlog_get_l1addr(void)
157{ 154{
158 struct acpi_buffer buf = {ACPI_ALLOCATE_BUFFER, NULL};
159 struct acpi_object_list input;
160 union acpi_object params[4], *obj;
161 u8 uuid[16]; 155 u8 uuid[16];
162 int i; 156 acpi_handle handle;
157 union acpi_object *obj;
163 158
164 acpi_str_to_uuid(extlog_dsm_uuid, uuid); 159 acpi_str_to_uuid(extlog_dsm_uuid, uuid);
165 input.count = 4;
166 input.pointer = params;
167 params[0].type = ACPI_TYPE_BUFFER;
168 params[0].buffer.length = 16;
169 params[0].buffer.pointer = uuid;
170 params[1].type = ACPI_TYPE_INTEGER;
171 params[1].integer.value = rev;
172 params[2].type = ACPI_TYPE_INTEGER;
173 params[2].integer.value = func;
174 params[3].type = ACPI_TYPE_PACKAGE;
175 params[3].package.count = 0;
176 params[3].package.elements = NULL;
177
178 if (ACPI_FAILURE(acpi_evaluate_object(handle, "_DSM", &input, &buf)))
179 return -1;
180
181 *ret = 0;
182 obj = (union acpi_object *)buf.pointer;
183 if (obj->type == ACPI_TYPE_INTEGER) {
184 *ret = obj->integer.value;
185 } else if (obj->type == ACPI_TYPE_BUFFER) {
186 if (obj->buffer.length <= 8) {
187 for (i = 0; i < obj->buffer.length; i++)
188 *ret |= (obj->buffer.pointer[i] << (i * 8));
189 }
190 }
191 kfree(buf.pointer);
192
193 return 0;
194}
195
196static bool extlog_get_l1addr(void)
197{
198 acpi_handle handle;
199 u64 ret;
200 160
201 if (ACPI_FAILURE(acpi_get_handle(NULL, "\\_SB", &handle))) 161 if (ACPI_FAILURE(acpi_get_handle(NULL, "\\_SB", &handle)))
202 return false; 162 return false;
203 163 if (!acpi_check_dsm(handle, uuid, EXTLOG_DSM_REV, 1 << EXTLOG_FN_ADDR))
204 if (extlog_get_dsm(handle, EXTLOG_DSM_REV, EXTLOG_FN_QUERY, &ret) ||
205 !(ret & EXTLOG_QUERY_L1_EXIST))
206 return false; 164 return false;
207 165 obj = acpi_evaluate_dsm_typed(handle, uuid, EXTLOG_DSM_REV,
208 if (extlog_get_dsm(handle, EXTLOG_DSM_REV, EXTLOG_FN_ADDR, &ret)) 166 EXTLOG_FN_ADDR, NULL, ACPI_TYPE_INTEGER);
167 if (!obj) {
209 return false; 168 return false;
169 } else {
170 l1_dirbase = obj->integer.value;
171 ACPI_FREE(obj);
172 }
210 173
211 l1_dirbase = ret;
212 /* Spec says L1 directory must be 4K aligned, bail out if it isn't */ 174 /* Spec says L1 directory must be 4K aligned, bail out if it isn't */
213 if (l1_dirbase & ((1 << 12) - 1)) { 175 if (l1_dirbase & ((1 << 12) - 1)) {
214 pr_warn(FW_BUG "L1 Directory is invalid at physical %llx\n", 176 pr_warn(FW_BUG "L1 Directory is invalid at physical %llx\n",
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index 551dad712ffe..9aeacdfca410 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -180,14 +180,14 @@ static unsigned long acpi_meminfo_end_pfn(struct acpi_memory_info *info)
180 180
181static int acpi_bind_memblk(struct memory_block *mem, void *arg) 181static int acpi_bind_memblk(struct memory_block *mem, void *arg)
182{ 182{
183 return acpi_bind_one(&mem->dev, (acpi_handle)arg); 183 return acpi_bind_one(&mem->dev, arg);
184} 184}
185 185
186static int acpi_bind_memory_blocks(struct acpi_memory_info *info, 186static int acpi_bind_memory_blocks(struct acpi_memory_info *info,
187 acpi_handle handle) 187 struct acpi_device *adev)
188{ 188{
189 return walk_memory_range(acpi_meminfo_start_pfn(info), 189 return walk_memory_range(acpi_meminfo_start_pfn(info),
190 acpi_meminfo_end_pfn(info), (void *)handle, 190 acpi_meminfo_end_pfn(info), adev,
191 acpi_bind_memblk); 191 acpi_bind_memblk);
192} 192}
193 193
@@ -197,8 +197,7 @@ static int acpi_unbind_memblk(struct memory_block *mem, void *arg)
197 return 0; 197 return 0;
198} 198}
199 199
200static void acpi_unbind_memory_blocks(struct acpi_memory_info *info, 200static void acpi_unbind_memory_blocks(struct acpi_memory_info *info)
201 acpi_handle handle)
202{ 201{
203 walk_memory_range(acpi_meminfo_start_pfn(info), 202 walk_memory_range(acpi_meminfo_start_pfn(info),
204 acpi_meminfo_end_pfn(info), NULL, acpi_unbind_memblk); 203 acpi_meminfo_end_pfn(info), NULL, acpi_unbind_memblk);
@@ -242,9 +241,9 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
242 if (result && result != -EEXIST) 241 if (result && result != -EEXIST)
243 continue; 242 continue;
244 243
245 result = acpi_bind_memory_blocks(info, handle); 244 result = acpi_bind_memory_blocks(info, mem_device->device);
246 if (result) { 245 if (result) {
247 acpi_unbind_memory_blocks(info, handle); 246 acpi_unbind_memory_blocks(info);
248 return -ENODEV; 247 return -ENODEV;
249 } 248 }
250 249
@@ -285,7 +284,7 @@ static void acpi_memory_remove_memory(struct acpi_memory_device *mem_device)
285 if (nid == NUMA_NO_NODE) 284 if (nid == NUMA_NO_NODE)
286 nid = memory_add_physaddr_to_nid(info->start_addr); 285 nid = memory_add_physaddr_to_nid(info->start_addr);
287 286
288 acpi_unbind_memory_blocks(info, handle); 287 acpi_unbind_memory_blocks(info);
289 remove_memory(nid, info->start_addr, info->length); 288 remove_memory(nid, info->start_addr, info->length);
290 list_del(&info->list); 289 list_del(&info->list);
291 kfree(info); 290 kfree(info);
diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c
index fc6008fbce35..65610c0e7243 100644
--- a/drivers/acpi/acpi_pad.c
+++ b/drivers/acpi/acpi_pad.c
@@ -28,8 +28,7 @@
28#include <linux/cpu.h> 28#include <linux/cpu.h>
29#include <linux/clockchips.h> 29#include <linux/clockchips.h>
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <acpi/acpi_bus.h> 31#include <linux/acpi.h>
32#include <acpi/acpi_drivers.h>
33#include <asm/mwait.h> 32#include <asm/mwait.h>
34 33
35#define ACPI_PROCESSOR_AGGREGATOR_CLASS "acpi_pad" 34#define ACPI_PROCESSOR_AGGREGATOR_CLASS "acpi_pad"
diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index 3c1d6b0c09a4..c9311be29a64 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -212,7 +212,7 @@ static int acpi_processor_get_info(struct acpi_device *device)
212 union acpi_object object = { 0 }; 212 union acpi_object object = { 0 };
213 struct acpi_buffer buffer = { sizeof(union acpi_object), &object }; 213 struct acpi_buffer buffer = { sizeof(union acpi_object), &object };
214 struct acpi_processor *pr = acpi_driver_data(device); 214 struct acpi_processor *pr = acpi_driver_data(device);
215 int cpu_index, device_declaration = 0; 215 int apic_id, cpu_index, device_declaration = 0;
216 acpi_status status = AE_OK; 216 acpi_status status = AE_OK;
217 static int cpu0_initialized; 217 static int cpu0_initialized;
218 unsigned long long value; 218 unsigned long long value;
@@ -258,18 +258,21 @@ static int acpi_processor_get_info(struct acpi_device *device)
258 device_declaration = 1; 258 device_declaration = 1;
259 pr->acpi_id = value; 259 pr->acpi_id = value;
260 } 260 }
261 pr->apic_id = acpi_get_apicid(pr->handle, device_declaration,
262 pr->acpi_id);
263 cpu_index = acpi_map_cpuid(pr->apic_id, pr->acpi_id);
264 261
265 /* Handle UP system running SMP kernel, with no LAPIC in MADT */ 262 apic_id = acpi_get_apicid(pr->handle, device_declaration, pr->acpi_id);
266 if (!cpu0_initialized && (cpu_index == -1) && 263 if (apic_id < 0) {
267 (num_online_cpus() == 1)) { 264 acpi_handle_err(pr->handle, "failed to get CPU APIC ID.\n");
268 cpu_index = 0; 265 return -ENODEV;
269 } 266 }
267 pr->apic_id = apic_id;
270 268
271 cpu0_initialized = 1; 269 cpu_index = acpi_map_cpuid(pr->apic_id, pr->acpi_id);
272 270 if (!cpu0_initialized) {
271 cpu0_initialized = 1;
272 /* Handle UP system running SMP kernel, with no LAPIC in MADT */
273 if ((cpu_index == -1) && (num_online_cpus() == 1))
274 cpu_index = 0;
275 }
273 pr->id = cpu_index; 276 pr->id = cpu_index;
274 277
275 /* 278 /*
@@ -282,6 +285,7 @@ static int acpi_processor_get_info(struct acpi_device *device)
282 if (ret) 285 if (ret)
283 return ret; 286 return ret;
284 } 287 }
288
285 /* 289 /*
286 * On some boxes several processors use the same processor bus id. 290 * On some boxes several processors use the same processor bus id.
287 * But they are located in different scope. For example: 291 * But they are located in different scope. For example:
@@ -395,7 +399,7 @@ static int acpi_processor_add(struct acpi_device *device,
395 goto err; 399 goto err;
396 } 400 }
397 401
398 result = acpi_bind_one(dev, pr->handle); 402 result = acpi_bind_one(dev, device);
399 if (result) 403 if (result)
400 goto err; 404 goto err;
401 405
diff --git a/drivers/acpi/acpica/acdebug.h b/drivers/acpi/acpica/acdebug.h
index a9fd0b872062..2bf3ca2b8a7a 100644
--- a/drivers/acpi/acpica/acdebug.h
+++ b/drivers/acpi/acpica/acdebug.h
@@ -113,7 +113,6 @@ void acpi_db_display_handlers(void);
113ACPI_HW_DEPENDENT_RETURN_VOID(void 113ACPI_HW_DEPENDENT_RETURN_VOID(void
114 acpi_db_generate_gpe(char *gpe_arg, 114 acpi_db_generate_gpe(char *gpe_arg,
115 char *block_arg)) 115 char *block_arg))
116
117ACPI_HW_DEPENDENT_RETURN_VOID(void acpi_db_generate_sci(void)) 116ACPI_HW_DEPENDENT_RETURN_VOID(void acpi_db_generate_sci(void))
118 117
119/* 118/*
diff --git a/drivers/acpi/acpica/acevents.h b/drivers/acpi/acpica/acevents.h
index 41abe552c7a3..0fb0adf435d6 100644
--- a/drivers/acpi/acpica/acevents.h
+++ b/drivers/acpi/acpica/acevents.h
@@ -71,9 +71,8 @@ acpi_status acpi_ev_init_global_lock_handler(void);
71 71
72ACPI_HW_DEPENDENT_RETURN_OK(acpi_status 72ACPI_HW_DEPENDENT_RETURN_OK(acpi_status
73 acpi_ev_acquire_global_lock(u16 timeout)) 73 acpi_ev_acquire_global_lock(u16 timeout))
74
75ACPI_HW_DEPENDENT_RETURN_OK(acpi_status acpi_ev_release_global_lock(void)) 74ACPI_HW_DEPENDENT_RETURN_OK(acpi_status acpi_ev_release_global_lock(void))
76 acpi_status acpi_ev_remove_global_lock_handler(void); 75acpi_status acpi_ev_remove_global_lock_handler(void);
77 76
78/* 77/*
79 * evgpe - Low-level GPE support 78 * evgpe - Low-level GPE support
@@ -133,7 +132,7 @@ acpi_status acpi_ev_gpe_initialize(void);
133ACPI_HW_DEPENDENT_RETURN_VOID(void 132ACPI_HW_DEPENDENT_RETURN_VOID(void
134 acpi_ev_update_gpes(acpi_owner_id table_owner_id)) 133 acpi_ev_update_gpes(acpi_owner_id table_owner_id))
135 134
136 acpi_status 135acpi_status
137acpi_ev_match_gpe_method(acpi_handle obj_handle, 136acpi_ev_match_gpe_method(acpi_handle obj_handle,
138 u32 level, void *context, void **return_value); 137 u32 level, void *context, void **return_value);
139 138
@@ -149,7 +148,9 @@ acpi_status
149acpi_ev_get_gpe_device(struct acpi_gpe_xrupt_info *gpe_xrupt_info, 148acpi_ev_get_gpe_device(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
150 struct acpi_gpe_block_info *gpe_block, void *context); 149 struct acpi_gpe_block_info *gpe_block, void *context);
151 150
152struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 interrupt_number); 151acpi_status
152acpi_ev_get_gpe_xrupt_block(u32 interrupt_number,
153 struct acpi_gpe_xrupt_info **gpe_xrupt_block);
153 154
154acpi_status acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt); 155acpi_status acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt);
155 156
diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index e9f1fc7f99c7..24db8e153bf0 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -119,6 +119,24 @@ bool ACPI_INIT_GLOBAL(acpi_gbl_enable_aml_debug_object, FALSE);
119u8 ACPI_INIT_GLOBAL(acpi_gbl_copy_dsdt_locally, FALSE); 119u8 ACPI_INIT_GLOBAL(acpi_gbl_copy_dsdt_locally, FALSE);
120 120
121/* 121/*
122 * Optionally ignore an XSDT if present and use the RSDT instead.
123 * Although the ACPI specification requires that an XSDT be used instead
124 * of the RSDT, the XSDT has been found to be corrupt or ill-formed on
125 * some machines. Default behavior is to use the XSDT if present.
126 */
127u8 ACPI_INIT_GLOBAL(acpi_gbl_do_not_use_xsdt, FALSE);
128
129/*
130 * Optionally use 32-bit FADT addresses if and when there is a conflict
131 * (address mismatch) between the 32-bit and 64-bit versions of the
132 * address. Although ACPICA adheres to the ACPI specification which
133 * requires the use of the corresponding 64-bit address if it is non-zero,
134 * some machines have been found to have a corrupted non-zero 64-bit
135 * address. Default is FALSE, do not favor the 32-bit addresses.
136 */
137u8 ACPI_INIT_GLOBAL(acpi_gbl_use32_bit_fadt_addresses, FALSE);
138
139/*
122 * Optionally truncate I/O addresses to 16 bits. Provides compatibility 140 * Optionally truncate I/O addresses to 16 bits. Provides compatibility
123 * with other ACPI implementations. NOTE: During ACPICA initialization, 141 * with other ACPI implementations. NOTE: During ACPICA initialization,
124 * this value is set to TRUE if any Windows OSI strings have been 142 * this value is set to TRUE if any Windows OSI strings have been
@@ -484,6 +502,18 @@ ACPI_EXTERN u32 acpi_gbl_size_of_acpi_objects;
484 502
485/***************************************************************************** 503/*****************************************************************************
486 * 504 *
505 * Application globals
506 *
507 ****************************************************************************/
508
509#ifdef ACPI_APPLICATION
510
511ACPI_FILE ACPI_INIT_GLOBAL(acpi_gbl_debug_file, NULL);
512
513#endif /* ACPI_APPLICATION */
514
515/*****************************************************************************
516 *
487 * Info/help support 517 * Info/help support
488 * 518 *
489 ****************************************************************************/ 519 ****************************************************************************/
diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
index 53ed1a8ba4f0..d95ca5449ace 100644
--- a/drivers/acpi/acpica/aclocal.h
+++ b/drivers/acpi/acpica/aclocal.h
@@ -1038,15 +1038,16 @@ struct acpi_external_list {
1038 struct acpi_external_list *next; 1038 struct acpi_external_list *next;
1039 u32 value; 1039 u32 value;
1040 u16 length; 1040 u16 length;
1041 u16 flags;
1041 u8 type; 1042 u8 type;
1042 u8 flags;
1043 u8 resolved;
1044 u8 emitted;
1045}; 1043};
1046 1044
1047/* Values for Flags field above */ 1045/* Values for Flags field above */
1048 1046
1049#define ACPI_IPATH_ALLOCATED 0x01 1047#define ACPI_EXT_RESOLVED_REFERENCE 0x01 /* Object was resolved during cross ref */
1048#define ACPI_EXT_ORIGIN_FROM_FILE 0x02 /* External came from a file */
1049#define ACPI_EXT_INTERNAL_PATH_ALLOCATED 0x04 /* Deallocate internal path on completion */
1050#define ACPI_EXT_EXTERNAL_EMITTED 0x08 /* External() statement has been emitted */
1050 1051
1051struct acpi_external_file { 1052struct acpi_external_file {
1052 char *path; 1053 char *path;
diff --git a/drivers/acpi/acpica/dsfield.c b/drivers/acpi/acpica/dsfield.c
index 2d4c07322576..e7a57c554e84 100644
--- a/drivers/acpi/acpica/dsfield.c
+++ b/drivers/acpi/acpica/dsfield.c
@@ -105,7 +105,7 @@ acpi_ds_create_external_region(acpi_status lookup_status,
105 * operation_region not found. Generate an External for it, and 105 * operation_region not found. Generate an External for it, and
106 * insert the name into the namespace. 106 * insert the name into the namespace.
107 */ 107 */
108 acpi_dm_add_to_external_list(op, path, ACPI_TYPE_REGION, 0); 108 acpi_dm_add_op_to_external_list(op, path, ACPI_TYPE_REGION, 0, 0);
109 status = acpi_ns_lookup(walk_state->scope_info, path, ACPI_TYPE_REGION, 109 status = acpi_ns_lookup(walk_state->scope_info, path, ACPI_TYPE_REGION,
110 ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT, 110 ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT,
111 walk_state, node); 111 walk_state, node);
diff --git a/drivers/acpi/acpica/dsutils.c b/drivers/acpi/acpica/dsutils.c
index ade44e49deb4..d7f53fb2979a 100644
--- a/drivers/acpi/acpica/dsutils.c
+++ b/drivers/acpi/acpica/dsutils.c
@@ -727,27 +727,26 @@ acpi_ds_create_operands(struct acpi_walk_state *walk_state,
727 index++; 727 index++;
728 } 728 }
729 729
730 index--; 730 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
731 "NumOperands %d, ArgCount %d, Index %d\n",
732 walk_state->num_operands, arg_count, index));
731 733
732 /* It is the appropriate order to get objects from the Result stack */ 734 /* Create the interpreter arguments, in reverse order */
733 735
736 index--;
734 for (i = 0; i < arg_count; i++) { 737 for (i = 0; i < arg_count; i++) {
735 arg = arguments[index]; 738 arg = arguments[index];
736 739 walk_state->operand_index = (u8)index;
737 /* Force the filling of the operand stack in inverse order */
738
739 walk_state->operand_index = (u8) index;
740 740
741 status = acpi_ds_create_operand(walk_state, arg, index); 741 status = acpi_ds_create_operand(walk_state, arg, index);
742 if (ACPI_FAILURE(status)) { 742 if (ACPI_FAILURE(status)) {
743 goto cleanup; 743 goto cleanup;
744 } 744 }
745 745
746 index--;
747
748 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 746 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
749 "Arg #%u (%p) done, Arg1=%p\n", index, arg, 747 "Created Arg #%u (%p) %u args total\n",
750 first_arg)); 748 index, arg, arg_count));
749 index--;
751 } 750 }
752 751
753 return_ACPI_STATUS(status); 752 return_ACPI_STATUS(status);
diff --git a/drivers/acpi/acpica/dswload.c b/drivers/acpi/acpica/dswload.c
index 95e681a36f9c..2dbe109727c8 100644
--- a/drivers/acpi/acpica/dswload.c
+++ b/drivers/acpi/acpica/dswload.c
@@ -181,8 +181,8 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
181 * Target of Scope() not found. Generate an External for it, and 181 * Target of Scope() not found. Generate an External for it, and
182 * insert the name into the namespace. 182 * insert the name into the namespace.
183 */ 183 */
184 acpi_dm_add_to_external_list(op, path, ACPI_TYPE_DEVICE, 184 acpi_dm_add_op_to_external_list(op, path,
185 0); 185 ACPI_TYPE_DEVICE, 0, 0);
186 status = 186 status =
187 acpi_ns_lookup(walk_state->scope_info, path, 187 acpi_ns_lookup(walk_state->scope_info, path,
188 object_type, ACPI_IMODE_LOAD_PASS1, 188 object_type, ACPI_IMODE_LOAD_PASS1,
diff --git a/drivers/acpi/acpica/evgpeblk.c b/drivers/acpi/acpica/evgpeblk.c
index a9e76bc4ad97..a31e549e64cc 100644
--- a/drivers/acpi/acpica/evgpeblk.c
+++ b/drivers/acpi/acpica/evgpeblk.c
@@ -87,9 +87,9 @@ acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block,
87 return_ACPI_STATUS(status); 87 return_ACPI_STATUS(status);
88 } 88 }
89 89
90 gpe_xrupt_block = acpi_ev_get_gpe_xrupt_block(interrupt_number); 90 status =
91 if (!gpe_xrupt_block) { 91 acpi_ev_get_gpe_xrupt_block(interrupt_number, &gpe_xrupt_block);
92 status = AE_NO_MEMORY; 92 if (ACPI_FAILURE(status)) {
93 goto unlock_and_exit; 93 goto unlock_and_exit;
94 } 94 }
95 95
@@ -112,7 +112,7 @@ acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block,
112 acpi_os_release_lock(acpi_gbl_gpe_lock, flags); 112 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
113 113
114unlock_and_exit: 114unlock_and_exit:
115 status = acpi_ut_release_mutex(ACPI_MTX_EVENTS); 115 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
116 return_ACPI_STATUS(status); 116 return_ACPI_STATUS(status);
117} 117}
118 118
diff --git a/drivers/acpi/acpica/evgpeutil.c b/drivers/acpi/acpica/evgpeutil.c
index d3f5e1e2a2b1..4d764e847a08 100644
--- a/drivers/acpi/acpica/evgpeutil.c
+++ b/drivers/acpi/acpica/evgpeutil.c
@@ -197,8 +197,9 @@ acpi_ev_get_gpe_device(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
197 * FUNCTION: acpi_ev_get_gpe_xrupt_block 197 * FUNCTION: acpi_ev_get_gpe_xrupt_block
198 * 198 *
199 * PARAMETERS: interrupt_number - Interrupt for a GPE block 199 * PARAMETERS: interrupt_number - Interrupt for a GPE block
200 * gpe_xrupt_block - Where the block is returned
200 * 201 *
201 * RETURN: A GPE interrupt block 202 * RETURN: Status
202 * 203 *
203 * DESCRIPTION: Get or Create a GPE interrupt block. There is one interrupt 204 * DESCRIPTION: Get or Create a GPE interrupt block. There is one interrupt
204 * block per unique interrupt level used for GPEs. Should be 205 * block per unique interrupt level used for GPEs. Should be
@@ -207,7 +208,9 @@ acpi_ev_get_gpe_device(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
207 * 208 *
208 ******************************************************************************/ 209 ******************************************************************************/
209 210
210struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 interrupt_number) 211acpi_status
212acpi_ev_get_gpe_xrupt_block(u32 interrupt_number,
213 struct acpi_gpe_xrupt_info ** gpe_xrupt_block)
211{ 214{
212 struct acpi_gpe_xrupt_info *next_gpe_xrupt; 215 struct acpi_gpe_xrupt_info *next_gpe_xrupt;
213 struct acpi_gpe_xrupt_info *gpe_xrupt; 216 struct acpi_gpe_xrupt_info *gpe_xrupt;
@@ -221,7 +224,8 @@ struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 interrupt_number)
221 next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head; 224 next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head;
222 while (next_gpe_xrupt) { 225 while (next_gpe_xrupt) {
223 if (next_gpe_xrupt->interrupt_number == interrupt_number) { 226 if (next_gpe_xrupt->interrupt_number == interrupt_number) {
224 return_PTR(next_gpe_xrupt); 227 *gpe_xrupt_block = next_gpe_xrupt;
228 return_ACPI_STATUS(AE_OK);
225 } 229 }
226 230
227 next_gpe_xrupt = next_gpe_xrupt->next; 231 next_gpe_xrupt = next_gpe_xrupt->next;
@@ -231,7 +235,7 @@ struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 interrupt_number)
231 235
232 gpe_xrupt = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_gpe_xrupt_info)); 236 gpe_xrupt = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_gpe_xrupt_info));
233 if (!gpe_xrupt) { 237 if (!gpe_xrupt) {
234 return_PTR(NULL); 238 return_ACPI_STATUS(AE_NO_MEMORY);
235 } 239 }
236 240
237 gpe_xrupt->interrupt_number = interrupt_number; 241 gpe_xrupt->interrupt_number = interrupt_number;
@@ -250,6 +254,7 @@ struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 interrupt_number)
250 } else { 254 } else {
251 acpi_gbl_gpe_xrupt_list_head = gpe_xrupt; 255 acpi_gbl_gpe_xrupt_list_head = gpe_xrupt;
252 } 256 }
257
253 acpi_os_release_lock(acpi_gbl_gpe_lock, flags); 258 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
254 259
255 /* Install new interrupt handler if not SCI_INT */ 260 /* Install new interrupt handler if not SCI_INT */
@@ -259,14 +264,15 @@ struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 interrupt_number)
259 acpi_ev_gpe_xrupt_handler, 264 acpi_ev_gpe_xrupt_handler,
260 gpe_xrupt); 265 gpe_xrupt);
261 if (ACPI_FAILURE(status)) { 266 if (ACPI_FAILURE(status)) {
262 ACPI_ERROR((AE_INFO, 267 ACPI_EXCEPTION((AE_INFO, status,
263 "Could not install GPE interrupt handler at level 0x%X", 268 "Could not install GPE interrupt handler at level 0x%X",
264 interrupt_number)); 269 interrupt_number));
265 return_PTR(NULL); 270 return_ACPI_STATUS(status);
266 } 271 }
267 } 272 }
268 273
269 return_PTR(gpe_xrupt); 274 *gpe_xrupt_block = gpe_xrupt;
275 return_ACPI_STATUS(AE_OK);
270} 276}
271 277
272/******************************************************************************* 278/*******************************************************************************
diff --git a/drivers/acpi/acpica/exresnte.c b/drivers/acpi/acpica/exresnte.c
index acd34f599313..7ca6925a87ca 100644
--- a/drivers/acpi/acpica/exresnte.c
+++ b/drivers/acpi/acpica/exresnte.c
@@ -124,7 +124,8 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr,
124 } 124 }
125 125
126 if (!source_desc) { 126 if (!source_desc) {
127 ACPI_ERROR((AE_INFO, "No object attached to node %p", node)); 127 ACPI_ERROR((AE_INFO, "No object attached to node [%4.4s] %p",
128 node->name.ascii, node));
128 return_ACPI_STATUS(AE_AML_NO_OPERAND); 129 return_ACPI_STATUS(AE_AML_NO_OPERAND);
129 } 130 }
130 131
diff --git a/drivers/acpi/acpica/nsxfeval.c b/drivers/acpi/acpica/nsxfeval.c
index e973e311f856..1f0c28ba50df 100644
--- a/drivers/acpi/acpica/nsxfeval.c
+++ b/drivers/acpi/acpica/nsxfeval.c
@@ -84,7 +84,7 @@ acpi_evaluate_object_typed(acpi_handle handle,
84 acpi_object_type return_type) 84 acpi_object_type return_type)
85{ 85{
86 acpi_status status; 86 acpi_status status;
87 u8 must_free = FALSE; 87 u8 free_buffer_on_error = FALSE;
88 88
89 ACPI_FUNCTION_TRACE(acpi_evaluate_object_typed); 89 ACPI_FUNCTION_TRACE(acpi_evaluate_object_typed);
90 90
@@ -95,14 +95,13 @@ acpi_evaluate_object_typed(acpi_handle handle,
95 } 95 }
96 96
97 if (return_buffer->length == ACPI_ALLOCATE_BUFFER) { 97 if (return_buffer->length == ACPI_ALLOCATE_BUFFER) {
98 must_free = TRUE; 98 free_buffer_on_error = TRUE;
99 } 99 }
100 100
101 /* Evaluate the object */ 101 /* Evaluate the object */
102 102
103 status = 103 status = acpi_evaluate_object(handle, pathname,
104 acpi_evaluate_object(handle, pathname, external_params, 104 external_params, return_buffer);
105 return_buffer);
106 if (ACPI_FAILURE(status)) { 105 if (ACPI_FAILURE(status)) {
107 return_ACPI_STATUS(status); 106 return_ACPI_STATUS(status);
108 } 107 }
@@ -135,11 +134,15 @@ acpi_evaluate_object_typed(acpi_handle handle,
135 pointer)->type), 134 pointer)->type),
136 acpi_ut_get_type_name(return_type))); 135 acpi_ut_get_type_name(return_type)));
137 136
138 if (must_free) { 137 if (free_buffer_on_error) {
139 138 /*
140 /* Caller used ACPI_ALLOCATE_BUFFER, free the return buffer */ 139 * Free a buffer created via ACPI_ALLOCATE_BUFFER.
141 140 * Note: We use acpi_os_free here because acpi_os_allocate was used
142 ACPI_FREE_BUFFER(*return_buffer); 141 * to allocate the buffer. This purposefully bypasses the
142 * (optionally enabled) allocation tracking mechanism since we
143 * only want to track internal allocations.
144 */
145 acpi_os_free(return_buffer->pointer);
143 return_buffer->pointer = NULL; 146 return_buffer->pointer = NULL;
144 } 147 }
145 148
diff --git a/drivers/acpi/acpica/psopinfo.c b/drivers/acpi/acpica/psopinfo.c
index 9ba5301e5751..b0c9787dbe61 100644
--- a/drivers/acpi/acpica/psopinfo.c
+++ b/drivers/acpi/acpica/psopinfo.c
@@ -71,6 +71,10 @@ static const u8 acpi_gbl_argument_count[] =
71 71
72const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode) 72const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode)
73{ 73{
74#ifdef ACPI_DEBUG_OUTPUT
75 const char *opcode_name = "Unknown AML opcode";
76#endif
77
74 ACPI_FUNCTION_NAME(ps_get_opcode_info); 78 ACPI_FUNCTION_NAME(ps_get_opcode_info);
75 79
76 /* 80 /*
@@ -92,11 +96,54 @@ const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode)
92 return (&acpi_gbl_aml_op_info 96 return (&acpi_gbl_aml_op_info
93 [acpi_gbl_long_op_index[(u8)opcode]]); 97 [acpi_gbl_long_op_index[(u8)opcode]]);
94 } 98 }
99#if defined ACPI_ASL_COMPILER && defined ACPI_DEBUG_OUTPUT
100#include "asldefine.h"
101
102 switch (opcode) {
103 case AML_RAW_DATA_BYTE:
104 opcode_name = "-Raw Data Byte-";
105 break;
106
107 case AML_RAW_DATA_WORD:
108 opcode_name = "-Raw Data Word-";
109 break;
110
111 case AML_RAW_DATA_DWORD:
112 opcode_name = "-Raw Data Dword-";
113 break;
114
115 case AML_RAW_DATA_QWORD:
116 opcode_name = "-Raw Data Qword-";
117 break;
118
119 case AML_RAW_DATA_BUFFER:
120 opcode_name = "-Raw Data Buffer-";
121 break;
122
123 case AML_RAW_DATA_CHAIN:
124 opcode_name = "-Raw Data Buffer Chain-";
125 break;
126
127 case AML_PACKAGE_LENGTH:
128 opcode_name = "-Package Length-";
129 break;
130
131 case AML_UNASSIGNED_OPCODE:
132 opcode_name = "-Unassigned Opcode-";
133 break;
134
135 case AML_DEFAULT_ARG_OP:
136 opcode_name = "-Default Arg-";
137 break;
138
139 default:
140 break;
141 }
142#endif
95 143
96 /* Unknown AML opcode */ 144 /* Unknown AML opcode */
97 145
98 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 146 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%s [%4.4X]\n", opcode_name, opcode));
99 "Unknown AML opcode [%4.4X]\n", opcode));
100 147
101 return (&acpi_gbl_aml_op_info[_UNK]); 148 return (&acpi_gbl_aml_op_info[_UNK]);
102} 149}
diff --git a/drivers/acpi/acpica/tbfadt.c b/drivers/acpi/acpica/tbfadt.c
index 9d99f2189693..8f89263ac47e 100644
--- a/drivers/acpi/acpica/tbfadt.c
+++ b/drivers/acpi/acpica/tbfadt.c
@@ -56,10 +56,11 @@ acpi_tb_init_generic_address(struct acpi_generic_address *generic_address,
56 56
57static void acpi_tb_convert_fadt(void); 57static void acpi_tb_convert_fadt(void);
58 58
59static void acpi_tb_validate_fadt(void);
60
61static void acpi_tb_setup_fadt_registers(void); 59static void acpi_tb_setup_fadt_registers(void);
62 60
61static u64
62acpi_tb_select_address(char *register_name, u32 address32, u64 address64);
63
63/* Table for conversion of FADT to common internal format and FADT validation */ 64/* Table for conversion of FADT to common internal format and FADT validation */
64 65
65typedef struct acpi_fadt_info { 66typedef struct acpi_fadt_info {
@@ -175,6 +176,7 @@ static struct acpi_fadt_pm_info fadt_pm_info_table[] = {
175 * space_id - ACPI Space ID for this register 176 * space_id - ACPI Space ID for this register
176 * byte_width - Width of this register 177 * byte_width - Width of this register
177 * address - Address of the register 178 * address - Address of the register
179 * register_name - ASCII name of the ACPI register
178 * 180 *
179 * RETURN: None 181 * RETURN: None
180 * 182 *
@@ -220,6 +222,68 @@ acpi_tb_init_generic_address(struct acpi_generic_address *generic_address,
220 222
221/******************************************************************************* 223/*******************************************************************************
222 * 224 *
225 * FUNCTION: acpi_tb_select_address
226 *
227 * PARAMETERS: register_name - ASCII name of the ACPI register
228 * address32 - 32-bit address of the register
229 * address64 - 64-bit address of the register
230 *
231 * RETURN: The resolved 64-bit address
232 *
233 * DESCRIPTION: Select between 32-bit and 64-bit versions of addresses within
234 * the FADT. Used for the FACS and DSDT addresses.
235 *
236 * NOTES:
237 *
238 * Check for FACS and DSDT address mismatches. An address mismatch between
239 * the 32-bit and 64-bit address fields (FIRMWARE_CTRL/X_FIRMWARE_CTRL and
240 * DSDT/X_DSDT) could be a corrupted address field or it might indicate
241 * the presence of two FACS or two DSDT tables.
242 *
243 * November 2013:
244 * By default, as per the ACPICA specification, a valid 64-bit address is
245 * used regardless of the value of the 32-bit address. However, this
246 * behavior can be overridden via the acpi_gbl_use32_bit_fadt_addresses flag.
247 *
248 ******************************************************************************/
249
250static u64
251acpi_tb_select_address(char *register_name, u32 address32, u64 address64)
252{
253
254 if (!address64) {
255
256 /* 64-bit address is zero, use 32-bit address */
257
258 return ((u64)address32);
259 }
260
261 if (address32 && (address64 != (u64)address32)) {
262
263 /* Address mismatch between 32-bit and 64-bit versions */
264
265 ACPI_BIOS_WARNING((AE_INFO,
266 "32/64X %s address mismatch in FADT: "
267 "0x%8.8X/0x%8.8X%8.8X, using %u-bit address",
268 register_name, address32,
269 ACPI_FORMAT_UINT64(address64),
270 acpi_gbl_use32_bit_fadt_addresses ? 32 :
271 64));
272
273 /* 32-bit address override */
274
275 if (acpi_gbl_use32_bit_fadt_addresses) {
276 return ((u64)address32);
277 }
278 }
279
280 /* Default is to use the 64-bit address */
281
282 return (address64);
283}
284
285/*******************************************************************************
286 *
223 * FUNCTION: acpi_tb_parse_fadt 287 * FUNCTION: acpi_tb_parse_fadt
224 * 288 *
225 * PARAMETERS: table_index - Index for the FADT 289 * PARAMETERS: table_index - Index for the FADT
@@ -331,10 +395,6 @@ void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length)
331 395
332 acpi_tb_convert_fadt(); 396 acpi_tb_convert_fadt();
333 397
334 /* Validate FADT values now, before we make any changes */
335
336 acpi_tb_validate_fadt();
337
338 /* Initialize the global ACPI register structures */ 398 /* Initialize the global ACPI register structures */
339 399
340 acpi_tb_setup_fadt_registers(); 400 acpi_tb_setup_fadt_registers();
@@ -344,66 +404,55 @@ void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length)
344 * 404 *
345 * FUNCTION: acpi_tb_convert_fadt 405 * FUNCTION: acpi_tb_convert_fadt
346 * 406 *
347 * PARAMETERS: None, uses acpi_gbl_FADT 407 * PARAMETERS: none - acpi_gbl_FADT is used.
348 * 408 *
349 * RETURN: None 409 * RETURN: None
350 * 410 *
351 * DESCRIPTION: Converts all versions of the FADT to a common internal format. 411 * DESCRIPTION: Converts all versions of the FADT to a common internal format.
352 * Expand 32-bit addresses to 64-bit as necessary. 412 * Expand 32-bit addresses to 64-bit as necessary. Also validate
413 * important fields within the FADT.
353 * 414 *
354 * NOTE: acpi_gbl_FADT must be of size (struct acpi_table_fadt), 415 * NOTE: acpi_gbl_FADT must be of size (struct acpi_table_fadt), and must
355 * and must contain a copy of the actual FADT. 416 * contain a copy of the actual BIOS-provided FADT.
356 * 417 *
357 * Notes on 64-bit register addresses: 418 * Notes on 64-bit register addresses:
358 * 419 *
359 * After this FADT conversion, later ACPICA code will only use the 64-bit "X" 420 * After this FADT conversion, later ACPICA code will only use the 64-bit "X"
360 * fields of the FADT for all ACPI register addresses. 421 * fields of the FADT for all ACPI register addresses.
361 * 422 *
362 * The 64-bit "X" fields are optional extensions to the original 32-bit FADT 423 * The 64-bit X fields are optional extensions to the original 32-bit FADT
363 * V1.0 fields. Even if they are present in the FADT, they are optional and 424 * V1.0 fields. Even if they are present in the FADT, they are optional and
364 * are unused if the BIOS sets them to zero. Therefore, we must copy/expand 425 * are unused if the BIOS sets them to zero. Therefore, we must copy/expand
365 * 32-bit V1.0 fields if the corresponding X field is zero. 426 * 32-bit V1.0 fields to the 64-bit X fields if the the 64-bit X field is
427 * originally zero.
366 * 428 *
367 * For ACPI 1.0 FADTs, all 32-bit address fields are expanded to the 429 * For ACPI 1.0 FADTs (that contain no 64-bit addresses), all 32-bit address
368 * corresponding "X" fields in the internal FADT. 430 * fields are expanded to the corresponding 64-bit X fields in the internal
431 * common FADT.
369 * 432 *
370 * For ACPI 2.0+ FADTs, all valid (non-zero) 32-bit address fields are expanded 433 * For ACPI 2.0+ FADTs, all valid (non-zero) 32-bit address fields are expanded
371 * to the corresponding 64-bit X fields. For compatibility with other ACPI 434 * to the corresponding 64-bit X fields, if the 64-bit field is originally
372 * implementations, we ignore the 64-bit field if the 32-bit field is valid, 435 * zero. Adhering to the ACPI specification, we completely ignore the 32-bit
373 * regardless of whether the host OS is 32-bit or 64-bit. 436 * field if the 64-bit field is valid, regardless of whether the host OS is
437 * 32-bit or 64-bit.
438 *
439 * Possible additional checks:
440 * (acpi_gbl_FADT.pm1_event_length >= 4)
441 * (acpi_gbl_FADT.pm1_control_length >= 2)
442 * (acpi_gbl_FADT.pm_timer_length >= 4)
443 * Gpe block lengths must be multiple of 2
374 * 444 *
375 ******************************************************************************/ 445 ******************************************************************************/
376 446
377static void acpi_tb_convert_fadt(void) 447static void acpi_tb_convert_fadt(void)
378{ 448{
449 char *name;
379 struct acpi_generic_address *address64; 450 struct acpi_generic_address *address64;
380 u32 address32; 451 u32 address32;
452 u8 length;
381 u32 i; 453 u32 i;
382 454
383 /* 455 /*
384 * Expand the 32-bit FACS and DSDT addresses to 64-bit as necessary.
385 * Later code will always use the X 64-bit field. Also, check for an
386 * address mismatch between the 32-bit and 64-bit address fields
387 * (FIRMWARE_CTRL/X_FIRMWARE_CTRL, DSDT/X_DSDT) which would indicate
388 * the presence of two FACS or two DSDT tables.
389 */
390 if (!acpi_gbl_FADT.Xfacs) {
391 acpi_gbl_FADT.Xfacs = (u64) acpi_gbl_FADT.facs;
392 } else if (acpi_gbl_FADT.facs &&
393 (acpi_gbl_FADT.Xfacs != (u64) acpi_gbl_FADT.facs)) {
394 ACPI_WARNING((AE_INFO,
395 "32/64 FACS address mismatch in FADT - two FACS tables!"));
396 }
397
398 if (!acpi_gbl_FADT.Xdsdt) {
399 acpi_gbl_FADT.Xdsdt = (u64) acpi_gbl_FADT.dsdt;
400 } else if (acpi_gbl_FADT.dsdt &&
401 (acpi_gbl_FADT.Xdsdt != (u64) acpi_gbl_FADT.dsdt)) {
402 ACPI_WARNING((AE_INFO,
403 "32/64 DSDT address mismatch in FADT - two DSDT tables!"));
404 }
405
406 /*
407 * For ACPI 1.0 FADTs (revision 1 or 2), ensure that reserved fields which 456 * For ACPI 1.0 FADTs (revision 1 or 2), ensure that reserved fields which
408 * should be zero are indeed zero. This will workaround BIOSs that 457 * should be zero are indeed zero. This will workaround BIOSs that
409 * inadvertently place values in these fields. 458 * inadvertently place values in these fields.
@@ -421,119 +470,24 @@ static void acpi_tb_convert_fadt(void)
421 acpi_gbl_FADT.boot_flags = 0; 470 acpi_gbl_FADT.boot_flags = 0;
422 } 471 }
423 472
424 /* Update the local FADT table header length */
425
426 acpi_gbl_FADT.header.length = sizeof(struct acpi_table_fadt);
427
428 /* 473 /*
429 * Expand the ACPI 1.0 32-bit addresses to the ACPI 2.0 64-bit "X" 474 * Now we can update the local FADT length to the length of the
430 * generic address structures as necessary. Later code will always use 475 * current FADT version as defined by the ACPI specification.
431 * the 64-bit address structures. 476 * Thus, we will have a common FADT internally.
432 *
433 * March 2009:
434 * We now always use the 32-bit address if it is valid (non-null). This
435 * is not in accordance with the ACPI specification which states that
436 * the 64-bit address supersedes the 32-bit version, but we do this for
437 * compatibility with other ACPI implementations. Most notably, in the
438 * case where both the 32 and 64 versions are non-null, we use the 32-bit
439 * version. This is the only address that is guaranteed to have been
440 * tested by the BIOS manufacturer.
441 */ 477 */
442 for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) { 478 acpi_gbl_FADT.header.length = sizeof(struct acpi_table_fadt);
443 address32 = *ACPI_ADD_PTR(u32,
444 &acpi_gbl_FADT,
445 fadt_info_table[i].address32);
446
447 address64 = ACPI_ADD_PTR(struct acpi_generic_address,
448 &acpi_gbl_FADT,
449 fadt_info_table[i].address64);
450
451 /*
452 * If both 32- and 64-bit addresses are valid (non-zero),
453 * they must match.
454 */
455 if (address64->address && address32 &&
456 (address64->address != (u64)address32)) {
457 ACPI_BIOS_ERROR((AE_INFO,
458 "32/64X address mismatch in FADT/%s: "
459 "0x%8.8X/0x%8.8X%8.8X, using 32",
460 fadt_info_table[i].name, address32,
461 ACPI_FORMAT_UINT64(address64->
462 address)));
463 }
464
465 /* Always use 32-bit address if it is valid (non-null) */
466
467 if (address32) {
468 /*
469 * Copy the 32-bit address to the 64-bit GAS structure. The
470 * Space ID is always I/O for 32-bit legacy address fields
471 */
472 acpi_tb_init_generic_address(address64,
473 ACPI_ADR_SPACE_SYSTEM_IO,
474 *ACPI_ADD_PTR(u8,
475 &acpi_gbl_FADT,
476 fadt_info_table
477 [i].length),
478 (u64) address32,
479 fadt_info_table[i].name);
480 }
481 }
482}
483
484/*******************************************************************************
485 *
486 * FUNCTION: acpi_tb_validate_fadt
487 *
488 * PARAMETERS: table - Pointer to the FADT to be validated
489 *
490 * RETURN: None
491 *
492 * DESCRIPTION: Validate various important fields within the FADT. If a problem
493 * is found, issue a message, but no status is returned.
494 * Used by both the table manager and the disassembler.
495 *
496 * Possible additional checks:
497 * (acpi_gbl_FADT.pm1_event_length >= 4)
498 * (acpi_gbl_FADT.pm1_control_length >= 2)
499 * (acpi_gbl_FADT.pm_timer_length >= 4)
500 * Gpe block lengths must be multiple of 2
501 *
502 ******************************************************************************/
503
504static void acpi_tb_validate_fadt(void)
505{
506 char *name;
507 struct acpi_generic_address *address64;
508 u8 length;
509 u32 i;
510 479
511 /* 480 /*
512 * Check for FACS and DSDT address mismatches. An address mismatch between 481 * Expand the 32-bit FACS and DSDT addresses to 64-bit as necessary.
513 * the 32-bit and 64-bit address fields (FIRMWARE_CTRL/X_FIRMWARE_CTRL and 482 * Later ACPICA code will always use the X 64-bit field.
514 * DSDT/X_DSDT) would indicate the presence of two FACS or two DSDT tables.
515 */ 483 */
516 if (acpi_gbl_FADT.facs && 484 acpi_gbl_FADT.Xfacs = acpi_tb_select_address("FACS",
517 (acpi_gbl_FADT.Xfacs != (u64)acpi_gbl_FADT.facs)) { 485 acpi_gbl_FADT.facs,
518 ACPI_BIOS_WARNING((AE_INFO, 486 acpi_gbl_FADT.Xfacs);
519 "32/64X FACS address mismatch in FADT - "
520 "0x%8.8X/0x%8.8X%8.8X, using 32",
521 acpi_gbl_FADT.facs,
522 ACPI_FORMAT_UINT64(acpi_gbl_FADT.Xfacs)));
523
524 acpi_gbl_FADT.Xfacs = (u64)acpi_gbl_FADT.facs;
525 }
526
527 if (acpi_gbl_FADT.dsdt &&
528 (acpi_gbl_FADT.Xdsdt != (u64)acpi_gbl_FADT.dsdt)) {
529 ACPI_BIOS_WARNING((AE_INFO,
530 "32/64X DSDT address mismatch in FADT - "
531 "0x%8.8X/0x%8.8X%8.8X, using 32",
532 acpi_gbl_FADT.dsdt,
533 ACPI_FORMAT_UINT64(acpi_gbl_FADT.Xdsdt)));
534 487
535 acpi_gbl_FADT.Xdsdt = (u64)acpi_gbl_FADT.dsdt; 488 acpi_gbl_FADT.Xdsdt = acpi_tb_select_address("DSDT",
536 } 489 acpi_gbl_FADT.dsdt,
490 acpi_gbl_FADT.Xdsdt);
537 491
538 /* If Hardware Reduced flag is set, we are all done */ 492 /* If Hardware Reduced flag is set, we are all done */
539 493
@@ -545,18 +499,95 @@ static void acpi_tb_validate_fadt(void)
545 499
546 for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) { 500 for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) {
547 /* 501 /*
548 * Generate pointer to the 64-bit address, get the register 502 * Get the 32-bit and 64-bit addresses, as well as the register
549 * length (width) and the register name 503 * length and register name.
550 */ 504 */
505 address32 = *ACPI_ADD_PTR(u32,
506 &acpi_gbl_FADT,
507 fadt_info_table[i].address32);
508
551 address64 = ACPI_ADD_PTR(struct acpi_generic_address, 509 address64 = ACPI_ADD_PTR(struct acpi_generic_address,
552 &acpi_gbl_FADT, 510 &acpi_gbl_FADT,
553 fadt_info_table[i].address64); 511 fadt_info_table[i].address64);
554 length = 512
555 *ACPI_ADD_PTR(u8, &acpi_gbl_FADT, 513 length = *ACPI_ADD_PTR(u8,
556 fadt_info_table[i].length); 514 &acpi_gbl_FADT,
515 fadt_info_table[i].length);
516
557 name = fadt_info_table[i].name; 517 name = fadt_info_table[i].name;
558 518
559 /* 519 /*
520 * Expand the ACPI 1.0 32-bit addresses to the ACPI 2.0 64-bit "X"
521 * generic address structures as necessary. Later code will always use
522 * the 64-bit address structures.
523 *
524 * November 2013:
525 * Now always use the 64-bit address if it is valid (non-zero), in
526 * accordance with the ACPI specification which states that a 64-bit
527 * address supersedes the 32-bit version. This behavior can be
528 * overridden by the acpi_gbl_use32_bit_fadt_addresses flag.
529 *
530 * During 64-bit address construction and verification,
531 * these cases are handled:
532 *
533 * Address32 zero, Address64 [don't care] - Use Address64
534 *
535 * Address32 non-zero, Address64 zero - Copy/use Address32
536 * Address32 non-zero == Address64 non-zero - Use Address64
537 * Address32 non-zero != Address64 non-zero - Warning, use Address64
538 *
539 * Override: if acpi_gbl_use32_bit_fadt_addresses is TRUE, and:
540 * Address32 non-zero != Address64 non-zero - Warning, copy/use Address32
541 *
542 * Note: space_id is always I/O for 32-bit legacy address fields
543 */
544 if (address32) {
545 if (!address64->address) {
546
547 /* 64-bit address is zero, use 32-bit address */
548
549 acpi_tb_init_generic_address(address64,
550 ACPI_ADR_SPACE_SYSTEM_IO,
551 *ACPI_ADD_PTR(u8,
552 &acpi_gbl_FADT,
553 fadt_info_table
554 [i].
555 length),
556 (u64)address32,
557 name);
558 } else if (address64->address != (u64)address32) {
559
560 /* Address mismatch */
561
562 ACPI_BIOS_WARNING((AE_INFO,
563 "32/64X address mismatch in FADT/%s: "
564 "0x%8.8X/0x%8.8X%8.8X, using %u-bit address",
565 name, address32,
566 ACPI_FORMAT_UINT64
567 (address64->address),
568 acpi_gbl_use32_bit_fadt_addresses
569 ? 32 : 64));
570
571 if (acpi_gbl_use32_bit_fadt_addresses) {
572
573 /* 32-bit address override */
574
575 acpi_tb_init_generic_address(address64,
576 ACPI_ADR_SPACE_SYSTEM_IO,
577 *ACPI_ADD_PTR
578 (u8,
579 &acpi_gbl_FADT,
580 fadt_info_table
581 [i].
582 length),
583 (u64)
584 address32,
585 name);
586 }
587 }
588 }
589
590 /*
560 * For each extended field, check for length mismatch between the 591 * For each extended field, check for length mismatch between the
561 * legacy length field and the corresponding 64-bit X length field. 592 * legacy length field and the corresponding 64-bit X length field.
562 * Note: If the legacy length field is > 0xFF bits, ignore this 593 * Note: If the legacy length field is > 0xFF bits, ignore this
diff --git a/drivers/acpi/acpica/tbutils.c b/drivers/acpi/acpica/tbutils.c
index 3d6bb83aa7e7..6412d3c301cb 100644
--- a/drivers/acpi/acpica/tbutils.c
+++ b/drivers/acpi/acpica/tbutils.c
@@ -49,69 +49,11 @@
49ACPI_MODULE_NAME("tbutils") 49ACPI_MODULE_NAME("tbutils")
50 50
51/* Local prototypes */ 51/* Local prototypes */
52static acpi_status acpi_tb_validate_xsdt(acpi_physical_address address);
53
52static acpi_physical_address 54static acpi_physical_address
53acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size); 55acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size);
54 56
55/*******************************************************************************
56 *
57 * FUNCTION: acpi_tb_check_xsdt
58 *
59 * PARAMETERS: address - Pointer to the XSDT
60 *
61 * RETURN: status
62 * AE_OK - XSDT is okay
63 * AE_NO_MEMORY - can't map XSDT
64 * AE_INVALID_TABLE_LENGTH - invalid table length
65 * AE_NULL_ENTRY - XSDT has NULL entry
66 *
67 * DESCRIPTION: validate XSDT
68******************************************************************************/
69
70static acpi_status
71acpi_tb_check_xsdt(acpi_physical_address address)
72{
73 struct acpi_table_header *table;
74 u32 length;
75 u64 xsdt_entry_address;
76 u8 *table_entry;
77 u32 table_count;
78 int i;
79
80 table = acpi_os_map_memory(address, sizeof(struct acpi_table_header));
81 if (!table)
82 return AE_NO_MEMORY;
83
84 length = table->length;
85 acpi_os_unmap_memory(table, sizeof(struct acpi_table_header));
86 if (length < sizeof(struct acpi_table_header))
87 return AE_INVALID_TABLE_LENGTH;
88
89 table = acpi_os_map_memory(address, length);
90 if (!table)
91 return AE_NO_MEMORY;
92
93 /* Calculate the number of tables described in XSDT */
94 table_count =
95 (u32) ((table->length -
96 sizeof(struct acpi_table_header)) / sizeof(u64));
97 table_entry =
98 ACPI_CAST_PTR(u8, table) + sizeof(struct acpi_table_header);
99 for (i = 0; i < table_count; i++) {
100 ACPI_MOVE_64_TO_64(&xsdt_entry_address, table_entry);
101 if (!xsdt_entry_address) {
102 /* XSDT has NULL entry */
103 break;
104 }
105 table_entry += sizeof(u64);
106 }
107 acpi_os_unmap_memory(table, length);
108
109 if (i < table_count)
110 return AE_NULL_ENTRY;
111 else
112 return AE_OK;
113}
114
115#if (!ACPI_REDUCED_HARDWARE) 57#if (!ACPI_REDUCED_HARDWARE)
116/******************************************************************************* 58/*******************************************************************************
117 * 59 *
@@ -383,7 +325,7 @@ acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size)
383 * Get the table physical address (32-bit for RSDT, 64-bit for XSDT): 325 * Get the table physical address (32-bit for RSDT, 64-bit for XSDT):
384 * Note: Addresses are 32-bit aligned (not 64) in both RSDT and XSDT 326 * Note: Addresses are 32-bit aligned (not 64) in both RSDT and XSDT
385 */ 327 */
386 if (table_entry_size == sizeof(u32)) { 328 if (table_entry_size == ACPI_RSDT_ENTRY_SIZE) {
387 /* 329 /*
388 * 32-bit platform, RSDT: Return 32-bit table entry 330 * 32-bit platform, RSDT: Return 32-bit table entry
389 * 64-bit platform, RSDT: Expand 32-bit to 64-bit and return 331 * 64-bit platform, RSDT: Expand 32-bit to 64-bit and return
@@ -415,6 +357,87 @@ acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size)
415 357
416/******************************************************************************* 358/*******************************************************************************
417 * 359 *
360 * FUNCTION: acpi_tb_validate_xsdt
361 *
362 * PARAMETERS: address - Physical address of the XSDT (from RSDP)
363 *
364 * RETURN: Status. AE_OK if the table appears to be valid.
365 *
366 * DESCRIPTION: Validate an XSDT to ensure that it is of minimum size and does
367 * not contain any NULL entries. A problem that is seen in the
368 * field is that the XSDT exists, but is actually useless because
369 * of one or more (or all) NULL entries.
370 *
371 ******************************************************************************/
372
373static acpi_status acpi_tb_validate_xsdt(acpi_physical_address xsdt_address)
374{
375 struct acpi_table_header *table;
376 u8 *next_entry;
377 acpi_physical_address address;
378 u32 length;
379 u32 entry_count;
380 acpi_status status;
381 u32 i;
382
383 /* Get the XSDT length */
384
385 table =
386 acpi_os_map_memory(xsdt_address, sizeof(struct acpi_table_header));
387 if (!table) {
388 return (AE_NO_MEMORY);
389 }
390
391 length = table->length;
392 acpi_os_unmap_memory(table, sizeof(struct acpi_table_header));
393
394 /*
395 * Minimum XSDT length is the size of the standard ACPI header
396 * plus one physical address entry
397 */
398 if (length < (sizeof(struct acpi_table_header) + ACPI_XSDT_ENTRY_SIZE)) {
399 return (AE_INVALID_TABLE_LENGTH);
400 }
401
402 /* Map the entire XSDT */
403
404 table = acpi_os_map_memory(xsdt_address, length);
405 if (!table) {
406 return (AE_NO_MEMORY);
407 }
408
409 /* Get the number of entries and pointer to first entry */
410
411 status = AE_OK;
412 next_entry = ACPI_ADD_PTR(u8, table, sizeof(struct acpi_table_header));
413 entry_count = (u32)((table->length - sizeof(struct acpi_table_header)) /
414 ACPI_XSDT_ENTRY_SIZE);
415
416 /* Validate each entry (physical address) within the XSDT */
417
418 for (i = 0; i < entry_count; i++) {
419 address =
420 acpi_tb_get_root_table_entry(next_entry,
421 ACPI_XSDT_ENTRY_SIZE);
422 if (!address) {
423
424 /* Detected a NULL entry, XSDT is invalid */
425
426 status = AE_NULL_ENTRY;
427 break;
428 }
429
430 next_entry += ACPI_XSDT_ENTRY_SIZE;
431 }
432
433 /* Unmap table */
434
435 acpi_os_unmap_memory(table, length);
436 return (status);
437}
438
439/*******************************************************************************
440 *
418 * FUNCTION: acpi_tb_parse_root_table 441 * FUNCTION: acpi_tb_parse_root_table
419 * 442 *
420 * PARAMETERS: rsdp - Pointer to the RSDP 443 * PARAMETERS: rsdp - Pointer to the RSDP
@@ -438,16 +461,14 @@ acpi_status __init acpi_tb_parse_root_table(acpi_physical_address rsdp_address)
438 u32 table_count; 461 u32 table_count;
439 struct acpi_table_header *table; 462 struct acpi_table_header *table;
440 acpi_physical_address address; 463 acpi_physical_address address;
441 acpi_physical_address uninitialized_var(rsdt_address);
442 u32 length; 464 u32 length;
443 u8 *table_entry; 465 u8 *table_entry;
444 acpi_status status; 466 acpi_status status;
445 467
446 ACPI_FUNCTION_TRACE(tb_parse_root_table); 468 ACPI_FUNCTION_TRACE(tb_parse_root_table);
447 469
448 /* 470 /* Map the entire RSDP and extract the address of the RSDT or XSDT */
449 * Map the entire RSDP and extract the address of the RSDT or XSDT 471
450 */
451 rsdp = acpi_os_map_memory(rsdp_address, sizeof(struct acpi_table_rsdp)); 472 rsdp = acpi_os_map_memory(rsdp_address, sizeof(struct acpi_table_rsdp));
452 if (!rsdp) { 473 if (!rsdp) {
453 return_ACPI_STATUS(AE_NO_MEMORY); 474 return_ACPI_STATUS(AE_NO_MEMORY);
@@ -457,24 +478,22 @@ acpi_status __init acpi_tb_parse_root_table(acpi_physical_address rsdp_address)
457 ACPI_CAST_PTR(struct acpi_table_header, 478 ACPI_CAST_PTR(struct acpi_table_header,
458 rsdp)); 479 rsdp));
459 480
460 /* Differentiate between RSDT and XSDT root tables */ 481 /* Use XSDT if present and not overridden. Otherwise, use RSDT */
461 482
462 if (rsdp->revision > 1 && rsdp->xsdt_physical_address 483 if ((rsdp->revision > 1) &&
463 && !acpi_rsdt_forced) { 484 rsdp->xsdt_physical_address && !acpi_gbl_do_not_use_xsdt) {
464 /* 485 /*
465 * Root table is an XSDT (64-bit physical addresses). We must use the 486 * RSDP contains an XSDT (64-bit physical addresses). We must use
466 * XSDT if the revision is > 1 and the XSDT pointer is present, as per 487 * the XSDT if the revision is > 1 and the XSDT pointer is present,
467 * the ACPI specification. 488 * as per the ACPI specification.
468 */ 489 */
469 address = (acpi_physical_address) rsdp->xsdt_physical_address; 490 address = (acpi_physical_address) rsdp->xsdt_physical_address;
470 table_entry_size = sizeof(u64); 491 table_entry_size = ACPI_XSDT_ENTRY_SIZE;
471 rsdt_address = (acpi_physical_address)
472 rsdp->rsdt_physical_address;
473 } else { 492 } else {
474 /* Root table is an RSDT (32-bit physical addresses) */ 493 /* Root table is an RSDT (32-bit physical addresses) */
475 494
476 address = (acpi_physical_address) rsdp->rsdt_physical_address; 495 address = (acpi_physical_address) rsdp->rsdt_physical_address;
477 table_entry_size = sizeof(u32); 496 table_entry_size = ACPI_RSDT_ENTRY_SIZE;
478 } 497 }
479 498
480 /* 499 /*
@@ -483,15 +502,25 @@ acpi_status __init acpi_tb_parse_root_table(acpi_physical_address rsdp_address)
483 */ 502 */
484 acpi_os_unmap_memory(rsdp, sizeof(struct acpi_table_rsdp)); 503 acpi_os_unmap_memory(rsdp, sizeof(struct acpi_table_rsdp));
485 504
486 if (table_entry_size == sizeof(u64)) { 505 /*
487 if (acpi_tb_check_xsdt(address) == AE_NULL_ENTRY) { 506 * If it is present and used, validate the XSDT for access/size
488 /* XSDT has NULL entry, RSDT is used */ 507 * and ensure that all table entries are at least non-NULL
489 address = rsdt_address; 508 */
490 table_entry_size = sizeof(u32); 509 if (table_entry_size == ACPI_XSDT_ENTRY_SIZE) {
491 ACPI_WARNING((AE_INFO, "BIOS XSDT has NULL entry, " 510 status = acpi_tb_validate_xsdt(address);
492 "using RSDT")); 511 if (ACPI_FAILURE(status)) {
512 ACPI_BIOS_WARNING((AE_INFO,
513 "XSDT is invalid (%s), using RSDT",
514 acpi_format_exception(status)));
515
516 /* Fall back to the RSDT */
517
518 address =
519 (acpi_physical_address) rsdp->rsdt_physical_address;
520 table_entry_size = ACPI_RSDT_ENTRY_SIZE;
493 } 521 }
494 } 522 }
523
495 /* Map the RSDT/XSDT table header to get the full table length */ 524 /* Map the RSDT/XSDT table header to get the full table length */
496 525
497 table = acpi_os_map_memory(address, sizeof(struct acpi_table_header)); 526 table = acpi_os_map_memory(address, sizeof(struct acpi_table_header));
@@ -501,12 +530,14 @@ acpi_status __init acpi_tb_parse_root_table(acpi_physical_address rsdp_address)
501 530
502 acpi_tb_print_table_header(address, table); 531 acpi_tb_print_table_header(address, table);
503 532
504 /* Get the length of the full table, verify length and map entire table */ 533 /*
505 534 * Validate length of the table, and map entire table.
535 * Minimum length table must contain at least one entry.
536 */
506 length = table->length; 537 length = table->length;
507 acpi_os_unmap_memory(table, sizeof(struct acpi_table_header)); 538 acpi_os_unmap_memory(table, sizeof(struct acpi_table_header));
508 539
509 if (length < sizeof(struct acpi_table_header)) { 540 if (length < (sizeof(struct acpi_table_header) + table_entry_size)) {
510 ACPI_BIOS_ERROR((AE_INFO, 541 ACPI_BIOS_ERROR((AE_INFO,
511 "Invalid table length 0x%X in RSDT/XSDT", 542 "Invalid table length 0x%X in RSDT/XSDT",
512 length)); 543 length));
@@ -526,22 +557,21 @@ acpi_status __init acpi_tb_parse_root_table(acpi_physical_address rsdp_address)
526 return_ACPI_STATUS(status); 557 return_ACPI_STATUS(status);
527 } 558 }
528 559
529 /* Calculate the number of tables described in the root table */ 560 /* Get the number of entries and pointer to first entry */
530 561
531 table_count = (u32)((table->length - sizeof(struct acpi_table_header)) / 562 table_count = (u32)((table->length - sizeof(struct acpi_table_header)) /
532 table_entry_size); 563 table_entry_size);
564 table_entry = ACPI_ADD_PTR(u8, table, sizeof(struct acpi_table_header));
565
533 /* 566 /*
534 * First two entries in the table array are reserved for the DSDT 567 * First two entries in the table array are reserved for the DSDT
535 * and FACS, which are not actually present in the RSDT/XSDT - they 568 * and FACS, which are not actually present in the RSDT/XSDT - they
536 * come from the FADT 569 * come from the FADT
537 */ 570 */
538 table_entry =
539 ACPI_CAST_PTR(u8, table) + sizeof(struct acpi_table_header);
540 acpi_gbl_root_table_list.current_table_count = 2; 571 acpi_gbl_root_table_list.current_table_count = 2;
541 572
542 /* 573 /* Initialize the root table array from the RSDT/XSDT */
543 * Initialize the root table array from the RSDT/XSDT 574
544 */
545 for (i = 0; i < table_count; i++) { 575 for (i = 0; i < table_count; i++) {
546 if (acpi_gbl_root_table_list.current_table_count >= 576 if (acpi_gbl_root_table_list.current_table_count >=
547 acpi_gbl_root_table_list.max_table_count) { 577 acpi_gbl_root_table_list.max_table_count) {
@@ -584,7 +614,7 @@ acpi_status __init acpi_tb_parse_root_table(acpi_physical_address rsdp_address)
584 acpi_tb_install_table(acpi_gbl_root_table_list.tables[i]. 614 acpi_tb_install_table(acpi_gbl_root_table_list.tables[i].
585 address, NULL, i); 615 address, NULL, i);
586 616
587 /* Special case for FADT - get the DSDT and FACS */ 617 /* Special case for FADT - validate it then get the DSDT and FACS */
588 618
589 if (ACPI_COMPARE_NAME 619 if (ACPI_COMPARE_NAME
590 (&acpi_gbl_root_table_list.tables[i].signature, 620 (&acpi_gbl_root_table_list.tables[i].signature,
diff --git a/drivers/acpi/acpica/utaddress.c b/drivers/acpi/acpica/utaddress.c
index e0a2e2779c2e..2c2b6ae5dfc4 100644
--- a/drivers/acpi/acpica/utaddress.c
+++ b/drivers/acpi/acpica/utaddress.c
@@ -224,10 +224,11 @@ acpi_ut_check_address_range(acpi_adr_space_type space_id,
224 224
225 while (range_info) { 225 while (range_info) {
226 /* 226 /*
227 * Check if the requested Address/Length overlaps this address_range. 227 * Check if the requested address/length overlaps this
228 * Four cases to consider: 228 * address range. There are four cases to consider:
229 * 229 *
230 * 1) Input address/length is contained completely in the address range 230 * 1) Input address/length is contained completely in the
231 * address range
231 * 2) Input address/length overlaps range at the range start 232 * 2) Input address/length overlaps range at the range start
232 * 3) Input address/length overlaps range at the range end 233 * 3) Input address/length overlaps range at the range end
233 * 4) Input address/length completely encompasses the range 234 * 4) Input address/length completely encompasses the range
@@ -244,11 +245,17 @@ acpi_ut_check_address_range(acpi_adr_space_type space_id,
244 region_node); 245 region_node);
245 246
246 ACPI_WARNING((AE_INFO, 247 ACPI_WARNING((AE_INFO,
247 "0x%p-0x%p %s conflicts with Region %s %d", 248 "%s range 0x%p-0x%p conflicts with OpRegion 0x%p-0x%p (%s)",
249 acpi_ut_get_region_name(space_id),
248 ACPI_CAST_PTR(void, address), 250 ACPI_CAST_PTR(void, address),
249 ACPI_CAST_PTR(void, end_address), 251 ACPI_CAST_PTR(void, end_address),
250 acpi_ut_get_region_name(space_id), 252 ACPI_CAST_PTR(void,
251 pathname, overlap_count)); 253 range_info->
254 start_address),
255 ACPI_CAST_PTR(void,
256 range_info->
257 end_address),
258 pathname));
252 ACPI_FREE(pathname); 259 ACPI_FREE(pathname);
253 } 260 }
254 } 261 }
diff --git a/drivers/acpi/acpica/utalloc.c b/drivers/acpi/acpica/utalloc.c
index 814267f52715..1851762fc5b5 100644
--- a/drivers/acpi/acpica/utalloc.c
+++ b/drivers/acpi/acpica/utalloc.c
@@ -302,9 +302,13 @@ acpi_ut_initialize_buffer(struct acpi_buffer * buffer,
302 return (AE_BUFFER_OVERFLOW); 302 return (AE_BUFFER_OVERFLOW);
303 303
304 case ACPI_ALLOCATE_BUFFER: 304 case ACPI_ALLOCATE_BUFFER:
305 305 /*
306 /* Allocate a new buffer */ 306 * Allocate a new buffer. We directectly call acpi_os_allocate here to
307 307 * purposefully bypass the (optionally enabled) internal allocation
308 * tracking mechanism since we only want to track internal
309 * allocations. Note: The caller should use acpi_os_free to free this
310 * buffer created via ACPI_ALLOCATE_BUFFER.
311 */
308 buffer->pointer = acpi_os_allocate(required_length); 312 buffer->pointer = acpi_os_allocate(required_length);
309 break; 313 break;
310 314
diff --git a/drivers/acpi/acpica/utcache.c b/drivers/acpi/acpica/utcache.c
index 366bfec4b770..cacd2fd9e665 100644
--- a/drivers/acpi/acpica/utcache.c
+++ b/drivers/acpi/acpica/utcache.c
@@ -248,12 +248,12 @@ void *acpi_os_acquire_object(struct acpi_memory_list *cache)
248 ACPI_FUNCTION_NAME(os_acquire_object); 248 ACPI_FUNCTION_NAME(os_acquire_object);
249 249
250 if (!cache) { 250 if (!cache) {
251 return (NULL); 251 return_PTR(NULL);
252 } 252 }
253 253
254 status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES); 254 status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
255 if (ACPI_FAILURE(status)) { 255 if (ACPI_FAILURE(status)) {
256 return (NULL); 256 return_PTR(NULL);
257 } 257 }
258 258
259 ACPI_MEM_TRACKING(cache->requests++); 259 ACPI_MEM_TRACKING(cache->requests++);
@@ -276,7 +276,7 @@ void *acpi_os_acquire_object(struct acpi_memory_list *cache)
276 276
277 status = acpi_ut_release_mutex(ACPI_MTX_CACHES); 277 status = acpi_ut_release_mutex(ACPI_MTX_CACHES);
278 if (ACPI_FAILURE(status)) { 278 if (ACPI_FAILURE(status)) {
279 return (NULL); 279 return_PTR(NULL);
280 } 280 }
281 281
282 /* Clear (zero) the previously used Object */ 282 /* Clear (zero) the previously used Object */
@@ -299,15 +299,15 @@ void *acpi_os_acquire_object(struct acpi_memory_list *cache)
299 299
300 status = acpi_ut_release_mutex(ACPI_MTX_CACHES); 300 status = acpi_ut_release_mutex(ACPI_MTX_CACHES);
301 if (ACPI_FAILURE(status)) { 301 if (ACPI_FAILURE(status)) {
302 return (NULL); 302 return_PTR(NULL);
303 } 303 }
304 304
305 object = ACPI_ALLOCATE_ZEROED(cache->object_size); 305 object = ACPI_ALLOCATE_ZEROED(cache->object_size);
306 if (!object) { 306 if (!object) {
307 return (NULL); 307 return_PTR(NULL);
308 } 308 }
309 } 309 }
310 310
311 return (object); 311 return_PTR(object);
312} 312}
313#endif /* ACPI_USE_LOCAL_CACHE */ 313#endif /* ACPI_USE_LOCAL_CACHE */
diff --git a/drivers/acpi/acpica/utdebug.c b/drivers/acpi/acpica/utdebug.c
index 03ae8affe48f..d971c8631263 100644
--- a/drivers/acpi/acpica/utdebug.c
+++ b/drivers/acpi/acpica/utdebug.c
@@ -194,9 +194,9 @@ acpi_debug_print(u32 requested_debug_level,
194 */ 194 */
195 acpi_os_printf("%9s-%04ld ", module_name, line_number); 195 acpi_os_printf("%9s-%04ld ", module_name, line_number);
196 196
197#ifdef ACPI_EXEC_APP 197#ifdef ACPI_APPLICATION
198 /* 198 /*
199 * For acpi_exec only, emit the thread ID and nesting level. 199 * For acpi_exec/iASL only, emit the thread ID and nesting level.
200 * Note: nesting level is really only useful during a single-thread 200 * Note: nesting level is really only useful during a single-thread
201 * execution. Otherwise, multiple threads will keep resetting the 201 * execution. Otherwise, multiple threads will keep resetting the
202 * level. 202 * level.
diff --git a/drivers/acpi/acpica/utglobal.c b/drivers/acpi/acpica/utglobal.c
index 81f9a9584451..030cb0dc673c 100644
--- a/drivers/acpi/acpica/utglobal.c
+++ b/drivers/acpi/acpica/utglobal.c
@@ -388,11 +388,7 @@ acpi_status acpi_ut_init_globals(void)
388/* Public globals */ 388/* Public globals */
389 389
390ACPI_EXPORT_SYMBOL(acpi_gbl_FADT) 390ACPI_EXPORT_SYMBOL(acpi_gbl_FADT)
391
392ACPI_EXPORT_SYMBOL(acpi_dbg_level) 391ACPI_EXPORT_SYMBOL(acpi_dbg_level)
393
394ACPI_EXPORT_SYMBOL(acpi_dbg_layer) 392ACPI_EXPORT_SYMBOL(acpi_dbg_layer)
395
396ACPI_EXPORT_SYMBOL(acpi_gpe_count) 393ACPI_EXPORT_SYMBOL(acpi_gpe_count)
397
398ACPI_EXPORT_SYMBOL(acpi_current_gpe_count) 394ACPI_EXPORT_SYMBOL(acpi_current_gpe_count)
diff --git a/drivers/acpi/acpica/utxfinit.c b/drivers/acpi/acpica/utxfinit.c
index 75efea0539c1..246ef68681f4 100644
--- a/drivers/acpi/acpica/utxfinit.c
+++ b/drivers/acpi/acpica/utxfinit.c
@@ -122,8 +122,16 @@ acpi_status __init acpi_initialize_subsystem(void)
122 122
123 /* If configured, initialize the AML debugger */ 123 /* If configured, initialize the AML debugger */
124 124
125 ACPI_DEBUGGER_EXEC(status = acpi_db_initialize()); 125#ifdef ACPI_DEBUGGER
126 return_ACPI_STATUS(status); 126 status = acpi_db_initialize();
127 if (ACPI_FAILURE(status)) {
128 ACPI_EXCEPTION((AE_INFO, status,
129 "During Debugger initialization"));
130 return_ACPI_STATUS(status);
131 }
132#endif
133
134 return_ACPI_STATUS(AE_OK);
127} 135}
128 136
129ACPI_EXPORT_SYMBOL_INIT(acpi_initialize_subsystem) 137ACPI_EXPORT_SYMBOL_INIT(acpi_initialize_subsystem)
diff --git a/drivers/acpi/apei/apei-base.c b/drivers/acpi/apei/apei-base.c
index 6d2c49b86b7f..0760b75f79cc 100644
--- a/drivers/acpi/apei/apei-base.c
+++ b/drivers/acpi/apei/apei-base.c
@@ -34,7 +34,6 @@
34#include <linux/module.h> 34#include <linux/module.h>
35#include <linux/init.h> 35#include <linux/init.h>
36#include <linux/acpi.h> 36#include <linux/acpi.h>
37#include <linux/acpi_io.h>
38#include <linux/slab.h> 37#include <linux/slab.h>
39#include <linux/io.h> 38#include <linux/io.h>
40#include <linux/kref.h> 39#include <linux/kref.h>
diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
index 21ba34a73883..e5bcd919d4e6 100644
--- a/drivers/acpi/apei/apei-internal.h
+++ b/drivers/acpi/apei/apei-internal.h
@@ -8,7 +8,6 @@
8 8
9#include <linux/cper.h> 9#include <linux/cper.h>
10#include <linux/acpi.h> 10#include <linux/acpi.h>
11#include <linux/acpi_io.h>
12 11
13struct apei_exec_context; 12struct apei_exec_context;
14 13
diff --git a/drivers/acpi/apei/einj.c b/drivers/acpi/apei/einj.c
index fb57d03e698b..ca0c6d7ec0d4 100644
--- a/drivers/acpi/apei/einj.c
+++ b/drivers/acpi/apei/einj.c
@@ -33,7 +33,6 @@
33#include <linux/nmi.h> 33#include <linux/nmi.h>
34#include <linux/delay.h> 34#include <linux/delay.h>
35#include <linux/mm.h> 35#include <linux/mm.h>
36#include <acpi/acpi.h>
37 36
38#include "apei-internal.h" 37#include "apei-internal.h"
39 38
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index a30bc313787b..694c486a12ed 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -33,7 +33,6 @@
33#include <linux/module.h> 33#include <linux/module.h>
34#include <linux/init.h> 34#include <linux/init.h>
35#include <linux/acpi.h> 35#include <linux/acpi.h>
36#include <linux/acpi_io.h>
37#include <linux/io.h> 36#include <linux/io.h>
38#include <linux/interrupt.h> 37#include <linux/interrupt.h>
39#include <linux/timer.h> 38#include <linux/timer.h>
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 5876a49dfd38..470e7542bf31 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -36,8 +36,7 @@
36#include <linux/suspend.h> 36#include <linux/suspend.h>
37#include <asm/unaligned.h> 37#include <asm/unaligned.h>
38 38
39#include <acpi/acpi_bus.h> 39#include <linux/acpi.h>
40#include <acpi/acpi_drivers.h>
41#include <linux/power_supply.h> 40#include <linux/power_supply.h>
42 41
43#define PREFIX "ACPI: " 42#define PREFIX "ACPI: "
diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
index 078c4f7fe2dd..10e4964d051a 100644
--- a/drivers/acpi/blacklist.c
+++ b/drivers/acpi/blacklist.c
@@ -30,7 +30,6 @@
30#include <linux/kernel.h> 30#include <linux/kernel.h>
31#include <linux/init.h> 31#include <linux/init.h>
32#include <linux/acpi.h> 32#include <linux/acpi.h>
33#include <acpi/acpi_bus.h>
34#include <linux/dmi.h> 33#include <linux/dmi.h>
35 34
36#include "internal.h" 35#include "internal.h"
@@ -323,6 +322,56 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
323 DMI_MATCH(DMI_PRODUCT_VERSION, "2349D15"), 322 DMI_MATCH(DMI_PRODUCT_VERSION, "2349D15"),
324 }, 323 },
325 }, 324 },
325 {
326 .callback = dmi_disable_osi_win8,
327 .ident = "HP ProBook 2013 models",
328 .matches = {
329 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
330 DMI_MATCH(DMI_PRODUCT_NAME, "HP ProBook "),
331 DMI_MATCH(DMI_PRODUCT_NAME, " G1"),
332 },
333 },
334 {
335 .callback = dmi_disable_osi_win8,
336 .ident = "HP EliteBook 2013 models",
337 .matches = {
338 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
339 DMI_MATCH(DMI_PRODUCT_NAME, "HP EliteBook "),
340 DMI_MATCH(DMI_PRODUCT_NAME, " G1"),
341 },
342 },
343 {
344 .callback = dmi_disable_osi_win8,
345 .ident = "HP ZBook 14",
346 .matches = {
347 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
348 DMI_MATCH(DMI_PRODUCT_NAME, "HP ZBook 14"),
349 },
350 },
351 {
352 .callback = dmi_disable_osi_win8,
353 .ident = "HP ZBook 15",
354 .matches = {
355 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
356 DMI_MATCH(DMI_PRODUCT_NAME, "HP ZBook 15"),
357 },
358 },
359 {
360 .callback = dmi_disable_osi_win8,
361 .ident = "HP ZBook 17",
362 .matches = {
363 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
364 DMI_MATCH(DMI_PRODUCT_NAME, "HP ZBook 17"),
365 },
366 },
367 {
368 .callback = dmi_disable_osi_win8,
369 .ident = "HP EliteBook 8780w",
370 .matches = {
371 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
372 DMI_MATCH(DMI_PRODUCT_NAME, "HP EliteBook 8780w"),
373 },
374 },
326 375
327 /* 376 /*
328 * BIOS invocation of _OSI(Linux) is almost always a BIOS bug. 377 * BIOS invocation of _OSI(Linux) is almost always a BIOS bug.
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 0710004055c8..384da5ab5955 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -37,8 +37,6 @@
37#include <asm/mpspec.h> 37#include <asm/mpspec.h>
38#endif 38#endif
39#include <linux/pci.h> 39#include <linux/pci.h>
40#include <acpi/acpi_bus.h>
41#include <acpi/acpi_drivers.h>
42#include <acpi/apei.h> 40#include <acpi/apei.h>
43#include <linux/dmi.h> 41#include <linux/dmi.h>
44#include <linux/suspend.h> 42#include <linux/suspend.h>
@@ -52,9 +50,6 @@ struct acpi_device *acpi_root;
52struct proc_dir_entry *acpi_root_dir; 50struct proc_dir_entry *acpi_root_dir;
53EXPORT_SYMBOL(acpi_root_dir); 51EXPORT_SYMBOL(acpi_root_dir);
54 52
55#define STRUCT_TO_INT(s) (*((int*)&s))
56
57
58#ifdef CONFIG_X86 53#ifdef CONFIG_X86
59static int set_copy_dsdt(const struct dmi_system_id *id) 54static int set_copy_dsdt(const struct dmi_system_id *id)
60{ 55{
@@ -115,18 +110,16 @@ int acpi_bus_get_status(struct acpi_device *device)
115 if (ACPI_FAILURE(status)) 110 if (ACPI_FAILURE(status))
116 return -ENODEV; 111 return -ENODEV;
117 112
118 STRUCT_TO_INT(device->status) = (int) sta; 113 acpi_set_device_status(device, sta);
119 114
120 if (device->status.functional && !device->status.present) { 115 if (device->status.functional && !device->status.present) {
121 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]: " 116 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]: "
122 "functional but not present;\n", 117 "functional but not present;\n",
123 device->pnp.bus_id, 118 device->pnp.bus_id, (u32)sta));
124 (u32) STRUCT_TO_INT(device->status)));
125 } 119 }
126 120
127 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]\n", 121 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]\n",
128 device->pnp.bus_id, 122 device->pnp.bus_id, (u32)sta));
129 (u32) STRUCT_TO_INT(device->status)));
130 return 0; 123 return 0;
131} 124}
132EXPORT_SYMBOL(acpi_bus_get_status); 125EXPORT_SYMBOL(acpi_bus_get_status);
@@ -339,58 +332,6 @@ static void acpi_bus_osc_support(void)
339 Notification Handling 332 Notification Handling
340 -------------------------------------------------------------------------- */ 333 -------------------------------------------------------------------------- */
341 334
342static void acpi_bus_check_device(acpi_handle handle)
343{
344 struct acpi_device *device;
345 acpi_status status;
346 struct acpi_device_status old_status;
347
348 if (acpi_bus_get_device(handle, &device))
349 return;
350 if (!device)
351 return;
352
353 old_status = device->status;
354
355 /*
356 * Make sure this device's parent is present before we go about
357 * messing with the device.
358 */
359 if (device->parent && !device->parent->status.present) {
360 device->status = device->parent->status;
361 return;
362 }
363
364 status = acpi_bus_get_status(device);
365 if (ACPI_FAILURE(status))
366 return;
367
368 if (STRUCT_TO_INT(old_status) == STRUCT_TO_INT(device->status))
369 return;
370
371 /*
372 * Device Insertion/Removal
373 */
374 if ((device->status.present) && !(old_status.present)) {
375 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device insertion detected\n"));
376 /* TBD: Handle device insertion */
377 } else if (!(device->status.present) && (old_status.present)) {
378 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device removal detected\n"));
379 /* TBD: Handle device removal */
380 }
381}
382
383static void acpi_bus_check_scope(acpi_handle handle)
384{
385 /* Status Change? */
386 acpi_bus_check_device(handle);
387
388 /*
389 * TBD: Enumerate child devices within this device's scope and
390 * run acpi_bus_check_device()'s on them.
391 */
392}
393
394/** 335/**
395 * acpi_bus_notify 336 * acpi_bus_notify
396 * --------------- 337 * ---------------
@@ -407,19 +348,11 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
407 switch (type) { 348 switch (type) {
408 349
409 case ACPI_NOTIFY_BUS_CHECK: 350 case ACPI_NOTIFY_BUS_CHECK:
410 acpi_bus_check_scope(handle); 351 /* TBD */
411 /*
412 * TBD: We'll need to outsource certain events to non-ACPI
413 * drivers via the device manager (device.c).
414 */
415 break; 352 break;
416 353
417 case ACPI_NOTIFY_DEVICE_CHECK: 354 case ACPI_NOTIFY_DEVICE_CHECK:
418 acpi_bus_check_device(handle); 355 /* TBD */
419 /*
420 * TBD: We'll need to outsource certain events to non-ACPI
421 * drivers via the device manager (device.c).
422 */
423 break; 356 break;
424 357
425 case ACPI_NOTIFY_DEVICE_WAKE: 358 case ACPI_NOTIFY_DEVICE_WAKE:
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index c971929d75c2..11c11f6b8fa1 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -31,8 +31,7 @@
31#include <linux/seq_file.h> 31#include <linux/seq_file.h>
32#include <linux/input.h> 32#include <linux/input.h>
33#include <linux/slab.h> 33#include <linux/slab.h>
34#include <acpi/acpi_bus.h> 34#include <linux/acpi.h>
35#include <acpi/acpi_drivers.h>
36#include <acpi/button.h> 35#include <acpi/button.h>
37 36
38#define PREFIX "ACPI: " 37#define PREFIX "ACPI: "
@@ -101,7 +100,6 @@ struct acpi_button {
101 struct input_dev *input; 100 struct input_dev *input;
102 char phys[32]; /* for input device */ 101 char phys[32]; /* for input device */
103 unsigned long pushed; 102 unsigned long pushed;
104 bool wakeup_enabled;
105}; 103};
106 104
107static BLOCKING_NOTIFIER_HEAD(acpi_lid_notifier); 105static BLOCKING_NOTIFIER_HEAD(acpi_lid_notifier);
@@ -407,16 +405,6 @@ static int acpi_button_add(struct acpi_device *device)
407 lid_device = device; 405 lid_device = device;
408 } 406 }
409 407
410 if (device->wakeup.flags.valid) {
411 /* Button's GPE is run-wake GPE */
412 acpi_enable_gpe(device->wakeup.gpe_device,
413 device->wakeup.gpe_number);
414 if (!device_may_wakeup(&device->dev)) {
415 device_set_wakeup_enable(&device->dev, true);
416 button->wakeup_enabled = true;
417 }
418 }
419
420 printk(KERN_INFO PREFIX "%s [%s]\n", name, acpi_device_bid(device)); 408 printk(KERN_INFO PREFIX "%s [%s]\n", name, acpi_device_bid(device));
421 return 0; 409 return 0;
422 410
@@ -433,13 +421,6 @@ static int acpi_button_remove(struct acpi_device *device)
433{ 421{
434 struct acpi_button *button = acpi_driver_data(device); 422 struct acpi_button *button = acpi_driver_data(device);
435 423
436 if (device->wakeup.flags.valid) {
437 acpi_disable_gpe(device->wakeup.gpe_device,
438 device->wakeup.gpe_number);
439 if (button->wakeup_enabled)
440 device_set_wakeup_enable(&device->dev, false);
441 }
442
443 acpi_button_remove_fs(device); 424 acpi_button_remove_fs(device);
444 input_unregister_device(button->input); 425 input_unregister_device(button->input);
445 kfree(button); 426 kfree(button);
diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c
index e23151667655..0b6ae6eb5c4a 100644
--- a/drivers/acpi/container.c
+++ b/drivers/acpi/container.c
@@ -27,8 +27,7 @@
27 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 27 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
28 */ 28 */
29#include <linux/acpi.h> 29#include <linux/acpi.h>
30 30#include <linux/container.h>
31#include "internal.h"
32 31
33#include "internal.h" 32#include "internal.h"
34 33
@@ -44,19 +43,65 @@ static const struct acpi_device_id container_device_ids[] = {
44 {"", 0}, 43 {"", 0},
45}; 44};
46 45
47static int container_device_attach(struct acpi_device *device, 46static int acpi_container_offline(struct container_dev *cdev)
47{
48 struct acpi_device *adev = ACPI_COMPANION(&cdev->dev);
49 struct acpi_device *child;
50
51 /* Check all of the dependent devices' physical companions. */
52 list_for_each_entry(child, &adev->children, node)
53 if (!acpi_scan_is_offline(child, false))
54 return -EBUSY;
55
56 return 0;
57}
58
59static void acpi_container_release(struct device *dev)
60{
61 kfree(to_container_dev(dev));
62}
63
64static int container_device_attach(struct acpi_device *adev,
48 const struct acpi_device_id *not_used) 65 const struct acpi_device_id *not_used)
49{ 66{
50 /* This is necessary for container hotplug to work. */ 67 struct container_dev *cdev;
68 struct device *dev;
69 int ret;
70
71 cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
72 if (!cdev)
73 return -ENOMEM;
74
75 cdev->offline = acpi_container_offline;
76 dev = &cdev->dev;
77 dev->bus = &container_subsys;
78 dev_set_name(dev, "%s", dev_name(&adev->dev));
79 ACPI_COMPANION_SET(dev, adev);
80 dev->release = acpi_container_release;
81 ret = device_register(dev);
82 if (ret)
83 return ret;
84
85 adev->driver_data = dev;
51 return 1; 86 return 1;
52} 87}
53 88
89static void container_device_detach(struct acpi_device *adev)
90{
91 struct device *dev = acpi_driver_data(adev);
92
93 adev->driver_data = NULL;
94 if (dev)
95 device_unregister(dev);
96}
97
54static struct acpi_scan_handler container_handler = { 98static struct acpi_scan_handler container_handler = {
55 .ids = container_device_ids, 99 .ids = container_device_ids,
56 .attach = container_device_attach, 100 .attach = container_device_attach,
101 .detach = container_device_detach,
57 .hotplug = { 102 .hotplug = {
58 .enabled = true, 103 .enabled = true,
59 .mode = AHM_CONTAINER, 104 .demand_offline = true,
60 }, 105 },
61}; 106};
62 107
diff --git a/drivers/acpi/custom_method.c b/drivers/acpi/custom_method.c
index 12b62f2cdb3f..c68e72414a67 100644
--- a/drivers/acpi/custom_method.c
+++ b/drivers/acpi/custom_method.c
@@ -7,7 +7,7 @@
7#include <linux/kernel.h> 7#include <linux/kernel.h>
8#include <linux/uaccess.h> 8#include <linux/uaccess.h>
9#include <linux/debugfs.h> 9#include <linux/debugfs.h>
10#include <acpi/acpi_drivers.h> 10#include <linux/acpi.h>
11 11
12#include "internal.h" 12#include "internal.h"
13 13
diff --git a/drivers/acpi/debugfs.c b/drivers/acpi/debugfs.c
index b55d6a20dc0e..6b1919f6bd82 100644
--- a/drivers/acpi/debugfs.c
+++ b/drivers/acpi/debugfs.c
@@ -5,7 +5,7 @@
5#include <linux/export.h> 5#include <linux/export.h>
6#include <linux/init.h> 6#include <linux/init.h>
7#include <linux/debugfs.h> 7#include <linux/debugfs.h>
8#include <acpi/acpi_drivers.h> 8#include <linux/acpi.h>
9 9
10#define _COMPONENT ACPI_SYSTEM_COMPONENT 10#define _COMPONENT ACPI_SYSTEM_COMPONENT
11ACPI_MODULE_NAME("debugfs"); 11ACPI_MODULE_NAME("debugfs");
diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
index b3480cf7db1a..d49f1e464703 100644
--- a/drivers/acpi/device_pm.c
+++ b/drivers/acpi/device_pm.c
@@ -256,6 +256,8 @@ int acpi_bus_init_power(struct acpi_device *device)
256 return -EINVAL; 256 return -EINVAL;
257 257
258 device->power.state = ACPI_STATE_UNKNOWN; 258 device->power.state = ACPI_STATE_UNKNOWN;
259 if (!acpi_device_is_present(device))
260 return 0;
259 261
260 result = acpi_device_get_power(device, &state); 262 result = acpi_device_get_power(device, &state);
261 if (result) 263 if (result)
@@ -302,15 +304,18 @@ int acpi_device_fix_up_power(struct acpi_device *device)
302 return ret; 304 return ret;
303} 305}
304 306
305int acpi_bus_update_power(acpi_handle handle, int *state_p) 307int acpi_device_update_power(struct acpi_device *device, int *state_p)
306{ 308{
307 struct acpi_device *device;
308 int state; 309 int state;
309 int result; 310 int result;
310 311
311 result = acpi_bus_get_device(handle, &device); 312 if (device->power.state == ACPI_STATE_UNKNOWN) {
312 if (result) 313 result = acpi_bus_init_power(device);
314 if (!result && state_p)
315 *state_p = device->power.state;
316
313 return result; 317 return result;
318 }
314 319
315 result = acpi_device_get_power(device, &state); 320 result = acpi_device_get_power(device, &state);
316 if (result) 321 if (result)
@@ -338,6 +343,15 @@ int acpi_bus_update_power(acpi_handle handle, int *state_p)
338 343
339 return 0; 344 return 0;
340} 345}
346
347int acpi_bus_update_power(acpi_handle handle, int *state_p)
348{
349 struct acpi_device *device;
350 int result;
351
352 result = acpi_bus_get_device(handle, &device);
353 return result ? result : acpi_device_update_power(device, state_p);
354}
341EXPORT_SYMBOL_GPL(acpi_bus_update_power); 355EXPORT_SYMBOL_GPL(acpi_bus_update_power);
342 356
343bool acpi_bus_power_manageable(acpi_handle handle) 357bool acpi_bus_power_manageable(acpi_handle handle)
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index dcd73ccb514c..c431c88faaff 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -32,8 +32,8 @@
32#include <linux/jiffies.h> 32#include <linux/jiffies.h>
33#include <linux/stddef.h> 33#include <linux/stddef.h>
34#include <linux/acpi.h> 34#include <linux/acpi.h>
35#include <acpi/acpi_bus.h> 35
36#include <acpi/acpi_drivers.h> 36#include "internal.h"
37 37
38#define PREFIX "ACPI: " 38#define PREFIX "ACPI: "
39 39
@@ -323,14 +323,11 @@ static int dock_present(struct dock_station *ds)
323 */ 323 */
324static void dock_create_acpi_device(acpi_handle handle) 324static void dock_create_acpi_device(acpi_handle handle)
325{ 325{
326 struct acpi_device *device; 326 struct acpi_device *device = NULL;
327 int ret; 327 int ret;
328 328
329 if (acpi_bus_get_device(handle, &device)) { 329 acpi_bus_get_device(handle, &device);
330 /* 330 if (!acpi_device_enumerated(device)) {
331 * no device created for this object,
332 * so we should create one.
333 */
334 ret = acpi_bus_scan(handle); 331 ret = acpi_bus_scan(handle);
335 if (ret) 332 if (ret)
336 pr_debug("error adding bus, %x\n", -ret); 333 pr_debug("error adding bus, %x\n", -ret);
@@ -898,9 +895,6 @@ find_dock_and_bay(acpi_handle handle, u32 lvl, void *context, void **rv)
898 895
899void __init acpi_dock_init(void) 896void __init acpi_dock_init(void)
900{ 897{
901 if (acpi_disabled)
902 return;
903
904 /* look for dock stations and bays */ 898 /* look for dock stations and bays */
905 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, 899 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
906 ACPI_UINT32_MAX, find_dock_and_bay, NULL, NULL, NULL); 900 ACPI_UINT32_MAX, find_dock_and_bay, NULL, NULL, NULL);
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index ba5b56db9d27..959d41acc108 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -39,10 +39,9 @@
39#include <linux/list.h> 39#include <linux/list.h>
40#include <linux/spinlock.h> 40#include <linux/spinlock.h>
41#include <linux/slab.h> 41#include <linux/slab.h>
42#include <asm/io.h> 42#include <linux/acpi.h>
43#include <acpi/acpi_bus.h>
44#include <acpi/acpi_drivers.h>
45#include <linux/dmi.h> 43#include <linux/dmi.h>
44#include <asm/io.h>
46 45
47#include "internal.h" 46#include "internal.h"
48 47
@@ -91,10 +90,6 @@ static unsigned int ec_storm_threshold __read_mostly = 8;
91module_param(ec_storm_threshold, uint, 0644); 90module_param(ec_storm_threshold, uint, 0644);
92MODULE_PARM_DESC(ec_storm_threshold, "Maxim false GPE numbers not considered as GPE storm"); 91MODULE_PARM_DESC(ec_storm_threshold, "Maxim false GPE numbers not considered as GPE storm");
93 92
94/* If we find an EC via the ECDT, we need to keep a ptr to its context */
95/* External interfaces use first EC only, so remember */
96typedef int (*acpi_ec_query_func) (void *data);
97
98struct acpi_ec_query_handler { 93struct acpi_ec_query_handler {
99 struct list_head node; 94 struct list_head node;
100 acpi_ec_query_func func; 95 acpi_ec_query_func func;
@@ -387,27 +382,6 @@ static int acpi_ec_write(struct acpi_ec *ec, u8 address, u8 data)
387 return acpi_ec_transaction(ec, &t); 382 return acpi_ec_transaction(ec, &t);
388} 383}
389 384
390/*
391 * Externally callable EC access functions. For now, assume 1 EC only
392 */
393int ec_burst_enable(void)
394{
395 if (!first_ec)
396 return -ENODEV;
397 return acpi_ec_burst_enable(first_ec);
398}
399
400EXPORT_SYMBOL(ec_burst_enable);
401
402int ec_burst_disable(void)
403{
404 if (!first_ec)
405 return -ENODEV;
406 return acpi_ec_burst_disable(first_ec);
407}
408
409EXPORT_SYMBOL(ec_burst_disable);
410
411int ec_read(u8 addr, u8 *val) 385int ec_read(u8 addr, u8 *val)
412{ 386{
413 int err; 387 int err;
@@ -779,9 +753,9 @@ static int ec_install_handlers(struct acpi_ec *ec)
779 pr_err("Fail in evaluating the _REG object" 753 pr_err("Fail in evaluating the _REG object"
780 " of EC device. Broken bios is suspected.\n"); 754 " of EC device. Broken bios is suspected.\n");
781 } else { 755 } else {
756 acpi_disable_gpe(NULL, ec->gpe);
782 acpi_remove_gpe_handler(NULL, ec->gpe, 757 acpi_remove_gpe_handler(NULL, ec->gpe,
783 &acpi_ec_gpe_handler); 758 &acpi_ec_gpe_handler);
784 acpi_disable_gpe(NULL, ec->gpe);
785 return -ENODEV; 759 return -ENODEV;
786 } 760 }
787 } 761 }
diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
index 4e7b798900f2..b4c216bab22b 100644
--- a/drivers/acpi/ec_sys.c
+++ b/drivers/acpi/ec_sys.c
@@ -105,7 +105,7 @@ static const struct file_operations acpi_ec_io_ops = {
105 .llseek = default_llseek, 105 .llseek = default_llseek,
106}; 106};
107 107
108int acpi_ec_add_debugfs(struct acpi_ec *ec, unsigned int ec_device_count) 108static int acpi_ec_add_debugfs(struct acpi_ec *ec, unsigned int ec_device_count)
109{ 109{
110 struct dentry *dev_dir; 110 struct dentry *dev_dir;
111 char name[64]; 111 char name[64];
diff --git a/drivers/acpi/event.c b/drivers/acpi/event.c
index cae3b387b867..ef2d730734dc 100644
--- a/drivers/acpi/event.c
+++ b/drivers/acpi/event.c
@@ -12,7 +12,7 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/poll.h> 13#include <linux/poll.h>
14#include <linux/gfp.h> 14#include <linux/gfp.h>
15#include <acpi/acpi_drivers.h> 15#include <linux/acpi.h>
16#include <net/netlink.h> 16#include <net/netlink.h>
17#include <net/genetlink.h> 17#include <net/genetlink.h>
18 18
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index ba3da88cee45..1fb62900f32a 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -29,8 +29,7 @@
29#include <linux/types.h> 29#include <linux/types.h>
30#include <asm/uaccess.h> 30#include <asm/uaccess.h>
31#include <linux/thermal.h> 31#include <linux/thermal.h>
32#include <acpi/acpi_bus.h> 32#include <linux/acpi.h>
33#include <acpi/acpi_drivers.h>
34 33
35#define PREFIX "ACPI: " 34#define PREFIX "ACPI: "
36 35
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index a22a295edb69..0c789224d40d 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -37,7 +37,7 @@ int register_acpi_bus_type(struct acpi_bus_type *type)
37{ 37{
38 if (acpi_disabled) 38 if (acpi_disabled)
39 return -ENODEV; 39 return -ENODEV;
40 if (type && type->match && type->find_device) { 40 if (type && type->match && type->find_companion) {
41 down_write(&bus_type_sem); 41 down_write(&bus_type_sem);
42 list_add_tail(&type->list, &bus_type_list); 42 list_add_tail(&type->list, &bus_type_list);
43 up_write(&bus_type_sem); 43 up_write(&bus_type_sem);
@@ -82,109 +82,74 @@ static struct acpi_bus_type *acpi_get_bus_type(struct device *dev)
82#define FIND_CHILD_MIN_SCORE 1 82#define FIND_CHILD_MIN_SCORE 1
83#define FIND_CHILD_MAX_SCORE 2 83#define FIND_CHILD_MAX_SCORE 2
84 84
85static acpi_status acpi_dev_present(acpi_handle handle, u32 lvl_not_used, 85static int find_child_checks(struct acpi_device *adev, bool check_children)
86 void *not_used, void **ret_p)
87{
88 struct acpi_device *adev = NULL;
89
90 acpi_bus_get_device(handle, &adev);
91 if (adev) {
92 *ret_p = handle;
93 return AE_CTRL_TERMINATE;
94 }
95 return AE_OK;
96}
97
98static int do_find_child_checks(acpi_handle handle, bool is_bridge)
99{ 86{
100 bool sta_present = true; 87 bool sta_present = true;
101 unsigned long long sta; 88 unsigned long long sta;
102 acpi_status status; 89 acpi_status status;
103 90
104 status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); 91 status = acpi_evaluate_integer(adev->handle, "_STA", NULL, &sta);
105 if (status == AE_NOT_FOUND) 92 if (status == AE_NOT_FOUND)
106 sta_present = false; 93 sta_present = false;
107 else if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_ENABLED)) 94 else if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_ENABLED))
108 return -ENODEV; 95 return -ENODEV;
109 96
110 if (is_bridge) { 97 if (check_children && list_empty(&adev->children))
111 void *test = NULL; 98 return -ENODEV;
112 99
113 /* Check if this object has at least one child device. */
114 acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, 1,
115 acpi_dev_present, NULL, NULL, &test);
116 if (!test)
117 return -ENODEV;
118 }
119 return sta_present ? FIND_CHILD_MAX_SCORE : FIND_CHILD_MIN_SCORE; 100 return sta_present ? FIND_CHILD_MAX_SCORE : FIND_CHILD_MIN_SCORE;
120} 101}
121 102
122struct find_child_context { 103struct acpi_device *acpi_find_child_device(struct acpi_device *parent,
123 u64 addr; 104 u64 address, bool check_children)
124 bool is_bridge;
125 acpi_handle ret;
126 int ret_score;
127};
128
129static acpi_status do_find_child(acpi_handle handle, u32 lvl_not_used,
130 void *data, void **not_used)
131{
132 struct find_child_context *context = data;
133 unsigned long long addr;
134 acpi_status status;
135 int score;
136
137 status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &addr);
138 if (ACPI_FAILURE(status) || addr != context->addr)
139 return AE_OK;
140
141 if (!context->ret) {
142 /* This is the first matching object. Save its handle. */
143 context->ret = handle;
144 return AE_OK;
145 }
146 /*
147 * There is more than one matching object with the same _ADR value.
148 * That really is unexpected, so we are kind of beyond the scope of the
149 * spec here. We have to choose which one to return, though.
150 *
151 * First, check if the previously found object is good enough and return
152 * its handle if so. Second, check the same for the object that we've
153 * just found.
154 */
155 if (!context->ret_score) {
156 score = do_find_child_checks(context->ret, context->is_bridge);
157 if (score == FIND_CHILD_MAX_SCORE)
158 return AE_CTRL_TERMINATE;
159 else
160 context->ret_score = score;
161 }
162 score = do_find_child_checks(handle, context->is_bridge);
163 if (score == FIND_CHILD_MAX_SCORE) {
164 context->ret = handle;
165 return AE_CTRL_TERMINATE;
166 } else if (score > context->ret_score) {
167 context->ret = handle;
168 context->ret_score = score;
169 }
170 return AE_OK;
171}
172
173acpi_handle acpi_find_child(acpi_handle parent, u64 addr, bool is_bridge)
174{ 105{
175 if (parent) { 106 struct acpi_device *adev, *ret = NULL;
176 struct find_child_context context = { 107 int ret_score = 0;
177 .addr = addr, 108
178 .is_bridge = is_bridge, 109 if (!parent)
179 }; 110 return NULL;
180 111
181 acpi_walk_namespace(ACPI_TYPE_DEVICE, parent, 1, do_find_child, 112 list_for_each_entry(adev, &parent->children, node) {
182 NULL, &context, NULL); 113 unsigned long long addr;
183 return context.ret; 114 acpi_status status;
115 int score;
116
117 status = acpi_evaluate_integer(adev->handle, METHOD_NAME__ADR,
118 NULL, &addr);
119 if (ACPI_FAILURE(status) || addr != address)
120 continue;
121
122 if (!ret) {
123 /* This is the first matching object. Save it. */
124 ret = adev;
125 continue;
126 }
127 /*
128 * There is more than one matching device object with the same
129 * _ADR value. That really is unexpected, so we are kind of
130 * beyond the scope of the spec here. We have to choose which
131 * one to return, though.
132 *
133 * First, check if the previously found object is good enough
134 * and return it if so. Second, do the same for the object that
135 * we've just found.
136 */
137 if (!ret_score) {
138 ret_score = find_child_checks(ret, check_children);
139 if (ret_score == FIND_CHILD_MAX_SCORE)
140 return ret;
141 }
142 score = find_child_checks(adev, check_children);
143 if (score == FIND_CHILD_MAX_SCORE) {
144 return adev;
145 } else if (score > ret_score) {
146 ret = adev;
147 ret_score = score;
148 }
184 } 149 }
185 return NULL; 150 return ret;
186} 151}
187EXPORT_SYMBOL_GPL(acpi_find_child); 152EXPORT_SYMBOL_GPL(acpi_find_child_device);
188 153
189static void acpi_physnode_link_name(char *buf, unsigned int node_id) 154static void acpi_physnode_link_name(char *buf, unsigned int node_id)
190{ 155{
@@ -195,9 +160,8 @@ static void acpi_physnode_link_name(char *buf, unsigned int node_id)
195 strcpy(buf, PHYSICAL_NODE_STRING); 160 strcpy(buf, PHYSICAL_NODE_STRING);
196} 161}
197 162
198int acpi_bind_one(struct device *dev, acpi_handle handle) 163int acpi_bind_one(struct device *dev, struct acpi_device *acpi_dev)
199{ 164{
200 struct acpi_device *acpi_dev = NULL;
201 struct acpi_device_physical_node *physical_node, *pn; 165 struct acpi_device_physical_node *physical_node, *pn;
202 char physical_node_name[PHYSICAL_NODE_NAME_SIZE]; 166 char physical_node_name[PHYSICAL_NODE_NAME_SIZE];
203 struct list_head *physnode_list; 167 struct list_head *physnode_list;
@@ -205,14 +169,12 @@ int acpi_bind_one(struct device *dev, acpi_handle handle)
205 int retval = -EINVAL; 169 int retval = -EINVAL;
206 170
207 if (ACPI_COMPANION(dev)) { 171 if (ACPI_COMPANION(dev)) {
208 if (handle) { 172 if (acpi_dev) {
209 dev_warn(dev, "ACPI companion already set\n"); 173 dev_warn(dev, "ACPI companion already set\n");
210 return -EINVAL; 174 return -EINVAL;
211 } else { 175 } else {
212 acpi_dev = ACPI_COMPANION(dev); 176 acpi_dev = ACPI_COMPANION(dev);
213 } 177 }
214 } else {
215 acpi_bus_get_device(handle, &acpi_dev);
216 } 178 }
217 if (!acpi_dev) 179 if (!acpi_dev)
218 return -EINVAL; 180 return -EINVAL;
@@ -322,29 +284,22 @@ int acpi_unbind_one(struct device *dev)
322} 284}
323EXPORT_SYMBOL_GPL(acpi_unbind_one); 285EXPORT_SYMBOL_GPL(acpi_unbind_one);
324 286
325void acpi_preset_companion(struct device *dev, acpi_handle parent, u64 addr)
326{
327 struct acpi_device *adev;
328
329 if (!acpi_bus_get_device(acpi_get_child(parent, addr), &adev))
330 ACPI_COMPANION_SET(dev, adev);
331}
332EXPORT_SYMBOL_GPL(acpi_preset_companion);
333
334static int acpi_platform_notify(struct device *dev) 287static int acpi_platform_notify(struct device *dev)
335{ 288{
336 struct acpi_bus_type *type = acpi_get_bus_type(dev); 289 struct acpi_bus_type *type = acpi_get_bus_type(dev);
337 acpi_handle handle;
338 int ret; 290 int ret;
339 291
340 ret = acpi_bind_one(dev, NULL); 292 ret = acpi_bind_one(dev, NULL);
341 if (ret && type) { 293 if (ret && type) {
342 ret = type->find_device(dev, &handle); 294 struct acpi_device *adev;
343 if (ret) { 295
296 adev = type->find_companion(dev);
297 if (!adev) {
344 DBG("Unable to get handle for %s\n", dev_name(dev)); 298 DBG("Unable to get handle for %s\n", dev_name(dev));
299 ret = -ENODEV;
345 goto out; 300 goto out;
346 } 301 }
347 ret = acpi_bind_one(dev, handle); 302 ret = acpi_bind_one(dev, adev);
348 if (ret) 303 if (ret)
349 goto out; 304 goto out;
350 } 305 }
diff --git a/drivers/acpi/hed.c b/drivers/acpi/hed.c
index 13b1d39d7cdf..aafe3ca829c2 100644
--- a/drivers/acpi/hed.c
+++ b/drivers/acpi/hed.c
@@ -25,8 +25,6 @@
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/acpi.h> 27#include <linux/acpi.h>
28#include <acpi/acpi_bus.h>
29#include <acpi/acpi_drivers.h>
30#include <acpi/hed.h> 28#include <acpi/hed.h>
31 29
32static struct acpi_device_id acpi_hed_ids[] = { 30static struct acpi_device_id acpi_hed_ids[] = {
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index a29739c0ba79..dedbb2d802f1 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -28,7 +28,6 @@ int init_acpi_device_notify(void);
28int acpi_scan_init(void); 28int acpi_scan_init(void);
29void acpi_pci_root_init(void); 29void acpi_pci_root_init(void);
30void acpi_pci_link_init(void); 30void acpi_pci_link_init(void);
31void acpi_pci_root_hp_init(void);
32void acpi_processor_init(void); 31void acpi_processor_init(void);
33void acpi_platform_init(void); 32void acpi_platform_init(void);
34int acpi_sysfs_init(void); 33int acpi_sysfs_init(void);
@@ -73,6 +72,9 @@ void acpi_lpss_init(void);
73static inline void acpi_lpss_init(void) {} 72static inline void acpi_lpss_init(void) {}
74#endif 73#endif
75 74
75bool acpi_queue_hotplug_work(struct work_struct *work);
76bool acpi_scan_is_offline(struct acpi_device *adev, bool uevent);
77
76/* -------------------------------------------------------------------------- 78/* --------------------------------------------------------------------------
77 Device Node Initialization / Removal 79 Device Node Initialization / Removal
78 -------------------------------------------------------------------------- */ 80 -------------------------------------------------------------------------- */
@@ -85,9 +87,9 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
85 int type, unsigned long long sta); 87 int type, unsigned long long sta);
86void acpi_device_add_finalize(struct acpi_device *device); 88void acpi_device_add_finalize(struct acpi_device *device);
87void acpi_free_pnp_ids(struct acpi_device_pnp *pnp); 89void acpi_free_pnp_ids(struct acpi_device_pnp *pnp);
88int acpi_bind_one(struct device *dev, acpi_handle handle); 90int acpi_bind_one(struct device *dev, struct acpi_device *adev);
89int acpi_unbind_one(struct device *dev); 91int acpi_unbind_one(struct device *dev);
90void acpi_bus_device_eject(void *data, u32 ost_src); 92bool acpi_device_is_present(struct acpi_device *adev);
91 93
92/* -------------------------------------------------------------------------- 94/* --------------------------------------------------------------------------
93 Power Resource 95 Power Resource
@@ -105,6 +107,8 @@ int acpi_power_get_inferred_state(struct acpi_device *device, int *state);
105int acpi_power_on_resources(struct acpi_device *device, int state); 107int acpi_power_on_resources(struct acpi_device *device, int state);
106int acpi_power_transition(struct acpi_device *device, int state); 108int acpi_power_transition(struct acpi_device *device, int state);
107 109
110int acpi_device_update_power(struct acpi_device *device, int *state_p);
111
108int acpi_wakeup_device_init(void); 112int acpi_wakeup_device_init(void);
109void acpi_early_processor_set_pdc(void); 113void acpi_early_processor_set_pdc(void);
110 114
@@ -127,12 +131,21 @@ struct acpi_ec {
127 131
128extern struct acpi_ec *first_ec; 132extern struct acpi_ec *first_ec;
129 133
134/* If we find an EC via the ECDT, we need to keep a ptr to its context */
135/* External interfaces use first EC only, so remember */
136typedef int (*acpi_ec_query_func) (void *data);
137
130int acpi_ec_init(void); 138int acpi_ec_init(void);
131int acpi_ec_ecdt_probe(void); 139int acpi_ec_ecdt_probe(void);
132int acpi_boot_ec_enable(void); 140int acpi_boot_ec_enable(void);
133void acpi_ec_block_transactions(void); 141void acpi_ec_block_transactions(void);
134void acpi_ec_unblock_transactions(void); 142void acpi_ec_unblock_transactions(void);
135void acpi_ec_unblock_transactions_early(void); 143void acpi_ec_unblock_transactions_early(void);
144int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit,
145 acpi_handle handle, acpi_ec_query_func func,
146 void *data);
147void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit);
148
136 149
137/*-------------------------------------------------------------------------- 150/*--------------------------------------------------------------------------
138 Suspend/Resume 151 Suspend/Resume
diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c
index a2343a1d9e0b..9e6816ef280a 100644
--- a/drivers/acpi/numa.c
+++ b/drivers/acpi/numa.c
@@ -29,7 +29,6 @@
29#include <linux/errno.h> 29#include <linux/errno.h>
30#include <linux/acpi.h> 30#include <linux/acpi.h>
31#include <linux/numa.h> 31#include <linux/numa.h>
32#include <acpi/acpi_bus.h>
33 32
34#define PREFIX "ACPI: " 33#define PREFIX "ACPI: "
35 34
diff --git a/drivers/acpi/nvs.c b/drivers/acpi/nvs.c
index 386a9fe497b4..de4fe03873c5 100644
--- a/drivers/acpi/nvs.c
+++ b/drivers/acpi/nvs.c
@@ -12,7 +12,8 @@
12#include <linux/mm.h> 12#include <linux/mm.h>
13#include <linux/slab.h> 13#include <linux/slab.h>
14#include <linux/acpi.h> 14#include <linux/acpi.h>
15#include <linux/acpi_io.h> 15
16#include "internal.h"
16 17
17/* ACPI NVS regions, APEI may use it */ 18/* ACPI NVS regions, APEI may use it */
18 19
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 54a20ff4b864..fc1aa7909690 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -39,7 +39,6 @@
39#include <linux/workqueue.h> 39#include <linux/workqueue.h>
40#include <linux/nmi.h> 40#include <linux/nmi.h>
41#include <linux/acpi.h> 41#include <linux/acpi.h>
42#include <linux/acpi_io.h>
43#include <linux/efi.h> 42#include <linux/efi.h>
44#include <linux/ioport.h> 43#include <linux/ioport.h>
45#include <linux/list.h> 44#include <linux/list.h>
@@ -49,9 +48,6 @@
49#include <asm/io.h> 48#include <asm/io.h>
50#include <asm/uaccess.h> 49#include <asm/uaccess.h>
51 50
52#include <acpi/acpi.h>
53#include <acpi/acpi_bus.h>
54#include <acpi/processor.h>
55#include "internal.h" 51#include "internal.h"
56 52
57#define _COMPONENT ACPI_OS_SERVICES 53#define _COMPONENT ACPI_OS_SERVICES
@@ -544,7 +540,7 @@ static u64 acpi_tables_addr;
544static int all_tables_size; 540static int all_tables_size;
545 541
546/* Copied from acpica/tbutils.c:acpi_tb_checksum() */ 542/* Copied from acpica/tbutils.c:acpi_tb_checksum() */
547u8 __init acpi_table_checksum(u8 *buffer, u32 length) 543static u8 __init acpi_table_checksum(u8 *buffer, u32 length)
548{ 544{
549 u8 sum = 0; 545 u8 sum = 0;
550 u8 *end = buffer + length; 546 u8 *end = buffer + length;
@@ -1215,6 +1211,10 @@ acpi_status acpi_hotplug_execute(acpi_hp_callback func, void *data, u32 src)
1215 return AE_OK; 1211 return AE_OK;
1216} 1212}
1217 1213
1214bool acpi_queue_hotplug_work(struct work_struct *work)
1215{
1216 return queue_work(kacpi_hotplug_wq, work);
1217}
1218 1218
1219acpi_status 1219acpi_status
1220acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle) 1220acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle)
@@ -1282,7 +1282,7 @@ acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout)
1282 jiffies = MAX_SCHEDULE_TIMEOUT; 1282 jiffies = MAX_SCHEDULE_TIMEOUT;
1283 else 1283 else
1284 jiffies = msecs_to_jiffies(timeout); 1284 jiffies = msecs_to_jiffies(timeout);
1285 1285
1286 ret = down_timeout(sem, jiffies); 1286 ret = down_timeout(sem, jiffies);
1287 if (ret) 1287 if (ret)
1288 status = AE_TIME; 1288 status = AE_TIME;
@@ -1794,7 +1794,7 @@ acpi_status __init acpi_os_initialize1(void)
1794{ 1794{
1795 kacpid_wq = alloc_workqueue("kacpid", 0, 1); 1795 kacpid_wq = alloc_workqueue("kacpid", 0, 1);
1796 kacpi_notify_wq = alloc_workqueue("kacpi_notify", 0, 1); 1796 kacpi_notify_wq = alloc_workqueue("kacpi_notify", 0, 1);
1797 kacpi_hotplug_wq = alloc_workqueue("kacpi_hotplug", 0, 1); 1797 kacpi_hotplug_wq = alloc_ordered_workqueue("kacpi_hotplug", 0);
1798 BUG_ON(!kacpid_wq); 1798 BUG_ON(!kacpid_wq);
1799 BUG_ON(!kacpi_notify_wq); 1799 BUG_ON(!kacpi_notify_wq);
1800 BUG_ON(!kacpi_hotplug_wq); 1800 BUG_ON(!kacpi_hotplug_wq);
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
index 41c5e1b799ef..52d45ea2bc4f 100644
--- a/drivers/acpi/pci_irq.c
+++ b/drivers/acpi/pci_irq.c
@@ -37,8 +37,6 @@
37#include <linux/pci.h> 37#include <linux/pci.h>
38#include <linux/acpi.h> 38#include <linux/acpi.h>
39#include <linux/slab.h> 39#include <linux/slab.h>
40#include <acpi/acpi_bus.h>
41#include <acpi/acpi_drivers.h>
42 40
43#define PREFIX "ACPI: " 41#define PREFIX "ACPI: "
44 42
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index 2652a614deeb..9418c7a1f786 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -39,9 +39,9 @@
39#include <linux/pci.h> 39#include <linux/pci.h>
40#include <linux/mutex.h> 40#include <linux/mutex.h>
41#include <linux/slab.h> 41#include <linux/slab.h>
42#include <linux/acpi.h>
42 43
43#include <acpi/acpi_bus.h> 44#include "internal.h"
44#include <acpi/acpi_drivers.h>
45 45
46#define PREFIX "ACPI: " 46#define PREFIX "ACPI: "
47 47
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 20360e480bd8..afafee56cf8b 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -35,9 +35,7 @@
35#include <linux/pci-aspm.h> 35#include <linux/pci-aspm.h>
36#include <linux/acpi.h> 36#include <linux/acpi.h>
37#include <linux/slab.h> 37#include <linux/slab.h>
38#include <acpi/acpi_bus.h> 38#include <acpi/apei.h> /* for acpi_hest_init() */
39#include <acpi/acpi_drivers.h>
40#include <acpi/apei.h>
41 39
42#include "internal.h" 40#include "internal.h"
43 41
@@ -51,6 +49,12 @@ static int acpi_pci_root_add(struct acpi_device *device,
51 const struct acpi_device_id *not_used); 49 const struct acpi_device_id *not_used);
52static void acpi_pci_root_remove(struct acpi_device *device); 50static void acpi_pci_root_remove(struct acpi_device *device);
53 51
52static int acpi_pci_root_scan_dependent(struct acpi_device *adev)
53{
54 acpiphp_check_host_bridge(adev->handle);
55 return 0;
56}
57
54#define ACPI_PCIE_REQ_SUPPORT (OSC_PCI_EXT_CONFIG_SUPPORT \ 58#define ACPI_PCIE_REQ_SUPPORT (OSC_PCI_EXT_CONFIG_SUPPORT \
55 | OSC_PCI_ASPM_SUPPORT \ 59 | OSC_PCI_ASPM_SUPPORT \
56 | OSC_PCI_CLOCK_PM_SUPPORT \ 60 | OSC_PCI_CLOCK_PM_SUPPORT \
@@ -66,7 +70,8 @@ static struct acpi_scan_handler pci_root_handler = {
66 .attach = acpi_pci_root_add, 70 .attach = acpi_pci_root_add,
67 .detach = acpi_pci_root_remove, 71 .detach = acpi_pci_root_remove,
68 .hotplug = { 72 .hotplug = {
69 .ignore = true, 73 .enabled = true,
74 .scan_dependent = acpi_pci_root_scan_dependent,
70 }, 75 },
71}; 76};
72 77
@@ -624,116 +629,9 @@ static void acpi_pci_root_remove(struct acpi_device *device)
624void __init acpi_pci_root_init(void) 629void __init acpi_pci_root_init(void)
625{ 630{
626 acpi_hest_init(); 631 acpi_hest_init();
627 632 if (acpi_pci_disabled)
628 if (!acpi_pci_disabled) {
629 pci_acpi_crs_quirks();
630 acpi_scan_add_handler(&pci_root_handler);
631 }
632}
633/* Support root bridge hotplug */
634
635static void handle_root_bridge_insertion(acpi_handle handle)
636{
637 struct acpi_device *device;
638
639 if (!acpi_bus_get_device(handle, &device)) {
640 dev_printk(KERN_DEBUG, &device->dev,
641 "acpi device already exists; ignoring notify\n");
642 return; 633 return;
643 }
644
645 if (acpi_bus_scan(handle))
646 acpi_handle_err(handle, "cannot add bridge to acpi list\n");
647}
648
649static void hotplug_event_root(void *data, u32 type)
650{
651 acpi_handle handle = data;
652 struct acpi_pci_root *root;
653
654 acpi_scan_lock_acquire();
655
656 root = acpi_pci_find_root(handle);
657
658 switch (type) {
659 case ACPI_NOTIFY_BUS_CHECK:
660 /* bus enumerate */
661 acpi_handle_printk(KERN_DEBUG, handle,
662 "Bus check notify on %s\n", __func__);
663 if (root)
664 acpiphp_check_host_bridge(handle);
665 else
666 handle_root_bridge_insertion(handle);
667
668 break;
669
670 case ACPI_NOTIFY_DEVICE_CHECK:
671 /* device check */
672 acpi_handle_printk(KERN_DEBUG, handle,
673 "Device check notify on %s\n", __func__);
674 if (!root)
675 handle_root_bridge_insertion(handle);
676 break;
677
678 case ACPI_NOTIFY_EJECT_REQUEST:
679 /* request device eject */
680 acpi_handle_printk(KERN_DEBUG, handle,
681 "Device eject notify on %s\n", __func__);
682 if (!root)
683 break;
684
685 get_device(&root->device->dev);
686
687 acpi_scan_lock_release();
688
689 acpi_bus_device_eject(root->device, ACPI_NOTIFY_EJECT_REQUEST);
690 return;
691 default:
692 acpi_handle_warn(handle,
693 "notify_handler: unknown event type 0x%x\n",
694 type);
695 break;
696 }
697
698 acpi_scan_lock_release();
699}
700
701static void handle_hotplug_event_root(acpi_handle handle, u32 type,
702 void *context)
703{
704 acpi_hotplug_execute(hotplug_event_root, handle, type);
705}
706
707static acpi_status __init
708find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
709{
710 acpi_status status;
711 int *count = (int *)context;
712
713 if (!acpi_is_root_bridge(handle))
714 return AE_OK;
715
716 (*count)++;
717
718 status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
719 handle_hotplug_event_root, NULL);
720 if (ACPI_FAILURE(status))
721 acpi_handle_printk(KERN_DEBUG, handle,
722 "notify handler is not installed, exit status: %u\n",
723 (unsigned int)status);
724 else
725 acpi_handle_printk(KERN_DEBUG, handle,
726 "notify handler is installed\n");
727
728 return AE_OK;
729}
730
731void __init acpi_pci_root_hp_init(void)
732{
733 int num = 0;
734
735 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
736 ACPI_UINT32_MAX, find_root_bridges, NULL, &num, NULL);
737 634
738 printk(KERN_DEBUG "Found %d acpi root devices\n", num); 635 pci_acpi_crs_quirks();
636 acpi_scan_add_handler_with_hotplug(&pci_root_handler, "pci_root");
739} 637}
diff --git a/drivers/acpi/pci_slot.c b/drivers/acpi/pci_slot.c
index d678a180ca2a..139d9e479370 100644
--- a/drivers/acpi/pci_slot.c
+++ b/drivers/acpi/pci_slot.c
@@ -35,6 +35,7 @@
35#include <linux/pci.h> 35#include <linux/pci.h>
36#include <linux/acpi.h> 36#include <linux/acpi.h>
37#include <linux/dmi.h> 37#include <linux/dmi.h>
38#include <linux/pci-acpi.h>
38 39
39static bool debug; 40static bool debug;
40static int check_sta_before_sun; 41static int check_sta_before_sun;
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c
index c2ad391d8041..ad7da686e6e6 100644
--- a/drivers/acpi/power.c
+++ b/drivers/acpi/power.c
@@ -42,8 +42,7 @@
42#include <linux/slab.h> 42#include <linux/slab.h>
43#include <linux/pm_runtime.h> 43#include <linux/pm_runtime.h>
44#include <linux/sysfs.h> 44#include <linux/sysfs.h>
45#include <acpi/acpi_bus.h> 45#include <linux/acpi.h>
46#include <acpi/acpi_drivers.h>
47#include "sleep.h" 46#include "sleep.h"
48#include "internal.h" 47#include "internal.h"
49 48
diff --git a/drivers/acpi/proc.c b/drivers/acpi/proc.c
index 6a5b152ad4d0..50fe34ffe932 100644
--- a/drivers/acpi/proc.c
+++ b/drivers/acpi/proc.c
@@ -3,12 +3,11 @@
3#include <linux/export.h> 3#include <linux/export.h>
4#include <linux/suspend.h> 4#include <linux/suspend.h>
5#include <linux/bcd.h> 5#include <linux/bcd.h>
6#include <linux/acpi.h>
6#include <asm/uaccess.h> 7#include <asm/uaccess.h>
7 8
8#include <acpi/acpi_bus.h>
9#include <acpi/acpi_drivers.h>
10
11#include "sleep.h" 9#include "sleep.h"
10#include "internal.h"
12 11
13#define _COMPONENT ACPI_SYSTEM_COMPONENT 12#define _COMPONENT ACPI_SYSTEM_COMPONENT
14 13
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index b3171f30b319..34e7b3c6a08d 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -10,8 +10,7 @@
10#include <linux/export.h> 10#include <linux/export.h>
11#include <linux/dmi.h> 11#include <linux/dmi.h>
12#include <linux/slab.h> 12#include <linux/slab.h>
13 13#include <linux/acpi.h>
14#include <acpi/acpi_drivers.h>
15#include <acpi/processor.h> 14#include <acpi/processor.h>
16 15
17#include "internal.h" 16#include "internal.h"
diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
index 146ab7e2b81d..c1c35623550f 100644
--- a/drivers/acpi/processor_driver.c
+++ b/drivers/acpi/processor_driver.c
@@ -224,9 +224,9 @@ static int __acpi_processor_start(struct acpi_device *device)
224 224
225static int acpi_processor_start(struct device *dev) 225static int acpi_processor_start(struct device *dev)
226{ 226{
227 struct acpi_device *device; 227 struct acpi_device *device = ACPI_COMPANION(dev);
228 228
229 if (acpi_bus_get_device(ACPI_HANDLE(dev), &device)) 229 if (!device)
230 return -ENODEV; 230 return -ENODEV;
231 231
232 return __acpi_processor_start(device); 232 return __acpi_processor_start(device);
@@ -234,10 +234,10 @@ static int acpi_processor_start(struct device *dev)
234 234
235static int acpi_processor_stop(struct device *dev) 235static int acpi_processor_stop(struct device *dev)
236{ 236{
237 struct acpi_device *device; 237 struct acpi_device *device = ACPI_COMPANION(dev);
238 struct acpi_processor *pr; 238 struct acpi_processor *pr;
239 239
240 if (acpi_bus_get_device(ACPI_HANDLE(dev), &device)) 240 if (!device)
241 return 0; 241 return 0;
242 242
243 acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, 243 acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY,
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 644516d9bde6..799644c3888c 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -35,6 +35,7 @@
35#include <linux/clockchips.h> 35#include <linux/clockchips.h>
36#include <linux/cpuidle.h> 36#include <linux/cpuidle.h>
37#include <linux/syscore_ops.h> 37#include <linux/syscore_ops.h>
38#include <acpi/processor.h>
38 39
39/* 40/*
40 * Include the apic definitions for x86 to have the APIC timer related defines 41 * Include the apic definitions for x86 to have the APIC timer related defines
@@ -46,9 +47,6 @@
46#include <asm/apic.h> 47#include <asm/apic.h>
47#endif 48#endif
48 49
49#include <acpi/acpi_bus.h>
50#include <acpi/processor.h>
51
52#define PREFIX "ACPI: " 50#define PREFIX "ACPI: "
53 51
54#define ACPI_PROCESSOR_CLASS "processor" 52#define ACPI_PROCESSOR_CLASS "processor"
@@ -213,7 +211,7 @@ static int acpi_processor_suspend(void)
213 211
214static void acpi_processor_resume(void) 212static void acpi_processor_resume(void)
215{ 213{
216 u32 resumed_bm_rld; 214 u32 resumed_bm_rld = 0;
217 215
218 acpi_read_bit_register(ACPI_BITREG_BUS_MASTER_RLD, &resumed_bm_rld); 216 acpi_read_bit_register(ACPI_BITREG_BUS_MASTER_RLD, &resumed_bm_rld);
219 if (resumed_bm_rld == saved_bm_rld) 217 if (resumed_bm_rld == saved_bm_rld)
@@ -598,7 +596,7 @@ static int acpi_processor_power_verify(struct acpi_processor *pr)
598 case ACPI_STATE_C2: 596 case ACPI_STATE_C2:
599 if (!cx->address) 597 if (!cx->address)
600 break; 598 break;
601 cx->valid = 1; 599 cx->valid = 1;
602 break; 600 break;
603 601
604 case ACPI_STATE_C3: 602 case ACPI_STATE_C3:
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index 60a7c28fc167..ff90054f04fd 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -31,15 +31,12 @@
31#include <linux/init.h> 31#include <linux/init.h>
32#include <linux/cpufreq.h> 32#include <linux/cpufreq.h>
33#include <linux/slab.h> 33#include <linux/slab.h>
34 34#include <linux/acpi.h>
35#include <acpi/processor.h>
35#ifdef CONFIG_X86 36#ifdef CONFIG_X86
36#include <asm/cpufeature.h> 37#include <asm/cpufeature.h>
37#endif 38#endif
38 39
39#include <acpi/acpi_bus.h>
40#include <acpi/acpi_drivers.h>
41#include <acpi/processor.h>
42
43#define PREFIX "ACPI: " 40#define PREFIX "ACPI: "
44 41
45#define ACPI_PROCESSOR_CLASS "processor" 42#define ACPI_PROCESSOR_CLASS "processor"
diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c
index d1d2e7fb5b30..e003663b2f8e 100644
--- a/drivers/acpi/processor_thermal.c
+++ b/drivers/acpi/processor_thermal.c
@@ -30,12 +30,9 @@
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/init.h> 31#include <linux/init.h>
32#include <linux/cpufreq.h> 32#include <linux/cpufreq.h>
33 33#include <linux/acpi.h>
34#include <asm/uaccess.h>
35
36#include <acpi/acpi_bus.h>
37#include <acpi/processor.h> 34#include <acpi/processor.h>
38#include <acpi/acpi_drivers.h> 35#include <asm/uaccess.h>
39 36
40#define PREFIX "ACPI: " 37#define PREFIX "ACPI: "
41 38
@@ -186,14 +183,14 @@ static int cpufreq_set_cur_state(unsigned int cpu, int state)
186 183
187#endif 184#endif
188 185
189/* thermal coolign device callbacks */ 186/* thermal cooling device callbacks */
190static int acpi_processor_max_state(struct acpi_processor *pr) 187static int acpi_processor_max_state(struct acpi_processor *pr)
191{ 188{
192 int max_state = 0; 189 int max_state = 0;
193 190
194 /* 191 /*
195 * There exists four states according to 192 * There exists four states according to
196 * cpufreq_thermal_reduction_ptg. 0, 1, 2, 3 193 * cpufreq_thermal_reduction_pctg. 0, 1, 2, 3
197 */ 194 */
198 max_state += cpufreq_get_max_state(pr->id); 195 max_state += cpufreq_get_max_state(pr->id);
199 if (pr->flags.throttling) 196 if (pr->flags.throttling)
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index e7dd2c1fee79..28baa05b8018 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -32,14 +32,11 @@
32#include <linux/init.h> 32#include <linux/init.h>
33#include <linux/sched.h> 33#include <linux/sched.h>
34#include <linux/cpufreq.h> 34#include <linux/cpufreq.h>
35 35#include <linux/acpi.h>
36#include <acpi/processor.h>
36#include <asm/io.h> 37#include <asm/io.h>
37#include <asm/uaccess.h> 38#include <asm/uaccess.h>
38 39
39#include <acpi/acpi_bus.h>
40#include <acpi/acpi_drivers.h>
41#include <acpi/processor.h>
42
43#define PREFIX "ACPI: " 40#define PREFIX "ACPI: "
44 41
45#define ACPI_PROCESSOR_CLASS "processor" 42#define ACPI_PROCESSOR_CLASS "processor"
diff --git a/drivers/acpi/sbshc.c b/drivers/acpi/sbshc.c
index b78bc605837e..26e5b5060523 100644
--- a/drivers/acpi/sbshc.c
+++ b/drivers/acpi/sbshc.c
@@ -8,8 +8,7 @@
8 * the Free Software Foundation version 2. 8 * the Free Software Foundation version 2.
9 */ 9 */
10 10
11#include <acpi/acpi_bus.h> 11#include <linux/acpi.h>
12#include <acpi/acpi_drivers.h>
13#include <linux/wait.h> 12#include <linux/wait.h>
14#include <linux/slab.h> 13#include <linux/slab.h>
15#include <linux/delay.h> 14#include <linux/delay.h>
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index fd39459926b1..c0f57ff15024 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -12,13 +12,12 @@
12#include <linux/dmi.h> 12#include <linux/dmi.h>
13#include <linux/nls.h> 13#include <linux/nls.h>
14 14
15#include <acpi/acpi_drivers.h> 15#include <asm/pgtable.h>
16 16
17#include "internal.h" 17#include "internal.h"
18 18
19#define _COMPONENT ACPI_BUS_COMPONENT 19#define _COMPONENT ACPI_BUS_COMPONENT
20ACPI_MODULE_NAME("scan"); 20ACPI_MODULE_NAME("scan");
21#define STRUCT_TO_INT(s) (*((int*)&s))
22extern struct acpi_device *acpi_root; 21extern struct acpi_device *acpi_root;
23 22
24#define ACPI_BUS_CLASS "system_bus" 23#define ACPI_BUS_CLASS "system_bus"
@@ -27,6 +26,8 @@ extern struct acpi_device *acpi_root;
27 26
28#define ACPI_IS_ROOT_DEVICE(device) (!(device)->parent) 27#define ACPI_IS_ROOT_DEVICE(device) (!(device)->parent)
29 28
29#define INVALID_ACPI_HANDLE ((acpi_handle)empty_zero_page)
30
30/* 31/*
31 * If set, devices will be hot-removed even if they cannot be put offline 32 * If set, devices will be hot-removed even if they cannot be put offline
32 * gracefully (from the kernel's standpoint). 33 * gracefully (from the kernel's standpoint).
@@ -125,6 +126,26 @@ acpi_device_modalias_show(struct device *dev, struct device_attribute *attr, cha
125} 126}
126static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL); 127static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL);
127 128
129bool acpi_scan_is_offline(struct acpi_device *adev, bool uevent)
130{
131 struct acpi_device_physical_node *pn;
132 bool offline = true;
133
134 mutex_lock(&adev->physical_node_lock);
135
136 list_for_each_entry(pn, &adev->physical_node_list, node)
137 if (device_supports_offline(pn->dev) && !pn->dev->offline) {
138 if (uevent)
139 kobject_uevent(&pn->dev->kobj, KOBJ_CHANGE);
140
141 offline = false;
142 break;
143 }
144
145 mutex_unlock(&adev->physical_node_lock);
146 return offline;
147}
148
128static acpi_status acpi_bus_offline(acpi_handle handle, u32 lvl, void *data, 149static acpi_status acpi_bus_offline(acpi_handle handle, u32 lvl, void *data,
129 void **ret_p) 150 void **ret_p)
130{ 151{
@@ -195,19 +216,11 @@ static acpi_status acpi_bus_online(acpi_handle handle, u32 lvl, void *data,
195 return AE_OK; 216 return AE_OK;
196} 217}
197 218
198static int acpi_scan_hot_remove(struct acpi_device *device) 219static int acpi_scan_try_to_offline(struct acpi_device *device)
199{ 220{
200 acpi_handle handle = device->handle; 221 acpi_handle handle = device->handle;
201 struct device *errdev; 222 struct device *errdev = NULL;
202 acpi_status status; 223 acpi_status status;
203 unsigned long long sta;
204
205 /* If there is no handle, the device node has been unregistered. */
206 if (!handle) {
207 dev_dbg(&device->dev, "ACPI handle missing\n");
208 put_device(&device->dev);
209 return -EINVAL;
210 }
211 224
212 /* 225 /*
213 * Carry out two passes here and ignore errors in the first pass, 226 * Carry out two passes here and ignore errors in the first pass,
@@ -218,7 +231,6 @@ static int acpi_scan_hot_remove(struct acpi_device *device)
218 * 231 *
219 * If the first pass is successful, the second one isn't needed, though. 232 * If the first pass is successful, the second one isn't needed, though.
220 */ 233 */
221 errdev = NULL;
222 status = acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX, 234 status = acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
223 NULL, acpi_bus_offline, (void *)false, 235 NULL, acpi_bus_offline, (void *)false,
224 (void **)&errdev); 236 (void **)&errdev);
@@ -226,7 +238,6 @@ static int acpi_scan_hot_remove(struct acpi_device *device)
226 dev_warn(errdev, "Offline disabled.\n"); 238 dev_warn(errdev, "Offline disabled.\n");
227 acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX, 239 acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
228 acpi_bus_online, NULL, NULL, NULL); 240 acpi_bus_online, NULL, NULL, NULL);
229 put_device(&device->dev);
230 return -EPERM; 241 return -EPERM;
231 } 242 }
232 acpi_bus_offline(handle, 0, (void *)false, (void **)&errdev); 243 acpi_bus_offline(handle, 0, (void *)false, (void **)&errdev);
@@ -245,20 +256,32 @@ static int acpi_scan_hot_remove(struct acpi_device *device)
245 acpi_walk_namespace(ACPI_TYPE_ANY, handle, 256 acpi_walk_namespace(ACPI_TYPE_ANY, handle,
246 ACPI_UINT32_MAX, acpi_bus_online, 257 ACPI_UINT32_MAX, acpi_bus_online,
247 NULL, NULL, NULL); 258 NULL, NULL, NULL);
248 put_device(&device->dev);
249 return -EBUSY; 259 return -EBUSY;
250 } 260 }
251 } 261 }
262 return 0;
263}
264
265static int acpi_scan_hot_remove(struct acpi_device *device)
266{
267 acpi_handle handle = device->handle;
268 unsigned long long sta;
269 acpi_status status;
270
271 if (device->handler->hotplug.demand_offline && !acpi_force_hot_remove) {
272 if (!acpi_scan_is_offline(device, true))
273 return -EBUSY;
274 } else {
275 int error = acpi_scan_try_to_offline(device);
276 if (error)
277 return error;
278 }
252 279
253 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 280 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
254 "Hot-removing device %s...\n", dev_name(&device->dev))); 281 "Hot-removing device %s...\n", dev_name(&device->dev)));
255 282
256 acpi_bus_trim(device); 283 acpi_bus_trim(device);
257 284
258 /* Device node has been unregistered. */
259 put_device(&device->dev);
260 device = NULL;
261
262 acpi_evaluate_lck(handle, 0); 285 acpi_evaluate_lck(handle, 0);
263 /* 286 /*
264 * TBD: _EJD support. 287 * TBD: _EJD support.
@@ -285,115 +308,127 @@ static int acpi_scan_hot_remove(struct acpi_device *device)
285 return 0; 308 return 0;
286} 309}
287 310
288void acpi_bus_device_eject(void *data, u32 ost_src) 311static int acpi_scan_device_not_present(struct acpi_device *adev)
289{ 312{
290 struct acpi_device *device = data; 313 if (!acpi_device_enumerated(adev)) {
291 acpi_handle handle = device->handle; 314 dev_warn(&adev->dev, "Still not present\n");
292 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; 315 return -EALREADY;
293 int error; 316 }
317 acpi_bus_trim(adev);
318 return 0;
319}
294 320
295 lock_device_hotplug(); 321static int acpi_scan_device_check(struct acpi_device *adev)
296 mutex_lock(&acpi_scan_lock); 322{
323 int error;
297 324
298 if (ost_src == ACPI_NOTIFY_EJECT_REQUEST) 325 acpi_bus_get_status(adev);
299 acpi_evaluate_hotplug_ost(handle, ACPI_NOTIFY_EJECT_REQUEST, 326 if (adev->status.present || adev->status.functional) {
300 ACPI_OST_SC_EJECT_IN_PROGRESS, NULL); 327 /*
328 * This function is only called for device objects for which
329 * matching scan handlers exist. The only situation in which
330 * the scan handler is not attached to this device object yet
331 * is when the device has just appeared (either it wasn't
332 * present at all before or it was removed and then added
333 * again).
334 */
335 if (adev->handler) {
336 dev_warn(&adev->dev, "Already enumerated\n");
337 return -EALREADY;
338 }
339 error = acpi_bus_scan(adev->handle);
340 if (error) {
341 dev_warn(&adev->dev, "Namespace scan failure\n");
342 return error;
343 }
344 if (!adev->handler) {
345 dev_warn(&adev->dev, "Enumeration failure\n");
346 error = -ENODEV;
347 }
348 } else {
349 error = acpi_scan_device_not_present(adev);
350 }
351 return error;
352}
301 353
302 if (device->handler && device->handler->hotplug.mode == AHM_CONTAINER) 354static int acpi_scan_bus_check(struct acpi_device *adev)
303 kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE); 355{
356 struct acpi_scan_handler *handler = adev->handler;
357 struct acpi_device *child;
358 int error;
304 359
305 error = acpi_scan_hot_remove(device); 360 acpi_bus_get_status(adev);
306 if (error == -EPERM) { 361 if (!(adev->status.present || adev->status.functional)) {
307 goto err_support; 362 acpi_scan_device_not_present(adev);
308 } else if (error) { 363 return 0;
309 goto err_out;
310 } 364 }
365 if (handler && handler->hotplug.scan_dependent)
366 return handler->hotplug.scan_dependent(adev);
311 367
312 out: 368 error = acpi_bus_scan(adev->handle);
313 mutex_unlock(&acpi_scan_lock); 369 if (error) {
314 unlock_device_hotplug(); 370 dev_warn(&adev->dev, "Namespace scan failure\n");
315 return; 371 return error;
316 372 }
317 err_support: 373 list_for_each_entry(child, &adev->children, node) {
318 ost_code = ACPI_OST_SC_EJECT_NOT_SUPPORTED; 374 error = acpi_scan_bus_check(child);
319 err_out: 375 if (error)
320 acpi_evaluate_hotplug_ost(handle, ost_src, ost_code, NULL); 376 return error;
321 goto out; 377 }
378 return 0;
322} 379}
323 380
324static void acpi_scan_bus_device_check(void *data, u32 ost_source) 381static void acpi_device_hotplug(void *data, u32 src)
325{ 382{
326 acpi_handle handle = data;
327 struct acpi_device *device = NULL;
328 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; 383 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE;
384 struct acpi_device *adev = data;
329 int error; 385 int error;
330 386
331 lock_device_hotplug(); 387 lock_device_hotplug();
332 mutex_lock(&acpi_scan_lock); 388 mutex_lock(&acpi_scan_lock);
333 389
334 if (ost_source != ACPI_NOTIFY_BUS_CHECK) { 390 /*
335 acpi_bus_get_device(handle, &device); 391 * The device object's ACPI handle cannot become invalid as long as we
336 if (device) { 392 * are holding acpi_scan_lock, but it may have become invalid before
337 dev_warn(&device->dev, "Attempt to re-insert\n"); 393 * that lock was acquired.
338 goto out; 394 */
339 } 395 if (adev->handle == INVALID_ACPI_HANDLE)
340 }
341 error = acpi_bus_scan(handle);
342 if (error) {
343 acpi_handle_warn(handle, "Namespace scan failure\n");
344 goto out;
345 }
346 error = acpi_bus_get_device(handle, &device);
347 if (error) {
348 acpi_handle_warn(handle, "Missing device node object\n");
349 goto out; 396 goto out;
350 }
351 ost_code = ACPI_OST_SC_SUCCESS;
352 if (device->handler && device->handler->hotplug.mode == AHM_CONTAINER)
353 kobject_uevent(&device->dev.kobj, KOBJ_ONLINE);
354
355 out:
356 acpi_evaluate_hotplug_ost(handle, ost_source, ost_code, NULL);
357 mutex_unlock(&acpi_scan_lock);
358 unlock_device_hotplug();
359}
360
361static void acpi_hotplug_unsupported(acpi_handle handle, u32 type)
362{
363 u32 ost_status;
364 397
365 switch (type) { 398 switch (src) {
366 case ACPI_NOTIFY_BUS_CHECK: 399 case ACPI_NOTIFY_BUS_CHECK:
367 acpi_handle_debug(handle, 400 error = acpi_scan_bus_check(adev);
368 "ACPI_NOTIFY_BUS_CHECK event: unsupported\n");
369 ost_status = ACPI_OST_SC_INSERT_NOT_SUPPORTED;
370 break; 401 break;
371 case ACPI_NOTIFY_DEVICE_CHECK: 402 case ACPI_NOTIFY_DEVICE_CHECK:
372 acpi_handle_debug(handle, 403 error = acpi_scan_device_check(adev);
373 "ACPI_NOTIFY_DEVICE_CHECK event: unsupported\n");
374 ost_status = ACPI_OST_SC_INSERT_NOT_SUPPORTED;
375 break; 404 break;
376 case ACPI_NOTIFY_EJECT_REQUEST: 405 case ACPI_NOTIFY_EJECT_REQUEST:
377 acpi_handle_debug(handle, 406 case ACPI_OST_EC_OSPM_EJECT:
378 "ACPI_NOTIFY_EJECT_REQUEST event: unsupported\n"); 407 error = acpi_scan_hot_remove(adev);
379 ost_status = ACPI_OST_SC_EJECT_NOT_SUPPORTED;
380 break; 408 break;
381 default: 409 default:
382 /* non-hotplug event; possibly handled by other handler */ 410 error = -EINVAL;
383 return; 411 break;
384 } 412 }
413 if (!error)
414 ost_code = ACPI_OST_SC_SUCCESS;
385 415
386 acpi_evaluate_hotplug_ost(handle, type, ost_status, NULL); 416 out:
417 acpi_evaluate_hotplug_ost(adev->handle, src, ost_code, NULL);
418 put_device(&adev->dev);
419 mutex_unlock(&acpi_scan_lock);
420 unlock_device_hotplug();
387} 421}
388 422
389static void acpi_hotplug_notify_cb(acpi_handle handle, u32 type, void *data) 423static void acpi_hotplug_notify_cb(acpi_handle handle, u32 type, void *data)
390{ 424{
425 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE;
391 struct acpi_scan_handler *handler = data; 426 struct acpi_scan_handler *handler = data;
392 struct acpi_device *adev; 427 struct acpi_device *adev;
393 acpi_status status; 428 acpi_status status;
394 429
395 if (!handler->hotplug.enabled) 430 if (acpi_bus_get_device(handle, &adev))
396 return acpi_hotplug_unsupported(handle, type); 431 goto err_out;
397 432
398 switch (type) { 433 switch (type) {
399 case ACPI_NOTIFY_BUS_CHECK: 434 case ACPI_NOTIFY_BUS_CHECK:
@@ -404,27 +439,27 @@ static void acpi_hotplug_notify_cb(acpi_handle handle, u32 type, void *data)
404 break; 439 break;
405 case ACPI_NOTIFY_EJECT_REQUEST: 440 case ACPI_NOTIFY_EJECT_REQUEST:
406 acpi_handle_debug(handle, "ACPI_NOTIFY_EJECT_REQUEST event\n"); 441 acpi_handle_debug(handle, "ACPI_NOTIFY_EJECT_REQUEST event\n");
407 if (acpi_bus_get_device(handle, &adev)) 442 if (!handler->hotplug.enabled) {
443 acpi_handle_err(handle, "Eject disabled\n");
444 ost_code = ACPI_OST_SC_EJECT_NOT_SUPPORTED;
408 goto err_out; 445 goto err_out;
409 446 }
410 get_device(&adev->dev); 447 acpi_evaluate_hotplug_ost(handle, ACPI_NOTIFY_EJECT_REQUEST,
411 status = acpi_hotplug_execute(acpi_bus_device_eject, adev, type); 448 ACPI_OST_SC_EJECT_IN_PROGRESS, NULL);
412 if (ACPI_SUCCESS(status)) 449 break;
413 return;
414
415 put_device(&adev->dev);
416 goto err_out;
417 default: 450 default:
418 /* non-hotplug event; possibly handled by other handler */ 451 /* non-hotplug event; possibly handled by other handler */
419 return; 452 return;
420 } 453 }
421 status = acpi_hotplug_execute(acpi_scan_bus_device_check, handle, type); 454 get_device(&adev->dev);
455 status = acpi_hotplug_execute(acpi_device_hotplug, adev, type);
422 if (ACPI_SUCCESS(status)) 456 if (ACPI_SUCCESS(status))
423 return; 457 return;
424 458
459 put_device(&adev->dev);
460
425 err_out: 461 err_out:
426 acpi_evaluate_hotplug_ost(handle, type, 462 acpi_evaluate_hotplug_ost(handle, type, ost_code, NULL);
427 ACPI_OST_SC_NON_SPECIFIC_FAILURE, NULL);
428} 463}
429 464
430static ssize_t real_power_state_show(struct device *dev, 465static ssize_t real_power_state_show(struct device *dev,
@@ -475,7 +510,7 @@ acpi_eject_store(struct device *d, struct device_attribute *attr,
475 acpi_evaluate_hotplug_ost(acpi_device->handle, ACPI_OST_EC_OSPM_EJECT, 510 acpi_evaluate_hotplug_ost(acpi_device->handle, ACPI_OST_EC_OSPM_EJECT,
476 ACPI_OST_SC_EJECT_IN_PROGRESS, NULL); 511 ACPI_OST_SC_EJECT_IN_PROGRESS, NULL);
477 get_device(&acpi_device->dev); 512 get_device(&acpi_device->dev);
478 status = acpi_hotplug_execute(acpi_bus_device_eject, acpi_device, 513 status = acpi_hotplug_execute(acpi_device_hotplug, acpi_device,
479 ACPI_OST_EC_OSPM_EJECT); 514 ACPI_OST_EC_OSPM_EJECT);
480 if (ACPI_SUCCESS(status)) 515 if (ACPI_SUCCESS(status))
481 return count; 516 return count;
@@ -567,6 +602,20 @@ acpi_device_sun_show(struct device *dev, struct device_attribute *attr,
567} 602}
568static DEVICE_ATTR(sun, 0444, acpi_device_sun_show, NULL); 603static DEVICE_ATTR(sun, 0444, acpi_device_sun_show, NULL);
569 604
605static ssize_t status_show(struct device *dev, struct device_attribute *attr,
606 char *buf) {
607 struct acpi_device *acpi_dev = to_acpi_device(dev);
608 acpi_status status;
609 unsigned long long sta;
610
611 status = acpi_evaluate_integer(acpi_dev->handle, "_STA", NULL, &sta);
612 if (ACPI_FAILURE(status))
613 return -ENODEV;
614
615 return sprintf(buf, "%llu\n", sta);
616}
617static DEVICE_ATTR_RO(status);
618
570static int acpi_device_setup_files(struct acpi_device *dev) 619static int acpi_device_setup_files(struct acpi_device *dev)
571{ 620{
572 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 621 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
@@ -622,6 +671,12 @@ static int acpi_device_setup_files(struct acpi_device *dev)
622 dev->pnp.sun = (unsigned long)-1; 671 dev->pnp.sun = (unsigned long)-1;
623 } 672 }
624 673
674 if (acpi_has_method(dev->handle, "_STA")) {
675 result = device_create_file(&dev->dev, &dev_attr_status);
676 if (result)
677 goto end;
678 }
679
625 /* 680 /*
626 * If device has _EJ0, 'eject' file is created that is used to trigger 681 * If device has _EJ0, 'eject' file is created that is used to trigger
627 * hot-removal function from userland. 682 * hot-removal function from userland.
@@ -677,6 +732,8 @@ static void acpi_device_remove_files(struct acpi_device *dev)
677 device_remove_file(&dev->dev, &dev_attr_adr); 732 device_remove_file(&dev->dev, &dev_attr_adr);
678 device_remove_file(&dev->dev, &dev_attr_modalias); 733 device_remove_file(&dev->dev, &dev_attr_modalias);
679 device_remove_file(&dev->dev, &dev_attr_hid); 734 device_remove_file(&dev->dev, &dev_attr_hid);
735 if (acpi_has_method(dev->handle, "_STA"))
736 device_remove_file(&dev->dev, &dev_attr_status);
680 if (dev->handle) 737 if (dev->handle)
681 device_remove_file(&dev->dev, &dev_attr_path); 738 device_remove_file(&dev->dev, &dev_attr_path);
682} 739}
@@ -907,9 +964,91 @@ struct bus_type acpi_bus_type = {
907 .uevent = acpi_device_uevent, 964 .uevent = acpi_device_uevent,
908}; 965};
909 966
910static void acpi_bus_data_handler(acpi_handle handle, void *context) 967static void acpi_device_del(struct acpi_device *device)
911{ 968{
912 /* Intentionally empty. */ 969 mutex_lock(&acpi_device_lock);
970 if (device->parent)
971 list_del(&device->node);
972
973 list_del(&device->wakeup_list);
974 mutex_unlock(&acpi_device_lock);
975
976 acpi_power_add_remove_device(device, false);
977 acpi_device_remove_files(device);
978 if (device->remove)
979 device->remove(device);
980
981 device_del(&device->dev);
982}
983
984static LIST_HEAD(acpi_device_del_list);
985static DEFINE_MUTEX(acpi_device_del_lock);
986
987static void acpi_device_del_work_fn(struct work_struct *work_not_used)
988{
989 for (;;) {
990 struct acpi_device *adev;
991
992 mutex_lock(&acpi_device_del_lock);
993
994 if (list_empty(&acpi_device_del_list)) {
995 mutex_unlock(&acpi_device_del_lock);
996 break;
997 }
998 adev = list_first_entry(&acpi_device_del_list,
999 struct acpi_device, del_list);
1000 list_del(&adev->del_list);
1001
1002 mutex_unlock(&acpi_device_del_lock);
1003
1004 acpi_device_del(adev);
1005 /*
1006 * Drop references to all power resources that might have been
1007 * used by the device.
1008 */
1009 acpi_power_transition(adev, ACPI_STATE_D3_COLD);
1010 put_device(&adev->dev);
1011 }
1012}
1013
1014/**
1015 * acpi_scan_drop_device - Drop an ACPI device object.
1016 * @handle: Handle of an ACPI namespace node, not used.
1017 * @context: Address of the ACPI device object to drop.
1018 *
1019 * This is invoked by acpi_ns_delete_node() during the removal of the ACPI
1020 * namespace node the device object pointed to by @context is attached to.
1021 *
1022 * The unregistration is carried out asynchronously to avoid running
1023 * acpi_device_del() under the ACPICA's namespace mutex and the list is used to
1024 * ensure the correct ordering (the device objects must be unregistered in the
1025 * same order in which the corresponding namespace nodes are deleted).
1026 */
1027static void acpi_scan_drop_device(acpi_handle handle, void *context)
1028{
1029 static DECLARE_WORK(work, acpi_device_del_work_fn);
1030 struct acpi_device *adev = context;
1031
1032 mutex_lock(&acpi_device_del_lock);
1033
1034 /*
1035 * Use the ACPI hotplug workqueue which is ordered, so this work item
1036 * won't run after any hotplug work items submitted subsequently. That
1037 * prevents attempts to register device objects identical to those being
1038 * deleted from happening concurrently (such attempts result from
1039 * hotplug events handled via the ACPI hotplug workqueue). It also will
1040 * run after all of the work items submitted previosuly, which helps
1041 * those work items to ensure that they are not accessing stale device
1042 * objects.
1043 */
1044 if (list_empty(&acpi_device_del_list))
1045 acpi_queue_hotplug_work(&work);
1046
1047 list_add_tail(&adev->del_list, &acpi_device_del_list);
1048 /* Make acpi_ns_validate_handle() return NULL for this handle. */
1049 adev->handle = INVALID_ACPI_HANDLE;
1050
1051 mutex_unlock(&acpi_device_del_lock);
913} 1052}
914 1053
915int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device) 1054int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device)
@@ -919,7 +1058,7 @@ int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device)
919 if (!device) 1058 if (!device)
920 return -EINVAL; 1059 return -EINVAL;
921 1060
922 status = acpi_get_data(handle, acpi_bus_data_handler, (void **)device); 1061 status = acpi_get_data(handle, acpi_scan_drop_device, (void **)device);
923 if (ACPI_FAILURE(status) || !*device) { 1062 if (ACPI_FAILURE(status) || !*device) {
924 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No context for object [%p]\n", 1063 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No context for object [%p]\n",
925 handle)); 1064 handle));
@@ -939,7 +1078,7 @@ int acpi_device_add(struct acpi_device *device,
939 if (device->handle) { 1078 if (device->handle) {
940 acpi_status status; 1079 acpi_status status;
941 1080
942 status = acpi_attach_data(device->handle, acpi_bus_data_handler, 1081 status = acpi_attach_data(device->handle, acpi_scan_drop_device,
943 device); 1082 device);
944 if (ACPI_FAILURE(status)) { 1083 if (ACPI_FAILURE(status)) {
945 acpi_handle_err(device->handle, 1084 acpi_handle_err(device->handle,
@@ -957,6 +1096,7 @@ int acpi_device_add(struct acpi_device *device,
957 INIT_LIST_HEAD(&device->node); 1096 INIT_LIST_HEAD(&device->node);
958 INIT_LIST_HEAD(&device->wakeup_list); 1097 INIT_LIST_HEAD(&device->wakeup_list);
959 INIT_LIST_HEAD(&device->physical_node_list); 1098 INIT_LIST_HEAD(&device->physical_node_list);
1099 INIT_LIST_HEAD(&device->del_list);
960 mutex_init(&device->physical_node_lock); 1100 mutex_init(&device->physical_node_lock);
961 1101
962 new_bus_id = kzalloc(sizeof(struct acpi_device_bus_id), GFP_KERNEL); 1102 new_bus_id = kzalloc(sizeof(struct acpi_device_bus_id), GFP_KERNEL);
@@ -1020,37 +1160,10 @@ int acpi_device_add(struct acpi_device *device,
1020 mutex_unlock(&acpi_device_lock); 1160 mutex_unlock(&acpi_device_lock);
1021 1161
1022 err_detach: 1162 err_detach:
1023 acpi_detach_data(device->handle, acpi_bus_data_handler); 1163 acpi_detach_data(device->handle, acpi_scan_drop_device);
1024 return result; 1164 return result;
1025} 1165}
1026 1166
1027static void acpi_device_unregister(struct acpi_device *device)
1028{
1029 mutex_lock(&acpi_device_lock);
1030 if (device->parent)
1031 list_del(&device->node);
1032
1033 list_del(&device->wakeup_list);
1034 mutex_unlock(&acpi_device_lock);
1035
1036 acpi_detach_data(device->handle, acpi_bus_data_handler);
1037
1038 acpi_power_add_remove_device(device, false);
1039 acpi_device_remove_files(device);
1040 if (device->remove)
1041 device->remove(device);
1042
1043 device_del(&device->dev);
1044 /*
1045 * Transition the device to D3cold to drop the reference counts of all
1046 * power resources the device depends on and turn off the ones that have
1047 * no more references.
1048 */
1049 acpi_device_set_power(device, ACPI_STATE_D3_COLD);
1050 device->handle = NULL;
1051 put_device(&device->dev);
1052}
1053
1054/* -------------------------------------------------------------------------- 1167/* --------------------------------------------------------------------------
1055 Driver Management 1168 Driver Management
1056 -------------------------------------------------------------------------- */ 1169 -------------------------------------------------------------------------- */
@@ -1624,11 +1737,13 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
1624 device->device_type = type; 1737 device->device_type = type;
1625 device->handle = handle; 1738 device->handle = handle;
1626 device->parent = acpi_bus_get_parent(handle); 1739 device->parent = acpi_bus_get_parent(handle);
1627 STRUCT_TO_INT(device->status) = sta; 1740 acpi_set_device_status(device, sta);
1628 acpi_device_get_busid(device); 1741 acpi_device_get_busid(device);
1629 acpi_set_pnp_ids(handle, &device->pnp, type); 1742 acpi_set_pnp_ids(handle, &device->pnp, type);
1630 acpi_bus_get_flags(device); 1743 acpi_bus_get_flags(device);
1631 device->flags.match_driver = false; 1744 device->flags.match_driver = false;
1745 device->flags.initialized = true;
1746 device->flags.visited = false;
1632 device_initialize(&device->dev); 1747 device_initialize(&device->dev);
1633 dev_set_uevent_suppress(&device->dev, true); 1748 dev_set_uevent_suppress(&device->dev, true);
1634} 1749}
@@ -1713,6 +1828,15 @@ static int acpi_bus_type_and_status(acpi_handle handle, int *type,
1713 return 0; 1828 return 0;
1714} 1829}
1715 1830
1831bool acpi_device_is_present(struct acpi_device *adev)
1832{
1833 if (adev->status.present || adev->status.functional)
1834 return true;
1835
1836 adev->flags.initialized = false;
1837 return false;
1838}
1839
1716static bool acpi_scan_handler_matching(struct acpi_scan_handler *handler, 1840static bool acpi_scan_handler_matching(struct acpi_scan_handler *handler,
1717 char *idstr, 1841 char *idstr,
1718 const struct acpi_device_id **matchid) 1842 const struct acpi_device_id **matchid)
@@ -1772,7 +1896,7 @@ static void acpi_scan_init_hotplug(acpi_handle handle, int type)
1772 */ 1896 */
1773 list_for_each_entry(hwid, &pnp.ids, list) { 1897 list_for_each_entry(hwid, &pnp.ids, list) {
1774 handler = acpi_scan_match_handler(hwid->id, NULL); 1898 handler = acpi_scan_match_handler(hwid->id, NULL);
1775 if (handler && !handler->hotplug.ignore) { 1899 if (handler) {
1776 acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, 1900 acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
1777 acpi_hotplug_notify_cb, handler); 1901 acpi_hotplug_notify_cb, handler);
1778 break; 1902 break;
@@ -1806,18 +1930,6 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used,
1806 1930
1807 acpi_scan_init_hotplug(handle, type); 1931 acpi_scan_init_hotplug(handle, type);
1808 1932
1809 if (!(sta & ACPI_STA_DEVICE_PRESENT) &&
1810 !(sta & ACPI_STA_DEVICE_FUNCTIONING)) {
1811 struct acpi_device_wakeup wakeup;
1812
1813 if (acpi_has_method(handle, "_PRW")) {
1814 acpi_bus_extract_wakeup_device_power_package(handle,
1815 &wakeup);
1816 acpi_power_resources_list_free(&wakeup.resources);
1817 }
1818 return AE_CTRL_DEPTH;
1819 }
1820
1821 acpi_add_single_object(&device, handle, type, sta); 1933 acpi_add_single_object(&device, handle, type, sta);
1822 if (!device) 1934 if (!device)
1823 return AE_CTRL_DEPTH; 1935 return AE_CTRL_DEPTH;
@@ -1852,36 +1964,40 @@ static int acpi_scan_attach_handler(struct acpi_device *device)
1852 return ret; 1964 return ret;
1853} 1965}
1854 1966
1855static acpi_status acpi_bus_device_attach(acpi_handle handle, u32 lvl_not_used, 1967static void acpi_bus_attach(struct acpi_device *device)
1856 void *not_used, void **ret_not_used)
1857{ 1968{
1858 struct acpi_device *device; 1969 struct acpi_device *child;
1859 unsigned long long sta_not_used;
1860 int ret; 1970 int ret;
1861 1971
1862 /* 1972 acpi_bus_get_status(device);
1863 * Ignore errors ignored by acpi_bus_check_add() to avoid terminating 1973 /* Skip devices that are not present. */
1864 * namespace walks prematurely. 1974 if (!acpi_device_is_present(device)) {
1865 */ 1975 device->flags.visited = false;
1866 if (acpi_bus_type_and_status(handle, &ret, &sta_not_used)) 1976 return;
1867 return AE_OK; 1977 }
1868
1869 if (acpi_bus_get_device(handle, &device))
1870 return AE_CTRL_DEPTH;
1871
1872 if (device->handler) 1978 if (device->handler)
1873 return AE_OK; 1979 goto ok;
1874 1980
1981 if (!device->flags.initialized) {
1982 acpi_bus_update_power(device, NULL);
1983 device->flags.initialized = true;
1984 }
1985 device->flags.visited = false;
1875 ret = acpi_scan_attach_handler(device); 1986 ret = acpi_scan_attach_handler(device);
1876 if (ret < 0) 1987 if (ret < 0)
1877 return AE_CTRL_DEPTH; 1988 return;
1878 1989
1879 device->flags.match_driver = true; 1990 device->flags.match_driver = true;
1880 if (ret > 0) 1991 if (!ret) {
1881 return AE_OK; 1992 ret = device_attach(&device->dev);
1993 if (ret < 0)
1994 return;
1995 }
1996 device->flags.visited = true;
1882 1997
1883 ret = device_attach(&device->dev); 1998 ok:
1884 return ret >= 0 ? AE_OK : AE_CTRL_DEPTH; 1999 list_for_each_entry(child, &device->children, node)
2000 acpi_bus_attach(child);
1885} 2001}
1886 2002
1887/** 2003/**
@@ -1901,75 +2017,48 @@ static acpi_status acpi_bus_device_attach(acpi_handle handle, u32 lvl_not_used,
1901int acpi_bus_scan(acpi_handle handle) 2017int acpi_bus_scan(acpi_handle handle)
1902{ 2018{
1903 void *device = NULL; 2019 void *device = NULL;
1904 int error = 0;
1905 2020
1906 if (ACPI_SUCCESS(acpi_bus_check_add(handle, 0, NULL, &device))) 2021 if (ACPI_SUCCESS(acpi_bus_check_add(handle, 0, NULL, &device)))
1907 acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX, 2022 acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
1908 acpi_bus_check_add, NULL, NULL, &device); 2023 acpi_bus_check_add, NULL, NULL, &device);
1909 2024
1910 if (!device) 2025 if (device) {
1911 error = -ENODEV; 2026 acpi_bus_attach(device);
1912 else if (ACPI_SUCCESS(acpi_bus_device_attach(handle, 0, NULL, NULL))) 2027 return 0;
1913 acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
1914 acpi_bus_device_attach, NULL, NULL, NULL);
1915
1916 return error;
1917}
1918EXPORT_SYMBOL(acpi_bus_scan);
1919
1920static acpi_status acpi_bus_device_detach(acpi_handle handle, u32 lvl_not_used,
1921 void *not_used, void **ret_not_used)
1922{
1923 struct acpi_device *device = NULL;
1924
1925 if (!acpi_bus_get_device(handle, &device)) {
1926 struct acpi_scan_handler *dev_handler = device->handler;
1927
1928 if (dev_handler) {
1929 if (dev_handler->detach)
1930 dev_handler->detach(device);
1931
1932 device->handler = NULL;
1933 } else {
1934 device_release_driver(&device->dev);
1935 }
1936 } 2028 }
1937 return AE_OK; 2029 return -ENODEV;
1938}
1939
1940static acpi_status acpi_bus_remove(acpi_handle handle, u32 lvl_not_used,
1941 void *not_used, void **ret_not_used)
1942{
1943 struct acpi_device *device = NULL;
1944
1945 if (!acpi_bus_get_device(handle, &device))
1946 acpi_device_unregister(device);
1947
1948 return AE_OK;
1949} 2030}
2031EXPORT_SYMBOL(acpi_bus_scan);
1950 2032
1951/** 2033/**
1952 * acpi_bus_trim - Remove ACPI device node and all of its descendants 2034 * acpi_bus_trim - Detach scan handlers and drivers from ACPI device objects.
1953 * @start: Root of the ACPI device nodes subtree to remove. 2035 * @adev: Root of the ACPI namespace scope to walk.
1954 * 2036 *
1955 * Must be called under acpi_scan_lock. 2037 * Must be called under acpi_scan_lock.
1956 */ 2038 */
1957void acpi_bus_trim(struct acpi_device *start) 2039void acpi_bus_trim(struct acpi_device *adev)
1958{ 2040{
2041 struct acpi_scan_handler *handler = adev->handler;
2042 struct acpi_device *child;
2043
2044 list_for_each_entry_reverse(child, &adev->children, node)
2045 acpi_bus_trim(child);
2046
2047 if (handler) {
2048 if (handler->detach)
2049 handler->detach(adev);
2050
2051 adev->handler = NULL;
2052 } else {
2053 device_release_driver(&adev->dev);
2054 }
1959 /* 2055 /*
1960 * Execute acpi_bus_device_detach() as a post-order callback to detach 2056 * Most likely, the device is going away, so put it into D3cold before
1961 * all ACPI drivers from the device nodes being removed. 2057 * that.
1962 */
1963 acpi_walk_namespace(ACPI_TYPE_ANY, start->handle, ACPI_UINT32_MAX, NULL,
1964 acpi_bus_device_detach, NULL, NULL);
1965 acpi_bus_device_detach(start->handle, 0, NULL, NULL);
1966 /*
1967 * Execute acpi_bus_remove() as a post-order callback to remove device
1968 * nodes in the given namespace scope.
1969 */ 2058 */
1970 acpi_walk_namespace(ACPI_TYPE_ANY, start->handle, ACPI_UINT32_MAX, NULL, 2059 acpi_device_set_power(adev, ACPI_STATE_D3_COLD);
1971 acpi_bus_remove, NULL, NULL); 2060 adev->flags.initialized = false;
1972 acpi_bus_remove(start->handle, 0, NULL, NULL); 2061 adev->flags.visited = false;
1973} 2062}
1974EXPORT_SYMBOL_GPL(acpi_bus_trim); 2063EXPORT_SYMBOL_GPL(acpi_bus_trim);
1975 2064
@@ -2047,14 +2136,14 @@ int __init acpi_scan_init(void)
2047 2136
2048 result = acpi_bus_scan_fixed(); 2137 result = acpi_bus_scan_fixed();
2049 if (result) { 2138 if (result) {
2050 acpi_device_unregister(acpi_root); 2139 acpi_detach_data(acpi_root->handle, acpi_scan_drop_device);
2140 acpi_device_del(acpi_root);
2141 put_device(&acpi_root->dev);
2051 goto out; 2142 goto out;
2052 } 2143 }
2053 2144
2054 acpi_update_all_gpes(); 2145 acpi_update_all_gpes();
2055 2146
2056 acpi_pci_root_hp_init();
2057
2058 out: 2147 out:
2059 mutex_unlock(&acpi_scan_lock); 2148 mutex_unlock(&acpi_scan_lock);
2060 return result; 2149 return result;
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 721e949e606e..b718806657cd 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -18,12 +18,8 @@
18#include <linux/reboot.h> 18#include <linux/reboot.h>
19#include <linux/acpi.h> 19#include <linux/acpi.h>
20#include <linux/module.h> 20#include <linux/module.h>
21
22#include <asm/io.h> 21#include <asm/io.h>
23 22
24#include <acpi/acpi_bus.h>
25#include <acpi/acpi_drivers.h>
26
27#include "internal.h" 23#include "internal.h"
28#include "sleep.h" 24#include "sleep.h"
29 25
@@ -670,11 +666,8 @@ static void acpi_hibernation_leave(void)
670 /* Reprogram control registers */ 666 /* Reprogram control registers */
671 acpi_leave_sleep_state_prep(ACPI_STATE_S4); 667 acpi_leave_sleep_state_prep(ACPI_STATE_S4);
672 /* Check the hardware signature */ 668 /* Check the hardware signature */
673 if (facs && s4_hardware_signature != facs->hardware_signature) { 669 if (facs && s4_hardware_signature != facs->hardware_signature)
674 printk(KERN_EMERG "ACPI: Hardware changed while hibernated, " 670 pr_crit("ACPI: Hardware changed while hibernated, success doubtful!\n");
675 "cannot resume!\n");
676 panic("ACPI S4 hardware signature mismatch");
677 }
678 /* Restore the NVS memory area */ 671 /* Restore the NVS memory area */
679 suspend_nvs_restore(); 672 suspend_nvs_restore();
680 /* Allow EC transactions to happen. */ 673 /* Allow EC transactions to happen. */
@@ -806,9 +799,6 @@ int __init acpi_sleep_init(void)
806 char *pos = supported; 799 char *pos = supported;
807 int i; 800 int i;
808 801
809 if (acpi_disabled)
810 return 0;
811
812 acpi_sleep_dmi_check(); 802 acpi_sleep_dmi_check();
813 803
814 sleep_states[ACPI_STATE_S0] = 1; 804 sleep_states[ACPI_STATE_S0] = 1;
diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
index 6dbc3ca45223..443dc9366052 100644
--- a/drivers/acpi/sysfs.c
+++ b/drivers/acpi/sysfs.c
@@ -5,7 +5,7 @@
5#include <linux/init.h> 5#include <linux/init.h>
6#include <linux/kernel.h> 6#include <linux/kernel.h>
7#include <linux/moduleparam.h> 7#include <linux/moduleparam.h>
8#include <acpi/acpi_drivers.h> 8#include <linux/acpi.h>
9 9
10#include "internal.h" 10#include "internal.h"
11 11
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
index d67a1fe07f0e..5837f857ac2e 100644
--- a/drivers/acpi/tables.c
+++ b/drivers/acpi/tables.c
@@ -278,12 +278,13 @@ acpi_table_parse_madt(enum acpi_madt_type id,
278 278
279/** 279/**
280 * acpi_table_parse - find table with @id, run @handler on it 280 * acpi_table_parse - find table with @id, run @handler on it
281 *
282 * @id: table id to find 281 * @id: table id to find
283 * @handler: handler to run 282 * @handler: handler to run
284 * 283 *
285 * Scan the ACPI System Descriptor Table (STD) for a table matching @id, 284 * Scan the ACPI System Descriptor Table (STD) for a table matching @id,
286 * run @handler on it. Return 0 if table found, return on if not. 285 * run @handler on it.
286 *
287 * Return 0 if table found, -errno if not.
287 */ 288 */
288int __init acpi_table_parse(char *id, acpi_tbl_table_handler handler) 289int __init acpi_table_parse(char *id, acpi_tbl_table_handler handler)
289{ 290{
@@ -293,7 +294,7 @@ int __init acpi_table_parse(char *id, acpi_tbl_table_handler handler)
293 if (acpi_disabled) 294 if (acpi_disabled)
294 return -ENODEV; 295 return -ENODEV;
295 296
296 if (!handler) 297 if (!id || !handler)
297 return -EINVAL; 298 return -EINVAL;
298 299
299 if (strncmp(id, ACPI_SIG_MADT, 4) == 0) 300 if (strncmp(id, ACPI_SIG_MADT, 4) == 0)
@@ -306,7 +307,7 @@ int __init acpi_table_parse(char *id, acpi_tbl_table_handler handler)
306 early_acpi_os_unmap_memory(table, tbl_size); 307 early_acpi_os_unmap_memory(table, tbl_size);
307 return 0; 308 return 0;
308 } else 309 } else
309 return 1; 310 return -ENODEV;
310} 311}
311 312
312/* 313/*
@@ -351,7 +352,7 @@ int __init acpi_table_init(void)
351 352
352 status = acpi_initialize_tables(initial_tables, ACPI_MAX_TABLES, 0); 353 status = acpi_initialize_tables(initial_tables, ACPI_MAX_TABLES, 0);
353 if (ACPI_FAILURE(status)) 354 if (ACPI_FAILURE(status))
354 return 1; 355 return -EINVAL;
355 356
356 check_multiple_madt(); 357 check_multiple_madt();
357 return 0; 358 return 0;
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 0d9f46b5ae6d..8349a555b92b 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -41,10 +41,9 @@
41#include <linux/kmod.h> 41#include <linux/kmod.h>
42#include <linux/reboot.h> 42#include <linux/reboot.h>
43#include <linux/device.h> 43#include <linux/device.h>
44#include <asm/uaccess.h>
45#include <linux/thermal.h> 44#include <linux/thermal.h>
46#include <acpi/acpi_bus.h> 45#include <linux/acpi.h>
47#include <acpi/acpi_drivers.h> 46#include <asm/uaccess.h>
48 47
49#define PREFIX "ACPI: " 48#define PREFIX "ACPI: "
50 49
@@ -862,7 +861,7 @@ acpi_thermal_unbind_cooling_device(struct thermal_zone_device *thermal,
862 return acpi_thermal_cooling_device_cb(thermal, cdev, false); 861 return acpi_thermal_cooling_device_cb(thermal, cdev, false);
863} 862}
864 863
865static const struct thermal_zone_device_ops acpi_thermal_zone_ops = { 864static struct thermal_zone_device_ops acpi_thermal_zone_ops = {
866 .bind = acpi_thermal_bind_cooling_device, 865 .bind = acpi_thermal_bind_cooling_device,
867 .unbind = acpi_thermal_unbind_cooling_device, 866 .unbind = acpi_thermal_unbind_cooling_device,
868 .get_temp = thermal_get_temp, 867 .get_temp = thermal_get_temp,
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index 6d408bfbbb1d..0347a37eb438 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -30,8 +30,6 @@
30#include <linux/types.h> 30#include <linux/types.h>
31#include <linux/hardirq.h> 31#include <linux/hardirq.h>
32#include <linux/acpi.h> 32#include <linux/acpi.h>
33#include <acpi/acpi_bus.h>
34#include <acpi/acpi_drivers.h>
35 33
36#include "internal.h" 34#include "internal.h"
37 35
@@ -574,3 +572,100 @@ acpi_status acpi_evaluate_lck(acpi_handle handle, int lock)
574 572
575 return status; 573 return status;
576} 574}
575
576/**
577 * acpi_evaluate_dsm - evaluate device's _DSM method
578 * @handle: ACPI device handle
579 * @uuid: UUID of requested functions, should be 16 bytes
580 * @rev: revision number of requested function
581 * @func: requested function number
582 * @argv4: the function specific parameter
583 *
584 * Evaluate device's _DSM method with specified UUID, revision id and
585 * function number. Caller needs to free the returned object.
586 *
587 * Though ACPI defines the fourth parameter for _DSM should be a package,
588 * some old BIOSes do expect a buffer or an integer etc.
589 */
590union acpi_object *
591acpi_evaluate_dsm(acpi_handle handle, const u8 *uuid, int rev, int func,
592 union acpi_object *argv4)
593{
594 acpi_status ret;
595 struct acpi_buffer buf = {ACPI_ALLOCATE_BUFFER, NULL};
596 union acpi_object params[4];
597 struct acpi_object_list input = {
598 .count = 4,
599 .pointer = params,
600 };
601
602 params[0].type = ACPI_TYPE_BUFFER;
603 params[0].buffer.length = 16;
604 params[0].buffer.pointer = (char *)uuid;
605 params[1].type = ACPI_TYPE_INTEGER;
606 params[1].integer.value = rev;
607 params[2].type = ACPI_TYPE_INTEGER;
608 params[2].integer.value = func;
609 if (argv4) {
610 params[3] = *argv4;
611 } else {
612 params[3].type = ACPI_TYPE_PACKAGE;
613 params[3].package.count = 0;
614 params[3].package.elements = NULL;
615 }
616
617 ret = acpi_evaluate_object(handle, "_DSM", &input, &buf);
618 if (ACPI_SUCCESS(ret))
619 return (union acpi_object *)buf.pointer;
620
621 if (ret != AE_NOT_FOUND)
622 acpi_handle_warn(handle,
623 "failed to evaluate _DSM (0x%x)\n", ret);
624
625 return NULL;
626}
627EXPORT_SYMBOL(acpi_evaluate_dsm);
628
629/**
630 * acpi_check_dsm - check if _DSM method supports requested functions.
631 * @handle: ACPI device handle
632 * @uuid: UUID of requested functions, should be 16 bytes at least
633 * @rev: revision number of requested functions
634 * @funcs: bitmap of requested functions
635 * @exclude: excluding special value, used to support i915 and nouveau
636 *
637 * Evaluate device's _DSM method to check whether it supports requested
638 * functions. Currently only support 64 functions at maximum, should be
639 * enough for now.
640 */
641bool acpi_check_dsm(acpi_handle handle, const u8 *uuid, int rev, u64 funcs)
642{
643 int i;
644 u64 mask = 0;
645 union acpi_object *obj;
646
647 if (funcs == 0)
648 return false;
649
650 obj = acpi_evaluate_dsm(handle, uuid, rev, 0, NULL);
651 if (!obj)
652 return false;
653
654 /* For compatibility, old BIOSes may return an integer */
655 if (obj->type == ACPI_TYPE_INTEGER)
656 mask = obj->integer.value;
657 else if (obj->type == ACPI_TYPE_BUFFER)
658 for (i = 0; i < obj->buffer.length && i < 8; i++)
659 mask |= (((u8)obj->buffer.pointer[i]) << (i * 8));
660 ACPI_FREE(obj);
661
662 /*
663 * Bit 0 indicates whether there's support for any functions other than
664 * function 0 for the specified UUID and revision.
665 */
666 if ((mask & 0x1) && (mask & funcs) == funcs)
667 return true;
668
669 return false;
670}
671EXPORT_SYMBOL(acpi_check_dsm);
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 995e91bcb97b..b727d105046d 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -37,12 +37,11 @@
37#include <linux/pci.h> 37#include <linux/pci.h>
38#include <linux/pci_ids.h> 38#include <linux/pci_ids.h>
39#include <linux/slab.h> 39#include <linux/slab.h>
40#include <asm/uaccess.h>
41#include <linux/dmi.h> 40#include <linux/dmi.h>
42#include <acpi/acpi_bus.h>
43#include <acpi/acpi_drivers.h>
44#include <linux/suspend.h> 41#include <linux/suspend.h>
42#include <linux/acpi.h>
45#include <acpi/video.h> 43#include <acpi/video.h>
44#include <asm/uaccess.h>
46 45
47#include "internal.h" 46#include "internal.h"
48 47
diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
index 84875fd4c74f..f0447d3daf2c 100644
--- a/drivers/acpi/video_detect.c
+++ b/drivers/acpi/video_detect.c
@@ -50,7 +50,7 @@ static bool acpi_video_caps_checked;
50 50
51static acpi_status 51static acpi_status
52acpi_backlight_cap_match(acpi_handle handle, u32 level, void *context, 52acpi_backlight_cap_match(acpi_handle handle, u32 level, void *context,
53 void **retyurn_value) 53 void **return_value)
54{ 54{
55 long *cap = context; 55 long *cap = context;
56 56
diff --git a/drivers/acpi/wakeup.c b/drivers/acpi/wakeup.c
index 7bfbe40bc43b..1638401ab282 100644
--- a/drivers/acpi/wakeup.c
+++ b/drivers/acpi/wakeup.c
@@ -5,7 +5,6 @@
5 5
6#include <linux/init.h> 6#include <linux/init.h>
7#include <linux/acpi.h> 7#include <linux/acpi.h>
8#include <acpi/acpi_drivers.h>
9#include <linux/kernel.h> 8#include <linux/kernel.h>
10#include <linux/types.h> 9#include <linux/types.h>
11 10
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index c0ed4f273cf2..e3a92a6da39a 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -427,6 +427,9 @@ static const struct pci_device_id ahci_pci_tbl[] = {
427 .driver_data = board_ahci_yes_fbs }, /* 88se9128 */ 427 .driver_data = board_ahci_yes_fbs }, /* 88se9128 */
428 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x9125), 428 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x9125),
429 .driver_data = board_ahci_yes_fbs }, /* 88se9125 */ 429 .driver_data = board_ahci_yes_fbs }, /* 88se9125 */
430 { PCI_DEVICE_SUB(PCI_VENDOR_ID_MARVELL_EXT, 0x9178,
431 PCI_VENDOR_ID_MARVELL_EXT, 0x9170),
432 .driver_data = board_ahci_yes_fbs }, /* 88se9170 */
430 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x917a), 433 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x917a),
431 .driver_data = board_ahci_yes_fbs }, /* 88se9172 */ 434 .driver_data = board_ahci_yes_fbs }, /* 88se9172 */
432 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x9172), 435 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x9172),
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index 4372cfa883c9..9e69a5308693 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -20,8 +20,6 @@
20#include <scsi/scsi_device.h> 20#include <scsi/scsi_device.h>
21#include "libata.h" 21#include "libata.h"
22 22
23#include <acpi/acpi_bus.h>
24
25unsigned int ata_acpi_gtf_filter = ATA_ACPI_FILTER_DEFAULT; 23unsigned int ata_acpi_gtf_filter = ATA_ACPI_FILTER_DEFAULT;
26module_param_named(acpi_gtf_filter, ata_acpi_gtf_filter, int, 0644); 24module_param_named(acpi_gtf_filter, ata_acpi_gtf_filter, int, 0644);
27MODULE_PARM_DESC(acpi_gtf_filter, "filter mask for ACPI _GTF commands, set to filter out (0x1=set xfermode, 0x2=lock/freeze lock, 0x4=DIPM, 0x8=FPDMA non-zero offset, 0x10=FPDMA DMA Setup FIS auto-activate)"); 25MODULE_PARM_DESC(acpi_gtf_filter, "filter mask for ACPI _GTF commands, set to filter out (0x1=set xfermode, 0x2=lock/freeze lock, 0x4=DIPM, 0x8=FPDMA non-zero offset, 0x10=FPDMA DMA Setup FIS auto-activate)");
@@ -180,12 +178,12 @@ static const struct acpi_dock_ops ata_acpi_ap_dock_ops = {
180/* bind acpi handle to pata port */ 178/* bind acpi handle to pata port */
181void ata_acpi_bind_port(struct ata_port *ap) 179void ata_acpi_bind_port(struct ata_port *ap)
182{ 180{
183 acpi_handle host_handle = ACPI_HANDLE(ap->host->dev); 181 struct acpi_device *host_companion = ACPI_COMPANION(ap->host->dev);
184 182
185 if (libata_noacpi || ap->flags & ATA_FLAG_ACPI_SATA || !host_handle) 183 if (libata_noacpi || ap->flags & ATA_FLAG_ACPI_SATA || !host_companion)
186 return; 184 return;
187 185
188 acpi_preset_companion(&ap->tdev, host_handle, ap->port_no); 186 acpi_preset_companion(&ap->tdev, host_companion, ap->port_no);
189 187
190 if (ata_acpi_gtm(ap, &ap->__acpi_init_gtm) == 0) 188 if (ata_acpi_gtm(ap, &ap->__acpi_init_gtm) == 0)
191 ap->pflags |= ATA_PFLAG_INIT_GTM_VALID; 189 ap->pflags |= ATA_PFLAG_INIT_GTM_VALID;
@@ -198,17 +196,17 @@ void ata_acpi_bind_port(struct ata_port *ap)
198void ata_acpi_bind_dev(struct ata_device *dev) 196void ata_acpi_bind_dev(struct ata_device *dev)
199{ 197{
200 struct ata_port *ap = dev->link->ap; 198 struct ata_port *ap = dev->link->ap;
201 acpi_handle port_handle = ACPI_HANDLE(&ap->tdev); 199 struct acpi_device *port_companion = ACPI_COMPANION(&ap->tdev);
202 acpi_handle host_handle = ACPI_HANDLE(ap->host->dev); 200 struct acpi_device *host_companion = ACPI_COMPANION(ap->host->dev);
203 acpi_handle parent_handle; 201 struct acpi_device *parent;
204 u64 adr; 202 u64 adr;
205 203
206 /* 204 /*
207 * For both sata/pata devices, host handle is required. 205 * For both sata/pata devices, host companion device is required.
208 * For pata device, port handle is also required. 206 * For pata device, port companion device is also required.
209 */ 207 */
210 if (libata_noacpi || !host_handle || 208 if (libata_noacpi || !host_companion ||
211 (!(ap->flags & ATA_FLAG_ACPI_SATA) && !port_handle)) 209 (!(ap->flags & ATA_FLAG_ACPI_SATA) && !port_companion))
212 return; 210 return;
213 211
214 if (ap->flags & ATA_FLAG_ACPI_SATA) { 212 if (ap->flags & ATA_FLAG_ACPI_SATA) {
@@ -216,13 +214,13 @@ void ata_acpi_bind_dev(struct ata_device *dev)
216 adr = SATA_ADR(ap->port_no, NO_PORT_MULT); 214 adr = SATA_ADR(ap->port_no, NO_PORT_MULT);
217 else 215 else
218 adr = SATA_ADR(ap->port_no, dev->link->pmp); 216 adr = SATA_ADR(ap->port_no, dev->link->pmp);
219 parent_handle = host_handle; 217 parent = host_companion;
220 } else { 218 } else {
221 adr = dev->devno; 219 adr = dev->devno;
222 parent_handle = port_handle; 220 parent = port_companion;
223 } 221 }
224 222
225 acpi_preset_companion(&dev->tdev, parent_handle, adr); 223 acpi_preset_companion(&dev->tdev, parent, adr);
226 224
227 register_hotplug_dock_device(ata_dev_acpi_handle(dev), 225 register_hotplug_dock_device(ata_dev_acpi_handle(dev),
228 &ata_acpi_dev_dock_ops, dev, NULL, NULL); 226 &ata_acpi_dev_dock_ops, dev, NULL, NULL);
diff --git a/drivers/ata/pata_acpi.c b/drivers/ata/pata_acpi.c
index 73212c9c6d5b..62c9ac80c6e9 100644
--- a/drivers/ata/pata_acpi.c
+++ b/drivers/ata/pata_acpi.c
@@ -12,11 +12,10 @@
12#include <linux/delay.h> 12#include <linux/delay.h>
13#include <linux/device.h> 13#include <linux/device.h>
14#include <linux/gfp.h> 14#include <linux/gfp.h>
15#include <scsi/scsi_host.h> 15#include <linux/acpi.h>
16#include <acpi/acpi_bus.h>
17
18#include <linux/libata.h> 16#include <linux/libata.h>
19#include <linux/ata.h> 17#include <linux/ata.h>
18#include <scsi/scsi_host.h>
20 19
21#define DRV_NAME "pata_acpi" 20#define DRV_NAME "pata_acpi"
22#define DRV_VERSION "0.2.3" 21#define DRV_VERSION "0.2.3"
diff --git a/drivers/ata/sata_sis.c b/drivers/ata/sata_sis.c
index fe3ca0989b14..1ad2f62d34b9 100644
--- a/drivers/ata/sata_sis.c
+++ b/drivers/ata/sata_sis.c
@@ -83,6 +83,10 @@ static struct pci_driver sis_pci_driver = {
83 .id_table = sis_pci_tbl, 83 .id_table = sis_pci_tbl,
84 .probe = sis_init_one, 84 .probe = sis_init_one,
85 .remove = ata_pci_remove_one, 85 .remove = ata_pci_remove_one,
86#ifdef CONFIG_PM
87 .suspend = ata_pci_device_suspend,
88 .resume = ata_pci_device_resume,
89#endif
86}; 90};
87 91
88static struct scsi_host_template sis_sht = { 92static struct scsi_host_template sis_sht = {
diff --git a/drivers/base/Makefile b/drivers/base/Makefile
index 94e8a80e87f8..d08c9d3b1d37 100644
--- a/drivers/base/Makefile
+++ b/drivers/base/Makefile
@@ -4,7 +4,7 @@ obj-y := core.o bus.o dd.o syscore.o \
4 driver.o class.o platform.o \ 4 driver.o class.o platform.o \
5 cpu.o firmware.o init.o map.o devres.o \ 5 cpu.o firmware.o init.o map.o devres.o \
6 attribute_container.o transport_class.o \ 6 attribute_container.o transport_class.o \
7 topology.o 7 topology.o container.o
8obj-$(CONFIG_DEVTMPFS) += devtmpfs.o 8obj-$(CONFIG_DEVTMPFS) += devtmpfs.o
9obj-$(CONFIG_DMA_CMA) += dma-contiguous.o 9obj-$(CONFIG_DMA_CMA) += dma-contiguous.o
10obj-y += power/ 10obj-y += power/
diff --git a/drivers/base/base.h b/drivers/base/base.h
index 2cbc6774f4cd..24f424249d9b 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -100,6 +100,7 @@ static inline int hypervisor_init(void) { return 0; }
100#endif 100#endif
101extern int platform_bus_init(void); 101extern int platform_bus_init(void);
102extern void cpu_dev_init(void); 102extern void cpu_dev_init(void);
103extern void container_dev_init(void);
103 104
104struct kobject *virtual_device_parent(struct device *dev); 105struct kobject *virtual_device_parent(struct device *dev);
105 106
diff --git a/drivers/base/container.c b/drivers/base/container.c
new file mode 100644
index 000000000000..ecbfbe2e908f
--- /dev/null
+++ b/drivers/base/container.c
@@ -0,0 +1,44 @@
1/*
2 * System bus type for containers.
3 *
4 * Copyright (C) 2013, Intel Corporation
5 * Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/container.h>
13
14#include "base.h"
15
16#define CONTAINER_BUS_NAME "container"
17
18static int trivial_online(struct device *dev)
19{
20 return 0;
21}
22
23static int container_offline(struct device *dev)
24{
25 struct container_dev *cdev = to_container_dev(dev);
26
27 return cdev->offline ? cdev->offline(cdev) : 0;
28}
29
30struct bus_type container_subsys = {
31 .name = CONTAINER_BUS_NAME,
32 .dev_name = CONTAINER_BUS_NAME,
33 .online = trivial_online,
34 .offline = container_offline,
35};
36
37void __init container_dev_init(void)
38{
39 int ret;
40
41 ret = subsys_system_register(&container_subsys, NULL);
42 if (ret)
43 pr_err("%s() failed: %d\n", __func__, ret);
44}
diff --git a/drivers/base/init.c b/drivers/base/init.c
index c16f0b808a17..da033d3bab3c 100644
--- a/drivers/base/init.c
+++ b/drivers/base/init.c
@@ -33,4 +33,5 @@ void __init driver_init(void)
33 platform_bus_init(); 33 platform_bus_init();
34 cpu_dev_init(); 34 cpu_dev_init();
35 memory_dev_init(); 35 memory_dev_init();
36 container_dev_init();
36} 37}
diff --git a/drivers/base/power/generic_ops.c b/drivers/base/power/generic_ops.c
index 5ee030a864f9..a2e55bfdf572 100644
--- a/drivers/base/power/generic_ops.c
+++ b/drivers/base/power/generic_ops.c
@@ -10,7 +10,7 @@
10#include <linux/pm_runtime.h> 10#include <linux/pm_runtime.h>
11#include <linux/export.h> 11#include <linux/export.h>
12 12
13#ifdef CONFIG_PM_RUNTIME 13#ifdef CONFIG_PM
14/** 14/**
15 * pm_generic_runtime_suspend - Generic runtime suspend callback for subsystems. 15 * pm_generic_runtime_suspend - Generic runtime suspend callback for subsystems.
16 * @dev: Device to suspend. 16 * @dev: Device to suspend.
@@ -48,7 +48,7 @@ int pm_generic_runtime_resume(struct device *dev)
48 return ret; 48 return ret;
49} 49}
50EXPORT_SYMBOL_GPL(pm_generic_runtime_resume); 50EXPORT_SYMBOL_GPL(pm_generic_runtime_resume);
51#endif /* CONFIG_PM_RUNTIME */ 51#endif /* CONFIG_PM */
52 52
53#ifdef CONFIG_PM_SLEEP 53#ifdef CONFIG_PM_SLEEP
54/** 54/**
diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c
index a2e69d26266d..83a598ebb65a 100644
--- a/drivers/block/null_blk.c
+++ b/drivers/block/null_blk.c
@@ -425,10 +425,7 @@ static void null_del_dev(struct nullb *nullb)
425 list_del_init(&nullb->list); 425 list_del_init(&nullb->list);
426 426
427 del_gendisk(nullb->disk); 427 del_gendisk(nullb->disk);
428 if (queue_mode == NULL_Q_MQ) 428 blk_cleanup_queue(nullb->q);
429 blk_mq_free_queue(nullb->q);
430 else
431 blk_cleanup_queue(nullb->q);
432 put_disk(nullb->disk); 429 put_disk(nullb->disk);
433 kfree(nullb); 430 kfree(nullb);
434} 431}
@@ -578,10 +575,7 @@ static int null_add_dev(void)
578 disk = nullb->disk = alloc_disk_node(1, home_node); 575 disk = nullb->disk = alloc_disk_node(1, home_node);
579 if (!disk) { 576 if (!disk) {
580queue_fail: 577queue_fail:
581 if (queue_mode == NULL_Q_MQ) 578 blk_cleanup_queue(nullb->q);
582 blk_mq_free_queue(nullb->q);
583 else
584 blk_cleanup_queue(nullb->q);
585 cleanup_queues(nullb); 579 cleanup_queues(nullb);
586err: 580err:
587 kfree(nullb); 581 kfree(nullb);
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index 5d9c31dfc905..d5d4cd82b9f7 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -34,15 +34,12 @@
34#include <linux/uaccess.h> 34#include <linux/uaccess.h>
35#include <linux/slab.h> 35#include <linux/slab.h>
36#include <linux/io.h> 36#include <linux/io.h>
37 37#include <linux/acpi.h>
38#include <linux/hpet.h>
38#include <asm/current.h> 39#include <asm/current.h>
39#include <asm/irq.h> 40#include <asm/irq.h>
40#include <asm/div64.h> 41#include <asm/div64.h>
41 42
42#include <linux/acpi.h>
43#include <acpi/acpi_bus.h>
44#include <linux/hpet.h>
45
46/* 43/*
47 * The High Precision Event Timer driver. 44 * The High Precision Event Timer driver.
48 * This driver is closely modelled after the rtc.c driver. 45 * This driver is closely modelled after the rtc.c driver.
diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
index 64420b3396a2..b9a57fa4b710 100644
--- a/drivers/char/tpm/tpm_acpi.c
+++ b/drivers/char/tpm/tpm_acpi.c
@@ -23,7 +23,7 @@
23#include <linux/security.h> 23#include <linux/security.h>
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <acpi/acpi.h> 26#include <linux/acpi.h>
27 27
28#include "tpm.h" 28#include "tpm.h"
29#include "tpm_eventlog.h" 29#include "tpm_eventlog.h"
diff --git a/drivers/char/tpm/tpm_ppi.c b/drivers/char/tpm/tpm_ppi.c
index e1f3337a0cf9..b3ea223585bd 100644
--- a/drivers/char/tpm/tpm_ppi.c
+++ b/drivers/char/tpm/tpm_ppi.c
@@ -1,16 +1,6 @@
1#include <linux/acpi.h> 1#include <linux/acpi.h>
2#include <acpi/acpi_drivers.h>
3#include "tpm.h" 2#include "tpm.h"
4 3
5static const u8 tpm_ppi_uuid[] = {
6 0xA6, 0xFA, 0xDD, 0x3D,
7 0x1B, 0x36,
8 0xB4, 0x4E,
9 0xA4, 0x24,
10 0x8D, 0x10, 0x08, 0x9D, 0x16, 0x53
11};
12static char *tpm_device_name = "TPM";
13
14#define TPM_PPI_REVISION_ID 1 4#define TPM_PPI_REVISION_ID 1
15#define TPM_PPI_FN_VERSION 1 5#define TPM_PPI_FN_VERSION 1
16#define TPM_PPI_FN_SUBREQ 2 6#define TPM_PPI_FN_SUBREQ 2
@@ -24,250 +14,178 @@ static char *tpm_device_name = "TPM";
24#define PPI_VS_REQ_END 255 14#define PPI_VS_REQ_END 255
25#define PPI_VERSION_LEN 3 15#define PPI_VERSION_LEN 3
26 16
17static const u8 tpm_ppi_uuid[] = {
18 0xA6, 0xFA, 0xDD, 0x3D,
19 0x1B, 0x36,
20 0xB4, 0x4E,
21 0xA4, 0x24,
22 0x8D, 0x10, 0x08, 0x9D, 0x16, 0x53
23};
24
25static char tpm_ppi_version[PPI_VERSION_LEN + 1];
26static acpi_handle tpm_ppi_handle;
27
27static acpi_status ppi_callback(acpi_handle handle, u32 level, void *context, 28static acpi_status ppi_callback(acpi_handle handle, u32 level, void *context,
28 void **return_value) 29 void **return_value)
29{ 30{
30 acpi_status status = AE_OK; 31 union acpi_object *obj;
31 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
32 32
33 if (ACPI_SUCCESS(acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer))) { 33 if (!acpi_check_dsm(handle, tpm_ppi_uuid, TPM_PPI_REVISION_ID,
34 if (strstr(buffer.pointer, context) != NULL) { 34 1 << TPM_PPI_FN_VERSION))
35 *return_value = handle; 35 return AE_OK;
36 status = AE_CTRL_TERMINATE; 36
37 } 37 /* Cache version string */
38 kfree(buffer.pointer); 38 obj = acpi_evaluate_dsm_typed(handle, tpm_ppi_uuid,
39 TPM_PPI_REVISION_ID, TPM_PPI_FN_VERSION,
40 NULL, ACPI_TYPE_STRING);
41 if (obj) {
42 strlcpy(tpm_ppi_version, obj->string.pointer,
43 PPI_VERSION_LEN + 1);
44 ACPI_FREE(obj);
39 } 45 }
40 46
41 return status; 47 *return_value = handle;
48
49 return AE_CTRL_TERMINATE;
42} 50}
43 51
44static inline void ppi_assign_params(union acpi_object params[4], 52static inline union acpi_object *
45 u64 function_num) 53tpm_eval_dsm(int func, acpi_object_type type, union acpi_object *argv4)
46{ 54{
47 params[0].type = ACPI_TYPE_BUFFER; 55 BUG_ON(!tpm_ppi_handle);
48 params[0].buffer.length = sizeof(tpm_ppi_uuid); 56 return acpi_evaluate_dsm_typed(tpm_ppi_handle, tpm_ppi_uuid,
49 params[0].buffer.pointer = (char *)tpm_ppi_uuid; 57 TPM_PPI_REVISION_ID, func, argv4, type);
50 params[1].type = ACPI_TYPE_INTEGER;
51 params[1].integer.value = TPM_PPI_REVISION_ID;
52 params[2].type = ACPI_TYPE_INTEGER;
53 params[2].integer.value = function_num;
54 params[3].type = ACPI_TYPE_PACKAGE;
55 params[3].package.count = 0;
56 params[3].package.elements = NULL;
57} 58}
58 59
59static ssize_t tpm_show_ppi_version(struct device *dev, 60static ssize_t tpm_show_ppi_version(struct device *dev,
60 struct device_attribute *attr, char *buf) 61 struct device_attribute *attr, char *buf)
61{ 62{
62 acpi_handle handle; 63 return scnprintf(buf, PAGE_SIZE, "%s\n", tpm_ppi_version);
63 acpi_status status;
64 struct acpi_object_list input;
65 struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
66 union acpi_object params[4];
67 union acpi_object *obj;
68
69 input.count = 4;
70 ppi_assign_params(params, TPM_PPI_FN_VERSION);
71 input.pointer = params;
72 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
73 ACPI_UINT32_MAX, ppi_callback, NULL,
74 tpm_device_name, &handle);
75 if (ACPI_FAILURE(status))
76 return -ENXIO;
77
78 status = acpi_evaluate_object_typed(handle, "_DSM", &input, &output,
79 ACPI_TYPE_STRING);
80 if (ACPI_FAILURE(status))
81 return -ENOMEM;
82 obj = (union acpi_object *)output.pointer;
83 status = scnprintf(buf, PAGE_SIZE, "%s\n", obj->string.pointer);
84 kfree(output.pointer);
85 return status;
86} 64}
87 65
88static ssize_t tpm_show_ppi_request(struct device *dev, 66static ssize_t tpm_show_ppi_request(struct device *dev,
89 struct device_attribute *attr, char *buf) 67 struct device_attribute *attr, char *buf)
90{ 68{
91 acpi_handle handle; 69 ssize_t size = -EINVAL;
92 acpi_status status; 70 union acpi_object *obj;
93 struct acpi_object_list input; 71
94 struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; 72 obj = tpm_eval_dsm(TPM_PPI_FN_GETREQ, ACPI_TYPE_PACKAGE, NULL);
95 union acpi_object params[4]; 73 if (!obj)
96 union acpi_object *ret_obj;
97
98 input.count = 4;
99 ppi_assign_params(params, TPM_PPI_FN_GETREQ);
100 input.pointer = params;
101 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
102 ACPI_UINT32_MAX, ppi_callback, NULL,
103 tpm_device_name, &handle);
104 if (ACPI_FAILURE(status))
105 return -ENXIO; 74 return -ENXIO;
106 75
107 status = acpi_evaluate_object_typed(handle, "_DSM", &input, &output,
108 ACPI_TYPE_PACKAGE);
109 if (ACPI_FAILURE(status))
110 return -ENOMEM;
111 /* 76 /*
112 * output.pointer should be of package type, including two integers. 77 * output.pointer should be of package type, including two integers.
113 * The first is function return code, 0 means success and 1 means 78 * The first is function return code, 0 means success and 1 means
114 * error. The second is pending TPM operation requested by the OS, 0 79 * error. The second is pending TPM operation requested by the OS, 0
115 * means none and >0 means operation value. 80 * means none and >0 means operation value.
116 */ 81 */
117 ret_obj = ((union acpi_object *)output.pointer)->package.elements; 82 if (obj->package.count == 2 &&
118 if (ret_obj->type == ACPI_TYPE_INTEGER) { 83 obj->package.elements[0].type == ACPI_TYPE_INTEGER &&
119 if (ret_obj->integer.value) { 84 obj->package.elements[1].type == ACPI_TYPE_INTEGER) {
120 status = -EFAULT; 85 if (obj->package.elements[0].integer.value)
121 goto cleanup; 86 size = -EFAULT;
122 }
123 ret_obj++;
124 if (ret_obj->type == ACPI_TYPE_INTEGER)
125 status = scnprintf(buf, PAGE_SIZE, "%llu\n",
126 ret_obj->integer.value);
127 else 87 else
128 status = -EINVAL; 88 size = scnprintf(buf, PAGE_SIZE, "%llu\n",
129 } else { 89 obj->package.elements[1].integer.value);
130 status = -EINVAL;
131 } 90 }
132cleanup: 91
133 kfree(output.pointer); 92 ACPI_FREE(obj);
134 return status; 93
94 return size;
135} 95}
136 96
137static ssize_t tpm_store_ppi_request(struct device *dev, 97static ssize_t tpm_store_ppi_request(struct device *dev,
138 struct device_attribute *attr, 98 struct device_attribute *attr,
139 const char *buf, size_t count) 99 const char *buf, size_t count)
140{ 100{
141 char version[PPI_VERSION_LEN + 1];
142 acpi_handle handle;
143 acpi_status status;
144 struct acpi_object_list input;
145 struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
146 union acpi_object params[4];
147 union acpi_object obj;
148 u32 req; 101 u32 req;
149 u64 ret; 102 u64 ret;
103 int func = TPM_PPI_FN_SUBREQ;
104 union acpi_object *obj, tmp;
105 union acpi_object argv4 = ACPI_INIT_DSM_ARGV4(1, &tmp);
150 106
151 input.count = 4;
152 ppi_assign_params(params, TPM_PPI_FN_VERSION);
153 input.pointer = params;
154 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
155 ACPI_UINT32_MAX, ppi_callback, NULL,
156 tpm_device_name, &handle);
157 if (ACPI_FAILURE(status))
158 return -ENXIO;
159
160 status = acpi_evaluate_object_typed(handle, "_DSM", &input, &output,
161 ACPI_TYPE_STRING);
162 if (ACPI_FAILURE(status))
163 return -ENOMEM;
164 strlcpy(version,
165 ((union acpi_object *)output.pointer)->string.pointer,
166 PPI_VERSION_LEN + 1);
167 kfree(output.pointer);
168 output.length = ACPI_ALLOCATE_BUFFER;
169 output.pointer = NULL;
170 /* 107 /*
171 * the function to submit TPM operation request to pre-os environment 108 * the function to submit TPM operation request to pre-os environment
172 * is updated with function index from SUBREQ to SUBREQ2 since PPI 109 * is updated with function index from SUBREQ to SUBREQ2 since PPI
173 * version 1.1 110 * version 1.1
174 */ 111 */
175 if (strcmp(version, "1.1") == -1) 112 if (acpi_check_dsm(tpm_ppi_handle, tpm_ppi_uuid, TPM_PPI_REVISION_ID,
176 params[2].integer.value = TPM_PPI_FN_SUBREQ; 113 1 << TPM_PPI_FN_SUBREQ2))
177 else 114 func = TPM_PPI_FN_SUBREQ2;
178 params[2].integer.value = TPM_PPI_FN_SUBREQ2; 115
179 /* 116 /*
180 * PPI spec defines params[3].type as ACPI_TYPE_PACKAGE. Some BIOS 117 * PPI spec defines params[3].type as ACPI_TYPE_PACKAGE. Some BIOS
181 * accept buffer/string/integer type, but some BIOS accept buffer/ 118 * accept buffer/string/integer type, but some BIOS accept buffer/
182 * string/package type. For PPI version 1.0 and 1.1, use buffer type 119 * string/package type. For PPI version 1.0 and 1.1, use buffer type
183 * for compatibility, and use package type since 1.2 according to spec. 120 * for compatibility, and use package type since 1.2 according to spec.
184 */ 121 */
185 if (strcmp(version, "1.2") == -1) { 122 if (strcmp(tpm_ppi_version, "1.2") < 0) {
186 params[3].type = ACPI_TYPE_BUFFER; 123 if (sscanf(buf, "%d", &req) != 1)
187 params[3].buffer.length = sizeof(req); 124 return -EINVAL;
188 sscanf(buf, "%d", &req); 125 argv4.type = ACPI_TYPE_BUFFER;
189 params[3].buffer.pointer = (char *)&req; 126 argv4.buffer.length = sizeof(req);
127 argv4.buffer.pointer = (u8 *)&req;
128 } else {
129 tmp.type = ACPI_TYPE_INTEGER;
130 if (sscanf(buf, "%llu", &tmp.integer.value) != 1)
131 return -EINVAL;
132 }
133
134 obj = tpm_eval_dsm(func, ACPI_TYPE_INTEGER, &argv4);
135 if (!obj) {
136 return -ENXIO;
190 } else { 137 } else {
191 params[3].package.count = 1; 138 ret = obj->integer.value;
192 obj.type = ACPI_TYPE_INTEGER; 139 ACPI_FREE(obj);
193 sscanf(buf, "%llu", &obj.integer.value);
194 params[3].package.elements = &obj;
195 } 140 }
196 141
197 status = acpi_evaluate_object_typed(handle, "_DSM", &input, &output,
198 ACPI_TYPE_INTEGER);
199 if (ACPI_FAILURE(status))
200 return -ENOMEM;
201 ret = ((union acpi_object *)output.pointer)->integer.value;
202 if (ret == 0) 142 if (ret == 0)
203 status = (acpi_status)count; 143 return (acpi_status)count;
204 else if (ret == 1) 144
205 status = -EPERM; 145 return (ret == 1) ? -EPERM : -EFAULT;
206 else
207 status = -EFAULT;
208 kfree(output.pointer);
209 return status;
210} 146}
211 147
212static ssize_t tpm_show_ppi_transition_action(struct device *dev, 148static ssize_t tpm_show_ppi_transition_action(struct device *dev,
213 struct device_attribute *attr, 149 struct device_attribute *attr,
214 char *buf) 150 char *buf)
215{ 151{
216 char version[PPI_VERSION_LEN + 1];
217 acpi_handle handle;
218 acpi_status status;
219 struct acpi_object_list input;
220 struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
221 union acpi_object params[4];
222 u32 ret; 152 u32 ret;
223 char *info[] = { 153 acpi_status status;
154 union acpi_object *obj = NULL;
155 union acpi_object tmp = {
156 .buffer.type = ACPI_TYPE_BUFFER,
157 .buffer.length = 0,
158 .buffer.pointer = NULL
159 };
160
161 static char *info[] = {
224 "None", 162 "None",
225 "Shutdown", 163 "Shutdown",
226 "Reboot", 164 "Reboot",
227 "OS Vendor-specific", 165 "OS Vendor-specific",
228 "Error", 166 "Error",
229 }; 167 };
230 input.count = 4;
231 ppi_assign_params(params, TPM_PPI_FN_VERSION);
232 input.pointer = params;
233 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
234 ACPI_UINT32_MAX, ppi_callback, NULL,
235 tpm_device_name, &handle);
236 if (ACPI_FAILURE(status))
237 return -ENXIO;
238 168
239 status = acpi_evaluate_object_typed(handle, "_DSM", &input, &output,
240 ACPI_TYPE_STRING);
241 if (ACPI_FAILURE(status))
242 return -ENOMEM;
243 strlcpy(version,
244 ((union acpi_object *)output.pointer)->string.pointer,
245 PPI_VERSION_LEN + 1);
246 /* 169 /*
247 * PPI spec defines params[3].type as empty package, but some platforms 170 * PPI spec defines params[3].type as empty package, but some platforms
248 * (e.g. Capella with PPI 1.0) need integer/string/buffer type, so for 171 * (e.g. Capella with PPI 1.0) need integer/string/buffer type, so for
249 * compatibility, define params[3].type as buffer, if PPI version < 1.2 172 * compatibility, define params[3].type as buffer, if PPI version < 1.2
250 */ 173 */
251 if (strcmp(version, "1.2") == -1) { 174 if (strcmp(tpm_ppi_version, "1.2") < 0)
252 params[3].type = ACPI_TYPE_BUFFER; 175 obj = &tmp;
253 params[3].buffer.length = 0; 176 obj = tpm_eval_dsm(TPM_PPI_FN_GETACT, ACPI_TYPE_INTEGER, obj);
254 params[3].buffer.pointer = NULL; 177 if (!obj) {
178 return -ENXIO;
179 } else {
180 ret = obj->integer.value;
181 ACPI_FREE(obj);
255 } 182 }
256 params[2].integer.value = TPM_PPI_FN_GETACT; 183
257 kfree(output.pointer);
258 output.length = ACPI_ALLOCATE_BUFFER;
259 output.pointer = NULL;
260 status = acpi_evaluate_object_typed(handle, "_DSM", &input, &output,
261 ACPI_TYPE_INTEGER);
262 if (ACPI_FAILURE(status))
263 return -ENOMEM;
264 ret = ((union acpi_object *)output.pointer)->integer.value;
265 if (ret < ARRAY_SIZE(info) - 1) 184 if (ret < ARRAY_SIZE(info) - 1)
266 status = scnprintf(buf, PAGE_SIZE, "%d: %s\n", ret, info[ret]); 185 status = scnprintf(buf, PAGE_SIZE, "%d: %s\n", ret, info[ret]);
267 else 186 else
268 status = scnprintf(buf, PAGE_SIZE, "%d: %s\n", ret, 187 status = scnprintf(buf, PAGE_SIZE, "%d: %s\n", ret,
269 info[ARRAY_SIZE(info)-1]); 188 info[ARRAY_SIZE(info)-1]);
270 kfree(output.pointer);
271 return status; 189 return status;
272} 190}
273 191
@@ -275,27 +193,14 @@ static ssize_t tpm_show_ppi_response(struct device *dev,
275 struct device_attribute *attr, 193 struct device_attribute *attr,
276 char *buf) 194 char *buf)
277{ 195{
278 acpi_handle handle; 196 acpi_status status = -EINVAL;
279 acpi_status status; 197 union acpi_object *obj, *ret_obj;
280 struct acpi_object_list input; 198 u64 req, res;
281 struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; 199
282 union acpi_object params[4]; 200 obj = tpm_eval_dsm(TPM_PPI_FN_GETRSP, ACPI_TYPE_PACKAGE, NULL);
283 union acpi_object *ret_obj; 201 if (!obj)
284 u64 req;
285
286 input.count = 4;
287 ppi_assign_params(params, TPM_PPI_FN_GETRSP);
288 input.pointer = params;
289 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
290 ACPI_UINT32_MAX, ppi_callback, NULL,
291 tpm_device_name, &handle);
292 if (ACPI_FAILURE(status))
293 return -ENXIO; 202 return -ENXIO;
294 203
295 status = acpi_evaluate_object_typed(handle, "_DSM", &input, &output,
296 ACPI_TYPE_PACKAGE);
297 if (ACPI_FAILURE(status))
298 return -ENOMEM;
299 /* 204 /*
300 * parameter output.pointer should be of package type, including 205 * parameter output.pointer should be of package type, including
301 * 3 integers. The first means function return code, the second means 206 * 3 integers. The first means function return code, the second means
@@ -303,115 +208,82 @@ static ssize_t tpm_show_ppi_response(struct device *dev,
303 * the most recent TPM operation request. Only if the first is 0, and 208 * the most recent TPM operation request. Only if the first is 0, and
304 * the second integer is not 0, the response makes sense. 209 * the second integer is not 0, the response makes sense.
305 */ 210 */
306 ret_obj = ((union acpi_object *)output.pointer)->package.elements; 211 ret_obj = obj->package.elements;
307 if (ret_obj->type != ACPI_TYPE_INTEGER) { 212 if (obj->package.count < 3 ||
308 status = -EINVAL; 213 ret_obj[0].type != ACPI_TYPE_INTEGER ||
214 ret_obj[1].type != ACPI_TYPE_INTEGER ||
215 ret_obj[2].type != ACPI_TYPE_INTEGER)
309 goto cleanup; 216 goto cleanup;
310 } 217
311 if (ret_obj->integer.value) { 218 if (ret_obj[0].integer.value) {
312 status = -EFAULT; 219 status = -EFAULT;
313 goto cleanup; 220 goto cleanup;
314 } 221 }
315 ret_obj++; 222
316 if (ret_obj->type != ACPI_TYPE_INTEGER) { 223 req = ret_obj[1].integer.value;
317 status = -EINVAL; 224 res = ret_obj[2].integer.value;
318 goto cleanup; 225 if (req) {
319 } 226 if (res == 0)
320 if (ret_obj->integer.value) {
321 req = ret_obj->integer.value;
322 ret_obj++;
323 if (ret_obj->type != ACPI_TYPE_INTEGER) {
324 status = -EINVAL;
325 goto cleanup;
326 }
327 if (ret_obj->integer.value == 0)
328 status = scnprintf(buf, PAGE_SIZE, "%llu %s\n", req, 227 status = scnprintf(buf, PAGE_SIZE, "%llu %s\n", req,
329 "0: Success"); 228 "0: Success");
330 else if (ret_obj->integer.value == 0xFFFFFFF0) 229 else if (res == 0xFFFFFFF0)
331 status = scnprintf(buf, PAGE_SIZE, "%llu %s\n", req, 230 status = scnprintf(buf, PAGE_SIZE, "%llu %s\n", req,
332 "0xFFFFFFF0: User Abort"); 231 "0xFFFFFFF0: User Abort");
333 else if (ret_obj->integer.value == 0xFFFFFFF1) 232 else if (res == 0xFFFFFFF1)
334 status = scnprintf(buf, PAGE_SIZE, "%llu %s\n", req, 233 status = scnprintf(buf, PAGE_SIZE, "%llu %s\n", req,
335 "0xFFFFFFF1: BIOS Failure"); 234 "0xFFFFFFF1: BIOS Failure");
336 else if (ret_obj->integer.value >= 1 && 235 else if (res >= 1 && res <= 0x00000FFF)
337 ret_obj->integer.value <= 0x00000FFF)
338 status = scnprintf(buf, PAGE_SIZE, "%llu %llu: %s\n", 236 status = scnprintf(buf, PAGE_SIZE, "%llu %llu: %s\n",
339 req, ret_obj->integer.value, 237 req, res, "Corresponding TPM error");
340 "Corresponding TPM error");
341 else 238 else
342 status = scnprintf(buf, PAGE_SIZE, "%llu %llu: %s\n", 239 status = scnprintf(buf, PAGE_SIZE, "%llu %llu: %s\n",
343 req, ret_obj->integer.value, 240 req, res, "Error");
344 "Error");
345 } else { 241 } else {
346 status = scnprintf(buf, PAGE_SIZE, "%llu: %s\n", 242 status = scnprintf(buf, PAGE_SIZE, "%llu: %s\n",
347 ret_obj->integer.value, "No Recent Request"); 243 req, "No Recent Request");
348 } 244 }
245
349cleanup: 246cleanup:
350 kfree(output.pointer); 247 ACPI_FREE(obj);
351 return status; 248 return status;
352} 249}
353 250
354static ssize_t show_ppi_operations(char *buf, u32 start, u32 end) 251static ssize_t show_ppi_operations(char *buf, u32 start, u32 end)
355{ 252{
356 char *str = buf;
357 char version[PPI_VERSION_LEN + 1];
358 acpi_handle handle;
359 acpi_status status;
360 struct acpi_object_list input;
361 struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
362 union acpi_object params[4];
363 union acpi_object obj;
364 int i; 253 int i;
365 u32 ret; 254 u32 ret;
366 char *info[] = { 255 char *str = buf;
256 union acpi_object *obj, tmp;
257 union acpi_object argv = ACPI_INIT_DSM_ARGV4(1, &tmp);
258
259 static char *info[] = {
367 "Not implemented", 260 "Not implemented",
368 "BIOS only", 261 "BIOS only",
369 "Blocked for OS by BIOS", 262 "Blocked for OS by BIOS",
370 "User required", 263 "User required",
371 "User not required", 264 "User not required",
372 }; 265 };
373 input.count = 4;
374 ppi_assign_params(params, TPM_PPI_FN_VERSION);
375 input.pointer = params;
376 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
377 ACPI_UINT32_MAX, ppi_callback, NULL,
378 tpm_device_name, &handle);
379 if (ACPI_FAILURE(status))
380 return -ENXIO;
381 266
382 status = acpi_evaluate_object_typed(handle, "_DSM", &input, &output, 267 if (!acpi_check_dsm(tpm_ppi_handle, tpm_ppi_uuid, TPM_PPI_REVISION_ID,
383 ACPI_TYPE_STRING); 268 1 << TPM_PPI_FN_GETOPR))
384 if (ACPI_FAILURE(status))
385 return -ENOMEM;
386
387 strlcpy(version,
388 ((union acpi_object *)output.pointer)->string.pointer,
389 PPI_VERSION_LEN + 1);
390 kfree(output.pointer);
391 output.length = ACPI_ALLOCATE_BUFFER;
392 output.pointer = NULL;
393 if (strcmp(version, "1.2") == -1)
394 return -EPERM; 269 return -EPERM;
395 270
396 params[2].integer.value = TPM_PPI_FN_GETOPR; 271 tmp.integer.type = ACPI_TYPE_INTEGER;
397 params[3].package.count = 1;
398 obj.type = ACPI_TYPE_INTEGER;
399 params[3].package.elements = &obj;
400 for (i = start; i <= end; i++) { 272 for (i = start; i <= end; i++) {
401 obj.integer.value = i; 273 tmp.integer.value = i;
402 status = acpi_evaluate_object_typed(handle, "_DSM", 274 obj = tpm_eval_dsm(TPM_PPI_FN_GETOPR, ACPI_TYPE_INTEGER, &argv);
403 &input, &output, ACPI_TYPE_INTEGER); 275 if (!obj) {
404 if (ACPI_FAILURE(status))
405 return -ENOMEM; 276 return -ENOMEM;
277 } else {
278 ret = obj->integer.value;
279 ACPI_FREE(obj);
280 }
406 281
407 ret = ((union acpi_object *)output.pointer)->integer.value;
408 if (ret > 0 && ret < ARRAY_SIZE(info)) 282 if (ret > 0 && ret < ARRAY_SIZE(info))
409 str += scnprintf(str, PAGE_SIZE, "%d %d: %s\n", 283 str += scnprintf(str, PAGE_SIZE, "%d %d: %s\n",
410 i, ret, info[ret]); 284 i, ret, info[ret]);
411 kfree(output.pointer);
412 output.length = ACPI_ALLOCATE_BUFFER;
413 output.pointer = NULL;
414 } 285 }
286
415 return str - buf; 287 return str - buf;
416} 288}
417 289
@@ -453,6 +325,12 @@ static struct attribute_group ppi_attr_grp = {
453 325
454int tpm_add_ppi(struct kobject *parent) 326int tpm_add_ppi(struct kobject *parent)
455{ 327{
328 /* Cache TPM ACPI handle and version string */
329 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
330 ppi_callback, NULL, NULL, &tpm_ppi_handle);
331 if (tpm_ppi_handle == NULL)
332 return -ENODEV;
333
456 return sysfs_create_group(parent, &ppi_attr_grp); 334 return sysfs_create_group(parent, &ppi_attr_grp);
457} 335}
458 336
diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
index 8d3009e44fba..5543b7df8e16 100644
--- a/drivers/clk/clk-divider.c
+++ b/drivers/clk/clk-divider.c
@@ -87,7 +87,7 @@ static unsigned int _get_table_val(const struct clk_div_table *table,
87 return 0; 87 return 0;
88} 88}
89 89
90static unsigned int _get_val(struct clk_divider *divider, u8 div) 90static unsigned int _get_val(struct clk_divider *divider, unsigned int div)
91{ 91{
92 if (divider->flags & CLK_DIVIDER_ONE_BASED) 92 if (divider->flags & CLK_DIVIDER_ONE_BASED)
93 return div; 93 return div;
diff --git a/drivers/clk/samsung/clk-exynos-audss.c b/drivers/clk/samsung/clk-exynos-audss.c
index 39b40aaede2b..68e515d093d8 100644
--- a/drivers/clk/samsung/clk-exynos-audss.c
+++ b/drivers/clk/samsung/clk-exynos-audss.c
@@ -26,17 +26,17 @@ static struct clk_onecell_data clk_data;
26#define ASS_CLK_DIV 0x4 26#define ASS_CLK_DIV 0x4
27#define ASS_CLK_GATE 0x8 27#define ASS_CLK_GATE 0x8
28 28
29/* list of all parent clock list */
30static const char *mout_audss_p[] = { "fin_pll", "fout_epll" };
31static const char *mout_i2s_p[] = { "mout_audss", "cdclk0", "sclk_audio0" };
32
33#ifdef CONFIG_PM_SLEEP
29static unsigned long reg_save[][2] = { 34static unsigned long reg_save[][2] = {
30 {ASS_CLK_SRC, 0}, 35 {ASS_CLK_SRC, 0},
31 {ASS_CLK_DIV, 0}, 36 {ASS_CLK_DIV, 0},
32 {ASS_CLK_GATE, 0}, 37 {ASS_CLK_GATE, 0},
33}; 38};
34 39
35/* list of all parent clock list */
36static const char *mout_audss_p[] = { "fin_pll", "fout_epll" };
37static const char *mout_i2s_p[] = { "mout_audss", "cdclk0", "sclk_audio0" };
38
39#ifdef CONFIG_PM_SLEEP
40static int exynos_audss_clk_suspend(void) 40static int exynos_audss_clk_suspend(void)
41{ 41{
42 int i; 42 int i;
diff --git a/drivers/clk/samsung/clk-exynos4.c b/drivers/clk/samsung/clk-exynos4.c
index ad5ff50c5f28..1a7c1b929c69 100644
--- a/drivers/clk/samsung/clk-exynos4.c
+++ b/drivers/clk/samsung/clk-exynos4.c
@@ -39,7 +39,7 @@
39#define SRC_TOP1 0xc214 39#define SRC_TOP1 0xc214
40#define SRC_CAM 0xc220 40#define SRC_CAM 0xc220
41#define SRC_TV 0xc224 41#define SRC_TV 0xc224
42#define SRC_MFC 0xcc28 42#define SRC_MFC 0xc228
43#define SRC_G3D 0xc22c 43#define SRC_G3D 0xc22c
44#define E4210_SRC_IMAGE 0xc230 44#define E4210_SRC_IMAGE 0xc230
45#define SRC_LCD0 0xc234 45#define SRC_LCD0 0xc234
diff --git a/drivers/clk/samsung/clk-exynos5250.c b/drivers/clk/samsung/clk-exynos5250.c
index adf32343c9f9..e52359cf9b6f 100644
--- a/drivers/clk/samsung/clk-exynos5250.c
+++ b/drivers/clk/samsung/clk-exynos5250.c
@@ -25,6 +25,7 @@
25#define MPLL_LOCK 0x4000 25#define MPLL_LOCK 0x4000
26#define MPLL_CON0 0x4100 26#define MPLL_CON0 0x4100
27#define SRC_CORE1 0x4204 27#define SRC_CORE1 0x4204
28#define GATE_IP_ACP 0x8800
28#define CPLL_LOCK 0x10020 29#define CPLL_LOCK 0x10020
29#define EPLL_LOCK 0x10030 30#define EPLL_LOCK 0x10030
30#define VPLL_LOCK 0x10040 31#define VPLL_LOCK 0x10040
@@ -75,7 +76,6 @@
75#define SRC_CDREX 0x20200 76#define SRC_CDREX 0x20200
76#define PLL_DIV2_SEL 0x20a24 77#define PLL_DIV2_SEL 0x20a24
77#define GATE_IP_DISP1 0x10928 78#define GATE_IP_DISP1 0x10928
78#define GATE_IP_ACP 0x10000
79 79
80/* list of PLLs to be registered */ 80/* list of PLLs to be registered */
81enum exynos5250_plls { 81enum exynos5250_plls {
@@ -120,7 +120,8 @@ enum exynos5250_clks {
120 spi2, i2s1, i2s2, pcm1, pcm2, pwm, spdif, ac97, hsi2c0, hsi2c1, hsi2c2, 120 spi2, i2s1, i2s2, pcm1, pcm2, pwm, spdif, ac97, hsi2c0, hsi2c1, hsi2c2,
121 hsi2c3, chipid, sysreg, pmu, cmu_top, cmu_core, cmu_mem, tzpc0, tzpc1, 121 hsi2c3, chipid, sysreg, pmu, cmu_top, cmu_core, cmu_mem, tzpc0, tzpc1,
122 tzpc2, tzpc3, tzpc4, tzpc5, tzpc6, tzpc7, tzpc8, tzpc9, hdmi_cec, mct, 122 tzpc2, tzpc3, tzpc4, tzpc5, tzpc6, tzpc7, tzpc8, tzpc9, hdmi_cec, mct,
123 wdt, rtc, tmu, fimd1, mie1, dsim0, dp, mixer, hdmi, g2d, 123 wdt, rtc, tmu, fimd1, mie1, dsim0, dp, mixer, hdmi, g2d, mdma0,
124 smmu_mdma0,
124 125
125 /* mux clocks */ 126 /* mux clocks */
126 mout_hdmi = 1024, 127 mout_hdmi = 1024,
@@ -354,8 +355,8 @@ static struct samsung_gate_clock exynos5250_gate_clks[] __initdata = {
354 GATE(smmu_gscl2, "smmu_gscl2", "aclk266", GATE_IP_GSCL, 9, 0, 0), 355 GATE(smmu_gscl2, "smmu_gscl2", "aclk266", GATE_IP_GSCL, 9, 0, 0),
355 GATE(smmu_gscl3, "smmu_gscl3", "aclk266", GATE_IP_GSCL, 10, 0, 0), 356 GATE(smmu_gscl3, "smmu_gscl3", "aclk266", GATE_IP_GSCL, 10, 0, 0),
356 GATE(mfc, "mfc", "aclk333", GATE_IP_MFC, 0, 0, 0), 357 GATE(mfc, "mfc", "aclk333", GATE_IP_MFC, 0, 0, 0),
357 GATE(smmu_mfcl, "smmu_mfcl", "aclk333", GATE_IP_MFC, 1, 0, 0), 358 GATE(smmu_mfcl, "smmu_mfcl", "aclk333", GATE_IP_MFC, 2, 0, 0),
358 GATE(smmu_mfcr, "smmu_mfcr", "aclk333", GATE_IP_MFC, 2, 0, 0), 359 GATE(smmu_mfcr, "smmu_mfcr", "aclk333", GATE_IP_MFC, 1, 0, 0),
359 GATE(rotator, "rotator", "aclk266", GATE_IP_GEN, 1, 0, 0), 360 GATE(rotator, "rotator", "aclk266", GATE_IP_GEN, 1, 0, 0),
360 GATE(jpeg, "jpeg", "aclk166", GATE_IP_GEN, 2, 0, 0), 361 GATE(jpeg, "jpeg", "aclk166", GATE_IP_GEN, 2, 0, 0),
361 GATE(mdma1, "mdma1", "aclk266", GATE_IP_GEN, 4, 0, 0), 362 GATE(mdma1, "mdma1", "aclk266", GATE_IP_GEN, 4, 0, 0),
@@ -406,7 +407,8 @@ static struct samsung_gate_clock exynos5250_gate_clks[] __initdata = {
406 GATE(hsi2c2, "hsi2c2", "aclk66", GATE_IP_PERIC, 30, 0, 0), 407 GATE(hsi2c2, "hsi2c2", "aclk66", GATE_IP_PERIC, 30, 0, 0),
407 GATE(hsi2c3, "hsi2c3", "aclk66", GATE_IP_PERIC, 31, 0, 0), 408 GATE(hsi2c3, "hsi2c3", "aclk66", GATE_IP_PERIC, 31, 0, 0),
408 GATE(chipid, "chipid", "aclk66", GATE_IP_PERIS, 0, 0, 0), 409 GATE(chipid, "chipid", "aclk66", GATE_IP_PERIS, 0, 0, 0),
409 GATE(sysreg, "sysreg", "aclk66", GATE_IP_PERIS, 1, 0, 0), 410 GATE(sysreg, "sysreg", "aclk66",
411 GATE_IP_PERIS, 1, CLK_IGNORE_UNUSED, 0),
410 GATE(pmu, "pmu", "aclk66", GATE_IP_PERIS, 2, CLK_IGNORE_UNUSED, 0), 412 GATE(pmu, "pmu", "aclk66", GATE_IP_PERIS, 2, CLK_IGNORE_UNUSED, 0),
411 GATE(tzpc0, "tzpc0", "aclk66", GATE_IP_PERIS, 6, 0, 0), 413 GATE(tzpc0, "tzpc0", "aclk66", GATE_IP_PERIS, 6, 0, 0),
412 GATE(tzpc1, "tzpc1", "aclk66", GATE_IP_PERIS, 7, 0, 0), 414 GATE(tzpc1, "tzpc1", "aclk66", GATE_IP_PERIS, 7, 0, 0),
@@ -492,6 +494,8 @@ static struct samsung_gate_clock exynos5250_gate_clks[] __initdata = {
492 GATE(mixer, "mixer", "mout_aclk200_disp1", GATE_IP_DISP1, 5, 0, 0), 494 GATE(mixer, "mixer", "mout_aclk200_disp1", GATE_IP_DISP1, 5, 0, 0),
493 GATE(hdmi, "hdmi", "mout_aclk200_disp1", GATE_IP_DISP1, 6, 0, 0), 495 GATE(hdmi, "hdmi", "mout_aclk200_disp1", GATE_IP_DISP1, 6, 0, 0),
494 GATE(g2d, "g2d", "aclk200", GATE_IP_ACP, 3, 0, 0), 496 GATE(g2d, "g2d", "aclk200", GATE_IP_ACP, 3, 0, 0),
497 GATE(mdma0, "mdma0", "aclk266", GATE_IP_ACP, 1, 0, 0),
498 GATE(smmu_mdma0, "smmu_mdma0", "aclk266", GATE_IP_ACP, 5, 0, 0),
495}; 499};
496 500
497static struct samsung_pll_rate_table vpll_24mhz_tbl[] __initdata = { 501static struct samsung_pll_rate_table vpll_24mhz_tbl[] __initdata = {
diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig
index 074787281c94..a6ef6acaa1c8 100644
--- a/drivers/firmware/Kconfig
+++ b/drivers/firmware/Kconfig
@@ -110,7 +110,7 @@ config DMI_SYSFS
110 110
111config ISCSI_IBFT_FIND 111config ISCSI_IBFT_FIND
112 bool "iSCSI Boot Firmware Table Attributes" 112 bool "iSCSI Boot Firmware Table Attributes"
113 depends on X86 113 depends on X86 && ACPI
114 default n 114 default n
115 help 115 help
116 This option enables the kernel to find the region of memory 116 This option enables the kernel to find the region of memory
diff --git a/drivers/gpu/drm/gma500/opregion.c b/drivers/gpu/drm/gma500/opregion.c
index ad0d6de938f3..13ec6283bf59 100644
--- a/drivers/gpu/drm/gma500/opregion.c
+++ b/drivers/gpu/drm/gma500/opregion.c
@@ -22,7 +22,6 @@
22 * 22 *
23 */ 23 */
24#include <linux/acpi.h> 24#include <linux/acpi.h>
25#include <linux/acpi_io.h>
26#include "psb_drv.h" 25#include "psb_drv.h"
27#include "psb_intel_reg.h" 26#include "psb_intel_reg.h"
28 27
diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index 41838eaa799c..d4ae48b04cf2 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -38,7 +38,6 @@ i915-y := i915_drv.o i915_dma.o i915_irq.o \
38 intel_ringbuffer.o \ 38 intel_ringbuffer.o \
39 intel_overlay.o \ 39 intel_overlay.o \
40 intel_sprite.o \ 40 intel_sprite.o \
41 intel_opregion.o \
42 intel_sideband.o \ 41 intel_sideband.o \
43 intel_uncore.o \ 42 intel_uncore.o \
44 dvo_ch7xxx.o \ 43 dvo_ch7xxx.o \
@@ -51,7 +50,7 @@ i915-y := i915_drv.o i915_dma.o i915_irq.o \
51 50
52i915-$(CONFIG_COMPAT) += i915_ioc32.o 51i915-$(CONFIG_COMPAT) += i915_ioc32.o
53 52
54i915-$(CONFIG_ACPI) += intel_acpi.o 53i915-$(CONFIG_ACPI) += intel_acpi.o intel_opregion.o
55 54
56i915-$(CONFIG_DRM_I915_FBDEV) += intel_fbdev.o 55i915-$(CONFIG_DRM_I915_FBDEV) += intel_fbdev.o
57 56
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 90fcccba17b0..1caa5e34fbe3 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2339,8 +2339,8 @@ extern void intel_i2c_reset(struct drm_device *dev);
2339 2339
2340/* intel_opregion.c */ 2340/* intel_opregion.c */
2341struct intel_encoder; 2341struct intel_encoder;
2342extern int intel_opregion_setup(struct drm_device *dev);
2343#ifdef CONFIG_ACPI 2342#ifdef CONFIG_ACPI
2343extern int intel_opregion_setup(struct drm_device *dev);
2344extern void intel_opregion_init(struct drm_device *dev); 2344extern void intel_opregion_init(struct drm_device *dev);
2345extern void intel_opregion_fini(struct drm_device *dev); 2345extern void intel_opregion_fini(struct drm_device *dev);
2346extern void intel_opregion_asle_intr(struct drm_device *dev); 2346extern void intel_opregion_asle_intr(struct drm_device *dev);
@@ -2349,6 +2349,7 @@ extern int intel_opregion_notify_encoder(struct intel_encoder *intel_encoder,
2349extern int intel_opregion_notify_adapter(struct drm_device *dev, 2349extern int intel_opregion_notify_adapter(struct drm_device *dev,
2350 pci_power_t state); 2350 pci_power_t state);
2351#else 2351#else
2352static inline int intel_opregion_setup(struct drm_device *dev) { return 0; }
2352static inline void intel_opregion_init(struct drm_device *dev) { return; } 2353static inline void intel_opregion_init(struct drm_device *dev) { return; }
2353static inline void intel_opregion_fini(struct drm_device *dev) { return; } 2354static inline void intel_opregion_fini(struct drm_device *dev) { return; }
2354static inline void intel_opregion_asle_intr(struct drm_device *dev) { return; } 2355static inline void intel_opregion_asle_intr(struct drm_device *dev) { return; }
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index c79dd2b1f70e..d3c3b5b15824 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -906,14 +906,12 @@ static void gen8_ggtt_insert_entries(struct i915_address_space *vm,
906 WARN_ON(readq(&gtt_entries[i-1]) 906 WARN_ON(readq(&gtt_entries[i-1])
907 != gen8_pte_encode(addr, level, true)); 907 != gen8_pte_encode(addr, level, true));
908 908
909#if 0 /* TODO: Still needed on GEN8? */
910 /* This next bit makes the above posting read even more important. We 909 /* This next bit makes the above posting read even more important. We
911 * want to flush the TLBs only after we're certain all the PTE updates 910 * want to flush the TLBs only after we're certain all the PTE updates
912 * have finished. 911 * have finished.
913 */ 912 */
914 I915_WRITE(GFX_FLSH_CNTL_GEN6, GFX_FLSH_CNTL_EN); 913 I915_WRITE(GFX_FLSH_CNTL_GEN6, GFX_FLSH_CNTL_EN);
915 POSTING_READ(GFX_FLSH_CNTL_GEN6); 914 POSTING_READ(GFX_FLSH_CNTL_GEN6);
916#endif
917} 915}
918 916
919/* 917/*
diff --git a/drivers/gpu/drm/i915/intel_acpi.c b/drivers/gpu/drm/i915/intel_acpi.c
index dfff0907f70e..d96eee1ae9c5 100644
--- a/drivers/gpu/drm/i915/intel_acpi.c
+++ b/drivers/gpu/drm/i915/intel_acpi.c
@@ -6,14 +6,10 @@
6#include <linux/pci.h> 6#include <linux/pci.h>
7#include <linux/acpi.h> 7#include <linux/acpi.h>
8#include <linux/vga_switcheroo.h> 8#include <linux/vga_switcheroo.h>
9#include <acpi/acpi_drivers.h>
10
11#include <drm/drmP.h> 9#include <drm/drmP.h>
12#include "i915_drv.h" 10#include "i915_drv.h"
13 11
14#define INTEL_DSM_REVISION_ID 1 /* For Calpella anyway... */ 12#define INTEL_DSM_REVISION_ID 1 /* For Calpella anyway... */
15
16#define INTEL_DSM_FN_SUPPORTED_FUNCTIONS 0 /* No args */
17#define INTEL_DSM_FN_PLATFORM_MUX_INFO 1 /* No args */ 13#define INTEL_DSM_FN_PLATFORM_MUX_INFO 1 /* No args */
18 14
19static struct intel_dsm_priv { 15static struct intel_dsm_priv {
@@ -28,61 +24,6 @@ static const u8 intel_dsm_guid[] = {
28 0x0f, 0x13, 0x17, 0xb0, 0x1c, 0x2c 24 0x0f, 0x13, 0x17, 0xb0, 0x1c, 0x2c
29}; 25};
30 26
31static int intel_dsm(acpi_handle handle, int func)
32{
33 struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
34 struct acpi_object_list input;
35 union acpi_object params[4];
36 union acpi_object *obj;
37 u32 result;
38 int ret = 0;
39
40 input.count = 4;
41 input.pointer = params;
42 params[0].type = ACPI_TYPE_BUFFER;
43 params[0].buffer.length = sizeof(intel_dsm_guid);
44 params[0].buffer.pointer = (char *)intel_dsm_guid;
45 params[1].type = ACPI_TYPE_INTEGER;
46 params[1].integer.value = INTEL_DSM_REVISION_ID;
47 params[2].type = ACPI_TYPE_INTEGER;
48 params[2].integer.value = func;
49 params[3].type = ACPI_TYPE_PACKAGE;
50 params[3].package.count = 0;
51 params[3].package.elements = NULL;
52
53 ret = acpi_evaluate_object(handle, "_DSM", &input, &output);
54 if (ret) {
55 DRM_DEBUG_DRIVER("failed to evaluate _DSM: %d\n", ret);
56 return ret;
57 }
58
59 obj = (union acpi_object *)output.pointer;
60
61 result = 0;
62 switch (obj->type) {
63 case ACPI_TYPE_INTEGER:
64 result = obj->integer.value;
65 break;
66
67 case ACPI_TYPE_BUFFER:
68 if (obj->buffer.length == 4) {
69 result = (obj->buffer.pointer[0] |
70 (obj->buffer.pointer[1] << 8) |
71 (obj->buffer.pointer[2] << 16) |
72 (obj->buffer.pointer[3] << 24));
73 break;
74 }
75 default:
76 ret = -EINVAL;
77 break;
78 }
79 if (result == 0x80000002)
80 ret = -ENODEV;
81
82 kfree(output.pointer);
83 return ret;
84}
85
86static char *intel_dsm_port_name(u8 id) 27static char *intel_dsm_port_name(u8 id)
87{ 28{
88 switch (id) { 29 switch (id) {
@@ -137,83 +78,56 @@ static char *intel_dsm_mux_type(u8 type)
137 78
138static void intel_dsm_platform_mux_info(void) 79static void intel_dsm_platform_mux_info(void)
139{ 80{
140 struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; 81 int i;
141 struct acpi_object_list input; 82 union acpi_object *pkg, *connector_count;
142 union acpi_object params[4]; 83
143 union acpi_object *pkg; 84 pkg = acpi_evaluate_dsm_typed(intel_dsm_priv.dhandle, intel_dsm_guid,
144 int i, ret; 85 INTEL_DSM_REVISION_ID, INTEL_DSM_FN_PLATFORM_MUX_INFO,
145 86 NULL, ACPI_TYPE_PACKAGE);
146 input.count = 4; 87 if (!pkg) {
147 input.pointer = params; 88 DRM_DEBUG_DRIVER("failed to evaluate _DSM\n");
148 params[0].type = ACPI_TYPE_BUFFER; 89 return;
149 params[0].buffer.length = sizeof(intel_dsm_guid);
150 params[0].buffer.pointer = (char *)intel_dsm_guid;
151 params[1].type = ACPI_TYPE_INTEGER;
152 params[1].integer.value = INTEL_DSM_REVISION_ID;
153 params[2].type = ACPI_TYPE_INTEGER;
154 params[2].integer.value = INTEL_DSM_FN_PLATFORM_MUX_INFO;
155 params[3].type = ACPI_TYPE_PACKAGE;
156 params[3].package.count = 0;
157 params[3].package.elements = NULL;
158
159 ret = acpi_evaluate_object(intel_dsm_priv.dhandle, "_DSM", &input,
160 &output);
161 if (ret) {
162 DRM_DEBUG_DRIVER("failed to evaluate _DSM: %d\n", ret);
163 goto out;
164 } 90 }
165 91
166 pkg = (union acpi_object *)output.pointer; 92 connector_count = &pkg->package.elements[0];
167 93 DRM_DEBUG_DRIVER("MUX info connectors: %lld\n",
168 if (pkg->type == ACPI_TYPE_PACKAGE) { 94 (unsigned long long)connector_count->integer.value);
169 union acpi_object *connector_count = &pkg->package.elements[0]; 95 for (i = 1; i < pkg->package.count; i++) {
170 DRM_DEBUG_DRIVER("MUX info connectors: %lld\n", 96 union acpi_object *obj = &pkg->package.elements[i];
171 (unsigned long long)connector_count->integer.value); 97 union acpi_object *connector_id = &obj->package.elements[0];
172 for (i = 1; i < pkg->package.count; i++) { 98 union acpi_object *info = &obj->package.elements[1];
173 union acpi_object *obj = &pkg->package.elements[i]; 99 DRM_DEBUG_DRIVER("Connector id: 0x%016llx\n",
174 union acpi_object *connector_id = 100 (unsigned long long)connector_id->integer.value);
175 &obj->package.elements[0]; 101 DRM_DEBUG_DRIVER(" port id: %s\n",
176 union acpi_object *info = &obj->package.elements[1]; 102 intel_dsm_port_name(info->buffer.pointer[0]));
177 DRM_DEBUG_DRIVER("Connector id: 0x%016llx\n", 103 DRM_DEBUG_DRIVER(" display mux info: %s\n",
178 (unsigned long long)connector_id->integer.value); 104 intel_dsm_mux_type(info->buffer.pointer[1]));
179 DRM_DEBUG_DRIVER(" port id: %s\n", 105 DRM_DEBUG_DRIVER(" aux/dc mux info: %s\n",
180 intel_dsm_port_name(info->buffer.pointer[0])); 106 intel_dsm_mux_type(info->buffer.pointer[2]));
181 DRM_DEBUG_DRIVER(" display mux info: %s\n", 107 DRM_DEBUG_DRIVER(" hpd mux info: %s\n",
182 intel_dsm_mux_type(info->buffer.pointer[1])); 108 intel_dsm_mux_type(info->buffer.pointer[3]));
183 DRM_DEBUG_DRIVER(" aux/dc mux info: %s\n",
184 intel_dsm_mux_type(info->buffer.pointer[2]));
185 DRM_DEBUG_DRIVER(" hpd mux info: %s\n",
186 intel_dsm_mux_type(info->buffer.pointer[3]));
187 }
188 } 109 }
189 110
190out: 111 ACPI_FREE(pkg);
191 kfree(output.pointer);
192} 112}
193 113
194static bool intel_dsm_pci_probe(struct pci_dev *pdev) 114static bool intel_dsm_pci_probe(struct pci_dev *pdev)
195{ 115{
196 acpi_handle dhandle; 116 acpi_handle dhandle;
197 int ret;
198 117
199 dhandle = ACPI_HANDLE(&pdev->dev); 118 dhandle = ACPI_HANDLE(&pdev->dev);
200 if (!dhandle) 119 if (!dhandle)
201 return false; 120 return false;
202 121
203 if (!acpi_has_method(dhandle, "_DSM")) { 122 if (!acpi_check_dsm(dhandle, intel_dsm_guid, INTEL_DSM_REVISION_ID,
123 1 << INTEL_DSM_FN_PLATFORM_MUX_INFO)) {
204 DRM_DEBUG_KMS("no _DSM method for intel device\n"); 124 DRM_DEBUG_KMS("no _DSM method for intel device\n");
205 return false; 125 return false;
206 } 126 }
207 127
208 ret = intel_dsm(dhandle, INTEL_DSM_FN_SUPPORTED_FUNCTIONS);
209 if (ret < 0) {
210 DRM_DEBUG_KMS("failed to get supported _DSM functions\n");
211 return false;
212 }
213
214 intel_dsm_priv.dhandle = dhandle; 128 intel_dsm_priv.dhandle = dhandle;
215
216 intel_dsm_platform_mux_info(); 129 intel_dsm_platform_mux_info();
130
217 return true; 131 return true;
218} 132}
219 133
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 54e82a80cf50..769b864465a9 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -10541,11 +10541,20 @@ static struct intel_quirk intel_quirks[] = {
10541 /* Sony Vaio Y cannot use SSC on LVDS */ 10541 /* Sony Vaio Y cannot use SSC on LVDS */
10542 { 0x0046, 0x104d, 0x9076, quirk_ssc_force_disable }, 10542 { 0x0046, 0x104d, 0x9076, quirk_ssc_force_disable },
10543 10543
10544 /* 10544 /* Acer Aspire 5734Z must invert backlight brightness */
10545 * All GM45 Acer (and its brands eMachines and Packard Bell) laptops 10545 { 0x2a42, 0x1025, 0x0459, quirk_invert_brightness },
10546 * seem to use inverted backlight PWM. 10546
10547 */ 10547 /* Acer/eMachines G725 */
10548 { 0x2a42, 0x1025, PCI_ANY_ID, quirk_invert_brightness }, 10548 { 0x2a42, 0x1025, 0x0210, quirk_invert_brightness },
10549
10550 /* Acer/eMachines e725 */
10551 { 0x2a42, 0x1025, 0x0212, quirk_invert_brightness },
10552
10553 /* Acer/Packard Bell NCL20 */
10554 { 0x2a42, 0x1025, 0x034b, quirk_invert_brightness },
10555
10556 /* Acer Aspire 4736Z */
10557 { 0x2a42, 0x1025, 0x0260, quirk_invert_brightness },
10549 10558
10550 /* Dell XPS13 HD Sandy Bridge */ 10559 /* Dell XPS13 HD Sandy Bridge */
10551 { 0x0116, 0x1028, 0x052e, quirk_no_pcm_pwm_enable }, 10560 { 0x0116, 0x1028, 0x052e, quirk_no_pcm_pwm_enable },
diff --git a/drivers/gpu/drm/i915/intel_opregion.c b/drivers/gpu/drm/i915/intel_opregion.c
index 6d69a9bad865..9a8804bee5cd 100644
--- a/drivers/gpu/drm/i915/intel_opregion.c
+++ b/drivers/gpu/drm/i915/intel_opregion.c
@@ -28,7 +28,6 @@
28#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 28#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
29 29
30#include <linux/acpi.h> 30#include <linux/acpi.h>
31#include <linux/acpi_io.h>
32#include <acpi/video.h> 31#include <acpi/video.h>
33 32
34#include <drm/drmP.h> 33#include <drm/drmP.h>
diff --git a/drivers/gpu/drm/nouveau/core/core/subdev.c b/drivers/gpu/drm/nouveau/core/core/subdev.c
index 48f06378d3f9..2ea5568b6cf5 100644
--- a/drivers/gpu/drm/nouveau/core/core/subdev.c
+++ b/drivers/gpu/drm/nouveau/core/core/subdev.c
@@ -104,11 +104,8 @@ nouveau_subdev_create_(struct nouveau_object *parent,
104 104
105 if (parent) { 105 if (parent) {
106 struct nouveau_device *device = nv_device(parent); 106 struct nouveau_device *device = nv_device(parent);
107 int subidx = nv_hclass(subdev) & 0xff;
108
109 subdev->debug = nouveau_dbgopt(device->dbgopt, subname); 107 subdev->debug = nouveau_dbgopt(device->dbgopt, subname);
110 subdev->mmio = nv_subdev(device)->mmio; 108 subdev->mmio = nv_subdev(device)->mmio;
111 device->subdev[subidx] = *pobject;
112 } 109 }
113 110
114 return 0; 111 return 0;
diff --git a/drivers/gpu/drm/nouveau/core/engine/device/base.c b/drivers/gpu/drm/nouveau/core/engine/device/base.c
index 9135b25a29d0..dd01c6c435d6 100644
--- a/drivers/gpu/drm/nouveau/core/engine/device/base.c
+++ b/drivers/gpu/drm/nouveau/core/engine/device/base.c
@@ -268,6 +268,8 @@ nouveau_devobj_ctor(struct nouveau_object *parent,
268 if (ret) 268 if (ret)
269 return ret; 269 return ret;
270 270
271 device->subdev[i] = devobj->subdev[i];
272
271 /* note: can't init *any* subdevs until devinit has been run 273 /* note: can't init *any* subdevs until devinit has been run
272 * due to not knowing exactly what the vbios init tables will 274 * due to not knowing exactly what the vbios init tables will
273 * mess with. devinit also can't be run until all of its 275 * mess with. devinit also can't be run until all of its
diff --git a/drivers/gpu/drm/nouveau/core/engine/device/nvc0.c b/drivers/gpu/drm/nouveau/core/engine/device/nvc0.c
index 8d06eef2b9ee..dbc5e33de94f 100644
--- a/drivers/gpu/drm/nouveau/core/engine/device/nvc0.c
+++ b/drivers/gpu/drm/nouveau/core/engine/device/nvc0.c
@@ -161,7 +161,7 @@ nvc0_identify(struct nouveau_device *device)
161 device->oclass[NVDEV_SUBDEV_THERM ] = &nva3_therm_oclass; 161 device->oclass[NVDEV_SUBDEV_THERM ] = &nva3_therm_oclass;
162 device->oclass[NVDEV_SUBDEV_MXM ] = &nv50_mxm_oclass; 162 device->oclass[NVDEV_SUBDEV_MXM ] = &nv50_mxm_oclass;
163 device->oclass[NVDEV_SUBDEV_DEVINIT] = &nvc0_devinit_oclass; 163 device->oclass[NVDEV_SUBDEV_DEVINIT] = &nvc0_devinit_oclass;
164 device->oclass[NVDEV_SUBDEV_MC ] = nvc3_mc_oclass; 164 device->oclass[NVDEV_SUBDEV_MC ] = nvc0_mc_oclass;
165 device->oclass[NVDEV_SUBDEV_BUS ] = nvc0_bus_oclass; 165 device->oclass[NVDEV_SUBDEV_BUS ] = nvc0_bus_oclass;
166 device->oclass[NVDEV_SUBDEV_TIMER ] = &nv04_timer_oclass; 166 device->oclass[NVDEV_SUBDEV_TIMER ] = &nv04_timer_oclass;
167 device->oclass[NVDEV_SUBDEV_FB ] = nvc0_fb_oclass; 167 device->oclass[NVDEV_SUBDEV_FB ] = nvc0_fb_oclass;
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/nvc0.c b/drivers/gpu/drm/nouveau/core/engine/graph/nvc0.c
index 434bb4b0fa2e..5c8a63dc506a 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/nvc0.c
+++ b/drivers/gpu/drm/nouveau/core/engine/graph/nvc0.c
@@ -334,7 +334,7 @@ nvc0_graph_mthd(struct nvc0_graph_priv *priv, struct nvc0_graph_mthd *mthds)
334 while ((mthd = &mthds[i++]) && (init = mthd->init)) { 334 while ((mthd = &mthds[i++]) && (init = mthd->init)) {
335 u32 addr = 0x80000000 | mthd->oclass; 335 u32 addr = 0x80000000 | mthd->oclass;
336 for (data = 0; init->count; init++) { 336 for (data = 0; init->count; init++) {
337 if (data != init->data) { 337 if (init == mthd->init || data != init->data) {
338 nv_wr32(priv, 0x40448c, init->data); 338 nv_wr32(priv, 0x40448c, init->data);
339 data = init->data; 339 data = init->data;
340 } 340 }
diff --git a/drivers/gpu/drm/nouveau/core/include/subdev/fb.h b/drivers/gpu/drm/nouveau/core/include/subdev/fb.h
index 8541aa382ff2..d89dbdf39b0d 100644
--- a/drivers/gpu/drm/nouveau/core/include/subdev/fb.h
+++ b/drivers/gpu/drm/nouveau/core/include/subdev/fb.h
@@ -75,6 +75,11 @@ struct nouveau_fb {
75static inline struct nouveau_fb * 75static inline struct nouveau_fb *
76nouveau_fb(void *obj) 76nouveau_fb(void *obj)
77{ 77{
78 /* fbram uses this before device subdev pointer is valid */
79 if (nv_iclass(obj, NV_SUBDEV_CLASS) &&
80 nv_subidx(obj) == NVDEV_SUBDEV_FB)
81 return obj;
82
78 return (void *)nv_device(obj)->subdev[NVDEV_SUBDEV_FB]; 83 return (void *)nv_device(obj)->subdev[NVDEV_SUBDEV_FB];
79} 84}
80 85
diff --git a/drivers/gpu/drm/nouveau/core/subdev/bios/init.c b/drivers/gpu/drm/nouveau/core/subdev/bios/init.c
index 420908cb82b6..df1b1b423093 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/bios/init.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/bios/init.c
@@ -365,13 +365,13 @@ static u16
365init_script(struct nouveau_bios *bios, int index) 365init_script(struct nouveau_bios *bios, int index)
366{ 366{
367 struct nvbios_init init = { .bios = bios }; 367 struct nvbios_init init = { .bios = bios };
368 u16 data; 368 u16 bmp_ver = bmp_version(bios), data;
369 369
370 if (bmp_version(bios) && bmp_version(bios) < 0x0510) { 370 if (bmp_ver && bmp_ver < 0x0510) {
371 if (index > 1) 371 if (index > 1 || bmp_ver < 0x0100)
372 return 0x0000; 372 return 0x0000;
373 373
374 data = bios->bmp_offset + (bios->version.major < 2 ? 14 : 18); 374 data = bios->bmp_offset + (bmp_ver < 0x0200 ? 14 : 18);
375 return nv_ro16(bios, data + (index * 2)); 375 return nv_ro16(bios, data + (index * 2));
376 } 376 }
377 377
@@ -1294,7 +1294,11 @@ init_jump(struct nvbios_init *init)
1294 u16 offset = nv_ro16(bios, init->offset + 1); 1294 u16 offset = nv_ro16(bios, init->offset + 1);
1295 1295
1296 trace("JUMP\t0x%04x\n", offset); 1296 trace("JUMP\t0x%04x\n", offset);
1297 init->offset = offset; 1297
1298 if (init_exec(init))
1299 init->offset = offset;
1300 else
1301 init->offset += 3;
1298} 1302}
1299 1303
1300/** 1304/**
diff --git a/drivers/gpu/drm/nouveau/core/subdev/mxm/base.c b/drivers/gpu/drm/nouveau/core/subdev/mxm/base.c
index 129120473f6c..13c5af88a601 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/mxm/base.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/mxm/base.c
@@ -87,55 +87,39 @@ mxm_shadow_dsm(struct nouveau_mxm *mxm, u8 version)
87 0xB8, 0x9C, 0x79, 0xB6, 0x2F, 0xD5, 0x56, 0x65 87 0xB8, 0x9C, 0x79, 0xB6, 0x2F, 0xD5, 0x56, 0x65
88 }; 88 };
89 u32 mxms_args[] = { 0x00000000 }; 89 u32 mxms_args[] = { 0x00000000 };
90 union acpi_object args[4] = { 90 union acpi_object argv4 = {
91 /* _DSM MUID */ 91 .buffer.type = ACPI_TYPE_BUFFER,
92 { .buffer.type = 3, 92 .buffer.length = sizeof(mxms_args),
93 .buffer.length = sizeof(muid), 93 .buffer.pointer = (char *)mxms_args,
94 .buffer.pointer = muid,
95 },
96 /* spec says this can be zero to mean "highest revision", but
97 * of course there's at least one bios out there which fails
98 * unless you pass in exactly the version it supports..
99 */
100 { .integer.type = ACPI_TYPE_INTEGER,
101 .integer.value = (version & 0xf0) << 4 | (version & 0x0f),
102 },
103 /* MXMS function */
104 { .integer.type = ACPI_TYPE_INTEGER,
105 .integer.value = 0x00000010,
106 },
107 /* Pointer to MXMS arguments */
108 { .buffer.type = ACPI_TYPE_BUFFER,
109 .buffer.length = sizeof(mxms_args),
110 .buffer.pointer = (char *)mxms_args,
111 },
112 }; 94 };
113 struct acpi_object_list list = { ARRAY_SIZE(args), args };
114 struct acpi_buffer retn = { ACPI_ALLOCATE_BUFFER, NULL };
115 union acpi_object *obj; 95 union acpi_object *obj;
116 acpi_handle handle; 96 acpi_handle handle;
117 int ret; 97 int rev;
118 98
119 handle = ACPI_HANDLE(&device->pdev->dev); 99 handle = ACPI_HANDLE(&device->pdev->dev);
120 if (!handle) 100 if (!handle)
121 return false; 101 return false;
122 102
123 ret = acpi_evaluate_object(handle, "_DSM", &list, &retn); 103 /*
124 if (ret) { 104 * spec says this can be zero to mean "highest revision", but
125 nv_debug(mxm, "DSM MXMS failed: %d\n", ret); 105 * of course there's at least one bios out there which fails
106 * unless you pass in exactly the version it supports..
107 */
108 rev = (version & 0xf0) << 4 | (version & 0x0f);
109 obj = acpi_evaluate_dsm(handle, muid, rev, 0x00000010, &argv4);
110 if (!obj) {
111 nv_debug(mxm, "DSM MXMS failed\n");
126 return false; 112 return false;
127 } 113 }
128 114
129 obj = retn.pointer;
130 if (obj->type == ACPI_TYPE_BUFFER) { 115 if (obj->type == ACPI_TYPE_BUFFER) {
131 mxm->mxms = kmemdup(obj->buffer.pointer, 116 mxm->mxms = kmemdup(obj->buffer.pointer,
132 obj->buffer.length, GFP_KERNEL); 117 obj->buffer.length, GFP_KERNEL);
133 } else 118 } else if (obj->type == ACPI_TYPE_INTEGER) {
134 if (obj->type == ACPI_TYPE_INTEGER) {
135 nv_debug(mxm, "DSM MXMS returned 0x%llx\n", obj->integer.value); 119 nv_debug(mxm, "DSM MXMS returned 0x%llx\n", obj->integer.value);
136 } 120 }
137 121
138 kfree(obj); 122 ACPI_FREE(obj);
139 return mxm->mxms != NULL; 123 return mxm->mxms != NULL;
140} 124}
141#endif 125#endif
diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.c b/drivers/gpu/drm/nouveau/nouveau_abi16.c
index 6828d81ed7b9..900fae01793e 100644
--- a/drivers/gpu/drm/nouveau/nouveau_abi16.c
+++ b/drivers/gpu/drm/nouveau/nouveau_abi16.c
@@ -447,6 +447,8 @@ nouveau_abi16_ioctl_notifierobj_alloc(ABI16_IOCTL_ARGS)
447 if (ret) 447 if (ret)
448 goto done; 448 goto done;
449 449
450 info->offset = ntfy->node->offset;
451
450done: 452done:
451 if (ret) 453 if (ret)
452 nouveau_abi16_ntfy_fini(chan, ntfy); 454 nouveau_abi16_ntfy_fini(chan, ntfy);
diff --git a/drivers/gpu/drm/nouveau/nouveau_acpi.c b/drivers/gpu/drm/nouveau/nouveau_acpi.c
index ba0183fb84f3..3c149617cfcb 100644
--- a/drivers/gpu/drm/nouveau/nouveau_acpi.c
+++ b/drivers/gpu/drm/nouveau/nouveau_acpi.c
@@ -1,15 +1,10 @@
1#include <linux/pci.h> 1#include <linux/pci.h>
2#include <linux/acpi.h> 2#include <linux/acpi.h>
3#include <linux/slab.h> 3#include <linux/slab.h>
4#include <acpi/acpi_drivers.h>
5#include <acpi/acpi_bus.h>
6#include <acpi/video.h>
7#include <acpi/acpi.h>
8#include <linux/mxm-wmi.h> 4#include <linux/mxm-wmi.h>
9
10#include <linux/vga_switcheroo.h> 5#include <linux/vga_switcheroo.h>
11
12#include <drm/drm_edid.h> 6#include <drm/drm_edid.h>
7#include <acpi/video.h>
13 8
14#include "nouveau_drm.h" 9#include "nouveau_drm.h"
15#include "nouveau_acpi.h" 10#include "nouveau_acpi.h"
@@ -78,124 +73,66 @@ static const char nouveau_op_dsm_muid[] = {
78 73
79static int nouveau_optimus_dsm(acpi_handle handle, int func, int arg, uint32_t *result) 74static int nouveau_optimus_dsm(acpi_handle handle, int func, int arg, uint32_t *result)
80{ 75{
81 struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; 76 int i;
82 struct acpi_object_list input;
83 union acpi_object params[4];
84 union acpi_object *obj; 77 union acpi_object *obj;
85 int i, err;
86 char args_buff[4]; 78 char args_buff[4];
79 union acpi_object argv4 = {
80 .buffer.type = ACPI_TYPE_BUFFER,
81 .buffer.length = 4,
82 .buffer.pointer = args_buff
83 };
87 84
88 input.count = 4;
89 input.pointer = params;
90 params[0].type = ACPI_TYPE_BUFFER;
91 params[0].buffer.length = sizeof(nouveau_op_dsm_muid);
92 params[0].buffer.pointer = (char *)nouveau_op_dsm_muid;
93 params[1].type = ACPI_TYPE_INTEGER;
94 params[1].integer.value = 0x00000100;
95 params[2].type = ACPI_TYPE_INTEGER;
96 params[2].integer.value = func;
97 params[3].type = ACPI_TYPE_BUFFER;
98 params[3].buffer.length = 4;
99 /* ACPI is little endian, AABBCCDD becomes {DD,CC,BB,AA} */ 85 /* ACPI is little endian, AABBCCDD becomes {DD,CC,BB,AA} */
100 for (i = 0; i < 4; i++) 86 for (i = 0; i < 4; i++)
101 args_buff[i] = (arg >> i * 8) & 0xFF; 87 args_buff[i] = (arg >> i * 8) & 0xFF;
102 params[3].buffer.pointer = args_buff;
103
104 err = acpi_evaluate_object(handle, "_DSM", &input, &output);
105 if (err) {
106 printk(KERN_INFO "failed to evaluate _DSM: %d\n", err);
107 return err;
108 }
109
110 obj = (union acpi_object *)output.pointer;
111 88
112 if (obj->type == ACPI_TYPE_INTEGER) 89 *result = 0;
113 if (obj->integer.value == 0x80000002) { 90 obj = acpi_evaluate_dsm_typed(handle, nouveau_op_dsm_muid, 0x00000100,
114 return -ENODEV; 91 func, &argv4, ACPI_TYPE_BUFFER);
115 } 92 if (!obj) {
116 93 acpi_handle_info(handle, "failed to evaluate _DSM\n");
117 if (obj->type == ACPI_TYPE_BUFFER) { 94 return AE_ERROR;
118 if (obj->buffer.length == 4 && result) { 95 } else {
119 *result = 0; 96 if (obj->buffer.length == 4) {
120 *result |= obj->buffer.pointer[0]; 97 *result |= obj->buffer.pointer[0];
121 *result |= (obj->buffer.pointer[1] << 8); 98 *result |= (obj->buffer.pointer[1] << 8);
122 *result |= (obj->buffer.pointer[2] << 16); 99 *result |= (obj->buffer.pointer[2] << 16);
123 *result |= (obj->buffer.pointer[3] << 24); 100 *result |= (obj->buffer.pointer[3] << 24);
124 } 101 }
102 ACPI_FREE(obj);
125 } 103 }
126 104
127 kfree(output.pointer);
128 return 0; 105 return 0;
129} 106}
130 107
131static int nouveau_dsm(acpi_handle handle, int func, int arg, uint32_t *result) 108static int nouveau_dsm(acpi_handle handle, int func, int arg)
132{ 109{
133 struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; 110 int ret = 0;
134 struct acpi_object_list input;
135 union acpi_object params[4];
136 union acpi_object *obj; 111 union acpi_object *obj;
137 int err; 112 union acpi_object argv4 = {
138 113 .integer.type = ACPI_TYPE_INTEGER,
139 input.count = 4; 114 .integer.value = arg,
140 input.pointer = params; 115 };
141 params[0].type = ACPI_TYPE_BUFFER; 116
142 params[0].buffer.length = sizeof(nouveau_dsm_muid); 117 obj = acpi_evaluate_dsm_typed(handle, nouveau_dsm_muid, 0x00000102,
143 params[0].buffer.pointer = (char *)nouveau_dsm_muid; 118 func, &argv4, ACPI_TYPE_INTEGER);
144 params[1].type = ACPI_TYPE_INTEGER; 119 if (!obj) {
145 params[1].integer.value = 0x00000102; 120 acpi_handle_info(handle, "failed to evaluate _DSM\n");
146 params[2].type = ACPI_TYPE_INTEGER; 121 return AE_ERROR;
147 params[2].integer.value = func; 122 } else {
148 params[3].type = ACPI_TYPE_INTEGER;
149 params[3].integer.value = arg;
150
151 err = acpi_evaluate_object(handle, "_DSM", &input, &output);
152 if (err) {
153 printk(KERN_INFO "failed to evaluate _DSM: %d\n", err);
154 return err;
155 }
156
157 obj = (union acpi_object *)output.pointer;
158
159 if (obj->type == ACPI_TYPE_INTEGER)
160 if (obj->integer.value == 0x80000002) 123 if (obj->integer.value == 0x80000002)
161 return -ENODEV; 124 ret = -ENODEV;
162 125 ACPI_FREE(obj);
163 if (obj->type == ACPI_TYPE_BUFFER) {
164 if (obj->buffer.length == 4 && result) {
165 *result = 0;
166 *result |= obj->buffer.pointer[0];
167 *result |= (obj->buffer.pointer[1] << 8);
168 *result |= (obj->buffer.pointer[2] << 16);
169 *result |= (obj->buffer.pointer[3] << 24);
170 }
171 } 126 }
172 127
173 kfree(output.pointer); 128 return ret;
174 return 0;
175}
176
177/* Returns 1 if a DSM function is usable and 0 otherwise */
178static int nouveau_test_dsm(acpi_handle test_handle,
179 int (*dsm_func)(acpi_handle, int, int, uint32_t *),
180 int sfnc)
181{
182 u32 result = 0;
183
184 /* Function 0 returns a Buffer containing available functions. The args
185 * parameter is ignored for function 0, so just put 0 in it */
186 if (dsm_func(test_handle, 0, 0, &result))
187 return 0;
188
189 /* ACPI Spec v4 9.14.1: if bit 0 is zero, no function is supported. If
190 * the n-th bit is enabled, function n is supported */
191 return result & 1 && result & (1 << sfnc);
192} 129}
193 130
194static int nouveau_dsm_switch_mux(acpi_handle handle, int mux_id) 131static int nouveau_dsm_switch_mux(acpi_handle handle, int mux_id)
195{ 132{
196 mxm_wmi_call_mxmx(mux_id == NOUVEAU_DSM_LED_STAMINA ? MXM_MXDS_ADAPTER_IGD : MXM_MXDS_ADAPTER_0); 133 mxm_wmi_call_mxmx(mux_id == NOUVEAU_DSM_LED_STAMINA ? MXM_MXDS_ADAPTER_IGD : MXM_MXDS_ADAPTER_0);
197 mxm_wmi_call_mxds(mux_id == NOUVEAU_DSM_LED_STAMINA ? MXM_MXDS_ADAPTER_IGD : MXM_MXDS_ADAPTER_0); 134 mxm_wmi_call_mxds(mux_id == NOUVEAU_DSM_LED_STAMINA ? MXM_MXDS_ADAPTER_IGD : MXM_MXDS_ADAPTER_0);
198 return nouveau_dsm(handle, NOUVEAU_DSM_LED, mux_id, NULL); 135 return nouveau_dsm(handle, NOUVEAU_DSM_LED, mux_id);
199} 136}
200 137
201static int nouveau_dsm_set_discrete_state(acpi_handle handle, enum vga_switcheroo_state state) 138static int nouveau_dsm_set_discrete_state(acpi_handle handle, enum vga_switcheroo_state state)
@@ -205,7 +142,7 @@ static int nouveau_dsm_set_discrete_state(acpi_handle handle, enum vga_switchero
205 arg = NOUVEAU_DSM_POWER_SPEED; 142 arg = NOUVEAU_DSM_POWER_SPEED;
206 else 143 else
207 arg = NOUVEAU_DSM_POWER_STAMINA; 144 arg = NOUVEAU_DSM_POWER_STAMINA;
208 nouveau_dsm(handle, NOUVEAU_DSM_POWER, arg, NULL); 145 nouveau_dsm(handle, NOUVEAU_DSM_POWER, arg);
209 return 0; 146 return 0;
210} 147}
211 148
@@ -265,11 +202,12 @@ static int nouveau_dsm_pci_probe(struct pci_dev *pdev)
265 nouveau_dsm_priv.other_handle = dhandle; 202 nouveau_dsm_priv.other_handle = dhandle;
266 return false; 203 return false;
267 } 204 }
268 if (nouveau_test_dsm(dhandle, nouveau_dsm, NOUVEAU_DSM_POWER)) 205 if (acpi_check_dsm(dhandle, nouveau_dsm_muid, 0x00000102,
206 1 << NOUVEAU_DSM_POWER))
269 retval |= NOUVEAU_DSM_HAS_MUX; 207 retval |= NOUVEAU_DSM_HAS_MUX;
270 208
271 if (nouveau_test_dsm(dhandle, nouveau_optimus_dsm, 209 if (acpi_check_dsm(dhandle, nouveau_op_dsm_muid, 0x00000100,
272 NOUVEAU_DSM_OPTIMUS_CAPS)) 210 1 << NOUVEAU_DSM_OPTIMUS_CAPS))
273 retval |= NOUVEAU_DSM_HAS_OPT; 211 retval |= NOUVEAU_DSM_HAS_OPT;
274 212
275 if (retval & NOUVEAU_DSM_HAS_OPT) { 213 if (retval & NOUVEAU_DSM_HAS_OPT) {
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index 29c3efdfc7dd..25ea82f8def3 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -610,7 +610,7 @@ nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
610 ret = nouveau_fence_sync(fence, chan); 610 ret = nouveau_fence_sync(fence, chan);
611 nouveau_fence_unref(&fence); 611 nouveau_fence_unref(&fence);
612 if (ret) 612 if (ret)
613 return ret; 613 goto fail_free;
614 614
615 if (new_bo != old_bo) { 615 if (new_bo != old_bo) {
616 ret = nouveau_bo_pin(new_bo, TTM_PL_FLAG_VRAM); 616 ret = nouveau_bo_pin(new_bo, TTM_PL_FLAG_VRAM);
diff --git a/drivers/gpu/drm/radeon/radeon_acpi.c b/drivers/gpu/drm/radeon/radeon_acpi.c
index 98a9074b306b..77e9d07c55b6 100644
--- a/drivers/gpu/drm/radeon/radeon_acpi.c
+++ b/drivers/gpu/drm/radeon/radeon_acpi.c
@@ -25,18 +25,14 @@
25#include <linux/acpi.h> 25#include <linux/acpi.h>
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/power_supply.h> 27#include <linux/power_supply.h>
28#include <acpi/acpi_drivers.h> 28#include <linux/vga_switcheroo.h>
29#include <acpi/acpi_bus.h>
30#include <acpi/video.h> 29#include <acpi/video.h>
31
32#include <drm/drmP.h> 30#include <drm/drmP.h>
33#include <drm/drm_crtc_helper.h> 31#include <drm/drm_crtc_helper.h>
34#include "radeon.h" 32#include "radeon.h"
35#include "radeon_acpi.h" 33#include "radeon_acpi.h"
36#include "atom.h" 34#include "atom.h"
37 35
38#include <linux/vga_switcheroo.h>
39
40#define ACPI_AC_CLASS "ac_adapter" 36#define ACPI_AC_CLASS "ac_adapter"
41 37
42extern void radeon_pm_acpi_event_handler(struct radeon_device *rdev); 38extern void radeon_pm_acpi_event_handler(struct radeon_device *rdev);
diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c
index 5f7e55f4b7f0..d22668f7d982 100644
--- a/drivers/hid/i2c-hid/i2c-hid.c
+++ b/drivers/hid/i2c-hid/i2c-hid.c
@@ -850,37 +850,23 @@ static int i2c_hid_acpi_pdata(struct i2c_client *client,
850 0xF7, 0xF6, 0xDF, 0x3C, 0x67, 0x42, 0x55, 0x45, 850 0xF7, 0xF6, 0xDF, 0x3C, 0x67, 0x42, 0x55, 0x45,
851 0xAD, 0x05, 0xB3, 0x0A, 0x3D, 0x89, 0x38, 0xDE, 851 0xAD, 0x05, 0xB3, 0x0A, 0x3D, 0x89, 0x38, 0xDE,
852 }; 852 };
853 union acpi_object params[4]; 853 union acpi_object *obj;
854 struct acpi_object_list input;
855 struct acpi_device *adev; 854 struct acpi_device *adev;
856 unsigned long long value;
857 acpi_handle handle; 855 acpi_handle handle;
858 856
859 handle = ACPI_HANDLE(&client->dev); 857 handle = ACPI_HANDLE(&client->dev);
860 if (!handle || acpi_bus_get_device(handle, &adev)) 858 if (!handle || acpi_bus_get_device(handle, &adev))
861 return -ENODEV; 859 return -ENODEV;
862 860
863 input.count = ARRAY_SIZE(params); 861 obj = acpi_evaluate_dsm_typed(handle, i2c_hid_guid, 1, 1, NULL,
864 input.pointer = params; 862 ACPI_TYPE_INTEGER);
865 863 if (!obj) {
866 params[0].type = ACPI_TYPE_BUFFER;
867 params[0].buffer.length = sizeof(i2c_hid_guid);
868 params[0].buffer.pointer = i2c_hid_guid;
869 params[1].type = ACPI_TYPE_INTEGER;
870 params[1].integer.value = 1;
871 params[2].type = ACPI_TYPE_INTEGER;
872 params[2].integer.value = 1; /* HID function */
873 params[3].type = ACPI_TYPE_PACKAGE;
874 params[3].package.count = 0;
875 params[3].package.elements = NULL;
876
877 if (ACPI_FAILURE(acpi_evaluate_integer(handle, "_DSM", &input,
878 &value))) {
879 dev_err(&client->dev, "device _DSM execution failed\n"); 864 dev_err(&client->dev, "device _DSM execution failed\n");
880 return -ENODEV; 865 return -ENODEV;
881 } 866 }
882 867
883 pdata->hid_descriptor_address = value; 868 pdata->hid_descriptor_address = obj->integer.value;
869 ACPI_FREE(obj);
884 870
885 return 0; 871 return 0;
886} 872}
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 48aad4faea06..077bb1bdac34 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -30,7 +30,6 @@
30#include <linux/sysctl.h> 30#include <linux/sysctl.h>
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/acpi.h> 32#include <linux/acpi.h>
33#include <acpi/acpi_bus.h>
34#include <linux/completion.h> 33#include <linux/completion.h>
35#include <linux/hyperv.h> 34#include <linux/hyperv.h>
36#include <linux/kernel_stat.h> 35#include <linux/kernel_stat.h>
@@ -39,7 +38,6 @@
39#include <asm/mshyperv.h> 38#include <asm/mshyperv.h>
40#include "hyperv_vmbus.h" 39#include "hyperv_vmbus.h"
41 40
42
43static struct acpi_device *hv_acpi_dev; 41static struct acpi_device *hv_acpi_dev;
44 42
45static struct tasklet_struct msg_dpc; 43static struct tasklet_struct msg_dpc;
diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
index 6a34f7f48eb9..579bdf93be43 100644
--- a/drivers/hwmon/acpi_power_meter.c
+++ b/drivers/hwmon/acpi_power_meter.c
@@ -30,8 +30,7 @@
30#include <linux/sched.h> 30#include <linux/sched.h>
31#include <linux/time.h> 31#include <linux/time.h>
32#include <linux/err.h> 32#include <linux/err.h>
33#include <acpi/acpi_drivers.h> 33#include <linux/acpi.h>
34#include <acpi/acpi_bus.h>
35 34
36#define ACPI_POWER_METER_NAME "power_meter" 35#define ACPI_POWER_METER_NAME "power_meter"
37ACPI_MODULE_NAME(ACPI_POWER_METER_NAME); 36ACPI_MODULE_NAME(ACPI_POWER_METER_NAME);
diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
index dafc63c6932d..ae208f612198 100644
--- a/drivers/hwmon/asus_atk0110.c
+++ b/drivers/hwmon/asus_atk0110.c
@@ -16,11 +16,7 @@
16#include <linux/dmi.h> 16#include <linux/dmi.h>
17#include <linux/jiffies.h> 17#include <linux/jiffies.h>
18#include <linux/err.h> 18#include <linux/err.h>
19 19#include <linux/acpi.h>
20#include <acpi/acpi.h>
21#include <acpi/acpi_drivers.h>
22#include <acpi/acpi_bus.h>
23
24 20
25#define ATK_HID "ATK0110" 21#define ATK_HID "ATK0110"
26 22
diff --git a/drivers/ide/ide-acpi.c b/drivers/ide/ide-acpi.c
index d9e1f7ccfe6f..b6940992a6ff 100644
--- a/drivers/ide/ide-acpi.c
+++ b/drivers/ide/ide-acpi.c
@@ -14,7 +14,6 @@
14#include <linux/errno.h> 14#include <linux/errno.h>
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/slab.h> 16#include <linux/slab.h>
17#include <acpi/acpi.h>
18#include <linux/ide.h> 17#include <linux/ide.h>
19#include <linux/pci.h> 18#include <linux/pci.h>
20#include <linux/dmi.h> 19#include <linux/dmi.h>
@@ -98,6 +97,17 @@ bool ide_port_acpi(ide_hwif_t *hwif)
98 return ide_noacpi == 0 && hwif->acpidata; 97 return ide_noacpi == 0 && hwif->acpidata;
99} 98}
100 99
100static acpi_handle acpi_get_child(acpi_handle handle, u64 addr)
101{
102 struct acpi_device *adev;
103
104 if (!handle || acpi_bus_get_device(handle, &adev))
105 return NULL;
106
107 adev = acpi_find_child_device(adev, addr, false);
108 return adev ? adev->handle : NULL;
109}
110
101/** 111/**
102 * ide_get_dev_handle - finds acpi_handle and PCI device.function 112 * ide_get_dev_handle - finds acpi_handle and PCI device.function
103 * @dev: device to locate 113 * @dev: device to locate
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_netlink.c b/drivers/infiniband/ulp/ipoib/ipoib_netlink.c
index c29b5c838833..cdc7df4fdb8a 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_netlink.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_netlink.c
@@ -31,6 +31,7 @@
31 */ 31 */
32 32
33#include <linux/netdevice.h> 33#include <linux/netdevice.h>
34#include <linux/if_arp.h> /* For ARPHRD_xxx */
34#include <linux/module.h> 35#include <linux/module.h>
35#include <net/rtnetlink.h> 36#include <net/rtnetlink.h>
36#include "ipoib.h" 37#include "ipoib.h"
@@ -103,7 +104,7 @@ static int ipoib_new_child_link(struct net *src_net, struct net_device *dev,
103 return -EINVAL; 104 return -EINVAL;
104 105
105 pdev = __dev_get_by_index(src_net, nla_get_u32(tb[IFLA_LINK])); 106 pdev = __dev_get_by_index(src_net, nla_get_u32(tb[IFLA_LINK]));
106 if (!pdev) 107 if (!pdev || pdev->type != ARPHRD_INFINIBAND)
107 return -ENODEV; 108 return -ENODEV;
108 109
109 ppriv = netdev_priv(pdev); 110 ppriv = netdev_priv(pdev);
diff --git a/drivers/input/misc/atlas_btns.c b/drivers/input/misc/atlas_btns.c
index 5d4402365a52..d781b5e52065 100644
--- a/drivers/input/misc/atlas_btns.c
+++ b/drivers/input/misc/atlas_btns.c
@@ -28,8 +28,8 @@
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/input.h> 29#include <linux/input.h>
30#include <linux/types.h> 30#include <linux/types.h>
31#include <linux/acpi.h>
31#include <asm/uaccess.h> 32#include <asm/uaccess.h>
32#include <acpi/acpi_drivers.h>
33 33
34#define ACPI_ATLAS_NAME "Atlas ACPI" 34#define ACPI_ATLAS_NAME "Atlas ACPI"
35#define ACPI_ATLAS_CLASS "Atlas" 35#define ACPI_ATLAS_CLASS "Atlas"
diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
index 8f798be6e398..28b4bea7c109 100644
--- a/drivers/iommu/amd_iommu_init.c
+++ b/drivers/iommu/amd_iommu_init.c
@@ -26,7 +26,6 @@
26#include <linux/msi.h> 26#include <linux/msi.h>
27#include <linux/amd-iommu.h> 27#include <linux/amd-iommu.h>
28#include <linux/export.h> 28#include <linux/export.h>
29#include <acpi/acpi.h>
30#include <asm/pci-direct.h> 29#include <asm/pci-direct.h>
31#include <asm/iommu.h> 30#include <asm/iommu.h>
32#include <asm/gart.h> 31#include <asm/gart.h>
diff --git a/drivers/iommu/intel_irq_remapping.c b/drivers/iommu/intel_irq_remapping.c
index bab10b1002fb..0cb7528b30a1 100644
--- a/drivers/iommu/intel_irq_remapping.c
+++ b/drivers/iommu/intel_irq_remapping.c
@@ -6,11 +6,11 @@
6#include <linux/hpet.h> 6#include <linux/hpet.h>
7#include <linux/pci.h> 7#include <linux/pci.h>
8#include <linux/irq.h> 8#include <linux/irq.h>
9#include <linux/intel-iommu.h>
10#include <linux/acpi.h>
9#include <asm/io_apic.h> 11#include <asm/io_apic.h>
10#include <asm/smp.h> 12#include <asm/smp.h>
11#include <asm/cpu.h> 13#include <asm/cpu.h>
12#include <linux/intel-iommu.h>
13#include <acpi/acpi.h>
14#include <asm/irq_remapping.h> 14#include <asm/irq_remapping.h>
15#include <asm/pci-direct.h> 15#include <asm/pci-direct.h>
16#include <asm/msidef.h> 16#include <asm/msidef.h>
diff --git a/drivers/isdn/hisax/hfc_pci.c b/drivers/isdn/hisax/hfc_pci.c
index 497bd026c237..4a4825528188 100644
--- a/drivers/isdn/hisax/hfc_pci.c
+++ b/drivers/isdn/hisax/hfc_pci.c
@@ -1643,10 +1643,6 @@ setup_hfcpci(struct IsdnCard *card)
1643 int i; 1643 int i;
1644 struct pci_dev *tmp_hfcpci = NULL; 1644 struct pci_dev *tmp_hfcpci = NULL;
1645 1645
1646#ifdef __BIG_ENDIAN
1647#error "not running on big endian machines now"
1648#endif
1649
1650 strcpy(tmp, hfcpci_revision); 1646 strcpy(tmp, hfcpci_revision);
1651 printk(KERN_INFO "HiSax: HFC-PCI driver Rev. %s\n", HiSax_getrev(tmp)); 1647 printk(KERN_INFO "HiSax: HFC-PCI driver Rev. %s\n", HiSax_getrev(tmp));
1652 1648
diff --git a/drivers/isdn/hisax/telespci.c b/drivers/isdn/hisax/telespci.c
index f6ab63aa6995..33eeb4602c7e 100644
--- a/drivers/isdn/hisax/telespci.c
+++ b/drivers/isdn/hisax/telespci.c
@@ -290,10 +290,6 @@ int setup_telespci(struct IsdnCard *card)
290 struct IsdnCardState *cs = card->cs; 290 struct IsdnCardState *cs = card->cs;
291 char tmp[64]; 291 char tmp[64];
292 292
293#ifdef __BIG_ENDIAN
294#error "not running on big endian machines now"
295#endif
296
297 strcpy(tmp, telespci_revision); 293 strcpy(tmp, telespci_revision);
298 printk(KERN_INFO "HiSax: Teles/PCI driver Rev. %s\n", HiSax_getrev(tmp)); 294 printk(KERN_INFO "HiSax: Teles/PCI driver Rev. %s\n", HiSax_getrev(tmp));
299 if (cs->typ != ISDN_CTYPE_TELESPCI) 295 if (cs->typ != ISDN_CTYPE_TELESPCI)
diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c
index 05188351711d..a97263e902ff 100644
--- a/drivers/leds/leds-lp5521.c
+++ b/drivers/leds/leds-lp5521.c
@@ -244,18 +244,12 @@ static int lp5521_update_program_memory(struct lp55xx_chip *chip,
244 if (i % 2) 244 if (i % 2)
245 goto err; 245 goto err;
246 246
247 mutex_lock(&chip->lock);
248
249 for (i = 0; i < LP5521_PROGRAM_LENGTH; i++) { 247 for (i = 0; i < LP5521_PROGRAM_LENGTH; i++) {
250 ret = lp55xx_write(chip, addr[idx] + i, pattern[i]); 248 ret = lp55xx_write(chip, addr[idx] + i, pattern[i]);
251 if (ret) { 249 if (ret)
252 mutex_unlock(&chip->lock);
253 return -EINVAL; 250 return -EINVAL;
254 }
255 } 251 }
256 252
257 mutex_unlock(&chip->lock);
258
259 return size; 253 return size;
260 254
261err: 255err:
@@ -427,15 +421,17 @@ static ssize_t store_engine_load(struct device *dev,
427{ 421{
428 struct lp55xx_led *led = i2c_get_clientdata(to_i2c_client(dev)); 422 struct lp55xx_led *led = i2c_get_clientdata(to_i2c_client(dev));
429 struct lp55xx_chip *chip = led->chip; 423 struct lp55xx_chip *chip = led->chip;
424 int ret;
430 425
431 mutex_lock(&chip->lock); 426 mutex_lock(&chip->lock);
432 427
433 chip->engine_idx = nr; 428 chip->engine_idx = nr;
434 lp5521_load_engine(chip); 429 lp5521_load_engine(chip);
430 ret = lp5521_update_program_memory(chip, buf, len);
435 431
436 mutex_unlock(&chip->lock); 432 mutex_unlock(&chip->lock);
437 433
438 return lp5521_update_program_memory(chip, buf, len); 434 return ret;
439} 435}
440store_load(1) 436store_load(1)
441store_load(2) 437store_load(2)
diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c
index 6b553d9f4266..fd9ab5f61441 100644
--- a/drivers/leds/leds-lp5523.c
+++ b/drivers/leds/leds-lp5523.c
@@ -337,18 +337,12 @@ static int lp5523_update_program_memory(struct lp55xx_chip *chip,
337 if (i % 2) 337 if (i % 2)
338 goto err; 338 goto err;
339 339
340 mutex_lock(&chip->lock);
341
342 for (i = 0; i < LP5523_PROGRAM_LENGTH; i++) { 340 for (i = 0; i < LP5523_PROGRAM_LENGTH; i++) {
343 ret = lp55xx_write(chip, LP5523_REG_PROG_MEM + i, pattern[i]); 341 ret = lp55xx_write(chip, LP5523_REG_PROG_MEM + i, pattern[i]);
344 if (ret) { 342 if (ret)
345 mutex_unlock(&chip->lock);
346 return -EINVAL; 343 return -EINVAL;
347 }
348 } 344 }
349 345
350 mutex_unlock(&chip->lock);
351
352 return size; 346 return size;
353 347
354err: 348err:
@@ -548,15 +542,17 @@ static ssize_t store_engine_load(struct device *dev,
548{ 542{
549 struct lp55xx_led *led = i2c_get_clientdata(to_i2c_client(dev)); 543 struct lp55xx_led *led = i2c_get_clientdata(to_i2c_client(dev));
550 struct lp55xx_chip *chip = led->chip; 544 struct lp55xx_chip *chip = led->chip;
545 int ret;
551 546
552 mutex_lock(&chip->lock); 547 mutex_lock(&chip->lock);
553 548
554 chip->engine_idx = nr; 549 chip->engine_idx = nr;
555 lp5523_load_engine_and_select_page(chip); 550 lp5523_load_engine_and_select_page(chip);
551 ret = lp5523_update_program_memory(chip, buf, len);
556 552
557 mutex_unlock(&chip->lock); 553 mutex_unlock(&chip->lock);
558 554
559 return lp5523_update_program_memory(chip, buf, len); 555 return ret;
560} 556}
561store_load(1) 557store_load(1)
562store_load(2) 558store_load(2)
diff --git a/drivers/mfd/rtsx_pcr.c b/drivers/mfd/rtsx_pcr.c
index 11e20afbdcac..705698fd2c7e 100644
--- a/drivers/mfd/rtsx_pcr.c
+++ b/drivers/mfd/rtsx_pcr.c
@@ -1228,8 +1228,14 @@ static void rtsx_pci_remove(struct pci_dev *pcidev)
1228 1228
1229 pcr->remove_pci = true; 1229 pcr->remove_pci = true;
1230 1230
1231 cancel_delayed_work(&pcr->carddet_work); 1231 /* Disable interrupts at the pcr level */
1232 cancel_delayed_work(&pcr->idle_work); 1232 spin_lock_irq(&pcr->lock);
1233 rtsx_pci_writel(pcr, RTSX_BIER, 0);
1234 pcr->bier = 0;
1235 spin_unlock_irq(&pcr->lock);
1236
1237 cancel_delayed_work_sync(&pcr->carddet_work);
1238 cancel_delayed_work_sync(&pcr->idle_work);
1233 1239
1234 mfd_remove_devices(&pcidev->dev); 1240 mfd_remove_devices(&pcidev->dev);
1235 1241
diff --git a/drivers/mmc/core/sdio_bus.c b/drivers/mmc/core/sdio_bus.c
index 157b570ba343..92d1ba8e8153 100644
--- a/drivers/mmc/core/sdio_bus.c
+++ b/drivers/mmc/core/sdio_bus.c
@@ -308,7 +308,7 @@ static void sdio_acpi_set_handle(struct sdio_func *func)
308 struct mmc_host *host = func->card->host; 308 struct mmc_host *host = func->card->host;
309 u64 addr = (host->slotno << 16) | func->num; 309 u64 addr = (host->slotno << 16) | func->num;
310 310
311 acpi_preset_companion(&func->dev, ACPI_HANDLE(host->parent), addr); 311 acpi_preset_companion(&func->dev, ACPI_COMPANION(host->parent), addr);
312} 312}
313#else 313#else
314static inline void sdio_acpi_set_handle(struct sdio_func *func) {} 314static inline void sdio_acpi_set_handle(struct sdio_func *func) {}
diff --git a/drivers/mtd/maps/pxa2xx-flash.c b/drivers/mtd/maps/pxa2xx-flash.c
index d210d131fef2..0f55589a56b8 100644
--- a/drivers/mtd/maps/pxa2xx-flash.c
+++ b/drivers/mtd/maps/pxa2xx-flash.c
@@ -73,7 +73,7 @@ static int pxa2xx_flash_probe(struct platform_device *pdev)
73 return -ENOMEM; 73 return -ENOMEM;
74 } 74 }
75 info->map.cached = 75 info->map.cached =
76 ioremap_cached(info->map.phys, info->map.size); 76 ioremap_cache(info->map.phys, info->map.size);
77 if (!info->map.cached) 77 if (!info->map.cached)
78 printk(KERN_WARNING "Failed to ioremap cached %s\n", 78 printk(KERN_WARNING "Failed to ioremap cached %s\n",
79 info->map.name); 79 info->map.name);
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 398e299ee1bd..4b8c58b0ec24 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -3732,7 +3732,8 @@ static inline int bond_slave_override(struct bonding *bond,
3732} 3732}
3733 3733
3734 3734
3735static u16 bond_select_queue(struct net_device *dev, struct sk_buff *skb) 3735static u16 bond_select_queue(struct net_device *dev, struct sk_buff *skb,
3736 void *accel_priv)
3736{ 3737{
3737 /* 3738 /*
3738 * This helper function exists to help dev_pick_tx get the correct 3739 * This helper function exists to help dev_pick_tx get the correct
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
index a1f66e2c9a86..ec6119089b82 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
@@ -520,10 +520,12 @@ struct bnx2x_fastpath {
520#define BNX2X_FP_STATE_IDLE 0 520#define BNX2X_FP_STATE_IDLE 0
521#define BNX2X_FP_STATE_NAPI (1 << 0) /* NAPI owns this FP */ 521#define BNX2X_FP_STATE_NAPI (1 << 0) /* NAPI owns this FP */
522#define BNX2X_FP_STATE_POLL (1 << 1) /* poll owns this FP */ 522#define BNX2X_FP_STATE_POLL (1 << 1) /* poll owns this FP */
523#define BNX2X_FP_STATE_NAPI_YIELD (1 << 2) /* NAPI yielded this FP */ 523#define BNX2X_FP_STATE_DISABLED (1 << 2)
524#define BNX2X_FP_STATE_POLL_YIELD (1 << 3) /* poll yielded this FP */ 524#define BNX2X_FP_STATE_NAPI_YIELD (1 << 3) /* NAPI yielded this FP */
525#define BNX2X_FP_STATE_POLL_YIELD (1 << 4) /* poll yielded this FP */
526#define BNX2X_FP_OWNED (BNX2X_FP_STATE_NAPI | BNX2X_FP_STATE_POLL)
525#define BNX2X_FP_YIELD (BNX2X_FP_STATE_NAPI_YIELD | BNX2X_FP_STATE_POLL_YIELD) 527#define BNX2X_FP_YIELD (BNX2X_FP_STATE_NAPI_YIELD | BNX2X_FP_STATE_POLL_YIELD)
526#define BNX2X_FP_LOCKED (BNX2X_FP_STATE_NAPI | BNX2X_FP_STATE_POLL) 528#define BNX2X_FP_LOCKED (BNX2X_FP_OWNED | BNX2X_FP_STATE_DISABLED)
527#define BNX2X_FP_USER_PEND (BNX2X_FP_STATE_POLL | BNX2X_FP_STATE_POLL_YIELD) 529#define BNX2X_FP_USER_PEND (BNX2X_FP_STATE_POLL | BNX2X_FP_STATE_POLL_YIELD)
528 /* protect state */ 530 /* protect state */
529 spinlock_t lock; 531 spinlock_t lock;
@@ -613,7 +615,7 @@ static inline bool bnx2x_fp_lock_napi(struct bnx2x_fastpath *fp)
613{ 615{
614 bool rc = true; 616 bool rc = true;
615 617
616 spin_lock(&fp->lock); 618 spin_lock_bh(&fp->lock);
617 if (fp->state & BNX2X_FP_LOCKED) { 619 if (fp->state & BNX2X_FP_LOCKED) {
618 WARN_ON(fp->state & BNX2X_FP_STATE_NAPI); 620 WARN_ON(fp->state & BNX2X_FP_STATE_NAPI);
619 fp->state |= BNX2X_FP_STATE_NAPI_YIELD; 621 fp->state |= BNX2X_FP_STATE_NAPI_YIELD;
@@ -622,7 +624,7 @@ static inline bool bnx2x_fp_lock_napi(struct bnx2x_fastpath *fp)
622 /* we don't care if someone yielded */ 624 /* we don't care if someone yielded */
623 fp->state = BNX2X_FP_STATE_NAPI; 625 fp->state = BNX2X_FP_STATE_NAPI;
624 } 626 }
625 spin_unlock(&fp->lock); 627 spin_unlock_bh(&fp->lock);
626 return rc; 628 return rc;
627} 629}
628 630
@@ -631,14 +633,16 @@ static inline bool bnx2x_fp_unlock_napi(struct bnx2x_fastpath *fp)
631{ 633{
632 bool rc = false; 634 bool rc = false;
633 635
634 spin_lock(&fp->lock); 636 spin_lock_bh(&fp->lock);
635 WARN_ON(fp->state & 637 WARN_ON(fp->state &
636 (BNX2X_FP_STATE_POLL | BNX2X_FP_STATE_NAPI_YIELD)); 638 (BNX2X_FP_STATE_POLL | BNX2X_FP_STATE_NAPI_YIELD));
637 639
638 if (fp->state & BNX2X_FP_STATE_POLL_YIELD) 640 if (fp->state & BNX2X_FP_STATE_POLL_YIELD)
639 rc = true; 641 rc = true;
640 fp->state = BNX2X_FP_STATE_IDLE; 642
641 spin_unlock(&fp->lock); 643 /* state ==> idle, unless currently disabled */
644 fp->state &= BNX2X_FP_STATE_DISABLED;
645 spin_unlock_bh(&fp->lock);
642 return rc; 646 return rc;
643} 647}
644 648
@@ -669,7 +673,9 @@ static inline bool bnx2x_fp_unlock_poll(struct bnx2x_fastpath *fp)
669 673
670 if (fp->state & BNX2X_FP_STATE_POLL_YIELD) 674 if (fp->state & BNX2X_FP_STATE_POLL_YIELD)
671 rc = true; 675 rc = true;
672 fp->state = BNX2X_FP_STATE_IDLE; 676
677 /* state ==> idle, unless currently disabled */
678 fp->state &= BNX2X_FP_STATE_DISABLED;
673 spin_unlock_bh(&fp->lock); 679 spin_unlock_bh(&fp->lock);
674 return rc; 680 return rc;
675} 681}
@@ -677,9 +683,23 @@ static inline bool bnx2x_fp_unlock_poll(struct bnx2x_fastpath *fp)
677/* true if a socket is polling, even if it did not get the lock */ 683/* true if a socket is polling, even if it did not get the lock */
678static inline bool bnx2x_fp_ll_polling(struct bnx2x_fastpath *fp) 684static inline bool bnx2x_fp_ll_polling(struct bnx2x_fastpath *fp)
679{ 685{
680 WARN_ON(!(fp->state & BNX2X_FP_LOCKED)); 686 WARN_ON(!(fp->state & BNX2X_FP_OWNED));
681 return fp->state & BNX2X_FP_USER_PEND; 687 return fp->state & BNX2X_FP_USER_PEND;
682} 688}
689
690/* false if fp is currently owned */
691static inline bool bnx2x_fp_ll_disable(struct bnx2x_fastpath *fp)
692{
693 int rc = true;
694
695 spin_lock_bh(&fp->lock);
696 if (fp->state & BNX2X_FP_OWNED)
697 rc = false;
698 fp->state |= BNX2X_FP_STATE_DISABLED;
699 spin_unlock_bh(&fp->lock);
700
701 return rc;
702}
683#else 703#else
684static inline void bnx2x_fp_init_lock(struct bnx2x_fastpath *fp) 704static inline void bnx2x_fp_init_lock(struct bnx2x_fastpath *fp)
685{ 705{
@@ -709,6 +729,10 @@ static inline bool bnx2x_fp_ll_polling(struct bnx2x_fastpath *fp)
709{ 729{
710 return false; 730 return false;
711} 731}
732static inline bool bnx2x_fp_ll_disable(struct bnx2x_fastpath *fp)
733{
734 return true;
735}
712#endif /* CONFIG_NET_RX_BUSY_POLL */ 736#endif /* CONFIG_NET_RX_BUSY_POLL */
713 737
714/* Use 2500 as a mini-jumbo MTU for FCoE */ 738/* Use 2500 as a mini-jumbo MTU for FCoE */
@@ -1250,7 +1274,10 @@ struct bnx2x_slowpath {
1250 * Therefore, if they would have been defined in the same union, 1274 * Therefore, if they would have been defined in the same union,
1251 * data can get corrupted. 1275 * data can get corrupted.
1252 */ 1276 */
1253 struct afex_vif_list_ramrod_data func_afex_rdata; 1277 union {
1278 struct afex_vif_list_ramrod_data viflist_data;
1279 struct function_update_data func_update;
1280 } func_afex_rdata;
1254 1281
1255 /* used by dmae command executer */ 1282 /* used by dmae command executer */
1256 struct dmae_command dmae[MAX_DMAE_C]; 1283 struct dmae_command dmae[MAX_DMAE_C];
@@ -2499,4 +2526,6 @@ void bnx2x_set_local_cmng(struct bnx2x *bp);
2499#define MCPR_SCRATCH_BASE(bp) \ 2526#define MCPR_SCRATCH_BASE(bp) \
2500 (CHIP_IS_E1x(bp) ? MCP_REG_MCPR_SCRATCH : MCP_A_REG_MCPR_SCRATCH) 2527 (CHIP_IS_E1x(bp) ? MCP_REG_MCPR_SCRATCH : MCP_A_REG_MCPR_SCRATCH)
2501 2528
2529#define E1H_MAX_MF_SB_COUNT (HC_SB_MAX_SB_E1X/(E1HVN_MAX * PORT_MAX))
2530
2502#endif /* bnx2x.h */ 2531#endif /* bnx2x.h */
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index ec96130533cc..bf811565ee24 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -160,6 +160,7 @@ static u16 bnx2x_free_tx_pkt(struct bnx2x *bp, struct bnx2x_fp_txdata *txdata,
160 struct sk_buff *skb = tx_buf->skb; 160 struct sk_buff *skb = tx_buf->skb;
161 u16 bd_idx = TX_BD(tx_buf->first_bd), new_cons; 161 u16 bd_idx = TX_BD(tx_buf->first_bd), new_cons;
162 int nbd; 162 int nbd;
163 u16 split_bd_len = 0;
163 164
164 /* prefetch skb end pointer to speedup dev_kfree_skb() */ 165 /* prefetch skb end pointer to speedup dev_kfree_skb() */
165 prefetch(&skb->end); 166 prefetch(&skb->end);
@@ -167,10 +168,7 @@ static u16 bnx2x_free_tx_pkt(struct bnx2x *bp, struct bnx2x_fp_txdata *txdata,
167 DP(NETIF_MSG_TX_DONE, "fp[%d]: pkt_idx %d buff @(%p)->skb %p\n", 168 DP(NETIF_MSG_TX_DONE, "fp[%d]: pkt_idx %d buff @(%p)->skb %p\n",
168 txdata->txq_index, idx, tx_buf, skb); 169 txdata->txq_index, idx, tx_buf, skb);
169 170
170 /* unmap first bd */
171 tx_start_bd = &txdata->tx_desc_ring[bd_idx].start_bd; 171 tx_start_bd = &txdata->tx_desc_ring[bd_idx].start_bd;
172 dma_unmap_single(&bp->pdev->dev, BD_UNMAP_ADDR(tx_start_bd),
173 BD_UNMAP_LEN(tx_start_bd), DMA_TO_DEVICE);
174 172
175 nbd = le16_to_cpu(tx_start_bd->nbd) - 1; 173 nbd = le16_to_cpu(tx_start_bd->nbd) - 1;
176#ifdef BNX2X_STOP_ON_ERROR 174#ifdef BNX2X_STOP_ON_ERROR
@@ -188,12 +186,19 @@ static u16 bnx2x_free_tx_pkt(struct bnx2x *bp, struct bnx2x_fp_txdata *txdata,
188 --nbd; 186 --nbd;
189 bd_idx = TX_BD(NEXT_TX_IDX(bd_idx)); 187 bd_idx = TX_BD(NEXT_TX_IDX(bd_idx));
190 188
191 /* ...and the TSO split header bd since they have no mapping */ 189 /* TSO headers+data bds share a common mapping. See bnx2x_tx_split() */
192 if (tx_buf->flags & BNX2X_TSO_SPLIT_BD) { 190 if (tx_buf->flags & BNX2X_TSO_SPLIT_BD) {
191 tx_data_bd = &txdata->tx_desc_ring[bd_idx].reg_bd;
192 split_bd_len = BD_UNMAP_LEN(tx_data_bd);
193 --nbd; 193 --nbd;
194 bd_idx = TX_BD(NEXT_TX_IDX(bd_idx)); 194 bd_idx = TX_BD(NEXT_TX_IDX(bd_idx));
195 } 195 }
196 196
197 /* unmap first bd */
198 dma_unmap_single(&bp->pdev->dev, BD_UNMAP_ADDR(tx_start_bd),
199 BD_UNMAP_LEN(tx_start_bd) + split_bd_len,
200 DMA_TO_DEVICE);
201
197 /* now free frags */ 202 /* now free frags */
198 while (nbd > 0) { 203 while (nbd > 0) {
199 204
@@ -1790,26 +1795,22 @@ static void bnx2x_napi_disable_cnic(struct bnx2x *bp)
1790{ 1795{
1791 int i; 1796 int i;
1792 1797
1793 local_bh_disable();
1794 for_each_rx_queue_cnic(bp, i) { 1798 for_each_rx_queue_cnic(bp, i) {
1795 napi_disable(&bnx2x_fp(bp, i, napi)); 1799 napi_disable(&bnx2x_fp(bp, i, napi));
1796 while (!bnx2x_fp_lock_napi(&bp->fp[i])) 1800 while (!bnx2x_fp_ll_disable(&bp->fp[i]))
1797 mdelay(1); 1801 usleep_range(1000, 2000);
1798 } 1802 }
1799 local_bh_enable();
1800} 1803}
1801 1804
1802static void bnx2x_napi_disable(struct bnx2x *bp) 1805static void bnx2x_napi_disable(struct bnx2x *bp)
1803{ 1806{
1804 int i; 1807 int i;
1805 1808
1806 local_bh_disable();
1807 for_each_eth_queue(bp, i) { 1809 for_each_eth_queue(bp, i) {
1808 napi_disable(&bnx2x_fp(bp, i, napi)); 1810 napi_disable(&bnx2x_fp(bp, i, napi));
1809 while (!bnx2x_fp_lock_napi(&bp->fp[i])) 1811 while (!bnx2x_fp_ll_disable(&bp->fp[i]))
1810 mdelay(1); 1812 usleep_range(1000, 2000);
1811 } 1813 }
1812 local_bh_enable();
1813} 1814}
1814 1815
1815void bnx2x_netif_start(struct bnx2x *bp) 1816void bnx2x_netif_start(struct bnx2x *bp)
@@ -1832,7 +1833,8 @@ void bnx2x_netif_stop(struct bnx2x *bp, int disable_hw)
1832 bnx2x_napi_disable_cnic(bp); 1833 bnx2x_napi_disable_cnic(bp);
1833} 1834}
1834 1835
1835u16 bnx2x_select_queue(struct net_device *dev, struct sk_buff *skb) 1836u16 bnx2x_select_queue(struct net_device *dev, struct sk_buff *skb,
1837 void *accel_priv)
1836{ 1838{
1837 struct bnx2x *bp = netdev_priv(dev); 1839 struct bnx2x *bp = netdev_priv(dev);
1838 1840
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
index da8fcaa74495..41f3ca5ad972 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
@@ -524,7 +524,8 @@ int bnx2x_set_vf_mac(struct net_device *dev, int queue, u8 *mac);
524int bnx2x_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, u8 qos); 524int bnx2x_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, u8 qos);
525 525
526/* select_queue callback */ 526/* select_queue callback */
527u16 bnx2x_select_queue(struct net_device *dev, struct sk_buff *skb); 527u16 bnx2x_select_queue(struct net_device *dev, struct sk_buff *skb,
528 void *accel_priv);
528 529
529static inline void bnx2x_update_rx_prod(struct bnx2x *bp, 530static inline void bnx2x_update_rx_prod(struct bnx2x *bp,
530 struct bnx2x_fastpath *fp, 531 struct bnx2x_fastpath *fp,
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c
index 20dcc02431ca..11fc79585491 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c
@@ -3865,6 +3865,19 @@ static void bnx2x_warpcore_enable_AN_KR(struct bnx2x_phy *phy,
3865 3865
3866 bnx2x_warpcore_enable_AN_KR2(phy, params, vars); 3866 bnx2x_warpcore_enable_AN_KR2(phy, params, vars);
3867 } else { 3867 } else {
3868 /* Enable Auto-Detect to support 1G over CL37 as well */
3869 bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD,
3870 MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X1, 0x10);
3871
3872 /* Force cl48 sync_status LOW to avoid getting stuck in CL73
3873 * parallel-detect loop when CL73 and CL37 are enabled.
3874 */
3875 CL22_WR_OVER_CL45(bp, phy, MDIO_REG_BANK_AER_BLOCK,
3876 MDIO_AER_BLOCK_AER_REG, 0);
3877 bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD,
3878 MDIO_WC_REG_RXB_ANA_RX_CONTROL_PCI, 0x0800);
3879 bnx2x_set_aer_mmd(params, phy);
3880
3868 bnx2x_disable_kr2(params, vars, phy); 3881 bnx2x_disable_kr2(params, vars, phy);
3869 } 3882 }
3870 3883
@@ -8120,17 +8133,20 @@ static int bnx2x_get_edc_mode(struct bnx2x_phy *phy,
8120 *edc_mode = EDC_MODE_ACTIVE_DAC; 8133 *edc_mode = EDC_MODE_ACTIVE_DAC;
8121 else 8134 else
8122 check_limiting_mode = 1; 8135 check_limiting_mode = 1;
8123 } else if (copper_module_type & 8136 } else {
8124 SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_PASSIVE) { 8137 *edc_mode = EDC_MODE_PASSIVE_DAC;
8138 /* Even in case PASSIVE_DAC indication is not set,
8139 * treat it as a passive DAC cable, since some cables
8140 * don't have this indication.
8141 */
8142 if (copper_module_type &
8143 SFP_EEPROM_FC_TX_TECH_BITMASK_COPPER_PASSIVE) {
8125 DP(NETIF_MSG_LINK, 8144 DP(NETIF_MSG_LINK,
8126 "Passive Copper cable detected\n"); 8145 "Passive Copper cable detected\n");
8127 *edc_mode = 8146 } else {
8128 EDC_MODE_PASSIVE_DAC; 8147 DP(NETIF_MSG_LINK,
8129 } else { 8148 "Unknown copper-cable-type\n");
8130 DP(NETIF_MSG_LINK, 8149 }
8131 "Unknown copper-cable-type 0x%x !!!\n",
8132 copper_module_type);
8133 return -EINVAL;
8134 } 8150 }
8135 break; 8151 break;
8136 } 8152 }
@@ -10825,9 +10841,9 @@ static int bnx2x_54618se_config_init(struct bnx2x_phy *phy,
10825 (1<<11)); 10841 (1<<11));
10826 10842
10827 if (((phy->req_line_speed == SPEED_AUTO_NEG) && 10843 if (((phy->req_line_speed == SPEED_AUTO_NEG) &&
10828 (phy->speed_cap_mask & 10844 (phy->speed_cap_mask &
10829 PORT_HW_CFG_SPEED_CAPABILITY_D0_1G)) || 10845 PORT_HW_CFG_SPEED_CAPABILITY_D0_1G)) ||
10830 (phy->req_line_speed == SPEED_1000)) { 10846 (phy->req_line_speed == SPEED_1000)) {
10831 an_1000_val |= (1<<8); 10847 an_1000_val |= (1<<8);
10832 autoneg_val |= (1<<9 | 1<<12); 10848 autoneg_val |= (1<<9 | 1<<12);
10833 if (phy->req_duplex == DUPLEX_FULL) 10849 if (phy->req_duplex == DUPLEX_FULL)
@@ -10843,30 +10859,32 @@ static int bnx2x_54618se_config_init(struct bnx2x_phy *phy,
10843 0x09, 10859 0x09,
10844 &an_1000_val); 10860 &an_1000_val);
10845 10861
10846 /* Set 100 speed advertisement */ 10862 /* Advertise 10/100 link speed */
10847 if (((phy->req_line_speed == SPEED_AUTO_NEG) && 10863 if (phy->req_line_speed == SPEED_AUTO_NEG) {
10848 (phy->speed_cap_mask & 10864 if (phy->speed_cap_mask &
10849 (PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_FULL | 10865 PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_HALF) {
10850 PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_HALF)))) { 10866 an_10_100_val |= (1<<5);
10851 an_10_100_val |= (1<<7); 10867 autoneg_val |= (1<<9 | 1<<12);
10852 /* Enable autoneg and restart autoneg for legacy speeds */ 10868 DP(NETIF_MSG_LINK, "Advertising 10M-HD\n");
10853 autoneg_val |= (1<<9 | 1<<12); 10869 }
10854 10870 if (phy->speed_cap_mask &
10855 if (phy->req_duplex == DUPLEX_FULL) 10871 PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_FULL) {
10856 an_10_100_val |= (1<<8);
10857 DP(NETIF_MSG_LINK, "Advertising 100M\n");
10858 }
10859
10860 /* Set 10 speed advertisement */
10861 if (((phy->req_line_speed == SPEED_AUTO_NEG) &&
10862 (phy->speed_cap_mask &
10863 (PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_FULL |
10864 PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_HALF)))) {
10865 an_10_100_val |= (1<<5);
10866 autoneg_val |= (1<<9 | 1<<12);
10867 if (phy->req_duplex == DUPLEX_FULL)
10868 an_10_100_val |= (1<<6); 10872 an_10_100_val |= (1<<6);
10869 DP(NETIF_MSG_LINK, "Advertising 10M\n"); 10873 autoneg_val |= (1<<9 | 1<<12);
10874 DP(NETIF_MSG_LINK, "Advertising 10M-FD\n");
10875 }
10876 if (phy->speed_cap_mask &
10877 PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_HALF) {
10878 an_10_100_val |= (1<<7);
10879 autoneg_val |= (1<<9 | 1<<12);
10880 DP(NETIF_MSG_LINK, "Advertising 100M-HD\n");
10881 }
10882 if (phy->speed_cap_mask &
10883 PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_FULL) {
10884 an_10_100_val |= (1<<8);
10885 autoneg_val |= (1<<9 | 1<<12);
10886 DP(NETIF_MSG_LINK, "Advertising 100M-FD\n");
10887 }
10870 } 10888 }
10871 10889
10872 /* Only 10/100 are allowed to work in FORCE mode */ 10890 /* Only 10/100 are allowed to work in FORCE mode */
@@ -13342,6 +13360,10 @@ static u8 bnx2x_analyze_link_error(struct link_params *params,
13342 DP(NETIF_MSG_LINK, "Link changed:[%x %x]->%x\n", vars->link_up, 13360 DP(NETIF_MSG_LINK, "Link changed:[%x %x]->%x\n", vars->link_up,
13343 old_status, status); 13361 old_status, status);
13344 13362
13363 /* Do not touch the link in case physical link down */
13364 if ((vars->phy_flags & PHY_PHYSICAL_LINK_FLAG) == 0)
13365 return 1;
13366
13345 /* a. Update shmem->link_status accordingly 13367 /* a. Update shmem->link_status accordingly
13346 * b. Update link_vars->link_up 13368 * b. Update link_vars->link_up
13347 */ 13369 */
@@ -13550,7 +13572,7 @@ static void bnx2x_check_kr2_wa(struct link_params *params,
13550 */ 13572 */
13551 not_kr2_device = (((base_page & 0x8000) == 0) || 13573 not_kr2_device = (((base_page & 0x8000) == 0) ||
13552 (((base_page & 0x8000) && 13574 (((base_page & 0x8000) &&
13553 ((next_page & 0xe0) == 0x2)))); 13575 ((next_page & 0xe0) == 0x20))));
13554 13576
13555 /* In case KR2 is already disabled, check if we need to re-enable it */ 13577 /* In case KR2 is already disabled, check if we need to re-enable it */
13556 if (!(vars->link_attr_sync & LINK_ATTR_SYNC_KR2_ENABLE)) { 13578 if (!(vars->link_attr_sync & LINK_ATTR_SYNC_KR2_ENABLE)) {
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 814d0eca9b33..8b3107b2fcc1 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -11447,9 +11447,9 @@ static int bnx2x_get_hwinfo(struct bnx2x *bp)
11447 } 11447 }
11448 } 11448 }
11449 11449
11450 /* adjust igu_sb_cnt to MF for E1x */ 11450 /* adjust igu_sb_cnt to MF for E1H */
11451 if (CHIP_IS_E1x(bp) && IS_MF(bp)) 11451 if (CHIP_IS_E1H(bp) && IS_MF(bp))
11452 bp->igu_sb_cnt /= E1HVN_MAX; 11452 bp->igu_sb_cnt = min_t(u8, bp->igu_sb_cnt, E1H_MAX_MF_SB_COUNT);
11453 11453
11454 /* port info */ 11454 /* port info */
11455 bnx2x_get_port_hwinfo(bp); 11455 bnx2x_get_port_hwinfo(bp);
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h
index 3efbb35267c8..14ffb6e56e59 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h
@@ -7179,6 +7179,7 @@ Theotherbitsarereservedandshouldbezero*/
7179#define MDIO_WC_REG_RX1_PCI_CTRL 0x80ca 7179#define MDIO_WC_REG_RX1_PCI_CTRL 0x80ca
7180#define MDIO_WC_REG_RX2_PCI_CTRL 0x80da 7180#define MDIO_WC_REG_RX2_PCI_CTRL 0x80da
7181#define MDIO_WC_REG_RX3_PCI_CTRL 0x80ea 7181#define MDIO_WC_REG_RX3_PCI_CTRL 0x80ea
7182#define MDIO_WC_REG_RXB_ANA_RX_CONTROL_PCI 0x80fa
7182#define MDIO_WC_REG_XGXSBLK2_UNICORE_MODE_10G 0x8104 7183#define MDIO_WC_REG_XGXSBLK2_UNICORE_MODE_10G 0x8104
7183#define MDIO_WC_REG_XGXS_STATUS3 0x8129 7184#define MDIO_WC_REG_XGXS_STATUS3 0x8129
7184#define MDIO_WC_REG_PAR_DET_10G_STATUS 0x8130 7185#define MDIO_WC_REG_PAR_DET_10G_STATUS 0x8130
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
index 32c92abf5094..18438a504d57 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
@@ -2038,6 +2038,7 @@ static int bnx2x_vlan_mac_del_all(struct bnx2x *bp,
2038 struct bnx2x_vlan_mac_ramrod_params p; 2038 struct bnx2x_vlan_mac_ramrod_params p;
2039 struct bnx2x_exe_queue_obj *exeq = &o->exe_queue; 2039 struct bnx2x_exe_queue_obj *exeq = &o->exe_queue;
2040 struct bnx2x_exeq_elem *exeq_pos, *exeq_pos_n; 2040 struct bnx2x_exeq_elem *exeq_pos, *exeq_pos_n;
2041 unsigned long flags;
2041 int read_lock; 2042 int read_lock;
2042 int rc = 0; 2043 int rc = 0;
2043 2044
@@ -2046,8 +2047,9 @@ static int bnx2x_vlan_mac_del_all(struct bnx2x *bp,
2046 spin_lock_bh(&exeq->lock); 2047 spin_lock_bh(&exeq->lock);
2047 2048
2048 list_for_each_entry_safe(exeq_pos, exeq_pos_n, &exeq->exe_queue, link) { 2049 list_for_each_entry_safe(exeq_pos, exeq_pos_n, &exeq->exe_queue, link) {
2049 if (exeq_pos->cmd_data.vlan_mac.vlan_mac_flags == 2050 flags = exeq_pos->cmd_data.vlan_mac.vlan_mac_flags;
2050 *vlan_mac_flags) { 2051 if (BNX2X_VLAN_MAC_CMP_FLAGS(flags) ==
2052 BNX2X_VLAN_MAC_CMP_FLAGS(*vlan_mac_flags)) {
2051 rc = exeq->remove(bp, exeq->owner, exeq_pos); 2053 rc = exeq->remove(bp, exeq->owner, exeq_pos);
2052 if (rc) { 2054 if (rc) {
2053 BNX2X_ERR("Failed to remove command\n"); 2055 BNX2X_ERR("Failed to remove command\n");
@@ -2080,7 +2082,9 @@ static int bnx2x_vlan_mac_del_all(struct bnx2x *bp,
2080 return read_lock; 2082 return read_lock;
2081 2083
2082 list_for_each_entry(pos, &o->head, link) { 2084 list_for_each_entry(pos, &o->head, link) {
2083 if (pos->vlan_mac_flags == *vlan_mac_flags) { 2085 flags = pos->vlan_mac_flags;
2086 if (BNX2X_VLAN_MAC_CMP_FLAGS(flags) ==
2087 BNX2X_VLAN_MAC_CMP_FLAGS(*vlan_mac_flags)) {
2084 p.user_req.vlan_mac_flags = pos->vlan_mac_flags; 2088 p.user_req.vlan_mac_flags = pos->vlan_mac_flags;
2085 memcpy(&p.user_req.u, &pos->u, sizeof(pos->u)); 2089 memcpy(&p.user_req.u, &pos->u, sizeof(pos->u));
2086 rc = bnx2x_config_vlan_mac(bp, &p); 2090 rc = bnx2x_config_vlan_mac(bp, &p);
@@ -4382,8 +4386,11 @@ int bnx2x_config_rss(struct bnx2x *bp,
4382 struct bnx2x_raw_obj *r = &o->raw; 4386 struct bnx2x_raw_obj *r = &o->raw;
4383 4387
4384 /* Do nothing if only driver cleanup was requested */ 4388 /* Do nothing if only driver cleanup was requested */
4385 if (test_bit(RAMROD_DRV_CLR_ONLY, &p->ramrod_flags)) 4389 if (test_bit(RAMROD_DRV_CLR_ONLY, &p->ramrod_flags)) {
4390 DP(BNX2X_MSG_SP, "Not configuring RSS ramrod_flags=%lx\n",
4391 p->ramrod_flags);
4386 return 0; 4392 return 0;
4393 }
4387 4394
4388 r->set_pending(r); 4395 r->set_pending(r);
4389 4396
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
index 658f4e33abf9..6a53c15c85a3 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
@@ -266,6 +266,13 @@ enum {
266 BNX2X_DONT_CONSUME_CAM_CREDIT, 266 BNX2X_DONT_CONSUME_CAM_CREDIT,
267 BNX2X_DONT_CONSUME_CAM_CREDIT_DEST, 267 BNX2X_DONT_CONSUME_CAM_CREDIT_DEST,
268}; 268};
269/* When looking for matching filters, some flags are not interesting */
270#define BNX2X_VLAN_MAC_CMP_MASK (1 << BNX2X_UC_LIST_MAC | \
271 1 << BNX2X_ETH_MAC | \
272 1 << BNX2X_ISCSI_ETH_MAC | \
273 1 << BNX2X_NETQ_ETH_MAC)
274#define BNX2X_VLAN_MAC_CMP_FLAGS(flags) \
275 ((flags) & BNX2X_VLAN_MAC_CMP_MASK)
269 276
270struct bnx2x_vlan_mac_ramrod_params { 277struct bnx2x_vlan_mac_ramrod_params {
271 /* Object to run the command from */ 278 /* Object to run the command from */
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
index 2e46c28fc601..e7845e5be1c7 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
@@ -1209,6 +1209,11 @@ static void bnx2x_vfop_rxmode(struct bnx2x *bp, struct bnx2x_virtf *vf)
1209 /* next state */ 1209 /* next state */
1210 vfop->state = BNX2X_VFOP_RXMODE_DONE; 1210 vfop->state = BNX2X_VFOP_RXMODE_DONE;
1211 1211
1212 /* record the accept flags in vfdb so hypervisor can modify them
1213 * if necessary
1214 */
1215 bnx2x_vfq(vf, ramrod->cl_id - vf->igu_base_id, accept_flags) =
1216 ramrod->rx_accept_flags;
1212 vfop->rc = bnx2x_config_rx_mode(bp, ramrod); 1217 vfop->rc = bnx2x_config_rx_mode(bp, ramrod);
1213 bnx2x_vfop_finalize(vf, vfop->rc, VFOP_DONE); 1218 bnx2x_vfop_finalize(vf, vfop->rc, VFOP_DONE);
1214op_err: 1219op_err:
@@ -1224,39 +1229,43 @@ op_pending:
1224 return; 1229 return;
1225} 1230}
1226 1231
1232static void bnx2x_vf_prep_rx_mode(struct bnx2x *bp, u8 qid,
1233 struct bnx2x_rx_mode_ramrod_params *ramrod,
1234 struct bnx2x_virtf *vf,
1235 unsigned long accept_flags)
1236{
1237 struct bnx2x_vf_queue *vfq = vfq_get(vf, qid);
1238
1239 memset(ramrod, 0, sizeof(*ramrod));
1240 ramrod->cid = vfq->cid;
1241 ramrod->cl_id = vfq_cl_id(vf, vfq);
1242 ramrod->rx_mode_obj = &bp->rx_mode_obj;
1243 ramrod->func_id = FW_VF_HANDLE(vf->abs_vfid);
1244 ramrod->rx_accept_flags = accept_flags;
1245 ramrod->tx_accept_flags = accept_flags;
1246 ramrod->pstate = &vf->filter_state;
1247 ramrod->state = BNX2X_FILTER_RX_MODE_PENDING;
1248
1249 set_bit(BNX2X_FILTER_RX_MODE_PENDING, &vf->filter_state);
1250 set_bit(RAMROD_RX, &ramrod->ramrod_flags);
1251 set_bit(RAMROD_TX, &ramrod->ramrod_flags);
1252
1253 ramrod->rdata = bnx2x_vf_sp(bp, vf, rx_mode_rdata.e2);
1254 ramrod->rdata_mapping = bnx2x_vf_sp_map(bp, vf, rx_mode_rdata.e2);
1255}
1256
1227int bnx2x_vfop_rxmode_cmd(struct bnx2x *bp, 1257int bnx2x_vfop_rxmode_cmd(struct bnx2x *bp,
1228 struct bnx2x_virtf *vf, 1258 struct bnx2x_virtf *vf,
1229 struct bnx2x_vfop_cmd *cmd, 1259 struct bnx2x_vfop_cmd *cmd,
1230 int qid, unsigned long accept_flags) 1260 int qid, unsigned long accept_flags)
1231{ 1261{
1232 struct bnx2x_vf_queue *vfq = vfq_get(vf, qid);
1233 struct bnx2x_vfop *vfop = bnx2x_vfop_add(bp, vf); 1262 struct bnx2x_vfop *vfop = bnx2x_vfop_add(bp, vf);
1234 1263
1235 if (vfop) { 1264 if (vfop) {
1236 struct bnx2x_rx_mode_ramrod_params *ramrod = 1265 struct bnx2x_rx_mode_ramrod_params *ramrod =
1237 &vf->op_params.rx_mode; 1266 &vf->op_params.rx_mode;
1238 1267
1239 memset(ramrod, 0, sizeof(*ramrod)); 1268 bnx2x_vf_prep_rx_mode(bp, qid, ramrod, vf, accept_flags);
1240
1241 /* Prepare ramrod parameters */
1242 ramrod->cid = vfq->cid;
1243 ramrod->cl_id = vfq_cl_id(vf, vfq);
1244 ramrod->rx_mode_obj = &bp->rx_mode_obj;
1245 ramrod->func_id = FW_VF_HANDLE(vf->abs_vfid);
1246
1247 ramrod->rx_accept_flags = accept_flags;
1248 ramrod->tx_accept_flags = accept_flags;
1249 ramrod->pstate = &vf->filter_state;
1250 ramrod->state = BNX2X_FILTER_RX_MODE_PENDING;
1251
1252 set_bit(BNX2X_FILTER_RX_MODE_PENDING, &vf->filter_state);
1253 set_bit(RAMROD_RX, &ramrod->ramrod_flags);
1254 set_bit(RAMROD_TX, &ramrod->ramrod_flags);
1255
1256 ramrod->rdata =
1257 bnx2x_vf_sp(bp, vf, rx_mode_rdata.e2);
1258 ramrod->rdata_mapping =
1259 bnx2x_vf_sp_map(bp, vf, rx_mode_rdata.e2);
1260 1269
1261 bnx2x_vfop_opset(BNX2X_VFOP_RXMODE_CONFIG, 1270 bnx2x_vfop_opset(BNX2X_VFOP_RXMODE_CONFIG,
1262 bnx2x_vfop_rxmode, cmd->done); 1271 bnx2x_vfop_rxmode, cmd->done);
@@ -3202,13 +3211,16 @@ int bnx2x_enable_sriov(struct bnx2x *bp)
3202 bnx2x_iov_static_resc(bp, vf); 3211 bnx2x_iov_static_resc(bp, vf);
3203 } 3212 }
3204 3213
3205 /* prepare msix vectors in VF configuration space */ 3214 /* prepare msix vectors in VF configuration space - the value in the
3215 * PCI configuration space should be the index of the last entry,
3216 * namely one less than the actual size of the table
3217 */
3206 for (vf_idx = first_vf; vf_idx < first_vf + req_vfs; vf_idx++) { 3218 for (vf_idx = first_vf; vf_idx < first_vf + req_vfs; vf_idx++) {
3207 bnx2x_pretend_func(bp, HW_VF_HANDLE(bp, vf_idx)); 3219 bnx2x_pretend_func(bp, HW_VF_HANDLE(bp, vf_idx));
3208 REG_WR(bp, PCICFG_OFFSET + GRC_CONFIG_REG_VF_MSIX_CONTROL, 3220 REG_WR(bp, PCICFG_OFFSET + GRC_CONFIG_REG_VF_MSIX_CONTROL,
3209 num_vf_queues); 3221 num_vf_queues - 1);
3210 DP(BNX2X_MSG_IOV, "set msix vec num in VF %d cfg space to %d\n", 3222 DP(BNX2X_MSG_IOV, "set msix vec num in VF %d cfg space to %d\n",
3211 vf_idx, num_vf_queues); 3223 vf_idx, num_vf_queues - 1);
3212 } 3224 }
3213 bnx2x_pretend_func(bp, BP_ABS_FUNC(bp)); 3225 bnx2x_pretend_func(bp, BP_ABS_FUNC(bp));
3214 3226
@@ -3436,10 +3448,18 @@ out:
3436 3448
3437int bnx2x_set_vf_vlan(struct net_device *dev, int vfidx, u16 vlan, u8 qos) 3449int bnx2x_set_vf_vlan(struct net_device *dev, int vfidx, u16 vlan, u8 qos)
3438{ 3450{
3451 struct bnx2x_queue_state_params q_params = {NULL};
3452 struct bnx2x_vlan_mac_ramrod_params ramrod_param;
3453 struct bnx2x_queue_update_params *update_params;
3454 struct pf_vf_bulletin_content *bulletin = NULL;
3455 struct bnx2x_rx_mode_ramrod_params rx_ramrod;
3439 struct bnx2x *bp = netdev_priv(dev); 3456 struct bnx2x *bp = netdev_priv(dev);
3440 int rc, q_logical_state; 3457 struct bnx2x_vlan_mac_obj *vlan_obj;
3458 unsigned long vlan_mac_flags = 0;
3459 unsigned long ramrod_flags = 0;
3441 struct bnx2x_virtf *vf = NULL; 3460 struct bnx2x_virtf *vf = NULL;
3442 struct pf_vf_bulletin_content *bulletin = NULL; 3461 unsigned long accept_flags;
3462 int rc;
3443 3463
3444 /* sanity and init */ 3464 /* sanity and init */
3445 rc = bnx2x_vf_ndo_prep(bp, vfidx, &vf, &bulletin); 3465 rc = bnx2x_vf_ndo_prep(bp, vfidx, &vf, &bulletin);
@@ -3457,104 +3477,118 @@ int bnx2x_set_vf_vlan(struct net_device *dev, int vfidx, u16 vlan, u8 qos)
3457 /* update PF's copy of the VF's bulletin. No point in posting the vlan 3477 /* update PF's copy of the VF's bulletin. No point in posting the vlan
3458 * to the VF since it doesn't have anything to do with it. But it useful 3478 * to the VF since it doesn't have anything to do with it. But it useful
3459 * to store it here in case the VF is not up yet and we can only 3479 * to store it here in case the VF is not up yet and we can only
3460 * configure the vlan later when it does. 3480 * configure the vlan later when it does. Treat vlan id 0 as remove the
3481 * Host tag.
3461 */ 3482 */
3462 bulletin->valid_bitmap |= 1 << VLAN_VALID; 3483 if (vlan > 0)
3484 bulletin->valid_bitmap |= 1 << VLAN_VALID;
3485 else
3486 bulletin->valid_bitmap &= ~(1 << VLAN_VALID);
3463 bulletin->vlan = vlan; 3487 bulletin->vlan = vlan;
3464 3488
3465 /* is vf initialized and queue set up? */ 3489 /* is vf initialized and queue set up? */
3466 q_logical_state = 3490 if (vf->state != VF_ENABLED ||
3467 bnx2x_get_q_logical_state(bp, &bnx2x_leading_vfq(vf, sp_obj)); 3491 bnx2x_get_q_logical_state(bp, &bnx2x_leading_vfq(vf, sp_obj)) !=
3468 if (vf->state == VF_ENABLED && 3492 BNX2X_Q_LOGICAL_STATE_ACTIVE)
3469 q_logical_state == BNX2X_Q_LOGICAL_STATE_ACTIVE) { 3493 return rc;
3470 /* configure the vlan in device on this vf's queue */
3471 unsigned long ramrod_flags = 0;
3472 unsigned long vlan_mac_flags = 0;
3473 struct bnx2x_vlan_mac_obj *vlan_obj =
3474 &bnx2x_leading_vfq(vf, vlan_obj);
3475 struct bnx2x_vlan_mac_ramrod_params ramrod_param;
3476 struct bnx2x_queue_state_params q_params = {NULL};
3477 struct bnx2x_queue_update_params *update_params;
3478 3494
3479 rc = validate_vlan_mac(bp, &bnx2x_leading_vfq(vf, mac_obj)); 3495 /* configure the vlan in device on this vf's queue */
3480 if (rc) 3496 vlan_obj = &bnx2x_leading_vfq(vf, vlan_obj);
3481 return rc; 3497 rc = validate_vlan_mac(bp, &bnx2x_leading_vfq(vf, mac_obj));
3482 memset(&ramrod_param, 0, sizeof(ramrod_param)); 3498 if (rc)
3499 return rc;
3483 3500
3484 /* must lock vfpf channel to protect against vf flows */ 3501 /* must lock vfpf channel to protect against vf flows */
3485 bnx2x_lock_vf_pf_channel(bp, vf, CHANNEL_TLV_PF_SET_VLAN); 3502 bnx2x_lock_vf_pf_channel(bp, vf, CHANNEL_TLV_PF_SET_VLAN);
3486 3503
3487 /* remove existing vlans */ 3504 /* remove existing vlans */
3488 __set_bit(RAMROD_COMP_WAIT, &ramrod_flags); 3505 __set_bit(RAMROD_COMP_WAIT, &ramrod_flags);
3489 rc = vlan_obj->delete_all(bp, vlan_obj, &vlan_mac_flags, 3506 rc = vlan_obj->delete_all(bp, vlan_obj, &vlan_mac_flags,
3490 &ramrod_flags); 3507 &ramrod_flags);
3491 if (rc) { 3508 if (rc) {
3492 BNX2X_ERR("failed to delete vlans\n"); 3509 BNX2X_ERR("failed to delete vlans\n");
3493 rc = -EINVAL; 3510 rc = -EINVAL;
3494 goto out; 3511 goto out;
3495 } 3512 }
3513
3514 /* need to remove/add the VF's accept_any_vlan bit */
3515 accept_flags = bnx2x_leading_vfq(vf, accept_flags);
3516 if (vlan)
3517 clear_bit(BNX2X_ACCEPT_ANY_VLAN, &accept_flags);
3518 else
3519 set_bit(BNX2X_ACCEPT_ANY_VLAN, &accept_flags);
3520
3521 bnx2x_vf_prep_rx_mode(bp, LEADING_IDX, &rx_ramrod, vf,
3522 accept_flags);
3523 bnx2x_leading_vfq(vf, accept_flags) = accept_flags;
3524 bnx2x_config_rx_mode(bp, &rx_ramrod);
3525
3526 /* configure the new vlan to device */
3527 memset(&ramrod_param, 0, sizeof(ramrod_param));
3528 __set_bit(RAMROD_COMP_WAIT, &ramrod_flags);
3529 ramrod_param.vlan_mac_obj = vlan_obj;
3530 ramrod_param.ramrod_flags = ramrod_flags;
3531 set_bit(BNX2X_DONT_CONSUME_CAM_CREDIT,
3532 &ramrod_param.user_req.vlan_mac_flags);
3533 ramrod_param.user_req.u.vlan.vlan = vlan;
3534 ramrod_param.user_req.cmd = BNX2X_VLAN_MAC_ADD;
3535 rc = bnx2x_config_vlan_mac(bp, &ramrod_param);
3536 if (rc) {
3537 BNX2X_ERR("failed to configure vlan\n");
3538 rc = -EINVAL;
3539 goto out;
3540 }
3496 3541
3497 /* send queue update ramrod to configure default vlan and silent 3542 /* send queue update ramrod to configure default vlan and silent
3498 * vlan removal 3543 * vlan removal
3544 */
3545 __set_bit(RAMROD_COMP_WAIT, &q_params.ramrod_flags);
3546 q_params.cmd = BNX2X_Q_CMD_UPDATE;
3547 q_params.q_obj = &bnx2x_leading_vfq(vf, sp_obj);
3548 update_params = &q_params.params.update;
3549 __set_bit(BNX2X_Q_UPDATE_DEF_VLAN_EN_CHNG,
3550 &update_params->update_flags);
3551 __set_bit(BNX2X_Q_UPDATE_SILENT_VLAN_REM_CHNG,
3552 &update_params->update_flags);
3553 if (vlan == 0) {
3554 /* if vlan is 0 then we want to leave the VF traffic
3555 * untagged, and leave the incoming traffic untouched
3556 * (i.e. do not remove any vlan tags).
3499 */ 3557 */
3500 __set_bit(RAMROD_COMP_WAIT, &q_params.ramrod_flags); 3558 __clear_bit(BNX2X_Q_UPDATE_DEF_VLAN_EN,
3501 q_params.cmd = BNX2X_Q_CMD_UPDATE; 3559 &update_params->update_flags);
3502 q_params.q_obj = &bnx2x_leading_vfq(vf, sp_obj); 3560 __clear_bit(BNX2X_Q_UPDATE_SILENT_VLAN_REM,
3503 update_params = &q_params.params.update; 3561 &update_params->update_flags);
3504 __set_bit(BNX2X_Q_UPDATE_DEF_VLAN_EN_CHNG, 3562 } else {
3563 /* configure default vlan to vf queue and set silent
3564 * vlan removal (the vf remains unaware of this vlan).
3565 */
3566 __set_bit(BNX2X_Q_UPDATE_DEF_VLAN_EN,
3505 &update_params->update_flags); 3567 &update_params->update_flags);
3506 __set_bit(BNX2X_Q_UPDATE_SILENT_VLAN_REM_CHNG, 3568 __set_bit(BNX2X_Q_UPDATE_SILENT_VLAN_REM,
3507 &update_params->update_flags); 3569 &update_params->update_flags);
3570 update_params->def_vlan = vlan;
3571 update_params->silent_removal_value =
3572 vlan & VLAN_VID_MASK;
3573 update_params->silent_removal_mask = VLAN_VID_MASK;
3574 }
3508 3575
3509 if (vlan == 0) { 3576 /* Update the Queue state */
3510 /* if vlan is 0 then we want to leave the VF traffic 3577 rc = bnx2x_queue_state_change(bp, &q_params);
3511 * untagged, and leave the incoming traffic untouched 3578 if (rc) {
3512 * (i.e. do not remove any vlan tags). 3579 BNX2X_ERR("Failed to configure default VLAN\n");
3513 */ 3580 goto out;
3514 __clear_bit(BNX2X_Q_UPDATE_DEF_VLAN_EN, 3581 }
3515 &update_params->update_flags);
3516 __clear_bit(BNX2X_Q_UPDATE_SILENT_VLAN_REM,
3517 &update_params->update_flags);
3518 } else {
3519 /* configure the new vlan to device */
3520 __set_bit(RAMROD_COMP_WAIT, &ramrod_flags);
3521 ramrod_param.vlan_mac_obj = vlan_obj;
3522 ramrod_param.ramrod_flags = ramrod_flags;
3523 ramrod_param.user_req.u.vlan.vlan = vlan;
3524 ramrod_param.user_req.cmd = BNX2X_VLAN_MAC_ADD;
3525 rc = bnx2x_config_vlan_mac(bp, &ramrod_param);
3526 if (rc) {
3527 BNX2X_ERR("failed to configure vlan\n");
3528 rc = -EINVAL;
3529 goto out;
3530 }
3531
3532 /* configure default vlan to vf queue and set silent
3533 * vlan removal (the vf remains unaware of this vlan).
3534 */
3535 update_params = &q_params.params.update;
3536 __set_bit(BNX2X_Q_UPDATE_DEF_VLAN_EN,
3537 &update_params->update_flags);
3538 __set_bit(BNX2X_Q_UPDATE_SILENT_VLAN_REM,
3539 &update_params->update_flags);
3540 update_params->def_vlan = vlan;
3541 }
3542 3582
3543 /* Update the Queue state */
3544 rc = bnx2x_queue_state_change(bp, &q_params);
3545 if (rc) {
3546 BNX2X_ERR("Failed to configure default VLAN\n");
3547 goto out;
3548 }
3549 3583
3550 /* clear the flag indicating that this VF needs its vlan 3584 /* clear the flag indicating that this VF needs its vlan
3551 * (will only be set if the HV configured the Vlan before vf was 3585 * (will only be set if the HV configured the Vlan before vf was
3552 * up and we were called because the VF came up later 3586 * up and we were called because the VF came up later
3553 */ 3587 */
3554out: 3588out:
3555 vf->cfg_flags &= ~VF_CFG_VLAN; 3589 vf->cfg_flags &= ~VF_CFG_VLAN;
3556 bnx2x_unlock_vf_pf_channel(bp, vf, CHANNEL_TLV_PF_SET_VLAN); 3590 bnx2x_unlock_vf_pf_channel(bp, vf, CHANNEL_TLV_PF_SET_VLAN);
3557 } 3591
3558 return rc; 3592 return rc;
3559} 3593}
3560 3594
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h
index 1ff6a9366629..8c213fa52174 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h
@@ -74,6 +74,7 @@ struct bnx2x_vf_queue {
74 /* VLANs object */ 74 /* VLANs object */
75 struct bnx2x_vlan_mac_obj vlan_obj; 75 struct bnx2x_vlan_mac_obj vlan_obj;
76 atomic_t vlan_count; /* 0 means vlan-0 is set ~ untagged */ 76 atomic_t vlan_count; /* 0 means vlan-0 is set ~ untagged */
77 unsigned long accept_flags; /* last accept flags configured */
77 78
78 /* Queue Slow-path State object */ 79 /* Queue Slow-path State object */
79 struct bnx2x_queue_sp_obj sp_obj; 80 struct bnx2x_queue_sp_obj sp_obj;
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c
index 3dc2537fe91b..0756d7dabdd5 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c
@@ -1598,6 +1598,8 @@ static void bnx2x_vfop_mbx_qfilters(struct bnx2x *bp, struct bnx2x_virtf *vf)
1598 1598
1599 if (msg->flags & VFPF_SET_Q_FILTERS_RX_MASK_CHANGED) { 1599 if (msg->flags & VFPF_SET_Q_FILTERS_RX_MASK_CHANGED) {
1600 unsigned long accept = 0; 1600 unsigned long accept = 0;
1601 struct pf_vf_bulletin_content *bulletin =
1602 BP_VF_BULLETIN(bp, vf->index);
1601 1603
1602 /* covert VF-PF if mask to bnx2x accept flags */ 1604 /* covert VF-PF if mask to bnx2x accept flags */
1603 if (msg->rx_mask & VFPF_RX_MASK_ACCEPT_MATCHED_UNICAST) 1605 if (msg->rx_mask & VFPF_RX_MASK_ACCEPT_MATCHED_UNICAST)
@@ -1617,9 +1619,11 @@ static void bnx2x_vfop_mbx_qfilters(struct bnx2x *bp, struct bnx2x_virtf *vf)
1617 __set_bit(BNX2X_ACCEPT_BROADCAST, &accept); 1619 __set_bit(BNX2X_ACCEPT_BROADCAST, &accept);
1618 1620
1619 /* A packet arriving the vf's mac should be accepted 1621 /* A packet arriving the vf's mac should be accepted
1620 * with any vlan 1622 * with any vlan, unless a vlan has already been
1623 * configured.
1621 */ 1624 */
1622 __set_bit(BNX2X_ACCEPT_ANY_VLAN, &accept); 1625 if (!(bulletin->valid_bitmap & (1 << VLAN_VALID)))
1626 __set_bit(BNX2X_ACCEPT_ANY_VLAN, &accept);
1623 1627
1624 /* set rx-mode */ 1628 /* set rx-mode */
1625 rc = bnx2x_vfop_rxmode_cmd(bp, vf, &cmd, 1629 rc = bnx2x_vfop_rxmode_cmd(bp, vf, &cmd,
@@ -1710,6 +1714,21 @@ static void bnx2x_vf_mbx_set_q_filters(struct bnx2x *bp,
1710 goto response; 1714 goto response;
1711 } 1715 }
1712 } 1716 }
1717 /* if vlan was set by hypervisor we don't allow guest to config vlan */
1718 if (bulletin->valid_bitmap & 1 << VLAN_VALID) {
1719 int i;
1720
1721 /* search for vlan filters */
1722 for (i = 0; i < filters->n_mac_vlan_filters; i++) {
1723 if (filters->filters[i].flags &
1724 VFPF_Q_FILTER_VLAN_TAG_VALID) {
1725 BNX2X_ERR("VF[%d] attempted to configure vlan but one was already set by Hypervisor. Aborting request\n",
1726 vf->abs_vfid);
1727 vf->op_rc = -EPERM;
1728 goto response;
1729 }
1730 }
1731 }
1713 1732
1714 /* verify vf_qid */ 1733 /* verify vf_qid */
1715 if (filters->vf_qid > vf_rxq_count(vf)) 1734 if (filters->vf_qid > vf_rxq_count(vf))
@@ -1805,6 +1824,9 @@ static void bnx2x_vf_mbx_update_rss(struct bnx2x *bp, struct bnx2x_virtf *vf,
1805 vf_op_params->rss_result_mask = rss_tlv->rss_result_mask; 1824 vf_op_params->rss_result_mask = rss_tlv->rss_result_mask;
1806 1825
1807 /* flags handled individually for backward/forward compatability */ 1826 /* flags handled individually for backward/forward compatability */
1827 vf_op_params->rss_flags = 0;
1828 vf_op_params->ramrod_flags = 0;
1829
1808 if (rss_tlv->rss_flags & VFPF_RSS_MODE_DISABLED) 1830 if (rss_tlv->rss_flags & VFPF_RSS_MODE_DISABLED)
1809 __set_bit(BNX2X_RSS_MODE_DISABLED, &vf_op_params->rss_flags); 1831 __set_bit(BNX2X_RSS_MODE_DISABLED, &vf_op_params->rss_flags);
1810 if (rss_tlv->rss_flags & VFPF_RSS_MODE_REGULAR) 1832 if (rss_tlv->rss_flags & VFPF_RSS_MODE_REGULAR)
diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c b/drivers/net/ethernet/chelsio/cxgb4/sge.c
index cc380c36e1a8..cc3511a5cd0c 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c
@@ -2581,7 +2581,7 @@ static int t4_sge_init_soft(struct adapter *adap)
2581 #undef READ_FL_BUF 2581 #undef READ_FL_BUF
2582 2582
2583 if (fl_small_pg != PAGE_SIZE || 2583 if (fl_small_pg != PAGE_SIZE ||
2584 (fl_large_pg != 0 && (fl_large_pg <= fl_small_pg || 2584 (fl_large_pg != 0 && (fl_large_pg < fl_small_pg ||
2585 (fl_large_pg & (fl_large_pg-1)) != 0))) { 2585 (fl_large_pg & (fl_large_pg-1)) != 0))) {
2586 dev_err(adap->pdev_dev, "bad SGE FL page buffer sizes [%d, %d]\n", 2586 dev_err(adap->pdev_dev, "bad SGE FL page buffer sizes [%d, %d]\n",
2587 fl_small_pg, fl_large_pg); 2587 fl_small_pg, fl_large_pg);
diff --git a/drivers/net/ethernet/emulex/benet/be.h b/drivers/net/ethernet/emulex/benet/be.h
index 5878df619b53..4ccaf9af6fc9 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -104,6 +104,7 @@ static inline char *nic_name(struct pci_dev *pdev)
104#define BE3_MAX_RSS_QS 16 104#define BE3_MAX_RSS_QS 16
105#define BE3_MAX_TX_QS 16 105#define BE3_MAX_TX_QS 16
106#define BE3_MAX_EVT_QS 16 106#define BE3_MAX_EVT_QS 16
107#define BE3_SRIOV_MAX_EVT_QS 8
107 108
108#define MAX_RX_QS 32 109#define MAX_RX_QS 32
109#define MAX_EVT_QS 32 110#define MAX_EVT_QS 32
@@ -480,7 +481,7 @@ struct be_adapter {
480 struct list_head entry; 481 struct list_head entry;
481 482
482 u32 flash_status; 483 u32 flash_status;
483 struct completion flash_compl; 484 struct completion et_cmd_compl;
484 485
485 struct be_resources res; /* resources available for the func */ 486 struct be_resources res; /* resources available for the func */
486 u16 num_vfs; /* Number of VFs provisioned by PF */ 487 u16 num_vfs; /* Number of VFs provisioned by PF */
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c
index e0e8bc1ef14c..94c35c8d799d 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -141,11 +141,17 @@ static int be_mcc_compl_process(struct be_adapter *adapter,
141 subsystem = resp_hdr->subsystem; 141 subsystem = resp_hdr->subsystem;
142 } 142 }
143 143
144 if (opcode == OPCODE_LOWLEVEL_LOOPBACK_TEST &&
145 subsystem == CMD_SUBSYSTEM_LOWLEVEL) {
146 complete(&adapter->et_cmd_compl);
147 return 0;
148 }
149
144 if (((opcode == OPCODE_COMMON_WRITE_FLASHROM) || 150 if (((opcode == OPCODE_COMMON_WRITE_FLASHROM) ||
145 (opcode == OPCODE_COMMON_WRITE_OBJECT)) && 151 (opcode == OPCODE_COMMON_WRITE_OBJECT)) &&
146 (subsystem == CMD_SUBSYSTEM_COMMON)) { 152 (subsystem == CMD_SUBSYSTEM_COMMON)) {
147 adapter->flash_status = compl_status; 153 adapter->flash_status = compl_status;
148 complete(&adapter->flash_compl); 154 complete(&adapter->et_cmd_compl);
149 } 155 }
150 156
151 if (compl_status == MCC_STATUS_SUCCESS) { 157 if (compl_status == MCC_STATUS_SUCCESS) {
@@ -2017,6 +2023,9 @@ int be_cmd_rss_config(struct be_adapter *adapter, u8 *rsstable,
2017 0x3ea83c02, 0x4a110304}; 2023 0x3ea83c02, 0x4a110304};
2018 int status; 2024 int status;
2019 2025
2026 if (!(be_if_cap_flags(adapter) & BE_IF_FLAGS_RSS))
2027 return 0;
2028
2020 if (mutex_lock_interruptible(&adapter->mbox_lock)) 2029 if (mutex_lock_interruptible(&adapter->mbox_lock))
2021 return -1; 2030 return -1;
2022 2031
@@ -2160,7 +2169,7 @@ int lancer_cmd_write_object(struct be_adapter *adapter, struct be_dma_mem *cmd,
2160 be_mcc_notify(adapter); 2169 be_mcc_notify(adapter);
2161 spin_unlock_bh(&adapter->mcc_lock); 2170 spin_unlock_bh(&adapter->mcc_lock);
2162 2171
2163 if (!wait_for_completion_timeout(&adapter->flash_compl, 2172 if (!wait_for_completion_timeout(&adapter->et_cmd_compl,
2164 msecs_to_jiffies(60000))) 2173 msecs_to_jiffies(60000)))
2165 status = -1; 2174 status = -1;
2166 else 2175 else
@@ -2255,8 +2264,8 @@ int be_cmd_write_flashrom(struct be_adapter *adapter, struct be_dma_mem *cmd,
2255 be_mcc_notify(adapter); 2264 be_mcc_notify(adapter);
2256 spin_unlock_bh(&adapter->mcc_lock); 2265 spin_unlock_bh(&adapter->mcc_lock);
2257 2266
2258 if (!wait_for_completion_timeout(&adapter->flash_compl, 2267 if (!wait_for_completion_timeout(&adapter->et_cmd_compl,
2259 msecs_to_jiffies(40000))) 2268 msecs_to_jiffies(40000)))
2260 status = -1; 2269 status = -1;
2261 else 2270 else
2262 status = adapter->flash_status; 2271 status = adapter->flash_status;
@@ -2367,6 +2376,7 @@ int be_cmd_loopback_test(struct be_adapter *adapter, u32 port_num,
2367{ 2376{
2368 struct be_mcc_wrb *wrb; 2377 struct be_mcc_wrb *wrb;
2369 struct be_cmd_req_loopback_test *req; 2378 struct be_cmd_req_loopback_test *req;
2379 struct be_cmd_resp_loopback_test *resp;
2370 int status; 2380 int status;
2371 2381
2372 spin_lock_bh(&adapter->mcc_lock); 2382 spin_lock_bh(&adapter->mcc_lock);
@@ -2381,8 +2391,8 @@ int be_cmd_loopback_test(struct be_adapter *adapter, u32 port_num,
2381 2391
2382 be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_LOWLEVEL, 2392 be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_LOWLEVEL,
2383 OPCODE_LOWLEVEL_LOOPBACK_TEST, sizeof(*req), wrb, NULL); 2393 OPCODE_LOWLEVEL_LOOPBACK_TEST, sizeof(*req), wrb, NULL);
2384 req->hdr.timeout = cpu_to_le32(4);
2385 2394
2395 req->hdr.timeout = cpu_to_le32(15);
2386 req->pattern = cpu_to_le64(pattern); 2396 req->pattern = cpu_to_le64(pattern);
2387 req->src_port = cpu_to_le32(port_num); 2397 req->src_port = cpu_to_le32(port_num);
2388 req->dest_port = cpu_to_le32(port_num); 2398 req->dest_port = cpu_to_le32(port_num);
@@ -2390,12 +2400,15 @@ int be_cmd_loopback_test(struct be_adapter *adapter, u32 port_num,
2390 req->num_pkts = cpu_to_le32(num_pkts); 2400 req->num_pkts = cpu_to_le32(num_pkts);
2391 req->loopback_type = cpu_to_le32(loopback_type); 2401 req->loopback_type = cpu_to_le32(loopback_type);
2392 2402
2393 status = be_mcc_notify_wait(adapter); 2403 be_mcc_notify(adapter);
2394 if (!status) { 2404
2395 struct be_cmd_resp_loopback_test *resp = embedded_payload(wrb); 2405 spin_unlock_bh(&adapter->mcc_lock);
2396 status = le32_to_cpu(resp->status);
2397 }
2398 2406
2407 wait_for_completion(&adapter->et_cmd_compl);
2408 resp = embedded_payload(wrb);
2409 status = le32_to_cpu(resp->status);
2410
2411 return status;
2399err: 2412err:
2400 spin_unlock_bh(&adapter->mcc_lock); 2413 spin_unlock_bh(&adapter->mcc_lock);
2401 return status; 2414 return status;
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index 0fde69d5cb6a..bf40fdaecfa3 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -2744,13 +2744,16 @@ static int be_rx_qs_create(struct be_adapter *adapter)
2744 if (!BEx_chip(adapter)) 2744 if (!BEx_chip(adapter))
2745 adapter->rss_flags |= RSS_ENABLE_UDP_IPV4 | 2745 adapter->rss_flags |= RSS_ENABLE_UDP_IPV4 |
2746 RSS_ENABLE_UDP_IPV6; 2746 RSS_ENABLE_UDP_IPV6;
2747 } else {
2748 /* Disable RSS, if only default RX Q is created */
2749 adapter->rss_flags = RSS_ENABLE_NONE;
2750 }
2747 2751
2748 rc = be_cmd_rss_config(adapter, rsstable, adapter->rss_flags, 2752 rc = be_cmd_rss_config(adapter, rsstable, adapter->rss_flags,
2749 128); 2753 128);
2750 if (rc) { 2754 if (rc) {
2751 adapter->rss_flags = 0; 2755 adapter->rss_flags = RSS_ENABLE_NONE;
2752 return rc; 2756 return rc;
2753 }
2754 } 2757 }
2755 2758
2756 /* First time posting */ 2759 /* First time posting */
@@ -3124,11 +3127,11 @@ static void BEx_get_resources(struct be_adapter *adapter,
3124{ 3127{
3125 struct pci_dev *pdev = adapter->pdev; 3128 struct pci_dev *pdev = adapter->pdev;
3126 bool use_sriov = false; 3129 bool use_sriov = false;
3130 int max_vfs;
3127 3131
3128 if (BE3_chip(adapter) && sriov_want(adapter)) { 3132 max_vfs = pci_sriov_get_totalvfs(pdev);
3129 int max_vfs;
3130 3133
3131 max_vfs = pci_sriov_get_totalvfs(pdev); 3134 if (BE3_chip(adapter) && sriov_want(adapter)) {
3132 res->max_vfs = max_vfs > 0 ? min(MAX_VFS, max_vfs) : 0; 3135 res->max_vfs = max_vfs > 0 ? min(MAX_VFS, max_vfs) : 0;
3133 use_sriov = res->max_vfs; 3136 use_sriov = res->max_vfs;
3134 } 3137 }
@@ -3159,7 +3162,11 @@ static void BEx_get_resources(struct be_adapter *adapter,
3159 BE3_MAX_RSS_QS : BE2_MAX_RSS_QS; 3162 BE3_MAX_RSS_QS : BE2_MAX_RSS_QS;
3160 res->max_rx_qs = res->max_rss_qs + 1; 3163 res->max_rx_qs = res->max_rss_qs + 1;
3161 3164
3162 res->max_evt_qs = be_physfn(adapter) ? BE3_MAX_EVT_QS : 1; 3165 if (be_physfn(adapter))
3166 res->max_evt_qs = (max_vfs > 0) ?
3167 BE3_SRIOV_MAX_EVT_QS : BE3_MAX_EVT_QS;
3168 else
3169 res->max_evt_qs = 1;
3163 3170
3164 res->if_cap_flags = BE_IF_CAP_FLAGS_WANT; 3171 res->if_cap_flags = BE_IF_CAP_FLAGS_WANT;
3165 if (!(adapter->function_caps & BE_FUNCTION_CAPS_RSS)) 3172 if (!(adapter->function_caps & BE_FUNCTION_CAPS_RSS))
@@ -4205,7 +4212,7 @@ static int be_ctrl_init(struct be_adapter *adapter)
4205 spin_lock_init(&adapter->mcc_lock); 4212 spin_lock_init(&adapter->mcc_lock);
4206 spin_lock_init(&adapter->mcc_cq_lock); 4213 spin_lock_init(&adapter->mcc_cq_lock);
4207 4214
4208 init_completion(&adapter->flash_compl); 4215 init_completion(&adapter->et_cmd_compl);
4209 pci_save_state(adapter->pdev); 4216 pci_save_state(adapter->pdev);
4210 return 0; 4217 return 0;
4211 4218
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 45b8b22b9987..50bb71c663e2 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -2049,8 +2049,6 @@ static void fec_reset_phy(struct platform_device *pdev)
2049 int err, phy_reset; 2049 int err, phy_reset;
2050 int msec = 1; 2050 int msec = 1;
2051 struct device_node *np = pdev->dev.of_node; 2051 struct device_node *np = pdev->dev.of_node;
2052 enum of_gpio_flags flags;
2053 bool port;
2054 2052
2055 if (!np) 2053 if (!np)
2056 return; 2054 return;
@@ -2060,22 +2058,18 @@ static void fec_reset_phy(struct platform_device *pdev)
2060 if (msec > 1000) 2058 if (msec > 1000)
2061 msec = 1; 2059 msec = 1;
2062 2060
2063 phy_reset = of_get_named_gpio_flags(np, "phy-reset-gpios", 0, &flags); 2061 phy_reset = of_get_named_gpio(np, "phy-reset-gpios", 0);
2064 if (!gpio_is_valid(phy_reset)) 2062 if (!gpio_is_valid(phy_reset))
2065 return; 2063 return;
2066 2064
2067 if (flags & OF_GPIO_ACTIVE_LOW) 2065 err = devm_gpio_request_one(&pdev->dev, phy_reset,
2068 port = GPIOF_OUT_INIT_LOW; 2066 GPIOF_OUT_INIT_LOW, "phy-reset");
2069 else
2070 port = GPIOF_OUT_INIT_HIGH;
2071
2072 err = devm_gpio_request_one(&pdev->dev, phy_reset, port, "phy-reset");
2073 if (err) { 2067 if (err) {
2074 dev_err(&pdev->dev, "failed to get phy-reset-gpios: %d\n", err); 2068 dev_err(&pdev->dev, "failed to get phy-reset-gpios: %d\n", err);
2075 return; 2069 return;
2076 } 2070 }
2077 msleep(msec); 2071 msleep(msec);
2078 gpio_set_value(phy_reset, !port); 2072 gpio_set_value(phy_reset, 1);
2079} 2073}
2080#else /* CONFIG_OF */ 2074#else /* CONFIG_OF */
2081static void fec_reset_phy(struct platform_device *pdev) 2075static void fec_reset_phy(struct platform_device *pdev)
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index cc06854296a3..5bcc870f8367 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -6827,12 +6827,20 @@ static inline int ixgbe_maybe_stop_tx(struct ixgbe_ring *tx_ring, u16 size)
6827 return __ixgbe_maybe_stop_tx(tx_ring, size); 6827 return __ixgbe_maybe_stop_tx(tx_ring, size);
6828} 6828}
6829 6829
6830#ifdef IXGBE_FCOE 6830static u16 ixgbe_select_queue(struct net_device *dev, struct sk_buff *skb,
6831static u16 ixgbe_select_queue(struct net_device *dev, struct sk_buff *skb) 6831 void *accel_priv)
6832{ 6832{
6833 struct ixgbe_fwd_adapter *fwd_adapter = accel_priv;
6834#ifdef IXGBE_FCOE
6833 struct ixgbe_adapter *adapter; 6835 struct ixgbe_adapter *adapter;
6834 struct ixgbe_ring_feature *f; 6836 struct ixgbe_ring_feature *f;
6835 int txq; 6837 int txq;
6838#endif
6839
6840 if (fwd_adapter)
6841 return skb->queue_mapping + fwd_adapter->tx_base_queue;
6842
6843#ifdef IXGBE_FCOE
6836 6844
6837 /* 6845 /*
6838 * only execute the code below if protocol is FCoE 6846 * only execute the code below if protocol is FCoE
@@ -6858,9 +6866,11 @@ static u16 ixgbe_select_queue(struct net_device *dev, struct sk_buff *skb)
6858 txq -= f->indices; 6866 txq -= f->indices;
6859 6867
6860 return txq + f->offset; 6868 return txq + f->offset;
6869#else
6870 return __netdev_pick_tx(dev, skb);
6871#endif
6861} 6872}
6862 6873
6863#endif
6864netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb, 6874netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb,
6865 struct ixgbe_adapter *adapter, 6875 struct ixgbe_adapter *adapter,
6866 struct ixgbe_ring *tx_ring) 6876 struct ixgbe_ring *tx_ring)
@@ -7629,27 +7639,11 @@ static void ixgbe_fwd_del(struct net_device *pdev, void *priv)
7629 kfree(fwd_adapter); 7639 kfree(fwd_adapter);
7630} 7640}
7631 7641
7632static netdev_tx_t ixgbe_fwd_xmit(struct sk_buff *skb,
7633 struct net_device *dev,
7634 void *priv)
7635{
7636 struct ixgbe_fwd_adapter *fwd_adapter = priv;
7637 unsigned int queue;
7638 struct ixgbe_ring *tx_ring;
7639
7640 queue = skb->queue_mapping + fwd_adapter->tx_base_queue;
7641 tx_ring = fwd_adapter->real_adapter->tx_ring[queue];
7642
7643 return __ixgbe_xmit_frame(skb, dev, tx_ring);
7644}
7645
7646static const struct net_device_ops ixgbe_netdev_ops = { 7642static const struct net_device_ops ixgbe_netdev_ops = {
7647 .ndo_open = ixgbe_open, 7643 .ndo_open = ixgbe_open,
7648 .ndo_stop = ixgbe_close, 7644 .ndo_stop = ixgbe_close,
7649 .ndo_start_xmit = ixgbe_xmit_frame, 7645 .ndo_start_xmit = ixgbe_xmit_frame,
7650#ifdef IXGBE_FCOE
7651 .ndo_select_queue = ixgbe_select_queue, 7646 .ndo_select_queue = ixgbe_select_queue,
7652#endif
7653 .ndo_set_rx_mode = ixgbe_set_rx_mode, 7647 .ndo_set_rx_mode = ixgbe_set_rx_mode,
7654 .ndo_validate_addr = eth_validate_addr, 7648 .ndo_validate_addr = eth_validate_addr,
7655 .ndo_set_mac_address = ixgbe_set_mac, 7649 .ndo_set_mac_address = ixgbe_set_mac,
@@ -7689,7 +7683,6 @@ static const struct net_device_ops ixgbe_netdev_ops = {
7689 .ndo_bridge_getlink = ixgbe_ndo_bridge_getlink, 7683 .ndo_bridge_getlink = ixgbe_ndo_bridge_getlink,
7690 .ndo_dfwd_add_station = ixgbe_fwd_add, 7684 .ndo_dfwd_add_station = ixgbe_fwd_add,
7691 .ndo_dfwd_del_station = ixgbe_fwd_del, 7685 .ndo_dfwd_del_station = ixgbe_fwd_del,
7692 .ndo_dfwd_start_xmit = ixgbe_fwd_xmit,
7693}; 7686};
7694 7687
7695/** 7688/**
diff --git a/drivers/net/ethernet/lantiq_etop.c b/drivers/net/ethernet/lantiq_etop.c
index 6a6c1f76d8e0..ec94a20d7099 100644
--- a/drivers/net/ethernet/lantiq_etop.c
+++ b/drivers/net/ethernet/lantiq_etop.c
@@ -619,7 +619,8 @@ ltq_etop_set_multicast_list(struct net_device *dev)
619} 619}
620 620
621static u16 621static u16
622ltq_etop_select_queue(struct net_device *dev, struct sk_buff *skb) 622ltq_etop_select_queue(struct net_device *dev, struct sk_buff *skb,
623 void *accel_priv)
623{ 624{
624 /* we are currently only using the first queue */ 625 /* we are currently only using the first queue */
625 return 0; 626 return 0;
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
index f54ebd5a1702..a7fcd593b2db 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
@@ -592,7 +592,8 @@ static void build_inline_wqe(struct mlx4_en_tx_desc *tx_desc, struct sk_buff *sk
592 } 592 }
593} 593}
594 594
595u16 mlx4_en_select_queue(struct net_device *dev, struct sk_buff *skb) 595u16 mlx4_en_select_queue(struct net_device *dev, struct sk_buff *skb,
596 void *accel_priv)
596{ 597{
597 struct mlx4_en_priv *priv = netdev_priv(dev); 598 struct mlx4_en_priv *priv = netdev_priv(dev);
598 u16 rings_p_up = priv->num_tx_rings_p_up; 599 u16 rings_p_up = priv->num_tx_rings_p_up;
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
index f3758de59c05..d5758adceaa2 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
@@ -714,7 +714,8 @@ int mlx4_en_set_cq_moder(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq);
714int mlx4_en_arm_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq); 714int mlx4_en_arm_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq);
715 715
716void mlx4_en_tx_irq(struct mlx4_cq *mcq); 716void mlx4_en_tx_irq(struct mlx4_cq *mcq);
717u16 mlx4_en_select_queue(struct net_device *dev, struct sk_buff *skb); 717u16 mlx4_en_select_queue(struct net_device *dev, struct sk_buff *skb,
718 void *accel_priv);
718netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev); 719netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev);
719 720
720int mlx4_en_create_tx_ring(struct mlx4_en_priv *priv, 721int mlx4_en_create_tx_ring(struct mlx4_en_priv *priv,
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h b/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h
index 631ea0ac1cd8..f2a7c7166e24 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h
@@ -487,6 +487,7 @@ struct qlcnic_hardware_context {
487 struct qlcnic_mailbox *mailbox; 487 struct qlcnic_mailbox *mailbox;
488 u8 extend_lb_time; 488 u8 extend_lb_time;
489 u8 phys_port_id[ETH_ALEN]; 489 u8 phys_port_id[ETH_ALEN];
490 u8 lb_mode;
490}; 491};
491 492
492struct qlcnic_adapter_stats { 493struct qlcnic_adapter_stats {
@@ -578,6 +579,8 @@ struct qlcnic_host_tx_ring {
578 dma_addr_t phys_addr; 579 dma_addr_t phys_addr;
579 dma_addr_t hw_cons_phys_addr; 580 dma_addr_t hw_cons_phys_addr;
580 struct netdev_queue *txq; 581 struct netdev_queue *txq;
582 /* Lock to protect Tx descriptors cleanup */
583 spinlock_t tx_clean_lock;
581} ____cacheline_internodealigned_in_smp; 584} ____cacheline_internodealigned_in_smp;
582 585
583/* 586/*
@@ -808,6 +811,7 @@ struct qlcnic_mac_list_s {
808 811
809#define QLCNIC_ILB_MODE 0x1 812#define QLCNIC_ILB_MODE 0x1
810#define QLCNIC_ELB_MODE 0x2 813#define QLCNIC_ELB_MODE 0x2
814#define QLCNIC_LB_MODE_MASK 0x3
811 815
812#define QLCNIC_LINKEVENT 0x1 816#define QLCNIC_LINKEVENT 0x1
813#define QLCNIC_LB_RESPONSE 0x2 817#define QLCNIC_LB_RESPONSE 0x2
@@ -1093,7 +1097,6 @@ struct qlcnic_adapter {
1093 struct qlcnic_filter_hash rx_fhash; 1097 struct qlcnic_filter_hash rx_fhash;
1094 struct list_head vf_mc_list; 1098 struct list_head vf_mc_list;
1095 1099
1096 spinlock_t tx_clean_lock;
1097 spinlock_t mac_learn_lock; 1100 spinlock_t mac_learn_lock;
1098 /* spinlock for catching rcv filters for eswitch traffic */ 1101 /* spinlock for catching rcv filters for eswitch traffic */
1099 spinlock_t rx_mac_learn_lock; 1102 spinlock_t rx_mac_learn_lock;
@@ -1708,6 +1711,7 @@ int qlcnic_83xx_init_mailbox_work(struct qlcnic_adapter *);
1708void qlcnic_83xx_detach_mailbox_work(struct qlcnic_adapter *); 1711void qlcnic_83xx_detach_mailbox_work(struct qlcnic_adapter *);
1709void qlcnic_83xx_reinit_mbx_work(struct qlcnic_mailbox *mbx); 1712void qlcnic_83xx_reinit_mbx_work(struct qlcnic_mailbox *mbx);
1710void qlcnic_83xx_free_mailbox(struct qlcnic_mailbox *mbx); 1713void qlcnic_83xx_free_mailbox(struct qlcnic_mailbox *mbx);
1714void qlcnic_update_stats(struct qlcnic_adapter *);
1711 1715
1712/* Adapter hardware abstraction */ 1716/* Adapter hardware abstraction */
1713struct qlcnic_hardware_ops { 1717struct qlcnic_hardware_ops {
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
index 6055d397a29e..f776f99f7915 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
@@ -1684,12 +1684,6 @@ int qlcnic_83xx_loopback_test(struct net_device *netdev, u8 mode)
1684 } 1684 }
1685 } while ((adapter->ahw->linkup && ahw->has_link_events) != 1); 1685 } while ((adapter->ahw->linkup && ahw->has_link_events) != 1);
1686 1686
1687 /* Make sure carrier is off and queue is stopped during loopback */
1688 if (netif_running(netdev)) {
1689 netif_carrier_off(netdev);
1690 netif_tx_stop_all_queues(netdev);
1691 }
1692
1693 ret = qlcnic_do_lb_test(adapter, mode); 1687 ret = qlcnic_do_lb_test(adapter, mode);
1694 1688
1695 qlcnic_83xx_clear_lb_mode(adapter, mode); 1689 qlcnic_83xx_clear_lb_mode(adapter, mode);
@@ -2121,6 +2115,7 @@ static void qlcnic_83xx_handle_link_aen(struct qlcnic_adapter *adapter,
2121 ahw->link_autoneg = MSB(MSW(data[3])); 2115 ahw->link_autoneg = MSB(MSW(data[3]));
2122 ahw->module_type = MSB(LSW(data[3])); 2116 ahw->module_type = MSB(LSW(data[3]));
2123 ahw->has_link_events = 1; 2117 ahw->has_link_events = 1;
2118 ahw->lb_mode = data[4] & QLCNIC_LB_MODE_MASK;
2124 qlcnic_advert_link_change(adapter, link_status); 2119 qlcnic_advert_link_change(adapter, link_status);
2125} 2120}
2126 2121
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c
index e3be2760665c..6b08194aa0d4 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c
@@ -167,27 +167,35 @@ static const char qlcnic_gstrings_test[][ETH_GSTRING_LEN] = {
167 167
168#define QLCNIC_TEST_LEN ARRAY_SIZE(qlcnic_gstrings_test) 168#define QLCNIC_TEST_LEN ARRAY_SIZE(qlcnic_gstrings_test)
169 169
170static inline int qlcnic_82xx_statistics(void) 170static inline int qlcnic_82xx_statistics(struct qlcnic_adapter *adapter)
171{ 171{
172 return ARRAY_SIZE(qlcnic_device_gstrings_stats) + 172 return ARRAY_SIZE(qlcnic_gstrings_stats) +
173 ARRAY_SIZE(qlcnic_83xx_mac_stats_strings); 173 ARRAY_SIZE(qlcnic_83xx_mac_stats_strings) +
174 QLCNIC_TX_STATS_LEN * adapter->drv_tx_rings;
174} 175}
175 176
176static inline int qlcnic_83xx_statistics(void) 177static inline int qlcnic_83xx_statistics(struct qlcnic_adapter *adapter)
177{ 178{
178 return ARRAY_SIZE(qlcnic_83xx_tx_stats_strings) + 179 return ARRAY_SIZE(qlcnic_gstrings_stats) +
180 ARRAY_SIZE(qlcnic_83xx_tx_stats_strings) +
179 ARRAY_SIZE(qlcnic_83xx_mac_stats_strings) + 181 ARRAY_SIZE(qlcnic_83xx_mac_stats_strings) +
180 ARRAY_SIZE(qlcnic_83xx_rx_stats_strings); 182 ARRAY_SIZE(qlcnic_83xx_rx_stats_strings) +
183 QLCNIC_TX_STATS_LEN * adapter->drv_tx_rings;
181} 184}
182 185
183static int qlcnic_dev_statistics_len(struct qlcnic_adapter *adapter) 186static int qlcnic_dev_statistics_len(struct qlcnic_adapter *adapter)
184{ 187{
185 if (qlcnic_82xx_check(adapter)) 188 int len = -1;
186 return qlcnic_82xx_statistics(); 189
187 else if (qlcnic_83xx_check(adapter)) 190 if (qlcnic_82xx_check(adapter)) {
188 return qlcnic_83xx_statistics(); 191 len = qlcnic_82xx_statistics(adapter);
189 else 192 if (adapter->flags & QLCNIC_ESWITCH_ENABLED)
190 return -1; 193 len += ARRAY_SIZE(qlcnic_device_gstrings_stats);
194 } else if (qlcnic_83xx_check(adapter)) {
195 len = qlcnic_83xx_statistics(adapter);
196 }
197
198 return len;
191} 199}
192 200
193#define QLCNIC_TX_INTR_NOT_CONFIGURED 0X78563412 201#define QLCNIC_TX_INTR_NOT_CONFIGURED 0X78563412
@@ -920,18 +928,13 @@ static int qlcnic_eeprom_test(struct net_device *dev)
920 928
921static int qlcnic_get_sset_count(struct net_device *dev, int sset) 929static int qlcnic_get_sset_count(struct net_device *dev, int sset)
922{ 930{
923 int len;
924 931
925 struct qlcnic_adapter *adapter = netdev_priv(dev); 932 struct qlcnic_adapter *adapter = netdev_priv(dev);
926 switch (sset) { 933 switch (sset) {
927 case ETH_SS_TEST: 934 case ETH_SS_TEST:
928 return QLCNIC_TEST_LEN; 935 return QLCNIC_TEST_LEN;
929 case ETH_SS_STATS: 936 case ETH_SS_STATS:
930 len = qlcnic_dev_statistics_len(adapter) + QLCNIC_STATS_LEN; 937 return qlcnic_dev_statistics_len(adapter);
931 if ((adapter->flags & QLCNIC_ESWITCH_ENABLED) ||
932 qlcnic_83xx_check(adapter))
933 return len;
934 return qlcnic_82xx_statistics();
935 default: 938 default:
936 return -EOPNOTSUPP; 939 return -EOPNOTSUPP;
937 } 940 }
@@ -1267,7 +1270,7 @@ static u64 *qlcnic_fill_stats(u64 *data, void *stats, int type)
1267 return data; 1270 return data;
1268} 1271}
1269 1272
1270static void qlcnic_update_stats(struct qlcnic_adapter *adapter) 1273void qlcnic_update_stats(struct qlcnic_adapter *adapter)
1271{ 1274{
1272 struct qlcnic_host_tx_ring *tx_ring; 1275 struct qlcnic_host_tx_ring *tx_ring;
1273 int ring; 1276 int ring;
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c
index e9c21e5d0ca9..c4262c23ed7c 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c
@@ -134,6 +134,8 @@ void qlcnic_release_tx_buffers(struct qlcnic_adapter *adapter,
134 struct qlcnic_skb_frag *buffrag; 134 struct qlcnic_skb_frag *buffrag;
135 int i, j; 135 int i, j;
136 136
137 spin_lock(&tx_ring->tx_clean_lock);
138
137 cmd_buf = tx_ring->cmd_buf_arr; 139 cmd_buf = tx_ring->cmd_buf_arr;
138 for (i = 0; i < tx_ring->num_desc; i++) { 140 for (i = 0; i < tx_ring->num_desc; i++) {
139 buffrag = cmd_buf->frag_array; 141 buffrag = cmd_buf->frag_array;
@@ -157,6 +159,8 @@ void qlcnic_release_tx_buffers(struct qlcnic_adapter *adapter,
157 } 159 }
158 cmd_buf++; 160 cmd_buf++;
159 } 161 }
162
163 spin_unlock(&tx_ring->tx_clean_lock);
160} 164}
161 165
162void qlcnic_free_sw_resources(struct qlcnic_adapter *adapter) 166void qlcnic_free_sw_resources(struct qlcnic_adapter *adapter)
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
index eda6c691d897..ad1531ae3aa8 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
@@ -689,6 +689,10 @@ void qlcnic_advert_link_change(struct qlcnic_adapter *adapter, int linkup)
689 adapter->ahw->linkup = 0; 689 adapter->ahw->linkup = 0;
690 netif_carrier_off(netdev); 690 netif_carrier_off(netdev);
691 } else if (!adapter->ahw->linkup && linkup) { 691 } else if (!adapter->ahw->linkup && linkup) {
692 /* Do not advertise Link up if the port is in loopback mode */
693 if (qlcnic_83xx_check(adapter) && adapter->ahw->lb_mode)
694 return;
695
692 netdev_info(netdev, "NIC Link is up\n"); 696 netdev_info(netdev, "NIC Link is up\n");
693 adapter->ahw->linkup = 1; 697 adapter->ahw->linkup = 1;
694 netif_carrier_on(netdev); 698 netif_carrier_on(netdev);
@@ -778,7 +782,7 @@ static int qlcnic_process_cmd_ring(struct qlcnic_adapter *adapter,
778 struct net_device *netdev = adapter->netdev; 782 struct net_device *netdev = adapter->netdev;
779 struct qlcnic_skb_frag *frag; 783 struct qlcnic_skb_frag *frag;
780 784
781 if (!spin_trylock(&adapter->tx_clean_lock)) 785 if (!spin_trylock(&tx_ring->tx_clean_lock))
782 return 1; 786 return 1;
783 787
784 sw_consumer = tx_ring->sw_consumer; 788 sw_consumer = tx_ring->sw_consumer;
@@ -807,8 +811,9 @@ static int qlcnic_process_cmd_ring(struct qlcnic_adapter *adapter,
807 break; 811 break;
808 } 812 }
809 813
814 tx_ring->sw_consumer = sw_consumer;
815
810 if (count && netif_running(netdev)) { 816 if (count && netif_running(netdev)) {
811 tx_ring->sw_consumer = sw_consumer;
812 smp_mb(); 817 smp_mb();
813 if (netif_tx_queue_stopped(tx_ring->txq) && 818 if (netif_tx_queue_stopped(tx_ring->txq) &&
814 netif_carrier_ok(netdev)) { 819 netif_carrier_ok(netdev)) {
@@ -834,7 +839,8 @@ static int qlcnic_process_cmd_ring(struct qlcnic_adapter *adapter,
834 */ 839 */
835 hw_consumer = le32_to_cpu(*(tx_ring->hw_consumer)); 840 hw_consumer = le32_to_cpu(*(tx_ring->hw_consumer));
836 done = (sw_consumer == hw_consumer); 841 done = (sw_consumer == hw_consumer);
837 spin_unlock(&adapter->tx_clean_lock); 842
843 spin_unlock(&tx_ring->tx_clean_lock);
838 844
839 return done; 845 return done;
840} 846}
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
index 2c8cac0c6a55..550791b8fbae 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
@@ -1756,7 +1756,6 @@ void __qlcnic_down(struct qlcnic_adapter *adapter, struct net_device *netdev)
1756 if (qlcnic_sriov_vf_check(adapter)) 1756 if (qlcnic_sriov_vf_check(adapter))
1757 qlcnic_sriov_cleanup_async_list(&adapter->ahw->sriov->bc); 1757 qlcnic_sriov_cleanup_async_list(&adapter->ahw->sriov->bc);
1758 smp_mb(); 1758 smp_mb();
1759 spin_lock(&adapter->tx_clean_lock);
1760 netif_carrier_off(netdev); 1759 netif_carrier_off(netdev);
1761 adapter->ahw->linkup = 0; 1760 adapter->ahw->linkup = 0;
1762 netif_tx_disable(netdev); 1761 netif_tx_disable(netdev);
@@ -1777,7 +1776,6 @@ void __qlcnic_down(struct qlcnic_adapter *adapter, struct net_device *netdev)
1777 1776
1778 for (ring = 0; ring < adapter->drv_tx_rings; ring++) 1777 for (ring = 0; ring < adapter->drv_tx_rings; ring++)
1779 qlcnic_release_tx_buffers(adapter, &adapter->tx_ring[ring]); 1778 qlcnic_release_tx_buffers(adapter, &adapter->tx_ring[ring]);
1780 spin_unlock(&adapter->tx_clean_lock);
1781} 1779}
1782 1780
1783/* Usage: During suspend and firmware recovery module */ 1781/* Usage: During suspend and firmware recovery module */
@@ -2172,6 +2170,7 @@ int qlcnic_alloc_tx_rings(struct qlcnic_adapter *adapter,
2172 } 2170 }
2173 memset(cmd_buf_arr, 0, TX_BUFF_RINGSIZE(tx_ring)); 2171 memset(cmd_buf_arr, 0, TX_BUFF_RINGSIZE(tx_ring));
2174 tx_ring->cmd_buf_arr = cmd_buf_arr; 2172 tx_ring->cmd_buf_arr = cmd_buf_arr;
2173 spin_lock_init(&tx_ring->tx_clean_lock);
2175 } 2174 }
2176 2175
2177 if (qlcnic_83xx_check(adapter) || 2176 if (qlcnic_83xx_check(adapter) ||
@@ -2299,7 +2298,6 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
2299 rwlock_init(&adapter->ahw->crb_lock); 2298 rwlock_init(&adapter->ahw->crb_lock);
2300 mutex_init(&adapter->ahw->mem_lock); 2299 mutex_init(&adapter->ahw->mem_lock);
2301 2300
2302 spin_lock_init(&adapter->tx_clean_lock);
2303 INIT_LIST_HEAD(&adapter->mac_list); 2301 INIT_LIST_HEAD(&adapter->mac_list);
2304 2302
2305 qlcnic_register_dcb(adapter); 2303 qlcnic_register_dcb(adapter);
@@ -2782,6 +2780,9 @@ static struct net_device_stats *qlcnic_get_stats(struct net_device *netdev)
2782 struct qlcnic_adapter *adapter = netdev_priv(netdev); 2780 struct qlcnic_adapter *adapter = netdev_priv(netdev);
2783 struct net_device_stats *stats = &netdev->stats; 2781 struct net_device_stats *stats = &netdev->stats;
2784 2782
2783 if (test_bit(__QLCNIC_DEV_UP, &adapter->state))
2784 qlcnic_update_stats(adapter);
2785
2785 stats->rx_packets = adapter->stats.rx_pkts + adapter->stats.lro_pkts; 2786 stats->rx_packets = adapter->stats.rx_pkts + adapter->stats.lro_pkts;
2786 stats->tx_packets = adapter->stats.xmitfinished; 2787 stats->tx_packets = adapter->stats.xmitfinished;
2787 stats->rx_bytes = adapter->stats.rxbytes + adapter->stats.lrobytes; 2788 stats->rx_bytes = adapter->stats.rxbytes + adapter->stats.lrobytes;
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c
index 686f460b1502..024f8161d2fe 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c
@@ -75,7 +75,6 @@ static int qlcnic_sriov_pf_cal_res_limit(struct qlcnic_adapter *adapter,
75 num_vfs = sriov->num_vfs; 75 num_vfs = sriov->num_vfs;
76 max = num_vfs + 1; 76 max = num_vfs + 1;
77 info->bit_offsets = 0xffff; 77 info->bit_offsets = 0xffff;
78 info->max_tx_ques = res->num_tx_queues / max;
79 info->max_rx_mcast_mac_filters = res->num_rx_mcast_mac_filters; 78 info->max_rx_mcast_mac_filters = res->num_rx_mcast_mac_filters;
80 num_vf_macs = QLCNIC_SRIOV_VF_MAX_MAC; 79 num_vf_macs = QLCNIC_SRIOV_VF_MAX_MAC;
81 80
@@ -86,6 +85,7 @@ static int qlcnic_sriov_pf_cal_res_limit(struct qlcnic_adapter *adapter,
86 info->max_tx_mac_filters = temp; 85 info->max_tx_mac_filters = temp;
87 info->min_tx_bw = 0; 86 info->min_tx_bw = 0;
88 info->max_tx_bw = MAX_BW; 87 info->max_tx_bw = MAX_BW;
88 info->max_tx_ques = res->num_tx_queues - sriov->num_vfs;
89 } else { 89 } else {
90 id = qlcnic_sriov_func_to_index(adapter, func); 90 id = qlcnic_sriov_func_to_index(adapter, func);
91 if (id < 0) 91 if (id < 0)
@@ -95,6 +95,7 @@ static int qlcnic_sriov_pf_cal_res_limit(struct qlcnic_adapter *adapter,
95 info->max_tx_bw = vp->max_tx_bw; 95 info->max_tx_bw = vp->max_tx_bw;
96 info->max_rx_ucast_mac_filters = num_vf_macs; 96 info->max_rx_ucast_mac_filters = num_vf_macs;
97 info->max_tx_mac_filters = num_vf_macs; 97 info->max_tx_mac_filters = num_vf_macs;
98 info->max_tx_ques = QLCNIC_SINGLE_RING;
98 } 99 }
99 100
100 info->max_rx_ip_addr = res->num_destip / max; 101 info->max_rx_ip_addr = res->num_destip / max;
diff --git a/drivers/net/ethernet/tile/tilegx.c b/drivers/net/ethernet/tile/tilegx.c
index 628b736e5ae7..0e9fb3301b11 100644
--- a/drivers/net/ethernet/tile/tilegx.c
+++ b/drivers/net/ethernet/tile/tilegx.c
@@ -2080,7 +2080,8 @@ static int tile_net_tx(struct sk_buff *skb, struct net_device *dev)
2080} 2080}
2081 2081
2082/* Return subqueue id on this core (one per core). */ 2082/* Return subqueue id on this core (one per core). */
2083static u16 tile_net_select_queue(struct net_device *dev, struct sk_buff *skb) 2083static u16 tile_net_select_queue(struct net_device *dev, struct sk_buff *skb,
2084 void *accel_priv)
2084{ 2085{
2085 return smp_processor_id(); 2086 return smp_processor_id();
2086} 2087}
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 60406b01f9eb..bc8faaec33f5 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -299,7 +299,7 @@ netdev_tx_t macvlan_start_xmit(struct sk_buff *skb,
299 299
300 if (vlan->fwd_priv) { 300 if (vlan->fwd_priv) {
301 skb->dev = vlan->lowerdev; 301 skb->dev = vlan->lowerdev;
302 ret = dev_hard_start_xmit(skb, skb->dev, NULL, vlan->fwd_priv); 302 ret = dev_queue_xmit_accel(skb, vlan->fwd_priv);
303 } else { 303 } else {
304 ret = macvlan_queue_xmit(skb, dev); 304 ret = macvlan_queue_xmit(skb, dev);
305 } 305 }
@@ -338,6 +338,8 @@ static const struct header_ops macvlan_hard_header_ops = {
338 .cache_update = eth_header_cache_update, 338 .cache_update = eth_header_cache_update,
339}; 339};
340 340
341static struct rtnl_link_ops macvlan_link_ops;
342
341static int macvlan_open(struct net_device *dev) 343static int macvlan_open(struct net_device *dev)
342{ 344{
343 struct macvlan_dev *vlan = netdev_priv(dev); 345 struct macvlan_dev *vlan = netdev_priv(dev);
@@ -353,7 +355,8 @@ static int macvlan_open(struct net_device *dev)
353 goto hash_add; 355 goto hash_add;
354 } 356 }
355 357
356 if (lowerdev->features & NETIF_F_HW_L2FW_DOFFLOAD) { 358 if (lowerdev->features & NETIF_F_HW_L2FW_DOFFLOAD &&
359 dev->rtnl_link_ops == &macvlan_link_ops) {
357 vlan->fwd_priv = 360 vlan->fwd_priv =
358 lowerdev->netdev_ops->ndo_dfwd_add_station(lowerdev, dev); 361 lowerdev->netdev_ops->ndo_dfwd_add_station(lowerdev, dev);
359 362
@@ -362,10 +365,8 @@ static int macvlan_open(struct net_device *dev)
362 */ 365 */
363 if (IS_ERR_OR_NULL(vlan->fwd_priv)) { 366 if (IS_ERR_OR_NULL(vlan->fwd_priv)) {
364 vlan->fwd_priv = NULL; 367 vlan->fwd_priv = NULL;
365 } else { 368 } else
366 dev->features &= ~NETIF_F_LLTX;
367 return 0; 369 return 0;
368 }
369 } 370 }
370 371
371 err = -EBUSY; 372 err = -EBUSY;
@@ -699,8 +700,7 @@ static netdev_features_t macvlan_fix_features(struct net_device *dev,
699 features = netdev_increment_features(vlan->lowerdev->features, 700 features = netdev_increment_features(vlan->lowerdev->features,
700 features, 701 features,
701 mask); 702 mask);
702 if (!vlan->fwd_priv) 703 features |= NETIF_F_LLTX;
703 features |= NETIF_F_LLTX;
704 704
705 return features; 705 return features;
706} 706}
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index 736050d6b451..b75ae5bde673 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -1647,7 +1647,8 @@ static netdev_tx_t team_xmit(struct sk_buff *skb, struct net_device *dev)
1647 return NETDEV_TX_OK; 1647 return NETDEV_TX_OK;
1648} 1648}
1649 1649
1650static u16 team_select_queue(struct net_device *dev, struct sk_buff *skb) 1650static u16 team_select_queue(struct net_device *dev, struct sk_buff *skb,
1651 void *accel_priv)
1651{ 1652{
1652 /* 1653 /*
1653 * This helper function exists to help dev_pick_tx get the correct 1654 * This helper function exists to help dev_pick_tx get the correct
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 7c8343a4f918..ecec8029c5e8 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -348,7 +348,8 @@ unlock:
348 * different rxq no. here. If we could not get rxhash, then we would 348 * different rxq no. here. If we could not get rxhash, then we would
349 * hope the rxq no. may help here. 349 * hope the rxq no. may help here.
350 */ 350 */
351static u16 tun_select_queue(struct net_device *dev, struct sk_buff *skb) 351static u16 tun_select_queue(struct net_device *dev, struct sk_buff *skb,
352 void *accel_priv)
352{ 353{
353 struct tun_struct *tun = netdev_priv(dev); 354 struct tun_struct *tun = netdev_priv(dev);
354 struct tun_flow_entry *e; 355 struct tun_flow_entry *e;
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index 86292e6aaf49..1a482344b3f5 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -185,7 +185,6 @@ enum rx_ctrl_state{
185#define BM_REQUEST_TYPE (0xa1) 185#define BM_REQUEST_TYPE (0xa1)
186#define B_NOTIFICATION (0x20) 186#define B_NOTIFICATION (0x20)
187#define W_VALUE (0x0) 187#define W_VALUE (0x0)
188#define W_INDEX (0x2)
189#define W_LENGTH (0x2) 188#define W_LENGTH (0x2)
190 189
191#define B_OVERRUN (0x1<<6) 190#define B_OVERRUN (0x1<<6)
@@ -1487,6 +1486,7 @@ static void tiocmget_intr_callback(struct urb *urb)
1487 struct uart_icount *icount; 1486 struct uart_icount *icount;
1488 struct hso_serial_state_notification *serial_state_notification; 1487 struct hso_serial_state_notification *serial_state_notification;
1489 struct usb_device *usb; 1488 struct usb_device *usb;
1489 int if_num;
1490 1490
1491 /* Sanity checks */ 1491 /* Sanity checks */
1492 if (!serial) 1492 if (!serial)
@@ -1495,15 +1495,24 @@ static void tiocmget_intr_callback(struct urb *urb)
1495 handle_usb_error(status, __func__, serial->parent); 1495 handle_usb_error(status, __func__, serial->parent);
1496 return; 1496 return;
1497 } 1497 }
1498
1499 /* tiocmget is only supported on HSO_PORT_MODEM */
1498 tiocmget = serial->tiocmget; 1500 tiocmget = serial->tiocmget;
1499 if (!tiocmget) 1501 if (!tiocmget)
1500 return; 1502 return;
1503 BUG_ON((serial->parent->port_spec & HSO_PORT_MASK) != HSO_PORT_MODEM);
1504
1501 usb = serial->parent->usb; 1505 usb = serial->parent->usb;
1506 if_num = serial->parent->interface->altsetting->desc.bInterfaceNumber;
1507
1508 /* wIndex should be the USB interface number of the port to which the
1509 * notification applies, which should always be the Modem port.
1510 */
1502 serial_state_notification = &tiocmget->serial_state_notification; 1511 serial_state_notification = &tiocmget->serial_state_notification;
1503 if (serial_state_notification->bmRequestType != BM_REQUEST_TYPE || 1512 if (serial_state_notification->bmRequestType != BM_REQUEST_TYPE ||
1504 serial_state_notification->bNotification != B_NOTIFICATION || 1513 serial_state_notification->bNotification != B_NOTIFICATION ||
1505 le16_to_cpu(serial_state_notification->wValue) != W_VALUE || 1514 le16_to_cpu(serial_state_notification->wValue) != W_VALUE ||
1506 le16_to_cpu(serial_state_notification->wIndex) != W_INDEX || 1515 le16_to_cpu(serial_state_notification->wIndex) != if_num ||
1507 le16_to_cpu(serial_state_notification->wLength) != W_LENGTH) { 1516 le16_to_cpu(serial_state_notification->wLength) != W_LENGTH) {
1508 dev_warn(&usb->dev, 1517 dev_warn(&usb->dev,
1509 "hso received invalid serial state notification\n"); 1518 "hso received invalid serial state notification\n");
diff --git a/drivers/net/usb/mcs7830.c b/drivers/net/usb/mcs7830.c
index 03832d3780aa..f54637828574 100644
--- a/drivers/net/usb/mcs7830.c
+++ b/drivers/net/usb/mcs7830.c
@@ -117,7 +117,6 @@ enum {
117struct mcs7830_data { 117struct mcs7830_data {
118 u8 multi_filter[8]; 118 u8 multi_filter[8];
119 u8 config; 119 u8 config;
120 u8 link_counter;
121}; 120};
122 121
123static const char driver_name[] = "MOSCHIP usb-ethernet driver"; 122static const char driver_name[] = "MOSCHIP usb-ethernet driver";
@@ -561,26 +560,16 @@ static void mcs7830_status(struct usbnet *dev, struct urb *urb)
561{ 560{
562 u8 *buf = urb->transfer_buffer; 561 u8 *buf = urb->transfer_buffer;
563 bool link, link_changed; 562 bool link, link_changed;
564 struct mcs7830_data *data = mcs7830_get_data(dev);
565 563
566 if (urb->actual_length < 16) 564 if (urb->actual_length < 16)
567 return; 565 return;
568 566
569 link = !(buf[1] & 0x20); 567 link = !(buf[1] == 0x20);
570 link_changed = netif_carrier_ok(dev->net) != link; 568 link_changed = netif_carrier_ok(dev->net) != link;
571 if (link_changed) { 569 if (link_changed) {
572 data->link_counter++; 570 usbnet_link_change(dev, link, 0);
573 /* 571 netdev_dbg(dev->net, "Link Status is: %d\n", link);
574 track link state 20 times to guard against erroneous 572 }
575 link state changes reported sometimes by the chip
576 */
577 if (data->link_counter > 20) {
578 data->link_counter = 0;
579 usbnet_link_change(dev, link, 0);
580 netdev_dbg(dev->net, "Link Status is: %d\n", link);
581 }
582 } else
583 data->link_counter = 0;
584} 573}
585 574
586static const struct driver_info moschip_info = { 575static const struct driver_info moschip_info = {
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index d208f8604981..5d776447d9c3 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -1797,16 +1797,17 @@ static int virtnet_restore(struct virtio_device *vdev)
1797 if (err) 1797 if (err)
1798 return err; 1798 return err;
1799 1799
1800 if (netif_running(vi->dev)) 1800 if (netif_running(vi->dev)) {
1801 for (i = 0; i < vi->curr_queue_pairs; i++)
1802 if (!try_fill_recv(&vi->rq[i], GFP_KERNEL))
1803 schedule_delayed_work(&vi->refill, 0);
1804
1801 for (i = 0; i < vi->max_queue_pairs; i++) 1805 for (i = 0; i < vi->max_queue_pairs; i++)
1802 virtnet_napi_enable(&vi->rq[i]); 1806 virtnet_napi_enable(&vi->rq[i]);
1807 }
1803 1808
1804 netif_device_attach(vi->dev); 1809 netif_device_attach(vi->dev);
1805 1810
1806 for (i = 0; i < vi->curr_queue_pairs; i++)
1807 if (!try_fill_recv(&vi->rq[i], GFP_KERNEL))
1808 schedule_delayed_work(&vi->refill, 0);
1809
1810 mutex_lock(&vi->config_lock); 1811 mutex_lock(&vi->config_lock);
1811 vi->config_enable = true; 1812 vi->config_enable = true;
1812 mutex_unlock(&vi->config_lock); 1813 mutex_unlock(&vi->config_lock);
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 249e01c5600c..ed384fee76ac 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -2440,7 +2440,8 @@ static int vxlan_newlink(struct net *net, struct net_device *dev,
2440 /* update header length based on lower device */ 2440 /* update header length based on lower device */
2441 dev->hard_header_len = lowerdev->hard_header_len + 2441 dev->hard_header_len = lowerdev->hard_header_len +
2442 (use_ipv6 ? VXLAN6_HEADROOM : VXLAN_HEADROOM); 2442 (use_ipv6 ? VXLAN6_HEADROOM : VXLAN_HEADROOM);
2443 } 2443 } else if (use_ipv6)
2444 vxlan->flags |= VXLAN_F_IPV6;
2444 2445
2445 if (data[IFLA_VXLAN_TOS]) 2446 if (data[IFLA_VXLAN_TOS])
2446 vxlan->tos = nla_get_u8(data[IFLA_VXLAN_TOS]); 2447 vxlan->tos = nla_get_u8(data[IFLA_VXLAN_TOS]);
diff --git a/drivers/net/wireless/iwlwifi/pcie/drv.c b/drivers/net/wireless/iwlwifi/pcie/drv.c
index 86605027c41d..e6272546395a 100644
--- a/drivers/net/wireless/iwlwifi/pcie/drv.c
+++ b/drivers/net/wireless/iwlwifi/pcie/drv.c
@@ -357,21 +357,27 @@ static DEFINE_PCI_DEVICE_TABLE(iwl_hw_card_ids) = {
357 {IWL_PCI_DEVICE(0x095B, 0x5310, iwl7265_2ac_cfg)}, 357 {IWL_PCI_DEVICE(0x095B, 0x5310, iwl7265_2ac_cfg)},
358 {IWL_PCI_DEVICE(0x095B, 0x5302, iwl7265_2ac_cfg)}, 358 {IWL_PCI_DEVICE(0x095B, 0x5302, iwl7265_2ac_cfg)},
359 {IWL_PCI_DEVICE(0x095B, 0x5210, iwl7265_2ac_cfg)}, 359 {IWL_PCI_DEVICE(0x095B, 0x5210, iwl7265_2ac_cfg)},
360 {IWL_PCI_DEVICE(0x095B, 0x5012, iwl7265_2ac_cfg)}, 360 {IWL_PCI_DEVICE(0x095A, 0x5012, iwl7265_2ac_cfg)},
361 {IWL_PCI_DEVICE(0x095B, 0x500A, iwl7265_2ac_cfg)}, 361 {IWL_PCI_DEVICE(0x095A, 0x500A, iwl7265_2ac_cfg)},
362 {IWL_PCI_DEVICE(0x095A, 0x5410, iwl7265_2ac_cfg)}, 362 {IWL_PCI_DEVICE(0x095A, 0x5410, iwl7265_2ac_cfg)},
363 {IWL_PCI_DEVICE(0x095A, 0x5400, iwl7265_2ac_cfg)},
363 {IWL_PCI_DEVICE(0x095A, 0x1010, iwl7265_2ac_cfg)}, 364 {IWL_PCI_DEVICE(0x095A, 0x1010, iwl7265_2ac_cfg)},
364 {IWL_PCI_DEVICE(0x095A, 0x5000, iwl7265_2n_cfg)}, 365 {IWL_PCI_DEVICE(0x095A, 0x5000, iwl7265_2n_cfg)},
365 {IWL_PCI_DEVICE(0x095B, 0x5200, iwl7265_2n_cfg)}, 366 {IWL_PCI_DEVICE(0x095B, 0x5200, iwl7265_2n_cfg)},
366 {IWL_PCI_DEVICE(0x095A, 0x5002, iwl7265_n_cfg)}, 367 {IWL_PCI_DEVICE(0x095A, 0x5002, iwl7265_n_cfg)},
367 {IWL_PCI_DEVICE(0x095B, 0x5202, iwl7265_n_cfg)}, 368 {IWL_PCI_DEVICE(0x095B, 0x5202, iwl7265_n_cfg)},
368 {IWL_PCI_DEVICE(0x095A, 0x9010, iwl7265_2ac_cfg)}, 369 {IWL_PCI_DEVICE(0x095A, 0x9010, iwl7265_2ac_cfg)},
370 {IWL_PCI_DEVICE(0x095A, 0x9110, iwl7265_2ac_cfg)},
369 {IWL_PCI_DEVICE(0x095A, 0x9210, iwl7265_2ac_cfg)}, 371 {IWL_PCI_DEVICE(0x095A, 0x9210, iwl7265_2ac_cfg)},
372 {IWL_PCI_DEVICE(0x095A, 0x9510, iwl7265_2ac_cfg)},
373 {IWL_PCI_DEVICE(0x095A, 0x9310, iwl7265_2ac_cfg)},
370 {IWL_PCI_DEVICE(0x095A, 0x9410, iwl7265_2ac_cfg)}, 374 {IWL_PCI_DEVICE(0x095A, 0x9410, iwl7265_2ac_cfg)},
371 {IWL_PCI_DEVICE(0x095A, 0x5020, iwl7265_2n_cfg)}, 375 {IWL_PCI_DEVICE(0x095A, 0x5020, iwl7265_2n_cfg)},
372 {IWL_PCI_DEVICE(0x095A, 0x502A, iwl7265_2n_cfg)}, 376 {IWL_PCI_DEVICE(0x095A, 0x502A, iwl7265_2n_cfg)},
373 {IWL_PCI_DEVICE(0x095A, 0x5420, iwl7265_2n_cfg)}, 377 {IWL_PCI_DEVICE(0x095A, 0x5420, iwl7265_2n_cfg)},
374 {IWL_PCI_DEVICE(0x095A, 0x5090, iwl7265_2ac_cfg)}, 378 {IWL_PCI_DEVICE(0x095A, 0x5090, iwl7265_2ac_cfg)},
379 {IWL_PCI_DEVICE(0x095A, 0x5190, iwl7265_2ac_cfg)},
380 {IWL_PCI_DEVICE(0x095A, 0x5590, iwl7265_2ac_cfg)},
375 {IWL_PCI_DEVICE(0x095B, 0x5290, iwl7265_2ac_cfg)}, 381 {IWL_PCI_DEVICE(0x095B, 0x5290, iwl7265_2ac_cfg)},
376 {IWL_PCI_DEVICE(0x095A, 0x5490, iwl7265_2ac_cfg)}, 382 {IWL_PCI_DEVICE(0x095A, 0x5490, iwl7265_2ac_cfg)},
377#endif /* CONFIG_IWLMVM */ 383#endif /* CONFIG_IWLMVM */
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index c72438bb2faf..a1b32ee9594a 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -2011,7 +2011,7 @@ static int hwsim_tx_info_frame_received_nl(struct sk_buff *skb_2,
2011 (hwsim_flags & HWSIM_TX_STAT_ACK)) { 2011 (hwsim_flags & HWSIM_TX_STAT_ACK)) {
2012 if (skb->len >= 16) { 2012 if (skb->len >= 16) {
2013 hdr = (struct ieee80211_hdr *) skb->data; 2013 hdr = (struct ieee80211_hdr *) skb->data;
2014 mac80211_hwsim_monitor_ack(txi->rate_driver_data[0], 2014 mac80211_hwsim_monitor_ack(data2->channel,
2015 hdr->addr2); 2015 hdr->addr2);
2016 } 2016 }
2017 txi->flags |= IEEE80211_TX_STAT_ACK; 2017 txi->flags |= IEEE80211_TX_STAT_ACK;
diff --git a/drivers/net/wireless/mwifiex/main.c b/drivers/net/wireless/mwifiex/main.c
index 78e8a6666cc6..8bb8988c435c 100644
--- a/drivers/net/wireless/mwifiex/main.c
+++ b/drivers/net/wireless/mwifiex/main.c
@@ -746,7 +746,8 @@ static struct net_device_stats *mwifiex_get_stats(struct net_device *dev)
746} 746}
747 747
748static u16 748static u16
749mwifiex_netdev_select_wmm_queue(struct net_device *dev, struct sk_buff *skb) 749mwifiex_netdev_select_wmm_queue(struct net_device *dev, struct sk_buff *skb,
750 void *accel_priv)
750{ 751{
751 skb->priority = cfg80211_classify8021d(skb); 752 skb->priority = cfg80211_classify8021d(skb);
752 return mwifiex_1d_to_wmm_queue[skb->priority]; 753 return mwifiex_1d_to_wmm_queue[skb->priority];
diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c
index 34ca4e58a43d..fff8cddfed81 100644
--- a/drivers/net/xen-netback/interface.c
+++ b/drivers/net/xen-netback/interface.c
@@ -34,6 +34,7 @@
34#include <linux/ethtool.h> 34#include <linux/ethtool.h>
35#include <linux/rtnetlink.h> 35#include <linux/rtnetlink.h>
36#include <linux/if_vlan.h> 36#include <linux/if_vlan.h>
37#include <linux/vmalloc.h>
37 38
38#include <xen/events.h> 39#include <xen/events.h>
39#include <asm/xen/hypercall.h> 40#include <asm/xen/hypercall.h>
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index e86439283a5d..4f0c40d405fc 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -491,7 +491,7 @@ static void acpiphp_bus_add(acpi_handle handle)
491 491
492 acpi_bus_scan(handle); 492 acpi_bus_scan(handle);
493 acpi_bus_get_device(handle, &adev); 493 acpi_bus_get_device(handle, &adev);
494 if (adev) 494 if (acpi_device_enumerated(adev))
495 acpi_device_set_power(adev, ACPI_STATE_D0); 495 acpi_device_set_power(adev, ACPI_STATE_D0);
496} 496}
497 497
diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
index ecfac7e72d91..8dcccffd6e21 100644
--- a/drivers/pci/hotplug/acpiphp_ibm.c
+++ b/drivers/pci/hotplug/acpiphp_ibm.c
@@ -31,12 +31,11 @@
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/module.h> 32#include <linux/module.h>
33#include <linux/kernel.h> 33#include <linux/kernel.h>
34#include <acpi/acpi_bus.h>
35#include <linux/sysfs.h> 34#include <linux/sysfs.h>
36#include <linux/kobject.h> 35#include <linux/kobject.h>
37#include <asm/uaccess.h>
38#include <linux/moduleparam.h> 36#include <linux/moduleparam.h>
39#include <linux/pci.h> 37#include <linux/pci.h>
38#include <asm/uaccess.h>
40 39
41#include "acpiphp.h" 40#include "acpiphp.h"
42#include "../pci.h" 41#include "../pci.h"
diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h
index 21e865ded1dc..24e147cae667 100644
--- a/drivers/pci/hotplug/pciehp.h
+++ b/drivers/pci/hotplug/pciehp.h
@@ -163,8 +163,6 @@ static inline const char *slot_name(struct slot *slot)
163} 163}
164 164
165#ifdef CONFIG_ACPI 165#ifdef CONFIG_ACPI
166#include <acpi/acpi.h>
167#include <acpi/acpi_bus.h>
168#include <linux/pci-acpi.h> 166#include <linux/pci-acpi.h>
169 167
170void __init pciehp_acpi_slot_detection_init(void); 168void __init pciehp_acpi_slot_detection_init(void);
diff --git a/drivers/pci/ioapic.c b/drivers/pci/ioapic.c
index 50ce68098298..2122b2bf006f 100644
--- a/drivers/pci/ioapic.c
+++ b/drivers/pci/ioapic.c
@@ -20,7 +20,6 @@
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/acpi.h> 21#include <linux/acpi.h>
22#include <linux/slab.h> 22#include <linux/slab.h>
23#include <acpi/acpi_bus.h>
24 23
25struct ioapic { 24struct ioapic {
26 acpi_handle handle; 25 acpi_handle handle;
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index f7ebdba14bde..733a8222b13f 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -12,9 +12,6 @@
12#include <linux/pci.h> 12#include <linux/pci.h>
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/pci-aspm.h> 14#include <linux/pci-aspm.h>
15#include <acpi/acpi.h>
16#include <acpi/acpi_bus.h>
17
18#include <linux/pci-acpi.h> 15#include <linux/pci-acpi.h>
19#include <linux/pm_runtime.h> 16#include <linux/pm_runtime.h>
20#include <linux/pm_qos.h> 17#include <linux/pm_qos.h>
@@ -306,10 +303,10 @@ void acpi_pci_remove_bus(struct pci_bus *bus)
306} 303}
307 304
308/* ACPI bus type */ 305/* ACPI bus type */
309static int acpi_pci_find_device(struct device *dev, acpi_handle *handle) 306static struct acpi_device *acpi_pci_find_companion(struct device *dev)
310{ 307{
311 struct pci_dev *pci_dev = to_pci_dev(dev); 308 struct pci_dev *pci_dev = to_pci_dev(dev);
312 bool is_bridge; 309 bool check_children;
313 u64 addr; 310 u64 addr;
314 311
315 /* 312 /*
@@ -317,14 +314,12 @@ static int acpi_pci_find_device(struct device *dev, acpi_handle *handle)
317 * is set only after acpi_pci_find_device() has been called for the 314 * is set only after acpi_pci_find_device() has been called for the
318 * given device. 315 * given device.
319 */ 316 */
320 is_bridge = pci_dev->hdr_type == PCI_HEADER_TYPE_BRIDGE 317 check_children = pci_dev->hdr_type == PCI_HEADER_TYPE_BRIDGE
321 || pci_dev->hdr_type == PCI_HEADER_TYPE_CARDBUS; 318 || pci_dev->hdr_type == PCI_HEADER_TYPE_CARDBUS;
322 /* Please ref to ACPI spec for the syntax of _ADR */ 319 /* Please ref to ACPI spec for the syntax of _ADR */
323 addr = (PCI_SLOT(pci_dev->devfn) << 16) | PCI_FUNC(pci_dev->devfn); 320 addr = (PCI_SLOT(pci_dev->devfn) << 16) | PCI_FUNC(pci_dev->devfn);
324 *handle = acpi_find_child(ACPI_HANDLE(dev->parent), addr, is_bridge); 321 return acpi_find_child_device(ACPI_COMPANION(dev->parent), addr,
325 if (!*handle) 322 check_children);
326 return -ENODEV;
327 return 0;
328} 323}
329 324
330static void pci_acpi_setup(struct device *dev) 325static void pci_acpi_setup(struct device *dev)
@@ -367,7 +362,7 @@ static bool pci_acpi_bus_match(struct device *dev)
367static struct acpi_bus_type acpi_pci_bus = { 362static struct acpi_bus_type acpi_pci_bus = {
368 .name = "PCI", 363 .name = "PCI",
369 .match = pci_acpi_bus_match, 364 .match = pci_acpi_bus_match,
370 .find_device = acpi_pci_find_device, 365 .find_companion = acpi_pci_find_companion,
371 .setup = pci_acpi_setup, 366 .setup = pci_acpi_setup,
372 .cleanup = pci_acpi_cleanup, 367 .cleanup = pci_acpi_cleanup,
373}; 368};
diff --git a/drivers/pci/pci-label.c b/drivers/pci/pci-label.c
index d51f45aa669e..d2d1ceccad4b 100644
--- a/drivers/pci/pci-label.c
+++ b/drivers/pci/pci-label.c
@@ -29,7 +29,6 @@
29#include <linux/nls.h> 29#include <linux/nls.h>
30#include <linux/acpi.h> 30#include <linux/acpi.h>
31#include <linux/pci-acpi.h> 31#include <linux/pci-acpi.h>
32#include <acpi/acpi_bus.h>
33#include "pci.h" 32#include "pci.h"
34 33
35#define DEVICE_LABEL_DSM 0x07 34#define DEVICE_LABEL_DSM 0x07
@@ -187,7 +186,6 @@ static const char device_label_dsm_uuid[] = {
187}; 186};
188 187
189enum acpi_attr_enum { 188enum acpi_attr_enum {
190 ACPI_ATTR_NONE = 0,
191 ACPI_ATTR_LABEL_SHOW, 189 ACPI_ATTR_LABEL_SHOW,
192 ACPI_ATTR_INDEX_SHOW, 190 ACPI_ATTR_INDEX_SHOW,
193}; 191};
@@ -195,84 +193,61 @@ enum acpi_attr_enum {
195static void dsm_label_utf16s_to_utf8s(union acpi_object *obj, char *buf) 193static void dsm_label_utf16s_to_utf8s(union acpi_object *obj, char *buf)
196{ 194{
197 int len; 195 int len;
198 len = utf16s_to_utf8s((const wchar_t *)obj-> 196 len = utf16s_to_utf8s((const wchar_t *)obj->string.pointer,
199 package.elements[1].string.pointer, 197 obj->string.length,
200 obj->package.elements[1].string.length,
201 UTF16_LITTLE_ENDIAN, 198 UTF16_LITTLE_ENDIAN,
202 buf, PAGE_SIZE); 199 buf, PAGE_SIZE);
203 buf[len] = '\n'; 200 buf[len] = '\n';
204} 201}
205 202
206static int 203static int
207dsm_get_label(acpi_handle handle, int func, 204dsm_get_label(struct device *dev, char *buf, enum acpi_attr_enum attr)
208 struct acpi_buffer *output,
209 char *buf, enum acpi_attr_enum attribute)
210{ 205{
211 struct acpi_object_list input; 206 acpi_handle handle;
212 union acpi_object params[4]; 207 union acpi_object *obj, *tmp;
213 union acpi_object *obj; 208 int len = -1;
214 int len = 0; 209
215 210 handle = ACPI_HANDLE(dev);
216 int err; 211 if (!handle)
217
218 input.count = 4;
219 input.pointer = params;
220 params[0].type = ACPI_TYPE_BUFFER;
221 params[0].buffer.length = sizeof(device_label_dsm_uuid);
222 params[0].buffer.pointer = (char *)device_label_dsm_uuid;
223 params[1].type = ACPI_TYPE_INTEGER;
224 params[1].integer.value = 0x02;
225 params[2].type = ACPI_TYPE_INTEGER;
226 params[2].integer.value = func;
227 params[3].type = ACPI_TYPE_PACKAGE;
228 params[3].package.count = 0;
229 params[3].package.elements = NULL;
230
231 err = acpi_evaluate_object(handle, "_DSM", &input, output);
232 if (err)
233 return -1; 212 return -1;
234 213
235 obj = (union acpi_object *)output->pointer; 214 obj = acpi_evaluate_dsm(handle, device_label_dsm_uuid, 0x2,
236 215 DEVICE_LABEL_DSM, NULL);
237 switch (obj->type) { 216 if (!obj)
238 case ACPI_TYPE_PACKAGE: 217 return -1;
239 if (obj->package.count != 2) 218
240 break; 219 tmp = obj->package.elements;
241 len = obj->package.elements[0].integer.value; 220 if (obj->type == ACPI_TYPE_PACKAGE && obj->package.count == 2 &&
242 if (buf) { 221 tmp[0].type == ACPI_TYPE_INTEGER &&
243 if (attribute == ACPI_ATTR_INDEX_SHOW) 222 tmp[1].type == ACPI_TYPE_STRING) {
244 scnprintf(buf, PAGE_SIZE, "%llu\n", 223 /*
245 obj->package.elements[0].integer.value); 224 * The second string element is optional even when
246 else if (attribute == ACPI_ATTR_LABEL_SHOW) 225 * this _DSM is implemented; when not implemented,
247 dsm_label_utf16s_to_utf8s(obj, buf); 226 * this entry must return a null string.
248 kfree(output->pointer); 227 */
249 return strlen(buf); 228 if (attr == ACPI_ATTR_INDEX_SHOW)
250 } 229 scnprintf(buf, PAGE_SIZE, "%llu\n", tmp->integer.value);
251 kfree(output->pointer); 230 else if (attr == ACPI_ATTR_LABEL_SHOW)
252 return len; 231 dsm_label_utf16s_to_utf8s(tmp + 1, buf);
253 break; 232 len = strlen(buf) > 0 ? strlen(buf) : -1;
254 default:
255 kfree(output->pointer);
256 } 233 }
257 return -1; 234
235 ACPI_FREE(obj);
236
237 return len;
258} 238}
259 239
260static bool 240static bool
261device_has_dsm(struct device *dev) 241device_has_dsm(struct device *dev)
262{ 242{
263 acpi_handle handle; 243 acpi_handle handle;
264 struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL};
265 244
266 handle = ACPI_HANDLE(dev); 245 handle = ACPI_HANDLE(dev);
267
268 if (!handle) 246 if (!handle)
269 return FALSE; 247 return false;
270 248
271 if (dsm_get_label(handle, DEVICE_LABEL_DSM, &output, NULL, 249 return !!acpi_check_dsm(handle, device_label_dsm_uuid, 0x2,
272 ACPI_ATTR_NONE) > 0) 250 1 << DEVICE_LABEL_DSM);
273 return TRUE;
274
275 return FALSE;
276} 251}
277 252
278static umode_t 253static umode_t
@@ -291,44 +266,13 @@ acpi_index_string_exist(struct kobject *kobj, struct attribute *attr, int n)
291static ssize_t 266static ssize_t
292acpilabel_show(struct device *dev, struct device_attribute *attr, char *buf) 267acpilabel_show(struct device *dev, struct device_attribute *attr, char *buf)
293{ 268{
294 struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL}; 269 return dsm_get_label(dev, buf, ACPI_ATTR_LABEL_SHOW);
295 acpi_handle handle;
296 int length;
297
298 handle = ACPI_HANDLE(dev);
299
300 if (!handle)
301 return -1;
302
303 length = dsm_get_label(handle, DEVICE_LABEL_DSM,
304 &output, buf, ACPI_ATTR_LABEL_SHOW);
305
306 if (length < 1)
307 return -1;
308
309 return length;
310} 270}
311 271
312static ssize_t 272static ssize_t
313acpiindex_show(struct device *dev, struct device_attribute *attr, char *buf) 273acpiindex_show(struct device *dev, struct device_attribute *attr, char *buf)
314{ 274{
315 struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL}; 275 return dsm_get_label(dev, buf, ACPI_ATTR_INDEX_SHOW);
316 acpi_handle handle;
317 int length;
318
319 handle = ACPI_HANDLE(dev);
320
321 if (!handle)
322 return -1;
323
324 length = dsm_get_label(handle, DEVICE_LABEL_DSM,
325 &output, buf, ACPI_ATTR_INDEX_SHOW);
326
327 if (length < 0)
328 return -1;
329
330 return length;
331
332} 276}
333 277
334static struct device_attribute acpi_attr_label = { 278static struct device_attribute acpi_attr_label = {
diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
index c9076bdaf2c1..c91f69b39db4 100644
--- a/drivers/platform/x86/acer-wmi.c
+++ b/drivers/platform/x86/acer-wmi.c
@@ -41,8 +41,6 @@
41#include <linux/slab.h> 41#include <linux/slab.h>
42#include <linux/input.h> 42#include <linux/input.h>
43#include <linux/input/sparse-keymap.h> 43#include <linux/input/sparse-keymap.h>
44
45#include <acpi/acpi_drivers.h>
46#include <acpi/video.h> 44#include <acpi/video.h>
47 45
48MODULE_AUTHOR("Carlos Corbacho"); 46MODULE_AUTHOR("Carlos Corbacho");
diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c
index 594323a926cf..7f4dc6f51f8a 100644
--- a/drivers/platform/x86/asus-laptop.c
+++ b/drivers/platform/x86/asus-laptop.c
@@ -53,8 +53,7 @@
53#include <linux/rfkill.h> 53#include <linux/rfkill.h>
54#include <linux/slab.h> 54#include <linux/slab.h>
55#include <linux/dmi.h> 55#include <linux/dmi.h>
56#include <acpi/acpi_drivers.h> 56#include <linux/acpi.h>
57#include <acpi/acpi_bus.h>
58 57
59#define ASUS_LAPTOP_VERSION "0.42" 58#define ASUS_LAPTOP_VERSION "0.42"
60 59
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 19c313b056c3..df7ecb9ecd9d 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -45,8 +45,7 @@
45#include <linux/seq_file.h> 45#include <linux/seq_file.h>
46#include <linux/platform_device.h> 46#include <linux/platform_device.h>
47#include <linux/thermal.h> 47#include <linux/thermal.h>
48#include <acpi/acpi_bus.h> 48#include <linux/acpi.h>
49#include <acpi/acpi_drivers.h>
50#include <acpi/video.h> 49#include <acpi/video.h>
51 50
52#include "asus-wmi.h" 51#include "asus-wmi.h"
diff --git a/drivers/platform/x86/classmate-laptop.c b/drivers/platform/x86/classmate-laptop.c
index 6dfa8d3b4eec..70d355a9ae2c 100644
--- a/drivers/platform/x86/classmate-laptop.c
+++ b/drivers/platform/x86/classmate-laptop.c
@@ -21,14 +21,13 @@
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/slab.h> 22#include <linux/slab.h>
23#include <linux/workqueue.h> 23#include <linux/workqueue.h>
24#include <acpi/acpi_drivers.h> 24#include <linux/acpi.h>
25#include <linux/backlight.h> 25#include <linux/backlight.h>
26#include <linux/input.h> 26#include <linux/input.h>
27#include <linux/rfkill.h> 27#include <linux/rfkill.h>
28 28
29MODULE_LICENSE("GPL"); 29MODULE_LICENSE("GPL");
30 30
31
32struct cmpc_accel { 31struct cmpc_accel {
33 int sensitivity; 32 int sensitivity;
34 int g_select; 33 int g_select;
diff --git a/drivers/platform/x86/dell-wmi-aio.c b/drivers/platform/x86/dell-wmi-aio.c
index bcf8cc6b5537..dbc97a33bbc8 100644
--- a/drivers/platform/x86/dell-wmi-aio.c
+++ b/drivers/platform/x86/dell-wmi-aio.c
@@ -24,7 +24,6 @@
24#include <linux/types.h> 24#include <linux/types.h>
25#include <linux/input.h> 25#include <linux/input.h>
26#include <linux/input/sparse-keymap.h> 26#include <linux/input/sparse-keymap.h>
27#include <acpi/acpi_drivers.h>
28#include <linux/acpi.h> 27#include <linux/acpi.h>
29#include <linux/string.h> 28#include <linux/string.h>
30 29
diff --git a/drivers/platform/x86/dell-wmi.c b/drivers/platform/x86/dell-wmi.c
index 60e0900bc117..390e8e33d5e3 100644
--- a/drivers/platform/x86/dell-wmi.c
+++ b/drivers/platform/x86/dell-wmi.c
@@ -32,7 +32,6 @@
32#include <linux/types.h> 32#include <linux/types.h>
33#include <linux/input.h> 33#include <linux/input.h>
34#include <linux/input/sparse-keymap.h> 34#include <linux/input/sparse-keymap.h>
35#include <acpi/acpi_drivers.h>
36#include <linux/acpi.h> 35#include <linux/acpi.h>
37#include <linux/string.h> 36#include <linux/string.h>
38#include <linux/dmi.h> 37#include <linux/dmi.h>
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index dec68e7a99c7..bcde1ea02dd3 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -28,8 +28,7 @@
28#include <linux/hwmon.h> 28#include <linux/hwmon.h>
29#include <linux/hwmon-sysfs.h> 29#include <linux/hwmon-sysfs.h>
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <acpi/acpi_drivers.h> 31#include <linux/acpi.h>
32#include <acpi/acpi_bus.h>
33#include <linux/uaccess.h> 32#include <linux/uaccess.h>
34#include <linux/input.h> 33#include <linux/input.h>
35#include <linux/input/sparse-keymap.h> 34#include <linux/input/sparse-keymap.h>
diff --git a/drivers/platform/x86/eeepc-wmi.c b/drivers/platform/x86/eeepc-wmi.c
index af67e6e56ebb..6112933f6278 100644
--- a/drivers/platform/x86/eeepc-wmi.c
+++ b/drivers/platform/x86/eeepc-wmi.c
@@ -33,7 +33,7 @@
33#include <linux/input/sparse-keymap.h> 33#include <linux/input/sparse-keymap.h>
34#include <linux/dmi.h> 34#include <linux/dmi.h>
35#include <linux/fb.h> 35#include <linux/fb.h>
36#include <acpi/acpi_bus.h> 36#include <linux/acpi.h>
37 37
38#include "asus-wmi.h" 38#include "asus-wmi.h"
39 39
diff --git a/drivers/platform/x86/hp_accel.c b/drivers/platform/x86/hp_accel.c
index a8e43cf70fac..aff4d0670edf 100644
--- a/drivers/platform/x86/hp_accel.c
+++ b/drivers/platform/x86/hp_accel.c
@@ -36,7 +36,7 @@
36#include <linux/uaccess.h> 36#include <linux/uaccess.h>
37#include <linux/leds.h> 37#include <linux/leds.h>
38#include <linux/atomic.h> 38#include <linux/atomic.h>
39#include <acpi/acpi_drivers.h> 39#include <linux/acpi.h>
40#include "../../misc/lis3lv02d/lis3lv02d.h" 40#include "../../misc/lis3lv02d/lis3lv02d.h"
41 41
42#define DRIVER_NAME "hp_accel" 42#define DRIVER_NAME "hp_accel"
diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
index 19ec95147f69..6dd060a0bb65 100644
--- a/drivers/platform/x86/ideapad-laptop.c
+++ b/drivers/platform/x86/ideapad-laptop.c
@@ -26,8 +26,7 @@
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/types.h> 28#include <linux/types.h>
29#include <acpi/acpi_bus.h> 29#include <linux/acpi.h>
30#include <acpi/acpi_drivers.h>
31#include <linux/rfkill.h> 30#include <linux/rfkill.h>
32#include <linux/platform_device.h> 31#include <linux/platform_device.h>
33#include <linux/input.h> 32#include <linux/input.h>
diff --git a/drivers/platform/x86/intel-rst.c b/drivers/platform/x86/intel-rst.c
index a2083a9e5662..d45bca34bf1b 100644
--- a/drivers/platform/x86/intel-rst.c
+++ b/drivers/platform/x86/intel-rst.c
@@ -20,7 +20,7 @@
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/slab.h> 22#include <linux/slab.h>
23#include <acpi/acpi_drivers.h> 23#include <linux/acpi.h>
24 24
25MODULE_LICENSE("GPL"); 25MODULE_LICENSE("GPL");
26 26
diff --git a/drivers/platform/x86/intel-smartconnect.c b/drivers/platform/x86/intel-smartconnect.c
index 1838400dc036..04cf5dffdfd9 100644
--- a/drivers/platform/x86/intel-smartconnect.c
+++ b/drivers/platform/x86/intel-smartconnect.c
@@ -19,7 +19,7 @@
19 19
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/module.h> 21#include <linux/module.h>
22#include <acpi/acpi_drivers.h> 22#include <linux/acpi.h>
23 23
24MODULE_LICENSE("GPL"); 24MODULE_LICENSE("GPL");
25 25
diff --git a/drivers/platform/x86/intel_menlow.c b/drivers/platform/x86/intel_menlow.c
index 11244f8703c4..e8b46d2c468c 100644
--- a/drivers/platform/x86/intel_menlow.c
+++ b/drivers/platform/x86/intel_menlow.c
@@ -36,10 +36,8 @@
36#include <linux/types.h> 36#include <linux/types.h>
37#include <linux/pci.h> 37#include <linux/pci.h>
38#include <linux/pm.h> 38#include <linux/pm.h>
39
40#include <linux/thermal.h> 39#include <linux/thermal.h>
41#include <acpi/acpi_bus.h> 40#include <linux/acpi.h>
42#include <acpi/acpi_drivers.h>
43 41
44MODULE_AUTHOR("Thomas Sujith"); 42MODULE_AUTHOR("Thomas Sujith");
45MODULE_AUTHOR("Zhang Rui"); 43MODULE_AUTHOR("Zhang Rui");
diff --git a/drivers/platform/x86/intel_oaktrail.c b/drivers/platform/x86/intel_oaktrail.c
index f6f18cde0f11..4bc960416785 100644
--- a/drivers/platform/x86/intel_oaktrail.c
+++ b/drivers/platform/x86/intel_oaktrail.c
@@ -50,9 +50,6 @@
50#include <linux/platform_device.h> 50#include <linux/platform_device.h>
51#include <linux/dmi.h> 51#include <linux/dmi.h>
52#include <linux/rfkill.h> 52#include <linux/rfkill.h>
53#include <acpi/acpi_bus.h>
54#include <acpi/acpi_drivers.h>
55
56 53
57#define DRIVER_NAME "intel_oaktrail" 54#define DRIVER_NAME "intel_oaktrail"
58#define DRIVER_VERSION "0.4ac1" 55#define DRIVER_VERSION "0.4ac1"
diff --git a/drivers/platform/x86/mxm-wmi.c b/drivers/platform/x86/mxm-wmi.c
index 0aea63b3729a..3c59c0a3ee0f 100644
--- a/drivers/platform/x86/mxm-wmi.c
+++ b/drivers/platform/x86/mxm-wmi.c
@@ -20,8 +20,7 @@
20#include <linux/kernel.h> 20#include <linux/kernel.h>
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/init.h> 22#include <linux/init.h>
23#include <acpi/acpi_bus.h> 23#include <linux/acpi.h>
24#include <acpi/acpi_drivers.h>
25 24
26MODULE_AUTHOR("Dave Airlie"); 25MODULE_AUTHOR("Dave Airlie");
27MODULE_DESCRIPTION("MXM WMI Driver"); 26MODULE_DESCRIPTION("MXM WMI Driver");
diff --git a/drivers/platform/x86/panasonic-laptop.c b/drivers/platform/x86/panasonic-laptop.c
index 3008fd20572e..609d38779b26 100644
--- a/drivers/platform/x86/panasonic-laptop.c
+++ b/drivers/platform/x86/panasonic-laptop.c
@@ -125,12 +125,10 @@
125#include <linux/seq_file.h> 125#include <linux/seq_file.h>
126#include <linux/uaccess.h> 126#include <linux/uaccess.h>
127#include <linux/slab.h> 127#include <linux/slab.h>
128#include <acpi/acpi_bus.h> 128#include <linux/acpi.h>
129#include <acpi/acpi_drivers.h>
130#include <linux/input.h> 129#include <linux/input.h>
131#include <linux/input/sparse-keymap.h> 130#include <linux/input/sparse-keymap.h>
132 131
133
134#ifndef ACPI_HOTKEY_COMPONENT 132#ifndef ACPI_HOTKEY_COMPONENT
135#define ACPI_HOTKEY_COMPONENT 0x10000000 133#define ACPI_HOTKEY_COMPONENT 0x10000000
136#endif 134#endif
diff --git a/drivers/platform/x86/pvpanic.c b/drivers/platform/x86/pvpanic.c
index 47ae0c47d4b5..c9f6e511daa6 100644
--- a/drivers/platform/x86/pvpanic.c
+++ b/drivers/platform/x86/pvpanic.c
@@ -24,8 +24,7 @@
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/types.h> 26#include <linux/types.h>
27#include <acpi/acpi_bus.h> 27#include <linux/acpi.h>
28#include <acpi/acpi_drivers.h>
29 28
30MODULE_AUTHOR("Hu Tao <hutao@cn.fujitsu.com>"); 29MODULE_AUTHOR("Hu Tao <hutao@cn.fujitsu.com>");
31MODULE_DESCRIPTION("pvpanic device driver"); 30MODULE_DESCRIPTION("pvpanic device driver");
diff --git a/drivers/platform/x86/samsung-q10.c b/drivers/platform/x86/samsung-q10.c
index cae7098e9b0d..5413f62d2e61 100644
--- a/drivers/platform/x86/samsung-q10.c
+++ b/drivers/platform/x86/samsung-q10.c
@@ -15,7 +15,7 @@
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16#include <linux/backlight.h> 16#include <linux/backlight.h>
17#include <linux/dmi.h> 17#include <linux/dmi.h>
18#include <acpi/acpi_drivers.h> 18#include <linux/acpi.h>
19 19
20#define SAMSUNGQ10_BL_MAX_INTENSITY 7 20#define SAMSUNGQ10_BL_MAX_INTENSITY 7
21 21
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index fb233ae7bb0e..563e4f595f83 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -61,9 +61,6 @@
61#include <linux/workqueue.h> 61#include <linux/workqueue.h>
62#include <linux/acpi.h> 62#include <linux/acpi.h>
63#include <linux/slab.h> 63#include <linux/slab.h>
64#include <acpi/acpi_drivers.h>
65#include <acpi/acpi_bus.h>
66#include <asm/uaccess.h>
67#include <linux/sonypi.h> 64#include <linux/sonypi.h>
68#include <linux/sony-laptop.h> 65#include <linux/sony-laptop.h>
69#include <linux/rfkill.h> 66#include <linux/rfkill.h>
@@ -71,6 +68,7 @@
71#include <linux/poll.h> 68#include <linux/poll.h>
72#include <linux/miscdevice.h> 69#include <linux/miscdevice.h>
73#endif 70#endif
71#include <asm/uaccess.h>
74 72
75#define dprintk(fmt, ...) \ 73#define dprintk(fmt, ...) \
76do { \ 74do { \
diff --git a/drivers/platform/x86/tc1100-wmi.c b/drivers/platform/x86/tc1100-wmi.c
index 9b93fdb61ed7..6a6ea28a7e51 100644
--- a/drivers/platform/x86/tc1100-wmi.c
+++ b/drivers/platform/x86/tc1100-wmi.c
@@ -32,9 +32,7 @@
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include <linux/init.h> 33#include <linux/init.h>
34#include <linux/types.h> 34#include <linux/types.h>
35#include <acpi/acpi.h> 35#include <linux/acpi.h>
36#include <acpi/acpi_bus.h>
37#include <acpi/acpi_drivers.h>
38#include <linux/platform_device.h> 36#include <linux/platform_device.h>
39 37
40#define GUID "C364AC71-36DB-495A-8494-B439D472A505" 38#define GUID "C364AC71-36DB-495A-8494-B439D472A505"
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 58b0274d24cc..defb6afc1409 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -61,7 +61,6 @@
61#include <linux/freezer.h> 61#include <linux/freezer.h>
62#include <linux/delay.h> 62#include <linux/delay.h>
63#include <linux/slab.h> 63#include <linux/slab.h>
64
65#include <linux/nvram.h> 64#include <linux/nvram.h>
66#include <linux/proc_fs.h> 65#include <linux/proc_fs.h>
67#include <linux/seq_file.h> 66#include <linux/seq_file.h>
@@ -74,21 +73,16 @@
74#include <linux/input.h> 73#include <linux/input.h>
75#include <linux/leds.h> 74#include <linux/leds.h>
76#include <linux/rfkill.h> 75#include <linux/rfkill.h>
77#include <asm/uaccess.h>
78
79#include <linux/dmi.h> 76#include <linux/dmi.h>
80#include <linux/jiffies.h> 77#include <linux/jiffies.h>
81#include <linux/workqueue.h> 78#include <linux/workqueue.h>
82 79#include <linux/acpi.h>
80#include <linux/pci_ids.h>
81#include <linux/thinkpad_acpi.h>
83#include <sound/core.h> 82#include <sound/core.h>
84#include <sound/control.h> 83#include <sound/control.h>
85#include <sound/initval.h> 84#include <sound/initval.h>
86 85#include <asm/uaccess.h>
87#include <acpi/acpi_drivers.h>
88
89#include <linux/pci_ids.h>
90
91#include <linux/thinkpad_acpi.h>
92 86
93/* ThinkPad CMOS commands */ 87/* ThinkPad CMOS commands */
94#define TP_CMOS_VOLUME_DOWN 0 88#define TP_CMOS_VOLUME_DOWN 0
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index 7fce391818d3..7ad1ed091f92 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -54,11 +54,9 @@
54#include <linux/slab.h> 54#include <linux/slab.h>
55#include <linux/workqueue.h> 55#include <linux/workqueue.h>
56#include <linux/i8042.h> 56#include <linux/i8042.h>
57 57#include <linux/acpi.h>
58#include <asm/uaccess.h> 58#include <asm/uaccess.h>
59 59
60#include <acpi/acpi_drivers.h>
61
62MODULE_AUTHOR("John Belmonte"); 60MODULE_AUTHOR("John Belmonte");
63MODULE_DESCRIPTION("Toshiba Laptop ACPI Extras Driver"); 61MODULE_DESCRIPTION("Toshiba Laptop ACPI Extras Driver");
64MODULE_LICENSE("GPL"); 62MODULE_LICENSE("GPL");
diff --git a/drivers/platform/x86/toshiba_bluetooth.c b/drivers/platform/x86/toshiba_bluetooth.c
index 74dd01ae343b..2cb1ea62b4a7 100644
--- a/drivers/platform/x86/toshiba_bluetooth.c
+++ b/drivers/platform/x86/toshiba_bluetooth.c
@@ -23,14 +23,12 @@
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/types.h> 25#include <linux/types.h>
26#include <acpi/acpi_bus.h> 26#include <linux/acpi.h>
27#include <acpi/acpi_drivers.h>
28 27
29MODULE_AUTHOR("Jes Sorensen <Jes.Sorensen@gmail.com>"); 28MODULE_AUTHOR("Jes Sorensen <Jes.Sorensen@gmail.com>");
30MODULE_DESCRIPTION("Toshiba Laptop ACPI Bluetooth Enable Driver"); 29MODULE_DESCRIPTION("Toshiba Laptop ACPI Bluetooth Enable Driver");
31MODULE_LICENSE("GPL"); 30MODULE_LICENSE("GPL");
32 31
33
34static int toshiba_bt_rfkill_add(struct acpi_device *device); 32static int toshiba_bt_rfkill_add(struct acpi_device *device);
35static int toshiba_bt_rfkill_remove(struct acpi_device *device); 33static int toshiba_bt_rfkill_remove(struct acpi_device *device);
36static void toshiba_bt_rfkill_notify(struct acpi_device *device, u32 event); 34static void toshiba_bt_rfkill_notify(struct acpi_device *device, u32 event);
diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index c2e7b2657aeb..43d13295e63d 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -37,8 +37,6 @@
37#include <linux/acpi.h> 37#include <linux/acpi.h>
38#include <linux/slab.h> 38#include <linux/slab.h>
39#include <linux/module.h> 39#include <linux/module.h>
40#include <acpi/acpi_bus.h>
41#include <acpi/acpi_drivers.h>
42 40
43ACPI_MODULE_NAME("wmi"); 41ACPI_MODULE_NAME("wmi");
44MODULE_AUTHOR("Carlos Corbacho"); 42MODULE_AUTHOR("Carlos Corbacho");
diff --git a/drivers/platform/x86/xo15-ebook.c b/drivers/platform/x86/xo15-ebook.c
index 4b1377bd5944..49cbccec6e2d 100644
--- a/drivers/platform/x86/xo15-ebook.c
+++ b/drivers/platform/x86/xo15-ebook.c
@@ -18,8 +18,7 @@
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/types.h> 19#include <linux/types.h>
20#include <linux/input.h> 20#include <linux/input.h>
21#include <acpi/acpi_bus.h> 21#include <linux/acpi.h>
22#include <acpi/acpi_drivers.h>
23 22
24#define MODULE_NAME "xo15-ebook" 23#define MODULE_NAME "xo15-ebook"
25 24
diff --git a/drivers/pnp/card.c b/drivers/pnp/card.c
index bc00693d0c79..874c236ac1a7 100644
--- a/drivers/pnp/card.c
+++ b/drivers/pnp/card.c
@@ -239,6 +239,7 @@ int pnp_add_card(struct pnp_card *card)
239 error = device_register(&card->dev); 239 error = device_register(&card->dev);
240 if (error) { 240 if (error) {
241 dev_err(&card->dev, "could not register (err=%d)\n", error); 241 dev_err(&card->dev, "could not register (err=%d)\n", error);
242 put_device(&card->dev);
242 return error; 243 return error;
243 } 244 }
244 245
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index 14655a0f0431..9f611cbbc294 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -24,7 +24,6 @@
24#include <linux/pnp.h> 24#include <linux/pnp.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/mod_devicetable.h> 26#include <linux/mod_devicetable.h>
27#include <acpi/acpi_bus.h>
28 27
29#include "../base.h" 28#include "../base.h"
30#include "pnpacpi.h" 29#include "pnpacpi.h"
@@ -242,6 +241,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
242 struct pnp_dev *dev; 241 struct pnp_dev *dev;
243 char *pnpid; 242 char *pnpid;
244 struct acpi_hardware_id *id; 243 struct acpi_hardware_id *id;
244 int error;
245 245
246 /* Skip devices that are already bound */ 246 /* Skip devices that are already bound */
247 if (device->physical_node_count) 247 if (device->physical_node_count)
@@ -300,10 +300,16 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
300 /* clear out the damaged flags */ 300 /* clear out the damaged flags */
301 if (!dev->active) 301 if (!dev->active)
302 pnp_init_resources(dev); 302 pnp_init_resources(dev);
303 pnp_add_device(dev); 303
304 error = pnp_add_device(dev);
305 if (error) {
306 put_device(&dev->dev);
307 return error;
308 }
309
304 num++; 310 num++;
305 311
306 return AE_OK; 312 return 0;
307} 313}
308 314
309static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle, 315static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle,
@@ -329,20 +335,15 @@ static int __init acpi_pnp_match(struct device *dev, void *_pnp)
329 && compare_pnp_id(pnp->id, acpi_device_hid(acpi)); 335 && compare_pnp_id(pnp->id, acpi_device_hid(acpi));
330} 336}
331 337
332static int __init acpi_pnp_find_device(struct device *dev, acpi_handle * handle) 338static struct acpi_device * __init acpi_pnp_find_companion(struct device *dev)
333{ 339{
334 struct device *adev; 340 dev = bus_find_device(&acpi_bus_type, NULL, to_pnp_dev(dev),
335 struct acpi_device *acpi; 341 acpi_pnp_match);
336 342 if (!dev)
337 adev = bus_find_device(&acpi_bus_type, NULL, 343 return NULL;
338 to_pnp_dev(dev), acpi_pnp_match);
339 if (!adev)
340 return -ENODEV;
341 344
342 acpi = to_acpi_device(adev); 345 put_device(dev);
343 *handle = acpi->handle; 346 return to_acpi_device(dev);
344 put_device(adev);
345 return 0;
346} 347}
347 348
348/* complete initialization of a PNPACPI device includes having 349/* complete initialization of a PNPACPI device includes having
@@ -356,7 +357,7 @@ static bool acpi_pnp_bus_match(struct device *dev)
356static struct acpi_bus_type __initdata acpi_pnp_bus = { 357static struct acpi_bus_type __initdata acpi_pnp_bus = {
357 .name = "PNP", 358 .name = "PNP",
358 .match = acpi_pnp_bus_match, 359 .match = acpi_pnp_bus_match,
359 .find_device = acpi_pnp_find_device, 360 .find_companion = acpi_pnp_find_companion,
360}; 361};
361 362
362int pnpacpi_disabled __initdata; 363int pnpacpi_disabled __initdata;
diff --git a/drivers/pnp/pnpacpi/pnpacpi.h b/drivers/pnp/pnpacpi/pnpacpi.h
index 3e60225b0227..051ef9699777 100644
--- a/drivers/pnp/pnpacpi/pnpacpi.h
+++ b/drivers/pnp/pnpacpi/pnpacpi.h
@@ -1,7 +1,6 @@
1#ifndef ACPI_PNP_H 1#ifndef ACPI_PNP_H
2#define ACPI_PNP_H 2#define ACPI_PNP_H
3 3
4#include <acpi/acpi_bus.h>
5#include <linux/acpi.h> 4#include <linux/acpi.h>
6#include <linux/pnp.h> 5#include <linux/pnp.h>
7 6
diff --git a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c
index 9b86a01af631..074569e77d22 100644
--- a/drivers/pnp/pnpbios/core.c
+++ b/drivers/pnp/pnpbios/core.c
@@ -312,18 +312,19 @@ static int __init insert_device(struct pnp_bios_node *node)
312 struct list_head *pos; 312 struct list_head *pos;
313 struct pnp_dev *dev; 313 struct pnp_dev *dev;
314 char id[8]; 314 char id[8];
315 int error;
315 316
316 /* check if the device is already added */ 317 /* check if the device is already added */
317 list_for_each(pos, &pnpbios_protocol.devices) { 318 list_for_each(pos, &pnpbios_protocol.devices) {
318 dev = list_entry(pos, struct pnp_dev, protocol_list); 319 dev = list_entry(pos, struct pnp_dev, protocol_list);
319 if (dev->number == node->handle) 320 if (dev->number == node->handle)
320 return -1; 321 return -EEXIST;
321 } 322 }
322 323
323 pnp_eisa_id_to_string(node->eisa_id & PNP_EISA_ID_MASK, id); 324 pnp_eisa_id_to_string(node->eisa_id & PNP_EISA_ID_MASK, id);
324 dev = pnp_alloc_dev(&pnpbios_protocol, node->handle, id); 325 dev = pnp_alloc_dev(&pnpbios_protocol, node->handle, id);
325 if (!dev) 326 if (!dev)
326 return -1; 327 return -ENOMEM;
327 328
328 pnpbios_parse_data_stream(dev, node); 329 pnpbios_parse_data_stream(dev, node);
329 dev->active = pnp_is_active(dev); 330 dev->active = pnp_is_active(dev);
@@ -342,7 +343,12 @@ static int __init insert_device(struct pnp_bios_node *node)
342 if (!dev->active) 343 if (!dev->active)
343 pnp_init_resources(dev); 344 pnp_init_resources(dev);
344 345
345 pnp_add_device(dev); 346 error = pnp_add_device(dev);
347 if (error) {
348 put_device(&dev->dev);
349 return error;
350 }
351
346 pnpbios_interface_attach_device(node); 352 pnpbios_interface_attach_device(node);
347 353
348 return 0; 354 return 0;
diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
index d95e101ffb43..bacddd102ae9 100644
--- a/drivers/pnp/resource.c
+++ b/drivers/pnp/resource.c
@@ -31,7 +31,7 @@ static int pnp_reserve_mem[16] = {[0 ... 15] = -1 }; /* reserve (don't use) some
31 * option registration 31 * option registration
32 */ 32 */
33 33
34struct pnp_option *pnp_build_option(struct pnp_dev *dev, unsigned long type, 34static struct pnp_option *pnp_build_option(struct pnp_dev *dev, unsigned long type,
35 unsigned int option_flags) 35 unsigned int option_flags)
36{ 36{
37 struct pnp_option *option; 37 struct pnp_option *option;
diff --git a/drivers/sfi/sfi_acpi.c b/drivers/sfi/sfi_acpi.c
index f5b4ca581541..d277b36eb389 100644
--- a/drivers/sfi/sfi_acpi.c
+++ b/drivers/sfi/sfi_acpi.c
@@ -60,9 +60,7 @@
60#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt 60#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
61 61
62#include <linux/kernel.h> 62#include <linux/kernel.h>
63#include <acpi/acpi.h> 63#include <linux/sfi_acpi.h>
64
65#include <linux/sfi.h>
66#include "sfi_core.h" 64#include "sfi_core.h"
67 65
68/* 66/*
diff --git a/drivers/staging/bcm/Bcmnet.c b/drivers/staging/bcm/Bcmnet.c
index 53fee2f9a498..8dfdd2732bdc 100644
--- a/drivers/staging/bcm/Bcmnet.c
+++ b/drivers/staging/bcm/Bcmnet.c
@@ -39,7 +39,8 @@ static INT bcm_close(struct net_device *dev)
39 return 0; 39 return 0;
40} 40}
41 41
42static u16 bcm_select_queue(struct net_device *dev, struct sk_buff *skb) 42static u16 bcm_select_queue(struct net_device *dev, struct sk_buff *skb,
43 void *accel_priv)
43{ 44{
44 return ClassifyPacket(netdev_priv(dev), skb); 45 return ClassifyPacket(netdev_priv(dev), skb);
45} 46}
diff --git a/drivers/staging/netlogic/xlr_net.c b/drivers/staging/netlogic/xlr_net.c
index 235d2b1ec593..eedffed17e39 100644
--- a/drivers/staging/netlogic/xlr_net.c
+++ b/drivers/staging/netlogic/xlr_net.c
@@ -306,7 +306,8 @@ static netdev_tx_t xlr_net_start_xmit(struct sk_buff *skb,
306 return NETDEV_TX_OK; 306 return NETDEV_TX_OK;
307} 307}
308 308
309static u16 xlr_net_select_queue(struct net_device *ndev, struct sk_buff *skb) 309static u16 xlr_net_select_queue(struct net_device *ndev, struct sk_buff *skb,
310 void *accel_priv)
310{ 311{
311 return (u16)smp_processor_id(); 312 return (u16)smp_processor_id();
312} 313}
diff --git a/drivers/staging/quickstart/quickstart.c b/drivers/staging/quickstart/quickstart.c
index 9f6ebdb23740..a85c3d68c462 100644
--- a/drivers/staging/quickstart/quickstart.c
+++ b/drivers/staging/quickstart/quickstart.c
@@ -31,7 +31,7 @@
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/init.h> 32#include <linux/init.h>
33#include <linux/types.h> 33#include <linux/types.h>
34#include <acpi/acpi_drivers.h> 34#include <linux/acpi.h>
35#include <linux/platform_device.h> 35#include <linux/platform_device.h>
36#include <linux/input.h> 36#include <linux/input.h>
37 37
diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c
index 17659bb04bef..dd69e344e409 100644
--- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c
+++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c
@@ -652,7 +652,8 @@ static unsigned int rtw_classify8021d(struct sk_buff *skb)
652 return dscp >> 5; 652 return dscp >> 5;
653} 653}
654 654
655static u16 rtw_select_queue(struct net_device *dev, struct sk_buff *skb) 655static u16 rtw_select_queue(struct net_device *dev, struct sk_buff *skb,
656 void *accel_priv)
656{ 657{
657 struct adapter *padapter = rtw_netdev_priv(dev); 658 struct adapter *padapter = rtw_netdev_priv(dev);
658 struct mlme_priv *pmlmepriv = &padapter->mlmepriv; 659 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
diff --git a/drivers/usb/core/usb-acpi.c b/drivers/usb/core/usb-acpi.c
index 4e243c37f17f..f0155a39aaa3 100644
--- a/drivers/usb/core/usb-acpi.c
+++ b/drivers/usb/core/usb-acpi.c
@@ -16,7 +16,6 @@
16#include <linux/acpi.h> 16#include <linux/acpi.h>
17#include <linux/pci.h> 17#include <linux/pci.h>
18#include <linux/usb/hcd.h> 18#include <linux/usb/hcd.h>
19#include <acpi/acpi_bus.h>
20 19
21#include "usb.h" 20#include "usb.h"
22 21
@@ -127,7 +126,7 @@ out:
127 return ret; 126 return ret;
128} 127}
129 128
130static int usb_acpi_find_device(struct device *dev, acpi_handle *handle) 129static struct acpi_device *usb_acpi_find_companion(struct device *dev)
131{ 130{
132 struct usb_device *udev; 131 struct usb_device *udev;
133 acpi_handle *parent_handle; 132 acpi_handle *parent_handle;
@@ -169,16 +168,15 @@ static int usb_acpi_find_device(struct device *dev, acpi_handle *handle)
169 break; 168 break;
170 } 169 }
171 170
172 return -ENODEV; 171 return NULL;
173 } 172 }
174 173
175 /* root hub's parent is the usb hcd. */ 174 /* root hub's parent is the usb hcd. */
176 parent_handle = ACPI_HANDLE(dev->parent); 175 return acpi_find_child_device(ACPI_COMPANION(dev->parent),
177 *handle = acpi_get_child(parent_handle, udev->portnum); 176 udev->portnum, false);
178 if (!*handle)
179 return -ENODEV;
180 return 0;
181 } else if (is_usb_port(dev)) { 177 } else if (is_usb_port(dev)) {
178 struct acpi_device *adev = NULL;
179
182 sscanf(dev_name(dev), "port%d", &port_num); 180 sscanf(dev_name(dev), "port%d", &port_num);
183 /* Get the struct usb_device point of port's hub */ 181 /* Get the struct usb_device point of port's hub */
184 udev = to_usb_device(dev->parent->parent); 182 udev = to_usb_device(dev->parent->parent);
@@ -194,26 +192,27 @@ static int usb_acpi_find_device(struct device *dev, acpi_handle *handle)
194 192
195 raw_port_num = usb_hcd_find_raw_port_number(hcd, 193 raw_port_num = usb_hcd_find_raw_port_number(hcd,
196 port_num); 194 port_num);
197 *handle = acpi_get_child(ACPI_HANDLE(&udev->dev), 195 adev = acpi_find_child_device(ACPI_COMPANION(&udev->dev),
198 raw_port_num); 196 raw_port_num, false);
199 if (!*handle) 197 if (!adev)
200 return -ENODEV; 198 return NULL;
201 } else { 199 } else {
202 parent_handle = 200 parent_handle =
203 usb_get_hub_port_acpi_handle(udev->parent, 201 usb_get_hub_port_acpi_handle(udev->parent,
204 udev->portnum); 202 udev->portnum);
205 if (!parent_handle) 203 if (!parent_handle)
206 return -ENODEV; 204 return NULL;
207 205
208 *handle = acpi_get_child(parent_handle, port_num); 206 acpi_bus_get_device(parent_handle, &adev);
209 if (!*handle) 207 adev = acpi_find_child_device(adev, port_num, false);
210 return -ENODEV; 208 if (!adev)
209 return NULL;
211 } 210 }
212 usb_acpi_check_port_connect_type(udev, *handle, port_num); 211 usb_acpi_check_port_connect_type(udev, adev->handle, port_num);
213 } else 212 return adev;
214 return -ENODEV; 213 }
215 214
216 return 0; 215 return NULL;
217} 216}
218 217
219static bool usb_acpi_bus_match(struct device *dev) 218static bool usb_acpi_bus_match(struct device *dev)
@@ -224,7 +223,7 @@ static bool usb_acpi_bus_match(struct device *dev)
224static struct acpi_bus_type usb_acpi_bus = { 223static struct acpi_bus_type usb_acpi_bus = {
225 .name = "USB", 224 .name = "USB",
226 .match = usb_acpi_bus_match, 225 .match = usb_acpi_bus_match,
227 .find_device = usb_acpi_find_device, 226 .find_companion = usb_acpi_find_companion,
228}; 227};
229 228
230int usb_acpi_register(void) 229int usb_acpi_register(void)
diff --git a/drivers/xen/xen-acpi-cpuhotplug.c b/drivers/xen/xen-acpi-cpuhotplug.c
index 8dae6c13063a..80875fb770ed 100644
--- a/drivers/xen/xen-acpi-cpuhotplug.c
+++ b/drivers/xen/xen-acpi-cpuhotplug.c
@@ -24,10 +24,7 @@
24#include <linux/cpu.h> 24#include <linux/cpu.h>
25#include <linux/acpi.h> 25#include <linux/acpi.h>
26#include <linux/uaccess.h> 26#include <linux/uaccess.h>
27#include <acpi/acpi_bus.h>
28#include <acpi/acpi_drivers.h>
29#include <acpi/processor.h> 27#include <acpi/processor.h>
30
31#include <xen/acpi.h> 28#include <xen/acpi.h>
32#include <xen/interface/platform.h> 29#include <xen/interface/platform.h>
33#include <asm/xen/hypercall.h> 30#include <asm/xen/hypercall.h>
@@ -269,7 +266,8 @@ static void acpi_processor_hotplug_notify(acpi_handle handle,
269 if (!is_processor_present(handle)) 266 if (!is_processor_present(handle))
270 break; 267 break;
271 268
272 if (!acpi_bus_get_device(handle, &device)) 269 acpi_bus_get_device(handle, &device);
270 if (acpi_device_enumerated(device))
273 break; 271 break;
274 272
275 result = acpi_bus_scan(handle); 273 result = acpi_bus_scan(handle);
@@ -277,8 +275,9 @@ static void acpi_processor_hotplug_notify(acpi_handle handle,
277 pr_err(PREFIX "Unable to add the device\n"); 275 pr_err(PREFIX "Unable to add the device\n");
278 break; 276 break;
279 } 277 }
280 result = acpi_bus_get_device(handle, &device); 278 device = NULL;
281 if (result) { 279 acpi_bus_get_device(handle, &device);
280 if (!acpi_device_enumerated(device)) {
282 pr_err(PREFIX "Missing device object\n"); 281 pr_err(PREFIX "Missing device object\n");
283 break; 282 break;
284 } 283 }
diff --git a/drivers/xen/xen-acpi-memhotplug.c b/drivers/xen/xen-acpi-memhotplug.c
index 9083f1e474f8..f8d18626969a 100644
--- a/drivers/xen/xen-acpi-memhotplug.c
+++ b/drivers/xen/xen-acpi-memhotplug.c
@@ -22,7 +22,6 @@
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/types.h> 23#include <linux/types.h>
24#include <linux/acpi.h> 24#include <linux/acpi.h>
25#include <acpi/acpi_drivers.h>
26#include <xen/acpi.h> 25#include <xen/acpi.h>
27#include <xen/interface/platform.h> 26#include <xen/interface/platform.h>
28#include <asm/xen/hypercall.h> 27#include <asm/xen/hypercall.h>
@@ -169,7 +168,7 @@ static int acpi_memory_get_device(acpi_handle handle,
169 acpi_scan_lock_acquire(); 168 acpi_scan_lock_acquire();
170 169
171 acpi_bus_get_device(handle, &device); 170 acpi_bus_get_device(handle, &device);
172 if (device) 171 if (acpi_device_enumerated(device))
173 goto end; 172 goto end;
174 173
175 /* 174 /*
@@ -182,8 +181,9 @@ static int acpi_memory_get_device(acpi_handle handle,
182 result = -EINVAL; 181 result = -EINVAL;
183 goto out; 182 goto out;
184 } 183 }
185 result = acpi_bus_get_device(handle, &device); 184 device = NULL;
186 if (result) { 185 acpi_bus_get_device(handle, &device);
186 if (!acpi_device_enumerated(device)) {
187 pr_warn(PREFIX "Missing device object\n"); 187 pr_warn(PREFIX "Missing device object\n");
188 result = -EINVAL; 188 result = -EINVAL;
189 goto out; 189 goto out;
diff --git a/drivers/xen/xen-acpi-pad.c b/drivers/xen/xen-acpi-pad.c
index 59708fdd068b..40c4bc06b5fa 100644
--- a/drivers/xen/xen-acpi-pad.c
+++ b/drivers/xen/xen-acpi-pad.c
@@ -18,11 +18,10 @@
18 18
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/types.h> 20#include <linux/types.h>
21#include <acpi/acpi_bus.h> 21#include <linux/acpi.h>
22#include <acpi/acpi_drivers.h>
23#include <asm/xen/hypercall.h>
24#include <xen/interface/version.h> 22#include <xen/interface/version.h>
25#include <xen/xen-ops.h> 23#include <xen/xen-ops.h>
24#include <asm/xen/hypercall.h>
26 25
27#define ACPI_PROCESSOR_AGGREGATOR_CLASS "acpi_pad" 26#define ACPI_PROCESSOR_AGGREGATOR_CLASS "acpi_pad"
28#define ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME "Processor Aggregator" 27#define ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME "Processor Aggregator"
diff --git a/drivers/xen/xen-acpi-processor.c b/drivers/xen/xen-acpi-processor.c
index 13bc6c31c060..7231859119f1 100644
--- a/drivers/xen/xen-acpi-processor.c
+++ b/drivers/xen/xen-acpi-processor.c
@@ -28,10 +28,8 @@
28#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/types.h> 29#include <linux/types.h>
30#include <linux/syscore_ops.h> 30#include <linux/syscore_ops.h>
31#include <acpi/acpi_bus.h> 31#include <linux/acpi.h>
32#include <acpi/acpi_drivers.h>
33#include <acpi/processor.h> 32#include <acpi/processor.h>
34
35#include <xen/xen.h> 33#include <xen/xen.h>
36#include <xen/interface/platform.h> 34#include <xen/interface/platform.h>
37#include <asm/xen/hypercall.h> 35#include <asm/xen/hypercall.h>
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 4410cc3d6ee2..3384dc4bed40 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -4218,7 +4218,7 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
4218 */ 4218 */
4219 map->m_flags &= ~EXT4_MAP_FROM_CLUSTER; 4219 map->m_flags &= ~EXT4_MAP_FROM_CLUSTER;
4220 newex.ee_block = cpu_to_le32(map->m_lblk); 4220 newex.ee_block = cpu_to_le32(map->m_lblk);
4221 cluster_offset = EXT4_LBLK_CMASK(sbi, map->m_lblk); 4221 cluster_offset = EXT4_LBLK_COFF(sbi, map->m_lblk);
4222 4222
4223 /* 4223 /*
4224 * If we are doing bigalloc, check to see if the extent returned 4224 * If we are doing bigalloc, check to see if the extent returned
diff --git a/fs/xfs/xfs_attr_remote.c b/fs/xfs/xfs_attr_remote.c
index 739e0a52deda..5549d69ddb45 100644
--- a/fs/xfs/xfs_attr_remote.c
+++ b/fs/xfs/xfs_attr_remote.c
@@ -110,7 +110,7 @@ xfs_attr3_rmt_verify(
110 if (be32_to_cpu(rmt->rm_bytes) > fsbsize - sizeof(*rmt)) 110 if (be32_to_cpu(rmt->rm_bytes) > fsbsize - sizeof(*rmt))
111 return false; 111 return false;
112 if (be32_to_cpu(rmt->rm_offset) + 112 if (be32_to_cpu(rmt->rm_offset) +
113 be32_to_cpu(rmt->rm_bytes) >= XATTR_SIZE_MAX) 113 be32_to_cpu(rmt->rm_bytes) > XATTR_SIZE_MAX)
114 return false; 114 return false;
115 if (rmt->rm_owner == 0) 115 if (rmt->rm_owner == 0)
116 return false; 116 return false;
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index 1394106ed22d..82e0dab46ee5 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -287,6 +287,7 @@ xfs_bmapi_allocate(
287 INIT_WORK_ONSTACK(&args->work, xfs_bmapi_allocate_worker); 287 INIT_WORK_ONSTACK(&args->work, xfs_bmapi_allocate_worker);
288 queue_work(xfs_alloc_wq, &args->work); 288 queue_work(xfs_alloc_wq, &args->work);
289 wait_for_completion(&done); 289 wait_for_completion(&done);
290 destroy_work_on_stack(&args->work);
290 return args->result; 291 return args->result;
291} 292}
292 293
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index ddabed1f51c2..8256eb4ad057 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -28,8 +28,6 @@
28 28
29#include <linux/device.h> 29#include <linux/device.h>
30 30
31#include <acpi/acpi.h>
32
33/* TBD: Make dynamic */ 31/* TBD: Make dynamic */
34#define ACPI_MAX_HANDLES 10 32#define ACPI_MAX_HANDLES 10
35struct acpi_handle_list { 33struct acpi_handle_list {
@@ -66,6 +64,32 @@ bool acpi_ata_match(acpi_handle handle);
66bool acpi_bay_match(acpi_handle handle); 64bool acpi_bay_match(acpi_handle handle);
67bool acpi_dock_match(acpi_handle handle); 65bool acpi_dock_match(acpi_handle handle);
68 66
67bool acpi_check_dsm(acpi_handle handle, const u8 *uuid, int rev, u64 funcs);
68union acpi_object *acpi_evaluate_dsm(acpi_handle handle, const u8 *uuid,
69 int rev, int func, union acpi_object *argv4);
70
71static inline union acpi_object *
72acpi_evaluate_dsm_typed(acpi_handle handle, const u8 *uuid, int rev, int func,
73 union acpi_object *argv4, acpi_object_type type)
74{
75 union acpi_object *obj;
76
77 obj = acpi_evaluate_dsm(handle, uuid, rev, func, argv4);
78 if (obj && obj->type != type) {
79 ACPI_FREE(obj);
80 obj = NULL;
81 }
82
83 return obj;
84}
85
86#define ACPI_INIT_DSM_ARGV4(cnt, eles) \
87 { \
88 .package.type = ACPI_TYPE_PACKAGE, \
89 .package.count = (cnt), \
90 .package.elements = (eles) \
91 }
92
69#ifdef CONFIG_ACPI 93#ifdef CONFIG_ACPI
70 94
71#include <linux/proc_fs.h> 95#include <linux/proc_fs.h>
@@ -91,17 +115,11 @@ struct acpi_device;
91 * ----------------- 115 * -----------------
92 */ 116 */
93 117
94enum acpi_hotplug_mode {
95 AHM_GENERIC = 0,
96 AHM_CONTAINER,
97 AHM_COUNT
98};
99
100struct acpi_hotplug_profile { 118struct acpi_hotplug_profile {
101 struct kobject kobj; 119 struct kobject kobj;
120 int (*scan_dependent)(struct acpi_device *adev);
102 bool enabled:1; 121 bool enabled:1;
103 bool ignore:1; 122 bool demand_offline:1;
104 enum acpi_hotplug_mode mode;
105}; 123};
106 124
107static inline struct acpi_hotplug_profile *to_acpi_hotplug_profile( 125static inline struct acpi_hotplug_profile *to_acpi_hotplug_profile(
@@ -169,8 +187,10 @@ struct acpi_device_flags {
169 u32 ejectable:1; 187 u32 ejectable:1;
170 u32 power_manageable:1; 188 u32 power_manageable:1;
171 u32 match_driver:1; 189 u32 match_driver:1;
190 u32 initialized:1;
191 u32 visited:1;
172 u32 no_hotplug:1; 192 u32 no_hotplug:1;
173 u32 reserved:26; 193 u32 reserved:24;
174}; 194};
175 195
176/* File System */ 196/* File System */
@@ -300,6 +320,7 @@ struct acpi_device {
300 struct list_head children; 320 struct list_head children;
301 struct list_head node; 321 struct list_head node;
302 struct list_head wakeup_list; 322 struct list_head wakeup_list;
323 struct list_head del_list;
303 struct acpi_device_status status; 324 struct acpi_device_status status;
304 struct acpi_device_flags flags; 325 struct acpi_device_flags flags;
305 struct acpi_device_pnp pnp; 326 struct acpi_device_pnp pnp;
@@ -325,6 +346,11 @@ static inline void *acpi_driver_data(struct acpi_device *d)
325#define to_acpi_device(d) container_of(d, struct acpi_device, dev) 346#define to_acpi_device(d) container_of(d, struct acpi_device, dev)
326#define to_acpi_driver(d) container_of(d, struct acpi_driver, drv) 347#define to_acpi_driver(d) container_of(d, struct acpi_driver, drv)
327 348
349static inline void acpi_set_device_status(struct acpi_device *adev, u32 sta)
350{
351 *((u32 *)&adev->status) = sta;
352}
353
328/* acpi_device.dev.bus == &acpi_bus_type */ 354/* acpi_device.dev.bus == &acpi_bus_type */
329extern struct bus_type acpi_bus_type; 355extern struct bus_type acpi_bus_type;
330 356
@@ -387,6 +413,11 @@ int acpi_match_device_ids(struct acpi_device *device,
387int acpi_create_dir(struct acpi_device *); 413int acpi_create_dir(struct acpi_device *);
388void acpi_remove_dir(struct acpi_device *); 414void acpi_remove_dir(struct acpi_device *);
389 415
416static inline bool acpi_device_enumerated(struct acpi_device *adev)
417{
418 return adev && adev->flags.initialized && adev->flags.visited;
419}
420
390typedef void (*acpi_hp_callback)(void *data, u32 src); 421typedef void (*acpi_hp_callback)(void *data, u32 src);
391 422
392acpi_status acpi_hotplug_execute(acpi_hp_callback func, void *data, u32 src); 423acpi_status acpi_hotplug_execute(acpi_hp_callback func, void *data, u32 src);
@@ -410,7 +441,7 @@ struct acpi_bus_type {
410 struct list_head list; 441 struct list_head list;
411 const char *name; 442 const char *name;
412 bool (*match)(struct device *dev); 443 bool (*match)(struct device *dev);
413 int (*find_device) (struct device *, acpi_handle *); 444 struct acpi_device * (*find_companion)(struct device *);
414 void (*setup)(struct device *); 445 void (*setup)(struct device *);
415 void (*cleanup)(struct device *); 446 void (*cleanup)(struct device *);
416}; 447};
@@ -429,12 +460,9 @@ struct acpi_pci_root {
429}; 460};
430 461
431/* helper */ 462/* helper */
432acpi_handle acpi_find_child(acpi_handle, u64, bool); 463
433static inline acpi_handle acpi_get_child(acpi_handle handle, u64 addr) 464struct acpi_device *acpi_find_child_device(struct acpi_device *parent,
434{ 465 u64 address, bool check_children);
435 return acpi_find_child(handle, addr, false);
436}
437void acpi_preset_companion(struct device *dev, acpi_handle parent, u64 addr);
438int acpi_is_root_bridge(acpi_handle); 466int acpi_is_root_bridge(acpi_handle);
439struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle); 467struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle);
440 468
diff --git a/include/acpi/acpi_drivers.h b/include/acpi/acpi_drivers.h
index 1cedfcb1bd88..b124fdb26046 100644
--- a/include/acpi/acpi_drivers.h
+++ b/include/acpi/acpi_drivers.h
@@ -26,9 +26,6 @@
26#ifndef __ACPI_DRIVERS_H__ 26#ifndef __ACPI_DRIVERS_H__
27#define __ACPI_DRIVERS_H__ 27#define __ACPI_DRIVERS_H__
28 28
29#include <linux/acpi.h>
30#include <acpi/acpi_bus.h>
31
32#define ACPI_MAX_STRING 80 29#define ACPI_MAX_STRING 80
33 30
34/* 31/*
diff --git a/include/linux/acpi_io.h b/include/acpi/acpi_io.h
index b0ffa219993e..2be858018c7f 100644
--- a/include/linux/acpi_io.h
+++ b/include/acpi/acpi_io.h
@@ -2,7 +2,6 @@
2#define _ACPI_IO_H_ 2#define _ACPI_IO_H_
3 3
4#include <linux/io.h> 4#include <linux/io.h>
5#include <acpi/acpi.h>
6 5
7static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys, 6static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys,
8 acpi_size size) 7 acpi_size size)
diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h
index 4278aba96503..d2f16f14b419 100644
--- a/include/acpi/acpixf.h
+++ b/include/acpi/acpixf.h
@@ -46,7 +46,7 @@
46 46
47/* Current ACPICA subsystem version in YYYYMMDD format */ 47/* Current ACPICA subsystem version in YYYYMMDD format */
48 48
49#define ACPI_CA_VERSION 0x20131115 49#define ACPI_CA_VERSION 0x20131218
50 50
51#include <acpi/acconfig.h> 51#include <acpi/acconfig.h>
52#include <acpi/actypes.h> 52#include <acpi/actypes.h>
@@ -54,7 +54,6 @@
54#include <acpi/acbuffer.h> 54#include <acpi/acbuffer.h>
55 55
56extern u8 acpi_gbl_permanent_mmap; 56extern u8 acpi_gbl_permanent_mmap;
57extern u32 acpi_rsdt_forced;
58 57
59/* 58/*
60 * Globals that are publically available 59 * Globals that are publically available
@@ -72,17 +71,19 @@ extern u32 acpi_dbg_layer;
72 71
73/* ACPICA runtime options */ 72/* ACPICA runtime options */
74 73
75extern u8 acpi_gbl_enable_interpreter_slack;
76extern u8 acpi_gbl_all_methods_serialized; 74extern u8 acpi_gbl_all_methods_serialized;
77extern u8 acpi_gbl_create_osi_method;
78extern u8 acpi_gbl_use_default_register_widths;
79extern acpi_name acpi_gbl_trace_method_name;
80extern u32 acpi_gbl_trace_flags;
81extern bool acpi_gbl_enable_aml_debug_object;
82extern u8 acpi_gbl_copy_dsdt_locally; 75extern u8 acpi_gbl_copy_dsdt_locally;
83extern u8 acpi_gbl_truncate_io_addresses; 76extern u8 acpi_gbl_create_osi_method;
84extern u8 acpi_gbl_disable_auto_repair; 77extern u8 acpi_gbl_disable_auto_repair;
85extern u8 acpi_gbl_disable_ssdt_table_load; 78extern u8 acpi_gbl_disable_ssdt_table_load;
79extern u8 acpi_gbl_do_not_use_xsdt;
80extern bool acpi_gbl_enable_aml_debug_object;
81extern u8 acpi_gbl_enable_interpreter_slack;
82extern u32 acpi_gbl_trace_flags;
83extern acpi_name acpi_gbl_trace_method_name;
84extern u8 acpi_gbl_truncate_io_addresses;
85extern u8 acpi_gbl_use32_bit_fadt_addresses;
86extern u8 acpi_gbl_use_default_register_widths;
86 87
87/* 88/*
88 * Hardware-reduced prototypes. All interfaces that use these macros will 89 * Hardware-reduced prototypes. All interfaces that use these macros will
@@ -130,10 +131,9 @@ acpi_status __init acpi_terminate(void);
130 * Miscellaneous global interfaces 131 * Miscellaneous global interfaces
131 */ 132 */
132ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_enable(void)) 133ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_enable(void))
133
134ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_disable(void)) 134ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_disable(void))
135#ifdef ACPI_FUTURE_USAGE 135#ifdef ACPI_FUTURE_USAGE
136 acpi_status acpi_subsystem_status(void); 136acpi_status acpi_subsystem_status(void);
137#endif 137#endif
138 138
139#ifdef ACPI_FUTURE_USAGE 139#ifdef ACPI_FUTURE_USAGE
@@ -278,16 +278,13 @@ ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
278 acpi_install_sci_handler(acpi_sci_handler 278 acpi_install_sci_handler(acpi_sci_handler
279 address, 279 address,
280 void *context)) 280 void *context))
281
282ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 281ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
283 acpi_remove_sci_handler(acpi_sci_handler 282 acpi_remove_sci_handler(acpi_sci_handler
284 address)) 283 address))
285
286ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 284ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
287 acpi_install_global_event_handler 285 acpi_install_global_event_handler
288 (acpi_gbl_event_handler handler, 286 (acpi_gbl_event_handler handler,
289 void *context)) 287 void *context))
290
291ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 288ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
292 acpi_install_fixed_event_handler(u32 289 acpi_install_fixed_event_handler(u32
293 acpi_event, 290 acpi_event,
@@ -295,12 +292,10 @@ ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
295 handler, 292 handler,
296 void 293 void
297 *context)) 294 *context))
298
299ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 295ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
300 acpi_remove_fixed_event_handler(u32 acpi_event, 296 acpi_remove_fixed_event_handler(u32 acpi_event,
301 acpi_event_handler 297 acpi_event_handler
302 handler)) 298 handler))
303
304ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 299ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
305 acpi_install_gpe_handler(acpi_handle 300 acpi_install_gpe_handler(acpi_handle
306 gpe_device, 301 gpe_device,
@@ -309,15 +304,14 @@ ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
309 acpi_gpe_handler 304 acpi_gpe_handler
310 address, 305 address,
311 void *context)) 306 void *context))
312
313ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 307ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
314 acpi_remove_gpe_handler(acpi_handle gpe_device, 308 acpi_remove_gpe_handler(acpi_handle gpe_device,
315 u32 gpe_number, 309 u32 gpe_number,
316 acpi_gpe_handler 310 acpi_gpe_handler
317 address)) 311 address))
318acpi_status acpi_install_notify_handler(acpi_handle device, u32 handler_type, 312acpi_status acpi_install_notify_handler(acpi_handle device, u32 handler_type,
319 acpi_notify_handler handler, 313 acpi_notify_handler handler,
320 void *context); 314 void *context);
321 315
322acpi_status 316acpi_status
323acpi_remove_notify_handler(acpi_handle device, 317acpi_remove_notify_handler(acpi_handle device,
@@ -366,7 +360,6 @@ ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
366 360
367ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 361ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
368 acpi_disable_event(u32 event, u32 flags)) 362 acpi_disable_event(u32 event, u32 flags))
369
370ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_clear_event(u32 event)) 363ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_clear_event(u32 event))
371 364
372ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 365ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
@@ -404,20 +397,16 @@ ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
404 parent_device, 397 parent_device,
405 acpi_handle gpe_device, 398 acpi_handle gpe_device,
406 u32 gpe_number)) 399 u32 gpe_number))
407
408ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 400ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
409 acpi_set_gpe_wake_mask(acpi_handle gpe_device, 401 acpi_set_gpe_wake_mask(acpi_handle gpe_device,
410 u32 gpe_number, 402 u32 gpe_number,
411 u8 action)) 403 u8 action))
412
413ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 404ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
414 acpi_get_gpe_status(acpi_handle gpe_device, 405 acpi_get_gpe_status(acpi_handle gpe_device,
415 u32 gpe_number, 406 u32 gpe_number,
416 acpi_event_status 407 acpi_event_status
417 *event_status)) 408 *event_status))
418
419ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_disable_all_gpes(void)) 409ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_disable_all_gpes(void))
420
421ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_enable_all_runtime_gpes(void)) 410ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_enable_all_runtime_gpes(void))
422 411
423ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 412ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
@@ -431,7 +420,6 @@ ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
431 *gpe_block_address, 420 *gpe_block_address,
432 u32 register_count, 421 u32 register_count,
433 u32 interrupt_number)) 422 u32 interrupt_number))
434
435ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 423ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
436 acpi_remove_gpe_block(acpi_handle gpe_device)) 424 acpi_remove_gpe_block(acpi_handle gpe_device))
437 425
@@ -532,7 +520,6 @@ ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
532#ifdef ACPI_FUTURE_USAGE 520#ifdef ACPI_FUTURE_USAGE
533ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 521ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
534 acpi_get_timer_resolution(u32 *resolution)) 522 acpi_get_timer_resolution(u32 *resolution))
535
536ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_get_timer(u32 *ticks)) 523ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_get_timer(u32 *ticks))
537 524
538ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 525ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
diff --git a/include/acpi/actbl.h b/include/acpi/actbl.h
index 94970880126f..325aeae1fa99 100644
--- a/include/acpi/actbl.h
+++ b/include/acpi/actbl.h
@@ -182,6 +182,9 @@ struct acpi_table_xsdt {
182 u64 table_offset_entry[1]; /* Array of pointers to ACPI tables */ 182 u64 table_offset_entry[1]; /* Array of pointers to ACPI tables */
183}; 183};
184 184
185#define ACPI_RSDT_ENTRY_SIZE (sizeof (u32))
186#define ACPI_XSDT_ENTRY_SIZE (sizeof (u64))
187
185/******************************************************************************* 188/*******************************************************************************
186 * 189 *
187 * FACS - Firmware ACPI Control Structure (FACS) 190 * FACS - Firmware ACPI Control Structure (FACS)
diff --git a/include/acpi/actbl1.h b/include/acpi/actbl1.h
index 556c83ee6b42..4ec8c194bfe5 100644
--- a/include/acpi/actbl1.h
+++ b/include/acpi/actbl1.h
@@ -457,7 +457,7 @@ struct acpi_hest_aer_common {
457 u8 enabled; 457 u8 enabled;
458 u32 records_to_preallocate; 458 u32 records_to_preallocate;
459 u32 max_sections_per_record; 459 u32 max_sections_per_record;
460 u32 bus; 460 u32 bus; /* Bus and Segment numbers */
461 u16 device; 461 u16 device;
462 u16 function; 462 u16 function;
463 u16 device_control; 463 u16 device_control;
@@ -473,6 +473,14 @@ struct acpi_hest_aer_common {
473#define ACPI_HEST_FIRMWARE_FIRST (1) 473#define ACPI_HEST_FIRMWARE_FIRST (1)
474#define ACPI_HEST_GLOBAL (1<<1) 474#define ACPI_HEST_GLOBAL (1<<1)
475 475
476/*
477 * Macros to access the bus/segment numbers in Bus field above:
478 * Bus number is encoded in bits 7:0
479 * Segment number is encoded in bits 23:8
480 */
481#define ACPI_HEST_BUS(bus) ((bus) & 0xFF)
482#define ACPI_HEST_SEGMENT(bus) (((bus) >> 8) & 0xFFFF)
483
476/* Hardware Error Notification */ 484/* Hardware Error Notification */
477 485
478struct acpi_hest_notify { 486struct acpi_hest_notify {
diff --git a/include/acpi/actbl2.h b/include/acpi/actbl2.h
index 40f7ed115452..094a906a0e98 100644
--- a/include/acpi/actbl2.h
+++ b/include/acpi/actbl2.h
@@ -327,6 +327,11 @@ struct acpi_table_dbg2 {
327 u32 info_count; 327 u32 info_count;
328}; 328};
329 329
330struct acpi_dbg2_header {
331 u32 info_offset;
332 u32 info_count;
333};
334
330/* Debug Device Information Subtable */ 335/* Debug Device Information Subtable */
331 336
332struct acpi_dbg2_device { 337struct acpi_dbg2_device {
diff --git a/include/acpi/actbl3.h b/include/acpi/actbl3.h
index e2c0931a3d67..01c2a9013e40 100644
--- a/include/acpi/actbl3.h
+++ b/include/acpi/actbl3.h
@@ -374,16 +374,22 @@ struct acpi_mpst_shared {
374struct acpi_table_pcct { 374struct acpi_table_pcct {
375 struct acpi_table_header header; /* Common ACPI table header */ 375 struct acpi_table_header header; /* Common ACPI table header */
376 u32 flags; 376 u32 flags;
377 u32 latency; 377 u64 reserved;
378 u32 reserved;
379}; 378};
380 379
381/* Values for Flags field above */ 380/* Values for Flags field above */
382 381
383#define ACPI_PCCT_DOORBELL 1 382#define ACPI_PCCT_DOORBELL 1
384 383
384/* Values for subtable type in struct acpi_subtable_header */
385
386enum acpi_pcct_type {
387 ACPI_PCCT_TYPE_GENERIC_SUBSPACE = 0,
388 ACPI_PCCT_TYPE_RESERVED = 1 /* 1 and greater are reserved */
389};
390
385/* 391/*
386 * PCCT subtables 392 * PCCT Subtables, correspond to Type in struct acpi_subtable_header
387 */ 393 */
388 394
389/* 0: Generic Communications Subspace */ 395/* 0: Generic Communications Subspace */
@@ -396,6 +402,9 @@ struct acpi_pcct_subspace {
396 struct acpi_generic_address doorbell_register; 402 struct acpi_generic_address doorbell_register;
397 u64 preserve_mask; 403 u64 preserve_mask;
398 u64 write_mask; 404 u64 write_mask;
405 u32 latency;
406 u32 max_access_rate;
407 u16 min_turnaround_time;
399}; 408};
400 409
401/* 410/*
diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h
index 809b1a0fee7f..68a3ada689c9 100644
--- a/include/acpi/actypes.h
+++ b/include/acpi/actypes.h
@@ -928,8 +928,8 @@ struct acpi_object_list {
928 * Miscellaneous common Data Structures used by the interfaces 928 * Miscellaneous common Data Structures used by the interfaces
929 */ 929 */
930#define ACPI_NO_BUFFER 0 930#define ACPI_NO_BUFFER 0
931#define ACPI_ALLOCATE_BUFFER (acpi_size) (-1) 931#define ACPI_ALLOCATE_BUFFER (acpi_size) (-1) /* Let ACPICA allocate buffer */
932#define ACPI_ALLOCATE_LOCAL_BUFFER (acpi_size) (-2) 932#define ACPI_ALLOCATE_LOCAL_BUFFER (acpi_size) (-2) /* For internal use only (enables tracking) */
933 933
934struct acpi_buffer { 934struct acpi_buffer {
935 acpi_size length; /* Length in bytes of the buffer */ 935 acpi_size length; /* Length in bytes of the buffer */
@@ -937,14 +937,6 @@ struct acpi_buffer {
937}; 937};
938 938
939/* 939/*
940 * Free a buffer created in an struct acpi_buffer via ACPI_ALLOCATE_BUFFER.
941 * Note: We use acpi_os_free here because acpi_os_allocate was used to allocate
942 * the buffer. This purposefully bypasses the internal allocation tracking
943 * mechanism (if it is enabled).
944 */
945#define ACPI_FREE_BUFFER(b) acpi_os_free((b).pointer)
946
947/*
948 * name_type for acpi_get_name 940 * name_type for acpi_get_name
949 */ 941 */
950#define ACPI_FULL_PATHNAME 0 942#define ACPI_FULL_PATHNAME 0
diff --git a/include/acpi/platform/acenv.h b/include/acpi/platform/acenv.h
index 974d3ef7c141..b402eb67af83 100644
--- a/include/acpi/platform/acenv.h
+++ b/include/acpi/platform/acenv.h
@@ -96,13 +96,14 @@
96#endif 96#endif
97 97
98/* 98/*
99 * acpi_bin/acpi_dump/acpi_src/acpi_xtract configuration. All single 99 * acpi_bin/acpi_dump/acpi_src/acpi_xtract/Example configuration. All single
100 * threaded, with no debug output. 100 * threaded, with no debug output.
101 */ 101 */
102#if (defined ACPI_BIN_APP) || \ 102#if (defined ACPI_BIN_APP) || \
103 (defined ACPI_DUMP_APP) || \ 103 (defined ACPI_DUMP_APP) || \
104 (defined ACPI_SRC_APP) || \ 104 (defined ACPI_SRC_APP) || \
105 (defined ACPI_XTRACT_APP) 105 (defined ACPI_XTRACT_APP) || \
106 (defined ACPI_EXAMPLE_APP)
106#define ACPI_APPLICATION 107#define ACPI_APPLICATION
107#define ACPI_SINGLE_THREADED 108#define ACPI_SINGLE_THREADED
108#endif 109#endif
@@ -394,4 +395,13 @@ typedef char *va_list;
394 395
395#endif /* ACPI_USE_SYSTEM_CLIBRARY */ 396#endif /* ACPI_USE_SYSTEM_CLIBRARY */
396 397
398#ifndef ACPI_FILE
399#ifdef ACPI_APPLICATION
400#include <stdio.h>
401#define ACPI_FILE FILE *
402#else
403#define ACPI_FILE void *
404#endif /* ACPI_APPLICATION */
405#endif /* ACPI_FILE */
406
397#endif /* __ACENV_H__ */ 407#endif /* __ACENV_H__ */
diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h
index 28f4f4dba0b6..008aa287c7a9 100644
--- a/include/acpi/platform/aclinux.h
+++ b/include/acpi/platform/aclinux.h
@@ -239,10 +239,6 @@ void acpi_os_unmap_memory(void __iomem * logical_address, acpi_size size);
239 */ 239 */
240void early_acpi_os_unmap_memory(void __iomem * virt, acpi_size size); 240void early_acpi_os_unmap_memory(void __iomem * virt, acpi_size size);
241 241
242void acpi_os_gpe_count(u32 gpe_number);
243
244void acpi_os_fixed_event_count(u32 fixed_event_number);
245
246#endif /* __KERNEL__ */ 242#endif /* __KERNEL__ */
247 243
248#endif /* __ACLINUX_H__ */ 244#endif /* __ACLINUX_H__ */
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index d9099b15b472..3e3247d95fd9 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -42,6 +42,7 @@
42#include <acpi/acpi_bus.h> 42#include <acpi/acpi_bus.h>
43#include <acpi/acpi_drivers.h> 43#include <acpi/acpi_drivers.h>
44#include <acpi/acpi_numa.h> 44#include <acpi/acpi_numa.h>
45#include <acpi/acpi_io.h>
45#include <asm/acpi.h> 46#include <asm/acpi.h>
46 47
47static inline acpi_handle acpi_device_handle(struct acpi_device *adev) 48static inline acpi_handle acpi_device_handle(struct acpi_device *adev)
@@ -53,6 +54,12 @@ static inline acpi_handle acpi_device_handle(struct acpi_device *adev)
53#define ACPI_COMPANION_SET(dev, adev) ACPI_COMPANION(dev) = (adev) 54#define ACPI_COMPANION_SET(dev, adev) ACPI_COMPANION(dev) = (adev)
54#define ACPI_HANDLE(dev) acpi_device_handle(ACPI_COMPANION(dev)) 55#define ACPI_HANDLE(dev) acpi_device_handle(ACPI_COMPANION(dev))
55 56
57static inline void acpi_preset_companion(struct device *dev,
58 struct acpi_device *parent, u64 addr)
59{
60 ACPI_COMPANION_SET(dev, acpi_find_child_device(parent, addr, NULL));
61}
62
56static inline const char *acpi_dev_name(struct acpi_device *adev) 63static inline const char *acpi_dev_name(struct acpi_device *adev)
57{ 64{
58 return dev_name(&adev->dev); 65 return dev_name(&adev->dev);
@@ -460,7 +467,7 @@ struct acpi_table_header;
460static inline int acpi_table_parse(char *id, 467static inline int acpi_table_parse(char *id,
461 int (*handler)(struct acpi_table_header *)) 468 int (*handler)(struct acpi_table_header *))
462{ 469{
463 return -1; 470 return -ENODEV;
464} 471}
465 472
466static inline int acpi_nvs_register(__u64 start, __u64 size) 473static inline int acpi_nvs_register(__u64 start, __u64 size)
diff --git a/include/linux/container.h b/include/linux/container.h
new file mode 100644
index 000000000000..3c03e6fd2035
--- /dev/null
+++ b/include/linux/container.h
@@ -0,0 +1,25 @@
1/*
2 * Definitions for container bus type.
3 *
4 * Copyright (C) 2013, Intel Corporation
5 * Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/device.h>
13
14/* drivers/base/power/container.c */
15extern struct bus_type container_subsys;
16
17struct container_dev {
18 struct device dev;
19 int (*offline)(struct container_dev *cdev);
20};
21
22static inline struct container_dev *to_container_dev(struct device *dev)
23{
24 return container_of(dev, struct container_dev, dev);
25}
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 46a14229a162..93b5ca754b5b 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -18,14 +18,10 @@
18#include <linux/completion.h> 18#include <linux/completion.h>
19#include <linux/pm.h> 19#include <linux/pm.h>
20#include <linux/mutex.h> 20#include <linux/mutex.h>
21#ifdef CONFIG_BLK_DEV_IDEACPI
22#include <acpi/acpi.h>
23#endif
24#include <asm/byteorder.h>
25#include <asm/io.h>
26
27/* for request_sense */ 21/* for request_sense */
28#include <linux/cdrom.h> 22#include <linux/cdrom.h>
23#include <asm/byteorder.h>
24#include <asm/io.h>
29 25
30#if defined(CONFIG_CRIS) || defined(CONFIG_FRV) || defined(CONFIG_MN10300) 26#if defined(CONFIG_CRIS) || defined(CONFIG_FRV) || defined(CONFIG_MN10300)
31# define SUPPORT_VLB_SYNC 0 27# define SUPPORT_VLB_SYNC 0
diff --git a/include/linux/iscsi_ibft.h b/include/linux/iscsi_ibft.h
index 8ba7e5b9d62c..605cc5c333d9 100644
--- a/include/linux/iscsi_ibft.h
+++ b/include/linux/iscsi_ibft.h
@@ -21,7 +21,7 @@
21#ifndef ISCSI_IBFT_H 21#ifndef ISCSI_IBFT_H
22#define ISCSI_IBFT_H 22#define ISCSI_IBFT_H
23 23
24#include <acpi/acpi.h> 24#include <linux/acpi.h>
25 25
26/* 26/*
27 * Logical location of iSCSI Boot Format Table. 27 * Logical location of iSCSI Boot Format Table.
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index d9a550bf3e8e..ce2a1f5f9a1e 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -769,7 +769,8 @@ struct netdev_phys_port_id {
769 * (can also return NETDEV_TX_LOCKED iff NETIF_F_LLTX) 769 * (can also return NETDEV_TX_LOCKED iff NETIF_F_LLTX)
770 * Required can not be NULL. 770 * Required can not be NULL.
771 * 771 *
772 * u16 (*ndo_select_queue)(struct net_device *dev, struct sk_buff *skb); 772 * u16 (*ndo_select_queue)(struct net_device *dev, struct sk_buff *skb,
773 * void *accel_priv);
773 * Called to decide which queue to when device supports multiple 774 * Called to decide which queue to when device supports multiple
774 * transmit queues. 775 * transmit queues.
775 * 776 *
@@ -990,7 +991,8 @@ struct net_device_ops {
990 netdev_tx_t (*ndo_start_xmit) (struct sk_buff *skb, 991 netdev_tx_t (*ndo_start_xmit) (struct sk_buff *skb,
991 struct net_device *dev); 992 struct net_device *dev);
992 u16 (*ndo_select_queue)(struct net_device *dev, 993 u16 (*ndo_select_queue)(struct net_device *dev,
993 struct sk_buff *skb); 994 struct sk_buff *skb,
995 void *accel_priv);
994 void (*ndo_change_rx_flags)(struct net_device *dev, 996 void (*ndo_change_rx_flags)(struct net_device *dev,
995 int flags); 997 int flags);
996 void (*ndo_set_rx_mode)(struct net_device *dev); 998 void (*ndo_set_rx_mode)(struct net_device *dev);
@@ -1529,7 +1531,8 @@ static inline void netdev_for_each_tx_queue(struct net_device *dev,
1529} 1531}
1530 1532
1531struct netdev_queue *netdev_pick_tx(struct net_device *dev, 1533struct netdev_queue *netdev_pick_tx(struct net_device *dev,
1532 struct sk_buff *skb); 1534 struct sk_buff *skb,
1535 void *accel_priv);
1533u16 __netdev_pick_tx(struct net_device *dev, struct sk_buff *skb); 1536u16 __netdev_pick_tx(struct net_device *dev, struct sk_buff *skb);
1534 1537
1535/* 1538/*
@@ -1819,6 +1822,7 @@ int dev_close(struct net_device *dev);
1819void dev_disable_lro(struct net_device *dev); 1822void dev_disable_lro(struct net_device *dev);
1820int dev_loopback_xmit(struct sk_buff *newskb); 1823int dev_loopback_xmit(struct sk_buff *newskb);
1821int dev_queue_xmit(struct sk_buff *skb); 1824int dev_queue_xmit(struct sk_buff *skb);
1825int dev_queue_xmit_accel(struct sk_buff *skb, void *accel_priv);
1822int register_netdevice(struct net_device *dev); 1826int register_netdevice(struct net_device *dev);
1823void unregister_netdevice_queue(struct net_device *dev, struct list_head *head); 1827void unregister_netdevice_queue(struct net_device *dev, struct list_head *head);
1824void unregister_netdevice_many(struct list_head *head); 1828void unregister_netdevice_many(struct list_head *head);
@@ -1912,6 +1916,15 @@ static inline int dev_parse_header(const struct sk_buff *skb,
1912 return dev->header_ops->parse(skb, haddr); 1916 return dev->header_ops->parse(skb, haddr);
1913} 1917}
1914 1918
1919static inline int dev_rebuild_header(struct sk_buff *skb)
1920{
1921 const struct net_device *dev = skb->dev;
1922
1923 if (!dev->header_ops || !dev->header_ops->rebuild)
1924 return 0;
1925 return dev->header_ops->rebuild(skb);
1926}
1927
1915typedef int gifconf_func_t(struct net_device * dev, char __user * bufptr, int len); 1928typedef int gifconf_func_t(struct net_device * dev, char __user * bufptr, int len);
1916int register_gifconf(unsigned int family, gifconf_func_t *gifconf); 1929int register_gifconf(unsigned int family, gifconf_func_t *gifconf);
1917static inline int unregister_gifconf(unsigned int family) 1930static inline int unregister_gifconf(unsigned int family)
@@ -2417,7 +2430,7 @@ int dev_change_carrier(struct net_device *, bool new_carrier);
2417int dev_get_phys_port_id(struct net_device *dev, 2430int dev_get_phys_port_id(struct net_device *dev,
2418 struct netdev_phys_port_id *ppid); 2431 struct netdev_phys_port_id *ppid);
2419int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev, 2432int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,
2420 struct netdev_queue *txq, void *accel_priv); 2433 struct netdev_queue *txq);
2421int dev_forward_skb(struct net_device *dev, struct sk_buff *skb); 2434int dev_forward_skb(struct net_device *dev, struct sk_buff *skb);
2422 2435
2423extern int netdev_budget; 2436extern int netdev_budget;
@@ -3008,6 +3021,19 @@ static inline void netif_set_gso_max_size(struct net_device *dev,
3008 dev->gso_max_size = size; 3021 dev->gso_max_size = size;
3009} 3022}
3010 3023
3024static inline void skb_gso_error_unwind(struct sk_buff *skb, __be16 protocol,
3025 int pulled_hlen, u16 mac_offset,
3026 int mac_len)
3027{
3028 skb->protocol = protocol;
3029 skb->encapsulation = 1;
3030 skb_push(skb, pulled_hlen);
3031 skb_reset_transport_header(skb);
3032 skb->mac_header = mac_offset;
3033 skb->network_header = skb->mac_header + mac_len;
3034 skb->mac_len = mac_len;
3035}
3036
3011static inline bool netif_is_macvlan(struct net_device *dev) 3037static inline bool netif_is_macvlan(struct net_device *dev)
3012{ 3038{
3013 return dev->priv_flags & IFF_MACVLAN; 3039 return dev->priv_flags & IFF_MACVLAN;
diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
index a2e2f1d17e16..5f2e559af6b0 100644
--- a/include/linux/pci_hotplug.h
+++ b/include/linux/pci_hotplug.h
@@ -175,8 +175,7 @@ struct hotplug_params {
175}; 175};
176 176
177#ifdef CONFIG_ACPI 177#ifdef CONFIG_ACPI
178#include <acpi/acpi.h> 178#include <linux/acpi.h>
179#include <acpi/acpi_bus.h>
180int pci_get_hp_params(struct pci_dev *dev, struct hotplug_params *hpp); 179int pci_get_hp_params(struct pci_dev *dev, struct hotplug_params *hpp);
181int acpi_get_hp_hw_control_from_firmware(struct pci_dev *dev, u32 flags); 180int acpi_get_hp_hw_control_from_firmware(struct pci_dev *dev, u32 flags);
182int acpi_pci_check_ejectable(struct pci_bus *pbus, acpi_handle handle); 181int acpi_pci_check_ejectable(struct pci_bus *pbus, acpi_handle handle);
diff --git a/include/linux/pm.h b/include/linux/pm.h
index a224c7f5c377..8c6583a53a06 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -311,6 +311,18 @@ struct dev_pm_ops {
311#define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) 311#define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn)
312#endif 312#endif
313 313
314#ifdef CONFIG_PM_SLEEP
315#define SET_LATE_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
316 .suspend_late = suspend_fn, \
317 .resume_early = resume_fn, \
318 .freeze_late = suspend_fn, \
319 .thaw_early = resume_fn, \
320 .poweroff_late = suspend_fn, \
321 .restore_early = resume_fn,
322#else
323#define SET_LATE_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn)
324#endif
325
314#ifdef CONFIG_PM_RUNTIME 326#ifdef CONFIG_PM_RUNTIME
315#define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \ 327#define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
316 .runtime_suspend = suspend_fn, \ 328 .runtime_suspend = suspend_fn, \
@@ -320,6 +332,15 @@ struct dev_pm_ops {
320#define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) 332#define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn)
321#endif 333#endif
322 334
335#ifdef CONFIG_PM
336#define SET_PM_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
337 .runtime_suspend = suspend_fn, \
338 .runtime_resume = resume_fn, \
339 .runtime_idle = idle_fn,
340#else
341#define SET_PM_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn)
342#endif
343
323/* 344/*
324 * Use this if you want to use the same suspend and resume callbacks for suspend 345 * Use this if you want to use the same suspend and resume callbacks for suspend
325 * to RAM and hibernation. 346 * to RAM and hibernation.
diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
index 6fa7cea25da9..16c9a62fa1c0 100644
--- a/include/linux/pm_runtime.h
+++ b/include/linux/pm_runtime.h
@@ -23,6 +23,14 @@
23 usage_count */ 23 usage_count */
24#define RPM_AUTO 0x08 /* Use autosuspend_delay */ 24#define RPM_AUTO 0x08 /* Use autosuspend_delay */
25 25
26#ifdef CONFIG_PM
27extern int pm_generic_runtime_suspend(struct device *dev);
28extern int pm_generic_runtime_resume(struct device *dev);
29#else
30static inline int pm_generic_runtime_suspend(struct device *dev) { return 0; }
31static inline int pm_generic_runtime_resume(struct device *dev) { return 0; }
32#endif
33
26#ifdef CONFIG_PM_RUNTIME 34#ifdef CONFIG_PM_RUNTIME
27 35
28extern struct workqueue_struct *pm_wq; 36extern struct workqueue_struct *pm_wq;
@@ -37,8 +45,6 @@ extern void pm_runtime_enable(struct device *dev);
37extern void __pm_runtime_disable(struct device *dev, bool check_resume); 45extern void __pm_runtime_disable(struct device *dev, bool check_resume);
38extern void pm_runtime_allow(struct device *dev); 46extern void pm_runtime_allow(struct device *dev);
39extern void pm_runtime_forbid(struct device *dev); 47extern void pm_runtime_forbid(struct device *dev);
40extern int pm_generic_runtime_suspend(struct device *dev);
41extern int pm_generic_runtime_resume(struct device *dev);
42extern void pm_runtime_no_callbacks(struct device *dev); 48extern void pm_runtime_no_callbacks(struct device *dev);
43extern void pm_runtime_irq_safe(struct device *dev); 49extern void pm_runtime_irq_safe(struct device *dev);
44extern void __pm_runtime_use_autosuspend(struct device *dev, bool use); 50extern void __pm_runtime_use_autosuspend(struct device *dev, bool use);
@@ -142,8 +148,6 @@ static inline bool pm_runtime_active(struct device *dev) { return true; }
142static inline bool pm_runtime_status_suspended(struct device *dev) { return false; } 148static inline bool pm_runtime_status_suspended(struct device *dev) { return false; }
143static inline bool pm_runtime_enabled(struct device *dev) { return false; } 149static inline bool pm_runtime_enabled(struct device *dev) { return false; }
144 150
145static inline int pm_generic_runtime_suspend(struct device *dev) { return 0; }
146static inline int pm_generic_runtime_resume(struct device *dev) { return 0; }
147static inline void pm_runtime_no_callbacks(struct device *dev) {} 151static inline void pm_runtime_no_callbacks(struct device *dev) {}
148static inline void pm_runtime_irq_safe(struct device *dev) {} 152static inline void pm_runtime_irq_safe(struct device *dev) {}
149 153
diff --git a/include/linux/sfi_acpi.h b/include/linux/sfi_acpi.h
index 631af63af42d..4723bbfa1c26 100644
--- a/include/linux/sfi_acpi.h
+++ b/include/linux/sfi_acpi.h
@@ -59,8 +59,11 @@
59#ifndef _LINUX_SFI_ACPI_H 59#ifndef _LINUX_SFI_ACPI_H
60#define _LINUX_SFI_ACPI_H 60#define _LINUX_SFI_ACPI_H
61 61
62#include <linux/acpi.h>
63#include <linux/sfi.h>
64
62#ifdef CONFIG_SFI 65#ifdef CONFIG_SFI
63#include <acpi/acpi.h> /* struct acpi_table_header */ 66#include <acpi/acpi.h> /* FIXME: inclusion should be removed */
64 67
65extern int sfi_acpi_table_parse(char *signature, char *oem_id, 68extern int sfi_acpi_table_parse(char *signature, char *oem_id,
66 char *oem_table_id, 69 char *oem_table_id,
diff --git a/include/linux/tboot.h b/include/linux/tboot.h
index c75128bed5fa..9a54b331f938 100644
--- a/include/linux/tboot.h
+++ b/include/linux/tboot.h
@@ -34,7 +34,7 @@ enum {
34}; 34};
35 35
36#ifdef CONFIG_INTEL_TXT 36#ifdef CONFIG_INTEL_TXT
37#include <acpi/acpi.h> 37#include <linux/acpi.h>
38/* used to communicate between tboot and the launched kernel */ 38/* used to communicate between tboot and the launched kernel */
39 39
40#define TB_KEY_SIZE 64 /* 512 bits */ 40#define TB_KEY_SIZE 64 /* 512 bits */
diff --git a/include/net/llc_pdu.h b/include/net/llc_pdu.h
index 31e2de7d57c5..c0f0a13ed818 100644
--- a/include/net/llc_pdu.h
+++ b/include/net/llc_pdu.h
@@ -142,7 +142,7 @@
142#define LLC_S_PF_IS_1(pdu) ((pdu->ctrl_2 & LLC_S_PF_BIT_MASK) ? 1 : 0) 142#define LLC_S_PF_IS_1(pdu) ((pdu->ctrl_2 & LLC_S_PF_BIT_MASK) ? 1 : 0)
143 143
144#define PDU_SUPV_GET_Nr(pdu) ((pdu->ctrl_2 & 0xFE) >> 1) 144#define PDU_SUPV_GET_Nr(pdu) ((pdu->ctrl_2 & 0xFE) >> 1)
145#define PDU_GET_NEXT_Vr(sn) (++sn & ~LLC_2_SEQ_NBR_MODULO) 145#define PDU_GET_NEXT_Vr(sn) (((sn) + 1) & ~LLC_2_SEQ_NBR_MODULO)
146 146
147/* FRMR information field macros */ 147/* FRMR information field macros */
148 148
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index 67b5d0068273..0a248b323d87 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -1046,9 +1046,6 @@ struct sctp_outq {
1046 1046
1047 /* Corked? */ 1047 /* Corked? */
1048 char cork; 1048 char cork;
1049
1050 /* Is this structure empty? */
1051 char empty;
1052}; 1049};
1053 1050
1054void sctp_outq_init(struct sctp_association *, struct sctp_outq *); 1051void sctp_outq_init(struct sctp_association *, struct sctp_outq *);
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index 0121dab83f43..37170d4dd9a6 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -82,6 +82,7 @@ void hibernation_set_ops(const struct platform_hibernation_ops *ops)
82 82
83 unlock_system_sleep(); 83 unlock_system_sleep();
84} 84}
85EXPORT_SYMBOL_GPL(hibernation_set_ops);
85 86
86static bool entering_platform_hibernation; 87static bool entering_platform_hibernation;
87 88
@@ -293,10 +294,10 @@ static int create_image(int platform_mode)
293 error); 294 error);
294 /* Restore control flow magically appears here */ 295 /* Restore control flow magically appears here */
295 restore_processor_state(); 296 restore_processor_state();
296 if (!in_suspend) { 297 if (!in_suspend)
297 events_check_enabled = false; 298 events_check_enabled = false;
298 platform_leave(platform_mode); 299
299 } 300 platform_leave(platform_mode);
300 301
301 Power_up: 302 Power_up:
302 syscore_resume(); 303 syscore_resume();
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 9c0b17295ba0..95d1acb0f3d2 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1154,7 +1154,7 @@ alloc:
1154 new_page = NULL; 1154 new_page = NULL;
1155 1155
1156 if (unlikely(!new_page)) { 1156 if (unlikely(!new_page)) {
1157 if (is_huge_zero_pmd(orig_pmd)) { 1157 if (!page) {
1158 ret = do_huge_pmd_wp_zero_page_fallback(mm, vma, 1158 ret = do_huge_pmd_wp_zero_page_fallback(mm, vma,
1159 address, pmd, orig_pmd, haddr); 1159 address, pmd, orig_pmd, haddr);
1160 } else { 1160 } else {
@@ -1181,7 +1181,7 @@ alloc:
1181 1181
1182 count_vm_event(THP_FAULT_ALLOC); 1182 count_vm_event(THP_FAULT_ALLOC);
1183 1183
1184 if (is_huge_zero_pmd(orig_pmd)) 1184 if (!page)
1185 clear_huge_page(new_page, haddr, HPAGE_PMD_NR); 1185 clear_huge_page(new_page, haddr, HPAGE_PMD_NR);
1186 else 1186 else
1187 copy_user_huge_page(new_page, page, haddr, vma, HPAGE_PMD_NR); 1187 copy_user_huge_page(new_page, page, haddr, vma, HPAGE_PMD_NR);
@@ -1207,7 +1207,7 @@ alloc:
1207 page_add_new_anon_rmap(new_page, vma, haddr); 1207 page_add_new_anon_rmap(new_page, vma, haddr);
1208 set_pmd_at(mm, haddr, pmd, entry); 1208 set_pmd_at(mm, haddr, pmd, entry);
1209 update_mmu_cache_pmd(vma, address, pmd); 1209 update_mmu_cache_pmd(vma, address, pmd);
1210 if (is_huge_zero_pmd(orig_pmd)) { 1210 if (!page) {
1211 add_mm_counter(mm, MM_ANONPAGES, HPAGE_PMD_NR); 1211 add_mm_counter(mm, MM_ANONPAGES, HPAGE_PMD_NR);
1212 put_huge_zero_page(); 1212 put_huge_zero_page();
1213 } else { 1213 } else {
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 762896ebfcf5..47c908f1f626 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -530,6 +530,23 @@ static const struct header_ops vlan_header_ops = {
530 .parse = eth_header_parse, 530 .parse = eth_header_parse,
531}; 531};
532 532
533static int vlan_passthru_hard_header(struct sk_buff *skb, struct net_device *dev,
534 unsigned short type,
535 const void *daddr, const void *saddr,
536 unsigned int len)
537{
538 struct vlan_dev_priv *vlan = vlan_dev_priv(dev);
539 struct net_device *real_dev = vlan->real_dev;
540
541 return dev_hard_header(skb, real_dev, type, daddr, saddr, len);
542}
543
544static const struct header_ops vlan_passthru_header_ops = {
545 .create = vlan_passthru_hard_header,
546 .rebuild = dev_rebuild_header,
547 .parse = eth_header_parse,
548};
549
533static struct device_type vlan_type = { 550static struct device_type vlan_type = {
534 .name = "vlan", 551 .name = "vlan",
535}; 552};
@@ -573,7 +590,7 @@ static int vlan_dev_init(struct net_device *dev)
573 590
574 dev->needed_headroom = real_dev->needed_headroom; 591 dev->needed_headroom = real_dev->needed_headroom;
575 if (real_dev->features & NETIF_F_HW_VLAN_CTAG_TX) { 592 if (real_dev->features & NETIF_F_HW_VLAN_CTAG_TX) {
576 dev->header_ops = real_dev->header_ops; 593 dev->header_ops = &vlan_passthru_header_ops;
577 dev->hard_header_len = real_dev->hard_header_len; 594 dev->hard_header_len = real_dev->hard_header_len;
578 } else { 595 } else {
579 dev->header_ops = &vlan_header_ops; 596 dev->header_ops = &vlan_header_ops;
diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
index 4c214b2b88ef..ef66365b7354 100644
--- a/net/bridge/br_multicast.c
+++ b/net/bridge/br_multicast.c
@@ -1998,7 +1998,7 @@ int br_multicast_set_hash_max(struct net_bridge *br, unsigned long val)
1998 u32 old; 1998 u32 old;
1999 struct net_bridge_mdb_htable *mdb; 1999 struct net_bridge_mdb_htable *mdb;
2000 2000
2001 spin_lock(&br->multicast_lock); 2001 spin_lock_bh(&br->multicast_lock);
2002 if (!netif_running(br->dev)) 2002 if (!netif_running(br->dev))
2003 goto unlock; 2003 goto unlock;
2004 2004
@@ -2030,7 +2030,7 @@ rollback:
2030 } 2030 }
2031 2031
2032unlock: 2032unlock:
2033 spin_unlock(&br->multicast_lock); 2033 spin_unlock_bh(&br->multicast_lock);
2034 2034
2035 return err; 2035 return err;
2036} 2036}
diff --git a/net/core/dev.c b/net/core/dev.c
index 4fc17221545d..0ce469e5ec80 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2539,7 +2539,7 @@ static inline int skb_needs_linearize(struct sk_buff *skb,
2539} 2539}
2540 2540
2541int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev, 2541int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,
2542 struct netdev_queue *txq, void *accel_priv) 2542 struct netdev_queue *txq)
2543{ 2543{
2544 const struct net_device_ops *ops = dev->netdev_ops; 2544 const struct net_device_ops *ops = dev->netdev_ops;
2545 int rc = NETDEV_TX_OK; 2545 int rc = NETDEV_TX_OK;
@@ -2605,13 +2605,10 @@ int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,
2605 dev_queue_xmit_nit(skb, dev); 2605 dev_queue_xmit_nit(skb, dev);
2606 2606
2607 skb_len = skb->len; 2607 skb_len = skb->len;
2608 if (accel_priv)
2609 rc = ops->ndo_dfwd_start_xmit(skb, dev, accel_priv);
2610 else
2611 rc = ops->ndo_start_xmit(skb, dev); 2608 rc = ops->ndo_start_xmit(skb, dev);
2612 2609
2613 trace_net_dev_xmit(skb, rc, dev, skb_len); 2610 trace_net_dev_xmit(skb, rc, dev, skb_len);
2614 if (rc == NETDEV_TX_OK && txq) 2611 if (rc == NETDEV_TX_OK)
2615 txq_trans_update(txq); 2612 txq_trans_update(txq);
2616 return rc; 2613 return rc;
2617 } 2614 }
@@ -2627,10 +2624,7 @@ gso:
2627 dev_queue_xmit_nit(nskb, dev); 2624 dev_queue_xmit_nit(nskb, dev);
2628 2625
2629 skb_len = nskb->len; 2626 skb_len = nskb->len;
2630 if (accel_priv) 2627 rc = ops->ndo_start_xmit(nskb, dev);
2631 rc = ops->ndo_dfwd_start_xmit(nskb, dev, accel_priv);
2632 else
2633 rc = ops->ndo_start_xmit(nskb, dev);
2634 trace_net_dev_xmit(nskb, rc, dev, skb_len); 2628 trace_net_dev_xmit(nskb, rc, dev, skb_len);
2635 if (unlikely(rc != NETDEV_TX_OK)) { 2629 if (unlikely(rc != NETDEV_TX_OK)) {
2636 if (rc & ~NETDEV_TX_MASK) 2630 if (rc & ~NETDEV_TX_MASK)
@@ -2811,7 +2805,7 @@ EXPORT_SYMBOL(dev_loopback_xmit);
2811 * the BH enable code must have IRQs enabled so that it will not deadlock. 2805 * the BH enable code must have IRQs enabled so that it will not deadlock.
2812 * --BLG 2806 * --BLG
2813 */ 2807 */
2814int dev_queue_xmit(struct sk_buff *skb) 2808int __dev_queue_xmit(struct sk_buff *skb, void *accel_priv)
2815{ 2809{
2816 struct net_device *dev = skb->dev; 2810 struct net_device *dev = skb->dev;
2817 struct netdev_queue *txq; 2811 struct netdev_queue *txq;
@@ -2827,7 +2821,7 @@ int dev_queue_xmit(struct sk_buff *skb)
2827 2821
2828 skb_update_prio(skb); 2822 skb_update_prio(skb);
2829 2823
2830 txq = netdev_pick_tx(dev, skb); 2824 txq = netdev_pick_tx(dev, skb, accel_priv);
2831 q = rcu_dereference_bh(txq->qdisc); 2825 q = rcu_dereference_bh(txq->qdisc);
2832 2826
2833#ifdef CONFIG_NET_CLS_ACT 2827#ifdef CONFIG_NET_CLS_ACT
@@ -2863,7 +2857,7 @@ int dev_queue_xmit(struct sk_buff *skb)
2863 2857
2864 if (!netif_xmit_stopped(txq)) { 2858 if (!netif_xmit_stopped(txq)) {
2865 __this_cpu_inc(xmit_recursion); 2859 __this_cpu_inc(xmit_recursion);
2866 rc = dev_hard_start_xmit(skb, dev, txq, NULL); 2860 rc = dev_hard_start_xmit(skb, dev, txq);
2867 __this_cpu_dec(xmit_recursion); 2861 __this_cpu_dec(xmit_recursion);
2868 if (dev_xmit_complete(rc)) { 2862 if (dev_xmit_complete(rc)) {
2869 HARD_TX_UNLOCK(dev, txq); 2863 HARD_TX_UNLOCK(dev, txq);
@@ -2892,8 +2886,19 @@ out:
2892 rcu_read_unlock_bh(); 2886 rcu_read_unlock_bh();
2893 return rc; 2887 return rc;
2894} 2888}
2889
2890int dev_queue_xmit(struct sk_buff *skb)
2891{
2892 return __dev_queue_xmit(skb, NULL);
2893}
2895EXPORT_SYMBOL(dev_queue_xmit); 2894EXPORT_SYMBOL(dev_queue_xmit);
2896 2895
2896int dev_queue_xmit_accel(struct sk_buff *skb, void *accel_priv)
2897{
2898 return __dev_queue_xmit(skb, accel_priv);
2899}
2900EXPORT_SYMBOL(dev_queue_xmit_accel);
2901
2897 2902
2898/*======================================================================= 2903/*=======================================================================
2899 Receiver routines 2904 Receiver routines
diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
index d6ef17322500..2fc5beaf5783 100644
--- a/net/core/flow_dissector.c
+++ b/net/core/flow_dissector.c
@@ -395,17 +395,21 @@ u16 __netdev_pick_tx(struct net_device *dev, struct sk_buff *skb)
395EXPORT_SYMBOL(__netdev_pick_tx); 395EXPORT_SYMBOL(__netdev_pick_tx);
396 396
397struct netdev_queue *netdev_pick_tx(struct net_device *dev, 397struct netdev_queue *netdev_pick_tx(struct net_device *dev,
398 struct sk_buff *skb) 398 struct sk_buff *skb,
399 void *accel_priv)
399{ 400{
400 int queue_index = 0; 401 int queue_index = 0;
401 402
402 if (dev->real_num_tx_queues != 1) { 403 if (dev->real_num_tx_queues != 1) {
403 const struct net_device_ops *ops = dev->netdev_ops; 404 const struct net_device_ops *ops = dev->netdev_ops;
404 if (ops->ndo_select_queue) 405 if (ops->ndo_select_queue)
405 queue_index = ops->ndo_select_queue(dev, skb); 406 queue_index = ops->ndo_select_queue(dev, skb,
407 accel_priv);
406 else 408 else
407 queue_index = __netdev_pick_tx(dev, skb); 409 queue_index = __netdev_pick_tx(dev, skb);
408 queue_index = dev_cap_txqueue(dev, queue_index); 410
411 if (!accel_priv)
412 queue_index = dev_cap_txqueue(dev, queue_index);
409 } 413 }
410 414
411 skb_set_queue_mapping(skb, queue_index); 415 skb_set_queue_mapping(skb, queue_index);
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 36b1443f9ae4..932c6d7cf666 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -1275,7 +1275,7 @@ int neigh_compat_output(struct neighbour *neigh, struct sk_buff *skb)
1275 1275
1276 if (dev_hard_header(skb, dev, ntohs(skb->protocol), NULL, NULL, 1276 if (dev_hard_header(skb, dev, ntohs(skb->protocol), NULL, NULL,
1277 skb->len) < 0 && 1277 skb->len) < 0 &&
1278 dev->header_ops->rebuild(skb)) 1278 dev_rebuild_header(skb))
1279 return 0; 1279 return 0;
1280 1280
1281 return dev_queue_xmit(skb); 1281 return dev_queue_xmit(skb);
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index 8f971990677c..19fe9c717ced 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -375,7 +375,7 @@ void netpoll_send_skb_on_dev(struct netpoll *np, struct sk_buff *skb,
375 if (skb_queue_len(&npinfo->txq) == 0 && !netpoll_owner_active(dev)) { 375 if (skb_queue_len(&npinfo->txq) == 0 && !netpoll_owner_active(dev)) {
376 struct netdev_queue *txq; 376 struct netdev_queue *txq;
377 377
378 txq = netdev_pick_tx(dev, skb); 378 txq = netdev_pick_tx(dev, skb, NULL);
379 379
380 /* try until next clock tick */ 380 /* try until next clock tick */
381 for (tries = jiffies_to_usecs(1)/USEC_PER_POLL; 381 for (tries = jiffies_to_usecs(1)/USEC_PER_POLL;
@@ -386,8 +386,14 @@ void netpoll_send_skb_on_dev(struct netpoll *np, struct sk_buff *skb,
386 !vlan_hw_offload_capable(netif_skb_features(skb), 386 !vlan_hw_offload_capable(netif_skb_features(skb),
387 skb->vlan_proto)) { 387 skb->vlan_proto)) {
388 skb = __vlan_put_tag(skb, skb->vlan_proto, vlan_tx_tag_get(skb)); 388 skb = __vlan_put_tag(skb, skb->vlan_proto, vlan_tx_tag_get(skb));
389 if (unlikely(!skb)) 389 if (unlikely(!skb)) {
390 break; 390 /* This is actually a packet drop, but we
391 * don't want the code at the end of this
392 * function to try and re-queue a NULL skb.
393 */
394 status = NETDEV_TX_OK;
395 goto unlock_txq;
396 }
391 skb->vlan_tci = 0; 397 skb->vlan_tci = 0;
392 } 398 }
393 399
@@ -395,6 +401,7 @@ void netpoll_send_skb_on_dev(struct netpoll *np, struct sk_buff *skb,
395 if (status == NETDEV_TX_OK) 401 if (status == NETDEV_TX_OK)
396 txq_trans_update(txq); 402 txq_trans_update(txq);
397 } 403 }
404 unlock_txq:
398 __netif_tx_unlock(txq); 405 __netif_tx_unlock(txq);
399 406
400 if (status == NETDEV_TX_OK) 407 if (status == NETDEV_TX_OK)
diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
index 459e200c08a4..a2d2456a557a 100644
--- a/net/ieee802154/6lowpan.c
+++ b/net/ieee802154/6lowpan.c
@@ -547,7 +547,7 @@ static int lowpan_header_create(struct sk_buff *skb,
547 hc06_ptr += 3; 547 hc06_ptr += 3;
548 } else { 548 } else {
549 /* compress nothing */ 549 /* compress nothing */
550 memcpy(hc06_ptr, &hdr, 4); 550 memcpy(hc06_ptr, hdr, 4);
551 /* replace the top byte with new ECN | DSCP format */ 551 /* replace the top byte with new ECN | DSCP format */
552 *hc06_ptr = tmp; 552 *hc06_ptr = tmp;
553 hc06_ptr += 4; 553 hc06_ptr += 4;
diff --git a/net/ipv4/gre_offload.c b/net/ipv4/gre_offload.c
index e5d436188464..2cd02f32f99f 100644
--- a/net/ipv4/gre_offload.c
+++ b/net/ipv4/gre_offload.c
@@ -28,6 +28,7 @@ static struct sk_buff *gre_gso_segment(struct sk_buff *skb,
28 netdev_features_t enc_features; 28 netdev_features_t enc_features;
29 int ghl = GRE_HEADER_SECTION; 29 int ghl = GRE_HEADER_SECTION;
30 struct gre_base_hdr *greh; 30 struct gre_base_hdr *greh;
31 u16 mac_offset = skb->mac_header;
31 int mac_len = skb->mac_len; 32 int mac_len = skb->mac_len;
32 __be16 protocol = skb->protocol; 33 __be16 protocol = skb->protocol;
33 int tnl_hlen; 34 int tnl_hlen;
@@ -58,13 +59,13 @@ static struct sk_buff *gre_gso_segment(struct sk_buff *skb,
58 } else 59 } else
59 csum = false; 60 csum = false;
60 61
62 if (unlikely(!pskb_may_pull(skb, ghl)))
63 goto out;
64
61 /* setup inner skb. */ 65 /* setup inner skb. */
62 skb->protocol = greh->protocol; 66 skb->protocol = greh->protocol;
63 skb->encapsulation = 0; 67 skb->encapsulation = 0;
64 68
65 if (unlikely(!pskb_may_pull(skb, ghl)))
66 goto out;
67
68 __skb_pull(skb, ghl); 69 __skb_pull(skb, ghl);
69 skb_reset_mac_header(skb); 70 skb_reset_mac_header(skb);
70 skb_set_network_header(skb, skb_inner_network_offset(skb)); 71 skb_set_network_header(skb, skb_inner_network_offset(skb));
@@ -73,8 +74,10 @@ static struct sk_buff *gre_gso_segment(struct sk_buff *skb,
73 /* segment inner packet. */ 74 /* segment inner packet. */
74 enc_features = skb->dev->hw_enc_features & netif_skb_features(skb); 75 enc_features = skb->dev->hw_enc_features & netif_skb_features(skb);
75 segs = skb_mac_gso_segment(skb, enc_features); 76 segs = skb_mac_gso_segment(skb, enc_features);
76 if (!segs || IS_ERR(segs)) 77 if (!segs || IS_ERR(segs)) {
78 skb_gso_error_unwind(skb, protocol, ghl, mac_offset, mac_len);
77 goto out; 79 goto out;
80 }
78 81
79 skb = segs; 82 skb = segs;
80 tnl_hlen = skb_tnl_header_len(skb); 83 tnl_hlen = skb_tnl_header_len(skb);
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index f140048334ce..a7e4729e974b 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -2478,6 +2478,7 @@ struct sk_buff *skb_udp_tunnel_segment(struct sk_buff *skb,
2478 netdev_features_t features) 2478 netdev_features_t features)
2479{ 2479{
2480 struct sk_buff *segs = ERR_PTR(-EINVAL); 2480 struct sk_buff *segs = ERR_PTR(-EINVAL);
2481 u16 mac_offset = skb->mac_header;
2481 int mac_len = skb->mac_len; 2482 int mac_len = skb->mac_len;
2482 int tnl_hlen = skb_inner_mac_header(skb) - skb_transport_header(skb); 2483 int tnl_hlen = skb_inner_mac_header(skb) - skb_transport_header(skb);
2483 __be16 protocol = skb->protocol; 2484 __be16 protocol = skb->protocol;
@@ -2497,8 +2498,11 @@ struct sk_buff *skb_udp_tunnel_segment(struct sk_buff *skb,
2497 /* segment inner packet. */ 2498 /* segment inner packet. */
2498 enc_features = skb->dev->hw_enc_features & netif_skb_features(skb); 2499 enc_features = skb->dev->hw_enc_features & netif_skb_features(skb);
2499 segs = skb_mac_gso_segment(skb, enc_features); 2500 segs = skb_mac_gso_segment(skb, enc_features);
2500 if (!segs || IS_ERR(segs)) 2501 if (!segs || IS_ERR(segs)) {
2502 skb_gso_error_unwind(skb, protocol, tnl_hlen, mac_offset,
2503 mac_len);
2501 goto out; 2504 goto out;
2505 }
2502 2506
2503 outer_hlen = skb_tnl_header_len(skb); 2507 outer_hlen = skb_tnl_header_len(skb);
2504 skb = segs; 2508 skb = segs;
diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
index 83206de2bc76..79c62bdcd3c5 100644
--- a/net/ipv4/udp_offload.c
+++ b/net/ipv4/udp_offload.c
@@ -41,6 +41,14 @@ static struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb,
41{ 41{
42 struct sk_buff *segs = ERR_PTR(-EINVAL); 42 struct sk_buff *segs = ERR_PTR(-EINVAL);
43 unsigned int mss; 43 unsigned int mss;
44 int offset;
45 __wsum csum;
46
47 if (skb->encapsulation &&
48 skb_shinfo(skb)->gso_type & SKB_GSO_UDP_TUNNEL) {
49 segs = skb_udp_tunnel_segment(skb, features);
50 goto out;
51 }
44 52
45 mss = skb_shinfo(skb)->gso_size; 53 mss = skb_shinfo(skb)->gso_size;
46 if (unlikely(skb->len <= mss)) 54 if (unlikely(skb->len <= mss))
@@ -63,27 +71,20 @@ static struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb,
63 goto out; 71 goto out;
64 } 72 }
65 73
74 /* Do software UFO. Complete and fill in the UDP checksum as
75 * HW cannot do checksum of UDP packets sent as multiple
76 * IP fragments.
77 */
78 offset = skb_checksum_start_offset(skb);
79 csum = skb_checksum(skb, offset, skb->len - offset, 0);
80 offset += skb->csum_offset;
81 *(__sum16 *)(skb->data + offset) = csum_fold(csum);
82 skb->ip_summed = CHECKSUM_NONE;
83
66 /* Fragment the skb. IP headers of the fragments are updated in 84 /* Fragment the skb. IP headers of the fragments are updated in
67 * inet_gso_segment() 85 * inet_gso_segment()
68 */ 86 */
69 if (skb->encapsulation && skb_shinfo(skb)->gso_type & SKB_GSO_UDP_TUNNEL) 87 segs = skb_segment(skb, features);
70 segs = skb_udp_tunnel_segment(skb, features);
71 else {
72 int offset;
73 __wsum csum;
74
75 /* Do software UFO. Complete and fill in the UDP checksum as
76 * HW cannot do checksum of UDP packets sent as multiple
77 * IP fragments.
78 */
79 offset = skb_checksum_start_offset(skb);
80 csum = skb_checksum(skb, offset, skb->len - offset, 0);
81 offset += skb->csum_offset;
82 *(__sum16 *)(skb->data + offset) = csum_fold(csum);
83 skb->ip_summed = CHECKSUM_NONE;
84
85 segs = skb_segment(skb, features);
86 }
87out: 88out:
88 return segs; 89 return segs;
89} 90}
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index d5fa5b8c443e..abe46a4228ce 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -1671,7 +1671,7 @@ void addrconf_leave_solict(struct inet6_dev *idev, const struct in6_addr *addr)
1671static void addrconf_join_anycast(struct inet6_ifaddr *ifp) 1671static void addrconf_join_anycast(struct inet6_ifaddr *ifp)
1672{ 1672{
1673 struct in6_addr addr; 1673 struct in6_addr addr;
1674 if (ifp->prefix_len == 127) /* RFC 6164 */ 1674 if (ifp->prefix_len >= 127) /* RFC 6164 */
1675 return; 1675 return;
1676 ipv6_addr_prefix(&addr, &ifp->addr, ifp->prefix_len); 1676 ipv6_addr_prefix(&addr, &ifp->addr, ifp->prefix_len);
1677 if (ipv6_addr_any(&addr)) 1677 if (ipv6_addr_any(&addr))
@@ -1682,7 +1682,7 @@ static void addrconf_join_anycast(struct inet6_ifaddr *ifp)
1682static void addrconf_leave_anycast(struct inet6_ifaddr *ifp) 1682static void addrconf_leave_anycast(struct inet6_ifaddr *ifp)
1683{ 1683{
1684 struct in6_addr addr; 1684 struct in6_addr addr;
1685 if (ifp->prefix_len == 127) /* RFC 6164 */ 1685 if (ifp->prefix_len >= 127) /* RFC 6164 */
1686 return; 1686 return;
1687 ipv6_addr_prefix(&addr, &ifp->addr, ifp->prefix_len); 1687 ipv6_addr_prefix(&addr, &ifp->addr, ifp->prefix_len);
1688 if (ipv6_addr_any(&addr)) 1688 if (ipv6_addr_any(&addr))
@@ -2509,7 +2509,8 @@ static void add_addr(struct inet6_dev *idev, const struct in6_addr *addr,
2509 struct inet6_ifaddr *ifp; 2509 struct inet6_ifaddr *ifp;
2510 2510
2511 ifp = ipv6_add_addr(idev, addr, NULL, plen, 2511 ifp = ipv6_add_addr(idev, addr, NULL, plen,
2512 scope, IFA_F_PERMANENT, 0, 0); 2512 scope, IFA_F_PERMANENT,
2513 INFINITY_LIFE_TIME, INFINITY_LIFE_TIME);
2513 if (!IS_ERR(ifp)) { 2514 if (!IS_ERR(ifp)) {
2514 spin_lock_bh(&ifp->lock); 2515 spin_lock_bh(&ifp->lock);
2515 ifp->flags &= ~IFA_F_TENTATIVE; 2516 ifp->flags &= ~IFA_F_TENTATIVE;
@@ -2637,7 +2638,8 @@ static void addrconf_add_linklocal(struct inet6_dev *idev, const struct in6_addr
2637#endif 2638#endif
2638 2639
2639 2640
2640 ifp = ipv6_add_addr(idev, addr, NULL, 64, IFA_LINK, addr_flags, 0, 0); 2641 ifp = ipv6_add_addr(idev, addr, NULL, 64, IFA_LINK, addr_flags,
2642 INFINITY_LIFE_TIME, INFINITY_LIFE_TIME);
2641 if (!IS_ERR(ifp)) { 2643 if (!IS_ERR(ifp)) {
2642 addrconf_prefix_route(&ifp->addr, ifp->prefix_len, idev->dev, 0, 0); 2644 addrconf_prefix_route(&ifp->addr, ifp->prefix_len, idev->dev, 0, 0);
2643 addrconf_dad_start(ifp); 2645 addrconf_dad_start(ifp);
@@ -3456,7 +3458,12 @@ restart:
3456 &inet6_addr_lst[i], addr_lst) { 3458 &inet6_addr_lst[i], addr_lst) {
3457 unsigned long age; 3459 unsigned long age;
3458 3460
3459 if (ifp->flags & IFA_F_PERMANENT) 3461 /* When setting preferred_lft to a value not zero or
3462 * infinity, while valid_lft is infinity
3463 * IFA_F_PERMANENT has a non-infinity life time.
3464 */
3465 if ((ifp->flags & IFA_F_PERMANENT) &&
3466 (ifp->prefered_lft == INFINITY_LIFE_TIME))
3460 continue; 3467 continue;
3461 3468
3462 spin_lock(&ifp->lock); 3469 spin_lock(&ifp->lock);
@@ -3481,7 +3488,8 @@ restart:
3481 ifp->flags |= IFA_F_DEPRECATED; 3488 ifp->flags |= IFA_F_DEPRECATED;
3482 } 3489 }
3483 3490
3484 if (time_before(ifp->tstamp + ifp->valid_lft * HZ, next)) 3491 if ((ifp->valid_lft != INFINITY_LIFE_TIME) &&
3492 (time_before(ifp->tstamp + ifp->valid_lft * HZ, next)))
3485 next = ifp->tstamp + ifp->valid_lft * HZ; 3493 next = ifp->tstamp + ifp->valid_lft * HZ;
3486 3494
3487 spin_unlock(&ifp->lock); 3495 spin_unlock(&ifp->lock);
@@ -3761,7 +3769,8 @@ static int inet6_fill_ifaddr(struct sk_buff *skb, struct inet6_ifaddr *ifa,
3761 put_ifaddrmsg(nlh, ifa->prefix_len, ifa->flags, rt_scope(ifa->scope), 3769 put_ifaddrmsg(nlh, ifa->prefix_len, ifa->flags, rt_scope(ifa->scope),
3762 ifa->idev->dev->ifindex); 3770 ifa->idev->dev->ifindex);
3763 3771
3764 if (!(ifa->flags&IFA_F_PERMANENT)) { 3772 if (!((ifa->flags&IFA_F_PERMANENT) &&
3773 (ifa->prefered_lft == INFINITY_LIFE_TIME))) {
3765 preferred = ifa->prefered_lft; 3774 preferred = ifa->prefered_lft;
3766 valid = ifa->valid_lft; 3775 valid = ifa->valid_lft;
3767 if (preferred != INFINITY_LIFE_TIME) { 3776 if (preferred != INFINITY_LIFE_TIME) {
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index d6062325db08..7881965a8248 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -103,16 +103,25 @@ struct ip6_tnl_net {
103 103
104static struct net_device_stats *ip6_get_stats(struct net_device *dev) 104static struct net_device_stats *ip6_get_stats(struct net_device *dev)
105{ 105{
106 struct pcpu_tstats sum = { 0 }; 106 struct pcpu_tstats tmp, sum = { 0 };
107 int i; 107 int i;
108 108
109 for_each_possible_cpu(i) { 109 for_each_possible_cpu(i) {
110 unsigned int start;
110 const struct pcpu_tstats *tstats = per_cpu_ptr(dev->tstats, i); 111 const struct pcpu_tstats *tstats = per_cpu_ptr(dev->tstats, i);
111 112
112 sum.rx_packets += tstats->rx_packets; 113 do {
113 sum.rx_bytes += tstats->rx_bytes; 114 start = u64_stats_fetch_begin_bh(&tstats->syncp);
114 sum.tx_packets += tstats->tx_packets; 115 tmp.rx_packets = tstats->rx_packets;
115 sum.tx_bytes += tstats->tx_bytes; 116 tmp.rx_bytes = tstats->rx_bytes;
117 tmp.tx_packets = tstats->tx_packets;
118 tmp.tx_bytes = tstats->tx_bytes;
119 } while (u64_stats_fetch_retry_bh(&tstats->syncp, start));
120
121 sum.rx_packets += tmp.rx_packets;
122 sum.rx_bytes += tmp.rx_bytes;
123 sum.tx_packets += tmp.tx_packets;
124 sum.tx_bytes += tmp.tx_bytes;
116 } 125 }
117 dev->stats.rx_packets = sum.rx_packets; 126 dev->stats.rx_packets = sum.rx_packets;
118 dev->stats.rx_bytes = sum.rx_bytes; 127 dev->stats.rx_bytes = sum.rx_bytes;
@@ -824,8 +833,10 @@ static int ip6_tnl_rcv(struct sk_buff *skb, __u16 protocol,
824 } 833 }
825 834
826 tstats = this_cpu_ptr(t->dev->tstats); 835 tstats = this_cpu_ptr(t->dev->tstats);
836 u64_stats_update_begin(&tstats->syncp);
827 tstats->rx_packets++; 837 tstats->rx_packets++;
828 tstats->rx_bytes += skb->len; 838 tstats->rx_bytes += skb->len;
839 u64_stats_update_end(&tstats->syncp);
829 840
830 netif_rx(skb); 841 netif_rx(skb);
831 842
diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c
index ed94ba61dda0..7b42d5ef868d 100644
--- a/net/ipv6/ip6_vti.c
+++ b/net/ipv6/ip6_vti.c
@@ -75,26 +75,6 @@ struct vti6_net {
75 struct ip6_tnl __rcu **tnls[2]; 75 struct ip6_tnl __rcu **tnls[2];
76}; 76};
77 77
78static struct net_device_stats *vti6_get_stats(struct net_device *dev)
79{
80 struct pcpu_tstats sum = { 0 };
81 int i;
82
83 for_each_possible_cpu(i) {
84 const struct pcpu_tstats *tstats = per_cpu_ptr(dev->tstats, i);
85
86 sum.rx_packets += tstats->rx_packets;
87 sum.rx_bytes += tstats->rx_bytes;
88 sum.tx_packets += tstats->tx_packets;
89 sum.tx_bytes += tstats->tx_bytes;
90 }
91 dev->stats.rx_packets = sum.rx_packets;
92 dev->stats.rx_bytes = sum.rx_bytes;
93 dev->stats.tx_packets = sum.tx_packets;
94 dev->stats.tx_bytes = sum.tx_bytes;
95 return &dev->stats;
96}
97
98#define for_each_vti6_tunnel_rcu(start) \ 78#define for_each_vti6_tunnel_rcu(start) \
99 for (t = rcu_dereference(start); t; t = rcu_dereference(t->next)) 79 for (t = rcu_dereference(start); t; t = rcu_dereference(t->next))
100 80
@@ -331,8 +311,10 @@ static int vti6_rcv(struct sk_buff *skb)
331 } 311 }
332 312
333 tstats = this_cpu_ptr(t->dev->tstats); 313 tstats = this_cpu_ptr(t->dev->tstats);
314 u64_stats_update_begin(&tstats->syncp);
334 tstats->rx_packets++; 315 tstats->rx_packets++;
335 tstats->rx_bytes += skb->len; 316 tstats->rx_bytes += skb->len;
317 u64_stats_update_end(&tstats->syncp);
336 318
337 skb->mark = 0; 319 skb->mark = 0;
338 secpath_reset(skb); 320 secpath_reset(skb);
@@ -716,7 +698,7 @@ static const struct net_device_ops vti6_netdev_ops = {
716 .ndo_start_xmit = vti6_tnl_xmit, 698 .ndo_start_xmit = vti6_tnl_xmit,
717 .ndo_do_ioctl = vti6_ioctl, 699 .ndo_do_ioctl = vti6_ioctl,
718 .ndo_change_mtu = vti6_change_mtu, 700 .ndo_change_mtu = vti6_change_mtu,
719 .ndo_get_stats = vti6_get_stats, 701 .ndo_get_stats64 = ip_tunnel_get_stats64,
720}; 702};
721 703
722/** 704/**
@@ -750,12 +732,18 @@ static void vti6_dev_setup(struct net_device *dev)
750static inline int vti6_dev_init_gen(struct net_device *dev) 732static inline int vti6_dev_init_gen(struct net_device *dev)
751{ 733{
752 struct ip6_tnl *t = netdev_priv(dev); 734 struct ip6_tnl *t = netdev_priv(dev);
735 int i;
753 736
754 t->dev = dev; 737 t->dev = dev;
755 t->net = dev_net(dev); 738 t->net = dev_net(dev);
756 dev->tstats = alloc_percpu(struct pcpu_tstats); 739 dev->tstats = alloc_percpu(struct pcpu_tstats);
757 if (!dev->tstats) 740 if (!dev->tstats)
758 return -ENOMEM; 741 return -ENOMEM;
742 for_each_possible_cpu(i) {
743 struct pcpu_tstats *stats;
744 stats = per_cpu_ptr(dev->tstats, i);
745 u64_stats_init(&stats->syncp);
746 }
759 return 0; 747 return 0;
760} 748}
761 749
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index c87482252577..d3005b34476a 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -702,8 +702,10 @@ static int ipip6_rcv(struct sk_buff *skb)
702 } 702 }
703 703
704 tstats = this_cpu_ptr(tunnel->dev->tstats); 704 tstats = this_cpu_ptr(tunnel->dev->tstats);
705 u64_stats_update_begin(&tstats->syncp);
705 tstats->rx_packets++; 706 tstats->rx_packets++;
706 tstats->rx_bytes += skb->len; 707 tstats->rx_bytes += skb->len;
708 u64_stats_update_end(&tstats->syncp);
707 709
708 netif_rx(skb); 710 netif_rx(skb);
709 711
diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c
index 7b01b9f5846c..c71b699eb555 100644
--- a/net/llc/af_llc.c
+++ b/net/llc/af_llc.c
@@ -715,7 +715,7 @@ static int llc_ui_recvmsg(struct kiocb *iocb, struct socket *sock,
715 unsigned long cpu_flags; 715 unsigned long cpu_flags;
716 size_t copied = 0; 716 size_t copied = 0;
717 u32 peek_seq = 0; 717 u32 peek_seq = 0;
718 u32 *seq; 718 u32 *seq, skb_len;
719 unsigned long used; 719 unsigned long used;
720 int target; /* Read at least this many bytes */ 720 int target; /* Read at least this many bytes */
721 long timeo; 721 long timeo;
@@ -812,6 +812,7 @@ static int llc_ui_recvmsg(struct kiocb *iocb, struct socket *sock,
812 } 812 }
813 continue; 813 continue;
814 found_ok_skb: 814 found_ok_skb:
815 skb_len = skb->len;
815 /* Ok so how much can we use? */ 816 /* Ok so how much can we use? */
816 used = skb->len - offset; 817 used = skb->len - offset;
817 if (len < used) 818 if (len < used)
@@ -844,7 +845,7 @@ static int llc_ui_recvmsg(struct kiocb *iocb, struct socket *sock,
844 } 845 }
845 846
846 /* Partial read */ 847 /* Partial read */
847 if (used + offset < skb->len) 848 if (used + offset < skb_len)
848 continue; 849 continue;
849 } while (len > 0); 850 } while (len > 0);
850 851
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index 36c3a4cbcabf..a0757913046e 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -1061,7 +1061,8 @@ static void ieee80211_uninit(struct net_device *dev)
1061} 1061}
1062 1062
1063static u16 ieee80211_netdev_select_queue(struct net_device *dev, 1063static u16 ieee80211_netdev_select_queue(struct net_device *dev,
1064 struct sk_buff *skb) 1064 struct sk_buff *skb,
1065 void *accel_priv)
1065{ 1066{
1066 return ieee80211_select_queue(IEEE80211_DEV_TO_SUB_IF(dev), skb); 1067 return ieee80211_select_queue(IEEE80211_DEV_TO_SUB_IF(dev), skb);
1067} 1068}
@@ -1078,7 +1079,8 @@ static const struct net_device_ops ieee80211_dataif_ops = {
1078}; 1079};
1079 1080
1080static u16 ieee80211_monitor_select_queue(struct net_device *dev, 1081static u16 ieee80211_monitor_select_queue(struct net_device *dev,
1081 struct sk_buff *skb) 1082 struct sk_buff *skb,
1083 void *accel_priv)
1082{ 1084{
1083 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1085 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1084 struct ieee80211_local *local = sdata->local; 1086 struct ieee80211_local *local = sdata->local;
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index c558b246ef00..ca7fa7f0613d 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -463,7 +463,6 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx)
463{ 463{
464 struct sta_info *sta = tx->sta; 464 struct sta_info *sta = tx->sta;
465 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); 465 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
466 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data;
467 struct ieee80211_local *local = tx->local; 466 struct ieee80211_local *local = tx->local;
468 467
469 if (unlikely(!sta)) 468 if (unlikely(!sta))
@@ -474,15 +473,6 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx)
474 !(info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER))) { 473 !(info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER))) {
475 int ac = skb_get_queue_mapping(tx->skb); 474 int ac = skb_get_queue_mapping(tx->skb);
476 475
477 /* only deauth, disassoc and action are bufferable MMPDUs */
478 if (ieee80211_is_mgmt(hdr->frame_control) &&
479 !ieee80211_is_deauth(hdr->frame_control) &&
480 !ieee80211_is_disassoc(hdr->frame_control) &&
481 !ieee80211_is_action(hdr->frame_control)) {
482 info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER;
483 return TX_CONTINUE;
484 }
485
486 ps_dbg(sta->sdata, "STA %pM aid %d: PS buffer for AC %d\n", 476 ps_dbg(sta->sdata, "STA %pM aid %d: PS buffer for AC %d\n",
487 sta->sta.addr, sta->sta.aid, ac); 477 sta->sta.addr, sta->sta.aid, ac);
488 if (tx->local->total_ps_buffered >= TOTAL_MAX_TX_BUFFER) 478 if (tx->local->total_ps_buffered >= TOTAL_MAX_TX_BUFFER)
@@ -525,9 +515,22 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx)
525static ieee80211_tx_result debug_noinline 515static ieee80211_tx_result debug_noinline
526ieee80211_tx_h_ps_buf(struct ieee80211_tx_data *tx) 516ieee80211_tx_h_ps_buf(struct ieee80211_tx_data *tx)
527{ 517{
518 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
519 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data;
520
528 if (unlikely(tx->flags & IEEE80211_TX_PS_BUFFERED)) 521 if (unlikely(tx->flags & IEEE80211_TX_PS_BUFFERED))
529 return TX_CONTINUE; 522 return TX_CONTINUE;
530 523
524 /* only deauth, disassoc and action are bufferable MMPDUs */
525 if (ieee80211_is_mgmt(hdr->frame_control) &&
526 !ieee80211_is_deauth(hdr->frame_control) &&
527 !ieee80211_is_disassoc(hdr->frame_control) &&
528 !ieee80211_is_action(hdr->frame_control)) {
529 if (tx->flags & IEEE80211_TX_UNICAST)
530 info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER;
531 return TX_CONTINUE;
532 }
533
531 if (tx->flags & IEEE80211_TX_UNICAST) 534 if (tx->flags & IEEE80211_TX_UNICAST)
532 return ieee80211_tx_h_unicast_ps_buf(tx); 535 return ieee80211_tx_h_unicast_ps_buf(tx);
533 else 536 else
diff --git a/net/netfilter/nf_conntrack_seqadj.c b/net/netfilter/nf_conntrack_seqadj.c
index b2d38da67822..f6e2ae91a80b 100644
--- a/net/netfilter/nf_conntrack_seqadj.c
+++ b/net/netfilter/nf_conntrack_seqadj.c
@@ -37,7 +37,7 @@ int nf_ct_seqadj_set(struct nf_conn *ct, enum ip_conntrack_info ctinfo,
37 return 0; 37 return 0;
38 38
39 if (unlikely(!seqadj)) { 39 if (unlikely(!seqadj)) {
40 WARN(1, "Wrong seqadj usage, missing nfct_seqadj_ext_add()\n"); 40 WARN_ONCE(1, "Missing nfct_seqadj_ext_add() setup call\n");
41 return 0; 41 return 0;
42 } 42 }
43 43
diff --git a/net/netfilter/nf_nat_irc.c b/net/netfilter/nf_nat_irc.c
index f02b3605823e..1fb2258c3535 100644
--- a/net/netfilter/nf_nat_irc.c
+++ b/net/netfilter/nf_nat_irc.c
@@ -34,10 +34,14 @@ static unsigned int help(struct sk_buff *skb,
34 struct nf_conntrack_expect *exp) 34 struct nf_conntrack_expect *exp)
35{ 35{
36 char buffer[sizeof("4294967296 65635")]; 36 char buffer[sizeof("4294967296 65635")];
37 struct nf_conn *ct = exp->master;
38 union nf_inet_addr newaddr;
37 u_int16_t port; 39 u_int16_t port;
38 unsigned int ret; 40 unsigned int ret;
39 41
40 /* Reply comes from server. */ 42 /* Reply comes from server. */
43 newaddr = ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3;
44
41 exp->saved_proto.tcp.port = exp->tuple.dst.u.tcp.port; 45 exp->saved_proto.tcp.port = exp->tuple.dst.u.tcp.port;
42 exp->dir = IP_CT_DIR_REPLY; 46 exp->dir = IP_CT_DIR_REPLY;
43 exp->expectfn = nf_nat_follow_master; 47 exp->expectfn = nf_nat_follow_master;
@@ -57,17 +61,35 @@ static unsigned int help(struct sk_buff *skb,
57 } 61 }
58 62
59 if (port == 0) { 63 if (port == 0) {
60 nf_ct_helper_log(skb, exp->master, "all ports in use"); 64 nf_ct_helper_log(skb, ct, "all ports in use");
61 return NF_DROP; 65 return NF_DROP;
62 } 66 }
63 67
64 ret = nf_nat_mangle_tcp_packet(skb, exp->master, ctinfo, 68 /* strlen("\1DCC CHAT chat AAAAAAAA P\1\n")=27
65 protoff, matchoff, matchlen, buffer, 69 * strlen("\1DCC SCHAT chat AAAAAAAA P\1\n")=28
66 strlen(buffer)); 70 * strlen("\1DCC SEND F AAAAAAAA P S\1\n")=26
71 * strlen("\1DCC MOVE F AAAAAAAA P S\1\n")=26
72 * strlen("\1DCC TSEND F AAAAAAAA P S\1\n")=27
73 *
74 * AAAAAAAAA: bound addr (1.0.0.0==16777216, min 8 digits,
75 * 255.255.255.255==4294967296, 10 digits)
76 * P: bound port (min 1 d, max 5d (65635))
77 * F: filename (min 1 d )
78 * S: size (min 1 d )
79 * 0x01, \n: terminators
80 */
81 /* AAA = "us", ie. where server normally talks to. */
82 snprintf(buffer, sizeof(buffer), "%u %u", ntohl(newaddr.ip), port);
83 pr_debug("nf_nat_irc: inserting '%s' == %pI4, port %u\n",
84 buffer, &newaddr.ip, port);
85
86 ret = nf_nat_mangle_tcp_packet(skb, ct, ctinfo, protoff, matchoff,
87 matchlen, buffer, strlen(buffer));
67 if (ret != NF_ACCEPT) { 88 if (ret != NF_ACCEPT) {
68 nf_ct_helper_log(skb, exp->master, "cannot mangle packet"); 89 nf_ct_helper_log(skb, ct, "cannot mangle packet");
69 nf_ct_unexpect_related(exp); 90 nf_ct_unexpect_related(exp);
70 } 91 }
92
71 return ret; 93 return ret;
72} 94}
73 95
diff --git a/net/nfc/core.c b/net/nfc/core.c
index 872529105abc..83b9927e7d19 100644
--- a/net/nfc/core.c
+++ b/net/nfc/core.c
@@ -384,7 +384,7 @@ int nfc_dep_link_is_up(struct nfc_dev *dev, u32 target_idx,
384{ 384{
385 dev->dep_link_up = true; 385 dev->dep_link_up = true;
386 386
387 if (!dev->active_target) { 387 if (!dev->active_target && rf_mode == NFC_RF_INITIATOR) {
388 struct nfc_target *target; 388 struct nfc_target *target;
389 389
390 target = nfc_find_target(dev, target_idx); 390 target = nfc_find_target(dev, target_idx);
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index 922a09406ba7..7fc899a943a8 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -126,7 +126,7 @@ int sch_direct_xmit(struct sk_buff *skb, struct Qdisc *q,
126 126
127 HARD_TX_LOCK(dev, txq, smp_processor_id()); 127 HARD_TX_LOCK(dev, txq, smp_processor_id());
128 if (!netif_xmit_frozen_or_stopped(txq)) 128 if (!netif_xmit_frozen_or_stopped(txq))
129 ret = dev_hard_start_xmit(skb, dev, txq, NULL); 129 ret = dev_hard_start_xmit(skb, dev, txq);
130 130
131 HARD_TX_UNLOCK(dev, txq); 131 HARD_TX_UNLOCK(dev, txq);
132 132
diff --git a/net/sctp/outqueue.c b/net/sctp/outqueue.c
index f51ba985a36e..59268f6e2c36 100644
--- a/net/sctp/outqueue.c
+++ b/net/sctp/outqueue.c
@@ -208,8 +208,6 @@ void sctp_outq_init(struct sctp_association *asoc, struct sctp_outq *q)
208 INIT_LIST_HEAD(&q->retransmit); 208 INIT_LIST_HEAD(&q->retransmit);
209 INIT_LIST_HEAD(&q->sacked); 209 INIT_LIST_HEAD(&q->sacked);
210 INIT_LIST_HEAD(&q->abandoned); 210 INIT_LIST_HEAD(&q->abandoned);
211
212 q->empty = 1;
213} 211}
214 212
215/* Free the outqueue structure and any related pending chunks. 213/* Free the outqueue structure and any related pending chunks.
@@ -332,7 +330,6 @@ int sctp_outq_tail(struct sctp_outq *q, struct sctp_chunk *chunk)
332 SCTP_INC_STATS(net, SCTP_MIB_OUTUNORDERCHUNKS); 330 SCTP_INC_STATS(net, SCTP_MIB_OUTUNORDERCHUNKS);
333 else 331 else
334 SCTP_INC_STATS(net, SCTP_MIB_OUTORDERCHUNKS); 332 SCTP_INC_STATS(net, SCTP_MIB_OUTORDERCHUNKS);
335 q->empty = 0;
336 break; 333 break;
337 } 334 }
338 } else { 335 } else {
@@ -654,7 +651,6 @@ redo:
654 if (chunk->fast_retransmit == SCTP_NEED_FRTX) 651 if (chunk->fast_retransmit == SCTP_NEED_FRTX)
655 chunk->fast_retransmit = SCTP_DONT_FRTX; 652 chunk->fast_retransmit = SCTP_DONT_FRTX;
656 653
657 q->empty = 0;
658 q->asoc->stats.rtxchunks++; 654 q->asoc->stats.rtxchunks++;
659 break; 655 break;
660 } 656 }
@@ -1065,8 +1061,6 @@ static int sctp_outq_flush(struct sctp_outq *q, int rtx_timeout)
1065 1061
1066 sctp_transport_reset_timers(transport); 1062 sctp_transport_reset_timers(transport);
1067 1063
1068 q->empty = 0;
1069
1070 /* Only let one DATA chunk get bundled with a 1064 /* Only let one DATA chunk get bundled with a
1071 * COOKIE-ECHO chunk. 1065 * COOKIE-ECHO chunk.
1072 */ 1066 */
@@ -1275,29 +1269,17 @@ int sctp_outq_sack(struct sctp_outq *q, struct sctp_chunk *chunk)
1275 "advertised peer ack point:0x%x\n", __func__, asoc, ctsn, 1269 "advertised peer ack point:0x%x\n", __func__, asoc, ctsn,
1276 asoc->adv_peer_ack_point); 1270 asoc->adv_peer_ack_point);
1277 1271
1278 /* See if all chunks are acked. 1272 return sctp_outq_is_empty(q);
1279 * Make sure the empty queue handler will get run later.
1280 */
1281 q->empty = (list_empty(&q->out_chunk_list) &&
1282 list_empty(&q->retransmit));
1283 if (!q->empty)
1284 goto finish;
1285
1286 list_for_each_entry(transport, transport_list, transports) {
1287 q->empty = q->empty && list_empty(&transport->transmitted);
1288 if (!q->empty)
1289 goto finish;
1290 }
1291
1292 pr_debug("%s: sack queue is empty\n", __func__);
1293finish:
1294 return q->empty;
1295} 1273}
1296 1274
1297/* Is the outqueue empty? */ 1275/* Is the outqueue empty?
1276 * The queue is empty when we have not pending data, no in-flight data
1277 * and nothing pending retransmissions.
1278 */
1298int sctp_outq_is_empty(const struct sctp_outq *q) 1279int sctp_outq_is_empty(const struct sctp_outq *q)
1299{ 1280{
1300 return q->empty; 1281 return q->out_qlen == 0 && q->outstanding_bytes == 0 &&
1282 list_empty(&q->retransmit);
1301} 1283}
1302 1284
1303/******************************************************************** 1285/********************************************************************
diff --git a/net/tipc/link.c b/net/tipc/link.c
index 69cd9bf3f561..13b987745820 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -1498,6 +1498,7 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *b_ptr)
1498 int type; 1498 int type;
1499 1499
1500 head = head->next; 1500 head = head->next;
1501 buf->next = NULL;
1501 1502
1502 /* Ensure bearer is still enabled */ 1503 /* Ensure bearer is still enabled */
1503 if (unlikely(!b_ptr->active)) 1504 if (unlikely(!b_ptr->active))
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 6625699f497c..57b0b49f4e6e 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -234,6 +234,14 @@ static int inode_alloc_security(struct inode *inode)
234 return 0; 234 return 0;
235} 235}
236 236
237static void inode_free_rcu(struct rcu_head *head)
238{
239 struct inode_security_struct *isec;
240
241 isec = container_of(head, struct inode_security_struct, rcu);
242 kmem_cache_free(sel_inode_cache, isec);
243}
244
237static void inode_free_security(struct inode *inode) 245static void inode_free_security(struct inode *inode)
238{ 246{
239 struct inode_security_struct *isec = inode->i_security; 247 struct inode_security_struct *isec = inode->i_security;
@@ -244,8 +252,16 @@ static void inode_free_security(struct inode *inode)
244 list_del_init(&isec->list); 252 list_del_init(&isec->list);
245 spin_unlock(&sbsec->isec_lock); 253 spin_unlock(&sbsec->isec_lock);
246 254
247 inode->i_security = NULL; 255 /*
248 kmem_cache_free(sel_inode_cache, isec); 256 * The inode may still be referenced in a path walk and
257 * a call to selinux_inode_permission() can be made
258 * after inode_free_security() is called. Ideally, the VFS
259 * wouldn't do this, but fixing that is a much harder
260 * job. For now, simply free the i_security via RCU, and
261 * leave the current inode->i_security pointer intact.
262 * The inode will be freed after the RCU grace period too.
263 */
264 call_rcu(&isec->rcu, inode_free_rcu);
249} 265}
250 266
251static int file_alloc_security(struct file *file) 267static int file_alloc_security(struct file *file)
diff --git a/security/selinux/include/objsec.h b/security/selinux/include/objsec.h
index b1dfe1049450..078e553f52f2 100644
--- a/security/selinux/include/objsec.h
+++ b/security/selinux/include/objsec.h
@@ -38,7 +38,10 @@ struct task_security_struct {
38 38
39struct inode_security_struct { 39struct inode_security_struct {
40 struct inode *inode; /* back pointer to inode object */ 40 struct inode *inode; /* back pointer to inode object */
41 struct list_head list; /* list of inode_security_struct */ 41 union {
42 struct list_head list; /* list of inode_security_struct */
43 struct rcu_head rcu; /* for freeing the inode_security_struct */
44 };
42 u32 task_sid; /* SID of creating task */ 45 u32 task_sid; /* SID of creating task */
43 u32 sid; /* SID of this object */ 46 u32 sid; /* SID of this object */
44 u16 sclass; /* security class of this object */ 47 u16 sclass; /* security class of this object */
diff --git a/tools/power/cpupower/debug/kernel/cpufreq-test_tsc.c b/tools/power/cpupower/debug/kernel/cpufreq-test_tsc.c
index 66cace601e57..0f10b81e3322 100644
--- a/tools/power/cpupower/debug/kernel/cpufreq-test_tsc.c
+++ b/tools/power/cpupower/debug/kernel/cpufreq-test_tsc.c
@@ -25,12 +25,9 @@
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/delay.h> 27#include <linux/delay.h>
28 28#include <linux/acpi.h>
29#include <asm/io.h> 29#include <asm/io.h>
30 30
31#include <acpi/acpi_bus.h>
32#include <acpi/acpi_drivers.h>
33
34static int pm_tmr_ioport = 0; 31static int pm_tmr_ioport = 0;
35 32
36/*helper function to safely read acpi pm timesource*/ 33/*helper function to safely read acpi pm timesource*/