aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-04-01 15:48:54 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-04-01 15:48:54 -0400
commit4dedde7c7a18f55180574f934dbc1be84ca0400b (patch)
treed7cc511e8ba8ffceadf3f45b9a63395c4e4183c5
parent683b6c6f82a60fabf47012581c2cfbf1b037ab95 (diff)
parent0ecfe310f4517d7505599be738158087c165be7c (diff)
Merge tag 'pm+acpi-3.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull ACPI and power management updates from Rafael Wysocki: "The majority of this material spent some time in linux-next, some of it even several weeks. There are a few relatively fresh commits in it, but they are mostly fixes and simple cleanups. ACPI took the lead this time, both in terms of the number of commits and the number of modified lines of code, cpufreq follows and there are a few changes in the PM core and in cpuidle too. A new feature that already got some LWN.net's attention is the device PM QoS extension allowing latency tolerance requirements to be propagated from leaf devices to their ancestors with hardware interfaces for specifying latency tolerance. That should help systems with hardware-driven power management to avoid going too far with it in cases when there are latency tolerance constraints. There also are some significant changes in the ACPI core related to the way in which hotplug notifications are handled. They affect PCI hotplug (ACPIPHP) and the ACPI dock station code too. The bottom line is that all those notification now go through the root notify handler and are propagated to the interested subsystems by means of callbacks instead of having to install a notify handler for each device object that we can potentially get hotplug notifications for. In addition to that ACPICA will now advertise "Windows 2013" compatibility for _OSI, because some systems out there don't work correctly if that is not done (some of them don't even boot). On the system suspend side of things, all of the device suspend and resume callbacks, except for ->prepare() and ->complete(), are now going to be executed asynchronously as that turns out to speed up system suspend and resume on some platforms quite significantly and we have a few more optimizations in that area. Apart from that, there are some new device IDs and fixes and cleanups all over. In particular, the system suspend and resume handling by cpufreq should be improved and the cpuidle menu governor should be a bit more robust now. Specifics: - Device PM QoS support for latency tolerance constraints on systems with hardware interfaces allowing such constraints to be specified. That is necessary to prevent hardware-driven power management from becoming overly aggressive on some systems and to prevent power management features leading to excessive latencies from being used in some cases. - Consolidation of the handling of ACPI hotplug notifications for device objects. This causes all device hotplug notifications to go through the root notify handler (that was executed for all of them anyway before) that propagates them to individual subsystems, if necessary, by executing callbacks provided by those subsystems (those callbacks are associated with struct acpi_device objects during device enumeration). As a result, the code in question becomes both smaller in size and more straightforward and all of those changes should not affect users. - ACPICA update, including fixes related to the handling of _PRT in cases when it is broken and the addition of "Windows 2013" to the list of supported "features" for _OSI (which is necessary to support systems that work incorrectly or don't even boot without it). Changes from Bob Moore and Lv Zheng. - Consolidation of ACPI _OST handling from Jiang Liu. - ACPI battery and AC fixes allowing unusual system configurations to be handled by that code from Alexander Mezin. - New device IDs for the ACPI LPSS driver from Chiau Ee Chew. - ACPI fan and thermal optimizations related to system suspend and resume from Aaron Lu. - Cleanups related to ACPI video from Jean Delvare. - Assorted ACPI fixes and cleanups from Al Stone, Hanjun Guo, Lan Tianyu, Paul Bolle, Tomasz Nowicki. - Intel RAPL (Running Average Power Limits) driver cleanups from Jacob Pan. - intel_pstate fixes and cleanups from Dirk Brandewie. - cpufreq fixes related to system suspend/resume handling from Viresh Kumar. - cpufreq core fixes and cleanups from Viresh Kumar, Stratos Karafotis, Saravana Kannan, Rashika Kheria, Joe Perches. - cpufreq drivers updates from Viresh Kumar, Zhuoyu Zhang, Rob Herring. - cpuidle fixes related to the menu governor from Tuukka Tikkanen. - cpuidle fix related to coupled CPUs handling from Paul Burton. - Asynchronous execution of all device suspend and resume callbacks, except for ->prepare and ->complete, during system suspend and resume from Chuansheng Liu. - Delayed resuming of runtime-suspended devices during system suspend for the PCI bus type and ACPI PM domain. - New set of PM helper routines to allow device runtime PM callbacks to be used during system suspend and resume more easily from Ulf Hansson. - Assorted fixes and cleanups in the PM core from Geert Uytterhoeven, Prabhakar Lad, Philipp Zabel, Rashika Kheria, Sebastian Capella. - devfreq fix from Saravana Kannan" * tag 'pm+acpi-3.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (162 commits) PM / devfreq: Rewrite devfreq_update_status() to fix multiple bugs PM / sleep: Correct whitespace errors in <linux/pm.h> intel_pstate: Set core to min P state during core offline cpufreq: Add stop CPU callback to cpufreq_driver interface cpufreq: Remove unnecessary braces cpufreq: Fix checkpatch errors and warnings cpufreq: powerpc: add cpufreq transition latency for FSL e500mc SoCs MAINTAINERS: Reorder maintainer addresses for PM and ACPI PM / Runtime: Update runtime_idle() documentation for return value meaning video / output: Drop display output class support fujitsu-laptop: Drop unneeded include acer-wmi: Stop selecting VIDEO_OUTPUT_CONTROL ACPI / gpu / drm: Stop selecting VIDEO_OUTPUT_CONTROL ACPI / video: fix ACPI_VIDEO dependencies cpufreq: remove unused notifier: CPUFREQ_{SUSPENDCHANGE|RESUMECHANGE} cpufreq: Do not allow ->setpolicy drivers to provide ->target cpufreq: arm_big_little: set 'physical_cluster' for each CPU cpufreq: arm_big_little: make vexpress driver depend on bL core driver ACPI / button: Add ACPI Button event via netlink routine ACPI: Remove duplicate definitions of PREFIX ...
-rw-r--r--Documentation/ABI/testing/sysfs-devices-power27
-rw-r--r--Documentation/ABI/testing/sysfs-power5
-rw-r--r--Documentation/cpu-freq/core.txt4
-rw-r--r--Documentation/cpu-freq/cpu-drivers.txt8
-rw-r--r--Documentation/kernel-parameters.txt8
-rw-r--r--Documentation/power/pm_qos_interface.txt82
-rw-r--r--Documentation/trace/events-power.txt2
-rw-r--r--MAINTAINERS8
-rw-r--r--arch/arm/kernel/smp.c3
-rw-r--r--arch/arm/kernel/smp_twd.c2
-rw-r--r--arch/arm/mach-pxa/viper.c3
-rw-r--r--arch/arm/mach-spear/spear1310.c1
-rw-r--r--arch/arm/mach-spear/spear1340.c1
-rw-r--r--arch/arm64/Kconfig8
-rw-r--r--arch/ia64/configs/generic_defconfig1
-rw-r--r--arch/ia64/configs/tiger_defconfig1
-rw-r--r--arch/ia64/configs/zx1_defconfig1
-rw-r--r--arch/ia64/kernel/acpi.c4
-rw-r--r--arch/powerpc/oprofile/op_model_cell.c3
-rw-r--r--arch/sparc/kernel/time_64.c3
-rw-r--r--arch/x86/configs/i386_defconfig1
-rw-r--r--arch/x86/configs/x86_64_defconfig1
-rw-r--r--arch/x86/kernel/acpi/boot.c4
-rw-r--r--arch/x86/kernel/tsc.c3
-rw-r--r--drivers/acpi/Kconfig28
-rw-r--r--drivers/acpi/ac.c25
-rw-r--r--drivers/acpi/acpi_cmos_rtc.c2
-rw-r--r--drivers/acpi/acpi_lpss.c82
-rw-r--r--drivers/acpi/acpi_pad.c24
-rw-r--r--drivers/acpi/acpica/Makefile4
-rw-r--r--drivers/acpi/acpica/accommon.h2
-rw-r--r--drivers/acpi/acpica/acdebug.h4
-rw-r--r--drivers/acpi/acpica/acdispat.h2
-rw-r--r--drivers/acpi/acpica/acevents.h2
-rw-r--r--drivers/acpi/acpica/acglobal.h355
-rw-r--r--drivers/acpi/acpica/achware.h2
-rw-r--r--drivers/acpi/acpica/acinterp.h6
-rw-r--r--drivers/acpi/acpica/aclocal.h2
-rw-r--r--drivers/acpi/acpica/acmacros.h16
-rw-r--r--drivers/acpi/acpica/acnamesp.h2
-rw-r--r--drivers/acpi/acpica/acobject.h2
-rw-r--r--drivers/acpi/acpica/acopcode.h2
-rw-r--r--drivers/acpi/acpica/acparser.h2
-rw-r--r--drivers/acpi/acpica/acpredef.h16
-rw-r--r--drivers/acpi/acpica/acresrc.h2
-rw-r--r--drivers/acpi/acpica/acstruct.h2
-rw-r--r--drivers/acpi/acpica/actables.h2
-rw-r--r--drivers/acpi/acpica/acutils.h4
-rw-r--r--drivers/acpi/acpica/amlcode.h2
-rw-r--r--drivers/acpi/acpica/amlresrc.h2
-rw-r--r--drivers/acpi/acpica/dsargs.c2
-rw-r--r--drivers/acpi/acpica/dscontrol.c2
-rw-r--r--drivers/acpi/acpica/dsfield.c2
-rw-r--r--drivers/acpi/acpica/dsinit.c2
-rw-r--r--drivers/acpi/acpica/dsmethod.c2
-rw-r--r--drivers/acpi/acpica/dsmthdat.c2
-rw-r--r--drivers/acpi/acpica/dsobject.c2
-rw-r--r--drivers/acpi/acpica/dsopcode.c2
-rw-r--r--drivers/acpi/acpica/dsutils.c2
-rw-r--r--drivers/acpi/acpica/dswexec.c2
-rw-r--r--drivers/acpi/acpica/dswload.c2
-rw-r--r--drivers/acpi/acpica/dswload2.c2
-rw-r--r--drivers/acpi/acpica/dswscope.c2
-rw-r--r--drivers/acpi/acpica/dswstate.c2
-rw-r--r--drivers/acpi/acpica/evevent.c2
-rw-r--r--drivers/acpi/acpica/evglock.c2
-rw-r--r--drivers/acpi/acpica/evgpe.c2
-rw-r--r--drivers/acpi/acpica/evgpeblk.c2
-rw-r--r--drivers/acpi/acpica/evgpeinit.c2
-rw-r--r--drivers/acpi/acpica/evgpeutil.c2
-rw-r--r--drivers/acpi/acpica/evhandler.c2
-rw-r--r--drivers/acpi/acpica/evmisc.c2
-rw-r--r--drivers/acpi/acpica/evregion.c13
-rw-r--r--drivers/acpi/acpica/evrgnini.c2
-rw-r--r--drivers/acpi/acpica/evsci.c2
-rw-r--r--drivers/acpi/acpica/evxface.c2
-rw-r--r--drivers/acpi/acpica/evxfevnt.c2
-rw-r--r--drivers/acpi/acpica/evxfgpe.c21
-rw-r--r--drivers/acpi/acpica/evxfregn.c2
-rw-r--r--drivers/acpi/acpica/exconfig.c2
-rw-r--r--drivers/acpi/acpica/exconvrt.c2
-rw-r--r--drivers/acpi/acpica/excreate.c2
-rw-r--r--drivers/acpi/acpica/exdebug.c2
-rw-r--r--drivers/acpi/acpica/exdump.c231
-rw-r--r--drivers/acpi/acpica/exfield.c2
-rw-r--r--drivers/acpi/acpica/exfldio.c2
-rw-r--r--drivers/acpi/acpica/exmisc.c2
-rw-r--r--drivers/acpi/acpica/exmutex.c2
-rw-r--r--drivers/acpi/acpica/exnames.c2
-rw-r--r--drivers/acpi/acpica/exoparg1.c2
-rw-r--r--drivers/acpi/acpica/exoparg2.c2
-rw-r--r--drivers/acpi/acpica/exoparg3.c2
-rw-r--r--drivers/acpi/acpica/exoparg6.c2
-rw-r--r--drivers/acpi/acpica/exprep.c2
-rw-r--r--drivers/acpi/acpica/exregion.c2
-rw-r--r--drivers/acpi/acpica/exresnte.c2
-rw-r--r--drivers/acpi/acpica/exresolv.c2
-rw-r--r--drivers/acpi/acpica/exresop.c2
-rw-r--r--drivers/acpi/acpica/exstore.c2
-rw-r--r--drivers/acpi/acpica/exstoren.c2
-rw-r--r--drivers/acpi/acpica/exstorob.c2
-rw-r--r--drivers/acpi/acpica/exsystem.c2
-rw-r--r--drivers/acpi/acpica/exutils.c2
-rw-r--r--drivers/acpi/acpica/hwacpi.c2
-rw-r--r--drivers/acpi/acpica/hwesleep.c2
-rw-r--r--drivers/acpi/acpica/hwgpe.c2
-rw-r--r--drivers/acpi/acpica/hwpci.c2
-rw-r--r--drivers/acpi/acpica/hwregs.c2
-rw-r--r--drivers/acpi/acpica/hwsleep.c2
-rw-r--r--drivers/acpi/acpica/hwtimer.c2
-rw-r--r--drivers/acpi/acpica/hwvalid.c2
-rw-r--r--drivers/acpi/acpica/hwxface.c2
-rw-r--r--drivers/acpi/acpica/hwxfsleep.c2
-rw-r--r--drivers/acpi/acpica/nsaccess.c2
-rw-r--r--drivers/acpi/acpica/nsalloc.c2
-rw-r--r--drivers/acpi/acpica/nsarguments.c2
-rw-r--r--drivers/acpi/acpica/nsconvert.c2
-rw-r--r--drivers/acpi/acpica/nsdump.c2
-rw-r--r--drivers/acpi/acpica/nsdumpdv.c2
-rw-r--r--drivers/acpi/acpica/nseval.c2
-rw-r--r--drivers/acpi/acpica/nsinit.c2
-rw-r--r--drivers/acpi/acpica/nsload.c2
-rw-r--r--drivers/acpi/acpica/nsnames.c2
-rw-r--r--drivers/acpi/acpica/nsobject.c12
-rw-r--r--drivers/acpi/acpica/nsparse.c2
-rw-r--r--drivers/acpi/acpica/nspredef.c2
-rw-r--r--drivers/acpi/acpica/nsprepkg.c42
-rw-r--r--drivers/acpi/acpica/nsrepair.c31
-rw-r--r--drivers/acpi/acpica/nsrepair2.c39
-rw-r--r--drivers/acpi/acpica/nssearch.c2
-rw-r--r--drivers/acpi/acpica/nsutils.c2
-rw-r--r--drivers/acpi/acpica/nswalk.c2
-rw-r--r--drivers/acpi/acpica/nsxfeval.c35
-rw-r--r--drivers/acpi/acpica/nsxfname.c2
-rw-r--r--drivers/acpi/acpica/nsxfobj.c2
-rw-r--r--drivers/acpi/acpica/psargs.c2
-rw-r--r--drivers/acpi/acpica/psloop.c2
-rw-r--r--drivers/acpi/acpica/psobject.c2
-rw-r--r--drivers/acpi/acpica/psopcode.c2
-rw-r--r--drivers/acpi/acpica/psopinfo.c2
-rw-r--r--drivers/acpi/acpica/psparse.c2
-rw-r--r--drivers/acpi/acpica/psscope.c2
-rw-r--r--drivers/acpi/acpica/pstree.c2
-rw-r--r--drivers/acpi/acpica/psutils.c2
-rw-r--r--drivers/acpi/acpica/pswalk.c2
-rw-r--r--drivers/acpi/acpica/psxface.c2
-rw-r--r--drivers/acpi/acpica/rsaddr.c2
-rw-r--r--drivers/acpi/acpica/rscalc.c4
-rw-r--r--drivers/acpi/acpica/rscreate.c12
-rw-r--r--drivers/acpi/acpica/rsdump.c5
-rw-r--r--drivers/acpi/acpica/rsdumpinfo.c4
-rw-r--r--drivers/acpi/acpica/rsinfo.c6
-rw-r--r--drivers/acpi/acpica/rsio.c2
-rw-r--r--drivers/acpi/acpica/rsirq.c2
-rw-r--r--drivers/acpi/acpica/rslist.c2
-rw-r--r--drivers/acpi/acpica/rsmemory.c2
-rw-r--r--drivers/acpi/acpica/rsmisc.c2
-rw-r--r--drivers/acpi/acpica/rsserial.c2
-rw-r--r--drivers/acpi/acpica/rsutils.c2
-rw-r--r--drivers/acpi/acpica/rsxface.c2
-rw-r--r--drivers/acpi/acpica/tbfadt.c2
-rw-r--r--drivers/acpi/acpica/tbfind.c2
-rw-r--r--drivers/acpi/acpica/tbinstal.c17
-rw-r--r--drivers/acpi/acpica/tbprint.c22
-rw-r--r--drivers/acpi/acpica/tbutils.c2
-rw-r--r--drivers/acpi/acpica/tbxface.c2
-rw-r--r--drivers/acpi/acpica/tbxfload.c2
-rw-r--r--drivers/acpi/acpica/tbxfroot.c2
-rw-r--r--drivers/acpi/acpica/utaddress.c2
-rw-r--r--drivers/acpi/acpica/utalloc.c2
-rw-r--r--drivers/acpi/acpica/utbuffer.c2
-rw-r--r--drivers/acpi/acpica/utcache.c2
-rw-r--r--drivers/acpi/acpica/utcopy.c8
-rw-r--r--drivers/acpi/acpica/utdebug.c2
-rw-r--r--drivers/acpi/acpica/utdecode.c2
-rw-r--r--drivers/acpi/acpica/utdelete.c17
-rw-r--r--drivers/acpi/acpica/uterror.c2
-rw-r--r--drivers/acpi/acpica/uteval.c2
-rw-r--r--drivers/acpi/acpica/utexcep.c2
-rw-r--r--drivers/acpi/acpica/utglobal.c39
-rw-r--r--drivers/acpi/acpica/utids.c2
-rw-r--r--drivers/acpi/acpica/utinit.c2
-rw-r--r--drivers/acpi/acpica/utlock.c2
-rw-r--r--drivers/acpi/acpica/utmath.c2
-rw-r--r--drivers/acpi/acpica/utmisc.c2
-rw-r--r--drivers/acpi/acpica/utmutex.c2
-rw-r--r--drivers/acpi/acpica/utobject.c2
-rw-r--r--drivers/acpi/acpica/utosi.c28
-rw-r--r--drivers/acpi/acpica/utownerid.c2
-rw-r--r--drivers/acpi/acpica/utpredef.c2
-rw-r--r--drivers/acpi/acpica/utresrc.c5
-rw-r--r--drivers/acpi/acpica/utstate.c2
-rw-r--r--drivers/acpi/acpica/utstring.c2
-rw-r--r--drivers/acpi/acpica/uttrack.c5
-rw-r--r--drivers/acpi/acpica/utxface.c2
-rw-r--r--drivers/acpi/acpica/utxferror.c2
-rw-r--r--drivers/acpi/acpica/utxfinit.c2
-rw-r--r--drivers/acpi/acpica/utxfmutex.c2
-rw-r--r--drivers/acpi/apei/Kconfig2
-rw-r--r--drivers/acpi/battery.c7
-rw-r--r--drivers/acpi/battery.h10
-rw-r--r--drivers/acpi/bus.c63
-rw-r--r--drivers/acpi/button.c4
-rw-r--r--drivers/acpi/container.c5
-rw-r--r--drivers/acpi/device_pm.c41
-rw-r--r--drivers/acpi/dock.c454
-rw-r--r--drivers/acpi/fan.c13
-rw-r--r--drivers/acpi/glue.c12
-rw-r--r--drivers/acpi/internal.h13
-rw-r--r--drivers/acpi/osl.c27
-rw-r--r--drivers/acpi/pci_irq.c36
-rw-r--r--drivers/acpi/pci_link.c2
-rw-r--r--drivers/acpi/pci_root.c4
-rw-r--r--drivers/acpi/power.c2
-rw-r--r--drivers/acpi/processor_core.c79
-rw-r--r--drivers/acpi/processor_driver.c2
-rw-r--r--drivers/acpi/processor_perflib.c14
-rw-r--r--drivers/acpi/sbs.c2
-rw-r--r--drivers/acpi/scan.c261
-rw-r--r--drivers/acpi/sysfs.c2
-rw-r--r--drivers/acpi/tables.c128
-rw-r--r--drivers/acpi/thermal.c37
-rw-r--r--drivers/acpi/utils.c16
-rw-r--r--drivers/acpi/video.c2
-rw-r--r--drivers/acpi/video_detect.c2
-rw-r--r--drivers/ata/libata-acpi.c72
-rw-r--r--drivers/base/power/Makefile3
-rw-r--r--drivers/base/power/domain.c2
-rw-r--r--drivers/base/power/main.c280
-rw-r--r--drivers/base/power/power.h4
-rw-r--r--drivers/base/power/qos.c220
-rw-r--r--drivers/base/power/runtime.c164
-rw-r--r--drivers/base/power/sysfs.c97
-rw-r--r--drivers/cpufreq/Kconfig.arm17
-rw-r--r--drivers/cpufreq/acpi-cpufreq.c1
-rw-r--r--drivers/cpufreq/arm_big_little.c6
-rw-r--r--drivers/cpufreq/blackfin-cpufreq.c1
-rw-r--r--drivers/cpufreq/cpufreq-cpu0.c1
-rw-r--r--drivers/cpufreq/cpufreq.c446
-rw-r--r--drivers/cpufreq/cpufreq_stats.c38
-rw-r--r--drivers/cpufreq/cris-artpec3-cpufreq.c1
-rw-r--r--drivers/cpufreq/cris-etraxfs-cpufreq.c1
-rw-r--r--drivers/cpufreq/davinci-cpufreq.c1
-rw-r--r--drivers/cpufreq/e_powersaver.c1
-rw-r--r--drivers/cpufreq/elanfreq.c1
-rw-r--r--drivers/cpufreq/exynos-cpufreq.c97
-rw-r--r--drivers/cpufreq/exynos5440-cpufreq.c1
-rw-r--r--drivers/cpufreq/freq_table.c46
-rw-r--r--drivers/cpufreq/ia64-acpi-cpufreq.c1
-rw-r--r--drivers/cpufreq/imx6q-cpufreq.c1
-rw-r--r--drivers/cpufreq/intel_pstate.c45
-rw-r--r--drivers/cpufreq/kirkwood-cpufreq.c1
-rw-r--r--drivers/cpufreq/longhaul.c1
-rw-r--r--drivers/cpufreq/loongson2_cpufreq.c1
-rw-r--r--drivers/cpufreq/omap-cpufreq.c1
-rw-r--r--drivers/cpufreq/p4-clockmod.c1
-rw-r--r--drivers/cpufreq/pasemi-cpufreq.c1
-rw-r--r--drivers/cpufreq/powernow-k6.c1
-rw-r--r--drivers/cpufreq/powernow-k7.c2
-rw-r--r--drivers/cpufreq/powernow-k8.c2
-rw-r--r--drivers/cpufreq/ppc-corenet-cpufreq.c5
-rw-r--r--drivers/cpufreq/ppc_cbe_cpufreq.c1
-rw-r--r--drivers/cpufreq/pxa2xx-cpufreq.c1
-rw-r--r--drivers/cpufreq/pxa3xx-cpufreq.c1
-rw-r--r--drivers/cpufreq/s5pv210-cpufreq.c49
-rw-r--r--drivers/cpufreq/sc520_freq.c1
-rw-r--r--drivers/cpufreq/sh-cpufreq.c1
-rw-r--r--drivers/cpufreq/sparc-us2e-cpufreq.c4
-rw-r--r--drivers/cpufreq/sparc-us3-cpufreq.c4
-rw-r--r--drivers/cpufreq/spear-cpufreq.c14
-rw-r--r--drivers/cpufreq/speedstep-centrino.c2
-rw-r--r--drivers/cpufreq/speedstep-ich.c1
-rw-r--r--drivers/cpufreq/speedstep-smi.c1
-rw-r--r--drivers/cpufreq/tegra-cpufreq.c47
-rw-r--r--drivers/cpuidle/cpuidle.c3
-rw-r--r--drivers/cpuidle/driver.c2
-rw-r--r--drivers/cpuidle/governors/menu.c75
-rw-r--r--drivers/devfreq/devfreq.c31
-rw-r--r--drivers/gpu/drm/gma500/Kconfig1
-rw-r--r--drivers/gpu/drm/i915/Kconfig1
-rw-r--r--drivers/gpu/drm/nouveau/Kconfig3
-rw-r--r--drivers/input/touchscreen/st1232.c3
-rw-r--r--drivers/mtd/nand/sh_flctl.c2
-rw-r--r--drivers/pci/hotplug/acpiphp.h16
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c523
-rw-r--r--drivers/pci/pci-driver.c33
-rw-r--r--drivers/pcmcia/sa11xx_base.c3
-rw-r--r--drivers/platform/x86/Kconfig2
-rw-r--r--drivers/platform/x86/fujitsu-laptop.c1
-rw-r--r--drivers/powercap/intel_rapl.c17
-rw-r--r--drivers/tty/serial/sh-sci.c3
-rw-r--r--drivers/video/Kconfig6
-rw-r--r--drivers/video/Makefile2
-rw-r--r--drivers/video/output.c133
-rw-r--r--drivers/xen/xen-acpi-cpuhotplug.c2
-rw-r--r--drivers/xen/xen-acpi-memhotplug.c2
-rw-r--r--drivers/xen/xen-acpi-pad.c26
-rw-r--r--include/acpi/acbuffer.h2
-rw-r--r--include/acpi/acconfig.h2
-rw-r--r--include/acpi/acexcep.h2
-rw-r--r--include/acpi/acnames.h2
-rw-r--r--include/acpi/acoutput.h2
-rw-r--r--include/acpi/acpi.h5
-rw-r--r--include/acpi/acpi_bus.h49
-rw-r--r--include/acpi/acpi_drivers.h26
-rw-r--r--include/acpi/acpiosxf.h2
-rw-r--r--include/acpi/acpixf.h8
-rw-r--r--include/acpi/acrestyp.h2
-rw-r--r--include/acpi/actbl.h2
-rw-r--r--include/acpi/actbl1.h2
-rw-r--r--include/acpi/actbl2.h2
-rw-r--r--include/acpi/actbl3.h2
-rw-r--r--include/acpi/actypes.h66
-rw-r--r--include/acpi/platform/acenv.h2
-rw-r--r--include/acpi/platform/acgcc.h2
-rw-r--r--include/acpi/platform/aclinux.h20
-rw-r--r--include/linux/acpi.h4
-rw-r--r--include/linux/cpufreq.h25
-rw-r--r--include/linux/pci-acpi.h4
-rw-r--r--include/linux/pm.h71
-rw-r--r--include/linux/pm_qos.h34
-rw-r--r--include/linux/pm_runtime.h4
-rw-r--r--include/linux/video_output.h57
-rw-r--r--include/trace/events/power.h4
-rw-r--r--kernel/power/hibernate.c22
-rw-r--r--kernel/power/main.c4
-rw-r--r--kernel/power/power.h2
-rw-r--r--kernel/power/qos.c18
-rw-r--r--kernel/power/snapshot.c2
-rw-r--r--kernel/power/suspend.c2
-rw-r--r--kernel/power/wakelock.c2
331 files changed, 3140 insertions, 2764 deletions
diff --git a/Documentation/ABI/testing/sysfs-devices-power b/Documentation/ABI/testing/sysfs-devices-power
index efe449bdf811..7dbf96b724ed 100644
--- a/Documentation/ABI/testing/sysfs-devices-power
+++ b/Documentation/ABI/testing/sysfs-devices-power
@@ -187,7 +187,7 @@ Description:
187 Not all drivers support this attribute. If it isn't supported, 187 Not all drivers support this attribute. If it isn't supported,
188 attempts to read or write it will yield I/O errors. 188 attempts to read or write it will yield I/O errors.
189 189
190What: /sys/devices/.../power/pm_qos_latency_us 190What: /sys/devices/.../power/pm_qos_resume_latency_us
191Date: March 2012 191Date: March 2012
192Contact: Rafael J. Wysocki <rjw@rjwysocki.net> 192Contact: Rafael J. Wysocki <rjw@rjwysocki.net>
193Description: 193Description:
@@ -205,6 +205,31 @@ Description:
205 This attribute has no effect on system-wide suspend/resume and 205 This attribute has no effect on system-wide suspend/resume and
206 hibernation. 206 hibernation.
207 207
208What: /sys/devices/.../power/pm_qos_latency_tolerance_us
209Date: January 2014
210Contact: Rafael J. Wysocki <rjw@rjwysocki.net>
211Description:
212 The /sys/devices/.../power/pm_qos_latency_tolerance_us attribute
213 contains the PM QoS active state latency tolerance limit for the
214 given device in microseconds. That is the maximum memory access
215 latency the device can suffer without any visible adverse
216 effects on user space functionality. If that value is the
217 string "any", the latency does not matter to user space at all,
218 but hardware should not be allowed to set the latency tolerance
219 for the device automatically.
220
221 Reading "auto" from this file means that the maximum memory
222 access latency for the device may be determined automatically
223 by the hardware as needed. Writing "auto" to it allows the
224 hardware to be switched to this mode if there are no other
225 latency tolerance requirements from the kernel side.
226
227 This attribute is only present if the feature controlled by it
228 is supported by the hardware.
229
230 This attribute has no effect on runtime suspend and resume of
231 devices and on system-wide suspend/resume and hibernation.
232
208What: /sys/devices/.../power/pm_qos_no_power_off 233What: /sys/devices/.../power/pm_qos_no_power_off
209Date: September 2012 234Date: September 2012
210Contact: Rafael J. Wysocki <rjw@rjwysocki.net> 235Contact: Rafael J. Wysocki <rjw@rjwysocki.net>
diff --git a/Documentation/ABI/testing/sysfs-power b/Documentation/ABI/testing/sysfs-power
index 205a73878441..64c9276e9421 100644
--- a/Documentation/ABI/testing/sysfs-power
+++ b/Documentation/ABI/testing/sysfs-power
@@ -12,8 +12,9 @@ Contact: Rafael J. Wysocki <rjw@rjwysocki.net>
12Description: 12Description:
13 The /sys/power/state file controls the system power state. 13 The /sys/power/state file controls the system power state.
14 Reading from this file returns what states are supported, 14 Reading from this file returns what states are supported,
15 which is hard-coded to 'standby' (Power-On Suspend), 'mem' 15 which is hard-coded to 'freeze' (Low-Power Idle), 'standby'
16 (Suspend-to-RAM), and 'disk' (Suspend-to-Disk). 16 (Power-On Suspend), 'mem' (Suspend-to-RAM), and 'disk'
17 (Suspend-to-Disk).
17 18
18 Writing to this file one of these strings causes the system to 19 Writing to this file one of these strings causes the system to
19 transition into that state. Please see the file 20 transition into that state. Please see the file
diff --git a/Documentation/cpu-freq/core.txt b/Documentation/cpu-freq/core.txt
index ce0666e51036..0060d76b445f 100644
--- a/Documentation/cpu-freq/core.txt
+++ b/Documentation/cpu-freq/core.txt
@@ -92,7 +92,3 @@ values:
92cpu - number of the affected CPU 92cpu - number of the affected CPU
93old - old frequency 93old - old frequency
94new - new frequency 94new - new frequency
95
96If the cpufreq core detects the frequency has changed while the system
97was suspended, these notifiers are called with CPUFREQ_RESUMECHANGE as
98second argument.
diff --git a/Documentation/cpu-freq/cpu-drivers.txt b/Documentation/cpu-freq/cpu-drivers.txt
index 8b1a4451422e..48da5fdcb9f1 100644
--- a/Documentation/cpu-freq/cpu-drivers.txt
+++ b/Documentation/cpu-freq/cpu-drivers.txt
@@ -61,7 +61,13 @@ target_index - See below on the differences.
61 61
62And optionally 62And optionally
63 63
64cpufreq_driver.exit - A pointer to a per-CPU cleanup function. 64cpufreq_driver.exit - A pointer to a per-CPU cleanup
65 function called during CPU_POST_DEAD
66 phase of cpu hotplug process.
67
68cpufreq_driver.stop_cpu - A pointer to a per-CPU stop function
69 called during CPU_DOWN_PREPARE phase of
70 cpu hotplug process.
65 71
66cpufreq_driver.resume - A pointer to a per-CPU resume function 72cpufreq_driver.resume - A pointer to a per-CPU resume function
67 which is called with interrupts disabled 73 which is called with interrupts disabled
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 67755ea834a7..121d5fcbd94a 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -231,6 +231,14 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
231 231
232 acpi_no_auto_ssdt [HW,ACPI] Disable automatic loading of SSDT 232 acpi_no_auto_ssdt [HW,ACPI] Disable automatic loading of SSDT
233 233
234 acpica_no_return_repair [HW, ACPI]
235 Disable AML predefined validation mechanism
236 This mechanism can repair the evaluation result to make
237 the return objects more ACPI specification compliant.
238 This option is useful for developers to identify the
239 root cause of an AML interpreter issue when the issue
240 has something to do with the repair mechanism.
241
234 acpi_os_name= [HW,ACPI] Tell ACPI BIOS the name of the OS 242 acpi_os_name= [HW,ACPI] Tell ACPI BIOS the name of the OS
235 Format: To spoof as Windows 98: ="Microsoft Windows" 243 Format: To spoof as Windows 98: ="Microsoft Windows"
236 244
diff --git a/Documentation/power/pm_qos_interface.txt b/Documentation/power/pm_qos_interface.txt
index 483632087788..a5da5c7e7128 100644
--- a/Documentation/power/pm_qos_interface.txt
+++ b/Documentation/power/pm_qos_interface.txt
@@ -88,17 +88,19 @@ node.
88 88
892. PM QoS per-device latency and flags framework 892. PM QoS per-device latency and flags framework
90 90
91For each device, there are two lists of PM QoS requests. One is maintained 91For each device, there are three lists of PM QoS requests. Two of them are
92along with the aggregated target of latency value and the other is for PM QoS 92maintained along with the aggregated targets of resume latency and active
93flags. Values are updated in response to changes of the request list. 93state latency tolerance (in microseconds) and the third one is for PM QoS flags.
94Values are updated in response to changes of the request list.
94 95
95Target latency value is simply the minimum of the request values held in the 96The target values of resume latency and active state latency tolerance are
96parameter list elements. The PM QoS flags aggregate value is a gather (bitwise 97simply the minimum of the request values held in the parameter list elements.
97OR) of all list elements' values. Two device PM QoS flags are defined currently: 98The PM QoS flags aggregate value is a gather (bitwise OR) of all list elements'
98PM_QOS_FLAG_NO_POWER_OFF and PM_QOS_FLAG_REMOTE_WAKEUP. 99values. Two device PM QoS flags are defined currently: PM_QOS_FLAG_NO_POWER_OFF
100and PM_QOS_FLAG_REMOTE_WAKEUP.
99 101
100Note: the aggregated target value is implemented as an atomic variable so that 102Note: The aggregated target values are implemented in such a way that reading
101reading the aggregated value does not require any locking mechanism. 103the aggregated value does not require any locking mechanism.
102 104
103 105
104From kernel mode the use of this interface is the following: 106From kernel mode the use of this interface is the following:
@@ -132,19 +134,21 @@ The meaning of the return values is as follows:
132 PM_QOS_FLAGS_UNDEFINED: The device's PM QoS structure has not been 134 PM_QOS_FLAGS_UNDEFINED: The device's PM QoS structure has not been
133 initialized or the list of requests is empty. 135 initialized or the list of requests is empty.
134 136
135int dev_pm_qos_add_ancestor_request(dev, handle, value) 137int dev_pm_qos_add_ancestor_request(dev, handle, type, value)
136Add a PM QoS request for the first direct ancestor of the given device whose 138Add a PM QoS request for the first direct ancestor of the given device whose
137power.ignore_children flag is unset. 139power.ignore_children flag is unset (for DEV_PM_QOS_RESUME_LATENCY requests)
140or whose power.set_latency_tolerance callback pointer is not NULL (for
141DEV_PM_QOS_LATENCY_TOLERANCE requests).
138 142
139int dev_pm_qos_expose_latency_limit(device, value) 143int dev_pm_qos_expose_latency_limit(device, value)
140Add a request to the device's PM QoS list of latency constraints and create 144Add a request to the device's PM QoS list of resume latency constraints and
141a sysfs attribute pm_qos_resume_latency_us under the device's power directory 145create a sysfs attribute pm_qos_resume_latency_us under the device's power
142allowing user space to manipulate that request. 146directory allowing user space to manipulate that request.
143 147
144void dev_pm_qos_hide_latency_limit(device) 148void dev_pm_qos_hide_latency_limit(device)
145Drop the request added by dev_pm_qos_expose_latency_limit() from the device's 149Drop the request added by dev_pm_qos_expose_latency_limit() from the device's
146PM QoS list of latency constraints and remove sysfs attribute pm_qos_resume_latency_us 150PM QoS list of resume latency constraints and remove sysfs attribute
147from the device's power directory. 151pm_qos_resume_latency_us from the device's power directory.
148 152
149int dev_pm_qos_expose_flags(device, value) 153int dev_pm_qos_expose_flags(device, value)
150Add a request to the device's PM QoS list of flags and create sysfs attributes 154Add a request to the device's PM QoS list of flags and create sysfs attributes
@@ -163,7 +167,7 @@ a per-device notification tree and a global notification tree.
163int dev_pm_qos_add_notifier(device, notifier): 167int dev_pm_qos_add_notifier(device, notifier):
164Adds a notification callback function for the device. 168Adds a notification callback function for the device.
165The callback is called when the aggregated value of the device constraints list 169The callback is called when the aggregated value of the device constraints list
166is changed. 170is changed (for resume latency device PM QoS only).
167 171
168int dev_pm_qos_remove_notifier(device, notifier): 172int dev_pm_qos_remove_notifier(device, notifier):
169Removes the notification callback function for the device. 173Removes the notification callback function for the device.
@@ -171,14 +175,48 @@ Removes the notification callback function for the device.
171int dev_pm_qos_add_global_notifier(notifier): 175int dev_pm_qos_add_global_notifier(notifier):
172Adds a notification callback function in the global notification tree of the 176Adds a notification callback function in the global notification tree of the
173framework. 177framework.
174The callback is called when the aggregated value for any device is changed. 178The callback is called when the aggregated value for any device is changed
179(for resume latency device PM QoS only).
175 180
176int dev_pm_qos_remove_global_notifier(notifier): 181int dev_pm_qos_remove_global_notifier(notifier):
177Removes the notification callback function from the global notification tree 182Removes the notification callback function from the global notification tree
178of the framework. 183of the framework.
179 184
180 185
181From user mode: 186Active state latency tolerance
182No API for user space access to the per-device latency constraints is provided 187
183yet - still under discussion. 188This device PM QoS type is used to support systems in which hardware may switch
184 189to energy-saving operation modes on the fly. In those systems, if the operation
190mode chosen by the hardware attempts to save energy in an overly aggressive way,
191it may cause excess latencies to be visible to software, causing it to miss
192certain protocol requirements or target frame or sample rates etc.
193
194If there is a latency tolerance control mechanism for a given device available
195to software, the .set_latency_tolerance callback in that device's dev_pm_info
196structure should be populated. The routine pointed to by it is should implement
197whatever is necessary to transfer the effective requirement value to the
198hardware.
199
200Whenever the effective latency tolerance changes for the device, its
201.set_latency_tolerance() callback will be executed and the effective value will
202be passed to it. If that value is negative, which means that the list of
203latency tolerance requirements for the device is empty, the callback is expected
204to switch the underlying hardware latency tolerance control mechanism to an
205autonomous mode if available. If that value is PM_QOS_LATENCY_ANY, in turn, and
206the hardware supports a special "no requirement" setting, the callback is
207expected to use it. That allows software to prevent the hardware from
208automatically updating the device's latency tolerance in response to its power
209state changes (e.g. during transitions from D3cold to D0), which generally may
210be done in the autonomous latency tolerance control mode.
211
212If .set_latency_tolerance() is present for the device, sysfs attribute
213pm_qos_latency_tolerance_us will be present in the devivce's power directory.
214Then, user space can use that attribute to specify its latency tolerance
215requirement for the device, if any. Writing "any" to it means "no requirement,
216but do not let the hardware control latency tolerance" and writing "auto" to it
217allows the hardware to be switched to the autonomous mode if there are no other
218requirements from the kernel side in the device's list.
219
220Kernel code can use the functions described above along with the
221DEV_PM_QOS_LATENCY_TOLERANCE device PM QoS type to add, remove and update
222latency tolerance requirements for devices.
diff --git a/Documentation/trace/events-power.txt b/Documentation/trace/events-power.txt
index 3bd33b8dc7c4..21d514ced212 100644
--- a/Documentation/trace/events-power.txt
+++ b/Documentation/trace/events-power.txt
@@ -92,5 +92,5 @@ dev_pm_qos_remove_request "device=%s type=%s new_value=%d"
92 92
93The first parameter gives the device name which tries to add/update/remove 93The first parameter gives the device name which tries to add/update/remove
94QoS requests. 94QoS requests.
95The second parameter gives the request type (e.g. "DEV_PM_QOS_LATENCY"). 95The second parameter gives the request type (e.g. "DEV_PM_QOS_RESUME_LATENCY").
96The third parameter is value to be added/updated/removed. 96The third parameter is value to be added/updated/removed.
diff --git a/MAINTAINERS b/MAINTAINERS
index d1f3cb340e01..eea871fdb8f9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -242,8 +242,8 @@ S: Maintained
242F: drivers/platform/x86/acer-wmi.c 242F: drivers/platform/x86/acer-wmi.c
243 243
244ACPI 244ACPI
245M: Len Brown <lenb@kernel.org>
246M: Rafael J. Wysocki <rjw@rjwysocki.net> 245M: Rafael J. Wysocki <rjw@rjwysocki.net>
246M: Len Brown <lenb@kernel.org>
247L: linux-acpi@vger.kernel.org 247L: linux-acpi@vger.kernel.org
248W: https://01.org/linux-acpi 248W: https://01.org/linux-acpi
249Q: https://patchwork.kernel.org/project/linux-acpi/list/ 249Q: https://patchwork.kernel.org/project/linux-acpi/list/
@@ -3658,8 +3658,8 @@ S: Maintained
3658F: fs/freevxfs/ 3658F: fs/freevxfs/
3659 3659
3660FREEZER 3660FREEZER
3661M: Pavel Machek <pavel@ucw.cz>
3662M: "Rafael J. Wysocki" <rjw@rjwysocki.net> 3661M: "Rafael J. Wysocki" <rjw@rjwysocki.net>
3662M: Pavel Machek <pavel@ucw.cz>
3663L: linux-pm@vger.kernel.org 3663L: linux-pm@vger.kernel.org
3664S: Supported 3664S: Supported
3665F: Documentation/power/freezing-of-tasks.txt 3665F: Documentation/power/freezing-of-tasks.txt
@@ -4023,8 +4023,8 @@ S: Maintained
4023F: drivers/video/hgafb.c 4023F: drivers/video/hgafb.c
4024 4024
4025HIBERNATION (aka Software Suspend, aka swsusp) 4025HIBERNATION (aka Software Suspend, aka swsusp)
4026M: Pavel Machek <pavel@ucw.cz>
4027M: "Rafael J. Wysocki" <rjw@rjwysocki.net> 4026M: "Rafael J. Wysocki" <rjw@rjwysocki.net>
4027M: Pavel Machek <pavel@ucw.cz>
4028L: linux-pm@vger.kernel.org 4028L: linux-pm@vger.kernel.org
4029S: Supported 4029S: Supported
4030F: arch/x86/power/ 4030F: arch/x86/power/
@@ -8453,9 +8453,9 @@ F: arch/sh/
8453F: drivers/sh/ 8453F: drivers/sh/
8454 8454
8455SUSPEND TO RAM 8455SUSPEND TO RAM
8456M: "Rafael J. Wysocki" <rjw@rjwysocki.net>
8456M: Len Brown <len.brown@intel.com> 8457M: Len Brown <len.brown@intel.com>
8457M: Pavel Machek <pavel@ucw.cz> 8458M: Pavel Machek <pavel@ucw.cz>
8458M: "Rafael J. Wysocki" <rjw@rjwysocki.net>
8459L: linux-pm@vger.kernel.org 8459L: linux-pm@vger.kernel.org
8460S: Supported 8460S: Supported
8461F: Documentation/power/ 8461F: Documentation/power/
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index b7b4c86e338b..7c4fada440f0 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -674,8 +674,7 @@ static int cpufreq_callback(struct notifier_block *nb,
674 } 674 }
675 675
676 if ((val == CPUFREQ_PRECHANGE && freq->old < freq->new) || 676 if ((val == CPUFREQ_PRECHANGE && freq->old < freq->new) ||
677 (val == CPUFREQ_POSTCHANGE && freq->old > freq->new) || 677 (val == CPUFREQ_POSTCHANGE && freq->old > freq->new)) {
678 (val == CPUFREQ_RESUMECHANGE || val == CPUFREQ_SUSPENDCHANGE)) {
679 loops_per_jiffy = cpufreq_scale(global_l_p_j_ref, 678 loops_per_jiffy = cpufreq_scale(global_l_p_j_ref,
680 global_l_p_j_ref_freq, 679 global_l_p_j_ref_freq,
681 freq->new); 680 freq->new);
diff --git a/arch/arm/kernel/smp_twd.c b/arch/arm/kernel/smp_twd.c
index 6591e26fc13f..dfc32130bc44 100644
--- a/arch/arm/kernel/smp_twd.c
+++ b/arch/arm/kernel/smp_twd.c
@@ -166,7 +166,7 @@ static int twd_cpufreq_transition(struct notifier_block *nb,
166 * frequency. The timer is local to a cpu, so cross-call to the 166 * frequency. The timer is local to a cpu, so cross-call to the
167 * changing cpu. 167 * changing cpu.
168 */ 168 */
169 if (state == CPUFREQ_POSTCHANGE || state == CPUFREQ_RESUMECHANGE) 169 if (state == CPUFREQ_POSTCHANGE)
170 smp_call_function_single(freqs->cpu, twd_update_frequency, 170 smp_call_function_single(freqs->cpu, twd_update_frequency,
171 NULL, 1); 171 NULL, 1);
172 172
diff --git a/arch/arm/mach-pxa/viper.c b/arch/arm/mach-pxa/viper.c
index 29905b127ad9..41f27f667ca8 100644
--- a/arch/arm/mach-pxa/viper.c
+++ b/arch/arm/mach-pxa/viper.c
@@ -885,9 +885,6 @@ static int viper_cpufreq_notifier(struct notifier_block *nb,
885 viper_set_core_cpu_voltage(freq->new, 0); 885 viper_set_core_cpu_voltage(freq->new, 0);
886 } 886 }
887 break; 887 break;
888 case CPUFREQ_RESUMECHANGE:
889 viper_set_core_cpu_voltage(freq->new, 0);
890 break;
891 default: 888 default:
892 /* ignore */ 889 /* ignore */
893 break; 890 break;
diff --git a/arch/arm/mach-spear/spear1310.c b/arch/arm/mach-spear/spear1310.c
index 7ad003001ab7..824b12a56a42 100644
--- a/arch/arm/mach-spear/spear1310.c
+++ b/arch/arm/mach-spear/spear1310.c
@@ -28,6 +28,7 @@
28static void __init spear1310_dt_init(void) 28static void __init spear1310_dt_init(void)
29{ 29{
30 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); 30 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
31 platform_device_register_simple("spear-cpufreq", -1, NULL, 0);
31} 32}
32 33
33static const char * const spear1310_dt_board_compat[] = { 34static const char * const spear1310_dt_board_compat[] = {
diff --git a/arch/arm/mach-spear/spear1340.c b/arch/arm/mach-spear/spear1340.c
index 3fb683424729..7b6bff7154e1 100644
--- a/arch/arm/mach-spear/spear1340.c
+++ b/arch/arm/mach-spear/spear1340.c
@@ -143,6 +143,7 @@ static void __init spear1340_dt_init(void)
143{ 143{
144 of_platform_populate(NULL, of_default_bus_match_table, 144 of_platform_populate(NULL, of_default_bus_match_table,
145 spear1340_auxdata_lookup, NULL); 145 spear1340_auxdata_lookup, NULL);
146 platform_device_register_simple("spear-cpufreq", -1, NULL, 0);
146} 147}
147 148
148static const char * const spear1340_dt_board_compat[] = { 149static const char * const spear1340_dt_board_compat[] = {
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 516d8a7ca697..07aa3556952c 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -325,6 +325,14 @@ source "drivers/cpufreq/Kconfig"
325 325
326endmenu 326endmenu
327 327
328menu "Power management options"
329
330source "kernel/power/Kconfig"
331
332source "drivers/cpufreq/Kconfig"
333
334endmenu
335
328source "net/Kconfig" 336source "net/Kconfig"
329 337
330source "drivers/Kconfig" 338source "drivers/Kconfig"
diff --git a/arch/ia64/configs/generic_defconfig b/arch/ia64/configs/generic_defconfig
index 6404acbb84b2..b4efaf2bc13e 100644
--- a/arch/ia64/configs/generic_defconfig
+++ b/arch/ia64/configs/generic_defconfig
@@ -25,7 +25,6 @@ CONFIG_KEXEC=y
25CONFIG_CRASH_DUMP=y 25CONFIG_CRASH_DUMP=y
26CONFIG_EFI_VARS=y 26CONFIG_EFI_VARS=y
27CONFIG_BINFMT_MISC=m 27CONFIG_BINFMT_MISC=m
28CONFIG_ACPI_PROCFS=y
29CONFIG_ACPI_BUTTON=m 28CONFIG_ACPI_BUTTON=m
30CONFIG_ACPI_FAN=m 29CONFIG_ACPI_FAN=m
31CONFIG_ACPI_DOCK=y 30CONFIG_ACPI_DOCK=y
diff --git a/arch/ia64/configs/tiger_defconfig b/arch/ia64/configs/tiger_defconfig
index 0f4e9e41f130..0fed9ae5a42a 100644
--- a/arch/ia64/configs/tiger_defconfig
+++ b/arch/ia64/configs/tiger_defconfig
@@ -26,7 +26,6 @@ CONFIG_IA64_PALINFO=y
26CONFIG_KEXEC=y 26CONFIG_KEXEC=y
27CONFIG_EFI_VARS=y 27CONFIG_EFI_VARS=y
28CONFIG_BINFMT_MISC=m 28CONFIG_BINFMT_MISC=m
29CONFIG_ACPI_PROCFS=y
30CONFIG_ACPI_BUTTON=m 29CONFIG_ACPI_BUTTON=m
31CONFIG_ACPI_FAN=m 30CONFIG_ACPI_FAN=m
32CONFIG_ACPI_PROCESSOR=m 31CONFIG_ACPI_PROCESSOR=m
diff --git a/arch/ia64/configs/zx1_defconfig b/arch/ia64/configs/zx1_defconfig
index fc7aba07c2b4..54bc72eda30d 100644
--- a/arch/ia64/configs/zx1_defconfig
+++ b/arch/ia64/configs/zx1_defconfig
@@ -16,7 +16,6 @@ CONFIG_IA64_PALINFO=y
16CONFIG_CRASH_DUMP=y 16CONFIG_CRASH_DUMP=y
17CONFIG_EFI_VARS=y 17CONFIG_EFI_VARS=y
18CONFIG_BINFMT_MISC=y 18CONFIG_BINFMT_MISC=y
19CONFIG_ACPI_PROCFS=y
20CONFIG_HOTPLUG_PCI=y 19CONFIG_HOTPLUG_PCI=y
21CONFIG_HOTPLUG_PCI_ACPI=y 20CONFIG_HOTPLUG_PCI_ACPI=y
22CONFIG_PACKET=y 21CONFIG_PACKET=y
diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c
index 07d209c9507f..467497ade45f 100644
--- a/arch/ia64/kernel/acpi.c
+++ b/arch/ia64/kernel/acpi.c
@@ -54,10 +54,6 @@
54#include <asm/sal.h> 54#include <asm/sal.h>
55#include <asm/cyclone.h> 55#include <asm/cyclone.h>
56 56
57#define BAD_MADT_ENTRY(entry, end) ( \
58 (!entry) || (unsigned long)entry + sizeof(*entry) > end || \
59 ((struct acpi_subtable_header *)entry)->length < sizeof(*entry))
60
61#define PREFIX "ACPI: " 57#define PREFIX "ACPI: "
62 58
63unsigned int acpi_cpei_override; 59unsigned int acpi_cpei_override;
diff --git a/arch/powerpc/oprofile/op_model_cell.c b/arch/powerpc/oprofile/op_model_cell.c
index 1f0ebdeea5f7..863d89386f60 100644
--- a/arch/powerpc/oprofile/op_model_cell.c
+++ b/arch/powerpc/oprofile/op_model_cell.c
@@ -1121,8 +1121,7 @@ oprof_cpufreq_notify(struct notifier_block *nb, unsigned long val, void *data)
1121 int ret = 0; 1121 int ret = 0;
1122 struct cpufreq_freqs *frq = data; 1122 struct cpufreq_freqs *frq = data;
1123 if ((val == CPUFREQ_PRECHANGE && frq->old < frq->new) || 1123 if ((val == CPUFREQ_PRECHANGE && frq->old < frq->new) ||
1124 (val == CPUFREQ_POSTCHANGE && frq->old > frq->new) || 1124 (val == CPUFREQ_POSTCHANGE && frq->old > frq->new))
1125 (val == CPUFREQ_RESUMECHANGE || val == CPUFREQ_SUSPENDCHANGE))
1126 set_spu_profiling_frequency(frq->new, spu_cycle_reset); 1125 set_spu_profiling_frequency(frq->new, spu_cycle_reset);
1127 return ret; 1126 return ret;
1128} 1127}
diff --git a/arch/sparc/kernel/time_64.c b/arch/sparc/kernel/time_64.c
index 24e8b8705e7f..3fddf64c7fc6 100644
--- a/arch/sparc/kernel/time_64.c
+++ b/arch/sparc/kernel/time_64.c
@@ -659,8 +659,7 @@ static int sparc64_cpufreq_notifier(struct notifier_block *nb, unsigned long val
659 ft->clock_tick_ref = cpu_data(cpu).clock_tick; 659 ft->clock_tick_ref = cpu_data(cpu).clock_tick;
660 } 660 }
661 if ((val == CPUFREQ_PRECHANGE && freq->old < freq->new) || 661 if ((val == CPUFREQ_PRECHANGE && freq->old < freq->new) ||
662 (val == CPUFREQ_POSTCHANGE && freq->old > freq->new) || 662 (val == CPUFREQ_POSTCHANGE && freq->old > freq->new)) {
663 (val == CPUFREQ_RESUMECHANGE)) {
664 cpu_data(cpu).clock_tick = 663 cpu_data(cpu).clock_tick =
665 cpufreq_scale(ft->clock_tick_ref, 664 cpufreq_scale(ft->clock_tick_ref,
666 ft->ref_freq, 665 ft->ref_freq,
diff --git a/arch/x86/configs/i386_defconfig b/arch/x86/configs/i386_defconfig
index a7fef2621cc9..619e7f7426c6 100644
--- a/arch/x86/configs/i386_defconfig
+++ b/arch/x86/configs/i386_defconfig
@@ -60,7 +60,6 @@ CONFIG_CRASH_DUMP=y
60CONFIG_HIBERNATION=y 60CONFIG_HIBERNATION=y
61CONFIG_PM_DEBUG=y 61CONFIG_PM_DEBUG=y
62CONFIG_PM_TRACE_RTC=y 62CONFIG_PM_TRACE_RTC=y
63CONFIG_ACPI_PROCFS=y
64CONFIG_ACPI_DOCK=y 63CONFIG_ACPI_DOCK=y
65CONFIG_CPU_FREQ=y 64CONFIG_CPU_FREQ=y
66# CONFIG_CPU_FREQ_STAT is not set 65# CONFIG_CPU_FREQ_STAT is not set
diff --git a/arch/x86/configs/x86_64_defconfig b/arch/x86/configs/x86_64_defconfig
index c1119d4c1281..6181c69b786b 100644
--- a/arch/x86/configs/x86_64_defconfig
+++ b/arch/x86/configs/x86_64_defconfig
@@ -58,7 +58,6 @@ CONFIG_CRASH_DUMP=y
58CONFIG_HIBERNATION=y 58CONFIG_HIBERNATION=y
59CONFIG_PM_DEBUG=y 59CONFIG_PM_DEBUG=y
60CONFIG_PM_TRACE_RTC=y 60CONFIG_PM_TRACE_RTC=y
61CONFIG_ACPI_PROCFS=y
62CONFIG_ACPI_DOCK=y 61CONFIG_ACPI_DOCK=y
63CONFIG_CPU_FREQ=y 62CONFIG_CPU_FREQ=y
64# CONFIG_CPU_FREQ_STAT is not set 63# CONFIG_CPU_FREQ_STAT is not set
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 9f46f2b1cfc2..8e61d23b8f64 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -53,10 +53,6 @@ EXPORT_SYMBOL(acpi_disabled);
53# include <asm/proto.h> 53# include <asm/proto.h>
54#endif /* X86 */ 54#endif /* X86 */
55 55
56#define BAD_MADT_ENTRY(entry, end) ( \
57 (!entry) || (unsigned long)entry + sizeof(*entry) > end || \
58 ((struct acpi_subtable_header *)entry)->length < sizeof(*entry))
59
60#define PREFIX "ACPI: " 56#define PREFIX "ACPI: "
61 57
62int acpi_noirq; /* skip ACPI IRQ initialization */ 58int acpi_noirq; /* skip ACPI IRQ initialization */
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index cfbe99f88830..7a9296ab8834 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -914,8 +914,7 @@ static int time_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
914 tsc_khz_ref = tsc_khz; 914 tsc_khz_ref = tsc_khz;
915 } 915 }
916 if ((val == CPUFREQ_PRECHANGE && freq->old < freq->new) || 916 if ((val == CPUFREQ_PRECHANGE && freq->old < freq->new) ||
917 (val == CPUFREQ_POSTCHANGE && freq->old > freq->new) || 917 (val == CPUFREQ_POSTCHANGE && freq->old > freq->new)) {
918 (val == CPUFREQ_RESUMECHANGE)) {
919 *lpj = cpufreq_scale(loops_per_jiffy_ref, ref_freq, freq->new); 918 *lpj = cpufreq_scale(loops_per_jiffy_ref, ref_freq, freq->new);
920 919
921 tsc_khz = cpufreq_scale(tsc_khz_ref, ref_freq, freq->new); 920 tsc_khz = cpufreq_scale(tsc_khz_ref, ref_freq, freq->new);
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 4770de5707b9..c205653e9644 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -43,19 +43,6 @@ config ACPI_SLEEP
43 depends on SUSPEND || HIBERNATION 43 depends on SUSPEND || HIBERNATION
44 default y 44 default y
45 45
46config ACPI_PROCFS
47 bool "Deprecated /proc/acpi files"
48 depends on PROC_FS
49 help
50 For backwards compatibility, this option allows
51 deprecated /proc/acpi/ files to exist, even when
52 they have been replaced by functions in /sys.
53
54 This option has no effect on /proc/acpi/ files
55 and functions which do not yet exist in /sys.
56
57 Say N to delete /proc/acpi/ files that have moved to /sys/
58
59config ACPI_EC_DEBUGFS 46config ACPI_EC_DEBUGFS
60 tristate "EC read/write access through /sys/kernel/debug/ec" 47 tristate "EC read/write access through /sys/kernel/debug/ec"
61 default n 48 default n
@@ -115,7 +102,7 @@ config ACPI_BUTTON
115 102
116config ACPI_VIDEO 103config ACPI_VIDEO
117 tristate "Video" 104 tristate "Video"
118 depends on X86 && BACKLIGHT_CLASS_DEVICE && VIDEO_OUTPUT_CONTROL 105 depends on X86 && BACKLIGHT_CLASS_DEVICE
119 depends on INPUT 106 depends on INPUT
120 select THERMAL 107 select THERMAL
121 help 108 help
@@ -343,6 +330,19 @@ config ACPI_BGRT
343 data from the firmware boot splash. It will appear under 330 data from the firmware boot splash. It will appear under
344 /sys/firmware/acpi/bgrt/ . 331 /sys/firmware/acpi/bgrt/ .
345 332
333config ACPI_REDUCED_HARDWARE_ONLY
334 bool "Hardware-reduced ACPI support only" if EXPERT
335 def_bool n
336 depends on ACPI
337 help
338 This config item changes the way the ACPI code is built. When this
339 option is selected, the kernel will use a specialized version of
340 ACPICA that ONLY supports the ACPI "reduced hardware" mode. The
341 resulting kernel will be smaller but it will also be restricted to
342 running in ACPI reduced hardware mode ONLY.
343
344 If you are unsure what to do, do not enable this option.
345
346source "drivers/acpi/apei/Kconfig" 346source "drivers/acpi/apei/Kconfig"
347 347
348config ACPI_EXTLOG 348config ACPI_EXTLOG
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index 6f190bc2b8b7..2c01c1da29ce 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -33,6 +33,7 @@
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 <linux/acpi.h> 35#include <linux/acpi.h>
36#include "battery.h"
36 37
37#define PREFIX "ACPI: " 38#define PREFIX "ACPI: "
38 39
@@ -57,6 +58,7 @@ struct acpi_ac {
57 struct power_supply charger; 58 struct power_supply charger;
58 struct platform_device *pdev; 59 struct platform_device *pdev;
59 unsigned long long state; 60 unsigned long long state;
61 struct notifier_block battery_nb;
60}; 62};
61 63
62#define to_acpi_ac(x) container_of(x, struct acpi_ac, charger) 64#define to_acpi_ac(x) container_of(x, struct acpi_ac, charger)
@@ -152,6 +154,26 @@ static void acpi_ac_notify_handler(acpi_handle handle, u32 event, void *data)
152 return; 154 return;
153} 155}
154 156
157static int acpi_ac_battery_notify(struct notifier_block *nb,
158 unsigned long action, void *data)
159{
160 struct acpi_ac *ac = container_of(nb, struct acpi_ac, battery_nb);
161 struct acpi_bus_event *event = (struct acpi_bus_event *)data;
162
163 /*
164 * On HP Pavilion dv6-6179er AC status notifications aren't triggered
165 * when adapter is plugged/unplugged. However, battery status
166 * notifcations are triggered when battery starts charging or
167 * discharging. Re-reading AC status triggers lost AC notifications,
168 * if AC status has changed.
169 */
170 if (strcmp(event->device_class, ACPI_BATTERY_CLASS) == 0 &&
171 event->type == ACPI_BATTERY_NOTIFY_STATUS)
172 acpi_ac_get_state(ac);
173
174 return NOTIFY_OK;
175}
176
155static int thinkpad_e530_quirk(const struct dmi_system_id *d) 177static int thinkpad_e530_quirk(const struct dmi_system_id *d)
156{ 178{
157 ac_sleep_before_get_state_ms = 1000; 179 ac_sleep_before_get_state_ms = 1000;
@@ -215,6 +237,8 @@ static int acpi_ac_probe(struct platform_device *pdev)
215 acpi_device_name(adev), acpi_device_bid(adev), 237 acpi_device_name(adev), acpi_device_bid(adev),
216 ac->state ? "on-line" : "off-line"); 238 ac->state ? "on-line" : "off-line");
217 239
240 ac->battery_nb.notifier_call = acpi_ac_battery_notify;
241 register_acpi_notifier(&ac->battery_nb);
218end: 242end:
219 if (result) 243 if (result)
220 kfree(ac); 244 kfree(ac);
@@ -261,6 +285,7 @@ static int acpi_ac_remove(struct platform_device *pdev)
261 ac = platform_get_drvdata(pdev); 285 ac = platform_get_drvdata(pdev);
262 if (ac->charger.dev) 286 if (ac->charger.dev)
263 power_supply_unregister(&ac->charger); 287 power_supply_unregister(&ac->charger);
288 unregister_acpi_notifier(&ac->battery_nb);
264 289
265 kfree(ac); 290 kfree(ac);
266 291
diff --git a/drivers/acpi/acpi_cmos_rtc.c b/drivers/acpi/acpi_cmos_rtc.c
index 84190ed89c04..961b45d18a5d 100644
--- a/drivers/acpi/acpi_cmos_rtc.c
+++ b/drivers/acpi/acpi_cmos_rtc.c
@@ -18,8 +18,6 @@
18 18
19#include "internal.h" 19#include "internal.h"
20 20
21#define PREFIX "ACPI: "
22
23ACPI_MODULE_NAME("cmos rtc"); 21ACPI_MODULE_NAME("cmos rtc");
24 22
25static const struct acpi_device_id acpi_cmos_rtc_ids[] = { 23static const struct acpi_device_id acpi_cmos_rtc_ids[] = {
diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
index 6745fe137b9e..69e29f409d4c 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -33,6 +33,13 @@ ACPI_MODULE_NAME("acpi_lpss");
33#define LPSS_GENERAL_UART_RTS_OVRD BIT(3) 33#define LPSS_GENERAL_UART_RTS_OVRD BIT(3)
34#define LPSS_SW_LTR 0x10 34#define LPSS_SW_LTR 0x10
35#define LPSS_AUTO_LTR 0x14 35#define LPSS_AUTO_LTR 0x14
36#define LPSS_LTR_SNOOP_REQ BIT(15)
37#define LPSS_LTR_SNOOP_MASK 0x0000FFFF
38#define LPSS_LTR_SNOOP_LAT_1US 0x800
39#define LPSS_LTR_SNOOP_LAT_32US 0xC00
40#define LPSS_LTR_SNOOP_LAT_SHIFT 5
41#define LPSS_LTR_SNOOP_LAT_CUTOFF 3000
42#define LPSS_LTR_MAX_VAL 0x3FF
36#define LPSS_TX_INT 0x20 43#define LPSS_TX_INT 0x20
37#define LPSS_TX_INT_MASK BIT(1) 44#define LPSS_TX_INT_MASK BIT(1)
38 45
@@ -102,6 +109,16 @@ static struct lpss_device_desc lpt_sdio_dev_desc = {
102 .ltr_required = true, 109 .ltr_required = true,
103}; 110};
104 111
112static struct lpss_shared_clock pwm_clock = {
113 .name = "pwm_clk",
114 .rate = 25000000,
115};
116
117static struct lpss_device_desc byt_pwm_dev_desc = {
118 .clk_required = true,
119 .shared_clock = &pwm_clock,
120};
121
105static struct lpss_shared_clock uart_clock = { 122static struct lpss_shared_clock uart_clock = {
106 .name = "uart_clk", 123 .name = "uart_clk",
107 .rate = 44236800, 124 .rate = 44236800,
@@ -157,6 +174,7 @@ static const struct acpi_device_id acpi_lpss_device_ids[] = {
157 { "INT33C7", }, 174 { "INT33C7", },
158 175
159 /* BayTrail LPSS devices */ 176 /* BayTrail LPSS devices */
177 { "80860F09", (unsigned long)&byt_pwm_dev_desc },
160 { "80860F0A", (unsigned long)&byt_uart_dev_desc }, 178 { "80860F0A", (unsigned long)&byt_uart_dev_desc },
161 { "80860F0E", (unsigned long)&byt_spi_dev_desc }, 179 { "80860F0E", (unsigned long)&byt_spi_dev_desc },
162 { "80860F14", (unsigned long)&byt_sdio_dev_desc }, 180 { "80860F14", (unsigned long)&byt_sdio_dev_desc },
@@ -315,6 +333,17 @@ static int acpi_lpss_create_device(struct acpi_device *adev,
315 return ret; 333 return ret;
316} 334}
317 335
336static u32 __lpss_reg_read(struct lpss_private_data *pdata, unsigned int reg)
337{
338 return readl(pdata->mmio_base + pdata->dev_desc->prv_offset + reg);
339}
340
341static void __lpss_reg_write(u32 val, struct lpss_private_data *pdata,
342 unsigned int reg)
343{
344 writel(val, pdata->mmio_base + pdata->dev_desc->prv_offset + reg);
345}
346
318static int lpss_reg_read(struct device *dev, unsigned int reg, u32 *val) 347static int lpss_reg_read(struct device *dev, unsigned int reg, u32 *val)
319{ 348{
320 struct acpi_device *adev; 349 struct acpi_device *adev;
@@ -336,7 +365,7 @@ static int lpss_reg_read(struct device *dev, unsigned int reg, u32 *val)
336 ret = -ENODEV; 365 ret = -ENODEV;
337 goto out; 366 goto out;
338 } 367 }
339 *val = readl(pdata->mmio_base + pdata->dev_desc->prv_offset + reg); 368 *val = __lpss_reg_read(pdata, reg);
340 369
341 out: 370 out:
342 spin_unlock_irqrestore(&dev->power.lock, flags); 371 spin_unlock_irqrestore(&dev->power.lock, flags);
@@ -389,6 +418,37 @@ static struct attribute_group lpss_attr_group = {
389 .name = "lpss_ltr", 418 .name = "lpss_ltr",
390}; 419};
391 420
421static void acpi_lpss_set_ltr(struct device *dev, s32 val)
422{
423 struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev));
424 u32 ltr_mode, ltr_val;
425
426 ltr_mode = __lpss_reg_read(pdata, LPSS_GENERAL);
427 if (val < 0) {
428 if (ltr_mode & LPSS_GENERAL_LTR_MODE_SW) {
429 ltr_mode &= ~LPSS_GENERAL_LTR_MODE_SW;
430 __lpss_reg_write(ltr_mode, pdata, LPSS_GENERAL);
431 }
432 return;
433 }
434 ltr_val = __lpss_reg_read(pdata, LPSS_SW_LTR) & ~LPSS_LTR_SNOOP_MASK;
435 if (val >= LPSS_LTR_SNOOP_LAT_CUTOFF) {
436 ltr_val |= LPSS_LTR_SNOOP_LAT_32US;
437 val = LPSS_LTR_MAX_VAL;
438 } else if (val > LPSS_LTR_MAX_VAL) {
439 ltr_val |= LPSS_LTR_SNOOP_LAT_32US | LPSS_LTR_SNOOP_REQ;
440 val >>= LPSS_LTR_SNOOP_LAT_SHIFT;
441 } else {
442 ltr_val |= LPSS_LTR_SNOOP_LAT_1US | LPSS_LTR_SNOOP_REQ;
443 }
444 ltr_val |= val;
445 __lpss_reg_write(ltr_val, pdata, LPSS_SW_LTR);
446 if (!(ltr_mode & LPSS_GENERAL_LTR_MODE_SW)) {
447 ltr_mode |= LPSS_GENERAL_LTR_MODE_SW;
448 __lpss_reg_write(ltr_mode, pdata, LPSS_GENERAL);
449 }
450}
451
392static int acpi_lpss_platform_notify(struct notifier_block *nb, 452static int acpi_lpss_platform_notify(struct notifier_block *nb,
393 unsigned long action, void *data) 453 unsigned long action, void *data)
394{ 454{
@@ -426,9 +486,29 @@ static struct notifier_block acpi_lpss_nb = {
426 .notifier_call = acpi_lpss_platform_notify, 486 .notifier_call = acpi_lpss_platform_notify,
427}; 487};
428 488
489static void acpi_lpss_bind(struct device *dev)
490{
491 struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev));
492
493 if (!pdata || !pdata->mmio_base || !pdata->dev_desc->ltr_required)
494 return;
495
496 if (pdata->mmio_size >= pdata->dev_desc->prv_offset + LPSS_LTR_SIZE)
497 dev->power.set_latency_tolerance = acpi_lpss_set_ltr;
498 else
499 dev_err(dev, "MMIO size insufficient to access LTR\n");
500}
501
502static void acpi_lpss_unbind(struct device *dev)
503{
504 dev->power.set_latency_tolerance = NULL;
505}
506
429static struct acpi_scan_handler lpss_handler = { 507static struct acpi_scan_handler lpss_handler = {
430 .ids = acpi_lpss_device_ids, 508 .ids = acpi_lpss_device_ids,
431 .attach = acpi_lpss_create_device, 509 .attach = acpi_lpss_create_device,
510 .bind = acpi_lpss_bind,
511 .unbind = acpi_lpss_unbind,
432}; 512};
433 513
434void __init acpi_lpss_init(void) 514void __init acpi_lpss_init(void)
diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c
index df96a0fe4890..37d73024b82e 100644
--- a/drivers/acpi/acpi_pad.c
+++ b/drivers/acpi/acpi_pad.c
@@ -408,28 +408,14 @@ static int acpi_pad_pur(acpi_handle handle)
408 return num; 408 return num;
409} 409}
410 410
411/* Notify firmware how many CPUs are idle */
412static void acpi_pad_ost(acpi_handle handle, int stat,
413 uint32_t idle_cpus)
414{
415 union acpi_object params[3] = {
416 {.type = ACPI_TYPE_INTEGER,},
417 {.type = ACPI_TYPE_INTEGER,},
418 {.type = ACPI_TYPE_BUFFER,},
419 };
420 struct acpi_object_list arg_list = {3, params};
421
422 params[0].integer.value = ACPI_PROCESSOR_AGGREGATOR_NOTIFY;
423 params[1].integer.value = stat;
424 params[2].buffer.length = 4;
425 params[2].buffer.pointer = (void *)&idle_cpus;
426 acpi_evaluate_object(handle, "_OST", &arg_list, NULL);
427}
428
429static void acpi_pad_handle_notify(acpi_handle handle) 411static void acpi_pad_handle_notify(acpi_handle handle)
430{ 412{
431 int num_cpus; 413 int num_cpus;
432 uint32_t idle_cpus; 414 uint32_t idle_cpus;
415 struct acpi_buffer param = {
416 .length = 4,
417 .pointer = (void *)&idle_cpus,
418 };
433 419
434 mutex_lock(&isolated_cpus_lock); 420 mutex_lock(&isolated_cpus_lock);
435 num_cpus = acpi_pad_pur(handle); 421 num_cpus = acpi_pad_pur(handle);
@@ -439,7 +425,7 @@ static void acpi_pad_handle_notify(acpi_handle handle)
439 } 425 }
440 acpi_pad_idle_cpus(num_cpus); 426 acpi_pad_idle_cpus(num_cpus);
441 idle_cpus = acpi_pad_idle_cpus_num(); 427 idle_cpus = acpi_pad_idle_cpus_num();
442 acpi_pad_ost(handle, 0, idle_cpus); 428 acpi_evaluate_ost(handle, ACPI_PROCESSOR_AGGREGATOR_NOTIFY, 0, &param);
443 mutex_unlock(&isolated_cpus_lock); 429 mutex_unlock(&isolated_cpus_lock);
444} 430}
445 431
diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile
index 438304086ff1..b7ed86a20427 100644
--- a/drivers/acpi/acpica/Makefile
+++ b/drivers/acpi/acpica/Makefile
@@ -122,6 +122,8 @@ acpi-y += \
122 rsaddr.o \ 122 rsaddr.o \
123 rscalc.o \ 123 rscalc.o \
124 rscreate.o \ 124 rscreate.o \
125 rsdump.o \
126 rsdumpinfo.o \
125 rsinfo.o \ 127 rsinfo.o \
126 rsio.o \ 128 rsio.o \
127 rsirq.o \ 129 rsirq.o \
@@ -132,8 +134,6 @@ acpi-y += \
132 rsutils.o \ 134 rsutils.o \
133 rsxface.o 135 rsxface.o
134 136
135acpi-$(ACPI_FUTURE_USAGE) += rsdump.o rsdumpinfo.o
136
137acpi-y += \ 137acpi-y += \
138 tbfadt.o \ 138 tbfadt.o \
139 tbfind.o \ 139 tbfind.o \
diff --git a/drivers/acpi/acpica/accommon.h b/drivers/acpi/acpica/accommon.h
index 8a6c4a0d22db..6f1c616910ac 100644
--- a/drivers/acpi/acpica/accommon.h
+++ b/drivers/acpi/acpica/accommon.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acdebug.h b/drivers/acpi/acpica/acdebug.h
index 2bf3ca2b8a7a..68a91eb0fa48 100644
--- a/drivers/acpi/acpica/acdebug.h
+++ b/drivers/acpi/acpica/acdebug.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -115,6 +115,8 @@ ACPI_HW_DEPENDENT_RETURN_VOID(void
115 char *block_arg)) 115 char *block_arg))
116ACPI_HW_DEPENDENT_RETURN_VOID(void acpi_db_generate_sci(void)) 116ACPI_HW_DEPENDENT_RETURN_VOID(void acpi_db_generate_sci(void))
117 117
118void acpi_db_execute_test(char *type_arg);
119
118/* 120/*
119 * dbconvert - miscellaneous conversion routines 121 * dbconvert - miscellaneous conversion routines
120 */ 122 */
diff --git a/drivers/acpi/acpica/acdispat.h b/drivers/acpi/acpica/acdispat.h
index 427db72a6302..5b472c43c31d 100644
--- a/drivers/acpi/acpica/acdispat.h
+++ b/drivers/acpi/acpica/acdispat.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acevents.h b/drivers/acpi/acpica/acevents.h
index 0fb0adf435d6..68ec61fff188 100644
--- a/drivers/acpi/acpica/acevents.h
+++ b/drivers/acpi/acpica/acevents.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index 4ed1aa384df2..8f40bb972ae3 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -51,11 +51,19 @@
51 * to simplify maintenance of the code. 51 * to simplify maintenance of the code.
52 */ 52 */
53#ifdef DEFINE_ACPI_GLOBALS 53#ifdef DEFINE_ACPI_GLOBALS
54#define ACPI_EXTERN 54#define ACPI_GLOBAL(type,name) \
55#define ACPI_INIT_GLOBAL(a,b) a=b 55 extern type name; \
56 type name
57
58#define ACPI_INIT_GLOBAL(type,name,value) \
59 type name=value
60
56#else 61#else
57#define ACPI_EXTERN extern 62#define ACPI_GLOBAL(type,name) \
58#define ACPI_INIT_GLOBAL(a,b) a 63 extern type name
64
65#define ACPI_INIT_GLOBAL(type,name,value) \
66 extern type name
59#endif 67#endif
60 68
61#ifdef DEFINE_ACPI_GLOBALS 69#ifdef DEFINE_ACPI_GLOBALS
@@ -82,7 +90,7 @@
82 * 5) Allow unresolved references (invalid target name) in package objects 90 * 5) Allow unresolved references (invalid target name) in package objects
83 * 6) Enable warning messages for behavior that is not ACPI spec compliant 91 * 6) Enable warning messages for behavior that is not ACPI spec compliant
84 */ 92 */
85u8 ACPI_INIT_GLOBAL(acpi_gbl_enable_interpreter_slack, FALSE); 93ACPI_INIT_GLOBAL(u8, acpi_gbl_enable_interpreter_slack, FALSE);
86 94
87/* 95/*
88 * Automatically serialize ALL control methods? Default is FALSE, meaning 96 * Automatically serialize ALL control methods? Default is FALSE, meaning
@@ -90,25 +98,25 @@ u8 ACPI_INIT_GLOBAL(acpi_gbl_enable_interpreter_slack, FALSE);
90 * Only change this if the ASL code is poorly written and cannot handle 98 * Only change this if the ASL code is poorly written and cannot handle
91 * reentrancy even though methods are marked "NotSerialized". 99 * reentrancy even though methods are marked "NotSerialized".
92 */ 100 */
93u8 ACPI_INIT_GLOBAL(acpi_gbl_all_methods_serialized, FALSE); 101ACPI_INIT_GLOBAL(u8, acpi_gbl_all_methods_serialized, FALSE);
94 102
95/* 103/*
96 * Create the predefined _OSI method in the namespace? Default is TRUE 104 * Create the predefined _OSI method in the namespace? Default is TRUE
97 * because ACPI CA is fully compatible with other ACPI implementations. 105 * because ACPI CA is fully compatible with other ACPI implementations.
98 * Changing this will revert ACPI CA (and machine ASL) to pre-OSI behavior. 106 * Changing this will revert ACPI CA (and machine ASL) to pre-OSI behavior.
99 */ 107 */
100u8 ACPI_INIT_GLOBAL(acpi_gbl_create_osi_method, TRUE); 108ACPI_INIT_GLOBAL(u8, acpi_gbl_create_osi_method, TRUE);
101 109
102/* 110/*
103 * Optionally use default values for the ACPI register widths. Set this to 111 * Optionally use default values for the ACPI register widths. Set this to
104 * TRUE to use the defaults, if an FADT contains incorrect widths/lengths. 112 * TRUE to use the defaults, if an FADT contains incorrect widths/lengths.
105 */ 113 */
106u8 ACPI_INIT_GLOBAL(acpi_gbl_use_default_register_widths, TRUE); 114ACPI_INIT_GLOBAL(u8, acpi_gbl_use_default_register_widths, TRUE);
107 115
108/* 116/*
109 * Optionally enable output from the AML Debug Object. 117 * Optionally enable output from the AML Debug Object.
110 */ 118 */
111u8 ACPI_INIT_GLOBAL(acpi_gbl_enable_aml_debug_object, FALSE); 119ACPI_INIT_GLOBAL(u8, acpi_gbl_enable_aml_debug_object, FALSE);
112 120
113/* 121/*
114 * Optionally copy the entire DSDT to local memory (instead of simply 122 * Optionally copy the entire DSDT to local memory (instead of simply
@@ -116,7 +124,7 @@ u8 ACPI_INIT_GLOBAL(acpi_gbl_enable_aml_debug_object, FALSE);
116 * DSDT, creating the need for this option. Default is FALSE, do not copy 124 * DSDT, creating the need for this option. Default is FALSE, do not copy
117 * the DSDT. 125 * the DSDT.
118 */ 126 */
119u8 ACPI_INIT_GLOBAL(acpi_gbl_copy_dsdt_locally, FALSE); 127ACPI_INIT_GLOBAL(u8, acpi_gbl_copy_dsdt_locally, FALSE);
120 128
121/* 129/*
122 * Optionally ignore an XSDT if present and use the RSDT instead. 130 * Optionally ignore an XSDT if present and use the RSDT instead.
@@ -124,7 +132,7 @@ u8 ACPI_INIT_GLOBAL(acpi_gbl_copy_dsdt_locally, FALSE);
124 * of the RSDT, the XSDT has been found to be corrupt or ill-formed on 132 * 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. 133 * some machines. Default behavior is to use the XSDT if present.
126 */ 134 */
127u8 ACPI_INIT_GLOBAL(acpi_gbl_do_not_use_xsdt, FALSE); 135ACPI_INIT_GLOBAL(u8, acpi_gbl_do_not_use_xsdt, FALSE);
128 136
129/* 137/*
130 * Optionally use 32-bit FADT addresses if and when there is a conflict 138 * Optionally use 32-bit FADT addresses if and when there is a conflict
@@ -134,7 +142,7 @@ u8 ACPI_INIT_GLOBAL(acpi_gbl_do_not_use_xsdt, FALSE);
134 * some machines have been found to have a corrupted non-zero 64-bit 142 * 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. 143 * address. Default is FALSE, do not favor the 32-bit addresses.
136 */ 144 */
137u8 ACPI_INIT_GLOBAL(acpi_gbl_use32_bit_fadt_addresses, FALSE); 145ACPI_INIT_GLOBAL(u8, acpi_gbl_use32_bit_fadt_addresses, FALSE);
138 146
139/* 147/*
140 * Optionally truncate I/O addresses to 16 bits. Provides compatibility 148 * Optionally truncate I/O addresses to 16 bits. Provides compatibility
@@ -142,47 +150,28 @@ u8 ACPI_INIT_GLOBAL(acpi_gbl_use32_bit_fadt_addresses, FALSE);
142 * this value is set to TRUE if any Windows OSI strings have been 150 * this value is set to TRUE if any Windows OSI strings have been
143 * requested by the BIOS. 151 * requested by the BIOS.
144 */ 152 */
145u8 ACPI_INIT_GLOBAL(acpi_gbl_truncate_io_addresses, FALSE); 153ACPI_INIT_GLOBAL(u8, acpi_gbl_truncate_io_addresses, FALSE);
146 154
147/* 155/*
148 * Disable runtime checking and repair of values returned by control methods. 156 * Disable runtime checking and repair of values returned by control methods.
149 * Use only if the repair is causing a problem on a particular machine. 157 * Use only if the repair is causing a problem on a particular machine.
150 */ 158 */
151u8 ACPI_INIT_GLOBAL(acpi_gbl_disable_auto_repair, FALSE); 159ACPI_INIT_GLOBAL(u8, acpi_gbl_disable_auto_repair, FALSE);
152 160
153/* 161/*
154 * Optionally do not load any SSDTs from the RSDT/XSDT during initialization. 162 * Optionally do not load any SSDTs from the RSDT/XSDT during initialization.
155 * This can be useful for debugging ACPI problems on some machines. 163 * This can be useful for debugging ACPI problems on some machines.
156 */ 164 */
157u8 ACPI_INIT_GLOBAL(acpi_gbl_disable_ssdt_table_load, FALSE); 165ACPI_INIT_GLOBAL(u8, acpi_gbl_disable_ssdt_table_load, FALSE);
158 166
159/* 167/*
160 * We keep track of the latest version of Windows that has been requested by 168 * We keep track of the latest version of Windows that has been requested by
161 * the BIOS. 169 * the BIOS.
162 */ 170 */
163u8 ACPI_INIT_GLOBAL(acpi_gbl_osi_data, 0); 171ACPI_INIT_GLOBAL(u8, acpi_gbl_osi_data, 0);
164
165/* acpi_gbl_FADT is a local copy of the FADT, converted to a common format. */
166
167struct acpi_table_fadt acpi_gbl_FADT;
168u32 acpi_current_gpe_count;
169u32 acpi_gbl_trace_flags;
170acpi_name acpi_gbl_trace_method_name;
171u8 acpi_gbl_system_awake_and_running;
172
173/*
174 * ACPI 5.0 introduces the concept of a "reduced hardware platform", meaning
175 * that the ACPI hardware is no longer required. A flag in the FADT indicates
176 * a reduced HW machine, and that flag is duplicated here for convenience.
177 */
178u8 acpi_gbl_reduced_hardware;
179 172
180#endif /* DEFINE_ACPI_GLOBALS */ 173#endif /* DEFINE_ACPI_GLOBALS */
181 174
182/* Do not disassemble buffers to resource descriptors */
183
184ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_no_resource_disassembly, FALSE);
185
186/***************************************************************************** 175/*****************************************************************************
187 * 176 *
188 * ACPI Table globals 177 * ACPI Table globals
@@ -190,37 +179,36 @@ ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_no_resource_disassembly, FALSE);
190 ****************************************************************************/ 179 ****************************************************************************/
191 180
192/* 181/*
193 * acpi_gbl_root_table_list is the master list of ACPI tables that were 182 * Master list of all ACPI tables that were found in the RSDT/XSDT.
194 * found in the RSDT/XSDT.
195 */ 183 */
196ACPI_EXTERN struct acpi_table_list acpi_gbl_root_table_list; 184ACPI_GLOBAL(struct acpi_table_list, acpi_gbl_root_table_list);
185
186/* DSDT information. Used to check for DSDT corruption */
187
188ACPI_GLOBAL(struct acpi_table_header *, acpi_gbl_DSDT);
189ACPI_GLOBAL(struct acpi_table_header, acpi_gbl_original_dsdt_header);
197 190
198#if (!ACPI_REDUCED_HARDWARE) 191#if (!ACPI_REDUCED_HARDWARE)
199ACPI_EXTERN struct acpi_table_facs *acpi_gbl_FACS; 192ACPI_GLOBAL(struct acpi_table_facs *, acpi_gbl_FACS);
200 193
201#endif /* !ACPI_REDUCED_HARDWARE */ 194#endif /* !ACPI_REDUCED_HARDWARE */
202 195
203/* These addresses are calculated from the FADT Event Block addresses */ 196/* These addresses are calculated from the FADT Event Block addresses */
204 197
205ACPI_EXTERN struct acpi_generic_address acpi_gbl_xpm1a_status; 198ACPI_GLOBAL(struct acpi_generic_address, acpi_gbl_xpm1a_status);
206ACPI_EXTERN struct acpi_generic_address acpi_gbl_xpm1a_enable; 199ACPI_GLOBAL(struct acpi_generic_address, acpi_gbl_xpm1a_enable);
207
208ACPI_EXTERN struct acpi_generic_address acpi_gbl_xpm1b_status;
209ACPI_EXTERN struct acpi_generic_address acpi_gbl_xpm1b_enable;
210 200
211/* DSDT information. Used to check for DSDT corruption */ 201ACPI_GLOBAL(struct acpi_generic_address, acpi_gbl_xpm1b_status);
212 202ACPI_GLOBAL(struct acpi_generic_address, acpi_gbl_xpm1b_enable);
213ACPI_EXTERN struct acpi_table_header *acpi_gbl_DSDT;
214ACPI_EXTERN struct acpi_table_header acpi_gbl_original_dsdt_header;
215 203
216/* 204/*
217 * Handle both ACPI 1.0 and ACPI 2.0 Integer widths. The integer width is 205 * Handle both ACPI 1.0 and ACPI 2.0+ Integer widths. The integer width is
218 * determined by the revision of the DSDT: If the DSDT revision is less than 206 * determined by the revision of the DSDT: If the DSDT revision is less than
219 * 2, use only the lower 32 bits of the internal 64-bit Integer. 207 * 2, use only the lower 32 bits of the internal 64-bit Integer.
220 */ 208 */
221ACPI_EXTERN u8 acpi_gbl_integer_bit_width; 209ACPI_GLOBAL(u8, acpi_gbl_integer_bit_width);
222ACPI_EXTERN u8 acpi_gbl_integer_byte_width; 210ACPI_GLOBAL(u8, acpi_gbl_integer_byte_width);
223ACPI_EXTERN u8 acpi_gbl_integer_nybble_width; 211ACPI_GLOBAL(u8, acpi_gbl_integer_nybble_width);
224 212
225/***************************************************************************** 213/*****************************************************************************
226 * 214 *
@@ -233,36 +221,36 @@ ACPI_EXTERN u8 acpi_gbl_integer_nybble_width;
233 * actual OS mutex handles, indexed by the local ACPI_MUTEX_HANDLEs. 221 * actual OS mutex handles, indexed by the local ACPI_MUTEX_HANDLEs.
234 * (The table maps local handles to the real OS handles) 222 * (The table maps local handles to the real OS handles)
235 */ 223 */
236ACPI_EXTERN struct acpi_mutex_info acpi_gbl_mutex_info[ACPI_NUM_MUTEX]; 224ACPI_GLOBAL(struct acpi_mutex_info, acpi_gbl_mutex_info[ACPI_NUM_MUTEX]);
237 225
238/* 226/*
239 * Global lock mutex is an actual AML mutex object 227 * Global lock mutex is an actual AML mutex object
240 * Global lock semaphore works in conjunction with the actual global lock 228 * Global lock semaphore works in conjunction with the actual global lock
241 * Global lock spinlock is used for "pending" handshake 229 * Global lock spinlock is used for "pending" handshake
242 */ 230 */
243ACPI_EXTERN union acpi_operand_object *acpi_gbl_global_lock_mutex; 231ACPI_GLOBAL(union acpi_operand_object *, acpi_gbl_global_lock_mutex);
244ACPI_EXTERN acpi_semaphore acpi_gbl_global_lock_semaphore; 232ACPI_GLOBAL(acpi_semaphore, acpi_gbl_global_lock_semaphore);
245ACPI_EXTERN acpi_spinlock acpi_gbl_global_lock_pending_lock; 233ACPI_GLOBAL(acpi_spinlock, acpi_gbl_global_lock_pending_lock);
246ACPI_EXTERN u16 acpi_gbl_global_lock_handle; 234ACPI_GLOBAL(u16, acpi_gbl_global_lock_handle);
247ACPI_EXTERN u8 acpi_gbl_global_lock_acquired; 235ACPI_GLOBAL(u8, acpi_gbl_global_lock_acquired);
248ACPI_EXTERN u8 acpi_gbl_global_lock_present; 236ACPI_GLOBAL(u8, acpi_gbl_global_lock_present);
249ACPI_EXTERN u8 acpi_gbl_global_lock_pending; 237ACPI_GLOBAL(u8, acpi_gbl_global_lock_pending);
250 238
251/* 239/*
252 * Spinlocks are used for interfaces that can be possibly called at 240 * Spinlocks are used for interfaces that can be possibly called at
253 * interrupt level 241 * interrupt level
254 */ 242 */
255ACPI_EXTERN acpi_spinlock acpi_gbl_gpe_lock; /* For GPE data structs and registers */ 243ACPI_GLOBAL(acpi_spinlock, acpi_gbl_gpe_lock); /* For GPE data structs and registers */
256ACPI_EXTERN acpi_spinlock acpi_gbl_hardware_lock; /* For ACPI H/W except GPE registers */ 244ACPI_GLOBAL(acpi_spinlock, acpi_gbl_hardware_lock); /* For ACPI H/W except GPE registers */
257ACPI_EXTERN acpi_spinlock acpi_gbl_reference_count_lock; 245ACPI_GLOBAL(acpi_spinlock, acpi_gbl_reference_count_lock);
258 246
259/* Mutex for _OSI support */ 247/* Mutex for _OSI support */
260 248
261ACPI_EXTERN acpi_mutex acpi_gbl_osi_mutex; 249ACPI_GLOBAL(acpi_mutex, acpi_gbl_osi_mutex);
262 250
263/* Reader/Writer lock is used for namespace walk and dynamic table unload */ 251/* Reader/Writer lock is used for namespace walk and dynamic table unload */
264 252
265ACPI_EXTERN struct acpi_rw_lock acpi_gbl_namespace_rw_lock; 253ACPI_GLOBAL(struct acpi_rw_lock, acpi_gbl_namespace_rw_lock);
266 254
267/***************************************************************************** 255/*****************************************************************************
268 * 256 *
@@ -272,70 +260,69 @@ ACPI_EXTERN struct acpi_rw_lock acpi_gbl_namespace_rw_lock;
272 260
273/* Object caches */ 261/* Object caches */
274 262
275ACPI_EXTERN acpi_cache_t *acpi_gbl_namespace_cache; 263ACPI_GLOBAL(acpi_cache_t *, acpi_gbl_namespace_cache);
276ACPI_EXTERN acpi_cache_t *acpi_gbl_state_cache; 264ACPI_GLOBAL(acpi_cache_t *, acpi_gbl_state_cache);
277ACPI_EXTERN acpi_cache_t *acpi_gbl_ps_node_cache; 265ACPI_GLOBAL(acpi_cache_t *, acpi_gbl_ps_node_cache);
278ACPI_EXTERN acpi_cache_t *acpi_gbl_ps_node_ext_cache; 266ACPI_GLOBAL(acpi_cache_t *, acpi_gbl_ps_node_ext_cache);
279ACPI_EXTERN acpi_cache_t *acpi_gbl_operand_cache; 267ACPI_GLOBAL(acpi_cache_t *, acpi_gbl_operand_cache);
268
269/* System */
270
271ACPI_INIT_GLOBAL(u32, acpi_gbl_startup_flags, 0);
272ACPI_INIT_GLOBAL(u8, acpi_gbl_shutdown, TRUE);
280 273
281/* Global handlers */ 274/* Global handlers */
282 275
283ACPI_EXTERN struct acpi_global_notify_handler acpi_gbl_global_notify[2]; 276ACPI_GLOBAL(struct acpi_global_notify_handler, acpi_gbl_global_notify[2]);
284ACPI_EXTERN acpi_exception_handler acpi_gbl_exception_handler; 277ACPI_GLOBAL(acpi_exception_handler, acpi_gbl_exception_handler);
285ACPI_EXTERN acpi_init_handler acpi_gbl_init_handler; 278ACPI_GLOBAL(acpi_init_handler, acpi_gbl_init_handler);
286ACPI_EXTERN acpi_table_handler acpi_gbl_table_handler; 279ACPI_GLOBAL(acpi_table_handler, acpi_gbl_table_handler);
287ACPI_EXTERN void *acpi_gbl_table_handler_context; 280ACPI_GLOBAL(void *, acpi_gbl_table_handler_context);
288ACPI_EXTERN struct acpi_walk_state *acpi_gbl_breakpoint_walk; 281ACPI_GLOBAL(struct acpi_walk_state *, acpi_gbl_breakpoint_walk);
289ACPI_EXTERN acpi_interface_handler acpi_gbl_interface_handler; 282ACPI_GLOBAL(acpi_interface_handler, acpi_gbl_interface_handler);
290ACPI_EXTERN struct acpi_sci_handler_info *acpi_gbl_sci_handler_list; 283ACPI_GLOBAL(struct acpi_sci_handler_info *, acpi_gbl_sci_handler_list);
291 284
292/* Owner ID support */ 285/* Owner ID support */
293 286
294ACPI_EXTERN u32 acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS]; 287ACPI_GLOBAL(u32, acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS]);
295ACPI_EXTERN u8 acpi_gbl_last_owner_id_index; 288ACPI_GLOBAL(u8, acpi_gbl_last_owner_id_index);
296ACPI_EXTERN u8 acpi_gbl_next_owner_id_offset; 289ACPI_GLOBAL(u8, acpi_gbl_next_owner_id_offset);
297 290
298/* Initialization sequencing */ 291/* Initialization sequencing */
299 292
300ACPI_EXTERN u8 acpi_gbl_reg_methods_executed; 293ACPI_GLOBAL(u8, acpi_gbl_reg_methods_executed);
301 294
302/* Misc */ 295/* Misc */
303 296
304ACPI_EXTERN u32 acpi_gbl_original_mode; 297ACPI_GLOBAL(u32, acpi_gbl_original_mode);
305ACPI_EXTERN u32 acpi_gbl_rsdp_original_location; 298ACPI_GLOBAL(u32, acpi_gbl_rsdp_original_location);
306ACPI_EXTERN u32 acpi_gbl_ns_lookup_count; 299ACPI_GLOBAL(u32, acpi_gbl_ns_lookup_count);
307ACPI_EXTERN u32 acpi_gbl_ps_find_count; 300ACPI_GLOBAL(u32, acpi_gbl_ps_find_count);
308ACPI_EXTERN u16 acpi_gbl_pm1_enable_register_save; 301ACPI_GLOBAL(u16, acpi_gbl_pm1_enable_register_save);
309ACPI_EXTERN u8 acpi_gbl_debugger_configuration; 302ACPI_GLOBAL(u8, acpi_gbl_debugger_configuration);
310ACPI_EXTERN u8 acpi_gbl_step_to_next_call; 303ACPI_GLOBAL(u8, acpi_gbl_step_to_next_call);
311ACPI_EXTERN u8 acpi_gbl_acpi_hardware_present; 304ACPI_GLOBAL(u8, acpi_gbl_acpi_hardware_present);
312ACPI_EXTERN u8 acpi_gbl_events_initialized; 305ACPI_GLOBAL(u8, acpi_gbl_events_initialized);
313ACPI_EXTERN struct acpi_interface_info *acpi_gbl_supported_interfaces; 306ACPI_GLOBAL(struct acpi_interface_info *, acpi_gbl_supported_interfaces);
314ACPI_EXTERN struct acpi_address_range 307ACPI_GLOBAL(struct acpi_address_range *,
315 *acpi_gbl_address_range_list[ACPI_ADDRESS_RANGE_MAX]; 308 acpi_gbl_address_range_list[ACPI_ADDRESS_RANGE_MAX]);
316 309
317#ifndef DEFINE_ACPI_GLOBALS 310/* Other miscellaneous, declared and initialized in utglobal */
318 311
319/* Other miscellaneous */
320
321extern u8 acpi_gbl_shutdown;
322extern u32 acpi_gbl_startup_flags;
323extern const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COUNT]; 312extern const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COUNT];
324extern const char *acpi_gbl_lowest_dstate_names[ACPI_NUM_sx_w_METHODS]; 313extern const char *acpi_gbl_lowest_dstate_names[ACPI_NUM_sx_w_METHODS];
325extern const char *acpi_gbl_highest_dstate_names[ACPI_NUM_sx_d_METHODS]; 314extern const char *acpi_gbl_highest_dstate_names[ACPI_NUM_sx_d_METHODS];
326extern const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES];
327extern const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS]; 315extern const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS];
328 316extern const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES];
329#endif
330 317
331#ifdef ACPI_DBG_TRACK_ALLOCATIONS 318#ifdef ACPI_DBG_TRACK_ALLOCATIONS
332 319
333/* Lists for tracking memory allocations */ 320/* Lists for tracking memory allocations (debug only) */
334 321
335ACPI_EXTERN struct acpi_memory_list *acpi_gbl_global_list; 322ACPI_GLOBAL(struct acpi_memory_list *, acpi_gbl_global_list);
336ACPI_EXTERN struct acpi_memory_list *acpi_gbl_ns_node_list; 323ACPI_GLOBAL(struct acpi_memory_list *, acpi_gbl_ns_node_list);
337ACPI_EXTERN u8 acpi_gbl_display_final_mem_stats; 324ACPI_GLOBAL(u8, acpi_gbl_display_final_mem_stats);
338ACPI_EXTERN u8 acpi_gbl_disable_mem_tracking; 325ACPI_GLOBAL(u8, acpi_gbl_disable_mem_tracking);
339#endif 326#endif
340 327
341/***************************************************************************** 328/*****************************************************************************
@@ -350,22 +337,23 @@ ACPI_EXTERN u8 acpi_gbl_disable_mem_tracking;
350#define NUM_PREDEFINED_NAMES 9 337#define NUM_PREDEFINED_NAMES 9
351#endif 338#endif
352 339
353ACPI_EXTERN struct acpi_namespace_node acpi_gbl_root_node_struct; 340ACPI_GLOBAL(struct acpi_namespace_node, acpi_gbl_root_node_struct);
354ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_root_node; 341ACPI_GLOBAL(struct acpi_namespace_node *, acpi_gbl_root_node);
355ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_fadt_gpe_device; 342ACPI_GLOBAL(struct acpi_namespace_node *, acpi_gbl_fadt_gpe_device);
356ACPI_EXTERN union acpi_operand_object *acpi_gbl_module_code_list; 343ACPI_GLOBAL(union acpi_operand_object *, acpi_gbl_module_code_list);
357 344
358extern const u8 acpi_gbl_ns_properties[ACPI_NUM_NS_TYPES]; 345extern const u8 acpi_gbl_ns_properties[ACPI_NUM_NS_TYPES];
359extern const struct acpi_predefined_names 346extern const struct acpi_predefined_names
360 acpi_gbl_pre_defined_names[NUM_PREDEFINED_NAMES]; 347 acpi_gbl_pre_defined_names[NUM_PREDEFINED_NAMES];
361 348
362#ifdef ACPI_DEBUG_OUTPUT 349#ifdef ACPI_DEBUG_OUTPUT
363ACPI_EXTERN u32 acpi_gbl_current_node_count; 350ACPI_GLOBAL(u32, acpi_gbl_current_node_count);
364ACPI_EXTERN u32 acpi_gbl_current_node_size; 351ACPI_GLOBAL(u32, acpi_gbl_current_node_size);
365ACPI_EXTERN u32 acpi_gbl_max_concurrent_node_count; 352ACPI_GLOBAL(u32, acpi_gbl_max_concurrent_node_count);
366ACPI_EXTERN acpi_size *acpi_gbl_entry_stack_pointer; 353ACPI_GLOBAL(acpi_size *, acpi_gbl_entry_stack_pointer);
367ACPI_EXTERN acpi_size *acpi_gbl_lowest_stack_pointer; 354ACPI_GLOBAL(acpi_size *, acpi_gbl_lowest_stack_pointer);
368ACPI_EXTERN u32 acpi_gbl_deepest_nesting; 355ACPI_GLOBAL(u32, acpi_gbl_deepest_nesting);
356ACPI_INIT_GLOBAL(u32, acpi_gbl_nesting_level, 0);
369#endif 357#endif
370 358
371/***************************************************************************** 359/*****************************************************************************
@@ -374,11 +362,11 @@ ACPI_EXTERN u32 acpi_gbl_deepest_nesting;
374 * 362 *
375 ****************************************************************************/ 363 ****************************************************************************/
376 364
377ACPI_EXTERN struct acpi_thread_state *acpi_gbl_current_walk_list; 365ACPI_GLOBAL(struct acpi_thread_state *, acpi_gbl_current_walk_list);
378 366
379/* Control method single step flag */ 367/* Control method single step flag */
380 368
381ACPI_EXTERN u8 acpi_gbl_cm_single_step; 369ACPI_GLOBAL(u8, acpi_gbl_cm_single_step);
382 370
383/***************************************************************************** 371/*****************************************************************************
384 * 372 *
@@ -388,8 +376,9 @@ ACPI_EXTERN u8 acpi_gbl_cm_single_step;
388 376
389extern struct acpi_bit_register_info 377extern struct acpi_bit_register_info
390 acpi_gbl_bit_register_info[ACPI_NUM_BITREG]; 378 acpi_gbl_bit_register_info[ACPI_NUM_BITREG];
391ACPI_EXTERN u8 acpi_gbl_sleep_type_a; 379
392ACPI_EXTERN u8 acpi_gbl_sleep_type_b; 380ACPI_GLOBAL(u8, acpi_gbl_sleep_type_a);
381ACPI_GLOBAL(u8, acpi_gbl_sleep_type_b);
393 382
394/***************************************************************************** 383/*****************************************************************************
395 * 384 *
@@ -399,14 +388,15 @@ ACPI_EXTERN u8 acpi_gbl_sleep_type_b;
399 388
400#if (!ACPI_REDUCED_HARDWARE) 389#if (!ACPI_REDUCED_HARDWARE)
401 390
402ACPI_EXTERN u8 acpi_gbl_all_gpes_initialized; 391ACPI_GLOBAL(u8, acpi_gbl_all_gpes_initialized);
403ACPI_EXTERN struct acpi_gpe_xrupt_info *acpi_gbl_gpe_xrupt_list_head; 392ACPI_GLOBAL(struct acpi_gpe_xrupt_info *, acpi_gbl_gpe_xrupt_list_head);
404ACPI_EXTERN struct acpi_gpe_block_info 393ACPI_GLOBAL(struct acpi_gpe_block_info *,
405 *acpi_gbl_gpe_fadt_blocks[ACPI_MAX_GPE_BLOCKS]; 394 acpi_gbl_gpe_fadt_blocks[ACPI_MAX_GPE_BLOCKS]);
406ACPI_EXTERN acpi_gbl_event_handler acpi_gbl_global_event_handler; 395ACPI_GLOBAL(acpi_gbl_event_handler, acpi_gbl_global_event_handler);
407ACPI_EXTERN void *acpi_gbl_global_event_handler_context; 396ACPI_GLOBAL(void *, acpi_gbl_global_event_handler_context);
408ACPI_EXTERN struct acpi_fixed_event_handler 397ACPI_GLOBAL(struct acpi_fixed_event_handler,
409 acpi_gbl_fixed_event_handlers[ACPI_NUM_FIXED_EVENTS]; 398 acpi_gbl_fixed_event_handlers[ACPI_NUM_FIXED_EVENTS]);
399
410extern struct acpi_fixed_event_info 400extern struct acpi_fixed_event_info
411 acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS]; 401 acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS];
412 402
@@ -418,23 +408,19 @@ extern struct acpi_fixed_event_info
418 * 408 *
419 ****************************************************************************/ 409 ****************************************************************************/
420 410
421/* Procedure nesting level for debug output */
422
423extern u32 acpi_gbl_nesting_level;
424
425/* Event counters */ 411/* Event counters */
426 412
427ACPI_EXTERN u32 acpi_method_count; 413ACPI_GLOBAL(u32, acpi_method_count);
428ACPI_EXTERN u32 acpi_gpe_count; 414ACPI_GLOBAL(u32, acpi_gpe_count);
429ACPI_EXTERN u32 acpi_sci_count; 415ACPI_GLOBAL(u32, acpi_sci_count);
430ACPI_EXTERN u32 acpi_fixed_event_count[ACPI_NUM_FIXED_EVENTS]; 416ACPI_GLOBAL(u32, acpi_fixed_event_count[ACPI_NUM_FIXED_EVENTS]);
431 417
432/* Support for dynamic control method tracing mechanism */ 418/* Support for dynamic control method tracing mechanism */
433 419
434ACPI_EXTERN u32 acpi_gbl_original_dbg_level; 420ACPI_GLOBAL(u32, acpi_gbl_original_dbg_level);
435ACPI_EXTERN u32 acpi_gbl_original_dbg_layer; 421ACPI_GLOBAL(u32, acpi_gbl_original_dbg_layer);
436ACPI_EXTERN u32 acpi_gbl_trace_dbg_level; 422ACPI_GLOBAL(u32, acpi_gbl_trace_dbg_level);
437ACPI_EXTERN u32 acpi_gbl_trace_dbg_layer; 423ACPI_GLOBAL(u32, acpi_gbl_trace_dbg_layer);
438 424
439/***************************************************************************** 425/*****************************************************************************
440 * 426 *
@@ -442,61 +428,64 @@ ACPI_EXTERN u32 acpi_gbl_trace_dbg_layer;
442 * 428 *
443 ****************************************************************************/ 429 ****************************************************************************/
444 430
445ACPI_EXTERN u8 acpi_gbl_db_output_flags; 431ACPI_GLOBAL(u8, acpi_gbl_db_output_flags);
446 432
447#ifdef ACPI_DISASSEMBLER 433#ifdef ACPI_DISASSEMBLER
448 434
449ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_ignore_noop_operator, FALSE); 435/* Do not disassemble buffers to resource descriptors */
436
437ACPI_INIT_GLOBAL(u8, acpi_gbl_no_resource_disassembly, FALSE);
438ACPI_INIT_GLOBAL(u8, acpi_gbl_ignore_noop_operator, FALSE);
450 439
451ACPI_EXTERN u8 acpi_gbl_db_opt_disasm; 440ACPI_GLOBAL(u8, acpi_gbl_db_opt_disasm);
452ACPI_EXTERN u8 acpi_gbl_db_opt_verbose; 441ACPI_GLOBAL(u8, acpi_gbl_db_opt_verbose);
453ACPI_EXTERN u8 acpi_gbl_num_external_methods; 442ACPI_GLOBAL(u8, acpi_gbl_num_external_methods);
454ACPI_EXTERN u32 acpi_gbl_resolved_external_methods; 443ACPI_GLOBAL(u32, acpi_gbl_resolved_external_methods);
455ACPI_EXTERN struct acpi_external_list *acpi_gbl_external_list; 444ACPI_GLOBAL(struct acpi_external_list *, acpi_gbl_external_list);
456ACPI_EXTERN struct acpi_external_file *acpi_gbl_external_file_list; 445ACPI_GLOBAL(struct acpi_external_file *, acpi_gbl_external_file_list);
457#endif 446#endif
458 447
459#ifdef ACPI_DEBUGGER 448#ifdef ACPI_DEBUGGER
460 449
461extern u8 acpi_gbl_method_executing; 450ACPI_INIT_GLOBAL(u8, acpi_gbl_db_terminate_threads, FALSE);
462extern u8 acpi_gbl_abort_method; 451ACPI_INIT_GLOBAL(u8, acpi_gbl_abort_method, FALSE);
463extern u8 acpi_gbl_db_terminate_threads; 452ACPI_INIT_GLOBAL(u8, acpi_gbl_method_executing, FALSE);
464 453
465ACPI_EXTERN u8 acpi_gbl_db_opt_tables; 454ACPI_GLOBAL(u8, acpi_gbl_db_opt_tables);
466ACPI_EXTERN u8 acpi_gbl_db_opt_stats; 455ACPI_GLOBAL(u8, acpi_gbl_db_opt_stats);
467ACPI_EXTERN u8 acpi_gbl_db_opt_ini_methods; 456ACPI_GLOBAL(u8, acpi_gbl_db_opt_ini_methods);
468ACPI_EXTERN u8 acpi_gbl_db_opt_no_region_support; 457ACPI_GLOBAL(u8, acpi_gbl_db_opt_no_region_support);
469ACPI_EXTERN u8 acpi_gbl_db_output_to_file; 458ACPI_GLOBAL(u8, acpi_gbl_db_output_to_file);
470ACPI_EXTERN char *acpi_gbl_db_buffer; 459ACPI_GLOBAL(char *, acpi_gbl_db_buffer);
471ACPI_EXTERN char *acpi_gbl_db_filename; 460ACPI_GLOBAL(char *, acpi_gbl_db_filename);
472ACPI_EXTERN u32 acpi_gbl_db_debug_level; 461ACPI_GLOBAL(u32, acpi_gbl_db_debug_level);
473ACPI_EXTERN u32 acpi_gbl_db_console_debug_level; 462ACPI_GLOBAL(u32, acpi_gbl_db_console_debug_level);
474ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_db_scope_node; 463ACPI_GLOBAL(struct acpi_namespace_node *, acpi_gbl_db_scope_node);
475 464
476ACPI_EXTERN char *acpi_gbl_db_args[ACPI_DEBUGGER_MAX_ARGS]; 465ACPI_GLOBAL(char *, acpi_gbl_db_args[ACPI_DEBUGGER_MAX_ARGS]);
477ACPI_EXTERN acpi_object_type acpi_gbl_db_arg_types[ACPI_DEBUGGER_MAX_ARGS]; 466ACPI_GLOBAL(acpi_object_type, acpi_gbl_db_arg_types[ACPI_DEBUGGER_MAX_ARGS]);
478 467
479/* These buffers should all be the same size */ 468/* These buffers should all be the same size */
480 469
481ACPI_EXTERN char acpi_gbl_db_line_buf[ACPI_DB_LINE_BUFFER_SIZE]; 470ACPI_GLOBAL(char, acpi_gbl_db_line_buf[ACPI_DB_LINE_BUFFER_SIZE]);
482ACPI_EXTERN char acpi_gbl_db_parsed_buf[ACPI_DB_LINE_BUFFER_SIZE]; 471ACPI_GLOBAL(char, acpi_gbl_db_parsed_buf[ACPI_DB_LINE_BUFFER_SIZE]);
483ACPI_EXTERN char acpi_gbl_db_scope_buf[ACPI_DB_LINE_BUFFER_SIZE]; 472ACPI_GLOBAL(char, acpi_gbl_db_scope_buf[ACPI_DB_LINE_BUFFER_SIZE]);
484ACPI_EXTERN char acpi_gbl_db_debug_filename[ACPI_DB_LINE_BUFFER_SIZE]; 473ACPI_GLOBAL(char, acpi_gbl_db_debug_filename[ACPI_DB_LINE_BUFFER_SIZE]);
485 474
486/* 475/*
487 * Statistic globals 476 * Statistic globals
488 */ 477 */
489ACPI_EXTERN u16 acpi_gbl_obj_type_count[ACPI_TYPE_NS_NODE_MAX + 1]; 478ACPI_GLOBAL(u16, acpi_gbl_obj_type_count[ACPI_TYPE_NS_NODE_MAX + 1]);
490ACPI_EXTERN u16 acpi_gbl_node_type_count[ACPI_TYPE_NS_NODE_MAX + 1]; 479ACPI_GLOBAL(u16, acpi_gbl_node_type_count[ACPI_TYPE_NS_NODE_MAX + 1]);
491ACPI_EXTERN u16 acpi_gbl_obj_type_count_misc; 480ACPI_GLOBAL(u16, acpi_gbl_obj_type_count_misc);
492ACPI_EXTERN u16 acpi_gbl_node_type_count_misc; 481ACPI_GLOBAL(u16, acpi_gbl_node_type_count_misc);
493ACPI_EXTERN u32 acpi_gbl_num_nodes; 482ACPI_GLOBAL(u32, acpi_gbl_num_nodes);
494ACPI_EXTERN u32 acpi_gbl_num_objects; 483ACPI_GLOBAL(u32, acpi_gbl_num_objects);
495 484
496ACPI_EXTERN u32 acpi_gbl_size_of_parse_tree; 485ACPI_GLOBAL(u32, acpi_gbl_size_of_parse_tree);
497ACPI_EXTERN u32 acpi_gbl_size_of_method_trees; 486ACPI_GLOBAL(u32, acpi_gbl_size_of_method_trees);
498ACPI_EXTERN u32 acpi_gbl_size_of_node_entries; 487ACPI_GLOBAL(u32, acpi_gbl_size_of_node_entries);
499ACPI_EXTERN u32 acpi_gbl_size_of_acpi_objects; 488ACPI_GLOBAL(u32, acpi_gbl_size_of_acpi_objects);
500 489
501#endif /* ACPI_DEBUGGER */ 490#endif /* ACPI_DEBUGGER */
502 491
@@ -508,7 +497,7 @@ ACPI_EXTERN u32 acpi_gbl_size_of_acpi_objects;
508 497
509#ifdef ACPI_APPLICATION 498#ifdef ACPI_APPLICATION
510 499
511ACPI_FILE ACPI_INIT_GLOBAL(acpi_gbl_debug_file, NULL); 500ACPI_INIT_GLOBAL(ACPI_FILE, acpi_gbl_debug_file, NULL);
512 501
513#endif /* ACPI_APPLICATION */ 502#endif /* ACPI_APPLICATION */
514 503
diff --git a/drivers/acpi/acpica/achware.h b/drivers/acpi/acpica/achware.h
index 6357e932bfd9..2ad2351a9833 100644
--- a/drivers/acpi/acpica/achware.h
+++ b/drivers/acpi/acpica/achware.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acinterp.h b/drivers/acpi/acpica/acinterp.h
index 8af8c9bdeb35..c54267748be5 100644
--- a/drivers/acpi/acpica/acinterp.h
+++ b/drivers/acpi/acpica/acinterp.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -87,6 +87,10 @@ typedef const struct acpi_exdump_info {
87#define ACPI_EXD_PACKAGE 11 87#define ACPI_EXD_PACKAGE 11
88#define ACPI_EXD_FIELD 12 88#define ACPI_EXD_FIELD 12
89#define ACPI_EXD_REFERENCE 13 89#define ACPI_EXD_REFERENCE 13
90#define ACPI_EXD_LIST 14 /* Operand object list */
91#define ACPI_EXD_HDLR_LIST 15 /* Address Handler list */
92#define ACPI_EXD_RGN_LIST 16 /* Region list */
93#define ACPI_EXD_NODE 17 /* Namespace Node */
90 94
91/* restore default alignment */ 95/* restore default alignment */
92 96
diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
index d95ca5449ace..52a21dafb540 100644
--- a/drivers/acpi/acpica/aclocal.h
+++ b/drivers/acpi/acpica/aclocal.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acmacros.h b/drivers/acpi/acpica/acmacros.h
index 2a86c65d873b..4bceb11c7380 100644
--- a/drivers/acpi/acpica/acmacros.h
+++ b/drivers/acpi/acpica/acmacros.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -63,17 +63,21 @@
63#define ACPI_SET64(ptr, val) (*ACPI_CAST64 (ptr) = (u64) (val)) 63#define ACPI_SET64(ptr, val) (*ACPI_CAST64 (ptr) = (u64) (val))
64 64
65/* 65/*
66 * printf() format helpers 66 * printf() format helpers. These macros are workarounds for the difficulties
67 * with emitting 64-bit integers and 64-bit pointers with the same code
68 * for both 32-bit and 64-bit hosts.
67 */ 69 */
68
69/* Split 64-bit integer into two 32-bit values. Use with %8.8X%8.8X */
70
71#define ACPI_FORMAT_UINT64(i) ACPI_HIDWORD(i), ACPI_LODWORD(i) 70#define ACPI_FORMAT_UINT64(i) ACPI_HIDWORD(i), ACPI_LODWORD(i)
72 71
73#if ACPI_MACHINE_WIDTH == 64 72#if ACPI_MACHINE_WIDTH == 64
74#define ACPI_FORMAT_NATIVE_UINT(i) ACPI_FORMAT_UINT64(i) 73#define ACPI_FORMAT_NATIVE_UINT(i) ACPI_FORMAT_UINT64(i)
74#define ACPI_FORMAT_TO_UINT(i) ACPI_FORMAT_UINT64(i)
75#define ACPI_PRINTF_UINT "0x%8.8X%8.8X"
76
75#else 77#else
76#define ACPI_FORMAT_NATIVE_UINT(i) 0, (i) 78#define ACPI_FORMAT_NATIVE_UINT(i) 0, (u32) (i)
79#define ACPI_FORMAT_TO_UINT(i) (u32) (i)
80#define ACPI_PRINTF_UINT "0x%8.8X"
77#endif 81#endif
78 82
79/* 83/*
diff --git a/drivers/acpi/acpica/acnamesp.h b/drivers/acpi/acpica/acnamesp.h
index e6138ac4a160..ee1c040f321c 100644
--- a/drivers/acpi/acpica/acnamesp.h
+++ b/drivers/acpi/acpica/acnamesp.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acobject.h b/drivers/acpi/acpica/acobject.h
index cc7ab6dd724e..1a4d61805ebc 100644
--- a/drivers/acpi/acpica/acobject.h
+++ b/drivers/acpi/acpica/acobject.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acopcode.h b/drivers/acpi/acpica/acopcode.h
index 3fc9ca7e8aa3..dda0e6affcf1 100644
--- a/drivers/acpi/acpica/acopcode.h
+++ b/drivers/acpi/acpica/acopcode.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acparser.h b/drivers/acpi/acpica/acparser.h
index aed319318835..6168b85463ed 100644
--- a/drivers/acpi/acpica/acparser.h
+++ b/drivers/acpi/acpica/acparser.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acpredef.h b/drivers/acpi/acpica/acpredef.h
index f600aded7261..a48d713e9599 100644
--- a/drivers/acpi/acpica/acpredef.h
+++ b/drivers/acpi/acpica/acpredef.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -48,7 +48,7 @@
48 * 48 *
49 * Return Package types 49 * Return Package types
50 * 50 *
51 * 1) PTYPE1 packages do not contain sub-packages. 51 * 1) PTYPE1 packages do not contain subpackages.
52 * 52 *
53 * ACPI_PTYPE1_FIXED: Fixed-length length, 1 or 2 object types: 53 * ACPI_PTYPE1_FIXED: Fixed-length length, 1 or 2 object types:
54 * object type 54 * object type
@@ -63,8 +63,8 @@
63 * (Used for _PRW) 63 * (Used for _PRW)
64 * 64 *
65 * 65 *
66 * 2) PTYPE2 packages contain a Variable-length number of sub-packages. Each 66 * 2) PTYPE2 packages contain a Variable-length number of subpackages. Each
67 * of the different types describe the contents of each of the sub-packages. 67 * of the different types describe the contents of each of the subpackages.
68 * 68 *
69 * ACPI_PTYPE2: Each subpackage contains 1 or 2 object types. Zero-length 69 * ACPI_PTYPE2: Each subpackage contains 1 or 2 object types. Zero-length
70 * parent package is allowed: 70 * parent package is allowed:
@@ -560,7 +560,7 @@ const union acpi_predefined_info acpi_gbl_predefined_methods[] = {
560 560
561 /* 561 /*
562 * For _HPX, a single package is returned, containing a variable-length number 562 * For _HPX, a single package is returned, containing a variable-length number
563 * of sub-packages. Each sub-package contains a PCI record setting. 563 * of subpackages. Each subpackage contains a PCI record setting.
564 * There are several different type of record settings, of different 564 * There are several different type of record settings, of different
565 * lengths, but all elements of all settings are Integers. 565 * lengths, but all elements of all settings are Integers.
566 */ 566 */
@@ -698,6 +698,12 @@ const union acpi_predefined_info acpi_gbl_predefined_methods[] = {
698 METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */ 698 METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */
699 PACKAGE_INFO(ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0), 699 PACKAGE_INFO(ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0),
700 700
701 {{"_PRP", METHOD_0ARGS,
702 METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Pkgs) each: 1 Str, 1 Int/Str/Pkg */
703 PACKAGE_INFO(ACPI_PTYPE2, ACPI_RTYPE_STRING, 1,
704 ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING |
705 ACPI_RTYPE_PACKAGE | ACPI_RTYPE_REFERENCE, 1, 0),
706
701 {{"_PRS", METHOD_0ARGS, 707 {{"_PRS", METHOD_0ARGS,
702 METHOD_RETURNS(ACPI_RTYPE_BUFFER)}}, 708 METHOD_RETURNS(ACPI_RTYPE_BUFFER)}},
703 709
diff --git a/drivers/acpi/acpica/acresrc.h b/drivers/acpi/acpica/acresrc.h
index ff97430455cb..4b008e8884a1 100644
--- a/drivers/acpi/acpica/acresrc.h
+++ b/drivers/acpi/acpica/acresrc.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acstruct.h b/drivers/acpi/acpica/acstruct.h
index fc83c0a5ca70..5d2989a1b68c 100644
--- a/drivers/acpi/acpica/acstruct.h
+++ b/drivers/acpi/acpica/acstruct.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/actables.h b/drivers/acpi/acpica/actables.h
index c54f42c64fe2..5fa4b2027697 100644
--- a/drivers/acpi/acpica/actables.h
+++ b/drivers/acpi/acpica/actables.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h
index be8180c17d7e..ceeec0b7ccb1 100644
--- a/drivers/acpi/acpica/acutils.h
+++ b/drivers/acpi/acpica/acutils.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -49,7 +49,7 @@ extern const u8 acpi_gbl_resource_aml_serial_bus_sizes[];
49 49
50/* Strings used by the disassembler and debugger resource dump routines */ 50/* Strings used by the disassembler and debugger resource dump routines */
51 51
52#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER) 52#if defined(ACPI_DEBUG_OUTPUT) || defined (ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER)
53 53
54extern const char *acpi_gbl_bm_decode[]; 54extern const char *acpi_gbl_bm_decode[];
55extern const char *acpi_gbl_config_decode[]; 55extern const char *acpi_gbl_config_decode[];
diff --git a/drivers/acpi/acpica/amlcode.h b/drivers/acpi/acpica/amlcode.h
index 48a3e331b72d..5908ccec6aea 100644
--- a/drivers/acpi/acpica/amlcode.h
+++ b/drivers/acpi/acpica/amlcode.h
@@ -7,7 +7,7 @@
7 *****************************************************************************/ 7 *****************************************************************************/
8 8
9/* 9/*
10 * Copyright (C) 2000 - 2013, Intel Corp. 10 * Copyright (C) 2000 - 2014, Intel Corp.
11 * All rights reserved. 11 * All rights reserved.
12 * 12 *
13 * Redistribution and use in source and binary forms, with or without 13 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/amlresrc.h b/drivers/acpi/acpica/amlresrc.h
index 87c26366d1df..f3f834408441 100644
--- a/drivers/acpi/acpica/amlresrc.h
+++ b/drivers/acpi/acpica/amlresrc.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dsargs.c b/drivers/acpi/acpica/dsargs.c
index afdc6df17abf..720b1cdda711 100644
--- a/drivers/acpi/acpica/dsargs.c
+++ b/drivers/acpi/acpica/dsargs.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2013, Intel Corp. 9 * Copyright (C) 2000 - 2014, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dscontrol.c b/drivers/acpi/acpica/dscontrol.c
index eb56b66444b5..8daf9de82b73 100644
--- a/drivers/acpi/acpica/dscontrol.c
+++ b/drivers/acpi/acpica/dscontrol.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2013, Intel Corp. 9 * Copyright (C) 2000 - 2014, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dsfield.c b/drivers/acpi/acpica/dsfield.c
index e7a57c554e84..3661c8e90540 100644
--- a/drivers/acpi/acpica/dsfield.c
+++ b/drivers/acpi/acpica/dsfield.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dsinit.c b/drivers/acpi/acpica/dsinit.c
index 14424200d246..96644d5ac0e1 100644
--- a/drivers/acpi/acpica/dsinit.c
+++ b/drivers/acpi/acpica/dsinit.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dsmethod.c b/drivers/acpi/acpica/dsmethod.c
index 81a78ba84311..2c6d42c2bc01 100644
--- a/drivers/acpi/acpica/dsmethod.c
+++ b/drivers/acpi/acpica/dsmethod.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dsmthdat.c b/drivers/acpi/acpica/dsmthdat.c
index c4b0b3657237..b67522df01ac 100644
--- a/drivers/acpi/acpica/dsmthdat.c
+++ b/drivers/acpi/acpica/dsmthdat.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dsobject.c b/drivers/acpi/acpica/dsobject.c
index b1746a68dad1..a1e7e6b6fcf7 100644
--- a/drivers/acpi/acpica/dsobject.c
+++ b/drivers/acpi/acpica/dsobject.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dsopcode.c b/drivers/acpi/acpica/dsopcode.c
index 5205edcf2c01..6c0759c0db47 100644
--- a/drivers/acpi/acpica/dsopcode.c
+++ b/drivers/acpi/acpica/dsopcode.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dsutils.c b/drivers/acpi/acpica/dsutils.c
index d7f53fb2979a..9f74795e2268 100644
--- a/drivers/acpi/acpica/dsutils.c
+++ b/drivers/acpi/acpica/dsutils.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dswexec.c b/drivers/acpi/acpica/dswexec.c
index 1bbb22fd6fa0..f7f5107e754d 100644
--- a/drivers/acpi/acpica/dswexec.c
+++ b/drivers/acpi/acpica/dswexec.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2013, Intel Corp. 9 * Copyright (C) 2000 - 2014, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dswload.c b/drivers/acpi/acpica/dswload.c
index 2dbe109727c8..bd7811c64169 100644
--- a/drivers/acpi/acpica/dswload.c
+++ b/drivers/acpi/acpica/dswload.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dswload2.c b/drivers/acpi/acpica/dswload2.c
index 7f569d573027..2ac28d297305 100644
--- a/drivers/acpi/acpica/dswload2.c
+++ b/drivers/acpi/acpica/dswload2.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dswscope.c b/drivers/acpi/acpica/dswscope.c
index d67891de1b54..9d6e2c1de1f8 100644
--- a/drivers/acpi/acpica/dswscope.c
+++ b/drivers/acpi/acpica/dswscope.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dswstate.c b/drivers/acpi/acpica/dswstate.c
index ecb12e2137ff..24f7d5ea678a 100644
--- a/drivers/acpi/acpica/dswstate.c
+++ b/drivers/acpi/acpica/dswstate.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evevent.c b/drivers/acpi/acpica/evevent.c
index 83cd45f4a870..c7bffff9ed32 100644
--- a/drivers/acpi/acpica/evevent.c
+++ b/drivers/acpi/acpica/evevent.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evglock.c b/drivers/acpi/acpica/evglock.c
index 4c67193a9fa7..3393a73ca0d6 100644
--- a/drivers/acpi/acpica/evglock.c
+++ b/drivers/acpi/acpica/evglock.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evgpe.c b/drivers/acpi/acpica/evgpe.c
index a9cb4a1a4bb8..955f83da68a5 100644
--- a/drivers/acpi/acpica/evgpe.c
+++ b/drivers/acpi/acpica/evgpe.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evgpeblk.c b/drivers/acpi/acpica/evgpeblk.c
index a31e549e64cc..caaed3c673fd 100644
--- a/drivers/acpi/acpica/evgpeblk.c
+++ b/drivers/acpi/acpica/evgpeblk.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evgpeinit.c b/drivers/acpi/acpica/evgpeinit.c
index a3e2f38aadf6..ae779c1e871d 100644
--- a/drivers/acpi/acpica/evgpeinit.c
+++ b/drivers/acpi/acpica/evgpeinit.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evgpeutil.c b/drivers/acpi/acpica/evgpeutil.c
index 4d764e847a08..17e4bbfdb096 100644
--- a/drivers/acpi/acpica/evgpeutil.c
+++ b/drivers/acpi/acpica/evgpeutil.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evhandler.c b/drivers/acpi/acpica/evhandler.c
index e3157313eb27..78ac29351c9e 100644
--- a/drivers/acpi/acpica/evhandler.c
+++ b/drivers/acpi/acpica/evhandler.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evmisc.c b/drivers/acpi/acpica/evmisc.c
index a5687540e9a6..5d594eb2e5ec 100644
--- a/drivers/acpi/acpica/evmisc.c
+++ b/drivers/acpi/acpica/evmisc.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evregion.c b/drivers/acpi/acpica/evregion.c
index 144cbb9b73bc..9957297d1580 100644
--- a/drivers/acpi/acpica/evregion.c
+++ b/drivers/acpi/acpica/evregion.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -314,6 +314,7 @@ acpi_ev_detach_region(union acpi_operand_object *region_obj,
314{ 314{
315 union acpi_operand_object *handler_obj; 315 union acpi_operand_object *handler_obj;
316 union acpi_operand_object *obj_desc; 316 union acpi_operand_object *obj_desc;
317 union acpi_operand_object *start_desc;
317 union acpi_operand_object **last_obj_ptr; 318 union acpi_operand_object **last_obj_ptr;
318 acpi_adr_space_setup region_setup; 319 acpi_adr_space_setup region_setup;
319 void **region_context; 320 void **region_context;
@@ -341,6 +342,7 @@ acpi_ev_detach_region(union acpi_operand_object *region_obj,
341 /* Find this region in the handler's list */ 342 /* Find this region in the handler's list */
342 343
343 obj_desc = handler_obj->address_space.region_list; 344 obj_desc = handler_obj->address_space.region_list;
345 start_desc = obj_desc;
344 last_obj_ptr = &handler_obj->address_space.region_list; 346 last_obj_ptr = &handler_obj->address_space.region_list;
345 347
346 while (obj_desc) { 348 while (obj_desc) {
@@ -438,6 +440,15 @@ acpi_ev_detach_region(union acpi_operand_object *region_obj,
438 440
439 last_obj_ptr = &obj_desc->region.next; 441 last_obj_ptr = &obj_desc->region.next;
440 obj_desc = obj_desc->region.next; 442 obj_desc = obj_desc->region.next;
443
444 /* Prevent infinite loop if list is corrupted */
445
446 if (obj_desc == start_desc) {
447 ACPI_ERROR((AE_INFO,
448 "Circular handler list in region object %p",
449 region_obj));
450 return_VOID;
451 }
441 } 452 }
442 453
443 /* If we get here, the region was not in the handler's region list */ 454 /* If we get here, the region was not in the handler's region list */
diff --git a/drivers/acpi/acpica/evrgnini.c b/drivers/acpi/acpica/evrgnini.c
index 8354c4f7f10c..1b148a440d67 100644
--- a/drivers/acpi/acpica/evrgnini.c
+++ b/drivers/acpi/acpica/evrgnini.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evsci.c b/drivers/acpi/acpica/evsci.c
index 9e9e3454d893..4d8a709c1fc4 100644
--- a/drivers/acpi/acpica/evsci.c
+++ b/drivers/acpi/acpica/evsci.c
@@ -6,7 +6,7 @@
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2013, Intel Corp. 9 * Copyright (C) 2000 - 2014, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evxface.c b/drivers/acpi/acpica/evxface.c
index 23a7fadca412..a734b27da061 100644
--- a/drivers/acpi/acpica/evxface.c
+++ b/drivers/acpi/acpica/evxface.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evxfevnt.c b/drivers/acpi/acpica/evxfevnt.c
index 39d06af5e347..e286640ad4ff 100644
--- a/drivers/acpi/acpica/evxfevnt.c
+++ b/drivers/acpi/acpica/evxfevnt.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evxfgpe.c b/drivers/acpi/acpica/evxfgpe.c
index 5713da77c665..20a1392ffe06 100644
--- a/drivers/acpi/acpica/evxfgpe.c
+++ b/drivers/acpi/acpica/evxfgpe.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -583,6 +583,18 @@ acpi_install_gpe_block(acpi_handle gpe_device,
583 goto unlock_and_exit; 583 goto unlock_and_exit;
584 } 584 }
585 585
586 /* Validate the parent device */
587
588 if (node->type != ACPI_TYPE_DEVICE) {
589 status = AE_TYPE;
590 goto unlock_and_exit;
591 }
592
593 if (node->object) {
594 status = AE_ALREADY_EXISTS;
595 goto unlock_and_exit;
596 }
597
586 /* 598 /*
587 * For user-installed GPE Block Devices, the gpe_block_base_number 599 * For user-installed GPE Block Devices, the gpe_block_base_number
588 * is always zero 600 * is always zero
@@ -666,6 +678,13 @@ acpi_status acpi_remove_gpe_block(acpi_handle gpe_device)
666 goto unlock_and_exit; 678 goto unlock_and_exit;
667 } 679 }
668 680
681 /* Validate the parent device */
682
683 if (node->type != ACPI_TYPE_DEVICE) {
684 status = AE_TYPE;
685 goto unlock_and_exit;
686 }
687
669 /* Get the device_object attached to the node */ 688 /* Get the device_object attached to the node */
670 689
671 obj_desc = acpi_ns_get_attached_object(node); 690 obj_desc = acpi_ns_get_attached_object(node);
diff --git a/drivers/acpi/acpica/evxfregn.c b/drivers/acpi/acpica/evxfregn.c
index 02ed75ac56cd..2d6f187939c7 100644
--- a/drivers/acpi/acpica/evxfregn.c
+++ b/drivers/acpi/acpica/evxfregn.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2013, Intel Corp. 9 * Copyright (C) 2000 - 2014, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exconfig.c b/drivers/acpi/acpica/exconfig.c
index 06d216c8d43a..8ba1464efd11 100644
--- a/drivers/acpi/acpica/exconfig.c
+++ b/drivers/acpi/acpica/exconfig.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exconvrt.c b/drivers/acpi/acpica/exconvrt.c
index 69e4a8cc9b71..c545386fee96 100644
--- a/drivers/acpi/acpica/exconvrt.c
+++ b/drivers/acpi/acpica/exconvrt.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/excreate.c b/drivers/acpi/acpica/excreate.c
index 3c2e6dcdad3e..95d23dabcfbb 100644
--- a/drivers/acpi/acpica/excreate.c
+++ b/drivers/acpi/acpica/excreate.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exdebug.c b/drivers/acpi/acpica/exdebug.c
index 81c72a4ecd82..4cfc3d3b5c97 100644
--- a/drivers/acpi/acpica/exdebug.c
+++ b/drivers/acpi/acpica/exdebug.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exdump.c b/drivers/acpi/acpica/exdump.c
index 4d046faac48c..973fdae00f94 100644
--- a/drivers/acpi/acpica/exdump.c
+++ b/drivers/acpi/acpica/exdump.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -94,12 +94,13 @@ static struct acpi_exdump_info acpi_ex_dump_buffer[5] = {
94 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_buffer), NULL}, 94 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_buffer), NULL},
95 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(buffer.length), "Length"}, 95 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(buffer.length), "Length"},
96 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(buffer.pointer), "Pointer"}, 96 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(buffer.pointer), "Pointer"},
97 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(buffer.node), "Parent Node"}, 97 {ACPI_EXD_NODE, ACPI_EXD_OFFSET(buffer.node), "Parent Node"},
98 {ACPI_EXD_BUFFER, 0, NULL} 98 {ACPI_EXD_BUFFER, 0, NULL}
99}; 99};
100 100
101static struct acpi_exdump_info acpi_ex_dump_package[5] = { 101static struct acpi_exdump_info acpi_ex_dump_package[6] = {
102 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_package), NULL}, 102 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_package), NULL},
103 {ACPI_EXD_NODE, ACPI_EXD_OFFSET(package.node), "Parent Node"},
103 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(package.flags), "Flags"}, 104 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(package.flags), "Flags"},
104 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(package.count), "Elements"}, 105 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(package.count), "Elements"},
105 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(package.elements), "Element List"}, 106 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(package.elements), "Element List"},
@@ -108,11 +109,11 @@ static struct acpi_exdump_info acpi_ex_dump_package[5] = {
108 109
109static struct acpi_exdump_info acpi_ex_dump_device[4] = { 110static struct acpi_exdump_info acpi_ex_dump_device[4] = {
110 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_device), NULL}, 111 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_device), NULL},
111 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(device.handler), "Handler"},
112 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(device.notify_list[0]), 112 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(device.notify_list[0]),
113 "System Notify"}, 113 "System Notify"},
114 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(device.notify_list[1]), 114 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(device.notify_list[1]),
115 "Device Notify"} 115 "Device Notify"},
116 {ACPI_EXD_HDLR_LIST, ACPI_EXD_OFFSET(device.handler), "Handler"}
116}; 117};
117 118
118static struct acpi_exdump_info acpi_ex_dump_event[2] = { 119static struct acpi_exdump_info acpi_ex_dump_event[2] = {
@@ -142,17 +143,18 @@ static struct acpi_exdump_info acpi_ex_dump_mutex[5] = {
142 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.os_mutex), "OsMutex"} 143 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.os_mutex), "OsMutex"}
143}; 144};
144 145
145static struct acpi_exdump_info acpi_ex_dump_region[7] = { 146static struct acpi_exdump_info acpi_ex_dump_region[8] = {
146 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_region), NULL}, 147 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_region), NULL},
147 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(region.space_id), "Space Id"}, 148 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(region.space_id), "Space Id"},
148 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(region.flags), "Flags"}, 149 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(region.flags), "Flags"},
150 {ACPI_EXD_NODE, ACPI_EXD_OFFSET(region.node), "Parent Node"},
149 {ACPI_EXD_ADDRESS, ACPI_EXD_OFFSET(region.address), "Address"}, 151 {ACPI_EXD_ADDRESS, ACPI_EXD_OFFSET(region.address), "Address"},
150 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(region.length), "Length"}, 152 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(region.length), "Length"},
151 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(region.handler), "Handler"}, 153 {ACPI_EXD_HDLR_LIST, ACPI_EXD_OFFSET(region.handler), "Handler"},
152 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(region.next), "Next"} 154 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(region.next), "Next"}
153}; 155};
154 156
155static struct acpi_exdump_info acpi_ex_dump_power[5] = { 157static struct acpi_exdump_info acpi_ex_dump_power[6] = {
156 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_power), NULL}, 158 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_power), NULL},
157 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(power_resource.system_level), 159 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(power_resource.system_level),
158 "System Level"}, 160 "System Level"},
@@ -161,7 +163,8 @@ static struct acpi_exdump_info acpi_ex_dump_power[5] = {
161 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(power_resource.notify_list[0]), 163 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(power_resource.notify_list[0]),
162 "System Notify"}, 164 "System Notify"},
163 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(power_resource.notify_list[1]), 165 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(power_resource.notify_list[1]),
164 "Device Notify"} 166 "Device Notify"},
167 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(power_resource.handler), "Handler"}
165}; 168};
166 169
167static struct acpi_exdump_info acpi_ex_dump_processor[7] = { 170static struct acpi_exdump_info acpi_ex_dump_processor[7] = {
@@ -225,7 +228,7 @@ static struct acpi_exdump_info acpi_ex_dump_reference[8] = {
225 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(reference.target_type), "Target Type"}, 228 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(reference.target_type), "Target Type"},
226 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(reference.value), "Value"}, 229 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(reference.value), "Value"},
227 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(reference.object), "Object Desc"}, 230 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(reference.object), "Object Desc"},
228 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(reference.node), "Node"}, 231 {ACPI_EXD_NODE, ACPI_EXD_OFFSET(reference.node), "Node"},
229 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(reference.where), "Where"}, 232 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(reference.where), "Where"},
230 {ACPI_EXD_REFERENCE, 0, NULL} 233 {ACPI_EXD_REFERENCE, 0, NULL}
231}; 234};
@@ -234,16 +237,16 @@ static struct acpi_exdump_info acpi_ex_dump_address_handler[6] = {
234 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_address_handler), 237 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_address_handler),
235 NULL}, 238 NULL},
236 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(address_space.space_id), "Space Id"}, 239 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(address_space.space_id), "Space Id"},
237 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(address_space.next), "Next"}, 240 {ACPI_EXD_HDLR_LIST, ACPI_EXD_OFFSET(address_space.next), "Next"},
238 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(address_space.region_list), 241 {ACPI_EXD_RGN_LIST, ACPI_EXD_OFFSET(address_space.region_list),
239 "Region List"}, 242 "Region List"},
240 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(address_space.node), "Node"}, 243 {ACPI_EXD_NODE, ACPI_EXD_OFFSET(address_space.node), "Node"},
241 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(address_space.context), "Context"} 244 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(address_space.context), "Context"}
242}; 245};
243 246
244static struct acpi_exdump_info acpi_ex_dump_notify[7] = { 247static struct acpi_exdump_info acpi_ex_dump_notify[7] = {
245 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_notify), NULL}, 248 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_notify), NULL},
246 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(notify.node), "Node"}, 249 {ACPI_EXD_NODE, ACPI_EXD_OFFSET(notify.node), "Node"},
247 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(notify.handler_type), "Handler Type"}, 250 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(notify.handler_type), "Handler Type"},
248 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(notify.handler), "Handler"}, 251 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(notify.handler), "Handler"},
249 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(notify.context), "Context"}, 252 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(notify.context), "Context"},
@@ -252,14 +255,31 @@ static struct acpi_exdump_info acpi_ex_dump_notify[7] = {
252 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(notify.next[1]), "Next Device Notify"} 255 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(notify.next[1]), "Next Device Notify"}
253}; 256};
254 257
258static struct acpi_exdump_info acpi_ex_dump_extra[6] = {
259 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_extra), NULL},
260 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(extra.method_REG), "_REG Method"},
261 {ACPI_EXD_NODE, ACPI_EXD_OFFSET(extra.scope_node), "Scope Node"},
262 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(extra.region_context),
263 "Region Context"},
264 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(extra.aml_start), "Aml Start"},
265 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(extra.aml_length), "Aml Length"}
266};
267
268static struct acpi_exdump_info acpi_ex_dump_data[3] = {
269 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_data), NULL},
270 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(data.handler), "Handler"},
271 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(data.pointer), "Raw Data"}
272};
273
255/* Miscellaneous tables */ 274/* Miscellaneous tables */
256 275
257static struct acpi_exdump_info acpi_ex_dump_common[4] = { 276static struct acpi_exdump_info acpi_ex_dump_common[5] = {
258 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_common), NULL}, 277 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_common), NULL},
259 {ACPI_EXD_TYPE, 0, NULL}, 278 {ACPI_EXD_TYPE, 0, NULL},
260 {ACPI_EXD_UINT16, ACPI_EXD_OFFSET(common.reference_count), 279 {ACPI_EXD_UINT16, ACPI_EXD_OFFSET(common.reference_count),
261 "Reference Count"}, 280 "Reference Count"},
262 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(common.flags), "Flags"} 281 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(common.flags), "Flags"},
282 {ACPI_EXD_LIST, ACPI_EXD_OFFSET(common.next_object), "Object List"}
263}; 283};
264 284
265static struct acpi_exdump_info acpi_ex_dump_field_common[7] = { 285static struct acpi_exdump_info acpi_ex_dump_field_common[7] = {
@@ -274,15 +294,17 @@ static struct acpi_exdump_info acpi_ex_dump_field_common[7] = {
274 "Field Bit Offset"}, 294 "Field Bit Offset"},
275 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(common_field.base_byte_offset), 295 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(common_field.base_byte_offset),
276 "Base Byte Offset"}, 296 "Base Byte Offset"},
277 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(common_field.node), "Parent Node"} 297 {ACPI_EXD_NODE, ACPI_EXD_OFFSET(common_field.node), "Parent Node"}
278}; 298};
279 299
280static struct acpi_exdump_info acpi_ex_dump_node[5] = { 300static struct acpi_exdump_info acpi_ex_dump_node[7] = {
281 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_node), NULL}, 301 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_node), NULL},
282 {ACPI_EXD_UINT8, ACPI_EXD_NSOFFSET(flags), "Flags"}, 302 {ACPI_EXD_UINT8, ACPI_EXD_NSOFFSET(flags), "Flags"},
283 {ACPI_EXD_UINT8, ACPI_EXD_NSOFFSET(owner_id), "Owner Id"}, 303 {ACPI_EXD_UINT8, ACPI_EXD_NSOFFSET(owner_id), "Owner Id"},
284 {ACPI_EXD_POINTER, ACPI_EXD_NSOFFSET(child), "Child List"}, 304 {ACPI_EXD_LIST, ACPI_EXD_NSOFFSET(object), "Object List"},
285 {ACPI_EXD_POINTER, ACPI_EXD_NSOFFSET(peer), "Next Peer"} 305 {ACPI_EXD_NODE, ACPI_EXD_NSOFFSET(parent), "Parent"},
306 {ACPI_EXD_NODE, ACPI_EXD_NSOFFSET(child), "Child"},
307 {ACPI_EXD_NODE, ACPI_EXD_NSOFFSET(peer), "Peer"}
286}; 308};
287 309
288/* Dispatch table, indexed by object type */ 310/* Dispatch table, indexed by object type */
@@ -315,7 +337,9 @@ static struct acpi_exdump_info *acpi_ex_dump_info[] = {
315 acpi_ex_dump_address_handler, 337 acpi_ex_dump_address_handler,
316 NULL, 338 NULL,
317 NULL, 339 NULL,
318 NULL 340 NULL,
341 acpi_ex_dump_extra,
342 acpi_ex_dump_data
319}; 343};
320 344
321/******************************************************************************* 345/*******************************************************************************
@@ -340,6 +364,10 @@ acpi_ex_dump_object(union acpi_operand_object *obj_desc,
340 char *name; 364 char *name;
341 const char *reference_name; 365 const char *reference_name;
342 u8 count; 366 u8 count;
367 union acpi_operand_object *start;
368 union acpi_operand_object *data = NULL;
369 union acpi_operand_object *next;
370 struct acpi_namespace_node *node;
343 371
344 if (!info) { 372 if (!info) {
345 acpi_os_printf 373 acpi_os_printf
@@ -363,9 +391,9 @@ acpi_ex_dump_object(union acpi_operand_object *obj_desc,
363 391
364 case ACPI_EXD_TYPE: 392 case ACPI_EXD_TYPE:
365 393
366 acpi_ex_out_string("Type", 394 acpi_os_printf("%20s : %2.2X [%s]\n", "Type",
367 acpi_ut_get_object_type_name 395 obj_desc->common.type,
368 (obj_desc)); 396 acpi_ut_get_object_type_name(obj_desc));
369 break; 397 break;
370 398
371 case ACPI_EXD_UINT8: 399 case ACPI_EXD_UINT8:
@@ -433,6 +461,121 @@ acpi_ex_dump_object(union acpi_operand_object *obj_desc,
433 acpi_ex_dump_reference_obj(obj_desc); 461 acpi_ex_dump_reference_obj(obj_desc);
434 break; 462 break;
435 463
464 case ACPI_EXD_LIST:
465
466 start = *ACPI_CAST_PTR(void *, target);
467 next = start;
468
469 acpi_os_printf("%20s : %p", name, next);
470 if (next) {
471 acpi_os_printf("(%s %2.2X)",
472 acpi_ut_get_object_type_name
473 (next), next->common.type);
474
475 while (next->common.next_object) {
476 if ((next->common.type ==
477 ACPI_TYPE_LOCAL_DATA) && !data) {
478 data = next;
479 }
480
481 next = next->common.next_object;
482 acpi_os_printf("->%p(%s %2.2X)", next,
483 acpi_ut_get_object_type_name
484 (next),
485 next->common.type);
486
487 if ((next == start) || (next == data)) {
488 acpi_os_printf
489 ("\n**** Error: Object list appears to be circular linked");
490 break;
491 }
492 }
493 }
494
495 acpi_os_printf("\n", next);
496 break;
497
498 case ACPI_EXD_HDLR_LIST:
499
500 start = *ACPI_CAST_PTR(void *, target);
501 next = start;
502
503 acpi_os_printf("%20s : %p", name, next);
504 if (next) {
505 acpi_os_printf("(%s %2.2X)",
506 acpi_ut_get_object_type_name
507 (next), next->common.type);
508
509 while (next->address_space.next) {
510 if ((next->common.type ==
511 ACPI_TYPE_LOCAL_DATA) && !data) {
512 data = next;
513 }
514
515 next = next->address_space.next;
516 acpi_os_printf("->%p(%s %2.2X)", next,
517 acpi_ut_get_object_type_name
518 (next),
519 next->common.type);
520
521 if ((next == start) || (next == data)) {
522 acpi_os_printf
523 ("\n**** Error: Handler list appears to be circular linked");
524 break;
525 }
526 }
527 }
528
529 acpi_os_printf("\n", next);
530 break;
531
532 case ACPI_EXD_RGN_LIST:
533
534 start = *ACPI_CAST_PTR(void *, target);
535 next = start;
536
537 acpi_os_printf("%20s : %p", name, next);
538 if (next) {
539 acpi_os_printf("(%s %2.2X)",
540 acpi_ut_get_object_type_name
541 (next), next->common.type);
542
543 while (next->region.next) {
544 if ((next->common.type ==
545 ACPI_TYPE_LOCAL_DATA) && !data) {
546 data = next;
547 }
548
549 next = next->region.next;
550 acpi_os_printf("->%p(%s %2.2X)", next,
551 acpi_ut_get_object_type_name
552 (next),
553 next->common.type);
554
555 if ((next == start) || (next == data)) {
556 acpi_os_printf
557 ("\n**** Error: Region list appears to be circular linked");
558 break;
559 }
560 }
561 }
562
563 acpi_os_printf("\n", next);
564 break;
565
566 case ACPI_EXD_NODE:
567
568 node =
569 *ACPI_CAST_PTR(struct acpi_namespace_node *,
570 target);
571
572 acpi_os_printf("%20s : %p", name, node);
573 if (node) {
574 acpi_os_printf(" [%4.4s]", node->name.ascii);
575 }
576 acpi_os_printf("\n");
577 break;
578
436 default: 579 default:
437 580
438 acpi_os_printf("**** Invalid table opcode [%X] ****\n", 581 acpi_os_printf("**** Invalid table opcode [%X] ****\n",
@@ -821,10 +964,8 @@ void acpi_ex_dump_namespace_node(struct acpi_namespace_node *node, u32 flags)
821 } 964 }
822 965
823 acpi_os_printf("%20s : %4.4s\n", "Name", acpi_ut_get_node_name(node)); 966 acpi_os_printf("%20s : %4.4s\n", "Name", acpi_ut_get_node_name(node));
824 acpi_ex_out_string("Type", acpi_ut_get_type_name(node->type)); 967 acpi_os_printf("%20s : %2.2X [%s]\n", "Type",
825 acpi_ex_out_pointer("Attached Object", 968 node->type, acpi_ut_get_type_name(node->type));
826 acpi_ns_get_attached_object(node));
827 acpi_ex_out_pointer("Parent", node->parent);
828 969
829 acpi_ex_dump_object(ACPI_CAST_PTR(union acpi_operand_object, node), 970 acpi_ex_dump_object(ACPI_CAST_PTR(union acpi_operand_object, node),
830 acpi_ex_dump_node); 971 acpi_ex_dump_node);
@@ -1017,22 +1158,26 @@ acpi_ex_dump_object_descriptor(union acpi_operand_object *obj_desc, u32 flags)
1017 ((struct acpi_namespace_node *)obj_desc)-> 1158 ((struct acpi_namespace_node *)obj_desc)->
1018 object); 1159 object);
1019 1160
1020 acpi_ex_dump_object_descriptor(((struct acpi_namespace_node *) 1161 obj_desc = ((struct acpi_namespace_node *)obj_desc)->object;
1021 obj_desc)->object, flags); 1162 goto dump_object;
1022 return_VOID;
1023 } 1163 }
1024 1164
1025 if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) != ACPI_DESC_TYPE_OPERAND) { 1165 if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) != ACPI_DESC_TYPE_OPERAND) {
1026 acpi_os_printf 1166 acpi_os_printf("%p is not an ACPI operand object: [%s]\n",
1027 ("ExDumpObjectDescriptor: %p is not an ACPI operand object: [%s]\n", 1167 obj_desc, acpi_ut_get_descriptor_name(obj_desc));
1028 obj_desc, acpi_ut_get_descriptor_name(obj_desc));
1029 return_VOID; 1168 return_VOID;
1030 } 1169 }
1031 1170
1032 if (obj_desc->common.type > ACPI_TYPE_NS_NODE_MAX) { 1171 /* Validate the object type */
1172
1173 if (obj_desc->common.type > ACPI_TYPE_LOCAL_MAX) {
1174 acpi_os_printf("Not a known object type: %2.2X\n",
1175 obj_desc->common.type);
1033 return_VOID; 1176 return_VOID;
1034 } 1177 }
1035 1178
1179dump_object:
1180
1036 /* Common Fields */ 1181 /* Common Fields */
1037 1182
1038 acpi_ex_dump_object(obj_desc, acpi_ex_dump_common); 1183 acpi_ex_dump_object(obj_desc, acpi_ex_dump_common);
@@ -1040,6 +1185,22 @@ acpi_ex_dump_object_descriptor(union acpi_operand_object *obj_desc, u32 flags)
1040 /* Object-specific fields */ 1185 /* Object-specific fields */
1041 1186
1042 acpi_ex_dump_object(obj_desc, acpi_ex_dump_info[obj_desc->common.type]); 1187 acpi_ex_dump_object(obj_desc, acpi_ex_dump_info[obj_desc->common.type]);
1188
1189 if (obj_desc->common.type == ACPI_TYPE_REGION) {
1190 obj_desc = obj_desc->common.next_object;
1191 if (obj_desc->common.type > ACPI_TYPE_LOCAL_MAX) {
1192 acpi_os_printf
1193 ("Secondary object is not a known object type: %2.2X\n",
1194 obj_desc->common.type);
1195
1196 return_VOID;
1197 }
1198
1199 acpi_os_printf("\nExtra attached Object (%p):\n", obj_desc);
1200 acpi_ex_dump_object(obj_desc,
1201 acpi_ex_dump_info[obj_desc->common.type]);
1202 }
1203
1043 return_VOID; 1204 return_VOID;
1044} 1205}
1045 1206
diff --git a/drivers/acpi/acpica/exfield.c b/drivers/acpi/acpica/exfield.c
index cfd875243421..68d97441432c 100644
--- a/drivers/acpi/acpica/exfield.c
+++ b/drivers/acpi/acpica/exfield.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exfldio.c b/drivers/acpi/acpica/exfldio.c
index 49fb742d61b9..1d1b27a96c5b 100644
--- a/drivers/acpi/acpica/exfldio.c
+++ b/drivers/acpi/acpica/exfldio.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exmisc.c b/drivers/acpi/acpica/exmisc.c
index 65d93607f368..2207e624f538 100644
--- a/drivers/acpi/acpica/exmisc.c
+++ b/drivers/acpi/acpica/exmisc.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exmutex.c b/drivers/acpi/acpica/exmutex.c
index 7be0205ad067..b49ea2a95f4f 100644
--- a/drivers/acpi/acpica/exmutex.c
+++ b/drivers/acpi/acpica/exmutex.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exnames.c b/drivers/acpi/acpica/exnames.c
index 14689dec4960..dbb03b544e8c 100644
--- a/drivers/acpi/acpica/exnames.c
+++ b/drivers/acpi/acpica/exnames.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exoparg1.c b/drivers/acpi/acpica/exoparg1.c
index d74cea416ca0..1b8e94104407 100644
--- a/drivers/acpi/acpica/exoparg1.c
+++ b/drivers/acpi/acpica/exoparg1.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exoparg2.c b/drivers/acpi/acpica/exoparg2.c
index d6fa0fce1fc9..2ede656ee26a 100644
--- a/drivers/acpi/acpica/exoparg2.c
+++ b/drivers/acpi/acpica/exoparg2.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exoparg3.c b/drivers/acpi/acpica/exoparg3.c
index bc042adf8804..363767cf01e5 100644
--- a/drivers/acpi/acpica/exoparg3.c
+++ b/drivers/acpi/acpica/exoparg3.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exoparg6.c b/drivers/acpi/acpica/exoparg6.c
index 4459e32c683d..29e9e99f7fe3 100644
--- a/drivers/acpi/acpica/exoparg6.c
+++ b/drivers/acpi/acpica/exoparg6.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exprep.c b/drivers/acpi/acpica/exprep.c
index 5a588611ab48..ee3f872870bc 100644
--- a/drivers/acpi/acpica/exprep.c
+++ b/drivers/acpi/acpica/exprep.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exregion.c b/drivers/acpi/acpica/exregion.c
index 9d28867e60dc..cd5288a257a9 100644
--- a/drivers/acpi/acpica/exregion.c
+++ b/drivers/acpi/acpica/exregion.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exresnte.c b/drivers/acpi/acpica/exresnte.c
index 7ca6925a87ca..ab060261b43e 100644
--- a/drivers/acpi/acpica/exresnte.c
+++ b/drivers/acpi/acpica/exresnte.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exresolv.c b/drivers/acpi/acpica/exresolv.c
index 1606524312e3..3cde553bcbe1 100644
--- a/drivers/acpi/acpica/exresolv.c
+++ b/drivers/acpi/acpica/exresolv.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exresop.c b/drivers/acpi/acpica/exresop.c
index be3f66973ee8..3af8de3fcea4 100644
--- a/drivers/acpi/acpica/exresop.c
+++ b/drivers/acpi/acpica/exresop.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exstore.c b/drivers/acpi/acpica/exstore.c
index f0b09bf9887d..daf49f7ea311 100644
--- a/drivers/acpi/acpica/exstore.c
+++ b/drivers/acpi/acpica/exstore.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exstoren.c b/drivers/acpi/acpica/exstoren.c
index 20d809d90c5b..04bd16c08f9e 100644
--- a/drivers/acpi/acpica/exstoren.c
+++ b/drivers/acpi/acpica/exstoren.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2013, Intel Corp. 9 * Copyright (C) 2000 - 2014, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exstorob.c b/drivers/acpi/acpica/exstorob.c
index 26e371073b1a..fd11018b0168 100644
--- a/drivers/acpi/acpica/exstorob.c
+++ b/drivers/acpi/acpica/exstorob.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exsystem.c b/drivers/acpi/acpica/exsystem.c
index 6578dee2e51b..841caed11c08 100644
--- a/drivers/acpi/acpica/exsystem.c
+++ b/drivers/acpi/acpica/exsystem.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exutils.c b/drivers/acpi/acpica/exutils.c
index 99dc7b287d55..5b16c5484bee 100644
--- a/drivers/acpi/acpica/exutils.c
+++ b/drivers/acpi/acpica/exutils.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/hwacpi.c b/drivers/acpi/acpica/hwacpi.c
index 3d36df828f52..1e66d960fc11 100644
--- a/drivers/acpi/acpica/hwacpi.c
+++ b/drivers/acpi/acpica/hwacpi.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/hwesleep.c b/drivers/acpi/acpica/hwesleep.c
index 414076818d40..858fdd6be598 100644
--- a/drivers/acpi/acpica/hwesleep.c
+++ b/drivers/acpi/acpica/hwesleep.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2013, Intel Corp. 9 * Copyright (C) 2000 - 2014, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/hwgpe.c b/drivers/acpi/acpica/hwgpe.c
index 96540506058f..2e6caabba07a 100644
--- a/drivers/acpi/acpica/hwgpe.c
+++ b/drivers/acpi/acpica/hwgpe.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/hwpci.c b/drivers/acpi/acpica/hwpci.c
index 0889a629505f..e701d8c33dbf 100644
--- a/drivers/acpi/acpica/hwpci.c
+++ b/drivers/acpi/acpica/hwpci.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/hwregs.c b/drivers/acpi/acpica/hwregs.c
index 12e6cff54f78..e0fd9b4978cd 100644
--- a/drivers/acpi/acpica/hwregs.c
+++ b/drivers/acpi/acpica/hwregs.c
@@ -6,7 +6,7 @@
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2013, Intel Corp. 9 * Copyright (C) 2000 - 2014, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/hwsleep.c b/drivers/acpi/acpica/hwsleep.c
index e3828cc4361b..d590693eb54e 100644
--- a/drivers/acpi/acpica/hwsleep.c
+++ b/drivers/acpi/acpica/hwsleep.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2013, Intel Corp. 9 * Copyright (C) 2000 - 2014, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/hwtimer.c b/drivers/acpi/acpica/hwtimer.c
index 3c498dc1636e..76ab5c1a814e 100644
--- a/drivers/acpi/acpica/hwtimer.c
+++ b/drivers/acpi/acpica/hwtimer.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/hwvalid.c b/drivers/acpi/acpica/hwvalid.c
index eab70d58852a..6b919127cd9d 100644
--- a/drivers/acpi/acpica/hwvalid.c
+++ b/drivers/acpi/acpica/hwvalid.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/hwxface.c b/drivers/acpi/acpica/hwxface.c
index b4b47db2dee2..96d007df65ec 100644
--- a/drivers/acpi/acpica/hwxface.c
+++ b/drivers/acpi/acpica/hwxface.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/hwxfsleep.c b/drivers/acpi/acpica/hwxfsleep.c
index 15dddc10fc9b..6921c7f3d208 100644
--- a/drivers/acpi/acpica/hwxfsleep.c
+++ b/drivers/acpi/acpica/hwxfsleep.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsaccess.c b/drivers/acpi/acpica/nsaccess.c
index 14f65f6345b9..f1249e3463be 100644
--- a/drivers/acpi/acpica/nsaccess.c
+++ b/drivers/acpi/acpica/nsaccess.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsalloc.c b/drivers/acpi/acpica/nsalloc.c
index fd1ff54cda19..607eb9e5150d 100644
--- a/drivers/acpi/acpica/nsalloc.c
+++ b/drivers/acpi/acpica/nsalloc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsarguments.c b/drivers/acpi/acpica/nsarguments.c
index 74b24c82707e..80fcfc8c9c1b 100644
--- a/drivers/acpi/acpica/nsarguments.c
+++ b/drivers/acpi/acpica/nsarguments.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsconvert.c b/drivers/acpi/acpica/nsconvert.c
index acd2964c2690..b55642c4ee58 100644
--- a/drivers/acpi/acpica/nsconvert.c
+++ b/drivers/acpi/acpica/nsconvert.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2013, Intel Corp. 9 * Copyright (C) 2000 - 2014, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsdump.c b/drivers/acpi/acpica/nsdump.c
index 48b9c6f12643..3d88ef4a3e0d 100644
--- a/drivers/acpi/acpica/nsdump.c
+++ b/drivers/acpi/acpica/nsdump.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsdumpdv.c b/drivers/acpi/acpica/nsdumpdv.c
index 283762511b73..42d37109aa5d 100644
--- a/drivers/acpi/acpica/nsdumpdv.c
+++ b/drivers/acpi/acpica/nsdumpdv.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nseval.c b/drivers/acpi/acpica/nseval.c
index 963ceef063f8..e634a05974db 100644
--- a/drivers/acpi/acpica/nseval.c
+++ b/drivers/acpi/acpica/nseval.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsinit.c b/drivers/acpi/acpica/nsinit.c
index 3a0423af968c..5b74677bf74d 100644
--- a/drivers/acpi/acpica/nsinit.c
+++ b/drivers/acpi/acpica/nsinit.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsload.c b/drivers/acpi/acpica/nsload.c
index 89ec645e7730..7ae521ce8d3f 100644
--- a/drivers/acpi/acpica/nsload.c
+++ b/drivers/acpi/acpica/nsload.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsnames.c b/drivers/acpi/acpica/nsnames.c
index 90a0380fb8a0..7eee0a6f02f6 100644
--- a/drivers/acpi/acpica/nsnames.c
+++ b/drivers/acpi/acpica/nsnames.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsobject.c b/drivers/acpi/acpica/nsobject.c
index 7a736f4d1fd8..fe54a8c73b8c 100644
--- a/drivers/acpi/acpica/nsobject.c
+++ b/drivers/acpi/acpica/nsobject.c
@@ -6,7 +6,7 @@
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2013, Intel Corp. 9 * Copyright (C) 2000 - 2014, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -222,13 +222,19 @@ void acpi_ns_detach_object(struct acpi_namespace_node *node)
222 } 222 }
223 } 223 }
224 224
225 /* Clear the entry in all cases */ 225 /* Clear the Node entry in all cases */
226 226
227 node->object = NULL; 227 node->object = NULL;
228 if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == ACPI_DESC_TYPE_OPERAND) { 228 if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == ACPI_DESC_TYPE_OPERAND) {
229
230 /* Unlink object from front of possible object list */
231
229 node->object = obj_desc->common.next_object; 232 node->object = obj_desc->common.next_object;
233
234 /* Handle possible 2-descriptor object */
235
230 if (node->object && 236 if (node->object &&
231 ((node->object)->common.type != ACPI_TYPE_LOCAL_DATA)) { 237 (node->object->common.type != ACPI_TYPE_LOCAL_DATA)) {
232 node->object = node->object->common.next_object; 238 node->object = node->object->common.next_object;
233 } 239 }
234 } 240 }
diff --git a/drivers/acpi/acpica/nsparse.c b/drivers/acpi/acpica/nsparse.c
index 177857340271..e83cff31754b 100644
--- a/drivers/acpi/acpica/nsparse.c
+++ b/drivers/acpi/acpica/nsparse.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nspredef.c b/drivers/acpi/acpica/nspredef.c
index d2855d9857c4..392910ffbed9 100644
--- a/drivers/acpi/acpica/nspredef.c
+++ b/drivers/acpi/acpica/nspredef.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsprepkg.c b/drivers/acpi/acpica/nsprepkg.c
index 3d5391f9bcb5..68f725839eb6 100644
--- a/drivers/acpi/acpica/nsprepkg.c
+++ b/drivers/acpi/acpica/nsprepkg.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -132,12 +132,12 @@ acpi_ns_check_package(struct acpi_evaluate_info *info,
132 * Decode the type of the expected package contents 132 * Decode the type of the expected package contents
133 * 133 *
134 * PTYPE1 packages contain no subpackages 134 * PTYPE1 packages contain no subpackages
135 * PTYPE2 packages contain sub-packages 135 * PTYPE2 packages contain subpackages
136 */ 136 */
137 switch (package->ret_info.type) { 137 switch (package->ret_info.type) {
138 case ACPI_PTYPE1_FIXED: 138 case ACPI_PTYPE1_FIXED:
139 /* 139 /*
140 * The package count is fixed and there are no sub-packages 140 * The package count is fixed and there are no subpackages
141 * 141 *
142 * If package is too small, exit. 142 * If package is too small, exit.
143 * If package is larger than expected, issue warning but continue 143 * If package is larger than expected, issue warning but continue
@@ -169,7 +169,7 @@ acpi_ns_check_package(struct acpi_evaluate_info *info,
169 169
170 case ACPI_PTYPE1_VAR: 170 case ACPI_PTYPE1_VAR:
171 /* 171 /*
172 * The package count is variable, there are no sub-packages, and all 172 * The package count is variable, there are no subpackages, and all
173 * elements must be of the same type 173 * elements must be of the same type
174 */ 174 */
175 for (i = 0; i < count; i++) { 175 for (i = 0; i < count; i++) {
@@ -185,7 +185,7 @@ acpi_ns_check_package(struct acpi_evaluate_info *info,
185 185
186 case ACPI_PTYPE1_OPTION: 186 case ACPI_PTYPE1_OPTION:
187 /* 187 /*
188 * The package count is variable, there are no sub-packages. There are 188 * The package count is variable, there are no subpackages. There are
189 * a fixed number of required elements, and a variable number of 189 * a fixed number of required elements, and a variable number of
190 * optional elements. 190 * optional elements.
191 * 191 *
@@ -242,7 +242,7 @@ acpi_ns_check_package(struct acpi_evaluate_info *info,
242 elements++; 242 elements++;
243 count--; 243 count--;
244 244
245 /* Examine the sub-packages */ 245 /* Examine the subpackages */
246 246
247 status = 247 status =
248 acpi_ns_check_package_list(info, package, elements, count); 248 acpi_ns_check_package_list(info, package, elements, count);
@@ -250,7 +250,7 @@ acpi_ns_check_package(struct acpi_evaluate_info *info,
250 250
251 case ACPI_PTYPE2_PKG_COUNT: 251 case ACPI_PTYPE2_PKG_COUNT:
252 252
253 /* First element is the (Integer) count of sub-packages to follow */ 253 /* First element is the (Integer) count of subpackages to follow */
254 254
255 status = acpi_ns_check_object_type(info, elements, 255 status = acpi_ns_check_object_type(info, elements,
256 ACPI_RTYPE_INTEGER, 0); 256 ACPI_RTYPE_INTEGER, 0);
@@ -270,7 +270,7 @@ acpi_ns_check_package(struct acpi_evaluate_info *info,
270 count = expected_count; 270 count = expected_count;
271 elements++; 271 elements++;
272 272
273 /* Examine the sub-packages */ 273 /* Examine the subpackages */
274 274
275 status = 275 status =
276 acpi_ns_check_package_list(info, package, elements, count); 276 acpi_ns_check_package_list(info, package, elements, count);
@@ -283,9 +283,9 @@ acpi_ns_check_package(struct acpi_evaluate_info *info,
283 case ACPI_PTYPE2_FIX_VAR: 283 case ACPI_PTYPE2_FIX_VAR:
284 /* 284 /*
285 * These types all return a single Package that consists of a 285 * These types all return a single Package that consists of a
286 * variable number of sub-Packages. 286 * variable number of subpackages.
287 * 287 *
288 * First, ensure that the first element is a sub-Package. If not, 288 * First, ensure that the first element is a subpackage. If not,
289 * the BIOS may have incorrectly returned the object as a single 289 * the BIOS may have incorrectly returned the object as a single
290 * package instead of a Package of Packages (a common error if 290 * package instead of a Package of Packages (a common error if
291 * there is only one entry). We may be able to repair this by 291 * there is only one entry). We may be able to repair this by
@@ -310,7 +310,7 @@ acpi_ns_check_package(struct acpi_evaluate_info *info,
310 count = 1; 310 count = 1;
311 } 311 }
312 312
313 /* Examine the sub-packages */ 313 /* Examine the subpackages */
314 314
315 status = 315 status =
316 acpi_ns_check_package_list(info, package, elements, count); 316 acpi_ns_check_package_list(info, package, elements, count);
@@ -370,9 +370,9 @@ acpi_ns_check_package_list(struct acpi_evaluate_info *info,
370 u32 j; 370 u32 j;
371 371
372 /* 372 /*
373 * Validate each sub-Package in the parent Package 373 * Validate each subpackage in the parent Package
374 * 374 *
375 * NOTE: assumes list of sub-packages contains no NULL elements. 375 * NOTE: assumes list of subpackages contains no NULL elements.
376 * Any NULL elements should have been removed by earlier call 376 * Any NULL elements should have been removed by earlier call
377 * to acpi_ns_remove_null_elements. 377 * to acpi_ns_remove_null_elements.
378 */ 378 */
@@ -389,7 +389,7 @@ acpi_ns_check_package_list(struct acpi_evaluate_info *info,
389 return (status); 389 return (status);
390 } 390 }
391 391
392 /* Examine the different types of expected sub-packages */ 392 /* Examine the different types of expected subpackages */
393 393
394 info->parent_package = sub_package; 394 info->parent_package = sub_package;
395 switch (package->ret_info.type) { 395 switch (package->ret_info.type) {
@@ -450,14 +450,14 @@ acpi_ns_check_package_list(struct acpi_evaluate_info *info,
450 450
451 case ACPI_PTYPE2_FIXED: 451 case ACPI_PTYPE2_FIXED:
452 452
453 /* Each sub-package has a fixed length */ 453 /* Each subpackage has a fixed length */
454 454
455 expected_count = package->ret_info2.count; 455 expected_count = package->ret_info2.count;
456 if (sub_package->package.count < expected_count) { 456 if (sub_package->package.count < expected_count) {
457 goto package_too_small; 457 goto package_too_small;
458 } 458 }
459 459
460 /* Check the type of each sub-package element */ 460 /* Check the type of each subpackage element */
461 461
462 for (j = 0; j < expected_count; j++) { 462 for (j = 0; j < expected_count; j++) {
463 status = 463 status =
@@ -475,14 +475,14 @@ acpi_ns_check_package_list(struct acpi_evaluate_info *info,
475 475
476 case ACPI_PTYPE2_MIN: 476 case ACPI_PTYPE2_MIN:
477 477
478 /* Each sub-package has a variable but minimum length */ 478 /* Each subpackage has a variable but minimum length */
479 479
480 expected_count = package->ret_info.count1; 480 expected_count = package->ret_info.count1;
481 if (sub_package->package.count < expected_count) { 481 if (sub_package->package.count < expected_count) {
482 goto package_too_small; 482 goto package_too_small;
483 } 483 }
484 484
485 /* Check the type of each sub-package element */ 485 /* Check the type of each subpackage element */
486 486
487 status = 487 status =
488 acpi_ns_check_package_elements(info, sub_elements, 488 acpi_ns_check_package_elements(info, sub_elements,
@@ -531,7 +531,7 @@ acpi_ns_check_package_list(struct acpi_evaluate_info *info,
531 (*sub_elements)->integer.value = expected_count; 531 (*sub_elements)->integer.value = expected_count;
532 } 532 }
533 533
534 /* Check the type of each sub-package element */ 534 /* Check the type of each subpackage element */
535 535
536 status = 536 status =
537 acpi_ns_check_package_elements(info, 537 acpi_ns_check_package_elements(info,
@@ -557,10 +557,10 @@ acpi_ns_check_package_list(struct acpi_evaluate_info *info,
557 557
558package_too_small: 558package_too_small:
559 559
560 /* The sub-package count was smaller than required */ 560 /* The subpackage count was smaller than required */
561 561
562 ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, info->node_flags, 562 ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, info->node_flags,
563 "Return Sub-Package[%u] is too small - found %u elements, expected %u", 563 "Return SubPackage[%u] is too small - found %u elements, expected %u",
564 i, sub_package->package.count, expected_count)); 564 i, sub_package->package.count, expected_count));
565 565
566 return (AE_AML_OPERAND_VALUE); 566 return (AE_AML_OPERAND_VALUE);
diff --git a/drivers/acpi/acpica/nsrepair.c b/drivers/acpi/acpica/nsrepair.c
index a05afff50eb9..7e417aa5c91e 100644
--- a/drivers/acpi/acpica/nsrepair.c
+++ b/drivers/acpi/acpica/nsrepair.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -207,13 +207,30 @@ acpi_ns_simple_repair(struct acpi_evaluate_info *info,
207 * this predefined name. Either one return value is expected, or none, 207 * this predefined name. Either one return value is expected, or none,
208 * for both methods and other objects. 208 * for both methods and other objects.
209 * 209 *
210 * Exit now if there is no return object. Warning if one was expected. 210 * Try to fix if there was no return object. Warning if failed to fix.
211 */ 211 */
212 if (!return_object) { 212 if (!return_object) {
213 if (expected_btypes && (!(expected_btypes & ACPI_RTYPE_NONE))) { 213 if (expected_btypes && (!(expected_btypes & ACPI_RTYPE_NONE))) {
214 ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, 214 if (package_index != ACPI_NOT_PACKAGE_ELEMENT) {
215 ACPI_WARN_ALWAYS, 215 ACPI_WARN_PREDEFINED((AE_INFO,
216 "Missing expected return value")); 216 info->full_pathname,
217 ACPI_WARN_ALWAYS,
218 "Found unexpected NULL package element"));
219
220 status =
221 acpi_ns_repair_null_element(info,
222 expected_btypes,
223 package_index,
224 return_object_ptr);
225 if (ACPI_SUCCESS(status)) {
226 return (AE_OK); /* Repair was successful */
227 }
228 } else {
229 ACPI_WARN_PREDEFINED((AE_INFO,
230 info->full_pathname,
231 ACPI_WARN_ALWAYS,
232 "Missing expected return value"));
233 }
217 234
218 return (AE_AML_NO_RETURN_VALUE); 235 return (AE_AML_NO_RETURN_VALUE);
219 } 236 }
@@ -448,7 +465,7 @@ acpi_ns_repair_null_element(struct acpi_evaluate_info * info,
448 * RETURN: None. 465 * RETURN: None.
449 * 466 *
450 * DESCRIPTION: Remove all NULL package elements from packages that contain 467 * DESCRIPTION: Remove all NULL package elements from packages that contain
451 * a variable number of sub-packages. For these types of 468 * a variable number of subpackages. For these types of
452 * packages, NULL elements can be safely removed. 469 * packages, NULL elements can be safely removed.
453 * 470 *
454 *****************************************************************************/ 471 *****************************************************************************/
@@ -469,7 +486,7 @@ acpi_ns_remove_null_elements(struct acpi_evaluate_info *info,
469 /* 486 /*
470 * We can safely remove all NULL elements from these package types: 487 * We can safely remove all NULL elements from these package types:
471 * PTYPE1_VAR packages contain a variable number of simple data types. 488 * PTYPE1_VAR packages contain a variable number of simple data types.
472 * PTYPE2 packages contain a variable number of sub-packages. 489 * PTYPE2 packages contain a variable number of subpackages.
473 */ 490 */
474 switch (package_type) { 491 switch (package_type) {
475 case ACPI_PTYPE1_VAR: 492 case ACPI_PTYPE1_VAR:
diff --git a/drivers/acpi/acpica/nsrepair2.c b/drivers/acpi/acpica/nsrepair2.c
index 6a25d320b169..b09e6bef72b8 100644
--- a/drivers/acpi/acpica/nsrepair2.c
+++ b/drivers/acpi/acpica/nsrepair2.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2013, Intel Corp. 9 * Copyright (C) 2000 - 2014, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -432,8 +432,8 @@ acpi_ns_repair_CID(struct acpi_evaluate_info *info,
432 * DESCRIPTION: Repair for the _CST object: 432 * DESCRIPTION: Repair for the _CST object:
433 * 1. Sort the list ascending by C state type 433 * 1. Sort the list ascending by C state type
434 * 2. Ensure type cannot be zero 434 * 2. Ensure type cannot be zero
435 * 3. A sub-package count of zero means _CST is meaningless 435 * 3. A subpackage count of zero means _CST is meaningless
436 * 4. Count must match the number of C state sub-packages 436 * 4. Count must match the number of C state subpackages
437 * 437 *
438 *****************************************************************************/ 438 *****************************************************************************/
439 439
@@ -611,6 +611,7 @@ acpi_ns_repair_PRT(struct acpi_evaluate_info *info,
611 union acpi_operand_object **top_object_list; 611 union acpi_operand_object **top_object_list;
612 union acpi_operand_object **sub_object_list; 612 union acpi_operand_object **sub_object_list;
613 union acpi_operand_object *obj_desc; 613 union acpi_operand_object *obj_desc;
614 union acpi_operand_object *sub_package;
614 u32 element_count; 615 u32 element_count;
615 u32 index; 616 u32 index;
616 617
@@ -619,8 +620,17 @@ acpi_ns_repair_PRT(struct acpi_evaluate_info *info,
619 top_object_list = package_object->package.elements; 620 top_object_list = package_object->package.elements;
620 element_count = package_object->package.count; 621 element_count = package_object->package.count;
621 622
622 for (index = 0; index < element_count; index++) { 623 /* Examine each subpackage */
623 sub_object_list = (*top_object_list)->package.elements; 624
625 for (index = 0; index < element_count; index++, top_object_list++) {
626 sub_package = *top_object_list;
627 sub_object_list = sub_package->package.elements;
628
629 /* Check for minimum required element count */
630
631 if (sub_package->package.count < 4) {
632 continue;
633 }
624 634
625 /* 635 /*
626 * If the BIOS has erroneously reversed the _PRT source_name (index 2) 636 * If the BIOS has erroneously reversed the _PRT source_name (index 2)
@@ -634,15 +644,12 @@ acpi_ns_repair_PRT(struct acpi_evaluate_info *info,
634 sub_object_list[2] = obj_desc; 644 sub_object_list[2] = obj_desc;
635 info->return_flags |= ACPI_OBJECT_REPAIRED; 645 info->return_flags |= ACPI_OBJECT_REPAIRED;
636 646
637 ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, 647 ACPI_WARN_PREDEFINED((AE_INFO,
648 info->full_pathname,
638 info->node_flags, 649 info->node_flags,
639 "PRT[%X]: Fixed reversed SourceName and SourceIndex", 650 "PRT[%X]: Fixed reversed SourceName and SourceIndex",
640 index)); 651 index));
641 } 652 }
642
643 /* Point to the next union acpi_operand_object in the top level package */
644
645 top_object_list++;
646 } 653 }
647 654
648 return (AE_OK); 655 return (AE_OK);
@@ -679,7 +686,7 @@ acpi_ns_repair_PSS(struct acpi_evaluate_info *info,
679 u32 i; 686 u32 i;
680 687
681 /* 688 /*
682 * Entries (sub-packages) in the _PSS Package must be sorted by power 689 * Entries (subpackages) in the _PSS Package must be sorted by power
683 * dissipation, in descending order. If it appears that the list is 690 * dissipation, in descending order. If it appears that the list is
684 * incorrectly sorted, sort it. We sort by cpu_frequency, since this 691 * incorrectly sorted, sort it. We sort by cpu_frequency, since this
685 * should be proportional to the power. 692 * should be proportional to the power.
@@ -767,9 +774,9 @@ acpi_ns_repair_TSS(struct acpi_evaluate_info *info,
767 * 774 *
768 * PARAMETERS: info - Method execution information block 775 * PARAMETERS: info - Method execution information block
769 * return_object - Pointer to the top-level returned object 776 * return_object - Pointer to the top-level returned object
770 * start_index - Index of the first sub-package 777 * start_index - Index of the first subpackage
771 * expected_count - Minimum length of each sub-package 778 * expected_count - Minimum length of each subpackage
772 * sort_index - Sub-package entry to sort on 779 * sort_index - Subpackage entry to sort on
773 * sort_direction - Ascending or descending 780 * sort_direction - Ascending or descending
774 * sort_key_name - Name of the sort_index field 781 * sort_key_name - Name of the sort_index field
775 * 782 *
@@ -805,7 +812,7 @@ acpi_ns_check_sorted_list(struct acpi_evaluate_info *info,
805 } 812 }
806 813
807 /* 814 /*
808 * NOTE: assumes list of sub-packages contains no NULL elements. 815 * NOTE: assumes list of subpackages contains no NULL elements.
809 * Any NULL elements should have been removed by earlier call 816 * Any NULL elements should have been removed by earlier call
810 * to acpi_ns_remove_null_elements. 817 * to acpi_ns_remove_null_elements.
811 */ 818 */
@@ -832,7 +839,7 @@ acpi_ns_check_sorted_list(struct acpi_evaluate_info *info,
832 return (AE_AML_OPERAND_TYPE); 839 return (AE_AML_OPERAND_TYPE);
833 } 840 }
834 841
835 /* Each sub-package must have the minimum length */ 842 /* Each subpackage must have the minimum length */
836 843
837 if ((*outer_elements)->package.count < expected_count) { 844 if ((*outer_elements)->package.count < expected_count) {
838 return (AE_AML_PACKAGE_LIMIT); 845 return (AE_AML_PACKAGE_LIMIT);
diff --git a/drivers/acpi/acpica/nssearch.c b/drivers/acpi/acpica/nssearch.c
index 47420faef073..af1cc42a8aa1 100644
--- a/drivers/acpi/acpica/nssearch.c
+++ b/drivers/acpi/acpica/nssearch.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsutils.c b/drivers/acpi/acpica/nsutils.c
index 4a0665b6bcc1..4a5e3f5c0ff7 100644
--- a/drivers/acpi/acpica/nsutils.c
+++ b/drivers/acpi/acpica/nsutils.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2013, Intel Corp. 9 * Copyright (C) 2000 - 2014, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nswalk.c b/drivers/acpi/acpica/nswalk.c
index e81f15ef659a..4758a1f2ce22 100644
--- a/drivers/acpi/acpica/nswalk.c
+++ b/drivers/acpi/acpica/nswalk.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsxfeval.c b/drivers/acpi/acpica/nsxfeval.c
index 1f0c28ba50df..4bd558bf10d2 100644
--- a/drivers/acpi/acpica/nsxfeval.c
+++ b/drivers/acpi/acpica/nsxfeval.c
@@ -6,7 +6,7 @@
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2013, Intel Corp. 9 * Copyright (C) 2000 - 2014, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -923,19 +923,22 @@ ACPI_EXPORT_SYMBOL(acpi_detach_data)
923 923
924/******************************************************************************* 924/*******************************************************************************
925 * 925 *
926 * FUNCTION: acpi_get_data 926 * FUNCTION: acpi_get_data_full
927 * 927 *
928 * PARAMETERS: obj_handle - Namespace node 928 * PARAMETERS: obj_handle - Namespace node
929 * handler - Handler used in call to attach_data 929 * handler - Handler used in call to attach_data
930 * data - Where the data is returned 930 * data - Where the data is returned
931 * callback - function to execute before returning
931 * 932 *
932 * RETURN: Status 933 * RETURN: Status
933 * 934 *
934 * DESCRIPTION: Retrieve data that was previously attached to a namespace node. 935 * DESCRIPTION: Retrieve data that was previously attached to a namespace node
936 * and execute a callback before returning.
935 * 937 *
936 ******************************************************************************/ 938 ******************************************************************************/
937acpi_status 939acpi_status
938acpi_get_data(acpi_handle obj_handle, acpi_object_handler handler, void **data) 940acpi_get_data_full(acpi_handle obj_handle, acpi_object_handler handler,
941 void **data, void (*callback)(void *))
939{ 942{
940 struct acpi_namespace_node *node; 943 struct acpi_namespace_node *node;
941 acpi_status status; 944 acpi_status status;
@@ -960,10 +963,34 @@ acpi_get_data(acpi_handle obj_handle, acpi_object_handler handler, void **data)
960 } 963 }
961 964
962 status = acpi_ns_get_attached_data(node, handler, data); 965 status = acpi_ns_get_attached_data(node, handler, data);
966 if (ACPI_SUCCESS(status) && callback) {
967 callback(*data);
968 }
963 969
964unlock_and_exit: 970unlock_and_exit:
965 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 971 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
966 return (status); 972 return (status);
967} 973}
968 974
975ACPI_EXPORT_SYMBOL(acpi_get_data_full)
976
977/*******************************************************************************
978 *
979 * FUNCTION: acpi_get_data
980 *
981 * PARAMETERS: obj_handle - Namespace node
982 * handler - Handler used in call to attach_data
983 * data - Where the data is returned
984 *
985 * RETURN: Status
986 *
987 * DESCRIPTION: Retrieve data that was previously attached to a namespace node.
988 *
989 ******************************************************************************/
990acpi_status
991acpi_get_data(acpi_handle obj_handle, acpi_object_handler handler, void **data)
992{
993 return acpi_get_data_full(obj_handle, handler, data, NULL);
994}
995
969ACPI_EXPORT_SYMBOL(acpi_get_data) 996ACPI_EXPORT_SYMBOL(acpi_get_data)
diff --git a/drivers/acpi/acpica/nsxfname.c b/drivers/acpi/acpica/nsxfname.c
index 3a4bd3ff49a3..8c6c11ce9760 100644
--- a/drivers/acpi/acpica/nsxfname.c
+++ b/drivers/acpi/acpica/nsxfname.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2013, Intel Corp. 9 * Copyright (C) 2000 - 2014, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsxfobj.c b/drivers/acpi/acpica/nsxfobj.c
index 0e6d79e462d4..dae9401be7a2 100644
--- a/drivers/acpi/acpica/nsxfobj.c
+++ b/drivers/acpi/acpica/nsxfobj.c
@@ -6,7 +6,7 @@
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2013, Intel Corp. 9 * Copyright (C) 2000 - 2014, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/psargs.c b/drivers/acpi/acpica/psargs.c
index 91a5a69db80c..314d314340ae 100644
--- a/drivers/acpi/acpica/psargs.c
+++ b/drivers/acpi/acpica/psargs.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/psloop.c b/drivers/acpi/acpica/psloop.c
index 065b44ae538f..646d1a3f6e27 100644
--- a/drivers/acpi/acpica/psloop.c
+++ b/drivers/acpi/acpica/psloop.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/psobject.c b/drivers/acpi/acpica/psobject.c
index 95dc608a66a8..af1f46cd37a5 100644
--- a/drivers/acpi/acpica/psobject.c
+++ b/drivers/acpi/acpica/psobject.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/psopcode.c b/drivers/acpi/acpica/psopcode.c
index 1b659e59710a..1755d2ac5656 100644
--- a/drivers/acpi/acpica/psopcode.c
+++ b/drivers/acpi/acpica/psopcode.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/psopinfo.c b/drivers/acpi/acpica/psopinfo.c
index b0c9787dbe61..0d8d37ffd04d 100644
--- a/drivers/acpi/acpica/psopinfo.c
+++ b/drivers/acpi/acpica/psopinfo.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/psparse.c b/drivers/acpi/acpica/psparse.c
index 79d9a28dedef..6d27b597394e 100644
--- a/drivers/acpi/acpica/psparse.c
+++ b/drivers/acpi/acpica/psparse.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/psscope.c b/drivers/acpi/acpica/psscope.c
index 6a4b6fb39f32..32d250feea21 100644
--- a/drivers/acpi/acpica/psscope.c
+++ b/drivers/acpi/acpica/psscope.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/pstree.c b/drivers/acpi/acpica/pstree.c
index 877dc0de8df3..0b64181e7720 100644
--- a/drivers/acpi/acpica/pstree.c
+++ b/drivers/acpi/acpica/pstree.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/psutils.c b/drivers/acpi/acpica/psutils.c
index 91fa73a6e55e..3cd48802eede 100644
--- a/drivers/acpi/acpica/psutils.c
+++ b/drivers/acpi/acpica/psutils.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/pswalk.c b/drivers/acpi/acpica/pswalk.c
index abd65624754f..9cb07e1e76d9 100644
--- a/drivers/acpi/acpica/pswalk.c
+++ b/drivers/acpi/acpica/pswalk.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/psxface.c b/drivers/acpi/acpica/psxface.c
index fcb7a840e996..e135acaa5e1c 100644
--- a/drivers/acpi/acpica/psxface.c
+++ b/drivers/acpi/acpica/psxface.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsaddr.c b/drivers/acpi/acpica/rsaddr.c
index f3a9276ac665..916fd095ff34 100644
--- a/drivers/acpi/acpica/rsaddr.c
+++ b/drivers/acpi/acpica/rsaddr.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rscalc.c b/drivers/acpi/acpica/rscalc.c
index b60c9cf82862..689556744b03 100644
--- a/drivers/acpi/acpica/rscalc.c
+++ b/drivers/acpi/acpica/rscalc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -636,7 +636,7 @@ acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object,
636 636
637 for (index = 0; index < number_of_elements; index++) { 637 for (index = 0; index < number_of_elements; index++) {
638 638
639 /* Dereference the sub-package */ 639 /* Dereference the subpackage */
640 640
641 package_element = *top_object_list; 641 package_element = *top_object_list;
642 642
diff --git a/drivers/acpi/acpica/rscreate.c b/drivers/acpi/acpica/rscreate.c
index 3a2ace93e62c..75d369050657 100644
--- a/drivers/acpi/acpica/rscreate.c
+++ b/drivers/acpi/acpica/rscreate.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -273,7 +273,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
273 */ 273 */
274 user_prt->length = (sizeof(struct acpi_pci_routing_table) - 4); 274 user_prt->length = (sizeof(struct acpi_pci_routing_table) - 4);
275 275
276 /* Each sub-package must be of length 4 */ 276 /* Each subpackage must be of length 4 */
277 277
278 if ((*top_object_list)->package.count != 4) { 278 if ((*top_object_list)->package.count != 4) {
279 ACPI_ERROR((AE_INFO, 279 ACPI_ERROR((AE_INFO,
@@ -283,7 +283,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
283 } 283 }
284 284
285 /* 285 /*
286 * Dereference the sub-package. 286 * Dereference the subpackage.
287 * The sub_object_list will now point to an array of the four IRQ 287 * The sub_object_list will now point to an array of the four IRQ
288 * elements: [Address, Pin, Source, source_index] 288 * elements: [Address, Pin, Source, source_index]
289 */ 289 */
@@ -292,7 +292,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
292 /* 1) First subobject: Dereference the PRT.Address */ 292 /* 1) First subobject: Dereference the PRT.Address */
293 293
294 obj_desc = sub_object_list[0]; 294 obj_desc = sub_object_list[0];
295 if (obj_desc->common.type != ACPI_TYPE_INTEGER) { 295 if (!obj_desc || obj_desc->common.type != ACPI_TYPE_INTEGER) {
296 ACPI_ERROR((AE_INFO, 296 ACPI_ERROR((AE_INFO,
297 "(PRT[%u].Address) Need Integer, found %s", 297 "(PRT[%u].Address) Need Integer, found %s",
298 index, 298 index,
@@ -305,7 +305,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
305 /* 2) Second subobject: Dereference the PRT.Pin */ 305 /* 2) Second subobject: Dereference the PRT.Pin */
306 306
307 obj_desc = sub_object_list[1]; 307 obj_desc = sub_object_list[1];
308 if (obj_desc->common.type != ACPI_TYPE_INTEGER) { 308 if (!obj_desc || obj_desc->common.type != ACPI_TYPE_INTEGER) {
309 ACPI_ERROR((AE_INFO, 309 ACPI_ERROR((AE_INFO,
310 "(PRT[%u].Pin) Need Integer, found %s", 310 "(PRT[%u].Pin) Need Integer, found %s",
311 index, 311 index,
@@ -394,7 +394,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
394 /* 4) Fourth subobject: Dereference the PRT.source_index */ 394 /* 4) Fourth subobject: Dereference the PRT.source_index */
395 395
396 obj_desc = sub_object_list[3]; 396 obj_desc = sub_object_list[3];
397 if (obj_desc->common.type != ACPI_TYPE_INTEGER) { 397 if (!obj_desc || obj_desc->common.type != ACPI_TYPE_INTEGER) {
398 ACPI_ERROR((AE_INFO, 398 ACPI_ERROR((AE_INFO,
399 "(PRT[%u].SourceIndex) Need Integer, found %s", 399 "(PRT[%u].SourceIndex) Need Integer, found %s",
400 index, 400 index,
diff --git a/drivers/acpi/acpica/rsdump.c b/drivers/acpi/acpica/rsdump.c
index 8a2d4986b0aa..c3c56b5a9788 100644
--- a/drivers/acpi/acpica/rsdump.c
+++ b/drivers/acpi/acpica/rsdump.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -47,7 +47,8 @@
47 47
48#define _COMPONENT ACPI_RESOURCES 48#define _COMPONENT ACPI_RESOURCES
49ACPI_MODULE_NAME("rsdump") 49ACPI_MODULE_NAME("rsdump")
50#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 50
51#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DISASSEMBLER) || defined(ACPI_DEBUGGER)
51/* Local prototypes */ 52/* Local prototypes */
52static void acpi_rs_out_string(char *title, char *value); 53static void acpi_rs_out_string(char *title, char *value);
53 54
diff --git a/drivers/acpi/acpica/rsdumpinfo.c b/drivers/acpi/acpica/rsdumpinfo.c
index 46192bd53653..2f9332d5c973 100644
--- a/drivers/acpi/acpica/rsdumpinfo.c
+++ b/drivers/acpi/acpica/rsdumpinfo.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -48,7 +48,7 @@
48#define _COMPONENT ACPI_RESOURCES 48#define _COMPONENT ACPI_RESOURCES
49ACPI_MODULE_NAME("rsdumpinfo") 49ACPI_MODULE_NAME("rsdumpinfo")
50 50
51#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 51#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DISASSEMBLER) || defined(ACPI_DEBUGGER)
52#define ACPI_RSD_OFFSET(f) (u8) ACPI_OFFSET (union acpi_resource_data,f) 52#define ACPI_RSD_OFFSET(f) (u8) ACPI_OFFSET (union acpi_resource_data,f)
53#define ACPI_PRT_OFFSET(f) (u8) ACPI_OFFSET (struct acpi_pci_routing_table,f) 53#define ACPI_PRT_OFFSET(f) (u8) ACPI_OFFSET (struct acpi_pci_routing_table,f)
54#define ACPI_RSD_TABLE_SIZE(name) (sizeof(name) / sizeof (struct acpi_rsdump_info)) 54#define ACPI_RSD_TABLE_SIZE(name) (sizeof(name) / sizeof (struct acpi_rsdump_info))
diff --git a/drivers/acpi/acpica/rsinfo.c b/drivers/acpi/acpica/rsinfo.c
index 41fed78e0de6..9d3f8a9a24bd 100644
--- a/drivers/acpi/acpica/rsinfo.c
+++ b/drivers/acpi/acpica/rsinfo.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -132,8 +132,7 @@ struct acpi_rsconvert_info *acpi_gbl_convert_resource_serial_bus_dispatch[] = {
132 acpi_rs_convert_uart_serial_bus, 132 acpi_rs_convert_uart_serial_bus,
133}; 133};
134 134
135#ifdef ACPI_FUTURE_USAGE 135#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DISASSEMBLER) || defined(ACPI_DEBUGGER)
136#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
137 136
138/* Dispatch table for resource dump functions */ 137/* Dispatch table for resource dump functions */
139 138
@@ -168,7 +167,6 @@ struct acpi_rsdump_info *acpi_gbl_dump_serial_bus_dispatch[] = {
168}; 167};
169#endif 168#endif
170 169
171#endif /* ACPI_FUTURE_USAGE */
172/* 170/*
173 * Base sizes for external AML resource descriptors, indexed by internal type. 171 * Base sizes for external AML resource descriptors, indexed by internal type.
174 * Includes size of the descriptor header (1 byte for small descriptors, 172 * Includes size of the descriptor header (1 byte for small descriptors,
diff --git a/drivers/acpi/acpica/rsio.c b/drivers/acpi/acpica/rsio.c
index ca183755a6f9..19d64873290a 100644
--- a/drivers/acpi/acpica/rsio.c
+++ b/drivers/acpi/acpica/rsio.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsirq.c b/drivers/acpi/acpica/rsirq.c
index 364decc1028a..3461f7db26df 100644
--- a/drivers/acpi/acpica/rsirq.c
+++ b/drivers/acpi/acpica/rsirq.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rslist.c b/drivers/acpi/acpica/rslist.c
index 6053aa182093..77291293af64 100644
--- a/drivers/acpi/acpica/rslist.c
+++ b/drivers/acpi/acpica/rslist.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsmemory.c b/drivers/acpi/acpica/rsmemory.c
index ebc773a1b350..eab4483ff5f8 100644
--- a/drivers/acpi/acpica/rsmemory.c
+++ b/drivers/acpi/acpica/rsmemory.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsmisc.c b/drivers/acpi/acpica/rsmisc.c
index c99cec9cefde..41eea4bc089c 100644
--- a/drivers/acpi/acpica/rsmisc.c
+++ b/drivers/acpi/acpica/rsmisc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsserial.c b/drivers/acpi/acpica/rsserial.c
index fe49fc43e10f..9e8407223d95 100644
--- a/drivers/acpi/acpica/rsserial.c
+++ b/drivers/acpi/acpica/rsserial.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsutils.c b/drivers/acpi/acpica/rsutils.c
index 14a7982c9961..897a5ceb0420 100644
--- a/drivers/acpi/acpica/rsutils.c
+++ b/drivers/acpi/acpica/rsutils.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsxface.c b/drivers/acpi/acpica/rsxface.c
index 01e476988aae..877ab9202133 100644
--- a/drivers/acpi/acpica/rsxface.c
+++ b/drivers/acpi/acpica/rsxface.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/tbfadt.c b/drivers/acpi/acpica/tbfadt.c
index 8f89263ac47e..ec14588254d4 100644
--- a/drivers/acpi/acpica/tbfadt.c
+++ b/drivers/acpi/acpica/tbfadt.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/tbfind.c b/drivers/acpi/acpica/tbfind.c
index e4f4f02d49e7..c12003947bd5 100644
--- a/drivers/acpi/acpica/tbfind.c
+++ b/drivers/acpi/acpica/tbfind.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/tbinstal.c b/drivers/acpi/acpica/tbinstal.c
index 634357d51fe9..e3040947e9a0 100644
--- a/drivers/acpi/acpica/tbinstal.c
+++ b/drivers/acpi/acpica/tbinstal.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -292,10 +292,11 @@ struct acpi_table_header *acpi_tb_table_override(struct acpi_table_header
292 new_table = acpi_os_map_memory(new_address, new_table_length); 292 new_table = acpi_os_map_memory(new_address, new_table_length);
293 if (!new_table) { 293 if (!new_table) {
294 ACPI_EXCEPTION((AE_INFO, AE_NO_MEMORY, 294 ACPI_EXCEPTION((AE_INFO, AE_NO_MEMORY,
295 "%4.4s %p Attempted physical table override failed", 295 "%4.4s " ACPI_PRINTF_UINT
296 " Attempted physical table override failed",
296 table_header->signature, 297 table_header->signature,
297 ACPI_CAST_PTR(void, 298 ACPI_FORMAT_TO_UINT(table_desc->
298 table_desc->address))); 299 address)));
299 return (NULL); 300 return (NULL);
300 } 301 }
301 302
@@ -308,11 +309,11 @@ struct acpi_table_header *acpi_tb_table_override(struct acpi_table_header
308 309
309finish_override: 310finish_override:
310 311
311 ACPI_INFO((AE_INFO, 312 ACPI_INFO((AE_INFO, "%4.4s " ACPI_PRINTF_UINT
312 "%4.4s %p %s table override, new table: %p", 313 " %s table override, new table: " ACPI_PRINTF_UINT,
313 table_header->signature, 314 table_header->signature,
314 ACPI_CAST_PTR(void, table_desc->address), 315 ACPI_FORMAT_TO_UINT(table_desc->address),
315 override_type, new_table)); 316 override_type, ACPI_FORMAT_TO_UINT(new_table)));
316 317
317 /* We can now unmap/delete the original table (if fully mapped) */ 318 /* We can now unmap/delete the original table (if fully mapped) */
318 319
diff --git a/drivers/acpi/acpica/tbprint.c b/drivers/acpi/acpica/tbprint.c
index 6866e767ba90..df3bb20ea325 100644
--- a/drivers/acpi/acpica/tbprint.c
+++ b/drivers/acpi/acpica/tbprint.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -128,15 +128,17 @@ acpi_tb_print_table_header(acpi_physical_address address,
128 struct acpi_table_header local_header; 128 struct acpi_table_header local_header;
129 129
130 /* 130 /*
131 * The reason that the Address is cast to a void pointer is so that we 131 * The reason that we use ACPI_PRINTF_UINT and ACPI_FORMAT_TO_UINT is to
132 * can use %p which will work properly on both 32-bit and 64-bit hosts. 132 * support both 32-bit and 64-bit hosts/addresses in a consistent manner.
133 * The %p specifier does not emit uniform output on all hosts. On some,
134 * leading zeros are not supported.
133 */ 135 */
134 if (ACPI_COMPARE_NAME(header->signature, ACPI_SIG_FACS)) { 136 if (ACPI_COMPARE_NAME(header->signature, ACPI_SIG_FACS)) {
135 137
136 /* FACS only has signature and length fields */ 138 /* FACS only has signature and length fields */
137 139
138 ACPI_INFO((AE_INFO, "%4.4s %p %06X", 140 ACPI_INFO((AE_INFO, "%-4.4s " ACPI_PRINTF_UINT " %06X",
139 header->signature, ACPI_CAST_PTR(void, address), 141 header->signature, ACPI_FORMAT_TO_UINT(address),
140 header->length)); 142 header->length));
141 } else if (ACPI_VALIDATE_RSDP_SIG(header->signature)) { 143 } else if (ACPI_VALIDATE_RSDP_SIG(header->signature)) {
142 144
@@ -147,8 +149,9 @@ acpi_tb_print_table_header(acpi_physical_address address,
147 header)->oem_id, ACPI_OEM_ID_SIZE); 149 header)->oem_id, ACPI_OEM_ID_SIZE);
148 acpi_tb_fix_string(local_header.oem_id, ACPI_OEM_ID_SIZE); 150 acpi_tb_fix_string(local_header.oem_id, ACPI_OEM_ID_SIZE);
149 151
150 ACPI_INFO((AE_INFO, "RSDP %p %06X (v%.2d %6.6s)", 152 ACPI_INFO((AE_INFO,
151 ACPI_CAST_PTR(void, address), 153 "RSDP " ACPI_PRINTF_UINT " %06X (v%.2d %-6.6s)",
154 ACPI_FORMAT_TO_UINT(address),
152 (ACPI_CAST_PTR(struct acpi_table_rsdp, header)-> 155 (ACPI_CAST_PTR(struct acpi_table_rsdp, header)->
153 revision > 156 revision >
154 0) ? ACPI_CAST_PTR(struct acpi_table_rsdp, 157 0) ? ACPI_CAST_PTR(struct acpi_table_rsdp,
@@ -162,8 +165,9 @@ acpi_tb_print_table_header(acpi_physical_address address,
162 acpi_tb_cleanup_table_header(&local_header, header); 165 acpi_tb_cleanup_table_header(&local_header, header);
163 166
164 ACPI_INFO((AE_INFO, 167 ACPI_INFO((AE_INFO,
165 "%4.4s %p %06X (v%.2d %6.6s %8.8s %08X %4.4s %08X)", 168 "%-4.4s " ACPI_PRINTF_UINT
166 local_header.signature, ACPI_CAST_PTR(void, address), 169 " %06X (v%.2d %-6.6s %-8.8s %08X %-4.4s %08X)",
170 local_header.signature, ACPI_FORMAT_TO_UINT(address),
167 local_header.length, local_header.revision, 171 local_header.length, local_header.revision,
168 local_header.oem_id, local_header.oem_table_id, 172 local_header.oem_id, local_header.oem_table_id,
169 local_header.oem_revision, 173 local_header.oem_revision,
diff --git a/drivers/acpi/acpica/tbutils.c b/drivers/acpi/acpica/tbutils.c
index 6412d3c301cb..a4702eee91a8 100644
--- a/drivers/acpi/acpica/tbutils.c
+++ b/drivers/acpi/acpica/tbutils.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/tbxface.c b/drivers/acpi/acpica/tbxface.c
index db826eaadd1c..a1593159d9ea 100644
--- a/drivers/acpi/acpica/tbxface.c
+++ b/drivers/acpi/acpica/tbxface.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/tbxfload.c b/drivers/acpi/acpica/tbxfload.c
index 60b5a871833c..0909420fc776 100644
--- a/drivers/acpi/acpica/tbxfload.c
+++ b/drivers/acpi/acpica/tbxfload.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/tbxfroot.c b/drivers/acpi/acpica/tbxfroot.c
index e4e1468877c3..65ab8fed3d5e 100644
--- a/drivers/acpi/acpica/tbxfroot.c
+++ b/drivers/acpi/acpica/tbxfroot.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utaddress.c b/drivers/acpi/acpica/utaddress.c
index 2c2b6ae5dfc4..a1acec9d2ef3 100644
--- a/drivers/acpi/acpica/utaddress.c
+++ b/drivers/acpi/acpica/utaddress.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utalloc.c b/drivers/acpi/acpica/utalloc.c
index 1851762fc5b5..efac83c606dc 100644
--- a/drivers/acpi/acpica/utalloc.c
+++ b/drivers/acpi/acpica/utalloc.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utbuffer.c b/drivers/acpi/acpica/utbuffer.c
index 11fde93be120..3c1699740653 100644
--- a/drivers/acpi/acpica/utbuffer.c
+++ b/drivers/acpi/acpica/utbuffer.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utcache.c b/drivers/acpi/acpica/utcache.c
index cacd2fd9e665..78fde0aac487 100644
--- a/drivers/acpi/acpica/utcache.c
+++ b/drivers/acpi/acpica/utcache.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utcopy.c b/drivers/acpi/acpica/utcopy.c
index edff4e653d9a..270c16464dd9 100644
--- a/drivers/acpi/acpica/utcopy.c
+++ b/drivers/acpi/acpica/utcopy.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -535,10 +535,10 @@ acpi_ut_copy_esimple_to_isimple(union acpi_object *external_object,
535 535
536 case ACPI_TYPE_LOCAL_REFERENCE: 536 case ACPI_TYPE_LOCAL_REFERENCE:
537 537
538 /* TBD: should validate incoming handle */ 538 /* An incoming reference is defined to be a namespace node */
539 539
540 internal_object->reference.class = ACPI_REFCLASS_NAME; 540 internal_object->reference.class = ACPI_REFCLASS_REFOF;
541 internal_object->reference.node = 541 internal_object->reference.object =
542 external_object->reference.handle; 542 external_object->reference.handle;
543 break; 543 break;
544 544
diff --git a/drivers/acpi/acpica/utdebug.c b/drivers/acpi/acpica/utdebug.c
index d971c8631263..21a20ac5b1e1 100644
--- a/drivers/acpi/acpica/utdebug.c
+++ b/drivers/acpi/acpica/utdebug.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utdecode.c b/drivers/acpi/acpica/utdecode.c
index b3f31dd89a45..fbfa9eca011f 100644
--- a/drivers/acpi/acpica/utdecode.c
+++ b/drivers/acpi/acpica/utdecode.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utdelete.c b/drivers/acpi/acpica/utdelete.c
index c07d2227ea42..a3516de213fa 100644
--- a/drivers/acpi/acpica/utdelete.c
+++ b/drivers/acpi/acpica/utdelete.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -75,6 +75,7 @@ static void acpi_ut_delete_internal_obj(union acpi_operand_object *object)
75 union acpi_operand_object *handler_desc; 75 union acpi_operand_object *handler_desc;
76 union acpi_operand_object *second_desc; 76 union acpi_operand_object *second_desc;
77 union acpi_operand_object *next_desc; 77 union acpi_operand_object *next_desc;
78 union acpi_operand_object *start_desc;
78 union acpi_operand_object **last_obj_ptr; 79 union acpi_operand_object **last_obj_ptr;
79 80
80 ACPI_FUNCTION_TRACE_PTR(ut_delete_internal_obj, object); 81 ACPI_FUNCTION_TRACE_PTR(ut_delete_internal_obj, object);
@@ -235,10 +236,11 @@ static void acpi_ut_delete_internal_obj(union acpi_operand_object *object)
235 if (handler_desc) { 236 if (handler_desc) {
236 next_desc = 237 next_desc =
237 handler_desc->address_space.region_list; 238 handler_desc->address_space.region_list;
239 start_desc = next_desc;
238 last_obj_ptr = 240 last_obj_ptr =
239 &handler_desc->address_space.region_list; 241 &handler_desc->address_space.region_list;
240 242
241 /* Remove the region object from the handler's list */ 243 /* Remove the region object from the handler list */
242 244
243 while (next_desc) { 245 while (next_desc) {
244 if (next_desc == object) { 246 if (next_desc == object) {
@@ -247,10 +249,19 @@ static void acpi_ut_delete_internal_obj(union acpi_operand_object *object)
247 break; 249 break;
248 } 250 }
249 251
250 /* Walk the linked list of handler */ 252 /* Walk the linked list of handlers */
251 253
252 last_obj_ptr = &next_desc->region.next; 254 last_obj_ptr = &next_desc->region.next;
253 next_desc = next_desc->region.next; 255 next_desc = next_desc->region.next;
256
257 /* Prevent infinite loop if list is corrupted */
258
259 if (next_desc == start_desc) {
260 ACPI_ERROR((AE_INFO,
261 "Circular region list in address handler object %p",
262 handler_desc));
263 return_VOID;
264 }
254 } 265 }
255 266
256 if (handler_desc->address_space.handler_flags & 267 if (handler_desc->address_space.handler_flags &
diff --git a/drivers/acpi/acpica/uterror.c b/drivers/acpi/acpica/uterror.c
index 154fdcaa5830..8e544d4688cd 100644
--- a/drivers/acpi/acpica/uterror.c
+++ b/drivers/acpi/acpica/uterror.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/uteval.c b/drivers/acpi/acpica/uteval.c
index 16fb90506db7..8fed1482d228 100644
--- a/drivers/acpi/acpica/uteval.c
+++ b/drivers/acpi/acpica/uteval.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utexcep.c b/drivers/acpi/acpica/utexcep.c
index 3cf7b597edb9..0403dcaabaf2 100644
--- a/drivers/acpi/acpica/utexcep.c
+++ b/drivers/acpi/acpica/utexcep.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utglobal.c b/drivers/acpi/acpica/utglobal.c
index 030cb0dc673c..f3abeae9d2f8 100644
--- a/drivers/acpi/acpica/utglobal.c
+++ b/drivers/acpi/acpica/utglobal.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -55,31 +55,27 @@ ACPI_MODULE_NAME("utglobal")
55 * Static global variable initialization. 55 * Static global variable initialization.
56 * 56 *
57 ******************************************************************************/ 57 ******************************************************************************/
58/* 58/* Debug output control masks */
59 * We want the debug switches statically initialized so they
60 * are already set when the debugger is entered.
61 */
62/* Debug switch - level and trace mask */
63u32 acpi_dbg_level = ACPI_DEBUG_DEFAULT; 59u32 acpi_dbg_level = ACPI_DEBUG_DEFAULT;
64 60
65/* Debug switch - layer (component) mask */
66
67u32 acpi_dbg_layer = 0; 61u32 acpi_dbg_layer = 0;
68u32 acpi_gbl_nesting_level = 0;
69 62
70/* Debugger globals */ 63/* acpi_gbl_FADT is a local copy of the FADT, converted to a common format. */
71 64
72u8 acpi_gbl_db_terminate_threads = FALSE; 65struct acpi_table_fadt acpi_gbl_FADT;
73u8 acpi_gbl_abort_method = FALSE; 66u32 acpi_gbl_trace_flags;
74u8 acpi_gbl_method_executing = FALSE; 67acpi_name acpi_gbl_trace_method_name;
68u8 acpi_gbl_system_awake_and_running;
69u32 acpi_current_gpe_count;
75 70
76/* System flags */ 71/*
77 72 * ACPI 5.0 introduces the concept of a "reduced hardware platform", meaning
78u32 acpi_gbl_startup_flags = 0; 73 * that the ACPI hardware is no longer required. A flag in the FADT indicates
79 74 * a reduced HW machine, and that flag is duplicated here for convenience.
80/* System starts uninitialized */ 75 */
76u8 acpi_gbl_reduced_hardware;
81 77
82u8 acpi_gbl_shutdown = TRUE; 78/* Various state name strings */
83 79
84const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COUNT] = { 80const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COUNT] = {
85 "\\_S0_", 81 "\\_S0_",
@@ -335,7 +331,6 @@ acpi_status acpi_ut_init_globals(void)
335 331
336 acpi_gbl_DSDT = NULL; 332 acpi_gbl_DSDT = NULL;
337 acpi_gbl_cm_single_step = FALSE; 333 acpi_gbl_cm_single_step = FALSE;
338 acpi_gbl_db_terminate_threads = FALSE;
339 acpi_gbl_shutdown = FALSE; 334 acpi_gbl_shutdown = FALSE;
340 acpi_gbl_ns_lookup_count = 0; 335 acpi_gbl_ns_lookup_count = 0;
341 acpi_gbl_ps_find_count = 0; 336 acpi_gbl_ps_find_count = 0;
@@ -382,6 +377,10 @@ acpi_status acpi_ut_init_globals(void)
382 acpi_gbl_disable_mem_tracking = FALSE; 377 acpi_gbl_disable_mem_tracking = FALSE;
383#endif 378#endif
384 379
380#ifdef ACPI_DEBUGGER
381 acpi_gbl_db_terminate_threads = FALSE;
382#endif
383
385 return_ACPI_STATUS(AE_OK); 384 return_ACPI_STATUS(AE_OK);
386} 385}
387 386
diff --git a/drivers/acpi/acpica/utids.c b/drivers/acpi/acpica/utids.c
index bfca7b4b6731..4b12880e5b11 100644
--- a/drivers/acpi/acpica/utids.c
+++ b/drivers/acpi/acpica/utids.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utinit.c b/drivers/acpi/acpica/utinit.c
index c5d1ac44c07d..5f56fc49021e 100644
--- a/drivers/acpi/acpica/utinit.c
+++ b/drivers/acpi/acpica/utinit.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utlock.c b/drivers/acpi/acpica/utlock.c
index 5c26ad420344..dc6e96547f18 100644
--- a/drivers/acpi/acpica/utlock.c
+++ b/drivers/acpi/acpica/utlock.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utmath.c b/drivers/acpi/acpica/utmath.c
index 909fe66e1934..d44dee6ee10a 100644
--- a/drivers/acpi/acpica/utmath.c
+++ b/drivers/acpi/acpica/utmath.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utmisc.c b/drivers/acpi/acpica/utmisc.c
index 02f9101b65e4..2e2bb14e1099 100644
--- a/drivers/acpi/acpica/utmisc.c
+++ b/drivers/acpi/acpica/utmisc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utmutex.c b/drivers/acpi/acpica/utmutex.c
index 08c323245584..82717fff9ffc 100644
--- a/drivers/acpi/acpica/utmutex.c
+++ b/drivers/acpi/acpica/utmutex.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utobject.c b/drivers/acpi/acpica/utobject.c
index 517af700399d..dfa9009bfc87 100644
--- a/drivers/acpi/acpica/utobject.c
+++ b/drivers/acpi/acpica/utobject.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utosi.c b/drivers/acpi/acpica/utosi.c
index 8856bd37bc76..685766fc6ca8 100644
--- a/drivers/acpi/acpica/utosi.c
+++ b/drivers/acpi/acpica/utosi.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -47,6 +47,31 @@
47#define _COMPONENT ACPI_UTILITIES 47#define _COMPONENT ACPI_UTILITIES
48ACPI_MODULE_NAME("utosi") 48ACPI_MODULE_NAME("utosi")
49 49
50/******************************************************************************
51 *
52 * ACPICA policy for new _OSI strings:
53 *
54 * It is the stated policy of ACPICA that new _OSI strings will be integrated
55 * into this module as soon as possible after they are defined. It is strongly
56 * recommended that all ACPICA hosts mirror this policy and integrate any
57 * changes to this module as soon as possible. There are several historical
58 * reasons behind this policy:
59 *
60 * 1) New BIOSs tend to test only the case where the host responds TRUE to
61 * the latest version of Windows, which would respond to the latest/newest
62 * _OSI string. Not responding TRUE to the latest version of Windows will
63 * risk executing untested code paths throughout the DSDT and SSDTs.
64 *
65 * 2) If a new _OSI string is recognized only after a significant delay, this
66 * has the potential to cause problems on existing working machines because
67 * of the possibility that a new and different path through the ASL code
68 * will be executed.
69 *
70 * 3) New _OSI strings are tending to come out about once per year. A delay
71 * in recognizing a new string for a significant amount of time risks the
72 * release of another string which only compounds the initial problem.
73 *
74 *****************************************************************************/
50/* 75/*
51 * Strings supported by the _OSI predefined control method (which is 76 * Strings supported by the _OSI predefined control method (which is
52 * implemented internally within this module.) 77 * implemented internally within this module.)
@@ -74,6 +99,7 @@ static struct acpi_interface_info acpi_default_supported_interfaces[] = {
74 {"Windows 2006 SP2", NULL, 0, ACPI_OSI_WIN_VISTA_SP2}, /* Windows Vista SP2 - Added 09/2010 */ 99 {"Windows 2006 SP2", NULL, 0, ACPI_OSI_WIN_VISTA_SP2}, /* Windows Vista SP2 - Added 09/2010 */
75 {"Windows 2009", NULL, 0, ACPI_OSI_WIN_7}, /* Windows 7 and Server 2008 R2 - Added 09/2009 */ 100 {"Windows 2009", NULL, 0, ACPI_OSI_WIN_7}, /* Windows 7 and Server 2008 R2 - Added 09/2009 */
76 {"Windows 2012", NULL, 0, ACPI_OSI_WIN_8}, /* Windows 8 and Server 2012 - Added 08/2012 */ 101 {"Windows 2012", NULL, 0, ACPI_OSI_WIN_8}, /* Windows 8 and Server 2012 - Added 08/2012 */
102 {"Windows 2013", NULL, 0, ACPI_OSI_WIN_8}, /* Windows 8.1 and Server 2012 R2 - Added 01/2014 */
77 103
78 /* Feature Group Strings */ 104 /* Feature Group Strings */
79 105
diff --git a/drivers/acpi/acpica/utownerid.c b/drivers/acpi/acpica/utownerid.c
index eb3aca761369..36bec57ebd23 100644
--- a/drivers/acpi/acpica/utownerid.c
+++ b/drivers/acpi/acpica/utownerid.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utpredef.c b/drivers/acpi/acpica/utpredef.c
index 2b1ce4cd3207..db30caff130a 100644
--- a/drivers/acpi/acpica/utpredef.c
+++ b/drivers/acpi/acpica/utpredef.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utresrc.c b/drivers/acpi/acpica/utresrc.c
index 2c2accb9e534..14cb6c0c8be2 100644
--- a/drivers/acpi/acpica/utresrc.c
+++ b/drivers/acpi/acpica/utresrc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -47,7 +47,8 @@
47 47
48#define _COMPONENT ACPI_UTILITIES 48#define _COMPONENT ACPI_UTILITIES
49ACPI_MODULE_NAME("utresrc") 49ACPI_MODULE_NAME("utresrc")
50#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER) 50
51#if defined(ACPI_DEBUG_OUTPUT) || defined (ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER)
51/* 52/*
52 * Strings used to decode resource descriptors. 53 * Strings used to decode resource descriptors.
53 * Used by both the disassembler and the debugger resource dump routines 54 * Used by both the disassembler and the debugger resource dump routines
diff --git a/drivers/acpi/acpica/utstate.c b/drivers/acpi/acpica/utstate.c
index 03c4c2febd84..1cc97a752c15 100644
--- a/drivers/acpi/acpica/utstate.c
+++ b/drivers/acpi/acpica/utstate.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utstring.c b/drivers/acpi/acpica/utstring.c
index 45c0eb26b33d..77219336c7e0 100644
--- a/drivers/acpi/acpica/utstring.c
+++ b/drivers/acpi/acpica/utstring.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/uttrack.c b/drivers/acpi/acpica/uttrack.c
index c0027773cccb..7d0ee969d781 100644
--- a/drivers/acpi/acpica/uttrack.c
+++ b/drivers/acpi/acpica/uttrack.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -276,7 +276,8 @@ acpi_ut_free_and_track(void *allocation,
276 } 276 }
277 277
278 acpi_os_free(debug_block); 278 acpi_os_free(debug_block);
279 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "%p freed\n", allocation)); 279 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "%p freed (block %p)\n",
280 allocation, debug_block));
280 return_VOID; 281 return_VOID;
281} 282}
282 283
diff --git a/drivers/acpi/acpica/utxface.c b/drivers/acpi/acpica/utxface.c
index be322c83643a..502a8492dc83 100644
--- a/drivers/acpi/acpica/utxface.c
+++ b/drivers/acpi/acpica/utxface.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utxferror.c b/drivers/acpi/acpica/utxferror.c
index f7edb88f6054..edd861102f1b 100644
--- a/drivers/acpi/acpica/utxferror.c
+++ b/drivers/acpi/acpica/utxferror.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utxfinit.c b/drivers/acpi/acpica/utxfinit.c
index 246ef68681f4..13380d818462 100644
--- a/drivers/acpi/acpica/utxfinit.c
+++ b/drivers/acpi/acpica/utxfinit.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utxfmutex.c b/drivers/acpi/acpica/utxfmutex.c
index 312299721ba1..2a0f9e04d3a4 100644
--- a/drivers/acpi/acpica/utxfmutex.c
+++ b/drivers/acpi/acpica/utxfmutex.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/apei/Kconfig b/drivers/acpi/apei/Kconfig
index 3650b2183227..c4dac7150960 100644
--- a/drivers/acpi/apei/Kconfig
+++ b/drivers/acpi/apei/Kconfig
@@ -12,7 +12,7 @@ config ACPI_APEI
12 12
13config ACPI_APEI_GHES 13config ACPI_APEI_GHES
14 bool "APEI Generic Hardware Error Source" 14 bool "APEI Generic Hardware Error Source"
15 depends on ACPI_APEI && X86 15 depends on ACPI_APEI
16 select ACPI_HED 16 select ACPI_HED
17 select IRQ_WORK 17 select IRQ_WORK
18 select GENERIC_ALLOCATOR 18 select GENERIC_ALLOCATOR
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 797a6938d051..9a2c63b20050 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -39,15 +39,13 @@
39#include <linux/acpi.h> 39#include <linux/acpi.h>
40#include <linux/power_supply.h> 40#include <linux/power_supply.h>
41 41
42#include "battery.h"
43
42#define PREFIX "ACPI: " 44#define PREFIX "ACPI: "
43 45
44#define ACPI_BATTERY_VALUE_UNKNOWN 0xFFFFFFFF 46#define ACPI_BATTERY_VALUE_UNKNOWN 0xFFFFFFFF
45 47
46#define ACPI_BATTERY_CLASS "battery"
47#define ACPI_BATTERY_DEVICE_NAME "Battery" 48#define ACPI_BATTERY_DEVICE_NAME "Battery"
48#define ACPI_BATTERY_NOTIFY_STATUS 0x80
49#define ACPI_BATTERY_NOTIFY_INFO 0x81
50#define ACPI_BATTERY_NOTIFY_THRESHOLD 0x82
51 49
52/* Battery power unit: 0 means mW, 1 means mA */ 50/* Battery power unit: 0 means mW, 1 means mA */
53#define ACPI_BATTERY_POWER_UNIT_MA 1 51#define ACPI_BATTERY_POWER_UNIT_MA 1
@@ -736,6 +734,7 @@ static void acpi_battery_notify(struct acpi_device *device, u32 event)
736 acpi_bus_generate_netlink_event(device->pnp.device_class, 734 acpi_bus_generate_netlink_event(device->pnp.device_class,
737 dev_name(&device->dev), event, 735 dev_name(&device->dev), event,
738 acpi_battery_present(battery)); 736 acpi_battery_present(battery));
737 acpi_notifier_call_chain(device, event, acpi_battery_present(battery));
739 /* acpi_battery_update could remove power_supply object */ 738 /* acpi_battery_update could remove power_supply object */
740 if (old && battery->bat.dev) 739 if (old && battery->bat.dev)
741 power_supply_changed(&battery->bat); 740 power_supply_changed(&battery->bat);
diff --git a/drivers/acpi/battery.h b/drivers/acpi/battery.h
new file mode 100644
index 000000000000..6c084976987d
--- /dev/null
+++ b/drivers/acpi/battery.h
@@ -0,0 +1,10 @@
1#ifndef __ACPI_BATTERY_H
2#define __ACPI_BATTERY_H
3
4#define ACPI_BATTERY_CLASS "battery"
5
6#define ACPI_BATTERY_NOTIFY_STATUS 0x80
7#define ACPI_BATTERY_NOTIFY_INFO 0x81
8#define ACPI_BATTERY_NOTIFY_THRESHOLD 0x82
9
10#endif
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index fcb59c21c68d..e7e5844c87d0 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -311,9 +311,7 @@ static void acpi_bus_osc_support(void)
311 capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_PPC_OST_SUPPORT; 311 capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_PPC_OST_SUPPORT;
312#endif 312#endif
313 313
314#ifdef ACPI_HOTPLUG_OST
315 capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_HOTPLUG_OST_SUPPORT; 314 capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_HOTPLUG_OST_SUPPORT;
316#endif
317 315
318 if (!ghes_disable) 316 if (!ghes_disable)
319 capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_APEI_SUPPORT; 317 capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_APEI_SUPPORT;
@@ -340,60 +338,77 @@ static void acpi_bus_osc_support(void)
340 */ 338 */
341static void acpi_bus_notify(acpi_handle handle, u32 type, void *data) 339static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
342{ 340{
343 struct acpi_device *device = NULL; 341 struct acpi_device *adev;
344 struct acpi_driver *driver; 342 struct acpi_driver *driver;
345 343 acpi_status status;
346 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Notification %#02x to handle %p\n", 344 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE;
347 type, handle));
348 345
349 switch (type) { 346 switch (type) {
350
351 case ACPI_NOTIFY_BUS_CHECK: 347 case ACPI_NOTIFY_BUS_CHECK:
352 /* TBD */ 348 acpi_handle_debug(handle, "ACPI_NOTIFY_BUS_CHECK event\n");
353 break; 349 break;
354 350
355 case ACPI_NOTIFY_DEVICE_CHECK: 351 case ACPI_NOTIFY_DEVICE_CHECK:
356 /* TBD */ 352 acpi_handle_debug(handle, "ACPI_NOTIFY_DEVICE_CHECK event\n");
357 break; 353 break;
358 354
359 case ACPI_NOTIFY_DEVICE_WAKE: 355 case ACPI_NOTIFY_DEVICE_WAKE:
360 /* TBD */ 356 acpi_handle_debug(handle, "ACPI_NOTIFY_DEVICE_WAKE event\n");
361 break; 357 break;
362 358
363 case ACPI_NOTIFY_EJECT_REQUEST: 359 case ACPI_NOTIFY_EJECT_REQUEST:
364 /* TBD */ 360 acpi_handle_debug(handle, "ACPI_NOTIFY_EJECT_REQUEST event\n");
365 break; 361 break;
366 362
367 case ACPI_NOTIFY_DEVICE_CHECK_LIGHT: 363 case ACPI_NOTIFY_DEVICE_CHECK_LIGHT:
364 acpi_handle_debug(handle, "ACPI_NOTIFY_DEVICE_CHECK_LIGHT event\n");
368 /* TBD: Exactly what does 'light' mean? */ 365 /* TBD: Exactly what does 'light' mean? */
369 break; 366 break;
370 367
371 case ACPI_NOTIFY_FREQUENCY_MISMATCH: 368 case ACPI_NOTIFY_FREQUENCY_MISMATCH:
372 /* TBD */ 369 acpi_handle_err(handle, "Device cannot be configured due "
370 "to a frequency mismatch\n");
373 break; 371 break;
374 372
375 case ACPI_NOTIFY_BUS_MODE_MISMATCH: 373 case ACPI_NOTIFY_BUS_MODE_MISMATCH:
376 /* TBD */ 374 acpi_handle_err(handle, "Device cannot be configured due "
375 "to a bus mode mismatch\n");
377 break; 376 break;
378 377
379 case ACPI_NOTIFY_POWER_FAULT: 378 case ACPI_NOTIFY_POWER_FAULT:
380 /* TBD */ 379 acpi_handle_err(handle, "Device has suffered a power fault\n");
381 break; 380 break;
382 381
383 default: 382 default:
384 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 383 acpi_handle_warn(handle, "Unsupported event type 0x%x\n", type);
385 "Received unknown/unsupported notification [%08x]\n", 384 ost_code = ACPI_OST_SC_UNRECOGNIZED_NOTIFY;
386 type)); 385 goto err;
387 break;
388 } 386 }
389 387
390 acpi_bus_get_device(handle, &device); 388 adev = acpi_bus_get_acpi_device(handle);
391 if (device) { 389 if (!adev)
392 driver = device->driver; 390 goto err;
393 if (driver && driver->ops.notify && 391
394 (driver->flags & ACPI_DRIVER_ALL_NOTIFY_EVENTS)) 392 driver = adev->driver;
395 driver->ops.notify(device, type); 393 if (driver && driver->ops.notify &&
394 (driver->flags & ACPI_DRIVER_ALL_NOTIFY_EVENTS))
395 driver->ops.notify(adev, type);
396
397 switch (type) {
398 case ACPI_NOTIFY_BUS_CHECK:
399 case ACPI_NOTIFY_DEVICE_CHECK:
400 case ACPI_NOTIFY_EJECT_REQUEST:
401 status = acpi_hotplug_schedule(adev, type);
402 if (ACPI_SUCCESS(status))
403 return;
404 default:
405 break;
396 } 406 }
407 acpi_bus_put_acpi_device(adev);
408 return;
409
410 err:
411 acpi_evaluate_ost(handle, type, ost_code, NULL);
397} 412}
398 413
399/* -------------------------------------------------------------------------- 414/* --------------------------------------------------------------------------
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index 714e957a871a..db35594d4df7 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -302,6 +302,10 @@ static void acpi_button_notify(struct acpi_device *device, u32 event)
302 input_sync(input); 302 input_sync(input);
303 303
304 pm_wakeup_event(&device->dev, 0); 304 pm_wakeup_event(&device->dev, 0);
305 acpi_bus_generate_netlink_event(
306 device->pnp.device_class,
307 dev_name(&device->dev),
308 event, ++button->pushed);
305 } 309 }
306 break; 310 break;
307 default: 311 default:
diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c
index 368f9ddb8480..63119d09b354 100644
--- a/drivers/acpi/container.c
+++ b/drivers/acpi/container.c
@@ -31,8 +31,6 @@
31 31
32#include "internal.h" 32#include "internal.h"
33 33
34#define PREFIX "ACPI: "
35
36#define _COMPONENT ACPI_CONTAINER_COMPONENT 34#define _COMPONENT ACPI_CONTAINER_COMPONENT
37ACPI_MODULE_NAME("container"); 35ACPI_MODULE_NAME("container");
38 36
@@ -68,6 +66,9 @@ static int container_device_attach(struct acpi_device *adev,
68 struct device *dev; 66 struct device *dev;
69 int ret; 67 int ret;
70 68
69 if (adev->flags.is_dock_station)
70 return 0;
71
71 cdev = kzalloc(sizeof(*cdev), GFP_KERNEL); 72 cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
72 if (!cdev) 73 if (!cdev)
73 return -ENOMEM; 74 return -ENOMEM;
diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
index c14a00d3dca6..d047739f3380 100644
--- a/drivers/acpi/device_pm.c
+++ b/drivers/acpi/device_pm.c
@@ -901,15 +901,30 @@ EXPORT_SYMBOL_GPL(acpi_dev_resume_early);
901int acpi_subsys_prepare(struct device *dev) 901int acpi_subsys_prepare(struct device *dev)
902{ 902{
903 /* 903 /*
904 * Follow PCI and resume devices suspended at run time before running 904 * Devices having power.ignore_children set may still be necessary for
905 * their system suspend callbacks. 905 * suspending their children in the next phase of device suspend.
906 */ 906 */
907 pm_runtime_resume(dev); 907 if (dev->power.ignore_children)
908 pm_runtime_resume(dev);
909
908 return pm_generic_prepare(dev); 910 return pm_generic_prepare(dev);
909} 911}
910EXPORT_SYMBOL_GPL(acpi_subsys_prepare); 912EXPORT_SYMBOL_GPL(acpi_subsys_prepare);
911 913
912/** 914/**
915 * acpi_subsys_suspend - Run the device driver's suspend callback.
916 * @dev: Device to handle.
917 *
918 * Follow PCI and resume devices suspended at run time before running their
919 * system suspend callbacks.
920 */
921int acpi_subsys_suspend(struct device *dev)
922{
923 pm_runtime_resume(dev);
924 return pm_generic_suspend(dev);
925}
926
927/**
913 * acpi_subsys_suspend_late - Suspend device using ACPI. 928 * acpi_subsys_suspend_late - Suspend device using ACPI.
914 * @dev: Device to suspend. 929 * @dev: Device to suspend.
915 * 930 *
@@ -937,6 +952,23 @@ int acpi_subsys_resume_early(struct device *dev)
937 return ret ? ret : pm_generic_resume_early(dev); 952 return ret ? ret : pm_generic_resume_early(dev);
938} 953}
939EXPORT_SYMBOL_GPL(acpi_subsys_resume_early); 954EXPORT_SYMBOL_GPL(acpi_subsys_resume_early);
955
956/**
957 * acpi_subsys_freeze - Run the device driver's freeze callback.
958 * @dev: Device to handle.
959 */
960int acpi_subsys_freeze(struct device *dev)
961{
962 /*
963 * This used to be done in acpi_subsys_prepare() for all devices and
964 * some drivers may depend on it, so do it here. Ideally, however,
965 * runtime-suspended devices should not be touched during freeze/thaw
966 * transitions.
967 */
968 pm_runtime_resume(dev);
969 return pm_generic_freeze(dev);
970}
971
940#endif /* CONFIG_PM_SLEEP */ 972#endif /* CONFIG_PM_SLEEP */
941 973
942static struct dev_pm_domain acpi_general_pm_domain = { 974static struct dev_pm_domain acpi_general_pm_domain = {
@@ -947,8 +979,11 @@ static struct dev_pm_domain acpi_general_pm_domain = {
947#endif 979#endif
948#ifdef CONFIG_PM_SLEEP 980#ifdef CONFIG_PM_SLEEP
949 .prepare = acpi_subsys_prepare, 981 .prepare = acpi_subsys_prepare,
982 .suspend = acpi_subsys_suspend,
950 .suspend_late = acpi_subsys_suspend_late, 983 .suspend_late = acpi_subsys_suspend_late,
951 .resume_early = acpi_subsys_resume_early, 984 .resume_early = acpi_subsys_resume_early,
985 .freeze = acpi_subsys_freeze,
986 .poweroff = acpi_subsys_suspend,
952 .poweroff_late = acpi_subsys_suspend_late, 987 .poweroff_late = acpi_subsys_suspend_late,
953 .restore_early = acpi_subsys_resume_early, 988 .restore_early = acpi_subsys_resume_early,
954#endif 989#endif
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index 5bfd769fc91f..f0fc6260266b 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -1,7 +1,9 @@
1/* 1/*
2 * dock.c - ACPI dock station driver 2 * dock.c - ACPI dock station driver
3 * 3 *
4 * Copyright (C) 2006 Kristen Carlson Accardi <kristen.c.accardi@intel.com> 4 * Copyright (C) 2006, 2014, Intel Corp.
5 * Author: Kristen Carlson Accardi <kristen.c.accardi@intel.com>
6 * Rafael J. Wysocki <rafael.j.wysocki@intel.com>
5 * 7 *
6 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 8 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 * 9 *
@@ -35,8 +37,6 @@
35 37
36#include "internal.h" 38#include "internal.h"
37 39
38#define PREFIX "ACPI: "
39
40#define ACPI_DOCK_DRIVER_DESCRIPTION "ACPI Dock Station Driver" 40#define ACPI_DOCK_DRIVER_DESCRIPTION "ACPI Dock Station Driver"
41 41
42ACPI_MODULE_NAME("dock"); 42ACPI_MODULE_NAME("dock");
@@ -68,15 +68,10 @@ struct dock_station {
68}; 68};
69static LIST_HEAD(dock_stations); 69static LIST_HEAD(dock_stations);
70static int dock_station_count; 70static int dock_station_count;
71static DEFINE_MUTEX(hotplug_lock);
72 71
73struct dock_dependent_device { 72struct dock_dependent_device {
74 struct list_head list; 73 struct list_head list;
75 acpi_handle handle; 74 struct acpi_device *adev;
76 const struct acpi_dock_ops *hp_ops;
77 void *hp_context;
78 unsigned int hp_refcount;
79 void (*hp_release)(void *);
80}; 75};
81 76
82#define DOCK_DOCKING 0x00000001 77#define DOCK_DOCKING 0x00000001
@@ -98,13 +93,13 @@ enum dock_callback_type {
98 *****************************************************************************/ 93 *****************************************************************************/
99/** 94/**
100 * add_dock_dependent_device - associate a device with the dock station 95 * add_dock_dependent_device - associate a device with the dock station
101 * @ds: The dock station 96 * @ds: Dock station.
102 * @handle: handle of the dependent device 97 * @adev: Dependent ACPI device object.
103 * 98 *
104 * Add the dependent device to the dock's dependent device list. 99 * Add the dependent device to the dock's dependent device list.
105 */ 100 */
106static int __init 101static int add_dock_dependent_device(struct dock_station *ds,
107add_dock_dependent_device(struct dock_station *ds, acpi_handle handle) 102 struct acpi_device *adev)
108{ 103{
109 struct dock_dependent_device *dd; 104 struct dock_dependent_device *dd;
110 105
@@ -112,180 +107,120 @@ add_dock_dependent_device(struct dock_station *ds, acpi_handle handle)
112 if (!dd) 107 if (!dd)
113 return -ENOMEM; 108 return -ENOMEM;
114 109
115 dd->handle = handle; 110 dd->adev = adev;
116 INIT_LIST_HEAD(&dd->list); 111 INIT_LIST_HEAD(&dd->list);
117 list_add_tail(&dd->list, &ds->dependent_devices); 112 list_add_tail(&dd->list, &ds->dependent_devices);
118 113
119 return 0; 114 return 0;
120} 115}
121 116
122static void remove_dock_dependent_devices(struct dock_station *ds) 117static void dock_hotplug_event(struct dock_dependent_device *dd, u32 event,
118 enum dock_callback_type cb_type)
123{ 119{
124 struct dock_dependent_device *dd, *aux; 120 struct acpi_device *adev = dd->adev;
125 121
126 list_for_each_entry_safe(dd, aux, &ds->dependent_devices, list) { 122 acpi_lock_hp_context();
127 list_del(&dd->list);
128 kfree(dd);
129 }
130}
131 123
132/** 124 if (!adev->hp)
133 * dock_init_hotplug - Initialize a hotplug device on a docking station. 125 goto out;
134 * @dd: Dock-dependent device.
135 * @ops: Dock operations to attach to the dependent device.
136 * @context: Data to pass to the @ops callbacks and @release.
137 * @init: Optional initialization routine to run after setting up context.
138 * @release: Optional release routine to run on removal.
139 */
140static int dock_init_hotplug(struct dock_dependent_device *dd,
141 const struct acpi_dock_ops *ops, void *context,
142 void (*init)(void *), void (*release)(void *))
143{
144 int ret = 0;
145 126
146 mutex_lock(&hotplug_lock); 127 if (cb_type == DOCK_CALL_FIXUP) {
147 if (WARN_ON(dd->hp_context)) { 128 void (*fixup)(struct acpi_device *);
148 ret = -EEXIST;
149 } else {
150 dd->hp_refcount = 1;
151 dd->hp_ops = ops;
152 dd->hp_context = context;
153 dd->hp_release = release;
154 if (init)
155 init(context);
156 }
157 mutex_unlock(&hotplug_lock);
158 return ret;
159}
160 129
161/** 130 fixup = adev->hp->fixup;
162 * dock_release_hotplug - Decrement hotplug reference counter of dock device. 131 if (fixup) {
163 * @dd: Dock-dependent device. 132 acpi_unlock_hp_context();
164 * 133 fixup(adev);
165 * Decrement the reference counter of @dd and if 0, detach its hotplug 134 return;
166 * operations from it, reset its context pointer and run the optional release 135 }
167 * routine if present. 136 } else if (cb_type == DOCK_CALL_UEVENT) {
168 */ 137 void (*uevent)(struct acpi_device *, u32);
169static void dock_release_hotplug(struct dock_dependent_device *dd) 138
170{ 139 uevent = adev->hp->uevent;
171 mutex_lock(&hotplug_lock); 140 if (uevent) {
172 if (dd->hp_context && !--dd->hp_refcount) { 141 acpi_unlock_hp_context();
173 void (*release)(void *) = dd->hp_release; 142 uevent(adev, event);
174 void *context = dd->hp_context; 143 return;
175 144 }
176 dd->hp_ops = NULL; 145 } else {
177 dd->hp_context = NULL; 146 int (*notify)(struct acpi_device *, u32);
178 dd->hp_release = NULL;
179 if (release)
180 release(context);
181 }
182 mutex_unlock(&hotplug_lock);
183}
184 147
185static void dock_hotplug_event(struct dock_dependent_device *dd, u32 event, 148 notify = adev->hp->notify;
186 enum dock_callback_type cb_type) 149 if (notify) {
187{ 150 acpi_unlock_hp_context();
188 acpi_notify_handler cb = NULL; 151 notify(adev, event);
189 bool run = false; 152 return;
190
191 mutex_lock(&hotplug_lock);
192
193 if (dd->hp_context) {
194 run = true;
195 dd->hp_refcount++;
196 if (dd->hp_ops) {
197 switch (cb_type) {
198 case DOCK_CALL_FIXUP:
199 cb = dd->hp_ops->fixup;
200 break;
201 case DOCK_CALL_UEVENT:
202 cb = dd->hp_ops->uevent;
203 break;
204 default:
205 cb = dd->hp_ops->handler;
206 }
207 } 153 }
208 } 154 }
209 155
210 mutex_unlock(&hotplug_lock); 156 out:
157 acpi_unlock_hp_context();
158}
211 159
212 if (!run) 160static struct dock_station *find_dock_station(acpi_handle handle)
213 return; 161{
162 struct dock_station *ds;
214 163
215 if (cb) 164 list_for_each_entry(ds, &dock_stations, sibling)
216 cb(dd->handle, event, dd->hp_context); 165 if (ds->handle == handle)
166 return ds;
217 167
218 dock_release_hotplug(dd); 168 return NULL;
219} 169}
220 170
221/** 171/**
222 * find_dock_dependent_device - get a device dependent on this dock 172 * find_dock_dependent_device - get a device dependent on this dock
223 * @ds: the dock station 173 * @ds: the dock station
224 * @handle: the acpi_handle of the device we want 174 * @adev: ACPI device object to find.
225 * 175 *
226 * iterate over the dependent device list for this dock. If the 176 * iterate over the dependent device list for this dock. If the
227 * dependent device matches the handle, return. 177 * dependent device matches the handle, return.
228 */ 178 */
229static struct dock_dependent_device * 179static struct dock_dependent_device *
230find_dock_dependent_device(struct dock_station *ds, acpi_handle handle) 180find_dock_dependent_device(struct dock_station *ds, struct acpi_device *adev)
231{ 181{
232 struct dock_dependent_device *dd; 182 struct dock_dependent_device *dd;
233 183
234 list_for_each_entry(dd, &ds->dependent_devices, list) 184 list_for_each_entry(dd, &ds->dependent_devices, list)
235 if (handle == dd->handle) 185 if (adev == dd->adev)
236 return dd; 186 return dd;
237 187
238 return NULL; 188 return NULL;
239} 189}
240 190
241/***************************************************************************** 191void register_dock_dependent_device(struct acpi_device *adev,
242 * Dock functions * 192 acpi_handle dshandle)
243 *****************************************************************************/
244static int __init is_battery(acpi_handle handle)
245{ 193{
246 struct acpi_device_info *info; 194 struct dock_station *ds = find_dock_station(dshandle);
247 int ret = 1;
248 195
249 if (!ACPI_SUCCESS(acpi_get_object_info(handle, &info))) 196 if (ds && !find_dock_dependent_device(ds, adev))
250 return 0; 197 add_dock_dependent_device(ds, adev);
251 if (!(info->valid & ACPI_VALID_HID))
252 ret = 0;
253 else
254 ret = !strcmp("PNP0C0A", info->hardware_id.string);
255
256 kfree(info);
257 return ret;
258} 198}
259 199
260/* Check whether ACPI object is an ejectable battery or disk bay */ 200/*****************************************************************************
261static bool __init is_ejectable_bay(acpi_handle handle) 201 * Dock functions *
262{ 202 *****************************************************************************/
263 if (acpi_has_method(handle, "_EJ0") && is_battery(handle))
264 return true;
265
266 return acpi_bay_match(handle);
267}
268 203
269/** 204/**
270 * is_dock_device - see if a device is on a dock station 205 * is_dock_device - see if a device is on a dock station
271 * @handle: acpi handle of the device 206 * @adev: ACPI device object to check.
272 * 207 *
273 * If this device is either the dock station itself, 208 * If this device is either the dock station itself,
274 * or is a device dependent on the dock station, then it 209 * or is a device dependent on the dock station, then it
275 * is a dock device 210 * is a dock device
276 */ 211 */
277int is_dock_device(acpi_handle handle) 212int is_dock_device(struct acpi_device *adev)
278{ 213{
279 struct dock_station *dock_station; 214 struct dock_station *dock_station;
280 215
281 if (!dock_station_count) 216 if (!dock_station_count)
282 return 0; 217 return 0;
283 218
284 if (acpi_dock_match(handle)) 219 if (acpi_dock_match(adev->handle))
285 return 1; 220 return 1;
286 221
287 list_for_each_entry(dock_station, &dock_stations, sibling) 222 list_for_each_entry(dock_station, &dock_stations, sibling)
288 if (find_dock_dependent_device(dock_station, handle)) 223 if (find_dock_dependent_device(dock_station, adev))
289 return 1; 224 return 1;
290 225
291 return 0; 226 return 0;
@@ -313,43 +248,6 @@ static int dock_present(struct dock_station *ds)
313} 248}
314 249
315/** 250/**
316 * dock_create_acpi_device - add new devices to acpi
317 * @handle - handle of the device to add
318 *
319 * This function will create a new acpi_device for the given
320 * handle if one does not exist already. This should cause
321 * acpi to scan for drivers for the given devices, and call
322 * matching driver's add routine.
323 */
324static void dock_create_acpi_device(acpi_handle handle)
325{
326 struct acpi_device *device = NULL;
327 int ret;
328
329 acpi_bus_get_device(handle, &device);
330 if (!acpi_device_enumerated(device)) {
331 ret = acpi_bus_scan(handle);
332 if (ret)
333 pr_debug("error adding bus, %x\n", -ret);
334 }
335}
336
337/**
338 * dock_remove_acpi_device - remove the acpi_device struct from acpi
339 * @handle - the handle of the device to remove
340 *
341 * Tell acpi to remove the acpi_device. This should cause any loaded
342 * driver to have it's remove routine called.
343 */
344static void dock_remove_acpi_device(acpi_handle handle)
345{
346 struct acpi_device *device;
347
348 if (!acpi_bus_get_device(handle, &device))
349 acpi_bus_trim(device);
350}
351
352/**
353 * hot_remove_dock_devices - Remove dock station devices. 251 * hot_remove_dock_devices - Remove dock station devices.
354 * @ds: Dock station. 252 * @ds: Dock station.
355 */ 253 */
@@ -366,7 +264,7 @@ static void hot_remove_dock_devices(struct dock_station *ds)
366 dock_hotplug_event(dd, ACPI_NOTIFY_EJECT_REQUEST, false); 264 dock_hotplug_event(dd, ACPI_NOTIFY_EJECT_REQUEST, false);
367 265
368 list_for_each_entry_reverse(dd, &ds->dependent_devices, list) 266 list_for_each_entry_reverse(dd, &ds->dependent_devices, list)
369 dock_remove_acpi_device(dd->handle); 267 acpi_bus_trim(dd->adev);
370} 268}
371 269
372/** 270/**
@@ -392,12 +290,20 @@ static void hotplug_dock_devices(struct dock_station *ds, u32 event)
392 dock_hotplug_event(dd, event, DOCK_CALL_HANDLER); 290 dock_hotplug_event(dd, event, DOCK_CALL_HANDLER);
393 291
394 /* 292 /*
395 * Now make sure that an acpi_device is created for each dependent 293 * Check if all devices have been enumerated already. If not, run
396 * device. That will cause scan handlers to be attached to device 294 * acpi_bus_scan() for them and that will cause scan handlers to be
397 * objects or acpi_drivers to be stopped/started if they are present. 295 * attached to device objects or acpi_drivers to be stopped/started if
296 * they are present.
398 */ 297 */
399 list_for_each_entry(dd, &ds->dependent_devices, list) 298 list_for_each_entry(dd, &ds->dependent_devices, list) {
400 dock_create_acpi_device(dd->handle); 299 struct acpi_device *adev = dd->adev;
300
301 if (!acpi_device_enumerated(adev)) {
302 int ret = acpi_bus_scan(adev->handle);
303 if (ret)
304 dev_dbg(&adev->dev, "scan error %d\n", -ret);
305 }
306 }
401} 307}
402 308
403static void dock_event(struct dock_station *ds, u32 event, int num) 309static void dock_event(struct dock_station *ds, u32 event, int num)
@@ -501,71 +407,6 @@ static int dock_in_progress(struct dock_station *ds)
501} 407}
502 408
503/** 409/**
504 * register_hotplug_dock_device - register a hotplug function
505 * @handle: the handle of the device
506 * @ops: handlers to call after docking
507 * @context: device specific data
508 * @init: Optional initialization routine to run after registration
509 * @release: Optional release routine to run on unregistration
510 *
511 * If a driver would like to perform a hotplug operation after a dock
512 * event, they can register an acpi_notifiy_handler to be called by
513 * the dock driver after _DCK is executed.
514 */
515int register_hotplug_dock_device(acpi_handle handle,
516 const struct acpi_dock_ops *ops, void *context,
517 void (*init)(void *), void (*release)(void *))
518{
519 struct dock_dependent_device *dd;
520 struct dock_station *dock_station;
521 int ret = -EINVAL;
522
523 if (WARN_ON(!context))
524 return -EINVAL;
525
526 if (!dock_station_count)
527 return -ENODEV;
528
529 /*
530 * make sure this handle is for a device dependent on the dock,
531 * this would include the dock station itself
532 */
533 list_for_each_entry(dock_station, &dock_stations, sibling) {
534 /*
535 * An ATA bay can be in a dock and itself can be ejected
536 * separately, so there are two 'dock stations' which need the
537 * ops
538 */
539 dd = find_dock_dependent_device(dock_station, handle);
540 if (dd && !dock_init_hotplug(dd, ops, context, init, release))
541 ret = 0;
542 }
543
544 return ret;
545}
546EXPORT_SYMBOL_GPL(register_hotplug_dock_device);
547
548/**
549 * unregister_hotplug_dock_device - remove yourself from the hotplug list
550 * @handle: the acpi handle of the device
551 */
552void unregister_hotplug_dock_device(acpi_handle handle)
553{
554 struct dock_dependent_device *dd;
555 struct dock_station *dock_station;
556
557 if (!dock_station_count)
558 return;
559
560 list_for_each_entry(dock_station, &dock_stations, sibling) {
561 dd = find_dock_dependent_device(dock_station, handle);
562 if (dd)
563 dock_release_hotplug(dd);
564 }
565}
566EXPORT_SYMBOL_GPL(unregister_hotplug_dock_device);
567
568/**
569 * handle_eject_request - handle an undock request checking for error conditions 410 * handle_eject_request - handle an undock request checking for error conditions
570 * 411 *
571 * Check to make sure the dock device is still present, then undock and 412 * Check to make sure the dock device is still present, then undock and
@@ -598,20 +439,23 @@ static int handle_eject_request(struct dock_station *ds, u32 event)
598} 439}
599 440
600/** 441/**
601 * dock_notify - act upon an acpi dock notification 442 * dock_notify - Handle ACPI dock notification.
602 * @ds: dock station 443 * @adev: Dock station's ACPI device object.
603 * @event: the acpi event 444 * @event: Event code.
604 * 445 *
605 * If we are notified to dock, then check to see if the dock is 446 * If we are notified to dock, then check to see if the dock is
606 * present and then dock. Notify all drivers of the dock event, 447 * present and then dock. Notify all drivers of the dock event,
607 * and then hotplug and devices that may need hotplugging. 448 * and then hotplug and devices that may need hotplugging.
608 */ 449 */
609static void dock_notify(struct dock_station *ds, u32 event) 450int dock_notify(struct acpi_device *adev, u32 event)
610{ 451{
611 acpi_handle handle = ds->handle; 452 acpi_handle handle = adev->handle;
612 struct acpi_device *adev = NULL; 453 struct dock_station *ds = find_dock_station(handle);
613 int surprise_removal = 0; 454 int surprise_removal = 0;
614 455
456 if (!ds)
457 return -ENODEV;
458
615 /* 459 /*
616 * According to acpi spec 3.0a, if a DEVICE_CHECK notification 460 * According to acpi spec 3.0a, if a DEVICE_CHECK notification
617 * is sent and _DCK is present, it is assumed to mean an undock 461 * is sent and _DCK is present, it is assumed to mean an undock
@@ -632,7 +476,6 @@ static void dock_notify(struct dock_station *ds, u32 event)
632 switch (event) { 476 switch (event) {
633 case ACPI_NOTIFY_BUS_CHECK: 477 case ACPI_NOTIFY_BUS_CHECK:
634 case ACPI_NOTIFY_DEVICE_CHECK: 478 case ACPI_NOTIFY_DEVICE_CHECK:
635 acpi_bus_get_device(handle, &adev);
636 if (!dock_in_progress(ds) && !acpi_device_enumerated(adev)) { 479 if (!dock_in_progress(ds) && !acpi_device_enumerated(adev)) {
637 begin_dock(ds); 480 begin_dock(ds);
638 dock(ds); 481 dock(ds);
@@ -662,49 +505,8 @@ static void dock_notify(struct dock_station *ds, u32 event)
662 else 505 else
663 dock_event(ds, event, UNDOCK_EVENT); 506 dock_event(ds, event, UNDOCK_EVENT);
664 break; 507 break;
665 default:
666 acpi_handle_err(handle, "Unknown dock event %d\n", event);
667 } 508 }
668} 509 return 0;
669
670static void acpi_dock_deferred_cb(void *data, u32 event)
671{
672 acpi_scan_lock_acquire();
673 dock_notify(data, event);
674 acpi_scan_lock_release();
675}
676
677static void dock_notify_handler(acpi_handle handle, u32 event, void *data)
678{
679 if (event != ACPI_NOTIFY_BUS_CHECK && event != ACPI_NOTIFY_DEVICE_CHECK
680 && event != ACPI_NOTIFY_EJECT_REQUEST)
681 return;
682
683 acpi_hotplug_execute(acpi_dock_deferred_cb, data, event);
684}
685
686/**
687 * find_dock_devices - find devices on the dock station
688 * @handle: the handle of the device we are examining
689 * @lvl: unused
690 * @context: the dock station private data
691 * @rv: unused
692 *
693 * This function is called by acpi_walk_namespace. It will
694 * check to see if an object has an _EJD method. If it does, then it
695 * will see if it is dependent on the dock station.
696 */
697static acpi_status __init find_dock_devices(acpi_handle handle, u32 lvl,
698 void *context, void **rv)
699{
700 struct dock_station *ds = context;
701 acpi_handle ejd = NULL;
702
703 acpi_bus_get_ejd(handle, &ejd);
704 if (ejd == ds->handle)
705 add_dock_dependent_device(ds, handle);
706
707 return AE_OK;
708} 510}
709 511
710/* 512/*
@@ -803,23 +605,28 @@ static struct attribute_group dock_attribute_group = {
803}; 605};
804 606
805/** 607/**
806 * dock_add - add a new dock station 608 * acpi_dock_add - Add a new dock station
807 * @handle: the dock station handle 609 * @adev: Dock station ACPI device object.
808 * 610 *
809 * allocated and initialize a new dock station device. Find all devices 611 * allocated and initialize a new dock station device.
810 * that are on the dock station, and register for dock event notifications.
811 */ 612 */
812static int __init dock_add(acpi_handle handle) 613void acpi_dock_add(struct acpi_device *adev)
813{ 614{
814 struct dock_station *dock_station, ds = { NULL, }; 615 struct dock_station *dock_station, ds = { NULL, };
616 struct platform_device_info pdevinfo;
617 acpi_handle handle = adev->handle;
815 struct platform_device *dd; 618 struct platform_device *dd;
816 acpi_status status;
817 int ret; 619 int ret;
818 620
819 dd = platform_device_register_data(NULL, "dock", dock_station_count, 621 memset(&pdevinfo, 0, sizeof(pdevinfo));
820 &ds, sizeof(ds)); 622 pdevinfo.name = "dock";
623 pdevinfo.id = dock_station_count;
624 pdevinfo.acpi_node.companion = adev;
625 pdevinfo.data = &ds;
626 pdevinfo.size_data = sizeof(ds);
627 dd = platform_device_register_full(&pdevinfo);
821 if (IS_ERR(dd)) 628 if (IS_ERR(dd))
822 return PTR_ERR(dd); 629 return;
823 630
824 dock_station = dd->dev.platform_data; 631 dock_station = dd->dev.platform_data;
825 632
@@ -837,72 +644,29 @@ static int __init dock_add(acpi_handle handle)
837 dock_station->flags |= DOCK_IS_DOCK; 644 dock_station->flags |= DOCK_IS_DOCK;
838 if (acpi_ata_match(handle)) 645 if (acpi_ata_match(handle))
839 dock_station->flags |= DOCK_IS_ATA; 646 dock_station->flags |= DOCK_IS_ATA;
840 if (is_battery(handle)) 647 if (acpi_device_is_battery(adev))
841 dock_station->flags |= DOCK_IS_BAT; 648 dock_station->flags |= DOCK_IS_BAT;
842 649
843 ret = sysfs_create_group(&dd->dev.kobj, &dock_attribute_group); 650 ret = sysfs_create_group(&dd->dev.kobj, &dock_attribute_group);
844 if (ret) 651 if (ret)
845 goto err_unregister; 652 goto err_unregister;
846 653
847 /* Find dependent devices */
848 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
849 ACPI_UINT32_MAX, find_dock_devices, NULL,
850 dock_station, NULL);
851
852 /* add the dock station as a device dependent on itself */ 654 /* add the dock station as a device dependent on itself */
853 ret = add_dock_dependent_device(dock_station, handle); 655 ret = add_dock_dependent_device(dock_station, adev);
854 if (ret) 656 if (ret)
855 goto err_rmgroup; 657 goto err_rmgroup;
856 658
857 status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
858 dock_notify_handler, dock_station);
859 if (ACPI_FAILURE(status)) {
860 ret = -ENODEV;
861 goto err_rmgroup;
862 }
863
864 dock_station_count++; 659 dock_station_count++;
865 list_add(&dock_station->sibling, &dock_stations); 660 list_add(&dock_station->sibling, &dock_stations);
866 return 0; 661 adev->flags.is_dock_station = true;
662 dev_info(&adev->dev, "ACPI dock station (docks/bays count: %d)\n",
663 dock_station_count);
664 return;
867 665
868err_rmgroup: 666err_rmgroup:
869 remove_dock_dependent_devices(dock_station);
870 sysfs_remove_group(&dd->dev.kobj, &dock_attribute_group); 667 sysfs_remove_group(&dd->dev.kobj, &dock_attribute_group);
668
871err_unregister: 669err_unregister:
872 platform_device_unregister(dd); 670 platform_device_unregister(dd);
873 acpi_handle_err(handle, "%s encountered error %d\n", __func__, ret); 671 acpi_handle_err(handle, "%s encountered error %d\n", __func__, ret);
874 return ret;
875}
876
877/**
878 * find_dock_and_bay - look for dock stations and bays
879 * @handle: acpi handle of a device
880 * @lvl: unused
881 * @context: unused
882 * @rv: unused
883 *
884 * This is called by acpi_walk_namespace to look for dock stations and bays.
885 */
886static acpi_status __init
887find_dock_and_bay(acpi_handle handle, u32 lvl, void *context, void **rv)
888{
889 if (acpi_dock_match(handle) || is_ejectable_bay(handle))
890 dock_add(handle);
891
892 return AE_OK;
893}
894
895void __init acpi_dock_init(void)
896{
897 /* look for dock stations and bays */
898 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
899 ACPI_UINT32_MAX, find_dock_and_bay, NULL, NULL, NULL);
900
901 if (!dock_station_count) {
902 pr_info(PREFIX "No dock devices found.\n");
903 return;
904 }
905
906 pr_info(PREFIX "%s: %d docks/bays found\n",
907 ACPI_DOCK_DRIVER_DESCRIPTION, dock_station_count);
908} 672}
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index 09e423f3d8ad..8acf53e62966 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -55,11 +55,16 @@ MODULE_DEVICE_TABLE(acpi, fan_device_ids);
55#ifdef CONFIG_PM_SLEEP 55#ifdef CONFIG_PM_SLEEP
56static int acpi_fan_suspend(struct device *dev); 56static int acpi_fan_suspend(struct device *dev);
57static int acpi_fan_resume(struct device *dev); 57static int acpi_fan_resume(struct device *dev);
58static struct dev_pm_ops acpi_fan_pm = {
59 .resume = acpi_fan_resume,
60 .freeze = acpi_fan_suspend,
61 .thaw = acpi_fan_resume,
62 .restore = acpi_fan_resume,
63};
64#define FAN_PM_OPS_PTR (&acpi_fan_pm)
58#else 65#else
59#define acpi_fan_suspend NULL 66#define FAN_PM_OPS_PTR NULL
60#define acpi_fan_resume NULL
61#endif 67#endif
62static SIMPLE_DEV_PM_OPS(acpi_fan_pm, acpi_fan_suspend, acpi_fan_resume);
63 68
64static struct acpi_driver acpi_fan_driver = { 69static struct acpi_driver acpi_fan_driver = {
65 .name = "fan", 70 .name = "fan",
@@ -69,7 +74,7 @@ static struct acpi_driver acpi_fan_driver = {
69 .add = acpi_fan_add, 74 .add = acpi_fan_add,
70 .remove = acpi_fan_remove, 75 .remove = acpi_fan_remove,
71 }, 76 },
72 .drv.pm = &acpi_fan_pm, 77 .drv.pm = FAN_PM_OPS_PTR,
73}; 78};
74 79
75/* thermal cooling device callbacks */ 80/* thermal cooling device callbacks */
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index 0c789224d40d..f774c65ecb8b 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -287,6 +287,7 @@ EXPORT_SYMBOL_GPL(acpi_unbind_one);
287static int acpi_platform_notify(struct device *dev) 287static int acpi_platform_notify(struct device *dev)
288{ 288{
289 struct acpi_bus_type *type = acpi_get_bus_type(dev); 289 struct acpi_bus_type *type = acpi_get_bus_type(dev);
290 struct acpi_device *adev;
290 int ret; 291 int ret;
291 292
292 ret = acpi_bind_one(dev, NULL); 293 ret = acpi_bind_one(dev, NULL);
@@ -303,9 +304,14 @@ static int acpi_platform_notify(struct device *dev)
303 if (ret) 304 if (ret)
304 goto out; 305 goto out;
305 } 306 }
307 adev = ACPI_COMPANION(dev);
308 if (!adev)
309 goto out;
306 310
307 if (type && type->setup) 311 if (type && type->setup)
308 type->setup(dev); 312 type->setup(dev);
313 else if (adev->handler && adev->handler->bind)
314 adev->handler->bind(dev);
309 315
310 out: 316 out:
311#if ACPI_GLUE_DEBUG 317#if ACPI_GLUE_DEBUG
@@ -324,11 +330,17 @@ static int acpi_platform_notify(struct device *dev)
324 330
325static int acpi_platform_notify_remove(struct device *dev) 331static int acpi_platform_notify_remove(struct device *dev)
326{ 332{
333 struct acpi_device *adev = ACPI_COMPANION(dev);
327 struct acpi_bus_type *type; 334 struct acpi_bus_type *type;
328 335
336 if (!adev)
337 return 0;
338
329 type = acpi_get_bus_type(dev); 339 type = acpi_get_bus_type(dev);
330 if (type && type->cleanup) 340 if (type && type->cleanup)
331 type->cleanup(dev); 341 type->cleanup(dev);
342 else if (adev->handler && adev->handler->unbind)
343 adev->handler->unbind(dev);
332 344
333 acpi_unbind_one(dev); 345 acpi_unbind_one(dev);
334 return 0; 346 return 0;
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index dedbb2d802f1..957391306cbf 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -37,9 +37,15 @@ void acpi_container_init(void);
37static inline void acpi_container_init(void) {} 37static inline void acpi_container_init(void) {}
38#endif 38#endif
39#ifdef CONFIG_ACPI_DOCK 39#ifdef CONFIG_ACPI_DOCK
40void acpi_dock_init(void); 40void register_dock_dependent_device(struct acpi_device *adev,
41 acpi_handle dshandle);
42int dock_notify(struct acpi_device *adev, u32 event);
43void acpi_dock_add(struct acpi_device *adev);
41#else 44#else
42static inline void acpi_dock_init(void) {} 45static inline void register_dock_dependent_device(struct acpi_device *adev,
46 acpi_handle dshandle) {}
47static inline int dock_notify(struct acpi_device *adev, u32 event) { return -ENODEV; }
48static inline void acpi_dock_add(struct acpi_device *adev) {}
43#endif 49#endif
44#ifdef CONFIG_ACPI_HOTPLUG_MEMORY 50#ifdef CONFIG_ACPI_HOTPLUG_MEMORY
45void acpi_memory_hotplug_init(void); 51void acpi_memory_hotplug_init(void);
@@ -72,7 +78,9 @@ void acpi_lpss_init(void);
72static inline void acpi_lpss_init(void) {} 78static inline void acpi_lpss_init(void) {}
73#endif 79#endif
74 80
81acpi_status acpi_hotplug_schedule(struct acpi_device *adev, u32 src);
75bool acpi_queue_hotplug_work(struct work_struct *work); 82bool acpi_queue_hotplug_work(struct work_struct *work);
83void acpi_device_hotplug(struct acpi_device *adev, u32 src);
76bool acpi_scan_is_offline(struct acpi_device *adev, bool uevent); 84bool acpi_scan_is_offline(struct acpi_device *adev, bool uevent);
77 85
78/* -------------------------------------------------------------------------- 86/* --------------------------------------------------------------------------
@@ -90,6 +98,7 @@ void acpi_free_pnp_ids(struct acpi_device_pnp *pnp);
90int acpi_bind_one(struct device *dev, struct acpi_device *adev); 98int acpi_bind_one(struct device *dev, struct acpi_device *adev);
91int acpi_unbind_one(struct device *dev); 99int acpi_unbind_one(struct device *dev);
92bool acpi_device_is_present(struct acpi_device *adev); 100bool acpi_device_is_present(struct acpi_device *adev);
101bool acpi_device_is_battery(struct acpi_device *adev);
93 102
94/* -------------------------------------------------------------------------- 103/* --------------------------------------------------------------------------
95 Power Resource 104 Power Resource
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index fc1aa7909690..27f84af4e337 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -52,7 +52,7 @@
52 52
53#define _COMPONENT ACPI_OS_SERVICES 53#define _COMPONENT ACPI_OS_SERVICES
54ACPI_MODULE_NAME("osl"); 54ACPI_MODULE_NAME("osl");
55#define PREFIX "ACPI: " 55
56struct acpi_os_dpc { 56struct acpi_os_dpc {
57 acpi_osd_exec_callback function; 57 acpi_osd_exec_callback function;
58 void *context; 58 void *context;
@@ -1168,8 +1168,7 @@ void acpi_os_wait_events_complete(void)
1168 1168
1169struct acpi_hp_work { 1169struct acpi_hp_work {
1170 struct work_struct work; 1170 struct work_struct work;
1171 acpi_hp_callback func; 1171 struct acpi_device *adev;
1172 void *data;
1173 u32 src; 1172 u32 src;
1174}; 1173};
1175 1174
@@ -1178,25 +1177,24 @@ static void acpi_hotplug_work_fn(struct work_struct *work)
1178 struct acpi_hp_work *hpw = container_of(work, struct acpi_hp_work, work); 1177 struct acpi_hp_work *hpw = container_of(work, struct acpi_hp_work, work);
1179 1178
1180 acpi_os_wait_events_complete(); 1179 acpi_os_wait_events_complete();
1181 hpw->func(hpw->data, hpw->src); 1180 acpi_device_hotplug(hpw->adev, hpw->src);
1182 kfree(hpw); 1181 kfree(hpw);
1183} 1182}
1184 1183
1185acpi_status acpi_hotplug_execute(acpi_hp_callback func, void *data, u32 src) 1184acpi_status acpi_hotplug_schedule(struct acpi_device *adev, u32 src)
1186{ 1185{
1187 struct acpi_hp_work *hpw; 1186 struct acpi_hp_work *hpw;
1188 1187
1189 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 1188 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
1190 "Scheduling function [%p(%p, %u)] for deferred execution.\n", 1189 "Scheduling hotplug event (%p, %u) for deferred execution.\n",
1191 func, data, src)); 1190 adev, src));
1192 1191
1193 hpw = kmalloc(sizeof(*hpw), GFP_KERNEL); 1192 hpw = kmalloc(sizeof(*hpw), GFP_KERNEL);
1194 if (!hpw) 1193 if (!hpw)
1195 return AE_NO_MEMORY; 1194 return AE_NO_MEMORY;
1196 1195
1197 INIT_WORK(&hpw->work, acpi_hotplug_work_fn); 1196 INIT_WORK(&hpw->work, acpi_hotplug_work_fn);
1198 hpw->func = func; 1197 hpw->adev = adev;
1199 hpw->data = data;
1200 hpw->src = src; 1198 hpw->src = src;
1201 /* 1199 /*
1202 * We can't run hotplug code in kacpid_wq/kacpid_notify_wq etc., because 1200 * We can't run hotplug code in kacpid_wq/kacpid_notify_wq etc., because
@@ -1780,6 +1778,17 @@ static int __init acpi_no_auto_ssdt_setup(char *s)
1780 1778
1781__setup("acpi_no_auto_ssdt", acpi_no_auto_ssdt_setup); 1779__setup("acpi_no_auto_ssdt", acpi_no_auto_ssdt_setup);
1782 1780
1781static int __init acpi_disable_return_repair(char *s)
1782{
1783 printk(KERN_NOTICE PREFIX
1784 "ACPI: Predefined validation mechanism disabled\n");
1785 acpi_gbl_disable_auto_repair = TRUE;
1786
1787 return 1;
1788}
1789
1790__setup("acpica_no_return_repair", acpi_disable_return_repair);
1791
1783acpi_status __init acpi_os_initialize(void) 1792acpi_status __init acpi_os_initialize(void)
1784{ 1793{
1785 acpi_os_map_generic_address(&acpi_gbl_FADT.xpm1a_event_block); 1794 acpi_os_map_generic_address(&acpi_gbl_FADT.xpm1a_event_block);
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
index 361b40c10c3f..9c62340c2360 100644
--- a/drivers/acpi/pci_irq.c
+++ b/drivers/acpi/pci_irq.c
@@ -370,6 +370,30 @@ static struct acpi_prt_entry *acpi_pci_irq_lookup(struct pci_dev *dev, int pin)
370 return NULL; 370 return NULL;
371} 371}
372 372
373#if IS_ENABLED(CONFIG_ISA) || IS_ENABLED(CONFIG_EISA)
374static int acpi_isa_register_gsi(struct pci_dev *dev)
375{
376 u32 dev_gsi;
377
378 /* Interrupt Line values above 0xF are forbidden */
379 if (dev->irq > 0 && (dev->irq <= 0xF) &&
380 (acpi_isa_irq_to_gsi(dev->irq, &dev_gsi) == 0)) {
381 dev_warn(&dev->dev, "PCI INT %c: no GSI - using ISA IRQ %d\n",
382 pin_name(dev->pin), dev->irq);
383 acpi_register_gsi(&dev->dev, dev_gsi,
384 ACPI_LEVEL_SENSITIVE,
385 ACPI_ACTIVE_LOW);
386 return 0;
387 }
388 return -EINVAL;
389}
390#else
391static inline int acpi_isa_register_gsi(struct pci_dev *dev)
392{
393 return -ENODEV;
394}
395#endif
396
373int acpi_pci_irq_enable(struct pci_dev *dev) 397int acpi_pci_irq_enable(struct pci_dev *dev)
374{ 398{
375 struct acpi_prt_entry *entry; 399 struct acpi_prt_entry *entry;
@@ -416,19 +440,9 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
416 * driver reported one, then use it. Exit in any case. 440 * driver reported one, then use it. Exit in any case.
417 */ 441 */
418 if (gsi < 0) { 442 if (gsi < 0) {
419 u32 dev_gsi; 443 if (acpi_isa_register_gsi(dev))
420 /* Interrupt Line values above 0xF are forbidden */
421 if (dev->irq > 0 && (dev->irq <= 0xF) &&
422 (acpi_isa_irq_to_gsi(dev->irq, &dev_gsi) == 0)) {
423 dev_warn(&dev->dev, "PCI INT %c: no GSI - using ISA IRQ %d\n",
424 pin_name(pin), dev->irq);
425 acpi_register_gsi(&dev->dev, dev_gsi,
426 ACPI_LEVEL_SENSITIVE,
427 ACPI_ACTIVE_LOW);
428 } else {
429 dev_warn(&dev->dev, "PCI INT %c: no GSI\n", 444 dev_warn(&dev->dev, "PCI INT %c: no GSI\n",
430 pin_name(pin)); 445 pin_name(pin));
431 }
432 446
433 kfree(entry); 447 kfree(entry);
434 return 0; 448 return 0;
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index 9418c7a1f786..cfd7581cc19f 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -43,8 +43,6 @@
43 43
44#include "internal.h" 44#include "internal.h"
45 45
46#define PREFIX "ACPI: "
47
48#define _COMPONENT ACPI_PCI_COMPONENT 46#define _COMPONENT ACPI_PCI_COMPONENT
49ACPI_MODULE_NAME("pci_link"); 47ACPI_MODULE_NAME("pci_link");
50#define ACPI_PCI_LINK_CLASS "pci_irq_routing" 48#define ACPI_PCI_LINK_CLASS "pci_irq_routing"
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index c1c4102e6478..d388f13d48b4 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -39,8 +39,6 @@
39 39
40#include "internal.h" 40#include "internal.h"
41 41
42#define PREFIX "ACPI: "
43
44#define _COMPONENT ACPI_PCI_COMPONENT 42#define _COMPONENT ACPI_PCI_COMPONENT
45ACPI_MODULE_NAME("pci_root"); 43ACPI_MODULE_NAME("pci_root");
46#define ACPI_PCI_ROOT_CLASS "pci_bridge" 44#define ACPI_PCI_ROOT_CLASS "pci_bridge"
@@ -51,7 +49,7 @@ static void acpi_pci_root_remove(struct acpi_device *device);
51 49
52static int acpi_pci_root_scan_dependent(struct acpi_device *adev) 50static int acpi_pci_root_scan_dependent(struct acpi_device *adev)
53{ 51{
54 acpiphp_check_host_bridge(adev->handle); 52 acpiphp_check_host_bridge(adev);
55 return 0; 53 return 0;
56} 54}
57 55
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c
index ad7da686e6e6..e0bcfb642b52 100644
--- a/drivers/acpi/power.c
+++ b/drivers/acpi/power.c
@@ -46,8 +46,6 @@
46#include "sleep.h" 46#include "sleep.h"
47#include "internal.h" 47#include "internal.h"
48 48
49#define PREFIX "ACPI: "
50
51#define _COMPONENT ACPI_POWER_COMPONENT 49#define _COMPONENT ACPI_POWER_COMPONENT
52ACPI_MODULE_NAME("power"); 50ACPI_MODULE_NAME("power");
53#define ACPI_POWER_CLASS "power_resource" 51#define ACPI_POWER_CLASS "power_resource"
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index a4eea9a508d3..86d73d5d503f 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -15,28 +15,9 @@
15 15
16#include "internal.h" 16#include "internal.h"
17 17
18#define PREFIX "ACPI: "
19#define _COMPONENT ACPI_PROCESSOR_COMPONENT 18#define _COMPONENT ACPI_PROCESSOR_COMPONENT
20ACPI_MODULE_NAME("processor_core"); 19ACPI_MODULE_NAME("processor_core");
21 20
22static int __init set_no_mwait(const struct dmi_system_id *id)
23{
24 printk(KERN_NOTICE PREFIX "%s detected - "
25 "disabling mwait for CPU C-states\n", id->ident);
26 boot_option_idle_override = IDLE_NOMWAIT;
27 return 0;
28}
29
30static struct dmi_system_id processor_idle_dmi_table[] __initdata = {
31 {
32 set_no_mwait, "Extensa 5220", {
33 DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
34 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
35 DMI_MATCH(DMI_PRODUCT_VERSION, "0100"),
36 DMI_MATCH(DMI_BOARD_NAME, "Columbia") }, NULL},
37 {},
38};
39
40static int map_lapic_id(struct acpi_subtable_header *entry, 21static int map_lapic_id(struct acpi_subtable_header *entry,
41 u32 acpi_id, int *apic_id) 22 u32 acpi_id, int *apic_id)
42{ 23{
@@ -89,6 +70,28 @@ static int map_lsapic_id(struct acpi_subtable_header *entry,
89 return 0; 70 return 0;
90} 71}
91 72
73static int map_gic_id(struct acpi_subtable_header *entry,
74 int device_declaration, u32 acpi_id, int *apic_id)
75{
76 struct acpi_madt_generic_interrupt *gic =
77 (struct acpi_madt_generic_interrupt *)entry;
78
79 if (!(gic->flags & ACPI_MADT_ENABLED))
80 return -ENODEV;
81
82 /*
83 * In the GIC interrupt model, logical processors are
84 * required to have a Processor Device object in the DSDT,
85 * so we should check device_declaration here
86 */
87 if (device_declaration && (gic->uid == acpi_id)) {
88 *apic_id = gic->gic_id;
89 return 0;
90 }
91
92 return -EINVAL;
93}
94
92static int map_madt_entry(int type, u32 acpi_id) 95static int map_madt_entry(int type, u32 acpi_id)
93{ 96{
94 unsigned long madt_end, entry; 97 unsigned long madt_end, entry;
@@ -124,6 +127,9 @@ static int map_madt_entry(int type, u32 acpi_id)
124 } else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) { 127 } else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) {
125 if (!map_lsapic_id(header, type, acpi_id, &apic_id)) 128 if (!map_lsapic_id(header, type, acpi_id, &apic_id))
126 break; 129 break;
130 } else if (header->type == ACPI_MADT_TYPE_GENERIC_INTERRUPT) {
131 if (!map_gic_id(header, type, acpi_id, &apic_id))
132 break;
127 } 133 }
128 entry += header->length; 134 entry += header->length;
129 } 135 }
@@ -154,6 +160,8 @@ static int map_mat_entry(acpi_handle handle, int type, u32 acpi_id)
154 map_lapic_id(header, acpi_id, &apic_id); 160 map_lapic_id(header, acpi_id, &apic_id);
155 } else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) { 161 } else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) {
156 map_lsapic_id(header, type, acpi_id, &apic_id); 162 map_lsapic_id(header, type, acpi_id, &apic_id);
163 } else if (header->type == ACPI_MADT_TYPE_GENERIC_INTERRUPT) {
164 map_gic_id(header, type, acpi_id, &apic_id);
157 } 165 }
158 166
159exit: 167exit:
@@ -323,7 +331,7 @@ static struct acpi_object_list *acpi_processor_alloc_pdc(void)
323 * _PDC is required for a BIOS-OS handshake for most of the newer 331 * _PDC is required for a BIOS-OS handshake for most of the newer
324 * ACPI processor features. 332 * ACPI processor features.
325 */ 333 */
326static int 334static acpi_status
327acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in) 335acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in)
328{ 336{
329 acpi_status status = AE_OK; 337 acpi_status status = AE_OK;
@@ -379,16 +387,43 @@ early_init_pdc(acpi_handle handle, u32 lvl, void *context, void **rv)
379 return AE_OK; 387 return AE_OK;
380} 388}
381 389
382void __init acpi_early_processor_set_pdc(void) 390#if defined(CONFIG_X86) || defined(CONFIG_IA64)
391static int __init set_no_mwait(const struct dmi_system_id *id)
392{
393 pr_notice(PREFIX "%s detected - disabling mwait for CPU C-states\n",
394 id->ident);
395 boot_option_idle_override = IDLE_NOMWAIT;
396 return 0;
397}
398
399static struct dmi_system_id processor_idle_dmi_table[] __initdata = {
400 {
401 set_no_mwait, "Extensa 5220", {
402 DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
403 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
404 DMI_MATCH(DMI_PRODUCT_VERSION, "0100"),
405 DMI_MATCH(DMI_BOARD_NAME, "Columbia") }, NULL},
406 {},
407};
408
409static void __init processor_dmi_check(void)
383{ 410{
384 /* 411 /*
385 * Check whether the system is DMI table. If yes, OSPM 412 * Check whether the system is DMI table. If yes, OSPM
386 * should not use mwait for CPU-states. 413 * should not use mwait for CPU-states.
387 */ 414 */
388 dmi_check_system(processor_idle_dmi_table); 415 dmi_check_system(processor_idle_dmi_table);
416}
417#else
418static inline void processor_dmi_check(void) {}
419#endif
420
421void __init acpi_early_processor_set_pdc(void)
422{
423 processor_dmi_check();
389 424
390 acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT, 425 acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT,
391 ACPI_UINT32_MAX, 426 ACPI_UINT32_MAX,
392 early_init_pdc, NULL, NULL, NULL); 427 early_init_pdc, NULL, NULL, NULL);
393 acpi_get_devices("ACPI0007", early_init_pdc, NULL, NULL); 428 acpi_get_devices(ACPI_PROCESSOR_DEVICE_HID, early_init_pdc, NULL, NULL);
394} 429}
diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
index c1c35623550f..7f70f3182d50 100644
--- a/drivers/acpi/processor_driver.c
+++ b/drivers/acpi/processor_driver.c
@@ -41,8 +41,6 @@
41 41
42#include "internal.h" 42#include "internal.h"
43 43
44#define PREFIX "ACPI: "
45
46#define ACPI_PROCESSOR_NOTIFY_PERFORMANCE 0x80 44#define ACPI_PROCESSOR_NOTIFY_PERFORMANCE 0x80
47#define ACPI_PROCESSOR_NOTIFY_POWER 0x81 45#define ACPI_PROCESSOR_NOTIFY_POWER 0x81
48#define ACPI_PROCESSOR_NOTIFY_THROTTLING 0x82 46#define ACPI_PROCESSOR_NOTIFY_THROTTLING 0x82
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index ff90054f04fd..cfc8aba72f86 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -156,17 +156,9 @@ static int acpi_processor_get_platform_limit(struct acpi_processor *pr)
156 */ 156 */
157static void acpi_processor_ppc_ost(acpi_handle handle, int status) 157static void acpi_processor_ppc_ost(acpi_handle handle, int status)
158{ 158{
159 union acpi_object params[2] = { 159 if (acpi_has_method(handle, "_OST"))
160 {.type = ACPI_TYPE_INTEGER,}, 160 acpi_evaluate_ost(handle, ACPI_PROCESSOR_NOTIFY_PERFORMANCE,
161 {.type = ACPI_TYPE_INTEGER,}, 161 status, NULL);
162 };
163 struct acpi_object_list arg_list = {2, params};
164
165 if (acpi_has_method(handle, "_OST")) {
166 params[0].integer.value = ACPI_PROCESSOR_NOTIFY_PERFORMANCE;
167 params[1].integer.value = status;
168 acpi_evaluate_object(handle, "_OST", &arg_list, NULL);
169 }
170} 162}
171 163
172int acpi_processor_ppc_has_changed(struct acpi_processor *pr, int event_flag) 164int acpi_processor_ppc_has_changed(struct acpi_processor *pr, int event_flag)
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
index dbd48498b938..366ca40a6f70 100644
--- a/drivers/acpi/sbs.c
+++ b/drivers/acpi/sbs.c
@@ -37,12 +37,12 @@
37#include <linux/power_supply.h> 37#include <linux/power_supply.h>
38 38
39#include "sbshc.h" 39#include "sbshc.h"
40#include "battery.h"
40 41
41#define PREFIX "ACPI: " 42#define PREFIX "ACPI: "
42 43
43#define ACPI_SBS_CLASS "sbs" 44#define ACPI_SBS_CLASS "sbs"
44#define ACPI_AC_CLASS "ac_adapter" 45#define ACPI_AC_CLASS "ac_adapter"
45#define ACPI_BATTERY_CLASS "battery"
46#define ACPI_SBS_DEVICE_NAME "Smart Battery System" 46#define ACPI_SBS_DEVICE_NAME "Smart Battery System"
47#define ACPI_SBS_FILE_INFO "info" 47#define ACPI_SBS_FILE_INFO "info"
48#define ACPI_SBS_FILE_STATE "state" 48#define ACPI_SBS_FILE_STATE "state"
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 57b053f424d1..7efe546a8c42 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -41,6 +41,7 @@ static DEFINE_MUTEX(acpi_scan_lock);
41static LIST_HEAD(acpi_scan_handlers_list); 41static LIST_HEAD(acpi_scan_handlers_list);
42DEFINE_MUTEX(acpi_device_lock); 42DEFINE_MUTEX(acpi_device_lock);
43LIST_HEAD(acpi_wakeup_device_list); 43LIST_HEAD(acpi_wakeup_device_list);
44static DEFINE_MUTEX(acpi_hp_context_lock);
44 45
45struct acpi_device_bus_id{ 46struct acpi_device_bus_id{
46 char bus_id[15]; 47 char bus_id[15];
@@ -60,6 +61,27 @@ void acpi_scan_lock_release(void)
60} 61}
61EXPORT_SYMBOL_GPL(acpi_scan_lock_release); 62EXPORT_SYMBOL_GPL(acpi_scan_lock_release);
62 63
64void acpi_lock_hp_context(void)
65{
66 mutex_lock(&acpi_hp_context_lock);
67}
68
69void acpi_unlock_hp_context(void)
70{
71 mutex_unlock(&acpi_hp_context_lock);
72}
73
74void acpi_initialize_hp_context(struct acpi_device *adev,
75 struct acpi_hotplug_context *hp,
76 int (*notify)(struct acpi_device *, u32),
77 void (*uevent)(struct acpi_device *, u32))
78{
79 acpi_lock_hp_context();
80 acpi_set_hp_context(adev, hp, notify, uevent, NULL);
81 acpi_unlock_hp_context();
82}
83EXPORT_SYMBOL_GPL(acpi_initialize_hp_context);
84
63int acpi_scan_add_handler(struct acpi_scan_handler *handler) 85int acpi_scan_add_handler(struct acpi_scan_handler *handler)
64{ 86{
65 if (!handler || !handler->attach) 87 if (!handler || !handler->attach)
@@ -439,90 +461,75 @@ static int acpi_scan_bus_check(struct acpi_device *adev)
439 return 0; 461 return 0;
440} 462}
441 463
442static void acpi_device_hotplug(void *data, u32 src) 464static int acpi_generic_hotplug_event(struct acpi_device *adev, u32 type)
443{ 465{
444 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; 466 switch (type) {
445 struct acpi_device *adev = data;
446 int error;
447
448 lock_device_hotplug();
449 mutex_lock(&acpi_scan_lock);
450
451 /*
452 * The device object's ACPI handle cannot become invalid as long as we
453 * are holding acpi_scan_lock, but it may have become invalid before
454 * that lock was acquired.
455 */
456 if (adev->handle == INVALID_ACPI_HANDLE)
457 goto out;
458
459 switch (src) {
460 case ACPI_NOTIFY_BUS_CHECK: 467 case ACPI_NOTIFY_BUS_CHECK:
461 error = acpi_scan_bus_check(adev); 468 return acpi_scan_bus_check(adev);
462 break;
463 case ACPI_NOTIFY_DEVICE_CHECK: 469 case ACPI_NOTIFY_DEVICE_CHECK:
464 error = acpi_scan_device_check(adev); 470 return acpi_scan_device_check(adev);
465 break;
466 case ACPI_NOTIFY_EJECT_REQUEST: 471 case ACPI_NOTIFY_EJECT_REQUEST:
467 case ACPI_OST_EC_OSPM_EJECT: 472 case ACPI_OST_EC_OSPM_EJECT:
468 error = acpi_scan_hot_remove(adev); 473 if (adev->handler && !adev->handler->hotplug.enabled) {
469 break; 474 dev_info(&adev->dev, "Eject disabled\n");
470 default: 475 return -EPERM;
471 error = -EINVAL; 476 }
472 break; 477 acpi_evaluate_ost(adev->handle, ACPI_NOTIFY_EJECT_REQUEST,
478 ACPI_OST_SC_EJECT_IN_PROGRESS, NULL);
479 return acpi_scan_hot_remove(adev);
473 } 480 }
474 if (!error) 481 return -EINVAL;
475 ost_code = ACPI_OST_SC_SUCCESS;
476
477 out:
478 acpi_evaluate_hotplug_ost(adev->handle, src, ost_code, NULL);
479 put_device(&adev->dev);
480 mutex_unlock(&acpi_scan_lock);
481 unlock_device_hotplug();
482} 482}
483 483
484static void acpi_hotplug_notify_cb(acpi_handle handle, u32 type, void *data) 484void acpi_device_hotplug(struct acpi_device *adev, u32 src)
485{ 485{
486 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; 486 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE;
487 struct acpi_device *adev; 487 int error = -ENODEV;
488 acpi_status status;
489 488
490 if (acpi_bus_get_device(handle, &adev)) 489 lock_device_hotplug();
491 goto err_out; 490 mutex_lock(&acpi_scan_lock);
492 491
493 switch (type) { 492 /*
494 case ACPI_NOTIFY_BUS_CHECK: 493 * The device object's ACPI handle cannot become invalid as long as we
495 acpi_handle_debug(handle, "ACPI_NOTIFY_BUS_CHECK event\n"); 494 * are holding acpi_scan_lock, but it might have become invalid before
496 break; 495 * that lock was acquired.
497 case ACPI_NOTIFY_DEVICE_CHECK: 496 */
498 acpi_handle_debug(handle, "ACPI_NOTIFY_DEVICE_CHECK event\n"); 497 if (adev->handle == INVALID_ACPI_HANDLE)
499 break; 498 goto err_out;
500 case ACPI_NOTIFY_EJECT_REQUEST:
501 acpi_handle_debug(handle, "ACPI_NOTIFY_EJECT_REQUEST event\n");
502 if (!adev->handler)
503 goto err_out;
504 499
505 if (!adev->handler->hotplug.enabled) { 500 if (adev->flags.is_dock_station) {
506 acpi_handle_err(handle, "Eject disabled\n"); 501 error = dock_notify(adev, src);
502 } else if (adev->flags.hotplug_notify) {
503 error = acpi_generic_hotplug_event(adev, src);
504 if (error == -EPERM) {
507 ost_code = ACPI_OST_SC_EJECT_NOT_SUPPORTED; 505 ost_code = ACPI_OST_SC_EJECT_NOT_SUPPORTED;
508 goto err_out; 506 goto err_out;
509 } 507 }
510 acpi_evaluate_hotplug_ost(handle, ACPI_NOTIFY_EJECT_REQUEST, 508 } else {
511 ACPI_OST_SC_EJECT_IN_PROGRESS, NULL); 509 int (*notify)(struct acpi_device *, u32);
512 break;
513 default:
514 /* non-hotplug event; possibly handled by other handler */
515 return;
516 }
517 get_device(&adev->dev);
518 status = acpi_hotplug_execute(acpi_device_hotplug, adev, type);
519 if (ACPI_SUCCESS(status))
520 return;
521 510
522 put_device(&adev->dev); 511 acpi_lock_hp_context();
512 notify = adev->hp ? adev->hp->notify : NULL;
513 acpi_unlock_hp_context();
514 /*
515 * There may be additional notify handlers for device objects
516 * without the .event() callback, so ignore them here.
517 */
518 if (notify)
519 error = notify(adev, src);
520 else
521 goto out;
522 }
523 if (!error)
524 ost_code = ACPI_OST_SC_SUCCESS;
523 525
524 err_out: 526 err_out:
525 acpi_evaluate_hotplug_ost(handle, type, ost_code, NULL); 527 acpi_evaluate_ost(adev->handle, src, ost_code, NULL);
528
529 out:
530 acpi_bus_put_acpi_device(adev);
531 mutex_unlock(&acpi_scan_lock);
532 unlock_device_hotplug();
526} 533}
527 534
528static ssize_t real_power_state_show(struct device *dev, 535static ssize_t real_power_state_show(struct device *dev,
@@ -570,17 +577,14 @@ acpi_eject_store(struct device *d, struct device_attribute *attr,
570 if (ACPI_FAILURE(status) || !acpi_device->flags.ejectable) 577 if (ACPI_FAILURE(status) || !acpi_device->flags.ejectable)
571 return -ENODEV; 578 return -ENODEV;
572 579
573 acpi_evaluate_hotplug_ost(acpi_device->handle, ACPI_OST_EC_OSPM_EJECT,
574 ACPI_OST_SC_EJECT_IN_PROGRESS, NULL);
575 get_device(&acpi_device->dev); 580 get_device(&acpi_device->dev);
576 status = acpi_hotplug_execute(acpi_device_hotplug, acpi_device, 581 status = acpi_hotplug_schedule(acpi_device, ACPI_OST_EC_OSPM_EJECT);
577 ACPI_OST_EC_OSPM_EJECT);
578 if (ACPI_SUCCESS(status)) 582 if (ACPI_SUCCESS(status))
579 return count; 583 return count;
580 584
581 put_device(&acpi_device->dev); 585 put_device(&acpi_device->dev);
582 acpi_evaluate_hotplug_ost(acpi_device->handle, ACPI_OST_EC_OSPM_EJECT, 586 acpi_evaluate_ost(acpi_device->handle, ACPI_OST_EC_OSPM_EJECT,
583 ACPI_OST_SC_NON_SPECIFIC_FAILURE, NULL); 587 ACPI_OST_SC_NON_SPECIFIC_FAILURE, NULL);
584 return status == AE_NO_MEMORY ? -ENOMEM : -EAGAIN; 588 return status == AE_NO_MEMORY ? -ENOMEM : -EAGAIN;
585} 589}
586 590
@@ -1114,14 +1118,16 @@ static void acpi_scan_drop_device(acpi_handle handle, void *context)
1114 mutex_unlock(&acpi_device_del_lock); 1118 mutex_unlock(&acpi_device_del_lock);
1115} 1119}
1116 1120
1117int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device) 1121static int acpi_get_device_data(acpi_handle handle, struct acpi_device **device,
1122 void (*callback)(void *))
1118{ 1123{
1119 acpi_status status; 1124 acpi_status status;
1120 1125
1121 if (!device) 1126 if (!device)
1122 return -EINVAL; 1127 return -EINVAL;
1123 1128
1124 status = acpi_get_data(handle, acpi_scan_drop_device, (void **)device); 1129 status = acpi_get_data_full(handle, acpi_scan_drop_device,
1130 (void **)device, callback);
1125 if (ACPI_FAILURE(status) || !*device) { 1131 if (ACPI_FAILURE(status) || !*device) {
1126 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No context for object [%p]\n", 1132 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No context for object [%p]\n",
1127 handle)); 1133 handle));
@@ -1129,8 +1135,32 @@ int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device)
1129 } 1135 }
1130 return 0; 1136 return 0;
1131} 1137}
1138
1139int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device)
1140{
1141 return acpi_get_device_data(handle, device, NULL);
1142}
1132EXPORT_SYMBOL(acpi_bus_get_device); 1143EXPORT_SYMBOL(acpi_bus_get_device);
1133 1144
1145static void get_acpi_device(void *dev)
1146{
1147 if (dev)
1148 get_device(&((struct acpi_device *)dev)->dev);
1149}
1150
1151struct acpi_device *acpi_bus_get_acpi_device(acpi_handle handle)
1152{
1153 struct acpi_device *adev = NULL;
1154
1155 acpi_get_device_data(handle, &adev, get_acpi_device);
1156 return adev;
1157}
1158
1159void acpi_bus_put_acpi_device(struct acpi_device *adev)
1160{
1161 put_device(&adev->dev);
1162}
1163
1134int acpi_device_add(struct acpi_device *device, 1164int acpi_device_add(struct acpi_device *device,
1135 void (*release)(struct device *)) 1165 void (*release)(struct device *))
1136{ 1166{
@@ -1641,6 +1671,27 @@ bool acpi_bay_match(acpi_handle handle)
1641 return acpi_ata_match(phandle); 1671 return acpi_ata_match(phandle);
1642} 1672}
1643 1673
1674bool acpi_device_is_battery(struct acpi_device *adev)
1675{
1676 struct acpi_hardware_id *hwid;
1677
1678 list_for_each_entry(hwid, &adev->pnp.ids, list)
1679 if (!strcmp("PNP0C0A", hwid->id))
1680 return true;
1681
1682 return false;
1683}
1684
1685static bool is_ejectable_bay(struct acpi_device *adev)
1686{
1687 acpi_handle handle = adev->handle;
1688
1689 if (acpi_has_method(handle, "_EJ0") && acpi_device_is_battery(adev))
1690 return true;
1691
1692 return acpi_bay_match(handle);
1693}
1694
1644/* 1695/*
1645 * acpi_dock_match - see if an acpi object has a _DCK method 1696 * acpi_dock_match - see if an acpi object has a _DCK method
1646 */ 1697 */
@@ -1706,6 +1757,20 @@ static bool acpi_ibm_smbus_match(acpi_handle handle)
1706 return false; 1757 return false;
1707} 1758}
1708 1759
1760static bool acpi_object_is_system_bus(acpi_handle handle)
1761{
1762 acpi_handle tmp;
1763
1764 if (ACPI_SUCCESS(acpi_get_handle(NULL, "\\_SB", &tmp)) &&
1765 tmp == handle)
1766 return true;
1767 if (ACPI_SUCCESS(acpi_get_handle(NULL, "\\_TZ", &tmp)) &&
1768 tmp == handle)
1769 return true;
1770
1771 return false;
1772}
1773
1709static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp, 1774static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp,
1710 int device_type) 1775 int device_type)
1711{ 1776{
@@ -1757,8 +1822,10 @@ static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp,
1757 acpi_add_id(pnp, ACPI_DOCK_HID); 1822 acpi_add_id(pnp, ACPI_DOCK_HID);
1758 else if (acpi_ibm_smbus_match(handle)) 1823 else if (acpi_ibm_smbus_match(handle))
1759 acpi_add_id(pnp, ACPI_SMBUS_IBM_HID); 1824 acpi_add_id(pnp, ACPI_SMBUS_IBM_HID);
1760 else if (list_empty(&pnp->ids) && handle == ACPI_ROOT_OBJECT) { 1825 else if (list_empty(&pnp->ids) &&
1761 acpi_add_id(pnp, ACPI_BUS_HID); /* \_SB, LNXSYBUS */ 1826 acpi_object_is_system_bus(handle)) {
1827 /* \_SB, \_TZ, LNXSYBUS */
1828 acpi_add_id(pnp, ACPI_BUS_HID);
1762 strcpy(pnp->device_name, ACPI_BUS_DEVICE_NAME); 1829 strcpy(pnp->device_name, ACPI_BUS_DEVICE_NAME);
1763 strcpy(pnp->device_class, ACPI_BUS_CLASS); 1830 strcpy(pnp->device_class, ACPI_BUS_CLASS);
1764 } 1831 }
@@ -1941,33 +2008,23 @@ void acpi_scan_hotplug_enabled(struct acpi_hotplug_profile *hotplug, bool val)
1941 mutex_unlock(&acpi_scan_lock); 2008 mutex_unlock(&acpi_scan_lock);
1942} 2009}
1943 2010
1944static void acpi_scan_init_hotplug(acpi_handle handle, int type) 2011static void acpi_scan_init_hotplug(struct acpi_device *adev)
1945{ 2012{
1946 struct acpi_device_pnp pnp = {};
1947 struct acpi_hardware_id *hwid; 2013 struct acpi_hardware_id *hwid;
1948 struct acpi_scan_handler *handler;
1949 2014
1950 INIT_LIST_HEAD(&pnp.ids); 2015 if (acpi_dock_match(adev->handle) || is_ejectable_bay(adev)) {
1951 acpi_set_pnp_ids(handle, &pnp, type); 2016 acpi_dock_add(adev);
1952 2017 return;
1953 if (!pnp.type.hardware_id) 2018 }
1954 goto out; 2019 list_for_each_entry(hwid, &adev->pnp.ids, list) {
2020 struct acpi_scan_handler *handler;
1955 2021
1956 /*
1957 * This relies on the fact that acpi_install_notify_handler() will not
1958 * install the same notify handler routine twice for the same handle.
1959 */
1960 list_for_each_entry(hwid, &pnp.ids, list) {
1961 handler = acpi_scan_match_handler(hwid->id, NULL); 2022 handler = acpi_scan_match_handler(hwid->id, NULL);
1962 if (handler) { 2023 if (handler) {
1963 acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, 2024 adev->flags.hotplug_notify = true;
1964 acpi_hotplug_notify_cb, handler);
1965 break; 2025 break;
1966 } 2026 }
1967 } 2027 }
1968
1969out:
1970 acpi_free_pnp_ids(&pnp);
1971} 2028}
1972 2029
1973static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used, 2030static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used,
@@ -1991,12 +2048,12 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used,
1991 return AE_OK; 2048 return AE_OK;
1992 } 2049 }
1993 2050
1994 acpi_scan_init_hotplug(handle, type);
1995
1996 acpi_add_single_object(&device, handle, type, sta); 2051 acpi_add_single_object(&device, handle, type, sta);
1997 if (!device) 2052 if (!device)
1998 return AE_CTRL_DEPTH; 2053 return AE_CTRL_DEPTH;
1999 2054
2055 acpi_scan_init_hotplug(device);
2056
2000 out: 2057 out:
2001 if (!*return_value) 2058 if (!*return_value)
2002 *return_value = device; 2059 *return_value = device;
@@ -2015,13 +2072,14 @@ static int acpi_scan_attach_handler(struct acpi_device *device)
2015 2072
2016 handler = acpi_scan_match_handler(hwid->id, &devid); 2073 handler = acpi_scan_match_handler(hwid->id, &devid);
2017 if (handler) { 2074 if (handler) {
2075 device->handler = handler;
2018 ret = handler->attach(device, devid); 2076 ret = handler->attach(device, devid);
2019 if (ret > 0) { 2077 if (ret > 0)
2020 device->handler = handler;
2021 break; 2078 break;
2022 } else if (ret < 0) { 2079
2080 device->handler = NULL;
2081 if (ret < 0)
2023 break; 2082 break;
2024 }
2025 } 2083 }
2026 } 2084 }
2027 return ret; 2085 return ret;
@@ -2030,8 +2088,12 @@ static int acpi_scan_attach_handler(struct acpi_device *device)
2030static void acpi_bus_attach(struct acpi_device *device) 2088static void acpi_bus_attach(struct acpi_device *device)
2031{ 2089{
2032 struct acpi_device *child; 2090 struct acpi_device *child;
2091 acpi_handle ejd;
2033 int ret; 2092 int ret;
2034 2093
2094 if (ACPI_SUCCESS(acpi_bus_get_ejd(device->handle, &ejd)))
2095 register_dock_dependent_device(device, ejd);
2096
2035 acpi_bus_get_status(device); 2097 acpi_bus_get_status(device);
2036 /* Skip devices that are not present. */ 2098 /* Skip devices that are not present. */
2037 if (!acpi_device_is_present(device)) { 2099 if (!acpi_device_is_present(device)) {
@@ -2184,7 +2246,6 @@ int __init acpi_scan_init(void)
2184 acpi_cmos_rtc_init(); 2246 acpi_cmos_rtc_init();
2185 acpi_container_init(); 2247 acpi_container_init();
2186 acpi_memory_hotplug_init(); 2248 acpi_memory_hotplug_init();
2187 acpi_dock_init();
2188 2249
2189 mutex_lock(&acpi_scan_lock); 2250 mutex_lock(&acpi_scan_lock);
2190 /* 2251 /*
diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
index 91a32cefb11f..38cb9782d4b8 100644
--- a/drivers/acpi/sysfs.c
+++ b/drivers/acpi/sysfs.c
@@ -12,8 +12,6 @@
12#define _COMPONENT ACPI_SYSTEM_COMPONENT 12#define _COMPONENT ACPI_SYSTEM_COMPONENT
13ACPI_MODULE_NAME("sysfs"); 13ACPI_MODULE_NAME("sysfs");
14 14
15#define PREFIX "ACPI: "
16
17#ifdef CONFIG_ACPI_DEBUG 15#ifdef CONFIG_ACPI_DEBUG
18/* 16/*
19 * ACPI debug sysfs I/F, including: 17 * ACPI debug sysfs I/F, including:
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
index 5837f857ac2e..21782290df41 100644
--- a/drivers/acpi/tables.c
+++ b/drivers/acpi/tables.c
@@ -23,6 +23,8 @@
23 * 23 *
24 */ 24 */
25 25
26#define pr_fmt(fmt) "ACPI: " fmt
27
26#include <linux/init.h> 28#include <linux/init.h>
27#include <linux/kernel.h> 29#include <linux/kernel.h>
28#include <linux/smp.h> 30#include <linux/smp.h>
@@ -33,8 +35,6 @@
33#include <linux/acpi.h> 35#include <linux/acpi.h>
34#include <linux/bootmem.h> 36#include <linux/bootmem.h>
35 37
36#define PREFIX "ACPI: "
37
38#define ACPI_MAX_TABLES 128 38#define ACPI_MAX_TABLES 128
39 39
40static char *mps_inti_flags_polarity[] = { "dfl", "high", "res", "low" }; 40static char *mps_inti_flags_polarity[] = { "dfl", "high", "res", "low" };
@@ -55,10 +55,9 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
55 { 55 {
56 struct acpi_madt_local_apic *p = 56 struct acpi_madt_local_apic *p =
57 (struct acpi_madt_local_apic *)header; 57 (struct acpi_madt_local_apic *)header;
58 printk(KERN_INFO PREFIX 58 pr_info("LAPIC (acpi_id[0x%02x] lapic_id[0x%02x] %s)\n",
59 "LAPIC (acpi_id[0x%02x] lapic_id[0x%02x] %s)\n", 59 p->processor_id, p->id,
60 p->processor_id, p->id, 60 (p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
61 (p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
62 } 61 }
63 break; 62 break;
64 63
@@ -66,11 +65,9 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
66 { 65 {
67 struct acpi_madt_local_x2apic *p = 66 struct acpi_madt_local_x2apic *p =
68 (struct acpi_madt_local_x2apic *)header; 67 (struct acpi_madt_local_x2apic *)header;
69 printk(KERN_INFO PREFIX 68 pr_info("X2APIC (apic_id[0x%02x] uid[0x%02x] %s)\n",
70 "X2APIC (apic_id[0x%02x] uid[0x%02x] %s)\n", 69 p->local_apic_id, p->uid,
71 p->local_apic_id, p->uid, 70 (p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
72 (p->lapic_flags & ACPI_MADT_ENABLED) ?
73 "enabled" : "disabled");
74 } 71 }
75 break; 72 break;
76 73
@@ -78,9 +75,8 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
78 { 75 {
79 struct acpi_madt_io_apic *p = 76 struct acpi_madt_io_apic *p =
80 (struct acpi_madt_io_apic *)header; 77 (struct acpi_madt_io_apic *)header;
81 printk(KERN_INFO PREFIX 78 pr_info("IOAPIC (id[0x%02x] address[0x%08x] gsi_base[%d])\n",
82 "IOAPIC (id[0x%02x] address[0x%08x] gsi_base[%d])\n", 79 p->id, p->address, p->global_irq_base);
83 p->id, p->address, p->global_irq_base);
84 } 80 }
85 break; 81 break;
86 82
@@ -88,18 +84,15 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
88 { 84 {
89 struct acpi_madt_interrupt_override *p = 85 struct acpi_madt_interrupt_override *p =
90 (struct acpi_madt_interrupt_override *)header; 86 (struct acpi_madt_interrupt_override *)header;
91 printk(KERN_INFO PREFIX 87 pr_info("INT_SRC_OVR (bus %d bus_irq %d global_irq %d %s %s)\n",
92 "INT_SRC_OVR (bus %d bus_irq %d global_irq %d %s %s)\n", 88 p->bus, p->source_irq, p->global_irq,
93 p->bus, p->source_irq, p->global_irq, 89 mps_inti_flags_polarity[p->inti_flags & ACPI_MADT_POLARITY_MASK],
94 mps_inti_flags_polarity[p->inti_flags & ACPI_MADT_POLARITY_MASK], 90 mps_inti_flags_trigger[(p->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2]);
95 mps_inti_flags_trigger[(p->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2]);
96 if (p->inti_flags & 91 if (p->inti_flags &
97 ~(ACPI_MADT_POLARITY_MASK | ACPI_MADT_TRIGGER_MASK)) 92 ~(ACPI_MADT_POLARITY_MASK | ACPI_MADT_TRIGGER_MASK))
98 printk(KERN_INFO PREFIX 93 pr_info("INT_SRC_OVR unexpected reserved flags: 0x%x\n",
99 "INT_SRC_OVR unexpected reserved flags: 0x%x\n", 94 p->inti_flags &
100 p->inti_flags &
101 ~(ACPI_MADT_POLARITY_MASK | ACPI_MADT_TRIGGER_MASK)); 95 ~(ACPI_MADT_POLARITY_MASK | ACPI_MADT_TRIGGER_MASK));
102
103 } 96 }
104 break; 97 break;
105 98
@@ -107,11 +100,10 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
107 { 100 {
108 struct acpi_madt_nmi_source *p = 101 struct acpi_madt_nmi_source *p =
109 (struct acpi_madt_nmi_source *)header; 102 (struct acpi_madt_nmi_source *)header;
110 printk(KERN_INFO PREFIX 103 pr_info("NMI_SRC (%s %s global_irq %d)\n",
111 "NMI_SRC (%s %s global_irq %d)\n", 104 mps_inti_flags_polarity[p->inti_flags & ACPI_MADT_POLARITY_MASK],
112 mps_inti_flags_polarity[p->inti_flags & ACPI_MADT_POLARITY_MASK], 105 mps_inti_flags_trigger[(p->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2],
113 mps_inti_flags_trigger[(p->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2], 106 p->global_irq);
114 p->global_irq);
115 } 107 }
116 break; 108 break;
117 109
@@ -119,12 +111,11 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
119 { 111 {
120 struct acpi_madt_local_apic_nmi *p = 112 struct acpi_madt_local_apic_nmi *p =
121 (struct acpi_madt_local_apic_nmi *)header; 113 (struct acpi_madt_local_apic_nmi *)header;
122 printk(KERN_INFO PREFIX 114 pr_info("LAPIC_NMI (acpi_id[0x%02x] %s %s lint[0x%x])\n",
123 "LAPIC_NMI (acpi_id[0x%02x] %s %s lint[0x%x])\n", 115 p->processor_id,
124 p->processor_id, 116 mps_inti_flags_polarity[p->inti_flags & ACPI_MADT_POLARITY_MASK ],
125 mps_inti_flags_polarity[p->inti_flags & ACPI_MADT_POLARITY_MASK ], 117 mps_inti_flags_trigger[(p->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2],
126 mps_inti_flags_trigger[(p->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2], 118 p->lint);
127 p->lint);
128 } 119 }
129 break; 120 break;
130 121
@@ -137,12 +128,11 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
137 polarity = p->inti_flags & ACPI_MADT_POLARITY_MASK; 128 polarity = p->inti_flags & ACPI_MADT_POLARITY_MASK;
138 trigger = (p->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2; 129 trigger = (p->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2;
139 130
140 printk(KERN_INFO PREFIX 131 pr_info("X2APIC_NMI (uid[0x%02x] %s %s lint[0x%x])\n",
141 "X2APIC_NMI (uid[0x%02x] %s %s lint[0x%x])\n", 132 p->uid,
142 p->uid, 133 mps_inti_flags_polarity[polarity],
143 mps_inti_flags_polarity[polarity], 134 mps_inti_flags_trigger[trigger],
144 mps_inti_flags_trigger[trigger], 135 p->lint);
145 p->lint);
146 } 136 }
147 break; 137 break;
148 138
@@ -150,9 +140,8 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
150 { 140 {
151 struct acpi_madt_local_apic_override *p = 141 struct acpi_madt_local_apic_override *p =
152 (struct acpi_madt_local_apic_override *)header; 142 (struct acpi_madt_local_apic_override *)header;
153 printk(KERN_INFO PREFIX 143 pr_info("LAPIC_ADDR_OVR (address[%p])\n",
154 "LAPIC_ADDR_OVR (address[%p])\n", 144 (void *)(unsigned long)p->address);
155 (void *)(unsigned long)p->address);
156 } 145 }
157 break; 146 break;
158 147
@@ -160,10 +149,9 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
160 { 149 {
161 struct acpi_madt_io_sapic *p = 150 struct acpi_madt_io_sapic *p =
162 (struct acpi_madt_io_sapic *)header; 151 (struct acpi_madt_io_sapic *)header;
163 printk(KERN_INFO PREFIX 152 pr_info("IOSAPIC (id[0x%x] address[%p] gsi_base[%d])\n",
164 "IOSAPIC (id[0x%x] address[%p] gsi_base[%d])\n", 153 p->id, (void *)(unsigned long)p->address,
165 p->id, (void *)(unsigned long)p->address, 154 p->global_irq_base);
166 p->global_irq_base);
167 } 155 }
168 break; 156 break;
169 157
@@ -171,10 +159,9 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
171 { 159 {
172 struct acpi_madt_local_sapic *p = 160 struct acpi_madt_local_sapic *p =
173 (struct acpi_madt_local_sapic *)header; 161 (struct acpi_madt_local_sapic *)header;
174 printk(KERN_INFO PREFIX 162 pr_info("LSAPIC (acpi_id[0x%02x] lsapic_id[0x%02x] lsapic_eid[0x%02x] %s)\n",
175 "LSAPIC (acpi_id[0x%02x] lsapic_id[0x%02x] lsapic_eid[0x%02x] %s)\n", 163 p->processor_id, p->id, p->eid,
176 p->processor_id, p->id, p->eid, 164 (p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
177 (p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
178 } 165 }
179 break; 166 break;
180 167
@@ -182,19 +169,17 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
182 { 169 {
183 struct acpi_madt_interrupt_source *p = 170 struct acpi_madt_interrupt_source *p =
184 (struct acpi_madt_interrupt_source *)header; 171 (struct acpi_madt_interrupt_source *)header;
185 printk(KERN_INFO PREFIX 172 pr_info("PLAT_INT_SRC (%s %s type[0x%x] id[0x%04x] eid[0x%x] iosapic_vector[0x%x] global_irq[0x%x]\n",
186 "PLAT_INT_SRC (%s %s type[0x%x] id[0x%04x] eid[0x%x] iosapic_vector[0x%x] global_irq[0x%x]\n", 173 mps_inti_flags_polarity[p->inti_flags & ACPI_MADT_POLARITY_MASK],
187 mps_inti_flags_polarity[p->inti_flags & ACPI_MADT_POLARITY_MASK], 174 mps_inti_flags_trigger[(p->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2],
188 mps_inti_flags_trigger[(p->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2], 175 p->type, p->id, p->eid, p->io_sapic_vector,
189 p->type, p->id, p->eid, p->io_sapic_vector, 176 p->global_irq);
190 p->global_irq);
191 } 177 }
192 break; 178 break;
193 179
194 default: 180 default:
195 printk(KERN_WARNING PREFIX 181 pr_warn("Found unsupported MADT entry (type = 0x%x)\n",
196 "Found unsupported MADT entry (type = 0x%x)\n", 182 header->type);
197 header->type);
198 break; 183 break;
199 } 184 }
200} 185}
@@ -225,7 +210,7 @@ acpi_table_parse_entries(char *id,
225 acpi_get_table_with_size(id, 0, &table_header, &tbl_size); 210 acpi_get_table_with_size(id, 0, &table_header, &tbl_size);
226 211
227 if (!table_header) { 212 if (!table_header) {
228 printk(KERN_WARNING PREFIX "%4.4s not present\n", id); 213 pr_warn("%4.4s not present\n", id);
229 return -ENODEV; 214 return -ENODEV;
230 } 215 }
231 216
@@ -248,7 +233,7 @@ acpi_table_parse_entries(char *id,
248 * infinite loop. 233 * infinite loop.
249 */ 234 */
250 if (entry->length == 0) { 235 if (entry->length == 0) {
251 pr_err(PREFIX "[%4.4s:0x%02x] Invalid zero length\n", id, entry_id); 236 pr_err("[%4.4s:0x%02x] Invalid zero length\n", id, entry_id);
252 goto err; 237 goto err;
253 } 238 }
254 239
@@ -256,8 +241,8 @@ acpi_table_parse_entries(char *id,
256 ((unsigned long)entry + entry->length); 241 ((unsigned long)entry + entry->length);
257 } 242 }
258 if (max_entries && count > max_entries) { 243 if (max_entries && count > max_entries) {
259 printk(KERN_WARNING PREFIX "[%4.4s:0x%02x] ignored %i entries of " 244 pr_warn("[%4.4s:0x%02x] ignored %i entries of %i found\n",
260 "%i found\n", id, entry_id, count - max_entries, count); 245 id, entry_id, count - max_entries, count);
261 } 246 }
262 247
263 early_acpi_os_unmap_memory((char *)table_header, tbl_size); 248 early_acpi_os_unmap_memory((char *)table_header, tbl_size);
@@ -322,13 +307,11 @@ static void __init check_multiple_madt(void)
322 307
323 acpi_get_table_with_size(ACPI_SIG_MADT, 2, &table, &tbl_size); 308 acpi_get_table_with_size(ACPI_SIG_MADT, 2, &table, &tbl_size);
324 if (table) { 309 if (table) {
325 printk(KERN_WARNING PREFIX 310 pr_warn("BIOS bug: multiple APIC/MADT found, using %d\n",
326 "BIOS bug: multiple APIC/MADT found," 311 acpi_apic_instance);
327 " using %d\n", acpi_apic_instance); 312 pr_warn("If \"acpi_apic_instance=%d\" works better, "
328 printk(KERN_WARNING PREFIX 313 "notify linux-acpi@vger.kernel.org\n",
329 "If \"acpi_apic_instance=%d\" works better, " 314 acpi_apic_instance ? 0 : 2);
330 "notify linux-acpi@vger.kernel.org\n",
331 acpi_apic_instance ? 0 : 2);
332 early_acpi_os_unmap_memory(table, tbl_size); 315 early_acpi_os_unmap_memory(table, tbl_size);
333 316
334 } else 317 } else
@@ -365,8 +348,7 @@ static int __init acpi_parse_apic_instance(char *str)
365 348
366 acpi_apic_instance = simple_strtoul(str, NULL, 0); 349 acpi_apic_instance = simple_strtoul(str, NULL, 0);
367 350
368 printk(KERN_NOTICE PREFIX "Shall use APIC/MADT table %d\n", 351 pr_notice("Shall use APIC/MADT table %d\n", acpi_apic_instance);
369 acpi_apic_instance);
370 352
371 return 0; 353 return 0;
372} 354}
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 08626c851be7..964068553334 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -43,6 +43,7 @@
43#include <linux/device.h> 43#include <linux/device.h>
44#include <linux/thermal.h> 44#include <linux/thermal.h>
45#include <linux/acpi.h> 45#include <linux/acpi.h>
46#include <linux/workqueue.h>
46#include <asm/uaccess.h> 47#include <asm/uaccess.h>
47 48
48#define PREFIX "ACPI: " 49#define PREFIX "ACPI: "
@@ -90,6 +91,8 @@ static int psv;
90module_param(psv, int, 0644); 91module_param(psv, int, 0644);
91MODULE_PARM_DESC(psv, "Disable or override all passive trip points."); 92MODULE_PARM_DESC(psv, "Disable or override all passive trip points.");
92 93
94static struct workqueue_struct *acpi_thermal_pm_queue;
95
93static int acpi_thermal_add(struct acpi_device *device); 96static int acpi_thermal_add(struct acpi_device *device);
94static int acpi_thermal_remove(struct acpi_device *device); 97static int acpi_thermal_remove(struct acpi_device *device);
95static void acpi_thermal_notify(struct acpi_device *device, u32 event); 98static void acpi_thermal_notify(struct acpi_device *device, u32 event);
@@ -101,11 +104,13 @@ static const struct acpi_device_id thermal_device_ids[] = {
101MODULE_DEVICE_TABLE(acpi, thermal_device_ids); 104MODULE_DEVICE_TABLE(acpi, thermal_device_ids);
102 105
103#ifdef CONFIG_PM_SLEEP 106#ifdef CONFIG_PM_SLEEP
107static int acpi_thermal_suspend(struct device *dev);
104static int acpi_thermal_resume(struct device *dev); 108static int acpi_thermal_resume(struct device *dev);
105#else 109#else
110#define acpi_thermal_suspend NULL
106#define acpi_thermal_resume NULL 111#define acpi_thermal_resume NULL
107#endif 112#endif
108static SIMPLE_DEV_PM_OPS(acpi_thermal_pm, NULL, acpi_thermal_resume); 113static SIMPLE_DEV_PM_OPS(acpi_thermal_pm, acpi_thermal_suspend, acpi_thermal_resume);
109 114
110static struct acpi_driver acpi_thermal_driver = { 115static struct acpi_driver acpi_thermal_driver = {
111 .name = "thermal", 116 .name = "thermal",
@@ -186,6 +191,7 @@ struct acpi_thermal {
186 struct thermal_zone_device *thermal_zone; 191 struct thermal_zone_device *thermal_zone;
187 int tz_enabled; 192 int tz_enabled;
188 int kelvin_offset; 193 int kelvin_offset;
194 struct work_struct thermal_check_work;
189}; 195};
190 196
191/* -------------------------------------------------------------------------- 197/* --------------------------------------------------------------------------
@@ -1064,6 +1070,13 @@ static void acpi_thermal_guess_offset(struct acpi_thermal *tz)
1064 tz->kelvin_offset = 2732; 1070 tz->kelvin_offset = 2732;
1065} 1071}
1066 1072
1073static void acpi_thermal_check_fn(struct work_struct *work)
1074{
1075 struct acpi_thermal *tz = container_of(work, struct acpi_thermal,
1076 thermal_check_work);
1077 acpi_thermal_check(tz);
1078}
1079
1067static int acpi_thermal_add(struct acpi_device *device) 1080static int acpi_thermal_add(struct acpi_device *device)
1068{ 1081{
1069 int result = 0; 1082 int result = 0;
@@ -1093,6 +1106,8 @@ static int acpi_thermal_add(struct acpi_device *device)
1093 if (result) 1106 if (result)
1094 goto free_memory; 1107 goto free_memory;
1095 1108
1109 INIT_WORK(&tz->thermal_check_work, acpi_thermal_check_fn);
1110
1096 pr_info(PREFIX "%s [%s] (%ld C)\n", acpi_device_name(device), 1111 pr_info(PREFIX "%s [%s] (%ld C)\n", acpi_device_name(device),
1097 acpi_device_bid(device), KELVIN_TO_CELSIUS(tz->temperature)); 1112 acpi_device_bid(device), KELVIN_TO_CELSIUS(tz->temperature));
1098 goto end; 1113 goto end;
@@ -1110,6 +1125,7 @@ static int acpi_thermal_remove(struct acpi_device *device)
1110 if (!device || !acpi_driver_data(device)) 1125 if (!device || !acpi_driver_data(device))
1111 return -EINVAL; 1126 return -EINVAL;
1112 1127
1128 flush_workqueue(acpi_thermal_pm_queue);
1113 tz = acpi_driver_data(device); 1129 tz = acpi_driver_data(device);
1114 1130
1115 acpi_thermal_unregister_thermal_zone(tz); 1131 acpi_thermal_unregister_thermal_zone(tz);
@@ -1118,6 +1134,13 @@ static int acpi_thermal_remove(struct acpi_device *device)
1118} 1134}
1119 1135
1120#ifdef CONFIG_PM_SLEEP 1136#ifdef CONFIG_PM_SLEEP
1137static int acpi_thermal_suspend(struct device *dev)
1138{
1139 /* Make sure the previously queued thermal check work has been done */
1140 flush_workqueue(acpi_thermal_pm_queue);
1141 return 0;
1142}
1143
1121static int acpi_thermal_resume(struct device *dev) 1144static int acpi_thermal_resume(struct device *dev)
1122{ 1145{
1123 struct acpi_thermal *tz; 1146 struct acpi_thermal *tz;
@@ -1148,7 +1171,7 @@ static int acpi_thermal_resume(struct device *dev)
1148 tz->state.active |= tz->trips.active[i].flags.enabled; 1171 tz->state.active |= tz->trips.active[i].flags.enabled;
1149 } 1172 }
1150 1173
1151 acpi_thermal_check(tz); 1174 queue_work(acpi_thermal_pm_queue, &tz->thermal_check_work);
1152 1175
1153 return AE_OK; 1176 return AE_OK;
1154} 1177}
@@ -1240,16 +1263,22 @@ static int __init acpi_thermal_init(void)
1240 return -ENODEV; 1263 return -ENODEV;
1241 } 1264 }
1242 1265
1266 acpi_thermal_pm_queue = create_workqueue("acpi_thermal_pm");
1267 if (!acpi_thermal_pm_queue)
1268 return -ENODEV;
1269
1243 result = acpi_bus_register_driver(&acpi_thermal_driver); 1270 result = acpi_bus_register_driver(&acpi_thermal_driver);
1244 if (result < 0) 1271 if (result < 0) {
1272 destroy_workqueue(acpi_thermal_pm_queue);
1245 return -ENODEV; 1273 return -ENODEV;
1274 }
1246 1275
1247 return 0; 1276 return 0;
1248} 1277}
1249 1278
1250static void __exit acpi_thermal_exit(void) 1279static void __exit acpi_thermal_exit(void)
1251{ 1280{
1252 1281 destroy_workqueue(acpi_thermal_pm_queue);
1253 acpi_bus_unregister_driver(&acpi_thermal_driver); 1282 acpi_bus_unregister_driver(&acpi_thermal_driver);
1254 1283
1255 return; 1284 return;
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index 85e3b612bdc0..0f5f78fa6545 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -422,7 +422,7 @@ out:
422EXPORT_SYMBOL(acpi_get_physical_device_location); 422EXPORT_SYMBOL(acpi_get_physical_device_location);
423 423
424/** 424/**
425 * acpi_evaluate_hotplug_ost: Evaluate _OST for hotplug operations 425 * acpi_evaluate_ost: Evaluate _OST for hotplug operations
426 * @handle: ACPI device handle 426 * @handle: ACPI device handle
427 * @source_event: source event code 427 * @source_event: source event code
428 * @status_code: status code 428 * @status_code: status code
@@ -433,17 +433,15 @@ EXPORT_SYMBOL(acpi_get_physical_device_location);
433 * When the platform does not support _OST, this function has no effect. 433 * When the platform does not support _OST, this function has no effect.
434 */ 434 */
435acpi_status 435acpi_status
436acpi_evaluate_hotplug_ost(acpi_handle handle, u32 source_event, 436acpi_evaluate_ost(acpi_handle handle, u32 source_event, u32 status_code,
437 u32 status_code, struct acpi_buffer *status_buf) 437 struct acpi_buffer *status_buf)
438{ 438{
439#ifdef ACPI_HOTPLUG_OST
440 union acpi_object params[3] = { 439 union acpi_object params[3] = {
441 {.type = ACPI_TYPE_INTEGER,}, 440 {.type = ACPI_TYPE_INTEGER,},
442 {.type = ACPI_TYPE_INTEGER,}, 441 {.type = ACPI_TYPE_INTEGER,},
443 {.type = ACPI_TYPE_BUFFER,} 442 {.type = ACPI_TYPE_BUFFER,}
444 }; 443 };
445 struct acpi_object_list arg_list = {3, params}; 444 struct acpi_object_list arg_list = {3, params};
446 acpi_status status;
447 445
448 params[0].integer.value = source_event; 446 params[0].integer.value = source_event;
449 params[1].integer.value = status_code; 447 params[1].integer.value = status_code;
@@ -455,13 +453,9 @@ acpi_evaluate_hotplug_ost(acpi_handle handle, u32 source_event,
455 params[2].buffer.length = 0; 453 params[2].buffer.length = 0;
456 } 454 }
457 455
458 status = acpi_evaluate_object(handle, "_OST", &arg_list, NULL); 456 return acpi_evaluate_object(handle, "_OST", &arg_list, NULL);
459 return status;
460#else
461 return AE_OK;
462#endif
463} 457}
464EXPORT_SYMBOL(acpi_evaluate_hotplug_ost); 458EXPORT_SYMBOL(acpi_evaluate_ost);
465 459
466/** 460/**
467 * acpi_handle_printk: Print message with ACPI prefix and object path 461 * acpi_handle_printk: Print message with ACPI prefix and object path
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index b6ba88ed31ae..48c7e8af9c96 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -45,8 +45,6 @@
45 45
46#include "internal.h" 46#include "internal.h"
47 47
48#define PREFIX "ACPI: "
49
50#define ACPI_VIDEO_BUS_NAME "Video Bus" 48#define ACPI_VIDEO_BUS_NAME "Video Bus"
51#define ACPI_VIDEO_DEVICE_NAME "Video Device" 49#define ACPI_VIDEO_DEVICE_NAME "Video Device"
52#define ACPI_VIDEO_NOTIFY_SWITCH 0x80 50#define ACPI_VIDEO_NOTIFY_SWITCH 0x80
diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
index 19080c8e2f2a..33e3db548a29 100644
--- a/drivers/acpi/video_detect.c
+++ b/drivers/acpi/video_detect.c
@@ -40,8 +40,6 @@
40 40
41#include "internal.h" 41#include "internal.h"
42 42
43#define PREFIX "ACPI: "
44
45ACPI_MODULE_NAME("video"); 43ACPI_MODULE_NAME("video");
46#define _COMPONENT ACPI_VIDEO_COMPONENT 44#define _COMPONENT ACPI_VIDEO_COMPONENT
47 45
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index b4f7cc2522d9..97a14fe47de1 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -38,6 +38,16 @@ static void ata_acpi_clear_gtf(struct ata_device *dev)
38 dev->gtf_cache = NULL; 38 dev->gtf_cache = NULL;
39} 39}
40 40
41struct ata_acpi_hotplug_context {
42 struct acpi_hotplug_context hp;
43 union {
44 struct ata_port *ap;
45 struct ata_device *dev;
46 } data;
47};
48
49#define ata_hotplug_data(context) (container_of((context), struct ata_acpi_hotplug_context, hp)->data)
50
41/** 51/**
42 * ata_dev_acpi_handle - provide the acpi_handle for an ata_device 52 * ata_dev_acpi_handle - provide the acpi_handle for an ata_device
43 * @dev: the acpi_handle returned will correspond to this device 53 * @dev: the acpi_handle returned will correspond to this device
@@ -121,18 +131,17 @@ static void ata_acpi_handle_hotplug(struct ata_port *ap, struct ata_device *dev,
121 ata_port_wait_eh(ap); 131 ata_port_wait_eh(ap);
122} 132}
123 133
124static void ata_acpi_dev_notify_dock(acpi_handle handle, u32 event, void *data) 134static int ata_acpi_dev_notify_dock(struct acpi_device *adev, u32 event)
125{ 135{
126 struct ata_device *dev = data; 136 struct ata_device *dev = ata_hotplug_data(adev->hp).dev;
127
128 ata_acpi_handle_hotplug(dev->link->ap, dev, event); 137 ata_acpi_handle_hotplug(dev->link->ap, dev, event);
138 return 0;
129} 139}
130 140
131static void ata_acpi_ap_notify_dock(acpi_handle handle, u32 event, void *data) 141static int ata_acpi_ap_notify_dock(struct acpi_device *adev, u32 event)
132{ 142{
133 struct ata_port *ap = data; 143 ata_acpi_handle_hotplug(ata_hotplug_data(adev->hp).ap, NULL, event);
134 144 return 0;
135 ata_acpi_handle_hotplug(ap, NULL, event);
136} 145}
137 146
138static void ata_acpi_uevent(struct ata_port *ap, struct ata_device *dev, 147static void ata_acpi_uevent(struct ata_port *ap, struct ata_device *dev,
@@ -154,31 +163,23 @@ static void ata_acpi_uevent(struct ata_port *ap, struct ata_device *dev,
154 } 163 }
155} 164}
156 165
157static void ata_acpi_ap_uevent(acpi_handle handle, u32 event, void *data) 166static void ata_acpi_ap_uevent(struct acpi_device *adev, u32 event)
158{ 167{
159 ata_acpi_uevent(data, NULL, event); 168 ata_acpi_uevent(ata_hotplug_data(adev->hp).ap, NULL, event);
160} 169}
161 170
162static void ata_acpi_dev_uevent(acpi_handle handle, u32 event, void *data) 171static void ata_acpi_dev_uevent(struct acpi_device *adev, u32 event)
163{ 172{
164 struct ata_device *dev = data; 173 struct ata_device *dev = ata_hotplug_data(adev->hp).dev;
165 ata_acpi_uevent(dev->link->ap, dev, event); 174 ata_acpi_uevent(dev->link->ap, dev, event);
166} 175}
167 176
168static const struct acpi_dock_ops ata_acpi_dev_dock_ops = {
169 .handler = ata_acpi_dev_notify_dock,
170 .uevent = ata_acpi_dev_uevent,
171};
172
173static const struct acpi_dock_ops ata_acpi_ap_dock_ops = {
174 .handler = ata_acpi_ap_notify_dock,
175 .uevent = ata_acpi_ap_uevent,
176};
177
178/* bind acpi handle to pata port */ 177/* bind acpi handle to pata port */
179void ata_acpi_bind_port(struct ata_port *ap) 178void ata_acpi_bind_port(struct ata_port *ap)
180{ 179{
181 struct acpi_device *host_companion = ACPI_COMPANION(ap->host->dev); 180 struct acpi_device *host_companion = ACPI_COMPANION(ap->host->dev);
181 struct acpi_device *adev;
182 struct ata_acpi_hotplug_context *context;
182 183
183 if (libata_noacpi || ap->flags & ATA_FLAG_ACPI_SATA || !host_companion) 184 if (libata_noacpi || ap->flags & ATA_FLAG_ACPI_SATA || !host_companion)
184 return; 185 return;
@@ -188,9 +189,17 @@ void ata_acpi_bind_port(struct ata_port *ap)
188 if (ata_acpi_gtm(ap, &ap->__acpi_init_gtm) == 0) 189 if (ata_acpi_gtm(ap, &ap->__acpi_init_gtm) == 0)
189 ap->pflags |= ATA_PFLAG_INIT_GTM_VALID; 190 ap->pflags |= ATA_PFLAG_INIT_GTM_VALID;
190 191
191 /* we might be on a docking station */ 192 adev = ACPI_COMPANION(&ap->tdev);
192 register_hotplug_dock_device(ACPI_HANDLE(&ap->tdev), 193 if (!adev || adev->hp)
193 &ata_acpi_ap_dock_ops, ap, NULL, NULL); 194 return;
195
196 context = kzalloc(sizeof(*context), GFP_KERNEL);
197 if (!context)
198 return;
199
200 context->data.ap = ap;
201 acpi_initialize_hp_context(adev, &context->hp, ata_acpi_ap_notify_dock,
202 ata_acpi_ap_uevent);
194} 203}
195 204
196void ata_acpi_bind_dev(struct ata_device *dev) 205void ata_acpi_bind_dev(struct ata_device *dev)
@@ -198,7 +207,8 @@ void ata_acpi_bind_dev(struct ata_device *dev)
198 struct ata_port *ap = dev->link->ap; 207 struct ata_port *ap = dev->link->ap;
199 struct acpi_device *port_companion = ACPI_COMPANION(&ap->tdev); 208 struct acpi_device *port_companion = ACPI_COMPANION(&ap->tdev);
200 struct acpi_device *host_companion = ACPI_COMPANION(ap->host->dev); 209 struct acpi_device *host_companion = ACPI_COMPANION(ap->host->dev);
201 struct acpi_device *parent; 210 struct acpi_device *parent, *adev;
211 struct ata_acpi_hotplug_context *context;
202 u64 adr; 212 u64 adr;
203 213
204 /* 214 /*
@@ -221,9 +231,17 @@ void ata_acpi_bind_dev(struct ata_device *dev)
221 } 231 }
222 232
223 acpi_preset_companion(&dev->tdev, parent, adr); 233 acpi_preset_companion(&dev->tdev, parent, adr);
234 adev = ACPI_COMPANION(&dev->tdev);
235 if (!adev || adev->hp)
236 return;
237
238 context = kzalloc(sizeof(*context), GFP_KERNEL);
239 if (!context)
240 return;
224 241
225 register_hotplug_dock_device(ata_dev_acpi_handle(dev), 242 context->data.dev = dev;
226 &ata_acpi_dev_dock_ops, dev, NULL, NULL); 243 acpi_initialize_hp_context(adev, &context->hp, ata_acpi_dev_notify_dock,
244 ata_acpi_dev_uevent);
227} 245}
228 246
229/** 247/**
diff --git a/drivers/base/power/Makefile b/drivers/base/power/Makefile
index 2e58ebb1f6c0..1cb8544598d5 100644
--- a/drivers/base/power/Makefile
+++ b/drivers/base/power/Makefile
@@ -1,6 +1,5 @@
1obj-$(CONFIG_PM) += sysfs.o generic_ops.o common.o qos.o 1obj-$(CONFIG_PM) += sysfs.o generic_ops.o common.o qos.o runtime.o
2obj-$(CONFIG_PM_SLEEP) += main.o wakeup.o 2obj-$(CONFIG_PM_SLEEP) += main.o wakeup.o
3obj-$(CONFIG_PM_RUNTIME) += runtime.o
4obj-$(CONFIG_PM_TRACE_RTC) += trace.o 3obj-$(CONFIG_PM_TRACE_RTC) += trace.o
5obj-$(CONFIG_PM_OPP) += opp.o 4obj-$(CONFIG_PM_OPP) += opp.o
6obj-$(CONFIG_PM_GENERIC_DOMAINS) += domain.o domain_governor.o 5obj-$(CONFIG_PM_GENERIC_DOMAINS) += domain.o domain_governor.o
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index bfb8955c406c..dc127e5dec4b 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -42,7 +42,7 @@
42 struct gpd_timing_data *__td = &dev_gpd_data(dev)->td; \ 42 struct gpd_timing_data *__td = &dev_gpd_data(dev)->td; \
43 if (!__retval && __elapsed > __td->field) { \ 43 if (!__retval && __elapsed > __td->field) { \
44 __td->field = __elapsed; \ 44 __td->field = __elapsed; \
45 dev_warn(dev, name " latency exceeded, new value %lld ns\n", \ 45 dev_dbg(dev, name " latency exceeded, new value %lld ns\n", \
46 __elapsed); \ 46 __elapsed); \
47 genpd->max_off_time_changed = true; \ 47 genpd->max_off_time_changed = true; \
48 __td->constraint_changed = true; \ 48 __td->constraint_changed = true; \
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 1b41fca3d65a..86d5e4fb5b98 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -29,6 +29,7 @@
29#include <linux/async.h> 29#include <linux/async.h>
30#include <linux/suspend.h> 30#include <linux/suspend.h>
31#include <trace/events/power.h> 31#include <trace/events/power.h>
32#include <linux/cpufreq.h>
32#include <linux/cpuidle.h> 33#include <linux/cpuidle.h>
33#include <linux/timer.h> 34#include <linux/timer.h>
34 35
@@ -91,6 +92,8 @@ void device_pm_sleep_init(struct device *dev)
91{ 92{
92 dev->power.is_prepared = false; 93 dev->power.is_prepared = false;
93 dev->power.is_suspended = false; 94 dev->power.is_suspended = false;
95 dev->power.is_noirq_suspended = false;
96 dev->power.is_late_suspended = false;
94 init_completion(&dev->power.completion); 97 init_completion(&dev->power.completion);
95 complete_all(&dev->power.completion); 98 complete_all(&dev->power.completion);
96 dev->power.wakeup = NULL; 99 dev->power.wakeup = NULL;
@@ -467,7 +470,7 @@ static void dpm_watchdog_clear(struct dpm_watchdog *wd)
467 * The driver of @dev will not receive interrupts while this function is being 470 * The driver of @dev will not receive interrupts while this function is being
468 * executed. 471 * executed.
469 */ 472 */
470static int device_resume_noirq(struct device *dev, pm_message_t state) 473static int device_resume_noirq(struct device *dev, pm_message_t state, bool async)
471{ 474{
472 pm_callback_t callback = NULL; 475 pm_callback_t callback = NULL;
473 char *info = NULL; 476 char *info = NULL;
@@ -479,6 +482,11 @@ static int device_resume_noirq(struct device *dev, pm_message_t state)
479 if (dev->power.syscore) 482 if (dev->power.syscore)
480 goto Out; 483 goto Out;
481 484
485 if (!dev->power.is_noirq_suspended)
486 goto Out;
487
488 dpm_wait(dev->parent, async);
489
482 if (dev->pm_domain) { 490 if (dev->pm_domain) {
483 info = "noirq power domain "; 491 info = "noirq power domain ";
484 callback = pm_noirq_op(&dev->pm_domain->ops, state); 492 callback = pm_noirq_op(&dev->pm_domain->ops, state);
@@ -499,12 +507,32 @@ static int device_resume_noirq(struct device *dev, pm_message_t state)
499 } 507 }
500 508
501 error = dpm_run_callback(callback, dev, state, info); 509 error = dpm_run_callback(callback, dev, state, info);
510 dev->power.is_noirq_suspended = false;
502 511
503 Out: 512 Out:
513 complete_all(&dev->power.completion);
504 TRACE_RESUME(error); 514 TRACE_RESUME(error);
505 return error; 515 return error;
506} 516}
507 517
518static bool is_async(struct device *dev)
519{
520 return dev->power.async_suspend && pm_async_enabled
521 && !pm_trace_is_enabled();
522}
523
524static void async_resume_noirq(void *data, async_cookie_t cookie)
525{
526 struct device *dev = (struct device *)data;
527 int error;
528
529 error = device_resume_noirq(dev, pm_transition, true);
530 if (error)
531 pm_dev_err(dev, pm_transition, " async", error);
532
533 put_device(dev);
534}
535
508/** 536/**
509 * dpm_resume_noirq - Execute "noirq resume" callbacks for all devices. 537 * dpm_resume_noirq - Execute "noirq resume" callbacks for all devices.
510 * @state: PM transition of the system being carried out. 538 * @state: PM transition of the system being carried out.
@@ -514,29 +542,48 @@ static int device_resume_noirq(struct device *dev, pm_message_t state)
514 */ 542 */
515static void dpm_resume_noirq(pm_message_t state) 543static void dpm_resume_noirq(pm_message_t state)
516{ 544{
545 struct device *dev;
517 ktime_t starttime = ktime_get(); 546 ktime_t starttime = ktime_get();
518 547
519 mutex_lock(&dpm_list_mtx); 548 mutex_lock(&dpm_list_mtx);
520 while (!list_empty(&dpm_noirq_list)) { 549 pm_transition = state;
521 struct device *dev = to_device(dpm_noirq_list.next);
522 int error;
523 550
551 /*
552 * Advanced the async threads upfront,
553 * in case the starting of async threads is
554 * delayed by non-async resuming devices.
555 */
556 list_for_each_entry(dev, &dpm_noirq_list, power.entry) {
557 reinit_completion(&dev->power.completion);
558 if (is_async(dev)) {
559 get_device(dev);
560 async_schedule(async_resume_noirq, dev);
561 }
562 }
563
564 while (!list_empty(&dpm_noirq_list)) {
565 dev = to_device(dpm_noirq_list.next);
524 get_device(dev); 566 get_device(dev);
525 list_move_tail(&dev->power.entry, &dpm_late_early_list); 567 list_move_tail(&dev->power.entry, &dpm_late_early_list);
526 mutex_unlock(&dpm_list_mtx); 568 mutex_unlock(&dpm_list_mtx);
527 569
528 error = device_resume_noirq(dev, state); 570 if (!is_async(dev)) {
529 if (error) { 571 int error;
530 suspend_stats.failed_resume_noirq++; 572
531 dpm_save_failed_step(SUSPEND_RESUME_NOIRQ); 573 error = device_resume_noirq(dev, state, false);
532 dpm_save_failed_dev(dev_name(dev)); 574 if (error) {
533 pm_dev_err(dev, state, " noirq", error); 575 suspend_stats.failed_resume_noirq++;
576 dpm_save_failed_step(SUSPEND_RESUME_NOIRQ);
577 dpm_save_failed_dev(dev_name(dev));
578 pm_dev_err(dev, state, " noirq", error);
579 }
534 } 580 }
535 581
536 mutex_lock(&dpm_list_mtx); 582 mutex_lock(&dpm_list_mtx);
537 put_device(dev); 583 put_device(dev);
538 } 584 }
539 mutex_unlock(&dpm_list_mtx); 585 mutex_unlock(&dpm_list_mtx);
586 async_synchronize_full();
540 dpm_show_time(starttime, state, "noirq"); 587 dpm_show_time(starttime, state, "noirq");
541 resume_device_irqs(); 588 resume_device_irqs();
542 cpuidle_resume(); 589 cpuidle_resume();
@@ -549,7 +596,7 @@ static void dpm_resume_noirq(pm_message_t state)
549 * 596 *
550 * Runtime PM is disabled for @dev while this function is being executed. 597 * Runtime PM is disabled for @dev while this function is being executed.
551 */ 598 */
552static int device_resume_early(struct device *dev, pm_message_t state) 599static int device_resume_early(struct device *dev, pm_message_t state, bool async)
553{ 600{
554 pm_callback_t callback = NULL; 601 pm_callback_t callback = NULL;
555 char *info = NULL; 602 char *info = NULL;
@@ -561,6 +608,11 @@ static int device_resume_early(struct device *dev, pm_message_t state)
561 if (dev->power.syscore) 608 if (dev->power.syscore)
562 goto Out; 609 goto Out;
563 610
611 if (!dev->power.is_late_suspended)
612 goto Out;
613
614 dpm_wait(dev->parent, async);
615
564 if (dev->pm_domain) { 616 if (dev->pm_domain) {
565 info = "early power domain "; 617 info = "early power domain ";
566 callback = pm_late_early_op(&dev->pm_domain->ops, state); 618 callback = pm_late_early_op(&dev->pm_domain->ops, state);
@@ -581,43 +633,75 @@ static int device_resume_early(struct device *dev, pm_message_t state)
581 } 633 }
582 634
583 error = dpm_run_callback(callback, dev, state, info); 635 error = dpm_run_callback(callback, dev, state, info);
636 dev->power.is_late_suspended = false;
584 637
585 Out: 638 Out:
586 TRACE_RESUME(error); 639 TRACE_RESUME(error);
587 640
588 pm_runtime_enable(dev); 641 pm_runtime_enable(dev);
642 complete_all(&dev->power.completion);
589 return error; 643 return error;
590} 644}
591 645
646static void async_resume_early(void *data, async_cookie_t cookie)
647{
648 struct device *dev = (struct device *)data;
649 int error;
650
651 error = device_resume_early(dev, pm_transition, true);
652 if (error)
653 pm_dev_err(dev, pm_transition, " async", error);
654
655 put_device(dev);
656}
657
592/** 658/**
593 * dpm_resume_early - Execute "early resume" callbacks for all devices. 659 * dpm_resume_early - Execute "early resume" callbacks for all devices.
594 * @state: PM transition of the system being carried out. 660 * @state: PM transition of the system being carried out.
595 */ 661 */
596static void dpm_resume_early(pm_message_t state) 662static void dpm_resume_early(pm_message_t state)
597{ 663{
664 struct device *dev;
598 ktime_t starttime = ktime_get(); 665 ktime_t starttime = ktime_get();
599 666
600 mutex_lock(&dpm_list_mtx); 667 mutex_lock(&dpm_list_mtx);
601 while (!list_empty(&dpm_late_early_list)) { 668 pm_transition = state;
602 struct device *dev = to_device(dpm_late_early_list.next);
603 int error;
604 669
670 /*
671 * Advanced the async threads upfront,
672 * in case the starting of async threads is
673 * delayed by non-async resuming devices.
674 */
675 list_for_each_entry(dev, &dpm_late_early_list, power.entry) {
676 reinit_completion(&dev->power.completion);
677 if (is_async(dev)) {
678 get_device(dev);
679 async_schedule(async_resume_early, dev);
680 }
681 }
682
683 while (!list_empty(&dpm_late_early_list)) {
684 dev = to_device(dpm_late_early_list.next);
605 get_device(dev); 685 get_device(dev);
606 list_move_tail(&dev->power.entry, &dpm_suspended_list); 686 list_move_tail(&dev->power.entry, &dpm_suspended_list);
607 mutex_unlock(&dpm_list_mtx); 687 mutex_unlock(&dpm_list_mtx);
608 688
609 error = device_resume_early(dev, state); 689 if (!is_async(dev)) {
610 if (error) { 690 int error;
611 suspend_stats.failed_resume_early++;
612 dpm_save_failed_step(SUSPEND_RESUME_EARLY);
613 dpm_save_failed_dev(dev_name(dev));
614 pm_dev_err(dev, state, " early", error);
615 }
616 691
692 error = device_resume_early(dev, state, false);
693 if (error) {
694 suspend_stats.failed_resume_early++;
695 dpm_save_failed_step(SUSPEND_RESUME_EARLY);
696 dpm_save_failed_dev(dev_name(dev));
697 pm_dev_err(dev, state, " early", error);
698 }
699 }
617 mutex_lock(&dpm_list_mtx); 700 mutex_lock(&dpm_list_mtx);
618 put_device(dev); 701 put_device(dev);
619 } 702 }
620 mutex_unlock(&dpm_list_mtx); 703 mutex_unlock(&dpm_list_mtx);
704 async_synchronize_full();
621 dpm_show_time(starttime, state, "early"); 705 dpm_show_time(starttime, state, "early");
622} 706}
623 707
@@ -732,12 +816,6 @@ static void async_resume(void *data, async_cookie_t cookie)
732 put_device(dev); 816 put_device(dev);
733} 817}
734 818
735static bool is_async(struct device *dev)
736{
737 return dev->power.async_suspend && pm_async_enabled
738 && !pm_trace_is_enabled();
739}
740
741/** 819/**
742 * dpm_resume - Execute "resume" callbacks for non-sysdev devices. 820 * dpm_resume - Execute "resume" callbacks for non-sysdev devices.
743 * @state: PM transition of the system being carried out. 821 * @state: PM transition of the system being carried out.
@@ -789,6 +867,8 @@ void dpm_resume(pm_message_t state)
789 mutex_unlock(&dpm_list_mtx); 867 mutex_unlock(&dpm_list_mtx);
790 async_synchronize_full(); 868 async_synchronize_full();
791 dpm_show_time(starttime, state, NULL); 869 dpm_show_time(starttime, state, NULL);
870
871 cpufreq_resume();
792} 872}
793 873
794/** 874/**
@@ -913,13 +993,24 @@ static pm_message_t resume_event(pm_message_t sleep_state)
913 * The driver of @dev will not receive interrupts while this function is being 993 * The driver of @dev will not receive interrupts while this function is being
914 * executed. 994 * executed.
915 */ 995 */
916static int device_suspend_noirq(struct device *dev, pm_message_t state) 996static int __device_suspend_noirq(struct device *dev, pm_message_t state, bool async)
917{ 997{
918 pm_callback_t callback = NULL; 998 pm_callback_t callback = NULL;
919 char *info = NULL; 999 char *info = NULL;
1000 int error = 0;
1001
1002 if (async_error)
1003 goto Complete;
1004
1005 if (pm_wakeup_pending()) {
1006 async_error = -EBUSY;
1007 goto Complete;
1008 }
920 1009
921 if (dev->power.syscore) 1010 if (dev->power.syscore)
922 return 0; 1011 goto Complete;
1012
1013 dpm_wait_for_children(dev, async);
923 1014
924 if (dev->pm_domain) { 1015 if (dev->pm_domain) {
925 info = "noirq power domain "; 1016 info = "noirq power domain ";
@@ -940,7 +1031,41 @@ static int device_suspend_noirq(struct device *dev, pm_message_t state)
940 callback = pm_noirq_op(dev->driver->pm, state); 1031 callback = pm_noirq_op(dev->driver->pm, state);
941 } 1032 }
942 1033
943 return dpm_run_callback(callback, dev, state, info); 1034 error = dpm_run_callback(callback, dev, state, info);
1035 if (!error)
1036 dev->power.is_noirq_suspended = true;
1037 else
1038 async_error = error;
1039
1040Complete:
1041 complete_all(&dev->power.completion);
1042 return error;
1043}
1044
1045static void async_suspend_noirq(void *data, async_cookie_t cookie)
1046{
1047 struct device *dev = (struct device *)data;
1048 int error;
1049
1050 error = __device_suspend_noirq(dev, pm_transition, true);
1051 if (error) {
1052 dpm_save_failed_dev(dev_name(dev));
1053 pm_dev_err(dev, pm_transition, " async", error);
1054 }
1055
1056 put_device(dev);
1057}
1058
1059static int device_suspend_noirq(struct device *dev)
1060{
1061 reinit_completion(&dev->power.completion);
1062
1063 if (pm_async_enabled && dev->power.async_suspend) {
1064 get_device(dev);
1065 async_schedule(async_suspend_noirq, dev);
1066 return 0;
1067 }
1068 return __device_suspend_noirq(dev, pm_transition, false);
944} 1069}
945 1070
946/** 1071/**
@@ -958,19 +1083,20 @@ static int dpm_suspend_noirq(pm_message_t state)
958 cpuidle_pause(); 1083 cpuidle_pause();
959 suspend_device_irqs(); 1084 suspend_device_irqs();
960 mutex_lock(&dpm_list_mtx); 1085 mutex_lock(&dpm_list_mtx);
1086 pm_transition = state;
1087 async_error = 0;
1088
961 while (!list_empty(&dpm_late_early_list)) { 1089 while (!list_empty(&dpm_late_early_list)) {
962 struct device *dev = to_device(dpm_late_early_list.prev); 1090 struct device *dev = to_device(dpm_late_early_list.prev);
963 1091
964 get_device(dev); 1092 get_device(dev);
965 mutex_unlock(&dpm_list_mtx); 1093 mutex_unlock(&dpm_list_mtx);
966 1094
967 error = device_suspend_noirq(dev, state); 1095 error = device_suspend_noirq(dev);
968 1096
969 mutex_lock(&dpm_list_mtx); 1097 mutex_lock(&dpm_list_mtx);
970 if (error) { 1098 if (error) {
971 pm_dev_err(dev, state, " noirq", error); 1099 pm_dev_err(dev, state, " noirq", error);
972 suspend_stats.failed_suspend_noirq++;
973 dpm_save_failed_step(SUSPEND_SUSPEND_NOIRQ);
974 dpm_save_failed_dev(dev_name(dev)); 1100 dpm_save_failed_dev(dev_name(dev));
975 put_device(dev); 1101 put_device(dev);
976 break; 1102 break;
@@ -979,16 +1105,21 @@ static int dpm_suspend_noirq(pm_message_t state)
979 list_move(&dev->power.entry, &dpm_noirq_list); 1105 list_move(&dev->power.entry, &dpm_noirq_list);
980 put_device(dev); 1106 put_device(dev);
981 1107
982 if (pm_wakeup_pending()) { 1108 if (async_error)
983 error = -EBUSY;
984 break; 1109 break;
985 }
986 } 1110 }
987 mutex_unlock(&dpm_list_mtx); 1111 mutex_unlock(&dpm_list_mtx);
988 if (error) 1112 async_synchronize_full();
1113 if (!error)
1114 error = async_error;
1115
1116 if (error) {
1117 suspend_stats.failed_suspend_noirq++;
1118 dpm_save_failed_step(SUSPEND_SUSPEND_NOIRQ);
989 dpm_resume_noirq(resume_event(state)); 1119 dpm_resume_noirq(resume_event(state));
990 else 1120 } else {
991 dpm_show_time(starttime, state, "noirq"); 1121 dpm_show_time(starttime, state, "noirq");
1122 }
992 return error; 1123 return error;
993} 1124}
994 1125
@@ -999,15 +1130,26 @@ static int dpm_suspend_noirq(pm_message_t state)
999 * 1130 *
1000 * Runtime PM is disabled for @dev while this function is being executed. 1131 * Runtime PM is disabled for @dev while this function is being executed.
1001 */ 1132 */
1002static int device_suspend_late(struct device *dev, pm_message_t state) 1133static int __device_suspend_late(struct device *dev, pm_message_t state, bool async)
1003{ 1134{
1004 pm_callback_t callback = NULL; 1135 pm_callback_t callback = NULL;
1005 char *info = NULL; 1136 char *info = NULL;
1137 int error = 0;
1006 1138
1007 __pm_runtime_disable(dev, false); 1139 __pm_runtime_disable(dev, false);
1008 1140
1141 if (async_error)
1142 goto Complete;
1143
1144 if (pm_wakeup_pending()) {
1145 async_error = -EBUSY;
1146 goto Complete;
1147 }
1148
1009 if (dev->power.syscore) 1149 if (dev->power.syscore)
1010 return 0; 1150 goto Complete;
1151
1152 dpm_wait_for_children(dev, async);
1011 1153
1012 if (dev->pm_domain) { 1154 if (dev->pm_domain) {
1013 info = "late power domain "; 1155 info = "late power domain ";
@@ -1028,7 +1170,41 @@ static int device_suspend_late(struct device *dev, pm_message_t state)
1028 callback = pm_late_early_op(dev->driver->pm, state); 1170 callback = pm_late_early_op(dev->driver->pm, state);
1029 } 1171 }
1030 1172
1031 return dpm_run_callback(callback, dev, state, info); 1173 error = dpm_run_callback(callback, dev, state, info);
1174 if (!error)
1175 dev->power.is_late_suspended = true;
1176 else
1177 async_error = error;
1178
1179Complete:
1180 complete_all(&dev->power.completion);
1181 return error;
1182}
1183
1184static void async_suspend_late(void *data, async_cookie_t cookie)
1185{
1186 struct device *dev = (struct device *)data;
1187 int error;
1188
1189 error = __device_suspend_late(dev, pm_transition, true);
1190 if (error) {
1191 dpm_save_failed_dev(dev_name(dev));
1192 pm_dev_err(dev, pm_transition, " async", error);
1193 }
1194 put_device(dev);
1195}
1196
1197static int device_suspend_late(struct device *dev)
1198{
1199 reinit_completion(&dev->power.completion);
1200
1201 if (pm_async_enabled && dev->power.async_suspend) {
1202 get_device(dev);
1203 async_schedule(async_suspend_late, dev);
1204 return 0;
1205 }
1206
1207 return __device_suspend_late(dev, pm_transition, false);
1032} 1208}
1033 1209
1034/** 1210/**
@@ -1041,19 +1217,20 @@ static int dpm_suspend_late(pm_message_t state)
1041 int error = 0; 1217 int error = 0;
1042 1218
1043 mutex_lock(&dpm_list_mtx); 1219 mutex_lock(&dpm_list_mtx);
1220 pm_transition = state;
1221 async_error = 0;
1222
1044 while (!list_empty(&dpm_suspended_list)) { 1223 while (!list_empty(&dpm_suspended_list)) {
1045 struct device *dev = to_device(dpm_suspended_list.prev); 1224 struct device *dev = to_device(dpm_suspended_list.prev);
1046 1225
1047 get_device(dev); 1226 get_device(dev);
1048 mutex_unlock(&dpm_list_mtx); 1227 mutex_unlock(&dpm_list_mtx);
1049 1228
1050 error = device_suspend_late(dev, state); 1229 error = device_suspend_late(dev);
1051 1230
1052 mutex_lock(&dpm_list_mtx); 1231 mutex_lock(&dpm_list_mtx);
1053 if (error) { 1232 if (error) {
1054 pm_dev_err(dev, state, " late", error); 1233 pm_dev_err(dev, state, " late", error);
1055 suspend_stats.failed_suspend_late++;
1056 dpm_save_failed_step(SUSPEND_SUSPEND_LATE);
1057 dpm_save_failed_dev(dev_name(dev)); 1234 dpm_save_failed_dev(dev_name(dev));
1058 put_device(dev); 1235 put_device(dev);
1059 break; 1236 break;
@@ -1062,17 +1239,18 @@ static int dpm_suspend_late(pm_message_t state)
1062 list_move(&dev->power.entry, &dpm_late_early_list); 1239 list_move(&dev->power.entry, &dpm_late_early_list);
1063 put_device(dev); 1240 put_device(dev);
1064 1241
1065 if (pm_wakeup_pending()) { 1242 if (async_error)
1066 error = -EBUSY;
1067 break; 1243 break;
1068 }
1069 } 1244 }
1070 mutex_unlock(&dpm_list_mtx); 1245 mutex_unlock(&dpm_list_mtx);
1071 if (error) 1246 async_synchronize_full();
1247 if (error) {
1248 suspend_stats.failed_suspend_late++;
1249 dpm_save_failed_step(SUSPEND_SUSPEND_LATE);
1072 dpm_resume_early(resume_event(state)); 1250 dpm_resume_early(resume_event(state));
1073 else 1251 } else {
1074 dpm_show_time(starttime, state, "late"); 1252 dpm_show_time(starttime, state, "late");
1075 1253 }
1076 return error; 1254 return error;
1077} 1255}
1078 1256
@@ -1259,6 +1437,8 @@ int dpm_suspend(pm_message_t state)
1259 1437
1260 might_sleep(); 1438 might_sleep();
1261 1439
1440 cpufreq_suspend();
1441
1262 mutex_lock(&dpm_list_mtx); 1442 mutex_lock(&dpm_list_mtx);
1263 pm_transition = state; 1443 pm_transition = state;
1264 async_error = 0; 1444 async_error = 0;
diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h
index cfc3226ec492..a21223d95926 100644
--- a/drivers/base/power/power.h
+++ b/drivers/base/power/power.h
@@ -89,8 +89,8 @@ extern void dpm_sysfs_remove(struct device *dev);
89extern void rpm_sysfs_remove(struct device *dev); 89extern void rpm_sysfs_remove(struct device *dev);
90extern int wakeup_sysfs_add(struct device *dev); 90extern int wakeup_sysfs_add(struct device *dev);
91extern void wakeup_sysfs_remove(struct device *dev); 91extern void wakeup_sysfs_remove(struct device *dev);
92extern int pm_qos_sysfs_add_latency(struct device *dev); 92extern int pm_qos_sysfs_add_resume_latency(struct device *dev);
93extern void pm_qos_sysfs_remove_latency(struct device *dev); 93extern void pm_qos_sysfs_remove_resume_latency(struct device *dev);
94extern int pm_qos_sysfs_add_flags(struct device *dev); 94extern int pm_qos_sysfs_add_flags(struct device *dev);
95extern void pm_qos_sysfs_remove_flags(struct device *dev); 95extern void pm_qos_sysfs_remove_flags(struct device *dev);
96 96
diff --git a/drivers/base/power/qos.c b/drivers/base/power/qos.c
index 5c1361a9e5dd..36b9eb4862cb 100644
--- a/drivers/base/power/qos.c
+++ b/drivers/base/power/qos.c
@@ -105,7 +105,7 @@ EXPORT_SYMBOL_GPL(dev_pm_qos_flags);
105s32 __dev_pm_qos_read_value(struct device *dev) 105s32 __dev_pm_qos_read_value(struct device *dev)
106{ 106{
107 return IS_ERR_OR_NULL(dev->power.qos) ? 107 return IS_ERR_OR_NULL(dev->power.qos) ?
108 0 : pm_qos_read_value(&dev->power.qos->latency); 108 0 : pm_qos_read_value(&dev->power.qos->resume_latency);
109} 109}
110 110
111/** 111/**
@@ -141,16 +141,24 @@ static int apply_constraint(struct dev_pm_qos_request *req,
141 int ret; 141 int ret;
142 142
143 switch(req->type) { 143 switch(req->type) {
144 case DEV_PM_QOS_LATENCY: 144 case DEV_PM_QOS_RESUME_LATENCY:
145 ret = pm_qos_update_target(&qos->latency, &req->data.pnode, 145 ret = pm_qos_update_target(&qos->resume_latency,
146 action, value); 146 &req->data.pnode, action, value);
147 if (ret) { 147 if (ret) {
148 value = pm_qos_read_value(&qos->latency); 148 value = pm_qos_read_value(&qos->resume_latency);
149 blocking_notifier_call_chain(&dev_pm_notifiers, 149 blocking_notifier_call_chain(&dev_pm_notifiers,
150 (unsigned long)value, 150 (unsigned long)value,
151 req); 151 req);
152 } 152 }
153 break; 153 break;
154 case DEV_PM_QOS_LATENCY_TOLERANCE:
155 ret = pm_qos_update_target(&qos->latency_tolerance,
156 &req->data.pnode, action, value);
157 if (ret) {
158 value = pm_qos_read_value(&qos->latency_tolerance);
159 req->dev->power.set_latency_tolerance(req->dev, value);
160 }
161 break;
154 case DEV_PM_QOS_FLAGS: 162 case DEV_PM_QOS_FLAGS:
155 ret = pm_qos_update_flags(&qos->flags, &req->data.flr, 163 ret = pm_qos_update_flags(&qos->flags, &req->data.flr,
156 action, value); 164 action, value);
@@ -186,13 +194,21 @@ static int dev_pm_qos_constraints_allocate(struct device *dev)
186 } 194 }
187 BLOCKING_INIT_NOTIFIER_HEAD(n); 195 BLOCKING_INIT_NOTIFIER_HEAD(n);
188 196
189 c = &qos->latency; 197 c = &qos->resume_latency;
190 plist_head_init(&c->list); 198 plist_head_init(&c->list);
191 c->target_value = PM_QOS_DEV_LAT_DEFAULT_VALUE; 199 c->target_value = PM_QOS_RESUME_LATENCY_DEFAULT_VALUE;
192 c->default_value = PM_QOS_DEV_LAT_DEFAULT_VALUE; 200 c->default_value = PM_QOS_RESUME_LATENCY_DEFAULT_VALUE;
201 c->no_constraint_value = PM_QOS_RESUME_LATENCY_DEFAULT_VALUE;
193 c->type = PM_QOS_MIN; 202 c->type = PM_QOS_MIN;
194 c->notifiers = n; 203 c->notifiers = n;
195 204
205 c = &qos->latency_tolerance;
206 plist_head_init(&c->list);
207 c->target_value = PM_QOS_LATENCY_TOLERANCE_DEFAULT_VALUE;
208 c->default_value = PM_QOS_LATENCY_TOLERANCE_DEFAULT_VALUE;
209 c->no_constraint_value = PM_QOS_LATENCY_TOLERANCE_NO_CONSTRAINT;
210 c->type = PM_QOS_MIN;
211
196 INIT_LIST_HEAD(&qos->flags.list); 212 INIT_LIST_HEAD(&qos->flags.list);
197 213
198 spin_lock_irq(&dev->power.lock); 214 spin_lock_irq(&dev->power.lock);
@@ -224,7 +240,7 @@ void dev_pm_qos_constraints_destroy(struct device *dev)
224 * If the device's PM QoS resume latency limit or PM QoS flags have been 240 * If the device's PM QoS resume latency limit or PM QoS flags have been
225 * exposed to user space, they have to be hidden at this point. 241 * exposed to user space, they have to be hidden at this point.
226 */ 242 */
227 pm_qos_sysfs_remove_latency(dev); 243 pm_qos_sysfs_remove_resume_latency(dev);
228 pm_qos_sysfs_remove_flags(dev); 244 pm_qos_sysfs_remove_flags(dev);
229 245
230 mutex_lock(&dev_pm_qos_mtx); 246 mutex_lock(&dev_pm_qos_mtx);
@@ -237,7 +253,7 @@ void dev_pm_qos_constraints_destroy(struct device *dev)
237 goto out; 253 goto out;
238 254
239 /* Flush the constraints lists for the device. */ 255 /* Flush the constraints lists for the device. */
240 c = &qos->latency; 256 c = &qos->resume_latency;
241 plist_for_each_entry_safe(req, tmp, &c->list, data.pnode) { 257 plist_for_each_entry_safe(req, tmp, &c->list, data.pnode) {
242 /* 258 /*
243 * Update constraints list and call the notification 259 * Update constraints list and call the notification
@@ -246,6 +262,11 @@ void dev_pm_qos_constraints_destroy(struct device *dev)
246 apply_constraint(req, PM_QOS_REMOVE_REQ, PM_QOS_DEFAULT_VALUE); 262 apply_constraint(req, PM_QOS_REMOVE_REQ, PM_QOS_DEFAULT_VALUE);
247 memset(req, 0, sizeof(*req)); 263 memset(req, 0, sizeof(*req));
248 } 264 }
265 c = &qos->latency_tolerance;
266 plist_for_each_entry_safe(req, tmp, &c->list, data.pnode) {
267 apply_constraint(req, PM_QOS_REMOVE_REQ, PM_QOS_DEFAULT_VALUE);
268 memset(req, 0, sizeof(*req));
269 }
249 f = &qos->flags; 270 f = &qos->flags;
250 list_for_each_entry_safe(req, tmp, &f->list, data.flr.node) { 271 list_for_each_entry_safe(req, tmp, &f->list, data.flr.node) {
251 apply_constraint(req, PM_QOS_REMOVE_REQ, PM_QOS_DEFAULT_VALUE); 272 apply_constraint(req, PM_QOS_REMOVE_REQ, PM_QOS_DEFAULT_VALUE);
@@ -265,6 +286,40 @@ void dev_pm_qos_constraints_destroy(struct device *dev)
265 mutex_unlock(&dev_pm_qos_sysfs_mtx); 286 mutex_unlock(&dev_pm_qos_sysfs_mtx);
266} 287}
267 288
289static bool dev_pm_qos_invalid_request(struct device *dev,
290 struct dev_pm_qos_request *req)
291{
292 return !req || (req->type == DEV_PM_QOS_LATENCY_TOLERANCE
293 && !dev->power.set_latency_tolerance);
294}
295
296static int __dev_pm_qos_add_request(struct device *dev,
297 struct dev_pm_qos_request *req,
298 enum dev_pm_qos_req_type type, s32 value)
299{
300 int ret = 0;
301
302 if (!dev || dev_pm_qos_invalid_request(dev, req))
303 return -EINVAL;
304
305 if (WARN(dev_pm_qos_request_active(req),
306 "%s() called for already added request\n", __func__))
307 return -EINVAL;
308
309 if (IS_ERR(dev->power.qos))
310 ret = -ENODEV;
311 else if (!dev->power.qos)
312 ret = dev_pm_qos_constraints_allocate(dev);
313
314 trace_dev_pm_qos_add_request(dev_name(dev), type, value);
315 if (!ret) {
316 req->dev = dev;
317 req->type = type;
318 ret = apply_constraint(req, PM_QOS_ADD_REQ, value);
319 }
320 return ret;
321}
322
268/** 323/**
269 * dev_pm_qos_add_request - inserts new qos request into the list 324 * dev_pm_qos_add_request - inserts new qos request into the list
270 * @dev: target device for the constraint 325 * @dev: target device for the constraint
@@ -290,31 +345,11 @@ void dev_pm_qos_constraints_destroy(struct device *dev)
290int dev_pm_qos_add_request(struct device *dev, struct dev_pm_qos_request *req, 345int dev_pm_qos_add_request(struct device *dev, struct dev_pm_qos_request *req,
291 enum dev_pm_qos_req_type type, s32 value) 346 enum dev_pm_qos_req_type type, s32 value)
292{ 347{
293 int ret = 0; 348 int ret;
294
295 if (!dev || !req) /*guard against callers passing in null */
296 return -EINVAL;
297
298 if (WARN(dev_pm_qos_request_active(req),
299 "%s() called for already added request\n", __func__))
300 return -EINVAL;
301 349
302 mutex_lock(&dev_pm_qos_mtx); 350 mutex_lock(&dev_pm_qos_mtx);
303 351 ret = __dev_pm_qos_add_request(dev, req, type, value);
304 if (IS_ERR(dev->power.qos))
305 ret = -ENODEV;
306 else if (!dev->power.qos)
307 ret = dev_pm_qos_constraints_allocate(dev);
308
309 trace_dev_pm_qos_add_request(dev_name(dev), type, value);
310 if (!ret) {
311 req->dev = dev;
312 req->type = type;
313 ret = apply_constraint(req, PM_QOS_ADD_REQ, value);
314 }
315
316 mutex_unlock(&dev_pm_qos_mtx); 352 mutex_unlock(&dev_pm_qos_mtx);
317
318 return ret; 353 return ret;
319} 354}
320EXPORT_SYMBOL_GPL(dev_pm_qos_add_request); 355EXPORT_SYMBOL_GPL(dev_pm_qos_add_request);
@@ -341,7 +376,8 @@ static int __dev_pm_qos_update_request(struct dev_pm_qos_request *req,
341 return -ENODEV; 376 return -ENODEV;
342 377
343 switch(req->type) { 378 switch(req->type) {
344 case DEV_PM_QOS_LATENCY: 379 case DEV_PM_QOS_RESUME_LATENCY:
380 case DEV_PM_QOS_LATENCY_TOLERANCE:
345 curr_value = req->data.pnode.prio; 381 curr_value = req->data.pnode.prio;
346 break; 382 break;
347 case DEV_PM_QOS_FLAGS: 383 case DEV_PM_QOS_FLAGS:
@@ -460,8 +496,8 @@ int dev_pm_qos_add_notifier(struct device *dev, struct notifier_block *notifier)
460 ret = dev_pm_qos_constraints_allocate(dev); 496 ret = dev_pm_qos_constraints_allocate(dev);
461 497
462 if (!ret) 498 if (!ret)
463 ret = blocking_notifier_chain_register( 499 ret = blocking_notifier_chain_register(dev->power.qos->resume_latency.notifiers,
464 dev->power.qos->latency.notifiers, notifier); 500 notifier);
465 501
466 mutex_unlock(&dev_pm_qos_mtx); 502 mutex_unlock(&dev_pm_qos_mtx);
467 return ret; 503 return ret;
@@ -487,9 +523,8 @@ int dev_pm_qos_remove_notifier(struct device *dev,
487 523
488 /* Silently return if the constraints object is not present. */ 524 /* Silently return if the constraints object is not present. */
489 if (!IS_ERR_OR_NULL(dev->power.qos)) 525 if (!IS_ERR_OR_NULL(dev->power.qos))
490 retval = blocking_notifier_chain_unregister( 526 retval = blocking_notifier_chain_unregister(dev->power.qos->resume_latency.notifiers,
491 dev->power.qos->latency.notifiers, 527 notifier);
492 notifier);
493 528
494 mutex_unlock(&dev_pm_qos_mtx); 529 mutex_unlock(&dev_pm_qos_mtx);
495 return retval; 530 return retval;
@@ -530,20 +565,32 @@ EXPORT_SYMBOL_GPL(dev_pm_qos_remove_global_notifier);
530 * dev_pm_qos_add_ancestor_request - Add PM QoS request for device's ancestor. 565 * dev_pm_qos_add_ancestor_request - Add PM QoS request for device's ancestor.
531 * @dev: Device whose ancestor to add the request for. 566 * @dev: Device whose ancestor to add the request for.
532 * @req: Pointer to the preallocated handle. 567 * @req: Pointer to the preallocated handle.
568 * @type: Type of the request.
533 * @value: Constraint latency value. 569 * @value: Constraint latency value.
534 */ 570 */
535int dev_pm_qos_add_ancestor_request(struct device *dev, 571int dev_pm_qos_add_ancestor_request(struct device *dev,
536 struct dev_pm_qos_request *req, s32 value) 572 struct dev_pm_qos_request *req,
573 enum dev_pm_qos_req_type type, s32 value)
537{ 574{
538 struct device *ancestor = dev->parent; 575 struct device *ancestor = dev->parent;
539 int ret = -ENODEV; 576 int ret = -ENODEV;
540 577
541 while (ancestor && !ancestor->power.ignore_children) 578 switch (type) {
542 ancestor = ancestor->parent; 579 case DEV_PM_QOS_RESUME_LATENCY:
580 while (ancestor && !ancestor->power.ignore_children)
581 ancestor = ancestor->parent;
543 582
583 break;
584 case DEV_PM_QOS_LATENCY_TOLERANCE:
585 while (ancestor && !ancestor->power.set_latency_tolerance)
586 ancestor = ancestor->parent;
587
588 break;
589 default:
590 ancestor = NULL;
591 }
544 if (ancestor) 592 if (ancestor)
545 ret = dev_pm_qos_add_request(ancestor, req, 593 ret = dev_pm_qos_add_request(ancestor, req, type, value);
546 DEV_PM_QOS_LATENCY, value);
547 594
548 if (ret < 0) 595 if (ret < 0)
549 req->dev = NULL; 596 req->dev = NULL;
@@ -559,9 +606,13 @@ static void __dev_pm_qos_drop_user_request(struct device *dev,
559 struct dev_pm_qos_request *req = NULL; 606 struct dev_pm_qos_request *req = NULL;
560 607
561 switch(type) { 608 switch(type) {
562 case DEV_PM_QOS_LATENCY: 609 case DEV_PM_QOS_RESUME_LATENCY:
563 req = dev->power.qos->latency_req; 610 req = dev->power.qos->resume_latency_req;
564 dev->power.qos->latency_req = NULL; 611 dev->power.qos->resume_latency_req = NULL;
612 break;
613 case DEV_PM_QOS_LATENCY_TOLERANCE:
614 req = dev->power.qos->latency_tolerance_req;
615 dev->power.qos->latency_tolerance_req = NULL;
565 break; 616 break;
566 case DEV_PM_QOS_FLAGS: 617 case DEV_PM_QOS_FLAGS:
567 req = dev->power.qos->flags_req; 618 req = dev->power.qos->flags_req;
@@ -597,7 +648,7 @@ int dev_pm_qos_expose_latency_limit(struct device *dev, s32 value)
597 if (!req) 648 if (!req)
598 return -ENOMEM; 649 return -ENOMEM;
599 650
600 ret = dev_pm_qos_add_request(dev, req, DEV_PM_QOS_LATENCY, value); 651 ret = dev_pm_qos_add_request(dev, req, DEV_PM_QOS_RESUME_LATENCY, value);
601 if (ret < 0) { 652 if (ret < 0) {
602 kfree(req); 653 kfree(req);
603 return ret; 654 return ret;
@@ -609,7 +660,7 @@ int dev_pm_qos_expose_latency_limit(struct device *dev, s32 value)
609 660
610 if (IS_ERR_OR_NULL(dev->power.qos)) 661 if (IS_ERR_OR_NULL(dev->power.qos))
611 ret = -ENODEV; 662 ret = -ENODEV;
612 else if (dev->power.qos->latency_req) 663 else if (dev->power.qos->resume_latency_req)
613 ret = -EEXIST; 664 ret = -EEXIST;
614 665
615 if (ret < 0) { 666 if (ret < 0) {
@@ -618,13 +669,13 @@ int dev_pm_qos_expose_latency_limit(struct device *dev, s32 value)
618 mutex_unlock(&dev_pm_qos_mtx); 669 mutex_unlock(&dev_pm_qos_mtx);
619 goto out; 670 goto out;
620 } 671 }
621 dev->power.qos->latency_req = req; 672 dev->power.qos->resume_latency_req = req;
622 673
623 mutex_unlock(&dev_pm_qos_mtx); 674 mutex_unlock(&dev_pm_qos_mtx);
624 675
625 ret = pm_qos_sysfs_add_latency(dev); 676 ret = pm_qos_sysfs_add_resume_latency(dev);
626 if (ret) 677 if (ret)
627 dev_pm_qos_drop_user_request(dev, DEV_PM_QOS_LATENCY); 678 dev_pm_qos_drop_user_request(dev, DEV_PM_QOS_RESUME_LATENCY);
628 679
629 out: 680 out:
630 mutex_unlock(&dev_pm_qos_sysfs_mtx); 681 mutex_unlock(&dev_pm_qos_sysfs_mtx);
@@ -634,8 +685,8 @@ EXPORT_SYMBOL_GPL(dev_pm_qos_expose_latency_limit);
634 685
635static void __dev_pm_qos_hide_latency_limit(struct device *dev) 686static void __dev_pm_qos_hide_latency_limit(struct device *dev)
636{ 687{
637 if (!IS_ERR_OR_NULL(dev->power.qos) && dev->power.qos->latency_req) 688 if (!IS_ERR_OR_NULL(dev->power.qos) && dev->power.qos->resume_latency_req)
638 __dev_pm_qos_drop_user_request(dev, DEV_PM_QOS_LATENCY); 689 __dev_pm_qos_drop_user_request(dev, DEV_PM_QOS_RESUME_LATENCY);
639} 690}
640 691
641/** 692/**
@@ -646,7 +697,7 @@ void dev_pm_qos_hide_latency_limit(struct device *dev)
646{ 697{
647 mutex_lock(&dev_pm_qos_sysfs_mtx); 698 mutex_lock(&dev_pm_qos_sysfs_mtx);
648 699
649 pm_qos_sysfs_remove_latency(dev); 700 pm_qos_sysfs_remove_resume_latency(dev);
650 701
651 mutex_lock(&dev_pm_qos_mtx); 702 mutex_lock(&dev_pm_qos_mtx);
652 __dev_pm_qos_hide_latency_limit(dev); 703 __dev_pm_qos_hide_latency_limit(dev);
@@ -768,6 +819,67 @@ int dev_pm_qos_update_flags(struct device *dev, s32 mask, bool set)
768 pm_runtime_put(dev); 819 pm_runtime_put(dev);
769 return ret; 820 return ret;
770} 821}
822
823/**
824 * dev_pm_qos_get_user_latency_tolerance - Get user space latency tolerance.
825 * @dev: Device to obtain the user space latency tolerance for.
826 */
827s32 dev_pm_qos_get_user_latency_tolerance(struct device *dev)
828{
829 s32 ret;
830
831 mutex_lock(&dev_pm_qos_mtx);
832 ret = IS_ERR_OR_NULL(dev->power.qos)
833 || !dev->power.qos->latency_tolerance_req ?
834 PM_QOS_LATENCY_TOLERANCE_NO_CONSTRAINT :
835 dev->power.qos->latency_tolerance_req->data.pnode.prio;
836 mutex_unlock(&dev_pm_qos_mtx);
837 return ret;
838}
839
840/**
841 * dev_pm_qos_update_user_latency_tolerance - Update user space latency tolerance.
842 * @dev: Device to update the user space latency tolerance for.
843 * @val: New user space latency tolerance for @dev (negative values disable).
844 */
845int dev_pm_qos_update_user_latency_tolerance(struct device *dev, s32 val)
846{
847 int ret;
848
849 mutex_lock(&dev_pm_qos_mtx);
850
851 if (IS_ERR_OR_NULL(dev->power.qos)
852 || !dev->power.qos->latency_tolerance_req) {
853 struct dev_pm_qos_request *req;
854
855 if (val < 0) {
856 ret = -EINVAL;
857 goto out;
858 }
859 req = kzalloc(sizeof(*req), GFP_KERNEL);
860 if (!req) {
861 ret = -ENOMEM;
862 goto out;
863 }
864 ret = __dev_pm_qos_add_request(dev, req, DEV_PM_QOS_LATENCY_TOLERANCE, val);
865 if (ret < 0) {
866 kfree(req);
867 goto out;
868 }
869 dev->power.qos->latency_tolerance_req = req;
870 } else {
871 if (val < 0) {
872 __dev_pm_qos_drop_user_request(dev, DEV_PM_QOS_LATENCY_TOLERANCE);
873 ret = 0;
874 } else {
875 ret = __dev_pm_qos_update_request(dev->power.qos->latency_tolerance_req, val);
876 }
877 }
878
879 out:
880 mutex_unlock(&dev_pm_qos_mtx);
881 return ret;
882}
771#else /* !CONFIG_PM_RUNTIME */ 883#else /* !CONFIG_PM_RUNTIME */
772static void __dev_pm_qos_hide_latency_limit(struct device *dev) {} 884static void __dev_pm_qos_hide_latency_limit(struct device *dev) {}
773static void __dev_pm_qos_hide_flags(struct device *dev) {} 885static void __dev_pm_qos_hide_flags(struct device *dev) {}
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index 72e00e66ecc5..67c7938e430b 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -13,6 +13,43 @@
13#include <trace/events/rpm.h> 13#include <trace/events/rpm.h>
14#include "power.h" 14#include "power.h"
15 15
16#define RPM_GET_CALLBACK(dev, cb) \
17({ \
18 int (*__rpm_cb)(struct device *__d); \
19 \
20 if (dev->pm_domain) \
21 __rpm_cb = dev->pm_domain->ops.cb; \
22 else if (dev->type && dev->type->pm) \
23 __rpm_cb = dev->type->pm->cb; \
24 else if (dev->class && dev->class->pm) \
25 __rpm_cb = dev->class->pm->cb; \
26 else if (dev->bus && dev->bus->pm) \
27 __rpm_cb = dev->bus->pm->cb; \
28 else \
29 __rpm_cb = NULL; \
30 \
31 if (!__rpm_cb && dev->driver && dev->driver->pm) \
32 __rpm_cb = dev->driver->pm->cb; \
33 \
34 __rpm_cb; \
35})
36
37static int (*rpm_get_suspend_cb(struct device *dev))(struct device *)
38{
39 return RPM_GET_CALLBACK(dev, runtime_suspend);
40}
41
42static int (*rpm_get_resume_cb(struct device *dev))(struct device *)
43{
44 return RPM_GET_CALLBACK(dev, runtime_resume);
45}
46
47#ifdef CONFIG_PM_RUNTIME
48static int (*rpm_get_idle_cb(struct device *dev))(struct device *)
49{
50 return RPM_GET_CALLBACK(dev, runtime_idle);
51}
52
16static int rpm_resume(struct device *dev, int rpmflags); 53static int rpm_resume(struct device *dev, int rpmflags);
17static int rpm_suspend(struct device *dev, int rpmflags); 54static int rpm_suspend(struct device *dev, int rpmflags);
18 55
@@ -310,19 +347,7 @@ static int rpm_idle(struct device *dev, int rpmflags)
310 347
311 dev->power.idle_notification = true; 348 dev->power.idle_notification = true;
312 349
313 if (dev->pm_domain) 350 callback = rpm_get_idle_cb(dev);
314 callback = dev->pm_domain->ops.runtime_idle;
315 else if (dev->type && dev->type->pm)
316 callback = dev->type->pm->runtime_idle;
317 else if (dev->class && dev->class->pm)
318 callback = dev->class->pm->runtime_idle;
319 else if (dev->bus && dev->bus->pm)
320 callback = dev->bus->pm->runtime_idle;
321 else
322 callback = NULL;
323
324 if (!callback && dev->driver && dev->driver->pm)
325 callback = dev->driver->pm->runtime_idle;
326 351
327 if (callback) 352 if (callback)
328 retval = __rpm_callback(callback, dev); 353 retval = __rpm_callback(callback, dev);
@@ -492,19 +517,7 @@ static int rpm_suspend(struct device *dev, int rpmflags)
492 517
493 __update_runtime_status(dev, RPM_SUSPENDING); 518 __update_runtime_status(dev, RPM_SUSPENDING);
494 519
495 if (dev->pm_domain) 520 callback = rpm_get_suspend_cb(dev);
496 callback = dev->pm_domain->ops.runtime_suspend;
497 else if (dev->type && dev->type->pm)
498 callback = dev->type->pm->runtime_suspend;
499 else if (dev->class && dev->class->pm)
500 callback = dev->class->pm->runtime_suspend;
501 else if (dev->bus && dev->bus->pm)
502 callback = dev->bus->pm->runtime_suspend;
503 else
504 callback = NULL;
505
506 if (!callback && dev->driver && dev->driver->pm)
507 callback = dev->driver->pm->runtime_suspend;
508 521
509 retval = rpm_callback(callback, dev); 522 retval = rpm_callback(callback, dev);
510 if (retval) 523 if (retval)
@@ -724,19 +737,7 @@ static int rpm_resume(struct device *dev, int rpmflags)
724 737
725 __update_runtime_status(dev, RPM_RESUMING); 738 __update_runtime_status(dev, RPM_RESUMING);
726 739
727 if (dev->pm_domain) 740 callback = rpm_get_resume_cb(dev);
728 callback = dev->pm_domain->ops.runtime_resume;
729 else if (dev->type && dev->type->pm)
730 callback = dev->type->pm->runtime_resume;
731 else if (dev->class && dev->class->pm)
732 callback = dev->class->pm->runtime_resume;
733 else if (dev->bus && dev->bus->pm)
734 callback = dev->bus->pm->runtime_resume;
735 else
736 callback = NULL;
737
738 if (!callback && dev->driver && dev->driver->pm)
739 callback = dev->driver->pm->runtime_resume;
740 741
741 retval = rpm_callback(callback, dev); 742 retval = rpm_callback(callback, dev);
742 if (retval) { 743 if (retval) {
@@ -1130,7 +1131,7 @@ EXPORT_SYMBOL_GPL(pm_runtime_barrier);
1130 * @dev: Device to handle. 1131 * @dev: Device to handle.
1131 * @check_resume: If set, check if there's a resume request for the device. 1132 * @check_resume: If set, check if there's a resume request for the device.
1132 * 1133 *
1133 * Increment power.disable_depth for the device and if was zero previously, 1134 * Increment power.disable_depth for the device and if it was zero previously,
1134 * cancel all pending runtime PM requests for the device and wait for all 1135 * cancel all pending runtime PM requests for the device and wait for all
1135 * operations in progress to complete. The device can be either active or 1136 * operations in progress to complete. The device can be either active or
1136 * suspended after its runtime PM has been disabled. 1137 * suspended after its runtime PM has been disabled.
@@ -1401,3 +1402,86 @@ void pm_runtime_remove(struct device *dev)
1401 if (dev->power.irq_safe && dev->parent) 1402 if (dev->power.irq_safe && dev->parent)
1402 pm_runtime_put(dev->parent); 1403 pm_runtime_put(dev->parent);
1403} 1404}
1405#endif
1406
1407/**
1408 * pm_runtime_force_suspend - Force a device into suspend state if needed.
1409 * @dev: Device to suspend.
1410 *
1411 * Disable runtime PM so we safely can check the device's runtime PM status and
1412 * if it is active, invoke it's .runtime_suspend callback to bring it into
1413 * suspend state. Keep runtime PM disabled to preserve the state unless we
1414 * encounter errors.
1415 *
1416 * Typically this function may be invoked from a system suspend callback to make
1417 * sure the device is put into low power state.
1418 */
1419int pm_runtime_force_suspend(struct device *dev)
1420{
1421 int (*callback)(struct device *);
1422 int ret = 0;
1423
1424 pm_runtime_disable(dev);
1425
1426 /*
1427 * Note that pm_runtime_status_suspended() returns false while
1428 * !CONFIG_PM_RUNTIME, which means the device will be put into low
1429 * power state.
1430 */
1431 if (pm_runtime_status_suspended(dev))
1432 return 0;
1433
1434 callback = rpm_get_suspend_cb(dev);
1435
1436 if (!callback) {
1437 ret = -ENOSYS;
1438 goto err;
1439 }
1440
1441 ret = callback(dev);
1442 if (ret)
1443 goto err;
1444
1445 pm_runtime_set_suspended(dev);
1446 return 0;
1447err:
1448 pm_runtime_enable(dev);
1449 return ret;
1450}
1451EXPORT_SYMBOL_GPL(pm_runtime_force_suspend);
1452
1453/**
1454 * pm_runtime_force_resume - Force a device into resume state.
1455 * @dev: Device to resume.
1456 *
1457 * Prior invoking this function we expect the user to have brought the device
1458 * into low power state by a call to pm_runtime_force_suspend(). Here we reverse
1459 * those actions and brings the device into full power. We update the runtime PM
1460 * status and re-enables runtime PM.
1461 *
1462 * Typically this function may be invoked from a system resume callback to make
1463 * sure the device is put into full power state.
1464 */
1465int pm_runtime_force_resume(struct device *dev)
1466{
1467 int (*callback)(struct device *);
1468 int ret = 0;
1469
1470 callback = rpm_get_resume_cb(dev);
1471
1472 if (!callback) {
1473 ret = -ENOSYS;
1474 goto out;
1475 }
1476
1477 ret = callback(dev);
1478 if (ret)
1479 goto out;
1480
1481 pm_runtime_set_active(dev);
1482 pm_runtime_mark_last_busy(dev);
1483out:
1484 pm_runtime_enable(dev);
1485 return ret;
1486}
1487EXPORT_SYMBOL_GPL(pm_runtime_force_resume);
diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
index 03e089ade5ce..95b181d1ca6d 100644
--- a/drivers/base/power/sysfs.c
+++ b/drivers/base/power/sysfs.c
@@ -218,15 +218,16 @@ static ssize_t autosuspend_delay_ms_store(struct device *dev,
218static DEVICE_ATTR(autosuspend_delay_ms, 0644, autosuspend_delay_ms_show, 218static DEVICE_ATTR(autosuspend_delay_ms, 0644, autosuspend_delay_ms_show,
219 autosuspend_delay_ms_store); 219 autosuspend_delay_ms_store);
220 220
221static ssize_t pm_qos_latency_show(struct device *dev, 221static ssize_t pm_qos_resume_latency_show(struct device *dev,
222 struct device_attribute *attr, char *buf) 222 struct device_attribute *attr,
223 char *buf)
223{ 224{
224 return sprintf(buf, "%d\n", dev_pm_qos_requested_latency(dev)); 225 return sprintf(buf, "%d\n", dev_pm_qos_requested_resume_latency(dev));
225} 226}
226 227
227static ssize_t pm_qos_latency_store(struct device *dev, 228static ssize_t pm_qos_resume_latency_store(struct device *dev,
228 struct device_attribute *attr, 229 struct device_attribute *attr,
229 const char *buf, size_t n) 230 const char *buf, size_t n)
230{ 231{
231 s32 value; 232 s32 value;
232 int ret; 233 int ret;
@@ -237,12 +238,47 @@ static ssize_t pm_qos_latency_store(struct device *dev,
237 if (value < 0) 238 if (value < 0)
238 return -EINVAL; 239 return -EINVAL;
239 240
240 ret = dev_pm_qos_update_request(dev->power.qos->latency_req, value); 241 ret = dev_pm_qos_update_request(dev->power.qos->resume_latency_req,
242 value);
241 return ret < 0 ? ret : n; 243 return ret < 0 ? ret : n;
242} 244}
243 245
244static DEVICE_ATTR(pm_qos_resume_latency_us, 0644, 246static DEVICE_ATTR(pm_qos_resume_latency_us, 0644,
245 pm_qos_latency_show, pm_qos_latency_store); 247 pm_qos_resume_latency_show, pm_qos_resume_latency_store);
248
249static ssize_t pm_qos_latency_tolerance_show(struct device *dev,
250 struct device_attribute *attr,
251 char *buf)
252{
253 s32 value = dev_pm_qos_get_user_latency_tolerance(dev);
254
255 if (value < 0)
256 return sprintf(buf, "auto\n");
257 else if (value == PM_QOS_LATENCY_ANY)
258 return sprintf(buf, "any\n");
259
260 return sprintf(buf, "%d\n", value);
261}
262
263static ssize_t pm_qos_latency_tolerance_store(struct device *dev,
264 struct device_attribute *attr,
265 const char *buf, size_t n)
266{
267 s32 value;
268 int ret;
269
270 if (kstrtos32(buf, 0, &value)) {
271 if (!strcmp(buf, "auto") || !strcmp(buf, "auto\n"))
272 value = PM_QOS_LATENCY_TOLERANCE_NO_CONSTRAINT;
273 else if (!strcmp(buf, "any") || !strcmp(buf, "any\n"))
274 value = PM_QOS_LATENCY_ANY;
275 }
276 ret = dev_pm_qos_update_user_latency_tolerance(dev, value);
277 return ret < 0 ? ret : n;
278}
279
280static DEVICE_ATTR(pm_qos_latency_tolerance_us, 0644,
281 pm_qos_latency_tolerance_show, pm_qos_latency_tolerance_store);
246 282
247static ssize_t pm_qos_no_power_off_show(struct device *dev, 283static ssize_t pm_qos_no_power_off_show(struct device *dev,
248 struct device_attribute *attr, 284 struct device_attribute *attr,
@@ -618,15 +654,26 @@ static struct attribute_group pm_runtime_attr_group = {
618 .attrs = runtime_attrs, 654 .attrs = runtime_attrs,
619}; 655};
620 656
621static struct attribute *pm_qos_latency_attrs[] = { 657static struct attribute *pm_qos_resume_latency_attrs[] = {
622#ifdef CONFIG_PM_RUNTIME 658#ifdef CONFIG_PM_RUNTIME
623 &dev_attr_pm_qos_resume_latency_us.attr, 659 &dev_attr_pm_qos_resume_latency_us.attr,
624#endif /* CONFIG_PM_RUNTIME */ 660#endif /* CONFIG_PM_RUNTIME */
625 NULL, 661 NULL,
626}; 662};
627static struct attribute_group pm_qos_latency_attr_group = { 663static struct attribute_group pm_qos_resume_latency_attr_group = {
664 .name = power_group_name,
665 .attrs = pm_qos_resume_latency_attrs,
666};
667
668static struct attribute *pm_qos_latency_tolerance_attrs[] = {
669#ifdef CONFIG_PM_RUNTIME
670 &dev_attr_pm_qos_latency_tolerance_us.attr,
671#endif /* CONFIG_PM_RUNTIME */
672 NULL,
673};
674static struct attribute_group pm_qos_latency_tolerance_attr_group = {
628 .name = power_group_name, 675 .name = power_group_name,
629 .attrs = pm_qos_latency_attrs, 676 .attrs = pm_qos_latency_tolerance_attrs,
630}; 677};
631 678
632static struct attribute *pm_qos_flags_attrs[] = { 679static struct attribute *pm_qos_flags_attrs[] = {
@@ -654,18 +701,23 @@ int dpm_sysfs_add(struct device *dev)
654 if (rc) 701 if (rc)
655 goto err_out; 702 goto err_out;
656 } 703 }
657
658 if (device_can_wakeup(dev)) { 704 if (device_can_wakeup(dev)) {
659 rc = sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group); 705 rc = sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group);
660 if (rc) { 706 if (rc)
661 if (pm_runtime_callbacks_present(dev)) 707 goto err_runtime;
662 sysfs_unmerge_group(&dev->kobj, 708 }
663 &pm_runtime_attr_group); 709 if (dev->power.set_latency_tolerance) {
664 goto err_out; 710 rc = sysfs_merge_group(&dev->kobj,
665 } 711 &pm_qos_latency_tolerance_attr_group);
712 if (rc)
713 goto err_wakeup;
666 } 714 }
667 return 0; 715 return 0;
668 716
717 err_wakeup:
718 sysfs_unmerge_group(&dev->kobj, &pm_wakeup_attr_group);
719 err_runtime:
720 sysfs_unmerge_group(&dev->kobj, &pm_runtime_attr_group);
669 err_out: 721 err_out:
670 sysfs_remove_group(&dev->kobj, &pm_attr_group); 722 sysfs_remove_group(&dev->kobj, &pm_attr_group);
671 return rc; 723 return rc;
@@ -681,14 +733,14 @@ void wakeup_sysfs_remove(struct device *dev)
681 sysfs_unmerge_group(&dev->kobj, &pm_wakeup_attr_group); 733 sysfs_unmerge_group(&dev->kobj, &pm_wakeup_attr_group);
682} 734}
683 735
684int pm_qos_sysfs_add_latency(struct device *dev) 736int pm_qos_sysfs_add_resume_latency(struct device *dev)
685{ 737{
686 return sysfs_merge_group(&dev->kobj, &pm_qos_latency_attr_group); 738 return sysfs_merge_group(&dev->kobj, &pm_qos_resume_latency_attr_group);
687} 739}
688 740
689void pm_qos_sysfs_remove_latency(struct device *dev) 741void pm_qos_sysfs_remove_resume_latency(struct device *dev)
690{ 742{
691 sysfs_unmerge_group(&dev->kobj, &pm_qos_latency_attr_group); 743 sysfs_unmerge_group(&dev->kobj, &pm_qos_resume_latency_attr_group);
692} 744}
693 745
694int pm_qos_sysfs_add_flags(struct device *dev) 746int pm_qos_sysfs_add_flags(struct device *dev)
@@ -708,6 +760,7 @@ void rpm_sysfs_remove(struct device *dev)
708 760
709void dpm_sysfs_remove(struct device *dev) 761void dpm_sysfs_remove(struct device *dev)
710{ 762{
763 sysfs_unmerge_group(&dev->kobj, &pm_qos_latency_tolerance_attr_group);
711 dev_pm_qos_constraints_destroy(dev); 764 dev_pm_qos_constraints_destroy(dev);
712 rpm_sysfs_remove(dev); 765 rpm_sysfs_remove(dev);
713 sysfs_unmerge_group(&dev->kobj, &pm_wakeup_attr_group); 766 sysfs_unmerge_group(&dev->kobj, &pm_wakeup_attr_group);
diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm
index 31297499a60a..9fb627046e17 100644
--- a/drivers/cpufreq/Kconfig.arm
+++ b/drivers/cpufreq/Kconfig.arm
@@ -2,6 +2,7 @@
2# ARM CPU Frequency scaling drivers 2# ARM CPU Frequency scaling drivers
3# 3#
4 4
5# big LITTLE core layer and glue drivers
5config ARM_BIG_LITTLE_CPUFREQ 6config ARM_BIG_LITTLE_CPUFREQ
6 tristate "Generic ARM big LITTLE CPUfreq driver" 7 tristate "Generic ARM big LITTLE CPUfreq driver"
7 depends on ARM && BIG_LITTLE && ARM_CPU_TOPOLOGY && HAVE_CLK 8 depends on ARM && BIG_LITTLE && ARM_CPU_TOPOLOGY && HAVE_CLK
@@ -16,6 +17,14 @@ config ARM_DT_BL_CPUFREQ
16 This enables probing via DT for Generic CPUfreq driver for ARM 17 This enables probing via DT for Generic CPUfreq driver for ARM
17 big.LITTLE platform. This gets frequency tables from DT. 18 big.LITTLE platform. This gets frequency tables from DT.
18 19
20config ARM_VEXPRESS_SPC_CPUFREQ
21 tristate "Versatile Express SPC based CPUfreq driver"
22 depends on ARM_BIG_LITTLE_CPUFREQ && ARCH_VEXPRESS_SPC
23 help
24 This add the CPUfreq driver support for Versatile Express
25 big.LITTLE platforms using SPC for power management.
26
27
19config ARM_EXYNOS_CPUFREQ 28config ARM_EXYNOS_CPUFREQ
20 bool 29 bool
21 30
@@ -241,11 +250,3 @@ config ARM_TEGRA_CPUFREQ
241 default y 250 default y
242 help 251 help
243 This adds the CPUFreq driver support for TEGRA SOCs. 252 This adds the CPUFreq driver support for TEGRA SOCs.
244
245config ARM_VEXPRESS_SPC_CPUFREQ
246 tristate "Versatile Express SPC based CPUfreq driver"
247 select ARM_BIG_LITTLE_CPUFREQ
248 depends on ARCH_VEXPRESS_SPC
249 help
250 This add the CPUfreq driver support for Versatile Express
251 big.LITTLE platforms using SPC for power management.
diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
index 18448a7e9f86..822ca03a87f7 100644
--- a/drivers/cpufreq/acpi-cpufreq.c
+++ b/drivers/cpufreq/acpi-cpufreq.c
@@ -855,7 +855,6 @@ static int acpi_cpufreq_cpu_exit(struct cpufreq_policy *policy)
855 pr_debug("acpi_cpufreq_cpu_exit\n"); 855 pr_debug("acpi_cpufreq_cpu_exit\n");
856 856
857 if (data) { 857 if (data) {
858 cpufreq_frequency_table_put_attr(policy->cpu);
859 per_cpu(acfreq_data, policy->cpu) = NULL; 858 per_cpu(acfreq_data, policy->cpu) = NULL;
860 acpi_processor_unregister_performance(data->acpi_data, 859 acpi_processor_unregister_performance(data->acpi_data,
861 policy->cpu); 860 policy->cpu);
diff --git a/drivers/cpufreq/arm_big_little.c b/drivers/cpufreq/arm_big_little.c
index 72f87e9317e3..bad2ed317ba2 100644
--- a/drivers/cpufreq/arm_big_little.c
+++ b/drivers/cpufreq/arm_big_little.c
@@ -446,9 +446,12 @@ static int bL_cpufreq_init(struct cpufreq_policy *policy)
446 } 446 }
447 447
448 if (cur_cluster < MAX_CLUSTERS) { 448 if (cur_cluster < MAX_CLUSTERS) {
449 int cpu;
450
449 cpumask_copy(policy->cpus, topology_core_cpumask(policy->cpu)); 451 cpumask_copy(policy->cpus, topology_core_cpumask(policy->cpu));
450 452
451 per_cpu(physical_cluster, policy->cpu) = cur_cluster; 453 for_each_cpu(cpu, policy->cpus)
454 per_cpu(physical_cluster, cpu) = cur_cluster;
452 } else { 455 } else {
453 /* Assumption: during init, we are always running on A15 */ 456 /* Assumption: during init, we are always running on A15 */
454 per_cpu(physical_cluster, policy->cpu) = A15_CLUSTER; 457 per_cpu(physical_cluster, policy->cpu) = A15_CLUSTER;
@@ -478,7 +481,6 @@ static int bL_cpufreq_exit(struct cpufreq_policy *policy)
478 return -ENODEV; 481 return -ENODEV;
479 } 482 }
480 483
481 cpufreq_frequency_table_put_attr(policy->cpu);
482 put_cluster_clk_and_freq_table(cpu_dev); 484 put_cluster_clk_and_freq_table(cpu_dev);
483 dev_dbg(cpu_dev, "%s: Exited, cpu: %d\n", __func__, policy->cpu); 485 dev_dbg(cpu_dev, "%s: Exited, cpu: %d\n", __func__, policy->cpu);
484 486
diff --git a/drivers/cpufreq/blackfin-cpufreq.c b/drivers/cpufreq/blackfin-cpufreq.c
index e9e63fc9c2c9..a9f8e5bd0716 100644
--- a/drivers/cpufreq/blackfin-cpufreq.c
+++ b/drivers/cpufreq/blackfin-cpufreq.c
@@ -195,7 +195,6 @@ static struct cpufreq_driver bfin_driver = {
195 .target_index = bfin_target, 195 .target_index = bfin_target,
196 .get = bfin_getfreq_khz, 196 .get = bfin_getfreq_khz,
197 .init = __bfin_cpu_init, 197 .init = __bfin_cpu_init,
198 .exit = cpufreq_generic_exit,
199 .name = "bfin cpufreq", 198 .name = "bfin cpufreq",
200 .attr = cpufreq_generic_attr, 199 .attr = cpufreq_generic_attr,
201}; 200};
diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.c
index 0c12ffc0ebcb..1bf6bbac3e03 100644
--- a/drivers/cpufreq/cpufreq-cpu0.c
+++ b/drivers/cpufreq/cpufreq-cpu0.c
@@ -109,7 +109,6 @@ static struct cpufreq_driver cpu0_cpufreq_driver = {
109 .target_index = cpu0_set_target, 109 .target_index = cpu0_set_target,
110 .get = cpufreq_generic_get, 110 .get = cpufreq_generic_get,
111 .init = cpu0_cpufreq_init, 111 .init = cpu0_cpufreq_init,
112 .exit = cpufreq_generic_exit,
113 .name = "generic_cpu0", 112 .name = "generic_cpu0",
114 .attr = cpufreq_generic_attr, 113 .attr = cpufreq_generic_attr,
115}; 114};
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 199b52b7c3e1..3aa7a7a226b3 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -26,7 +26,7 @@
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/mutex.h> 27#include <linux/mutex.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/syscore_ops.h> 29#include <linux/suspend.h>
30#include <linux/tick.h> 30#include <linux/tick.h>
31#include <trace/events/power.h> 31#include <trace/events/power.h>
32 32
@@ -42,10 +42,11 @@ static DEFINE_RWLOCK(cpufreq_driver_lock);
42DEFINE_MUTEX(cpufreq_governor_lock); 42DEFINE_MUTEX(cpufreq_governor_lock);
43static LIST_HEAD(cpufreq_policy_list); 43static LIST_HEAD(cpufreq_policy_list);
44 44
45#ifdef CONFIG_HOTPLUG_CPU
46/* This one keeps track of the previously set governor of a removed CPU */ 45/* This one keeps track of the previously set governor of a removed CPU */
47static DEFINE_PER_CPU(char[CPUFREQ_NAME_LEN], cpufreq_cpu_governor); 46static DEFINE_PER_CPU(char[CPUFREQ_NAME_LEN], cpufreq_cpu_governor);
48#endif 47
48/* Flag to suspend/resume CPUFreq governors */
49static bool cpufreq_suspended;
49 50
50static inline bool has_target(void) 51static inline bool has_target(void)
51{ 52{
@@ -181,8 +182,8 @@ unsigned int cpufreq_generic_get(unsigned int cpu)
181 struct cpufreq_policy *policy = per_cpu(cpufreq_cpu_data, cpu); 182 struct cpufreq_policy *policy = per_cpu(cpufreq_cpu_data, cpu);
182 183
183 if (!policy || IS_ERR(policy->clk)) { 184 if (!policy || IS_ERR(policy->clk)) {
184 pr_err("%s: No %s associated to cpu: %d\n", __func__, 185 pr_err("%s: No %s associated to cpu: %d\n",
185 policy ? "clk" : "policy", cpu); 186 __func__, policy ? "clk" : "policy", cpu);
186 return 0; 187 return 0;
187 } 188 }
188 189
@@ -190,6 +191,12 @@ unsigned int cpufreq_generic_get(unsigned int cpu)
190} 191}
191EXPORT_SYMBOL_GPL(cpufreq_generic_get); 192EXPORT_SYMBOL_GPL(cpufreq_generic_get);
192 193
194/* Only for cpufreq core internal use */
195struct cpufreq_policy *cpufreq_cpu_get_raw(unsigned int cpu)
196{
197 return per_cpu(cpufreq_cpu_data, cpu);
198}
199
193struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu) 200struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu)
194{ 201{
195 struct cpufreq_policy *policy = NULL; 202 struct cpufreq_policy *policy = NULL;
@@ -254,15 +261,14 @@ static void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci)
254 if (!l_p_j_ref_freq) { 261 if (!l_p_j_ref_freq) {
255 l_p_j_ref = loops_per_jiffy; 262 l_p_j_ref = loops_per_jiffy;
256 l_p_j_ref_freq = ci->old; 263 l_p_j_ref_freq = ci->old;
257 pr_debug("saving %lu as reference value for loops_per_jiffy; " 264 pr_debug("saving %lu as reference value for loops_per_jiffy; freq is %u kHz\n",
258 "freq is %u kHz\n", l_p_j_ref, l_p_j_ref_freq); 265 l_p_j_ref, l_p_j_ref_freq);
259 } 266 }
260 if ((val == CPUFREQ_POSTCHANGE && ci->old != ci->new) || 267 if (val == CPUFREQ_POSTCHANGE && ci->old != ci->new) {
261 (val == CPUFREQ_RESUMECHANGE || val == CPUFREQ_SUSPENDCHANGE)) {
262 loops_per_jiffy = cpufreq_scale(l_p_j_ref, l_p_j_ref_freq, 268 loops_per_jiffy = cpufreq_scale(l_p_j_ref, l_p_j_ref_freq,
263 ci->new); 269 ci->new);
264 pr_debug("scaling loops_per_jiffy to %lu " 270 pr_debug("scaling loops_per_jiffy to %lu for frequency %u kHz\n",
265 "for frequency %u kHz\n", loops_per_jiffy, ci->new); 271 loops_per_jiffy, ci->new);
266 } 272 }
267} 273}
268#else 274#else
@@ -282,7 +288,7 @@ static void __cpufreq_notify_transition(struct cpufreq_policy *policy,
282 288
283 freqs->flags = cpufreq_driver->flags; 289 freqs->flags = cpufreq_driver->flags;
284 pr_debug("notification %u of frequency transition to %u kHz\n", 290 pr_debug("notification %u of frequency transition to %u kHz\n",
285 state, freqs->new); 291 state, freqs->new);
286 292
287 switch (state) { 293 switch (state) {
288 294
@@ -294,9 +300,8 @@ static void __cpufreq_notify_transition(struct cpufreq_policy *policy,
294 if (!(cpufreq_driver->flags & CPUFREQ_CONST_LOOPS)) { 300 if (!(cpufreq_driver->flags & CPUFREQ_CONST_LOOPS)) {
295 if ((policy) && (policy->cpu == freqs->cpu) && 301 if ((policy) && (policy->cpu == freqs->cpu) &&
296 (policy->cur) && (policy->cur != freqs->old)) { 302 (policy->cur) && (policy->cur != freqs->old)) {
297 pr_debug("Warning: CPU frequency is" 303 pr_debug("Warning: CPU frequency is %u, cpufreq assumed %u kHz\n",
298 " %u, cpufreq assumed %u kHz.\n", 304 freqs->old, policy->cur);
299 freqs->old, policy->cur);
300 freqs->old = policy->cur; 305 freqs->old = policy->cur;
301 } 306 }
302 } 307 }
@@ -307,8 +312,8 @@ static void __cpufreq_notify_transition(struct cpufreq_policy *policy,
307 312
308 case CPUFREQ_POSTCHANGE: 313 case CPUFREQ_POSTCHANGE:
309 adjust_jiffies(CPUFREQ_POSTCHANGE, freqs); 314 adjust_jiffies(CPUFREQ_POSTCHANGE, freqs);
310 pr_debug("FREQ: %lu - CPU: %lu", (unsigned long)freqs->new, 315 pr_debug("FREQ: %lu - CPU: %lu\n",
311 (unsigned long)freqs->cpu); 316 (unsigned long)freqs->new, (unsigned long)freqs->cpu);
312 trace_cpu_frequency(freqs->new, freqs->cpu); 317 trace_cpu_frequency(freqs->new, freqs->cpu);
313 srcu_notifier_call_chain(&cpufreq_transition_notifier_list, 318 srcu_notifier_call_chain(&cpufreq_transition_notifier_list,
314 CPUFREQ_POSTCHANGE, freqs); 319 CPUFREQ_POSTCHANGE, freqs);
@@ -352,7 +357,7 @@ EXPORT_SYMBOL_GPL(cpufreq_notify_post_transition);
352/********************************************************************* 357/*********************************************************************
353 * SYSFS INTERFACE * 358 * SYSFS INTERFACE *
354 *********************************************************************/ 359 *********************************************************************/
355ssize_t show_boost(struct kobject *kobj, 360static ssize_t show_boost(struct kobject *kobj,
356 struct attribute *attr, char *buf) 361 struct attribute *attr, char *buf)
357{ 362{
358 return sprintf(buf, "%d\n", cpufreq_driver->boost_enabled); 363 return sprintf(buf, "%d\n", cpufreq_driver->boost_enabled);
@@ -368,13 +373,13 @@ static ssize_t store_boost(struct kobject *kobj, struct attribute *attr,
368 return -EINVAL; 373 return -EINVAL;
369 374
370 if (cpufreq_boost_trigger_state(enable)) { 375 if (cpufreq_boost_trigger_state(enable)) {
371 pr_err("%s: Cannot %s BOOST!\n", __func__, 376 pr_err("%s: Cannot %s BOOST!\n",
372 enable ? "enable" : "disable"); 377 __func__, enable ? "enable" : "disable");
373 return -EINVAL; 378 return -EINVAL;
374 } 379 }
375 380
376 pr_debug("%s: cpufreq BOOST %s\n", __func__, 381 pr_debug("%s: cpufreq BOOST %s\n",
377 enable ? "enabled" : "disabled"); 382 __func__, enable ? "enabled" : "disabled");
378 383
379 return count; 384 return count;
380} 385}
@@ -879,18 +884,25 @@ err_out_kobj_put:
879 884
880static void cpufreq_init_policy(struct cpufreq_policy *policy) 885static void cpufreq_init_policy(struct cpufreq_policy *policy)
881{ 886{
887 struct cpufreq_governor *gov = NULL;
882 struct cpufreq_policy new_policy; 888 struct cpufreq_policy new_policy;
883 int ret = 0; 889 int ret = 0;
884 890
885 memcpy(&new_policy, policy, sizeof(*policy)); 891 memcpy(&new_policy, policy, sizeof(*policy));
886 892
893 /* Update governor of new_policy to the governor used before hotplug */
894 gov = __find_governor(per_cpu(cpufreq_cpu_governor, policy->cpu));
895 if (gov)
896 pr_debug("Restoring governor %s for cpu %d\n",
897 policy->governor->name, policy->cpu);
898 else
899 gov = CPUFREQ_DEFAULT_GOVERNOR;
900
901 new_policy.governor = gov;
902
887 /* Use the default policy if its valid. */ 903 /* Use the default policy if its valid. */
888 if (cpufreq_driver->setpolicy) 904 if (cpufreq_driver->setpolicy)
889 cpufreq_parse_governor(policy->governor->name, 905 cpufreq_parse_governor(gov->name, &new_policy.policy, NULL);
890 &new_policy.policy, NULL);
891
892 /* assure that the starting sequence is run in cpufreq_set_policy */
893 policy->governor = NULL;
894 906
895 /* set default policy */ 907 /* set default policy */
896 ret = cpufreq_set_policy(policy, &new_policy); 908 ret = cpufreq_set_policy(policy, &new_policy);
@@ -927,8 +939,11 @@ static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy,
927 up_write(&policy->rwsem); 939 up_write(&policy->rwsem);
928 940
929 if (has_target()) { 941 if (has_target()) {
930 if ((ret = __cpufreq_governor(policy, CPUFREQ_GOV_START)) || 942 ret = __cpufreq_governor(policy, CPUFREQ_GOV_START);
931 (ret = __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS))) { 943 if (!ret)
944 ret = __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS);
945
946 if (ret) {
932 pr_err("%s: Failed to start governor\n", __func__); 947 pr_err("%s: Failed to start governor\n", __func__);
933 return ret; 948 return ret;
934 } 949 }
@@ -949,6 +964,8 @@ static struct cpufreq_policy *cpufreq_policy_restore(unsigned int cpu)
949 964
950 read_unlock_irqrestore(&cpufreq_driver_lock, flags); 965 read_unlock_irqrestore(&cpufreq_driver_lock, flags);
951 966
967 policy->governor = NULL;
968
952 return policy; 969 return policy;
953} 970}
954 971
@@ -1022,21 +1039,19 @@ static void update_policy_cpu(struct cpufreq_policy *policy, unsigned int cpu)
1022 1039
1023 up_write(&policy->rwsem); 1040 up_write(&policy->rwsem);
1024 1041
1025 cpufreq_frequency_table_update_policy_cpu(policy);
1026 blocking_notifier_call_chain(&cpufreq_policy_notifier_list, 1042 blocking_notifier_call_chain(&cpufreq_policy_notifier_list,
1027 CPUFREQ_UPDATE_POLICY_CPU, policy); 1043 CPUFREQ_UPDATE_POLICY_CPU, policy);
1028} 1044}
1029 1045
1030static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif, 1046static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif)
1031 bool frozen)
1032{ 1047{
1033 unsigned int j, cpu = dev->id; 1048 unsigned int j, cpu = dev->id;
1034 int ret = -ENOMEM; 1049 int ret = -ENOMEM;
1035 struct cpufreq_policy *policy; 1050 struct cpufreq_policy *policy;
1036 unsigned long flags; 1051 unsigned long flags;
1052 bool recover_policy = cpufreq_suspended;
1037#ifdef CONFIG_HOTPLUG_CPU 1053#ifdef CONFIG_HOTPLUG_CPU
1038 struct cpufreq_policy *tpolicy; 1054 struct cpufreq_policy *tpolicy;
1039 struct cpufreq_governor *gov;
1040#endif 1055#endif
1041 1056
1042 if (cpu_is_offline(cpu)) 1057 if (cpu_is_offline(cpu))
@@ -1075,9 +1090,9 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif,
1075 * Restore the saved policy when doing light-weight init and fall back 1090 * Restore the saved policy when doing light-weight init and fall back
1076 * to the full init if that fails. 1091 * to the full init if that fails.
1077 */ 1092 */
1078 policy = frozen ? cpufreq_policy_restore(cpu) : NULL; 1093 policy = recover_policy ? cpufreq_policy_restore(cpu) : NULL;
1079 if (!policy) { 1094 if (!policy) {
1080 frozen = false; 1095 recover_policy = false;
1081 policy = cpufreq_policy_alloc(); 1096 policy = cpufreq_policy_alloc();
1082 if (!policy) 1097 if (!policy)
1083 goto nomem_out; 1098 goto nomem_out;
@@ -1089,12 +1104,11 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif,
1089 * the creation of a brand new one. So we need to perform this update 1104 * the creation of a brand new one. So we need to perform this update
1090 * by invoking update_policy_cpu(). 1105 * by invoking update_policy_cpu().
1091 */ 1106 */
1092 if (frozen && cpu != policy->cpu) 1107 if (recover_policy && cpu != policy->cpu)
1093 update_policy_cpu(policy, cpu); 1108 update_policy_cpu(policy, cpu);
1094 else 1109 else
1095 policy->cpu = cpu; 1110 policy->cpu = cpu;
1096 1111
1097 policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
1098 cpumask_copy(policy->cpus, cpumask_of(cpu)); 1112 cpumask_copy(policy->cpus, cpumask_of(cpu));
1099 1113
1100 init_completion(&policy->kobj_unregister); 1114 init_completion(&policy->kobj_unregister);
@@ -1118,7 +1132,7 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif,
1118 */ 1132 */
1119 cpumask_and(policy->cpus, policy->cpus, cpu_online_mask); 1133 cpumask_and(policy->cpus, policy->cpus, cpu_online_mask);
1120 1134
1121 if (!frozen) { 1135 if (!recover_policy) {
1122 policy->user_policy.min = policy->min; 1136 policy->user_policy.min = policy->min;
1123 policy->user_policy.max = policy->max; 1137 policy->user_policy.max = policy->max;
1124 } 1138 }
@@ -1180,16 +1194,7 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif,
1180 blocking_notifier_call_chain(&cpufreq_policy_notifier_list, 1194 blocking_notifier_call_chain(&cpufreq_policy_notifier_list,
1181 CPUFREQ_START, policy); 1195 CPUFREQ_START, policy);
1182 1196
1183#ifdef CONFIG_HOTPLUG_CPU 1197 if (!recover_policy) {
1184 gov = __find_governor(per_cpu(cpufreq_cpu_governor, cpu));
1185 if (gov) {
1186 policy->governor = gov;
1187 pr_debug("Restoring governor %s for cpu %d\n",
1188 policy->governor->name, cpu);
1189 }
1190#endif
1191
1192 if (!frozen) {
1193 ret = cpufreq_add_dev_interface(policy, dev); 1198 ret = cpufreq_add_dev_interface(policy, dev);
1194 if (ret) 1199 if (ret)
1195 goto err_out_unregister; 1200 goto err_out_unregister;
@@ -1203,7 +1208,7 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif,
1203 1208
1204 cpufreq_init_policy(policy); 1209 cpufreq_init_policy(policy);
1205 1210
1206 if (!frozen) { 1211 if (!recover_policy) {
1207 policy->user_policy.policy = policy->policy; 1212 policy->user_policy.policy = policy->policy;
1208 policy->user_policy.governor = policy->governor; 1213 policy->user_policy.governor = policy->governor;
1209 } 1214 }
@@ -1226,7 +1231,7 @@ err_get_freq:
1226 if (cpufreq_driver->exit) 1231 if (cpufreq_driver->exit)
1227 cpufreq_driver->exit(policy); 1232 cpufreq_driver->exit(policy);
1228err_set_policy_cpu: 1233err_set_policy_cpu:
1229 if (frozen) { 1234 if (recover_policy) {
1230 /* Do not leave stale fallback data behind. */ 1235 /* Do not leave stale fallback data behind. */
1231 per_cpu(cpufreq_cpu_data_fallback, cpu) = NULL; 1236 per_cpu(cpufreq_cpu_data_fallback, cpu) = NULL;
1232 cpufreq_policy_put_kobj(policy); 1237 cpufreq_policy_put_kobj(policy);
@@ -1250,7 +1255,7 @@ nomem_out:
1250 */ 1255 */
1251static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif) 1256static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif)
1252{ 1257{
1253 return __cpufreq_add_dev(dev, sif, false); 1258 return __cpufreq_add_dev(dev, sif);
1254} 1259}
1255 1260
1256static int cpufreq_nominate_new_policy_cpu(struct cpufreq_policy *policy, 1261static int cpufreq_nominate_new_policy_cpu(struct cpufreq_policy *policy,
@@ -1265,7 +1270,7 @@ static int cpufreq_nominate_new_policy_cpu(struct cpufreq_policy *policy,
1265 sysfs_remove_link(&cpu_dev->kobj, "cpufreq"); 1270 sysfs_remove_link(&cpu_dev->kobj, "cpufreq");
1266 ret = kobject_move(&policy->kobj, &cpu_dev->kobj); 1271 ret = kobject_move(&policy->kobj, &cpu_dev->kobj);
1267 if (ret) { 1272 if (ret) {
1268 pr_err("%s: Failed to move kobj: %d", __func__, ret); 1273 pr_err("%s: Failed to move kobj: %d\n", __func__, ret);
1269 1274
1270 down_write(&policy->rwsem); 1275 down_write(&policy->rwsem);
1271 cpumask_set_cpu(old_cpu, policy->cpus); 1276 cpumask_set_cpu(old_cpu, policy->cpus);
@@ -1281,8 +1286,7 @@ static int cpufreq_nominate_new_policy_cpu(struct cpufreq_policy *policy,
1281} 1286}
1282 1287
1283static int __cpufreq_remove_dev_prepare(struct device *dev, 1288static int __cpufreq_remove_dev_prepare(struct device *dev,
1284 struct subsys_interface *sif, 1289 struct subsys_interface *sif)
1285 bool frozen)
1286{ 1290{
1287 unsigned int cpu = dev->id, cpus; 1291 unsigned int cpu = dev->id, cpus;
1288 int new_cpu, ret; 1292 int new_cpu, ret;
@@ -1296,7 +1300,7 @@ static int __cpufreq_remove_dev_prepare(struct device *dev,
1296 policy = per_cpu(cpufreq_cpu_data, cpu); 1300 policy = per_cpu(cpufreq_cpu_data, cpu);
1297 1301
1298 /* Save the policy somewhere when doing a light-weight tear-down */ 1302 /* Save the policy somewhere when doing a light-weight tear-down */
1299 if (frozen) 1303 if (cpufreq_suspended)
1300 per_cpu(cpufreq_cpu_data_fallback, cpu) = policy; 1304 per_cpu(cpufreq_cpu_data_fallback, cpu) = policy;
1301 1305
1302 write_unlock_irqrestore(&cpufreq_driver_lock, flags); 1306 write_unlock_irqrestore(&cpufreq_driver_lock, flags);
@@ -1314,11 +1318,9 @@ static int __cpufreq_remove_dev_prepare(struct device *dev,
1314 } 1318 }
1315 } 1319 }
1316 1320
1317#ifdef CONFIG_HOTPLUG_CPU
1318 if (!cpufreq_driver->setpolicy) 1321 if (!cpufreq_driver->setpolicy)
1319 strncpy(per_cpu(cpufreq_cpu_governor, cpu), 1322 strncpy(per_cpu(cpufreq_cpu_governor, cpu),
1320 policy->governor->name, CPUFREQ_NAME_LEN); 1323 policy->governor->name, CPUFREQ_NAME_LEN);
1321#endif
1322 1324
1323 down_read(&policy->rwsem); 1325 down_read(&policy->rwsem);
1324 cpus = cpumask_weight(policy->cpus); 1326 cpus = cpumask_weight(policy->cpus);
@@ -1331,19 +1333,19 @@ static int __cpufreq_remove_dev_prepare(struct device *dev,
1331 if (new_cpu >= 0) { 1333 if (new_cpu >= 0) {
1332 update_policy_cpu(policy, new_cpu); 1334 update_policy_cpu(policy, new_cpu);
1333 1335
1334 if (!frozen) { 1336 if (!cpufreq_suspended)
1335 pr_debug("%s: policy Kobject moved to cpu: %d from: %d\n", 1337 pr_debug("%s: policy Kobject moved to cpu: %d from: %d\n",
1336 __func__, new_cpu, cpu); 1338 __func__, new_cpu, cpu);
1337 }
1338 } 1339 }
1340 } else if (cpufreq_driver->stop_cpu && cpufreq_driver->setpolicy) {
1341 cpufreq_driver->stop_cpu(policy);
1339 } 1342 }
1340 1343
1341 return 0; 1344 return 0;
1342} 1345}
1343 1346
1344static int __cpufreq_remove_dev_finish(struct device *dev, 1347static int __cpufreq_remove_dev_finish(struct device *dev,
1345 struct subsys_interface *sif, 1348 struct subsys_interface *sif)
1346 bool frozen)
1347{ 1349{
1348 unsigned int cpu = dev->id, cpus; 1350 unsigned int cpu = dev->id, cpus;
1349 int ret; 1351 int ret;
@@ -1373,12 +1375,12 @@ static int __cpufreq_remove_dev_finish(struct device *dev,
1373 CPUFREQ_GOV_POLICY_EXIT); 1375 CPUFREQ_GOV_POLICY_EXIT);
1374 if (ret) { 1376 if (ret) {
1375 pr_err("%s: Failed to exit governor\n", 1377 pr_err("%s: Failed to exit governor\n",
1376 __func__); 1378 __func__);
1377 return ret; 1379 return ret;
1378 } 1380 }
1379 } 1381 }
1380 1382
1381 if (!frozen) 1383 if (!cpufreq_suspended)
1382 cpufreq_policy_put_kobj(policy); 1384 cpufreq_policy_put_kobj(policy);
1383 1385
1384 /* 1386 /*
@@ -1394,16 +1396,16 @@ static int __cpufreq_remove_dev_finish(struct device *dev,
1394 list_del(&policy->policy_list); 1396 list_del(&policy->policy_list);
1395 write_unlock_irqrestore(&cpufreq_driver_lock, flags); 1397 write_unlock_irqrestore(&cpufreq_driver_lock, flags);
1396 1398
1397 if (!frozen) 1399 if (!cpufreq_suspended)
1398 cpufreq_policy_free(policy); 1400 cpufreq_policy_free(policy);
1399 } else { 1401 } else if (has_target()) {
1400 if (has_target()) { 1402 ret = __cpufreq_governor(policy, CPUFREQ_GOV_START);
1401 if ((ret = __cpufreq_governor(policy, CPUFREQ_GOV_START)) || 1403 if (!ret)
1402 (ret = __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS))) { 1404 ret = __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS);
1403 pr_err("%s: Failed to start governor\n", 1405
1404 __func__); 1406 if (ret) {
1405 return ret; 1407 pr_err("%s: Failed to start governor\n", __func__);
1406 } 1408 return ret;
1407 } 1409 }
1408 } 1410 }
1409 1411
@@ -1424,10 +1426,10 @@ static int cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif)
1424 if (cpu_is_offline(cpu)) 1426 if (cpu_is_offline(cpu))
1425 return 0; 1427 return 0;
1426 1428
1427 ret = __cpufreq_remove_dev_prepare(dev, sif, false); 1429 ret = __cpufreq_remove_dev_prepare(dev, sif);
1428 1430
1429 if (!ret) 1431 if (!ret)
1430 ret = __cpufreq_remove_dev_finish(dev, sif, false); 1432 ret = __cpufreq_remove_dev_finish(dev, sif);
1431 1433
1432 return ret; 1434 return ret;
1433} 1435}
@@ -1458,8 +1460,8 @@ static void cpufreq_out_of_sync(unsigned int cpu, unsigned int old_freq,
1458 struct cpufreq_freqs freqs; 1460 struct cpufreq_freqs freqs;
1459 unsigned long flags; 1461 unsigned long flags;
1460 1462
1461 pr_debug("Warning: CPU frequency out of sync: cpufreq and timing " 1463 pr_debug("Warning: CPU frequency out of sync: cpufreq and timing core thinks of %u, is %u kHz\n",
1462 "core thinks of %u, is %u kHz.\n", old_freq, new_freq); 1464 old_freq, new_freq);
1463 1465
1464 freqs.old = old_freq; 1466 freqs.old = old_freq;
1465 freqs.new = new_freq; 1467 freqs.new = new_freq;
@@ -1570,83 +1572,104 @@ static struct subsys_interface cpufreq_interface = {
1570 .remove_dev = cpufreq_remove_dev, 1572 .remove_dev = cpufreq_remove_dev,
1571}; 1573};
1572 1574
1575/*
1576 * In case platform wants some specific frequency to be configured
1577 * during suspend..
1578 */
1579int cpufreq_generic_suspend(struct cpufreq_policy *policy)
1580{
1581 int ret;
1582
1583 if (!policy->suspend_freq) {
1584 pr_err("%s: suspend_freq can't be zero\n", __func__);
1585 return -EINVAL;
1586 }
1587
1588 pr_debug("%s: Setting suspend-freq: %u\n", __func__,
1589 policy->suspend_freq);
1590
1591 ret = __cpufreq_driver_target(policy, policy->suspend_freq,
1592 CPUFREQ_RELATION_H);
1593 if (ret)
1594 pr_err("%s: unable to set suspend-freq: %u. err: %d\n",
1595 __func__, policy->suspend_freq, ret);
1596
1597 return ret;
1598}
1599EXPORT_SYMBOL(cpufreq_generic_suspend);
1600
1573/** 1601/**
1574 * cpufreq_bp_suspend - Prepare the boot CPU for system suspend. 1602 * cpufreq_suspend() - Suspend CPUFreq governors
1575 * 1603 *
1576 * This function is only executed for the boot processor. The other CPUs 1604 * Called during system wide Suspend/Hibernate cycles for suspending governors
1577 * have been put offline by means of CPU hotplug. 1605 * as some platforms can't change frequency after this point in suspend cycle.
1606 * Because some of the devices (like: i2c, regulators, etc) they use for
1607 * changing frequency are suspended quickly after this point.
1578 */ 1608 */
1579static int cpufreq_bp_suspend(void) 1609void cpufreq_suspend(void)
1580{ 1610{
1581 int ret = 0;
1582
1583 int cpu = smp_processor_id();
1584 struct cpufreq_policy *policy; 1611 struct cpufreq_policy *policy;
1585 1612
1586 pr_debug("suspending cpu %u\n", cpu); 1613 if (!cpufreq_driver)
1614 return;
1587 1615
1588 /* If there's no policy for the boot CPU, we have nothing to do. */ 1616 if (!has_target())
1589 policy = cpufreq_cpu_get(cpu); 1617 return;
1590 if (!policy)
1591 return 0;
1592 1618
1593 if (cpufreq_driver->suspend) { 1619 pr_debug("%s: Suspending Governors\n", __func__);
1594 ret = cpufreq_driver->suspend(policy); 1620
1595 if (ret) 1621 list_for_each_entry(policy, &cpufreq_policy_list, policy_list) {
1596 printk(KERN_ERR "cpufreq: suspend failed in ->suspend " 1622 if (__cpufreq_governor(policy, CPUFREQ_GOV_STOP))
1597 "step on CPU %u\n", policy->cpu); 1623 pr_err("%s: Failed to stop governor for policy: %p\n",
1624 __func__, policy);
1625 else if (cpufreq_driver->suspend
1626 && cpufreq_driver->suspend(policy))
1627 pr_err("%s: Failed to suspend driver: %p\n", __func__,
1628 policy);
1598 } 1629 }
1599 1630
1600 cpufreq_cpu_put(policy); 1631 cpufreq_suspended = true;
1601 return ret;
1602} 1632}
1603 1633
1604/** 1634/**
1605 * cpufreq_bp_resume - Restore proper frequency handling of the boot CPU. 1635 * cpufreq_resume() - Resume CPUFreq governors
1606 * 1636 *
1607 * 1.) resume CPUfreq hardware support (cpufreq_driver->resume()) 1637 * Called during system wide Suspend/Hibernate cycle for resuming governors that
1608 * 2.) schedule call cpufreq_update_policy() ASAP as interrupts are 1638 * are suspended with cpufreq_suspend().
1609 * restored. It will verify that the current freq is in sync with
1610 * what we believe it to be. This is a bit later than when it
1611 * should be, but nonethteless it's better than calling
1612 * cpufreq_driver->get() here which might re-enable interrupts...
1613 *
1614 * This function is only executed for the boot CPU. The other CPUs have not
1615 * been turned on yet.
1616 */ 1639 */
1617static void cpufreq_bp_resume(void) 1640void cpufreq_resume(void)
1618{ 1641{
1619 int ret = 0;
1620
1621 int cpu = smp_processor_id();
1622 struct cpufreq_policy *policy; 1642 struct cpufreq_policy *policy;
1623 1643
1624 pr_debug("resuming cpu %u\n", cpu); 1644 if (!cpufreq_driver)
1645 return;
1625 1646
1626 /* If there's no policy for the boot CPU, we have nothing to do. */ 1647 if (!has_target())
1627 policy = cpufreq_cpu_get(cpu);
1628 if (!policy)
1629 return; 1648 return;
1630 1649
1631 if (cpufreq_driver->resume) { 1650 pr_debug("%s: Resuming Governors\n", __func__);
1632 ret = cpufreq_driver->resume(policy);
1633 if (ret) {
1634 printk(KERN_ERR "cpufreq: resume failed in ->resume "
1635 "step on CPU %u\n", policy->cpu);
1636 goto fail;
1637 }
1638 }
1639 1651
1640 schedule_work(&policy->update); 1652 cpufreq_suspended = false;
1641 1653
1642fail: 1654 list_for_each_entry(policy, &cpufreq_policy_list, policy_list) {
1643 cpufreq_cpu_put(policy); 1655 if (__cpufreq_governor(policy, CPUFREQ_GOV_START)
1644} 1656 || __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS))
1657 pr_err("%s: Failed to start governor for policy: %p\n",
1658 __func__, policy);
1659 else if (cpufreq_driver->resume
1660 && cpufreq_driver->resume(policy))
1661 pr_err("%s: Failed to resume driver: %p\n", __func__,
1662 policy);
1645 1663
1646static struct syscore_ops cpufreq_syscore_ops = { 1664 /*
1647 .suspend = cpufreq_bp_suspend, 1665 * schedule call cpufreq_update_policy() for boot CPU, i.e. last
1648 .resume = cpufreq_bp_resume, 1666 * policy in list. It will verify that the current freq is in
1649}; 1667 * sync with what we believe it to be.
1668 */
1669 if (list_is_last(&policy->policy_list, &cpufreq_policy_list))
1670 schedule_work(&policy->update);
1671 }
1672}
1650 1673
1651/** 1674/**
1652 * cpufreq_get_current_driver - return current driver's name 1675 * cpufreq_get_current_driver - return current driver's name
@@ -1762,7 +1785,7 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
1762 target_freq = policy->min; 1785 target_freq = policy->min;
1763 1786
1764 pr_debug("target for CPU %u: %u kHz, relation %u, requested %u kHz\n", 1787 pr_debug("target for CPU %u: %u kHz, relation %u, requested %u kHz\n",
1765 policy->cpu, target_freq, relation, old_target_freq); 1788 policy->cpu, target_freq, relation, old_target_freq);
1766 1789
1767 /* 1790 /*
1768 * This might look like a redundant call as we are checking it again 1791 * This might look like a redundant call as we are checking it again
@@ -1807,8 +1830,7 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
1807 freqs.flags = 0; 1830 freqs.flags = 0;
1808 1831
1809 pr_debug("%s: cpu: %d, oldfreq: %u, new freq: %u\n", 1832 pr_debug("%s: cpu: %d, oldfreq: %u, new freq: %u\n",
1810 __func__, policy->cpu, freqs.old, 1833 __func__, policy->cpu, freqs.old, freqs.new);
1811 freqs.new);
1812 1834
1813 cpufreq_notify_transition(policy, &freqs, 1835 cpufreq_notify_transition(policy, &freqs,
1814 CPUFREQ_PRECHANGE); 1836 CPUFREQ_PRECHANGE);
@@ -1817,7 +1839,7 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
1817 retval = cpufreq_driver->target_index(policy, index); 1839 retval = cpufreq_driver->target_index(policy, index);
1818 if (retval) 1840 if (retval)
1819 pr_err("%s: Failed to change cpu frequency: %d\n", 1841 pr_err("%s: Failed to change cpu frequency: %d\n",
1820 __func__, retval); 1842 __func__, retval);
1821 1843
1822 if (notify) 1844 if (notify)
1823 cpufreq_notify_post_transition(policy, &freqs, retval); 1845 cpufreq_notify_post_transition(policy, &freqs, retval);
@@ -1863,17 +1885,18 @@ static int __cpufreq_governor(struct cpufreq_policy *policy,
1863 struct cpufreq_governor *gov = NULL; 1885 struct cpufreq_governor *gov = NULL;
1864#endif 1886#endif
1865 1887
1888 /* Don't start any governor operations if we are entering suspend */
1889 if (cpufreq_suspended)
1890 return 0;
1891
1866 if (policy->governor->max_transition_latency && 1892 if (policy->governor->max_transition_latency &&
1867 policy->cpuinfo.transition_latency > 1893 policy->cpuinfo.transition_latency >
1868 policy->governor->max_transition_latency) { 1894 policy->governor->max_transition_latency) {
1869 if (!gov) 1895 if (!gov)
1870 return -EINVAL; 1896 return -EINVAL;
1871 else { 1897 else {
1872 printk(KERN_WARNING "%s governor failed, too long" 1898 pr_warn("%s governor failed, too long transition latency of HW, fallback to %s governor\n",
1873 " transition latency of HW, fallback" 1899 policy->governor->name, gov->name);
1874 " to %s governor\n",
1875 policy->governor->name,
1876 gov->name);
1877 policy->governor = gov; 1900 policy->governor = gov;
1878 } 1901 }
1879 } 1902 }
@@ -1883,7 +1906,7 @@ static int __cpufreq_governor(struct cpufreq_policy *policy,
1883 return -EINVAL; 1906 return -EINVAL;
1884 1907
1885 pr_debug("__cpufreq_governor for CPU %u, event %u\n", 1908 pr_debug("__cpufreq_governor for CPU %u, event %u\n",
1886 policy->cpu, event); 1909 policy->cpu, event);
1887 1910
1888 mutex_lock(&cpufreq_governor_lock); 1911 mutex_lock(&cpufreq_governor_lock);
1889 if ((policy->governor_enabled && event == CPUFREQ_GOV_START) 1912 if ((policy->governor_enabled && event == CPUFREQ_GOV_START)
@@ -1950,9 +1973,7 @@ EXPORT_SYMBOL_GPL(cpufreq_register_governor);
1950 1973
1951void cpufreq_unregister_governor(struct cpufreq_governor *governor) 1974void cpufreq_unregister_governor(struct cpufreq_governor *governor)
1952{ 1975{
1953#ifdef CONFIG_HOTPLUG_CPU
1954 int cpu; 1976 int cpu;
1955#endif
1956 1977
1957 if (!governor) 1978 if (!governor)
1958 return; 1979 return;
@@ -1960,14 +1981,12 @@ void cpufreq_unregister_governor(struct cpufreq_governor *governor)
1960 if (cpufreq_disabled()) 1981 if (cpufreq_disabled())
1961 return; 1982 return;
1962 1983
1963#ifdef CONFIG_HOTPLUG_CPU
1964 for_each_present_cpu(cpu) { 1984 for_each_present_cpu(cpu) {
1965 if (cpu_online(cpu)) 1985 if (cpu_online(cpu))
1966 continue; 1986 continue;
1967 if (!strcmp(per_cpu(cpufreq_cpu_governor, cpu), governor->name)) 1987 if (!strcmp(per_cpu(cpufreq_cpu_governor, cpu), governor->name))
1968 strcpy(per_cpu(cpufreq_cpu_governor, cpu), "\0"); 1988 strcpy(per_cpu(cpufreq_cpu_governor, cpu), "\0");
1969 } 1989 }
1970#endif
1971 1990
1972 mutex_lock(&cpufreq_governor_mutex); 1991 mutex_lock(&cpufreq_governor_mutex);
1973 list_del(&governor->governor_list); 1992 list_del(&governor->governor_list);
@@ -2012,22 +2031,21 @@ EXPORT_SYMBOL(cpufreq_get_policy);
2012static int cpufreq_set_policy(struct cpufreq_policy *policy, 2031static int cpufreq_set_policy(struct cpufreq_policy *policy,
2013 struct cpufreq_policy *new_policy) 2032 struct cpufreq_policy *new_policy)
2014{ 2033{
2015 int ret = 0, failed = 1; 2034 struct cpufreq_governor *old_gov;
2035 int ret;
2016 2036
2017 pr_debug("setting new policy for CPU %u: %u - %u kHz\n", new_policy->cpu, 2037 pr_debug("setting new policy for CPU %u: %u - %u kHz\n",
2018 new_policy->min, new_policy->max); 2038 new_policy->cpu, new_policy->min, new_policy->max);
2019 2039
2020 memcpy(&new_policy->cpuinfo, &policy->cpuinfo, sizeof(policy->cpuinfo)); 2040 memcpy(&new_policy->cpuinfo, &policy->cpuinfo, sizeof(policy->cpuinfo));
2021 2041
2022 if (new_policy->min > policy->max || new_policy->max < policy->min) { 2042 if (new_policy->min > policy->max || new_policy->max < policy->min)
2023 ret = -EINVAL; 2043 return -EINVAL;
2024 goto error_out;
2025 }
2026 2044
2027 /* verify the cpu speed can be set within this limit */ 2045 /* verify the cpu speed can be set within this limit */
2028 ret = cpufreq_driver->verify(new_policy); 2046 ret = cpufreq_driver->verify(new_policy);
2029 if (ret) 2047 if (ret)
2030 goto error_out; 2048 return ret;
2031 2049
2032 /* adjust if necessary - all reasons */ 2050 /* adjust if necessary - all reasons */
2033 blocking_notifier_call_chain(&cpufreq_policy_notifier_list, 2051 blocking_notifier_call_chain(&cpufreq_policy_notifier_list,
@@ -2043,7 +2061,7 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy,
2043 */ 2061 */
2044 ret = cpufreq_driver->verify(new_policy); 2062 ret = cpufreq_driver->verify(new_policy);
2045 if (ret) 2063 if (ret)
2046 goto error_out; 2064 return ret;
2047 2065
2048 /* notification of the new policy */ 2066 /* notification of the new policy */
2049 blocking_notifier_call_chain(&cpufreq_policy_notifier_list, 2067 blocking_notifier_call_chain(&cpufreq_policy_notifier_list,
@@ -2053,63 +2071,53 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy,
2053 policy->max = new_policy->max; 2071 policy->max = new_policy->max;
2054 2072
2055 pr_debug("new min and max freqs are %u - %u kHz\n", 2073 pr_debug("new min and max freqs are %u - %u kHz\n",
2056 policy->min, policy->max); 2074 policy->min, policy->max);
2057 2075
2058 if (cpufreq_driver->setpolicy) { 2076 if (cpufreq_driver->setpolicy) {
2059 policy->policy = new_policy->policy; 2077 policy->policy = new_policy->policy;
2060 pr_debug("setting range\n"); 2078 pr_debug("setting range\n");
2061 ret = cpufreq_driver->setpolicy(new_policy); 2079 return cpufreq_driver->setpolicy(new_policy);
2062 } else { 2080 }
2063 if (new_policy->governor != policy->governor) {
2064 /* save old, working values */
2065 struct cpufreq_governor *old_gov = policy->governor;
2066
2067 pr_debug("governor switch\n");
2068
2069 /* end old governor */
2070 if (policy->governor) {
2071 __cpufreq_governor(policy, CPUFREQ_GOV_STOP);
2072 up_write(&policy->rwsem);
2073 __cpufreq_governor(policy,
2074 CPUFREQ_GOV_POLICY_EXIT);
2075 down_write(&policy->rwsem);
2076 }
2077 2081
2078 /* start new governor */ 2082 if (new_policy->governor == policy->governor)
2079 policy->governor = new_policy->governor; 2083 goto out;
2080 if (!__cpufreq_governor(policy, CPUFREQ_GOV_POLICY_INIT)) {
2081 if (!__cpufreq_governor(policy, CPUFREQ_GOV_START)) {
2082 failed = 0;
2083 } else {
2084 up_write(&policy->rwsem);
2085 __cpufreq_governor(policy,
2086 CPUFREQ_GOV_POLICY_EXIT);
2087 down_write(&policy->rwsem);
2088 }
2089 }
2090 2084
2091 if (failed) { 2085 pr_debug("governor switch\n");
2092 /* new governor failed, so re-start old one */ 2086
2093 pr_debug("starting governor %s failed\n", 2087 /* save old, working values */
2094 policy->governor->name); 2088 old_gov = policy->governor;
2095 if (old_gov) { 2089 /* end old governor */
2096 policy->governor = old_gov; 2090 if (old_gov) {
2097 __cpufreq_governor(policy, 2091 __cpufreq_governor(policy, CPUFREQ_GOV_STOP);
2098 CPUFREQ_GOV_POLICY_INIT); 2092 up_write(&policy->rwsem);
2099 __cpufreq_governor(policy, 2093 __cpufreq_governor(policy, CPUFREQ_GOV_POLICY_EXIT);
2100 CPUFREQ_GOV_START); 2094 down_write(&policy->rwsem);
2101 }
2102 ret = -EINVAL;
2103 goto error_out;
2104 }
2105 /* might be a policy change, too, so fall through */
2106 }
2107 pr_debug("governor: change or update limits\n");
2108 ret = __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS);
2109 } 2095 }
2110 2096
2111error_out: 2097 /* start new governor */
2112 return ret; 2098 policy->governor = new_policy->governor;
2099 if (!__cpufreq_governor(policy, CPUFREQ_GOV_POLICY_INIT)) {
2100 if (!__cpufreq_governor(policy, CPUFREQ_GOV_START))
2101 goto out;
2102
2103 up_write(&policy->rwsem);
2104 __cpufreq_governor(policy, CPUFREQ_GOV_POLICY_EXIT);
2105 down_write(&policy->rwsem);
2106 }
2107
2108 /* new governor failed, so re-start old one */
2109 pr_debug("starting governor %s failed\n", policy->governor->name);
2110 if (old_gov) {
2111 policy->governor = old_gov;
2112 __cpufreq_governor(policy, CPUFREQ_GOV_POLICY_INIT);
2113 __cpufreq_governor(policy, CPUFREQ_GOV_START);
2114 }
2115
2116 return -EINVAL;
2117
2118 out:
2119 pr_debug("governor: change or update limits\n");
2120 return __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS);
2113} 2121}
2114 2122
2115/** 2123/**
@@ -2145,8 +2153,13 @@ int cpufreq_update_policy(unsigned int cpu)
2145 */ 2153 */
2146 if (cpufreq_driver->get && !cpufreq_driver->setpolicy) { 2154 if (cpufreq_driver->get && !cpufreq_driver->setpolicy) {
2147 new_policy.cur = cpufreq_driver->get(cpu); 2155 new_policy.cur = cpufreq_driver->get(cpu);
2156 if (WARN_ON(!new_policy.cur)) {
2157 ret = -EIO;
2158 goto no_policy;
2159 }
2160
2148 if (!policy->cur) { 2161 if (!policy->cur) {
2149 pr_debug("Driver did not initialize current freq"); 2162 pr_debug("Driver did not initialize current freq\n");
2150 policy->cur = new_policy.cur; 2163 policy->cur = new_policy.cur;
2151 } else { 2164 } else {
2152 if (policy->cur != new_policy.cur && has_target()) 2165 if (policy->cur != new_policy.cur && has_target())
@@ -2170,30 +2183,24 @@ static int cpufreq_cpu_callback(struct notifier_block *nfb,
2170{ 2183{
2171 unsigned int cpu = (unsigned long)hcpu; 2184 unsigned int cpu = (unsigned long)hcpu;
2172 struct device *dev; 2185 struct device *dev;
2173 bool frozen = false;
2174 2186
2175 dev = get_cpu_device(cpu); 2187 dev = get_cpu_device(cpu);
2176 if (dev) { 2188 if (dev) {
2177
2178 if (action & CPU_TASKS_FROZEN)
2179 frozen = true;
2180
2181 switch (action & ~CPU_TASKS_FROZEN) { 2189 switch (action & ~CPU_TASKS_FROZEN) {
2182 case CPU_ONLINE: 2190 case CPU_ONLINE:
2183 __cpufreq_add_dev(dev, NULL, frozen); 2191 __cpufreq_add_dev(dev, NULL);
2184 cpufreq_update_policy(cpu);
2185 break; 2192 break;
2186 2193
2187 case CPU_DOWN_PREPARE: 2194 case CPU_DOWN_PREPARE:
2188 __cpufreq_remove_dev_prepare(dev, NULL, frozen); 2195 __cpufreq_remove_dev_prepare(dev, NULL);
2189 break; 2196 break;
2190 2197
2191 case CPU_POST_DEAD: 2198 case CPU_POST_DEAD:
2192 __cpufreq_remove_dev_finish(dev, NULL, frozen); 2199 __cpufreq_remove_dev_finish(dev, NULL);
2193 break; 2200 break;
2194 2201
2195 case CPU_DOWN_FAILED: 2202 case CPU_DOWN_FAILED:
2196 __cpufreq_add_dev(dev, NULL, frozen); 2203 __cpufreq_add_dev(dev, NULL);
2197 break; 2204 break;
2198 } 2205 }
2199 } 2206 }
@@ -2249,8 +2256,8 @@ int cpufreq_boost_trigger_state(int state)
2249 cpufreq_driver->boost_enabled = !state; 2256 cpufreq_driver->boost_enabled = !state;
2250 write_unlock_irqrestore(&cpufreq_driver_lock, flags); 2257 write_unlock_irqrestore(&cpufreq_driver_lock, flags);
2251 2258
2252 pr_err("%s: Cannot %s BOOST\n", __func__, 2259 pr_err("%s: Cannot %s BOOST\n",
2253 state ? "enable" : "disable"); 2260 __func__, state ? "enable" : "disable");
2254 } 2261 }
2255 2262
2256 return ret; 2263 return ret;
@@ -2295,7 +2302,9 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
2295 2302
2296 if (!driver_data || !driver_data->verify || !driver_data->init || 2303 if (!driver_data || !driver_data->verify || !driver_data->init ||
2297 !(driver_data->setpolicy || driver_data->target_index || 2304 !(driver_data->setpolicy || driver_data->target_index ||
2298 driver_data->target)) 2305 driver_data->target) ||
2306 (driver_data->setpolicy && (driver_data->target_index ||
2307 driver_data->target)))
2299 return -EINVAL; 2308 return -EINVAL;
2300 2309
2301 pr_debug("trying to register driver %s\n", driver_data->name); 2310 pr_debug("trying to register driver %s\n", driver_data->name);
@@ -2322,7 +2331,7 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
2322 ret = cpufreq_sysfs_create_file(&boost.attr); 2331 ret = cpufreq_sysfs_create_file(&boost.attr);
2323 if (ret) { 2332 if (ret) {
2324 pr_err("%s: cannot register global BOOST sysfs file\n", 2333 pr_err("%s: cannot register global BOOST sysfs file\n",
2325 __func__); 2334 __func__);
2326 goto err_null_driver; 2335 goto err_null_driver;
2327 } 2336 }
2328 } 2337 }
@@ -2345,7 +2354,7 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
2345 /* if all ->init() calls failed, unregister */ 2354 /* if all ->init() calls failed, unregister */
2346 if (ret) { 2355 if (ret) {
2347 pr_debug("no CPU initialized for driver %s\n", 2356 pr_debug("no CPU initialized for driver %s\n",
2348 driver_data->name); 2357 driver_data->name);
2349 goto err_if_unreg; 2358 goto err_if_unreg;
2350 } 2359 }
2351 } 2360 }
@@ -2409,7 +2418,6 @@ static int __init cpufreq_core_init(void)
2409 2418
2410 cpufreq_global_kobject = kobject_create(); 2419 cpufreq_global_kobject = kobject_create();
2411 BUG_ON(!cpufreq_global_kobject); 2420 BUG_ON(!cpufreq_global_kobject);
2412 register_syscore_ops(&cpufreq_syscore_ops);
2413 2421
2414 return 0; 2422 return 0;
2415} 2423}
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
index 79911a27a48a..ecaaebf969fc 100644
--- a/drivers/cpufreq/cpufreq_stats.c
+++ b/drivers/cpufreq/cpufreq_stats.c
@@ -180,27 +180,25 @@ static void cpufreq_stats_free_table(unsigned int cpu)
180 cpufreq_cpu_put(policy); 180 cpufreq_cpu_put(policy);
181} 181}
182 182
183static int __cpufreq_stats_create_table(struct cpufreq_policy *policy, 183static int __cpufreq_stats_create_table(struct cpufreq_policy *policy)
184 struct cpufreq_frequency_table *table)
185{ 184{
186 unsigned int i, j, count = 0, ret = 0; 185 unsigned int i, j, count = 0, ret = 0;
187 struct cpufreq_stats *stat; 186 struct cpufreq_stats *stat;
188 struct cpufreq_policy *current_policy;
189 unsigned int alloc_size; 187 unsigned int alloc_size;
190 unsigned int cpu = policy->cpu; 188 unsigned int cpu = policy->cpu;
189 struct cpufreq_frequency_table *table;
190
191 table = cpufreq_frequency_get_table(cpu);
192 if (unlikely(!table))
193 return 0;
194
191 if (per_cpu(cpufreq_stats_table, cpu)) 195 if (per_cpu(cpufreq_stats_table, cpu))
192 return -EBUSY; 196 return -EBUSY;
193 stat = kzalloc(sizeof(*stat), GFP_KERNEL); 197 stat = kzalloc(sizeof(*stat), GFP_KERNEL);
194 if ((stat) == NULL) 198 if ((stat) == NULL)
195 return -ENOMEM; 199 return -ENOMEM;
196 200
197 current_policy = cpufreq_cpu_get(cpu); 201 ret = sysfs_create_group(&policy->kobj, &stats_attr_group);
198 if (current_policy == NULL) {
199 ret = -EINVAL;
200 goto error_get_fail;
201 }
202
203 ret = sysfs_create_group(&current_policy->kobj, &stats_attr_group);
204 if (ret) 202 if (ret)
205 goto error_out; 203 goto error_out;
206 204
@@ -223,7 +221,7 @@ static int __cpufreq_stats_create_table(struct cpufreq_policy *policy,
223 stat->time_in_state = kzalloc(alloc_size, GFP_KERNEL); 221 stat->time_in_state = kzalloc(alloc_size, GFP_KERNEL);
224 if (!stat->time_in_state) { 222 if (!stat->time_in_state) {
225 ret = -ENOMEM; 223 ret = -ENOMEM;
226 goto error_out; 224 goto error_alloc;
227 } 225 }
228 stat->freq_table = (unsigned int *)(stat->time_in_state + count); 226 stat->freq_table = (unsigned int *)(stat->time_in_state + count);
229 227
@@ -243,11 +241,10 @@ static int __cpufreq_stats_create_table(struct cpufreq_policy *policy,
243 stat->last_time = get_jiffies_64(); 241 stat->last_time = get_jiffies_64();
244 stat->last_index = freq_table_get_index(stat, policy->cur); 242 stat->last_index = freq_table_get_index(stat, policy->cur);
245 spin_unlock(&cpufreq_stats_lock); 243 spin_unlock(&cpufreq_stats_lock);
246 cpufreq_cpu_put(current_policy);
247 return 0; 244 return 0;
245error_alloc:
246 sysfs_remove_group(&policy->kobj, &stats_attr_group);
248error_out: 247error_out:
249 cpufreq_cpu_put(current_policy);
250error_get_fail:
251 kfree(stat); 248 kfree(stat);
252 per_cpu(cpufreq_stats_table, cpu) = NULL; 249 per_cpu(cpufreq_stats_table, cpu) = NULL;
253 return ret; 250 return ret;
@@ -256,7 +253,6 @@ error_get_fail:
256static void cpufreq_stats_create_table(unsigned int cpu) 253static void cpufreq_stats_create_table(unsigned int cpu)
257{ 254{
258 struct cpufreq_policy *policy; 255 struct cpufreq_policy *policy;
259 struct cpufreq_frequency_table *table;
260 256
261 /* 257 /*
262 * "likely(!policy)" because normally cpufreq_stats will be registered 258 * "likely(!policy)" because normally cpufreq_stats will be registered
@@ -266,9 +262,7 @@ static void cpufreq_stats_create_table(unsigned int cpu)
266 if (likely(!policy)) 262 if (likely(!policy))
267 return; 263 return;
268 264
269 table = cpufreq_frequency_get_table(policy->cpu); 265 __cpufreq_stats_create_table(policy);
270 if (likely(table))
271 __cpufreq_stats_create_table(policy, table);
272 266
273 cpufreq_cpu_put(policy); 267 cpufreq_cpu_put(policy);
274} 268}
@@ -291,20 +285,14 @@ static int cpufreq_stat_notifier_policy(struct notifier_block *nb,
291{ 285{
292 int ret = 0; 286 int ret = 0;
293 struct cpufreq_policy *policy = data; 287 struct cpufreq_policy *policy = data;
294 struct cpufreq_frequency_table *table;
295 unsigned int cpu = policy->cpu;
296 288
297 if (val == CPUFREQ_UPDATE_POLICY_CPU) { 289 if (val == CPUFREQ_UPDATE_POLICY_CPU) {
298 cpufreq_stats_update_policy_cpu(policy); 290 cpufreq_stats_update_policy_cpu(policy);
299 return 0; 291 return 0;
300 } 292 }
301 293
302 table = cpufreq_frequency_get_table(cpu);
303 if (!table)
304 return 0;
305
306 if (val == CPUFREQ_CREATE_POLICY) 294 if (val == CPUFREQ_CREATE_POLICY)
307 ret = __cpufreq_stats_create_table(policy, table); 295 ret = __cpufreq_stats_create_table(policy);
308 else if (val == CPUFREQ_REMOVE_POLICY) 296 else if (val == CPUFREQ_REMOVE_POLICY)
309 __cpufreq_stats_free_table(policy); 297 __cpufreq_stats_free_table(policy);
310 298
diff --git a/drivers/cpufreq/cris-artpec3-cpufreq.c b/drivers/cpufreq/cris-artpec3-cpufreq.c
index 86559040c54c..d4573032cbbc 100644
--- a/drivers/cpufreq/cris-artpec3-cpufreq.c
+++ b/drivers/cpufreq/cris-artpec3-cpufreq.c
@@ -57,7 +57,6 @@ static struct cpufreq_driver cris_freq_driver = {
57 .verify = cpufreq_generic_frequency_table_verify, 57 .verify = cpufreq_generic_frequency_table_verify,
58 .target_index = cris_freq_target, 58 .target_index = cris_freq_target,
59 .init = cris_freq_cpu_init, 59 .init = cris_freq_cpu_init,
60 .exit = cpufreq_generic_exit,
61 .name = "cris_freq", 60 .name = "cris_freq",
62 .attr = cpufreq_generic_attr, 61 .attr = cpufreq_generic_attr,
63}; 62};
diff --git a/drivers/cpufreq/cris-etraxfs-cpufreq.c b/drivers/cpufreq/cris-etraxfs-cpufreq.c
index 26d940d40b1d..13c3361437f7 100644
--- a/drivers/cpufreq/cris-etraxfs-cpufreq.c
+++ b/drivers/cpufreq/cris-etraxfs-cpufreq.c
@@ -57,7 +57,6 @@ static struct cpufreq_driver cris_freq_driver = {
57 .verify = cpufreq_generic_frequency_table_verify, 57 .verify = cpufreq_generic_frequency_table_verify,
58 .target_index = cris_freq_target, 58 .target_index = cris_freq_target,
59 .init = cris_freq_cpu_init, 59 .init = cris_freq_cpu_init,
60 .exit = cpufreq_generic_exit,
61 .name = "cris_freq", 60 .name = "cris_freq",
62 .attr = cpufreq_generic_attr, 61 .attr = cpufreq_generic_attr,
63}; 62};
diff --git a/drivers/cpufreq/davinci-cpufreq.c b/drivers/cpufreq/davinci-cpufreq.c
index 2cf33848d86e..28a16dc6e02e 100644
--- a/drivers/cpufreq/davinci-cpufreq.c
+++ b/drivers/cpufreq/davinci-cpufreq.c
@@ -125,7 +125,6 @@ static struct cpufreq_driver davinci_driver = {
125 .target_index = davinci_target, 125 .target_index = davinci_target,
126 .get = cpufreq_generic_get, 126 .get = cpufreq_generic_get,
127 .init = davinci_cpu_init, 127 .init = davinci_cpu_init,
128 .exit = cpufreq_generic_exit,
129 .name = "davinci", 128 .name = "davinci",
130 .attr = cpufreq_generic_attr, 129 .attr = cpufreq_generic_attr,
131}; 130};
diff --git a/drivers/cpufreq/e_powersaver.c b/drivers/cpufreq/e_powersaver.c
index 9012b8bb6b64..a0d2a423cea9 100644
--- a/drivers/cpufreq/e_powersaver.c
+++ b/drivers/cpufreq/e_powersaver.c
@@ -382,7 +382,6 @@ static int eps_cpu_exit(struct cpufreq_policy *policy)
382 unsigned int cpu = policy->cpu; 382 unsigned int cpu = policy->cpu;
383 383
384 /* Bye */ 384 /* Bye */
385 cpufreq_frequency_table_put_attr(policy->cpu);
386 kfree(eps_cpu[cpu]); 385 kfree(eps_cpu[cpu]);
387 eps_cpu[cpu] = NULL; 386 eps_cpu[cpu] = NULL;
388 return 0; 387 return 0;
diff --git a/drivers/cpufreq/elanfreq.c b/drivers/cpufreq/elanfreq.c
index de08acff5101..c987e94708f5 100644
--- a/drivers/cpufreq/elanfreq.c
+++ b/drivers/cpufreq/elanfreq.c
@@ -198,7 +198,6 @@ static struct cpufreq_driver elanfreq_driver = {
198 .verify = cpufreq_generic_frequency_table_verify, 198 .verify = cpufreq_generic_frequency_table_verify,
199 .target_index = elanfreq_target, 199 .target_index = elanfreq_target,
200 .init = elanfreq_cpu_init, 200 .init = elanfreq_cpu_init,
201 .exit = cpufreq_generic_exit,
202 .name = "elanfreq", 201 .name = "elanfreq",
203 .attr = cpufreq_generic_attr, 202 .attr = cpufreq_generic_attr,
204}; 203};
diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
index fcd2914d081a..f99cfe24e7bc 100644
--- a/drivers/cpufreq/exynos-cpufreq.c
+++ b/drivers/cpufreq/exynos-cpufreq.c
@@ -16,7 +16,6 @@
16#include <linux/slab.h> 16#include <linux/slab.h>
17#include <linux/regulator/consumer.h> 17#include <linux/regulator/consumer.h>
18#include <linux/cpufreq.h> 18#include <linux/cpufreq.h>
19#include <linux/suspend.h>
20#include <linux/platform_device.h> 19#include <linux/platform_device.h>
21 20
22#include <plat/cpu.h> 21#include <plat/cpu.h>
@@ -24,12 +23,8 @@
24#include "exynos-cpufreq.h" 23#include "exynos-cpufreq.h"
25 24
26static struct exynos_dvfs_info *exynos_info; 25static struct exynos_dvfs_info *exynos_info;
27
28static struct regulator *arm_regulator; 26static struct regulator *arm_regulator;
29
30static unsigned int locking_frequency; 27static unsigned int locking_frequency;
31static bool frequency_locked;
32static DEFINE_MUTEX(cpufreq_lock);
33 28
34static int exynos_cpufreq_get_index(unsigned int freq) 29static int exynos_cpufreq_get_index(unsigned int freq)
35{ 30{
@@ -134,83 +129,13 @@ out:
134 129
135static int exynos_target(struct cpufreq_policy *policy, unsigned int index) 130static int exynos_target(struct cpufreq_policy *policy, unsigned int index)
136{ 131{
137 struct cpufreq_frequency_table *freq_table = exynos_info->freq_table; 132 return exynos_cpufreq_scale(exynos_info->freq_table[index].frequency);
138 int ret = 0;
139
140 mutex_lock(&cpufreq_lock);
141
142 if (frequency_locked)
143 goto out;
144
145 ret = exynos_cpufreq_scale(freq_table[index].frequency);
146
147out:
148 mutex_unlock(&cpufreq_lock);
149
150 return ret;
151}
152
153#ifdef CONFIG_PM
154static int exynos_cpufreq_suspend(struct cpufreq_policy *policy)
155{
156 return 0;
157}
158
159static int exynos_cpufreq_resume(struct cpufreq_policy *policy)
160{
161 return 0;
162}
163#endif
164
165/**
166 * exynos_cpufreq_pm_notifier - block CPUFREQ's activities in suspend-resume
167 * context
168 * @notifier
169 * @pm_event
170 * @v
171 *
172 * While frequency_locked == true, target() ignores every frequency but
173 * locking_frequency. The locking_frequency value is the initial frequency,
174 * which is set by the bootloader. In order to eliminate possible
175 * inconsistency in clock values, we save and restore frequencies during
176 * suspend and resume and block CPUFREQ activities. Note that the standard
177 * suspend/resume cannot be used as they are too deep (syscore_ops) for
178 * regulator actions.
179 */
180static int exynos_cpufreq_pm_notifier(struct notifier_block *notifier,
181 unsigned long pm_event, void *v)
182{
183 int ret;
184
185 switch (pm_event) {
186 case PM_SUSPEND_PREPARE:
187 mutex_lock(&cpufreq_lock);
188 frequency_locked = true;
189 mutex_unlock(&cpufreq_lock);
190
191 ret = exynos_cpufreq_scale(locking_frequency);
192 if (ret < 0)
193 return NOTIFY_BAD;
194
195 break;
196
197 case PM_POST_SUSPEND:
198 mutex_lock(&cpufreq_lock);
199 frequency_locked = false;
200 mutex_unlock(&cpufreq_lock);
201 break;
202 }
203
204 return NOTIFY_OK;
205} 133}
206 134
207static struct notifier_block exynos_cpufreq_nb = {
208 .notifier_call = exynos_cpufreq_pm_notifier,
209};
210
211static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy) 135static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy)
212{ 136{
213 policy->clk = exynos_info->cpu_clk; 137 policy->clk = exynos_info->cpu_clk;
138 policy->suspend_freq = locking_frequency;
214 return cpufreq_generic_init(policy, exynos_info->freq_table, 100000); 139 return cpufreq_generic_init(policy, exynos_info->freq_table, 100000);
215} 140}
216 141
@@ -220,15 +145,13 @@ static struct cpufreq_driver exynos_driver = {
220 .target_index = exynos_target, 145 .target_index = exynos_target,
221 .get = cpufreq_generic_get, 146 .get = cpufreq_generic_get,
222 .init = exynos_cpufreq_cpu_init, 147 .init = exynos_cpufreq_cpu_init,
223 .exit = cpufreq_generic_exit,
224 .name = "exynos_cpufreq", 148 .name = "exynos_cpufreq",
225 .attr = cpufreq_generic_attr, 149 .attr = cpufreq_generic_attr,
226#ifdef CONFIG_ARM_EXYNOS_CPU_FREQ_BOOST_SW 150#ifdef CONFIG_ARM_EXYNOS_CPU_FREQ_BOOST_SW
227 .boost_supported = true, 151 .boost_supported = true,
228#endif 152#endif
229#ifdef CONFIG_PM 153#ifdef CONFIG_PM
230 .suspend = exynos_cpufreq_suspend, 154 .suspend = cpufreq_generic_suspend,
231 .resume = exynos_cpufreq_resume,
232#endif 155#endif
233}; 156};
234 157
@@ -263,19 +186,13 @@ static int exynos_cpufreq_probe(struct platform_device *pdev)
263 goto err_vdd_arm; 186 goto err_vdd_arm;
264 } 187 }
265 188
189 /* Done here as we want to capture boot frequency */
266 locking_frequency = clk_get_rate(exynos_info->cpu_clk) / 1000; 190 locking_frequency = clk_get_rate(exynos_info->cpu_clk) / 1000;
267 191
268 register_pm_notifier(&exynos_cpufreq_nb); 192 if (!cpufreq_register_driver(&exynos_driver))
269 193 return 0;
270 if (cpufreq_register_driver(&exynos_driver)) {
271 pr_err("%s: failed to register cpufreq driver\n", __func__);
272 goto err_cpufreq;
273 }
274
275 return 0;
276err_cpufreq:
277 unregister_pm_notifier(&exynos_cpufreq_nb);
278 194
195 pr_err("%s: failed to register cpufreq driver\n", __func__);
279 regulator_put(arm_regulator); 196 regulator_put(arm_regulator);
280err_vdd_arm: 197err_vdd_arm:
281 kfree(exynos_info); 198 kfree(exynos_info);
diff --git a/drivers/cpufreq/exynos5440-cpufreq.c b/drivers/cpufreq/exynos5440-cpufreq.c
index 49b756015316..7f776aa91e2f 100644
--- a/drivers/cpufreq/exynos5440-cpufreq.c
+++ b/drivers/cpufreq/exynos5440-cpufreq.c
@@ -312,7 +312,6 @@ static struct cpufreq_driver exynos_driver = {
312 .target_index = exynos_target, 312 .target_index = exynos_target,
313 .get = cpufreq_generic_get, 313 .get = cpufreq_generic_get,
314 .init = exynos_cpufreq_cpu_init, 314 .init = exynos_cpufreq_cpu_init,
315 .exit = cpufreq_generic_exit,
316 .name = CPUFREQ_NAME, 315 .name = CPUFREQ_NAME,
317 .attr = cpufreq_generic_attr, 316 .attr = cpufreq_generic_attr,
318}; 317};
diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c
index 8e54f97899ba..65a477075b3f 100644
--- a/drivers/cpufreq/freq_table.c
+++ b/drivers/cpufreq/freq_table.c
@@ -91,8 +91,8 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy *policy,
91EXPORT_SYMBOL_GPL(cpufreq_frequency_table_verify); 91EXPORT_SYMBOL_GPL(cpufreq_frequency_table_verify);
92 92
93/* 93/*
94 * Generic routine to verify policy & frequency table, requires driver to call 94 * Generic routine to verify policy & frequency table, requires driver to set
95 * cpufreq_frequency_table_get_attr() prior to it. 95 * policy->freq_table prior to it.
96 */ 96 */
97int cpufreq_generic_frequency_table_verify(struct cpufreq_policy *policy) 97int cpufreq_generic_frequency_table_verify(struct cpufreq_policy *policy)
98{ 98{
@@ -203,8 +203,6 @@ int cpufreq_frequency_table_get_index(struct cpufreq_policy *policy,
203} 203}
204EXPORT_SYMBOL_GPL(cpufreq_frequency_table_get_index); 204EXPORT_SYMBOL_GPL(cpufreq_frequency_table_get_index);
205 205
206static DEFINE_PER_CPU(struct cpufreq_frequency_table *, cpufreq_show_table);
207
208/** 206/**
209 * show_available_freqs - show available frequencies for the specified CPU 207 * show_available_freqs - show available frequencies for the specified CPU
210 */ 208 */
@@ -212,15 +210,12 @@ static ssize_t show_available_freqs(struct cpufreq_policy *policy, char *buf,
212 bool show_boost) 210 bool show_boost)
213{ 211{
214 unsigned int i = 0; 212 unsigned int i = 0;
215 unsigned int cpu = policy->cpu;
216 ssize_t count = 0; 213 ssize_t count = 0;
217 struct cpufreq_frequency_table *table; 214 struct cpufreq_frequency_table *table = policy->freq_table;
218 215
219 if (!per_cpu(cpufreq_show_table, cpu)) 216 if (!table)
220 return -ENODEV; 217 return -ENODEV;
221 218
222 table = per_cpu(cpufreq_show_table, cpu);
223
224 for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++) { 219 for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++) {
225 if (table[i].frequency == CPUFREQ_ENTRY_INVALID) 220 if (table[i].frequency == CPUFREQ_ENTRY_INVALID)
226 continue; 221 continue;
@@ -283,49 +278,24 @@ struct freq_attr *cpufreq_generic_attr[] = {
283}; 278};
284EXPORT_SYMBOL_GPL(cpufreq_generic_attr); 279EXPORT_SYMBOL_GPL(cpufreq_generic_attr);
285 280
286/*
287 * if you use these, you must assure that the frequency table is valid
288 * all the time between get_attr and put_attr!
289 */
290void cpufreq_frequency_table_get_attr(struct cpufreq_frequency_table *table,
291 unsigned int cpu)
292{
293 pr_debug("setting show_table for cpu %u to %p\n", cpu, table);
294 per_cpu(cpufreq_show_table, cpu) = table;
295}
296EXPORT_SYMBOL_GPL(cpufreq_frequency_table_get_attr);
297
298void cpufreq_frequency_table_put_attr(unsigned int cpu)
299{
300 pr_debug("clearing show_table for cpu %u\n", cpu);
301 per_cpu(cpufreq_show_table, cpu) = NULL;
302}
303EXPORT_SYMBOL_GPL(cpufreq_frequency_table_put_attr);
304
305int cpufreq_table_validate_and_show(struct cpufreq_policy *policy, 281int cpufreq_table_validate_and_show(struct cpufreq_policy *policy,
306 struct cpufreq_frequency_table *table) 282 struct cpufreq_frequency_table *table)
307{ 283{
308 int ret = cpufreq_frequency_table_cpuinfo(policy, table); 284 int ret = cpufreq_frequency_table_cpuinfo(policy, table);
309 285
310 if (!ret) 286 if (!ret)
311 cpufreq_frequency_table_get_attr(table, policy->cpu); 287 policy->freq_table = table;
312 288
313 return ret; 289 return ret;
314} 290}
315EXPORT_SYMBOL_GPL(cpufreq_table_validate_and_show); 291EXPORT_SYMBOL_GPL(cpufreq_table_validate_and_show);
316 292
317void cpufreq_frequency_table_update_policy_cpu(struct cpufreq_policy *policy) 293struct cpufreq_policy *cpufreq_cpu_get_raw(unsigned int cpu);
318{
319 pr_debug("Updating show_table for new_cpu %u from last_cpu %u\n",
320 policy->cpu, policy->last_cpu);
321 per_cpu(cpufreq_show_table, policy->cpu) = per_cpu(cpufreq_show_table,
322 policy->last_cpu);
323 per_cpu(cpufreq_show_table, policy->last_cpu) = NULL;
324}
325 294
326struct cpufreq_frequency_table *cpufreq_frequency_get_table(unsigned int cpu) 295struct cpufreq_frequency_table *cpufreq_frequency_get_table(unsigned int cpu)
327{ 296{
328 return per_cpu(cpufreq_show_table, cpu); 297 struct cpufreq_policy *policy = cpufreq_cpu_get_raw(cpu);
298 return policy ? policy->freq_table : NULL;
329} 299}
330EXPORT_SYMBOL_GPL(cpufreq_frequency_get_table); 300EXPORT_SYMBOL_GPL(cpufreq_frequency_get_table);
331 301
diff --git a/drivers/cpufreq/ia64-acpi-cpufreq.c b/drivers/cpufreq/ia64-acpi-cpufreq.c
index 53c6ac637e10..a22b5d182e0e 100644
--- a/drivers/cpufreq/ia64-acpi-cpufreq.c
+++ b/drivers/cpufreq/ia64-acpi-cpufreq.c
@@ -332,7 +332,6 @@ acpi_cpufreq_cpu_exit (
332 pr_debug("acpi_cpufreq_cpu_exit\n"); 332 pr_debug("acpi_cpufreq_cpu_exit\n");
333 333
334 if (data) { 334 if (data) {
335 cpufreq_frequency_table_put_attr(policy->cpu);
336 acpi_io_data[policy->cpu] = NULL; 335 acpi_io_data[policy->cpu] = NULL;
337 acpi_processor_unregister_performance(&data->acpi_data, 336 acpi_processor_unregister_performance(&data->acpi_data,
338 policy->cpu); 337 policy->cpu);
diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c
index ce69059be1fc..e27fca86fe4f 100644
--- a/drivers/cpufreq/imx6q-cpufreq.c
+++ b/drivers/cpufreq/imx6q-cpufreq.c
@@ -144,7 +144,6 @@ static struct cpufreq_driver imx6q_cpufreq_driver = {
144 .target_index = imx6q_set_target, 144 .target_index = imx6q_set_target,
145 .get = cpufreq_generic_get, 145 .get = cpufreq_generic_get,
146 .init = imx6q_cpufreq_init, 146 .init = imx6q_cpufreq_init,
147 .exit = cpufreq_generic_exit,
148 .name = "imx6q-cpufreq", 147 .name = "imx6q-cpufreq",
149 .attr = cpufreq_generic_attr, 148 .attr = cpufreq_generic_attr,
150}; 149};
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 2cd36b9297f3..bcb9a6d0ae11 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -99,8 +99,7 @@ struct cpudata {
99 u64 prev_aperf; 99 u64 prev_aperf;
100 u64 prev_mperf; 100 u64 prev_mperf;
101 unsigned long long prev_tsc; 101 unsigned long long prev_tsc;
102 int sample_ptr; 102 struct sample sample;
103 struct sample samples[SAMPLE_COUNT];
104}; 103};
105 104
106static struct cpudata **all_cpu_data; 105static struct cpudata **all_cpu_data;
@@ -154,7 +153,7 @@ static inline void pid_reset(struct _pid *pid, int setpoint, int busy,
154 pid->setpoint = setpoint; 153 pid->setpoint = setpoint;
155 pid->deadband = deadband; 154 pid->deadband = deadband;
156 pid->integral = int_tofp(integral); 155 pid->integral = int_tofp(integral);
157 pid->last_err = setpoint - busy; 156 pid->last_err = int_tofp(setpoint) - int_tofp(busy);
158} 157}
159 158
160static inline void pid_p_gain_set(struct _pid *pid, int percent) 159static inline void pid_p_gain_set(struct _pid *pid, int percent)
@@ -447,7 +446,7 @@ static void core_set_pstate(struct cpudata *cpudata, int pstate)
447 if (limits.no_turbo) 446 if (limits.no_turbo)
448 val |= (u64)1 << 32; 447 val |= (u64)1 << 32;
449 448
450 wrmsrl(MSR_IA32_PERF_CTL, val); 449 wrmsrl_on_cpu(cpudata->cpu, MSR_IA32_PERF_CTL, val);
451} 450}
452 451
453static struct cpu_defaults core_params = { 452static struct cpu_defaults core_params = {
@@ -586,15 +585,14 @@ static inline void intel_pstate_sample(struct cpudata *cpu)
586 mperf = mperf >> FRAC_BITS; 585 mperf = mperf >> FRAC_BITS;
587 tsc = tsc >> FRAC_BITS; 586 tsc = tsc >> FRAC_BITS;
588 587
589 cpu->sample_ptr = (cpu->sample_ptr + 1) % SAMPLE_COUNT; 588 cpu->sample.aperf = aperf;
590 cpu->samples[cpu->sample_ptr].aperf = aperf; 589 cpu->sample.mperf = mperf;
591 cpu->samples[cpu->sample_ptr].mperf = mperf; 590 cpu->sample.tsc = tsc;
592 cpu->samples[cpu->sample_ptr].tsc = tsc; 591 cpu->sample.aperf -= cpu->prev_aperf;
593 cpu->samples[cpu->sample_ptr].aperf -= cpu->prev_aperf; 592 cpu->sample.mperf -= cpu->prev_mperf;
594 cpu->samples[cpu->sample_ptr].mperf -= cpu->prev_mperf; 593 cpu->sample.tsc -= cpu->prev_tsc;
595 cpu->samples[cpu->sample_ptr].tsc -= cpu->prev_tsc;
596 594
597 intel_pstate_calc_busy(cpu, &cpu->samples[cpu->sample_ptr]); 595 intel_pstate_calc_busy(cpu, &cpu->sample);
598 596
599 cpu->prev_aperf = aperf; 597 cpu->prev_aperf = aperf;
600 cpu->prev_mperf = mperf; 598 cpu->prev_mperf = mperf;
@@ -614,7 +612,7 @@ static inline int32_t intel_pstate_get_scaled_busy(struct cpudata *cpu)
614{ 612{
615 int32_t core_busy, max_pstate, current_pstate; 613 int32_t core_busy, max_pstate, current_pstate;
616 614
617 core_busy = cpu->samples[cpu->sample_ptr].core_pct_busy; 615 core_busy = cpu->sample.core_pct_busy;
618 max_pstate = int_tofp(cpu->pstate.max_pstate); 616 max_pstate = int_tofp(cpu->pstate.max_pstate);
619 current_pstate = int_tofp(cpu->pstate.current_pstate); 617 current_pstate = int_tofp(cpu->pstate.current_pstate);
620 core_busy = mul_fp(core_busy, div_fp(max_pstate, current_pstate)); 618 core_busy = mul_fp(core_busy, div_fp(max_pstate, current_pstate));
@@ -648,7 +646,7 @@ static void intel_pstate_timer_func(unsigned long __data)
648 646
649 intel_pstate_sample(cpu); 647 intel_pstate_sample(cpu);
650 648
651 sample = &cpu->samples[cpu->sample_ptr]; 649 sample = &cpu->sample;
652 650
653 intel_pstate_adjust_busy_pstate(cpu); 651 intel_pstate_adjust_busy_pstate(cpu);
654 652
@@ -729,7 +727,7 @@ static unsigned int intel_pstate_get(unsigned int cpu_num)
729 cpu = all_cpu_data[cpu_num]; 727 cpu = all_cpu_data[cpu_num];
730 if (!cpu) 728 if (!cpu)
731 return 0; 729 return 0;
732 sample = &cpu->samples[cpu->sample_ptr]; 730 sample = &cpu->sample;
733 return sample->freq; 731 return sample->freq;
734} 732}
735 733
@@ -773,14 +771,17 @@ static int intel_pstate_verify_policy(struct cpufreq_policy *policy)
773 return 0; 771 return 0;
774} 772}
775 773
776static int intel_pstate_cpu_exit(struct cpufreq_policy *policy) 774static void intel_pstate_stop_cpu(struct cpufreq_policy *policy)
777{ 775{
778 int cpu = policy->cpu; 776 int cpu_num = policy->cpu;
777 struct cpudata *cpu = all_cpu_data[cpu_num];
779 778
780 del_timer(&all_cpu_data[cpu]->timer); 779 pr_info("intel_pstate CPU %d exiting\n", cpu_num);
781 kfree(all_cpu_data[cpu]); 780
782 all_cpu_data[cpu] = NULL; 781 del_timer(&all_cpu_data[cpu_num]->timer);
783 return 0; 782 intel_pstate_set_pstate(cpu, cpu->pstate.min_pstate);
783 kfree(all_cpu_data[cpu_num]);
784 all_cpu_data[cpu_num] = NULL;
784} 785}
785 786
786static int intel_pstate_cpu_init(struct cpufreq_policy *policy) 787static int intel_pstate_cpu_init(struct cpufreq_policy *policy)
@@ -818,7 +819,7 @@ static struct cpufreq_driver intel_pstate_driver = {
818 .setpolicy = intel_pstate_set_policy, 819 .setpolicy = intel_pstate_set_policy,
819 .get = intel_pstate_get, 820 .get = intel_pstate_get,
820 .init = intel_pstate_cpu_init, 821 .init = intel_pstate_cpu_init,
821 .exit = intel_pstate_cpu_exit, 822 .stop_cpu = intel_pstate_stop_cpu,
822 .name = "intel_pstate", 823 .name = "intel_pstate",
823}; 824};
824 825
diff --git a/drivers/cpufreq/kirkwood-cpufreq.c b/drivers/cpufreq/kirkwood-cpufreq.c
index eb7abe345b50..3d114bc5a97a 100644
--- a/drivers/cpufreq/kirkwood-cpufreq.c
+++ b/drivers/cpufreq/kirkwood-cpufreq.c
@@ -102,7 +102,6 @@ static struct cpufreq_driver kirkwood_cpufreq_driver = {
102 .verify = cpufreq_generic_frequency_table_verify, 102 .verify = cpufreq_generic_frequency_table_verify,
103 .target_index = kirkwood_cpufreq_target, 103 .target_index = kirkwood_cpufreq_target,
104 .init = kirkwood_cpufreq_cpu_init, 104 .init = kirkwood_cpufreq_cpu_init,
105 .exit = cpufreq_generic_exit,
106 .name = "kirkwood-cpufreq", 105 .name = "kirkwood-cpufreq",
107 .attr = cpufreq_generic_attr, 106 .attr = cpufreq_generic_attr,
108}; 107};
diff --git a/drivers/cpufreq/longhaul.c b/drivers/cpufreq/longhaul.c
index 45bafddfd8ea..7b94da3d2d10 100644
--- a/drivers/cpufreq/longhaul.c
+++ b/drivers/cpufreq/longhaul.c
@@ -913,7 +913,6 @@ static struct cpufreq_driver longhaul_driver = {
913 .target_index = longhaul_target, 913 .target_index = longhaul_target,
914 .get = longhaul_get, 914 .get = longhaul_get,
915 .init = longhaul_cpu_init, 915 .init = longhaul_cpu_init,
916 .exit = cpufreq_generic_exit,
917 .name = "longhaul", 916 .name = "longhaul",
918 .attr = cpufreq_generic_attr, 917 .attr = cpufreq_generic_attr,
919}; 918};
diff --git a/drivers/cpufreq/loongson2_cpufreq.c b/drivers/cpufreq/loongson2_cpufreq.c
index b6581abc9207..a3588d61d933 100644
--- a/drivers/cpufreq/loongson2_cpufreq.c
+++ b/drivers/cpufreq/loongson2_cpufreq.c
@@ -104,7 +104,6 @@ static int loongson2_cpufreq_cpu_init(struct cpufreq_policy *policy)
104 104
105static int loongson2_cpufreq_exit(struct cpufreq_policy *policy) 105static int loongson2_cpufreq_exit(struct cpufreq_policy *policy)
106{ 106{
107 cpufreq_frequency_table_put_attr(policy->cpu);
108 clk_put(policy->clk); 107 clk_put(policy->clk);
109 return 0; 108 return 0;
110} 109}
diff --git a/drivers/cpufreq/omap-cpufreq.c b/drivers/cpufreq/omap-cpufreq.c
index 590f5b66d181..5f69c9aa703c 100644
--- a/drivers/cpufreq/omap-cpufreq.c
+++ b/drivers/cpufreq/omap-cpufreq.c
@@ -143,7 +143,6 @@ fail:
143 143
144static int omap_cpu_exit(struct cpufreq_policy *policy) 144static int omap_cpu_exit(struct cpufreq_policy *policy)
145{ 145{
146 cpufreq_frequency_table_put_attr(policy->cpu);
147 freq_table_free(); 146 freq_table_free();
148 clk_put(policy->clk); 147 clk_put(policy->clk);
149 return 0; 148 return 0;
diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
index 3d1cba9fd5f9..74f593e70e19 100644
--- a/drivers/cpufreq/p4-clockmod.c
+++ b/drivers/cpufreq/p4-clockmod.c
@@ -237,7 +237,6 @@ static struct cpufreq_driver p4clockmod_driver = {
237 .verify = cpufreq_generic_frequency_table_verify, 237 .verify = cpufreq_generic_frequency_table_verify,
238 .target_index = cpufreq_p4_target, 238 .target_index = cpufreq_p4_target,
239 .init = cpufreq_p4_cpu_init, 239 .init = cpufreq_p4_cpu_init,
240 .exit = cpufreq_generic_exit,
241 .get = cpufreq_p4_get, 240 .get = cpufreq_p4_get,
242 .name = "p4-clockmod", 241 .name = "p4-clockmod",
243 .attr = cpufreq_generic_attr, 242 .attr = cpufreq_generic_attr,
diff --git a/drivers/cpufreq/pasemi-cpufreq.c b/drivers/cpufreq/pasemi-cpufreq.c
index 0426008380d8..6a2b7d3e85a7 100644
--- a/drivers/cpufreq/pasemi-cpufreq.c
+++ b/drivers/cpufreq/pasemi-cpufreq.c
@@ -234,7 +234,6 @@ static int pas_cpufreq_cpu_exit(struct cpufreq_policy *policy)
234 if (sdcpwr_mapbase) 234 if (sdcpwr_mapbase)
235 iounmap(sdcpwr_mapbase); 235 iounmap(sdcpwr_mapbase);
236 236
237 cpufreq_frequency_table_put_attr(policy->cpu);
238 return 0; 237 return 0;
239} 238}
240 239
diff --git a/drivers/cpufreq/powernow-k6.c b/drivers/cpufreq/powernow-k6.c
index b9a444e358b5..ce27e6c26c94 100644
--- a/drivers/cpufreq/powernow-k6.c
+++ b/drivers/cpufreq/powernow-k6.c
@@ -231,7 +231,6 @@ static int powernow_k6_cpu_exit(struct cpufreq_policy *policy)
231 if (i == max_multiplier) 231 if (i == max_multiplier)
232 powernow_k6_target(policy, i); 232 powernow_k6_target(policy, i);
233 } 233 }
234 cpufreq_frequency_table_put_attr(policy->cpu);
235 return 0; 234 return 0;
236} 235}
237 236
diff --git a/drivers/cpufreq/powernow-k7.c b/drivers/cpufreq/powernow-k7.c
index 946708a1d745..0e68e0275621 100644
--- a/drivers/cpufreq/powernow-k7.c
+++ b/drivers/cpufreq/powernow-k7.c
@@ -664,8 +664,6 @@ static int powernow_cpu_init(struct cpufreq_policy *policy)
664 664
665static int powernow_cpu_exit(struct cpufreq_policy *policy) 665static int powernow_cpu_exit(struct cpufreq_policy *policy)
666{ 666{
667 cpufreq_frequency_table_put_attr(policy->cpu);
668
669#ifdef CONFIG_X86_POWERNOW_K7_ACPI 667#ifdef CONFIG_X86_POWERNOW_K7_ACPI
670 if (acpi_processor_perf) { 668 if (acpi_processor_perf) {
671 acpi_processor_unregister_performance(acpi_processor_perf, 0); 669 acpi_processor_unregister_performance(acpi_processor_perf, 0);
diff --git a/drivers/cpufreq/powernow-k8.c b/drivers/cpufreq/powernow-k8.c
index 6684e0342792..27eb2be44de5 100644
--- a/drivers/cpufreq/powernow-k8.c
+++ b/drivers/cpufreq/powernow-k8.c
@@ -1164,8 +1164,6 @@ static int powernowk8_cpu_exit(struct cpufreq_policy *pol)
1164 1164
1165 powernow_k8_cpu_exit_acpi(data); 1165 powernow_k8_cpu_exit_acpi(data);
1166 1166
1167 cpufreq_frequency_table_put_attr(pol->cpu);
1168
1169 kfree(data->powernow_table); 1167 kfree(data->powernow_table);
1170 kfree(data); 1168 kfree(data);
1171 for_each_cpu(cpu, pol->cpus) 1169 for_each_cpu(cpu, pol->cpus)
diff --git a/drivers/cpufreq/ppc-corenet-cpufreq.c b/drivers/cpufreq/ppc-corenet-cpufreq.c
index 051000f44ca2..3bd9123e7026 100644
--- a/drivers/cpufreq/ppc-corenet-cpufreq.c
+++ b/drivers/cpufreq/ppc-corenet-cpufreq.c
@@ -21,6 +21,7 @@
21#include <linux/of.h> 21#include <linux/of.h>
22#include <linux/slab.h> 22#include <linux/slab.h>
23#include <linux/smp.h> 23#include <linux/smp.h>
24#include <sysdev/fsl_soc.h>
24 25
25/** 26/**
26 * struct cpu_data - per CPU data struct 27 * struct cpu_data - per CPU data struct
@@ -205,7 +206,8 @@ static int corenet_cpufreq_cpu_init(struct cpufreq_policy *policy)
205 for_each_cpu(i, per_cpu(cpu_mask, cpu)) 206 for_each_cpu(i, per_cpu(cpu_mask, cpu))
206 per_cpu(cpu_data, i) = data; 207 per_cpu(cpu_data, i) = data;
207 208
208 policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; 209 policy->cpuinfo.transition_latency =
210 (12 * NSEC_PER_SEC) / fsl_get_sys_freq();
209 of_node_put(np); 211 of_node_put(np);
210 212
211 return 0; 213 return 0;
@@ -228,7 +230,6 @@ static int __exit corenet_cpufreq_cpu_exit(struct cpufreq_policy *policy)
228 struct cpu_data *data = per_cpu(cpu_data, policy->cpu); 230 struct cpu_data *data = per_cpu(cpu_data, policy->cpu);
229 unsigned int cpu; 231 unsigned int cpu;
230 232
231 cpufreq_frequency_table_put_attr(policy->cpu);
232 of_node_put(data->parent); 233 of_node_put(data->parent);
233 kfree(data->table); 234 kfree(data->table);
234 kfree(data); 235 kfree(data);
diff --git a/drivers/cpufreq/ppc_cbe_cpufreq.c b/drivers/cpufreq/ppc_cbe_cpufreq.c
index e42ca9c31cea..af7b1cabd1e7 100644
--- a/drivers/cpufreq/ppc_cbe_cpufreq.c
+++ b/drivers/cpufreq/ppc_cbe_cpufreq.c
@@ -141,7 +141,6 @@ static struct cpufreq_driver cbe_cpufreq_driver = {
141 .verify = cpufreq_generic_frequency_table_verify, 141 .verify = cpufreq_generic_frequency_table_verify,
142 .target_index = cbe_cpufreq_target, 142 .target_index = cbe_cpufreq_target,
143 .init = cbe_cpufreq_cpu_init, 143 .init = cbe_cpufreq_cpu_init,
144 .exit = cpufreq_generic_exit,
145 .name = "cbe-cpufreq", 144 .name = "cbe-cpufreq",
146 .flags = CPUFREQ_CONST_LOOPS, 145 .flags = CPUFREQ_CONST_LOOPS,
147}; 146};
diff --git a/drivers/cpufreq/pxa2xx-cpufreq.c b/drivers/cpufreq/pxa2xx-cpufreq.c
index a9195a86b069..e24269ab4e9b 100644
--- a/drivers/cpufreq/pxa2xx-cpufreq.c
+++ b/drivers/cpufreq/pxa2xx-cpufreq.c
@@ -427,7 +427,6 @@ static struct cpufreq_driver pxa_cpufreq_driver = {
427 .verify = cpufreq_generic_frequency_table_verify, 427 .verify = cpufreq_generic_frequency_table_verify,
428 .target_index = pxa_set_target, 428 .target_index = pxa_set_target,
429 .init = pxa_cpufreq_init, 429 .init = pxa_cpufreq_init,
430 .exit = cpufreq_generic_exit,
431 .get = pxa_cpufreq_get, 430 .get = pxa_cpufreq_get,
432 .name = "PXA2xx", 431 .name = "PXA2xx",
433}; 432};
diff --git a/drivers/cpufreq/pxa3xx-cpufreq.c b/drivers/cpufreq/pxa3xx-cpufreq.c
index 3785687e9d70..a01275900389 100644
--- a/drivers/cpufreq/pxa3xx-cpufreq.c
+++ b/drivers/cpufreq/pxa3xx-cpufreq.c
@@ -205,7 +205,6 @@ static struct cpufreq_driver pxa3xx_cpufreq_driver = {
205 .verify = cpufreq_generic_frequency_table_verify, 205 .verify = cpufreq_generic_frequency_table_verify,
206 .target_index = pxa3xx_cpufreq_set, 206 .target_index = pxa3xx_cpufreq_set,
207 .init = pxa3xx_cpufreq_init, 207 .init = pxa3xx_cpufreq_init,
208 .exit = cpufreq_generic_exit,
209 .get = pxa3xx_cpufreq_get, 208 .get = pxa3xx_cpufreq_get,
210 .name = "pxa3xx-cpufreq", 209 .name = "pxa3xx-cpufreq",
211}; 210};
diff --git a/drivers/cpufreq/s5pv210-cpufreq.c b/drivers/cpufreq/s5pv210-cpufreq.c
index 55a8e9fa9435..72421534fff5 100644
--- a/drivers/cpufreq/s5pv210-cpufreq.c
+++ b/drivers/cpufreq/s5pv210-cpufreq.c
@@ -18,7 +18,6 @@
18#include <linux/cpufreq.h> 18#include <linux/cpufreq.h>
19#include <linux/reboot.h> 19#include <linux/reboot.h>
20#include <linux/regulator/consumer.h> 20#include <linux/regulator/consumer.h>
21#include <linux/suspend.h>
22 21
23#include <mach/map.h> 22#include <mach/map.h>
24#include <mach/regs-clock.h> 23#include <mach/regs-clock.h>
@@ -435,18 +434,6 @@ exit:
435 return ret; 434 return ret;
436} 435}
437 436
438#ifdef CONFIG_PM
439static int s5pv210_cpufreq_suspend(struct cpufreq_policy *policy)
440{
441 return 0;
442}
443
444static int s5pv210_cpufreq_resume(struct cpufreq_policy *policy)
445{
446 return 0;
447}
448#endif
449
450static int check_mem_type(void __iomem *dmc_reg) 437static int check_mem_type(void __iomem *dmc_reg)
451{ 438{
452 unsigned long val; 439 unsigned long val;
@@ -502,6 +489,7 @@ static int __init s5pv210_cpu_init(struct cpufreq_policy *policy)
502 s5pv210_dram_conf[1].refresh = (__raw_readl(S5P_VA_DMC1 + 0x30) * 1000); 489 s5pv210_dram_conf[1].refresh = (__raw_readl(S5P_VA_DMC1 + 0x30) * 1000);
503 s5pv210_dram_conf[1].freq = clk_get_rate(dmc1_clk); 490 s5pv210_dram_conf[1].freq = clk_get_rate(dmc1_clk);
504 491
492 policy->suspend_freq = SLEEP_FREQ;
505 return cpufreq_generic_init(policy, s5pv210_freq_table, 40000); 493 return cpufreq_generic_init(policy, s5pv210_freq_table, 40000);
506 494
507out_dmc1: 495out_dmc1:
@@ -511,32 +499,6 @@ out_dmc0:
511 return ret; 499 return ret;
512} 500}
513 501
514static int s5pv210_cpufreq_notifier_event(struct notifier_block *this,
515 unsigned long event, void *ptr)
516{
517 int ret;
518
519 switch (event) {
520 case PM_SUSPEND_PREPARE:
521 ret = cpufreq_driver_target(cpufreq_cpu_get(0), SLEEP_FREQ, 0);
522 if (ret < 0)
523 return NOTIFY_BAD;
524
525 /* Disable updation of cpu frequency */
526 no_cpufreq_access = true;
527 return NOTIFY_OK;
528 case PM_POST_RESTORE:
529 case PM_POST_SUSPEND:
530 /* Enable updation of cpu frequency */
531 no_cpufreq_access = false;
532 cpufreq_driver_target(cpufreq_cpu_get(0), SLEEP_FREQ, 0);
533
534 return NOTIFY_OK;
535 }
536
537 return NOTIFY_DONE;
538}
539
540static int s5pv210_cpufreq_reboot_notifier_event(struct notifier_block *this, 502static int s5pv210_cpufreq_reboot_notifier_event(struct notifier_block *this,
541 unsigned long event, void *ptr) 503 unsigned long event, void *ptr)
542{ 504{
@@ -558,15 +520,11 @@ static struct cpufreq_driver s5pv210_driver = {
558 .init = s5pv210_cpu_init, 520 .init = s5pv210_cpu_init,
559 .name = "s5pv210", 521 .name = "s5pv210",
560#ifdef CONFIG_PM 522#ifdef CONFIG_PM
561 .suspend = s5pv210_cpufreq_suspend, 523 .suspend = cpufreq_generic_suspend,
562 .resume = s5pv210_cpufreq_resume, 524 .resume = cpufreq_generic_suspend, /* We need to set SLEEP FREQ again */
563#endif 525#endif
564}; 526};
565 527
566static struct notifier_block s5pv210_cpufreq_notifier = {
567 .notifier_call = s5pv210_cpufreq_notifier_event,
568};
569
570static struct notifier_block s5pv210_cpufreq_reboot_notifier = { 528static struct notifier_block s5pv210_cpufreq_reboot_notifier = {
571 .notifier_call = s5pv210_cpufreq_reboot_notifier_event, 529 .notifier_call = s5pv210_cpufreq_reboot_notifier_event,
572}; 530};
@@ -586,7 +544,6 @@ static int __init s5pv210_cpufreq_init(void)
586 return PTR_ERR(int_regulator); 544 return PTR_ERR(int_regulator);
587 } 545 }
588 546
589 register_pm_notifier(&s5pv210_cpufreq_notifier);
590 register_reboot_notifier(&s5pv210_cpufreq_reboot_notifier); 547 register_reboot_notifier(&s5pv210_cpufreq_reboot_notifier);
591 548
592 return cpufreq_register_driver(&s5pv210_driver); 549 return cpufreq_register_driver(&s5pv210_driver);
diff --git a/drivers/cpufreq/sc520_freq.c b/drivers/cpufreq/sc520_freq.c
index 6adb354e359c..69371bf0886d 100644
--- a/drivers/cpufreq/sc520_freq.c
+++ b/drivers/cpufreq/sc520_freq.c
@@ -93,7 +93,6 @@ static struct cpufreq_driver sc520_freq_driver = {
93 .verify = cpufreq_generic_frequency_table_verify, 93 .verify = cpufreq_generic_frequency_table_verify,
94 .target_index = sc520_freq_target, 94 .target_index = sc520_freq_target,
95 .init = sc520_freq_cpu_init, 95 .init = sc520_freq_cpu_init,
96 .exit = cpufreq_generic_exit,
97 .name = "sc520_freq", 96 .name = "sc520_freq",
98 .attr = cpufreq_generic_attr, 97 .attr = cpufreq_generic_attr,
99}; 98};
diff --git a/drivers/cpufreq/sh-cpufreq.c b/drivers/cpufreq/sh-cpufreq.c
index 387af12503a6..696170ebd3a3 100644
--- a/drivers/cpufreq/sh-cpufreq.c
+++ b/drivers/cpufreq/sh-cpufreq.c
@@ -143,7 +143,6 @@ static int sh_cpufreq_cpu_exit(struct cpufreq_policy *policy)
143 unsigned int cpu = policy->cpu; 143 unsigned int cpu = policy->cpu;
144 struct clk *cpuclk = &per_cpu(sh_cpuclk, cpu); 144 struct clk *cpuclk = &per_cpu(sh_cpuclk, cpu);
145 145
146 cpufreq_frequency_table_put_attr(cpu);
147 clk_put(cpuclk); 146 clk_put(cpuclk);
148 147
149 return 0; 148 return 0;
diff --git a/drivers/cpufreq/sparc-us2e-cpufreq.c b/drivers/cpufreq/sparc-us2e-cpufreq.c
index 62aa23e219d4..b73feeb666f9 100644
--- a/drivers/cpufreq/sparc-us2e-cpufreq.c
+++ b/drivers/cpufreq/sparc-us2e-cpufreq.c
@@ -301,10 +301,8 @@ static int __init us2e_freq_cpu_init(struct cpufreq_policy *policy)
301 301
302static int us2e_freq_cpu_exit(struct cpufreq_policy *policy) 302static int us2e_freq_cpu_exit(struct cpufreq_policy *policy)
303{ 303{
304 if (cpufreq_us2e_driver) { 304 if (cpufreq_us2e_driver)
305 cpufreq_frequency_table_put_attr(policy->cpu);
306 us2e_freq_target(policy, 0); 305 us2e_freq_target(policy, 0);
307 }
308 306
309 return 0; 307 return 0;
310} 308}
diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
index 724ffbd7105d..9bb42ba50efa 100644
--- a/drivers/cpufreq/sparc-us3-cpufreq.c
+++ b/drivers/cpufreq/sparc-us3-cpufreq.c
@@ -156,10 +156,8 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
156 156
157static int us3_freq_cpu_exit(struct cpufreq_policy *policy) 157static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
158{ 158{
159 if (cpufreq_us3_driver) { 159 if (cpufreq_us3_driver)
160 cpufreq_frequency_table_put_attr(policy->cpu);
161 us3_freq_target(policy, 0); 160 us3_freq_target(policy, 0);
162 }
163 161
164 return 0; 162 return 0;
165} 163}
diff --git a/drivers/cpufreq/spear-cpufreq.c b/drivers/cpufreq/spear-cpufreq.c
index 5c86e3fa5593..4cfdcff8a310 100644
--- a/drivers/cpufreq/spear-cpufreq.c
+++ b/drivers/cpufreq/spear-cpufreq.c
@@ -19,6 +19,7 @@
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/of_device.h> 21#include <linux/of_device.h>
22#include <linux/platform_device.h>
22#include <linux/slab.h> 23#include <linux/slab.h>
23#include <linux/types.h> 24#include <linux/types.h>
24 25
@@ -163,11 +164,10 @@ static struct cpufreq_driver spear_cpufreq_driver = {
163 .target_index = spear_cpufreq_target, 164 .target_index = spear_cpufreq_target,
164 .get = cpufreq_generic_get, 165 .get = cpufreq_generic_get,
165 .init = spear_cpufreq_init, 166 .init = spear_cpufreq_init,
166 .exit = cpufreq_generic_exit,
167 .attr = cpufreq_generic_attr, 167 .attr = cpufreq_generic_attr,
168}; 168};
169 169
170static int spear_cpufreq_driver_init(void) 170static int spear_cpufreq_probe(struct platform_device *pdev)
171{ 171{
172 struct device_node *np; 172 struct device_node *np;
173 const struct property *prop; 173 const struct property *prop;
@@ -235,7 +235,15 @@ out_put_node:
235 of_node_put(np); 235 of_node_put(np);
236 return ret; 236 return ret;
237} 237}
238late_initcall(spear_cpufreq_driver_init); 238
239static struct platform_driver spear_cpufreq_platdrv = {
240 .driver = {
241 .name = "spear-cpufreq",
242 .owner = THIS_MODULE,
243 },
244 .probe = spear_cpufreq_probe,
245};
246module_platform_driver(spear_cpufreq_platdrv);
239 247
240MODULE_AUTHOR("Deepak Sikri <deepak.sikri@st.com>"); 248MODULE_AUTHOR("Deepak Sikri <deepak.sikri@st.com>");
241MODULE_DESCRIPTION("SPEAr CPUFreq driver"); 249MODULE_DESCRIPTION("SPEAr CPUFreq driver");
diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
index 4e1daca5ce3b..6723f0390f20 100644
--- a/drivers/cpufreq/speedstep-centrino.c
+++ b/drivers/cpufreq/speedstep-centrino.c
@@ -406,8 +406,6 @@ static int centrino_cpu_exit(struct cpufreq_policy *policy)
406 if (!per_cpu(centrino_model, cpu)) 406 if (!per_cpu(centrino_model, cpu))
407 return -ENODEV; 407 return -ENODEV;
408 408
409 cpufreq_frequency_table_put_attr(cpu);
410
411 per_cpu(centrino_model, cpu) = NULL; 409 per_cpu(centrino_model, cpu) = NULL;
412 410
413 return 0; 411 return 0;
diff --git a/drivers/cpufreq/speedstep-ich.c b/drivers/cpufreq/speedstep-ich.c
index 7639b2be2a90..394ac159312a 100644
--- a/drivers/cpufreq/speedstep-ich.c
+++ b/drivers/cpufreq/speedstep-ich.c
@@ -311,7 +311,6 @@ static struct cpufreq_driver speedstep_driver = {
311 .verify = cpufreq_generic_frequency_table_verify, 311 .verify = cpufreq_generic_frequency_table_verify,
312 .target_index = speedstep_target, 312 .target_index = speedstep_target,
313 .init = speedstep_cpu_init, 313 .init = speedstep_cpu_init,
314 .exit = cpufreq_generic_exit,
315 .get = speedstep_get, 314 .get = speedstep_get,
316 .attr = cpufreq_generic_attr, 315 .attr = cpufreq_generic_attr,
317}; 316};
diff --git a/drivers/cpufreq/speedstep-smi.c b/drivers/cpufreq/speedstep-smi.c
index 998c17b42200..db5d274dc13a 100644
--- a/drivers/cpufreq/speedstep-smi.c
+++ b/drivers/cpufreq/speedstep-smi.c
@@ -280,7 +280,6 @@ static struct cpufreq_driver speedstep_driver = {
280 .verify = cpufreq_generic_frequency_table_verify, 280 .verify = cpufreq_generic_frequency_table_verify,
281 .target_index = speedstep_target, 281 .target_index = speedstep_target,
282 .init = speedstep_cpu_init, 282 .init = speedstep_cpu_init,
283 .exit = cpufreq_generic_exit,
284 .get = speedstep_get, 283 .get = speedstep_get,
285 .resume = speedstep_resume, 284 .resume = speedstep_resume,
286 .attr = cpufreq_generic_attr, 285 .attr = cpufreq_generic_attr,
diff --git a/drivers/cpufreq/tegra-cpufreq.c b/drivers/cpufreq/tegra-cpufreq.c
index e652c1bd8d0f..63f00598a251 100644
--- a/drivers/cpufreq/tegra-cpufreq.c
+++ b/drivers/cpufreq/tegra-cpufreq.c
@@ -26,7 +26,6 @@
26#include <linux/err.h> 26#include <linux/err.h>
27#include <linux/clk.h> 27#include <linux/clk.h>
28#include <linux/io.h> 28#include <linux/io.h>
29#include <linux/suspend.h>
30 29
31static struct cpufreq_frequency_table freq_table[] = { 30static struct cpufreq_frequency_table freq_table[] = {
32 { .frequency = 216000 }, 31 { .frequency = 216000 },
@@ -47,9 +46,6 @@ static struct clk *pll_x_clk;
47static struct clk *pll_p_clk; 46static struct clk *pll_p_clk;
48static struct clk *emc_clk; 47static struct clk *emc_clk;
49 48
50static DEFINE_MUTEX(tegra_cpu_lock);
51static bool is_suspended;
52
53static int tegra_cpu_clk_set_rate(unsigned long rate) 49static int tegra_cpu_clk_set_rate(unsigned long rate)
54{ 50{
55 int ret; 51 int ret;
@@ -112,42 +108,9 @@ static int tegra_update_cpu_speed(struct cpufreq_policy *policy,
112 108
113static int tegra_target(struct cpufreq_policy *policy, unsigned int index) 109static int tegra_target(struct cpufreq_policy *policy, unsigned int index)
114{ 110{
115 int ret = -EBUSY; 111 return tegra_update_cpu_speed(policy, freq_table[index].frequency);
116
117 mutex_lock(&tegra_cpu_lock);
118
119 if (!is_suspended)
120 ret = tegra_update_cpu_speed(policy,
121 freq_table[index].frequency);
122
123 mutex_unlock(&tegra_cpu_lock);
124 return ret;
125} 112}
126 113
127static int tegra_pm_notify(struct notifier_block *nb, unsigned long event,
128 void *dummy)
129{
130 mutex_lock(&tegra_cpu_lock);
131 if (event == PM_SUSPEND_PREPARE) {
132 struct cpufreq_policy *policy = cpufreq_cpu_get(0);
133 is_suspended = true;
134 pr_info("Tegra cpufreq suspend: setting frequency to %d kHz\n",
135 freq_table[0].frequency);
136 if (clk_get_rate(cpu_clk) / 1000 != freq_table[0].frequency)
137 tegra_update_cpu_speed(policy, freq_table[0].frequency);
138 cpufreq_cpu_put(policy);
139 } else if (event == PM_POST_SUSPEND) {
140 is_suspended = false;
141 }
142 mutex_unlock(&tegra_cpu_lock);
143
144 return NOTIFY_OK;
145}
146
147static struct notifier_block tegra_cpu_pm_notifier = {
148 .notifier_call = tegra_pm_notify,
149};
150
151static int tegra_cpu_init(struct cpufreq_policy *policy) 114static int tegra_cpu_init(struct cpufreq_policy *policy)
152{ 115{
153 int ret; 116 int ret;
@@ -166,16 +129,13 @@ static int tegra_cpu_init(struct cpufreq_policy *policy)
166 return ret; 129 return ret;
167 } 130 }
168 131
169 if (policy->cpu == 0)
170 register_pm_notifier(&tegra_cpu_pm_notifier);
171
172 policy->clk = cpu_clk; 132 policy->clk = cpu_clk;
133 policy->suspend_freq = freq_table[0].frequency;
173 return 0; 134 return 0;
174} 135}
175 136
176static int tegra_cpu_exit(struct cpufreq_policy *policy) 137static int tegra_cpu_exit(struct cpufreq_policy *policy)
177{ 138{
178 cpufreq_frequency_table_put_attr(policy->cpu);
179 clk_disable_unprepare(cpu_clk); 139 clk_disable_unprepare(cpu_clk);
180 clk_disable_unprepare(emc_clk); 140 clk_disable_unprepare(emc_clk);
181 return 0; 141 return 0;
@@ -190,6 +150,9 @@ static struct cpufreq_driver tegra_cpufreq_driver = {
190 .exit = tegra_cpu_exit, 150 .exit = tegra_cpu_exit,
191 .name = "tegra", 151 .name = "tegra",
192 .attr = cpufreq_generic_attr, 152 .attr = cpufreq_generic_attr,
153#ifdef CONFIG_PM
154 .suspend = cpufreq_generic_suspend,
155#endif
193}; 156};
194 157
195static int __init tegra_cpufreq_init(void) 158static int __init tegra_cpufreq_init(void)
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index 09d05ab262be..cb20fd915be8 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -85,7 +85,8 @@ int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv,
85 85
86 time_end = ktime_get(); 86 time_end = ktime_get();
87 87
88 local_irq_enable(); 88 if (!cpuidle_state_is_coupled(dev, drv, entered_state))
89 local_irq_enable();
89 90
90 diff = ktime_to_us(ktime_sub(time_end, time_start)); 91 diff = ktime_to_us(ktime_sub(time_end, time_start));
91 if (diff > INT_MAX) 92 if (diff > INT_MAX)
diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c
index 06dbe7c86199..136d6a283e0a 100644
--- a/drivers/cpuidle/driver.c
+++ b/drivers/cpuidle/driver.c
@@ -209,7 +209,7 @@ static void poll_idle_init(struct cpuidle_driver *drv)
209 state->exit_latency = 0; 209 state->exit_latency = 0;
210 state->target_residency = 0; 210 state->target_residency = 0;
211 state->power_usage = -1; 211 state->power_usage = -1;
212 state->flags = 0; 212 state->flags = CPUIDLE_FLAG_TIME_VALID;
213 state->enter = poll_idle; 213 state->enter = poll_idle;
214 state->disabled = false; 214 state->disabled = false;
215} 215}
diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
index cf7f2f0e4ef5..71b523293354 100644
--- a/drivers/cpuidle/governors/menu.c
+++ b/drivers/cpuidle/governors/menu.c
@@ -122,9 +122,8 @@ struct menu_device {
122 int last_state_idx; 122 int last_state_idx;
123 int needs_update; 123 int needs_update;
124 124
125 unsigned int expected_us; 125 unsigned int next_timer_us;
126 unsigned int predicted_us; 126 unsigned int predicted_us;
127 unsigned int exit_us;
128 unsigned int bucket; 127 unsigned int bucket;
129 unsigned int correction_factor[BUCKETS]; 128 unsigned int correction_factor[BUCKETS];
130 unsigned int intervals[INTERVALS]; 129 unsigned int intervals[INTERVALS];
@@ -257,7 +256,7 @@ again:
257 stddev = int_sqrt(stddev); 256 stddev = int_sqrt(stddev);
258 if (((avg > stddev * 6) && (divisor * 4 >= INTERVALS * 3)) 257 if (((avg > stddev * 6) && (divisor * 4 >= INTERVALS * 3))
259 || stddev <= 20) { 258 || stddev <= 20) {
260 if (data->expected_us > avg) 259 if (data->next_timer_us > avg)
261 data->predicted_us = avg; 260 data->predicted_us = avg;
262 return; 261 return;
263 } 262 }
@@ -289,7 +288,7 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
289 struct menu_device *data = &__get_cpu_var(menu_devices); 288 struct menu_device *data = &__get_cpu_var(menu_devices);
290 int latency_req = pm_qos_request(PM_QOS_CPU_DMA_LATENCY); 289 int latency_req = pm_qos_request(PM_QOS_CPU_DMA_LATENCY);
291 int i; 290 int i;
292 int multiplier; 291 unsigned int interactivity_req;
293 struct timespec t; 292 struct timespec t;
294 293
295 if (data->needs_update) { 294 if (data->needs_update) {
@@ -298,7 +297,6 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
298 } 297 }
299 298
300 data->last_state_idx = 0; 299 data->last_state_idx = 0;
301 data->exit_us = 0;
302 300
303 /* Special case when user has set very strict latency requirement */ 301 /* Special case when user has set very strict latency requirement */
304 if (unlikely(latency_req == 0)) 302 if (unlikely(latency_req == 0))
@@ -306,13 +304,11 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
306 304
307 /* determine the expected residency time, round up */ 305 /* determine the expected residency time, round up */
308 t = ktime_to_timespec(tick_nohz_get_sleep_length()); 306 t = ktime_to_timespec(tick_nohz_get_sleep_length());
309 data->expected_us = 307 data->next_timer_us =
310 t.tv_sec * USEC_PER_SEC + t.tv_nsec / NSEC_PER_USEC; 308 t.tv_sec * USEC_PER_SEC + t.tv_nsec / NSEC_PER_USEC;
311 309
312 310
313 data->bucket = which_bucket(data->expected_us); 311 data->bucket = which_bucket(data->next_timer_us);
314
315 multiplier = performance_multiplier();
316 312
317 /* 313 /*
318 * if the correction factor is 0 (eg first time init or cpu hotplug 314 * if the correction factor is 0 (eg first time init or cpu hotplug
@@ -326,17 +322,26 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
326 * operands are 32 bits. 322 * operands are 32 bits.
327 * Make sure to round up for half microseconds. 323 * Make sure to round up for half microseconds.
328 */ 324 */
329 data->predicted_us = div_round64((uint64_t)data->expected_us * 325 data->predicted_us = div_round64((uint64_t)data->next_timer_us *
330 data->correction_factor[data->bucket], 326 data->correction_factor[data->bucket],
331 RESOLUTION * DECAY); 327 RESOLUTION * DECAY);
332 328
333 get_typical_interval(data); 329 get_typical_interval(data);
334 330
335 /* 331 /*
332 * Performance multiplier defines a minimum predicted idle
333 * duration / latency ratio. Adjust the latency limit if
334 * necessary.
335 */
336 interactivity_req = data->predicted_us / performance_multiplier();
337 if (latency_req > interactivity_req)
338 latency_req = interactivity_req;
339
340 /*
336 * We want to default to C1 (hlt), not to busy polling 341 * We want to default to C1 (hlt), not to busy polling
337 * unless the timer is happening really really soon. 342 * unless the timer is happening really really soon.
338 */ 343 */
339 if (data->expected_us > 5 && 344 if (data->next_timer_us > 5 &&
340 !drv->states[CPUIDLE_DRIVER_STATE_START].disabled && 345 !drv->states[CPUIDLE_DRIVER_STATE_START].disabled &&
341 dev->states_usage[CPUIDLE_DRIVER_STATE_START].disable == 0) 346 dev->states_usage[CPUIDLE_DRIVER_STATE_START].disable == 0)
342 data->last_state_idx = CPUIDLE_DRIVER_STATE_START; 347 data->last_state_idx = CPUIDLE_DRIVER_STATE_START;
@@ -355,11 +360,8 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
355 continue; 360 continue;
356 if (s->exit_latency > latency_req) 361 if (s->exit_latency > latency_req)
357 continue; 362 continue;
358 if (s->exit_latency * multiplier > data->predicted_us)
359 continue;
360 363
361 data->last_state_idx = i; 364 data->last_state_idx = i;
362 data->exit_us = s->exit_latency;
363 } 365 }
364 366
365 return data->last_state_idx; 367 return data->last_state_idx;
@@ -390,36 +392,47 @@ static void menu_update(struct cpuidle_driver *drv, struct cpuidle_device *dev)
390{ 392{
391 struct menu_device *data = &__get_cpu_var(menu_devices); 393 struct menu_device *data = &__get_cpu_var(menu_devices);
392 int last_idx = data->last_state_idx; 394 int last_idx = data->last_state_idx;
393 unsigned int last_idle_us = cpuidle_get_last_residency(dev);
394 struct cpuidle_state *target = &drv->states[last_idx]; 395 struct cpuidle_state *target = &drv->states[last_idx];
395 unsigned int measured_us; 396 unsigned int measured_us;
396 unsigned int new_factor; 397 unsigned int new_factor;
397 398
398 /* 399 /*
399 * Ugh, this idle state doesn't support residency measurements, so we 400 * Try to figure out how much time passed between entry to low
400 * are basically lost in the dark. As a compromise, assume we slept 401 * power state and occurrence of the wakeup event.
401 * for the whole expected time. 402 *
403 * If the entered idle state didn't support residency measurements,
404 * we are basically lost in the dark how much time passed.
405 * As a compromise, assume we slept for the whole expected time.
406 *
407 * Any measured amount of time will include the exit latency.
408 * Since we are interested in when the wakeup begun, not when it
409 * was completed, we must substract the exit latency. However, if
410 * the measured amount of time is less than the exit latency,
411 * assume the state was never reached and the exit latency is 0.
402 */ 412 */
403 if (unlikely(!(target->flags & CPUIDLE_FLAG_TIME_VALID))) 413 if (unlikely(!(target->flags & CPUIDLE_FLAG_TIME_VALID))) {
404 last_idle_us = data->expected_us; 414 /* Use timer value as is */
415 measured_us = data->next_timer_us;
405 416
417 } else {
418 /* Use measured value */
419 measured_us = cpuidle_get_last_residency(dev);
406 420
407 measured_us = last_idle_us; 421 /* Deduct exit latency */
408 422 if (measured_us > target->exit_latency)
409 /* 423 measured_us -= target->exit_latency;
410 * We correct for the exit latency; we are assuming here that the
411 * exit latency happens after the event that we're interested in.
412 */
413 if (measured_us > data->exit_us)
414 measured_us -= data->exit_us;
415 424
425 /* Make sure our coefficients do not exceed unity */
426 if (measured_us > data->next_timer_us)
427 measured_us = data->next_timer_us;
428 }
416 429
417 /* Update our correction ratio */ 430 /* Update our correction ratio */
418 new_factor = data->correction_factor[data->bucket]; 431 new_factor = data->correction_factor[data->bucket];
419 new_factor -= new_factor / DECAY; 432 new_factor -= new_factor / DECAY;
420 433
421 if (data->expected_us > 0 && measured_us < MAX_INTERESTING) 434 if (data->next_timer_us > 0 && measured_us < MAX_INTERESTING)
422 new_factor += RESOLUTION * measured_us / data->expected_us; 435 new_factor += RESOLUTION * measured_us / data->next_timer_us;
423 else 436 else
424 /* 437 /*
425 * we were idle so long that we count it as a perfect 438 * we were idle so long that we count it as a perfect
@@ -439,7 +452,7 @@ static void menu_update(struct cpuidle_driver *drv, struct cpuidle_device *dev)
439 data->correction_factor[data->bucket] = new_factor; 452 data->correction_factor[data->bucket] = new_factor;
440 453
441 /* update the repeating-pattern data */ 454 /* update the repeating-pattern data */
442 data->intervals[data->interval_ptr++] = last_idle_us; 455 data->intervals[data->interval_ptr++] = measured_us;
443 if (data->interval_ptr >= INTERVALS) 456 if (data->interval_ptr >= INTERVALS)
444 data->interval_ptr = 0; 457 data->interval_ptr = 0;
445} 458}
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index a0b2f7e0eedb..2042ec3656ba 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -91,26 +91,35 @@ static int devfreq_get_freq_level(struct devfreq *devfreq, unsigned long freq)
91 */ 91 */
92static int devfreq_update_status(struct devfreq *devfreq, unsigned long freq) 92static int devfreq_update_status(struct devfreq *devfreq, unsigned long freq)
93{ 93{
94 int lev, prev_lev; 94 int lev, prev_lev, ret = 0;
95 unsigned long cur_time; 95 unsigned long cur_time;
96 96
97 lev = devfreq_get_freq_level(devfreq, freq);
98 if (lev < 0)
99 return lev;
100
101 cur_time = jiffies; 97 cur_time = jiffies;
102 devfreq->time_in_state[lev] += 98
99 prev_lev = devfreq_get_freq_level(devfreq, devfreq->previous_freq);
100 if (prev_lev < 0) {
101 ret = prev_lev;
102 goto out;
103 }
104
105 devfreq->time_in_state[prev_lev] +=
103 cur_time - devfreq->last_stat_updated; 106 cur_time - devfreq->last_stat_updated;
104 if (freq != devfreq->previous_freq) { 107
105 prev_lev = devfreq_get_freq_level(devfreq, 108 lev = devfreq_get_freq_level(devfreq, freq);
106 devfreq->previous_freq); 109 if (lev < 0) {
110 ret = lev;
111 goto out;
112 }
113
114 if (lev != prev_lev) {
107 devfreq->trans_table[(prev_lev * 115 devfreq->trans_table[(prev_lev *
108 devfreq->profile->max_state) + lev]++; 116 devfreq->profile->max_state) + lev]++;
109 devfreq->total_trans++; 117 devfreq->total_trans++;
110 } 118 }
111 devfreq->last_stat_updated = cur_time;
112 119
113 return 0; 120out:
121 devfreq->last_stat_updated = cur_time;
122 return ret;
114} 123}
115 124
116/** 125/**
diff --git a/drivers/gpu/drm/gma500/Kconfig b/drivers/gpu/drm/gma500/Kconfig
index 508cf99a292d..17f928ec84ea 100644
--- a/drivers/gpu/drm/gma500/Kconfig
+++ b/drivers/gpu/drm/gma500/Kconfig
@@ -10,7 +10,6 @@ config DRM_GMA500
10 # GMA500 depends on ACPI_VIDEO when ACPI is enabled, just like i915 10 # GMA500 depends on ACPI_VIDEO when ACPI is enabled, just like i915
11 select ACPI_VIDEO if ACPI 11 select ACPI_VIDEO if ACPI
12 select BACKLIGHT_CLASS_DEVICE if ACPI 12 select BACKLIGHT_CLASS_DEVICE if ACPI
13 select VIDEO_OUTPUT_CONTROL if ACPI
14 select INPUT if ACPI 13 select INPUT if ACPI
15 help 14 help
16 Say yes for an experimental 2D KMS framebuffer driver for the 15 Say yes for an experimental 2D KMS framebuffer driver for the
diff --git a/drivers/gpu/drm/i915/Kconfig b/drivers/gpu/drm/i915/Kconfig
index 73ed59eff139..bea2d67196fb 100644
--- a/drivers/gpu/drm/i915/Kconfig
+++ b/drivers/gpu/drm/i915/Kconfig
@@ -14,7 +14,6 @@ config DRM_I915
14 # but for select to work, need to select ACPI_VIDEO's dependencies, ick 14 # but for select to work, need to select ACPI_VIDEO's dependencies, ick
15 select BACKLIGHT_LCD_SUPPORT if ACPI 15 select BACKLIGHT_LCD_SUPPORT if ACPI
16 select BACKLIGHT_CLASS_DEVICE if ACPI 16 select BACKLIGHT_CLASS_DEVICE if ACPI
17 select VIDEO_OUTPUT_CONTROL if ACPI
18 select INPUT if ACPI 17 select INPUT if ACPI
19 select ACPI_VIDEO if ACPI 18 select ACPI_VIDEO if ACPI
20 select ACPI_BUTTON if ACPI 19 select ACPI_BUTTON if ACPI
diff --git a/drivers/gpu/drm/nouveau/Kconfig b/drivers/gpu/drm/nouveau/Kconfig
index 7cf787d697b1..637c29a33127 100644
--- a/drivers/gpu/drm/nouveau/Kconfig
+++ b/drivers/gpu/drm/nouveau/Kconfig
@@ -11,7 +11,7 @@ config DRM_NOUVEAU
11 select FB 11 select FB
12 select FRAMEBUFFER_CONSOLE if !EXPERT 12 select FRAMEBUFFER_CONSOLE if !EXPERT
13 select FB_BACKLIGHT if DRM_NOUVEAU_BACKLIGHT 13 select FB_BACKLIGHT if DRM_NOUVEAU_BACKLIGHT
14 select ACPI_VIDEO if ACPI && X86 && BACKLIGHT_CLASS_DEVICE && VIDEO_OUTPUT_CONTROL && INPUT 14 select ACPI_VIDEO if ACPI && X86 && BACKLIGHT_CLASS_DEVICE && INPUT
15 select X86_PLATFORM_DEVICES if ACPI && X86 15 select X86_PLATFORM_DEVICES if ACPI && X86
16 select ACPI_WMI if ACPI && X86 16 select ACPI_WMI if ACPI && X86
17 select MXM_WMI if ACPI && X86 17 select MXM_WMI if ACPI && X86
@@ -19,7 +19,6 @@ config DRM_NOUVEAU
19 # Similar to i915, we need to select ACPI_VIDEO and it's dependencies 19 # Similar to i915, we need to select ACPI_VIDEO and it's dependencies
20 select BACKLIGHT_LCD_SUPPORT if ACPI && X86 20 select BACKLIGHT_LCD_SUPPORT if ACPI && X86
21 select BACKLIGHT_CLASS_DEVICE if ACPI && X86 21 select BACKLIGHT_CLASS_DEVICE if ACPI && X86
22 select VIDEO_OUTPUT_CONTROL if ACPI && X86
23 select INPUT if ACPI && X86 22 select INPUT if ACPI && X86
24 select THERMAL if ACPI && X86 23 select THERMAL if ACPI && X86
25 select ACPI_VIDEO if ACPI && X86 24 select ACPI_VIDEO if ACPI && X86
diff --git a/drivers/input/touchscreen/st1232.c b/drivers/input/touchscreen/st1232.c
index 5c342b3139e8..3c0f57efe7b1 100644
--- a/drivers/input/touchscreen/st1232.c
+++ b/drivers/input/touchscreen/st1232.c
@@ -134,7 +134,8 @@ static irqreturn_t st1232_ts_irq_handler(int irq, void *dev_id)
134 } else if (!ts->low_latency_req.dev) { 134 } else if (!ts->low_latency_req.dev) {
135 /* First contact, request 100 us latency. */ 135 /* First contact, request 100 us latency. */
136 dev_pm_qos_add_ancestor_request(&ts->client->dev, 136 dev_pm_qos_add_ancestor_request(&ts->client->dev,
137 &ts->low_latency_req, 100); 137 &ts->low_latency_req,
138 DEV_PM_QOS_RESUME_LATENCY, 100);
138 } 139 }
139 140
140 /* SYN_REPORT */ 141 /* SYN_REPORT */
diff --git a/drivers/mtd/nand/sh_flctl.c b/drivers/mtd/nand/sh_flctl.c
index d72783dd7b96..c0670237e7a2 100644
--- a/drivers/mtd/nand/sh_flctl.c
+++ b/drivers/mtd/nand/sh_flctl.c
@@ -897,7 +897,7 @@ static void flctl_select_chip(struct mtd_info *mtd, int chipnr)
897 if (!flctl->qos_request) { 897 if (!flctl->qos_request) {
898 ret = dev_pm_qos_add_request(&flctl->pdev->dev, 898 ret = dev_pm_qos_add_request(&flctl->pdev->dev,
899 &flctl->pm_qos, 899 &flctl->pm_qos,
900 DEV_PM_QOS_LATENCY, 900 DEV_PM_QOS_RESUME_LATENCY,
901 100); 901 100);
902 if (ret < 0) 902 if (ret < 0)
903 dev_err(&flctl->pdev->dev, 903 dev_err(&flctl->pdev->dev,
diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h
index b6162be4df40..2b859249303b 100644
--- a/drivers/pci/hotplug/acpiphp.h
+++ b/drivers/pci/hotplug/acpiphp.h
@@ -93,7 +93,6 @@ struct acpiphp_slot {
93 struct list_head funcs; /* one slot may have different 93 struct list_head funcs; /* one slot may have different
94 objects (i.e. for each function) */ 94 objects (i.e. for each function) */
95 struct slot *slot; 95 struct slot *slot;
96 struct mutex crit_sect;
97 96
98 u8 device; /* pci device# */ 97 u8 device; /* pci device# */
99 u32 flags; /* see below */ 98 u32 flags; /* see below */
@@ -117,20 +116,30 @@ struct acpiphp_func {
117}; 116};
118 117
119struct acpiphp_context { 118struct acpiphp_context {
120 acpi_handle handle; 119 struct acpi_hotplug_context hp;
121 struct acpiphp_func func; 120 struct acpiphp_func func;
122 struct acpiphp_bridge *bridge; 121 struct acpiphp_bridge *bridge;
123 unsigned int refcount; 122 unsigned int refcount;
124}; 123};
125 124
125static inline struct acpiphp_context *to_acpiphp_context(struct acpi_hotplug_context *hp)
126{
127 return container_of(hp, struct acpiphp_context, hp);
128}
129
126static inline struct acpiphp_context *func_to_context(struct acpiphp_func *func) 130static inline struct acpiphp_context *func_to_context(struct acpiphp_func *func)
127{ 131{
128 return container_of(func, struct acpiphp_context, func); 132 return container_of(func, struct acpiphp_context, func);
129} 133}
130 134
135static inline struct acpi_device *func_to_acpi_device(struct acpiphp_func *func)
136{
137 return func_to_context(func)->hp.self;
138}
139
131static inline acpi_handle func_to_handle(struct acpiphp_func *func) 140static inline acpi_handle func_to_handle(struct acpiphp_func *func)
132{ 141{
133 return func_to_context(func)->handle; 142 return func_to_acpi_device(func)->handle;
134} 143}
135 144
136/* 145/*
@@ -158,7 +167,6 @@ struct acpiphp_attention_info
158 167
159#define FUNC_HAS_STA (0x00000001) 168#define FUNC_HAS_STA (0x00000001)
160#define FUNC_HAS_EJ0 (0x00000002) 169#define FUNC_HAS_EJ0 (0x00000002)
161#define FUNC_HAS_DCK (0x00000004)
162 170
163/* function prototypes */ 171/* function prototypes */
164 172
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index 7c7a388c85ab..828acf422c17 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -58,71 +58,59 @@
58 58
59static LIST_HEAD(bridge_list); 59static LIST_HEAD(bridge_list);
60static DEFINE_MUTEX(bridge_mutex); 60static DEFINE_MUTEX(bridge_mutex);
61static DEFINE_MUTEX(acpiphp_context_lock);
62 61
63static void handle_hotplug_event(acpi_handle handle, u32 type, void *data); 62static int acpiphp_hotplug_notify(struct acpi_device *adev, u32 type);
63static void acpiphp_post_dock_fixup(struct acpi_device *adev);
64static void acpiphp_sanitize_bus(struct pci_bus *bus); 64static void acpiphp_sanitize_bus(struct pci_bus *bus);
65static void acpiphp_set_hpp_values(struct pci_bus *bus); 65static void acpiphp_set_hpp_values(struct pci_bus *bus);
66static void hotplug_event(acpi_handle handle, u32 type, void *data); 66static void hotplug_event(u32 type, struct acpiphp_context *context);
67static void free_bridge(struct kref *kref); 67static void free_bridge(struct kref *kref);
68 68
69static void acpiphp_context_handler(acpi_handle handle, void *context)
70{
71 /* Intentionally empty. */
72}
73
74/** 69/**
75 * acpiphp_init_context - Create hotplug context and grab a reference to it. 70 * acpiphp_init_context - Create hotplug context and grab a reference to it.
76 * @handle: ACPI object handle to create the context for. 71 * @adev: ACPI device object to create the context for.
77 * 72 *
78 * Call under acpiphp_context_lock. 73 * Call under acpi_hp_context_lock.
79 */ 74 */
80static struct acpiphp_context *acpiphp_init_context(acpi_handle handle) 75static struct acpiphp_context *acpiphp_init_context(struct acpi_device *adev)
81{ 76{
82 struct acpiphp_context *context; 77 struct acpiphp_context *context;
83 acpi_status status;
84 78
85 context = kzalloc(sizeof(*context), GFP_KERNEL); 79 context = kzalloc(sizeof(*context), GFP_KERNEL);
86 if (!context) 80 if (!context)
87 return NULL; 81 return NULL;
88 82
89 context->handle = handle;
90 context->refcount = 1; 83 context->refcount = 1;
91 status = acpi_attach_data(handle, acpiphp_context_handler, context); 84 acpi_set_hp_context(adev, &context->hp, acpiphp_hotplug_notify, NULL,
92 if (ACPI_FAILURE(status)) { 85 acpiphp_post_dock_fixup);
93 kfree(context);
94 return NULL;
95 }
96 return context; 86 return context;
97} 87}
98 88
99/** 89/**
100 * acpiphp_get_context - Get hotplug context and grab a reference to it. 90 * acpiphp_get_context - Get hotplug context and grab a reference to it.
101 * @handle: ACPI object handle to get the context for. 91 * @adev: ACPI device object to get the context for.
102 * 92 *
103 * Call under acpiphp_context_lock. 93 * Call under acpi_hp_context_lock.
104 */ 94 */
105static struct acpiphp_context *acpiphp_get_context(acpi_handle handle) 95static struct acpiphp_context *acpiphp_get_context(struct acpi_device *adev)
106{ 96{
107 struct acpiphp_context *context = NULL; 97 struct acpiphp_context *context;
108 acpi_status status;
109 void *data;
110 98
111 status = acpi_get_data(handle, acpiphp_context_handler, &data); 99 if (!adev->hp)
112 if (ACPI_SUCCESS(status)) { 100 return NULL;
113 context = data; 101
114 context->refcount++; 102 context = to_acpiphp_context(adev->hp);
115 } 103 context->refcount++;
116 return context; 104 return context;
117} 105}
118 106
119/** 107/**
120 * acpiphp_put_context - Drop a reference to ACPI hotplug context. 108 * acpiphp_put_context - Drop a reference to ACPI hotplug context.
121 * @handle: ACPI object handle to put the context for. 109 * @context: ACPI hotplug context to drop a reference to.
122 * 110 *
123 * The context object is removed if there are no more references to it. 111 * The context object is removed if there are no more references to it.
124 * 112 *
125 * Call under acpiphp_context_lock. 113 * Call under acpi_hp_context_lock.
126 */ 114 */
127static void acpiphp_put_context(struct acpiphp_context *context) 115static void acpiphp_put_context(struct acpiphp_context *context)
128{ 116{
@@ -130,7 +118,7 @@ static void acpiphp_put_context(struct acpiphp_context *context)
130 return; 118 return;
131 119
132 WARN_ON(context->bridge); 120 WARN_ON(context->bridge);
133 acpi_detach_data(context->handle, acpiphp_context_handler); 121 context->hp.self->hp = NULL;
134 kfree(context); 122 kfree(context);
135} 123}
136 124
@@ -144,6 +132,27 @@ static inline void put_bridge(struct acpiphp_bridge *bridge)
144 kref_put(&bridge->ref, free_bridge); 132 kref_put(&bridge->ref, free_bridge);
145} 133}
146 134
135static struct acpiphp_context *acpiphp_grab_context(struct acpi_device *adev)
136{
137 struct acpiphp_context *context;
138
139 acpi_lock_hp_context();
140 context = acpiphp_get_context(adev);
141 if (!context || context->func.parent->is_going_away) {
142 acpi_unlock_hp_context();
143 return NULL;
144 }
145 get_bridge(context->func.parent);
146 acpiphp_put_context(context);
147 acpi_unlock_hp_context();
148 return context;
149}
150
151static void acpiphp_let_context_go(struct acpiphp_context *context)
152{
153 put_bridge(context->func.parent);
154}
155
147static void free_bridge(struct kref *kref) 156static void free_bridge(struct kref *kref)
148{ 157{
149 struct acpiphp_context *context; 158 struct acpiphp_context *context;
@@ -151,7 +160,7 @@ static void free_bridge(struct kref *kref)
151 struct acpiphp_slot *slot, *next; 160 struct acpiphp_slot *slot, *next;
152 struct acpiphp_func *func, *tmp; 161 struct acpiphp_func *func, *tmp;
153 162
154 mutex_lock(&acpiphp_context_lock); 163 acpi_lock_hp_context();
155 164
156 bridge = container_of(kref, struct acpiphp_bridge, ref); 165 bridge = container_of(kref, struct acpiphp_bridge, ref);
157 166
@@ -175,31 +184,32 @@ static void free_bridge(struct kref *kref)
175 pci_dev_put(bridge->pci_dev); 184 pci_dev_put(bridge->pci_dev);
176 kfree(bridge); 185 kfree(bridge);
177 186
178 mutex_unlock(&acpiphp_context_lock); 187 acpi_unlock_hp_context();
179} 188}
180 189
181/* 190/**
182 * the _DCK method can do funny things... and sometimes not 191 * acpiphp_post_dock_fixup - Post-dock fixups for PCI devices.
183 * hah-hah funny. 192 * @adev: ACPI device object corresponding to a PCI device.
184 * 193 *
185 * TBD - figure out a way to only call fixups for 194 * TBD - figure out a way to only call fixups for systems that require them.
186 * systems that require them.
187 */ 195 */
188static void post_dock_fixups(acpi_handle not_used, u32 event, void *data) 196static void acpiphp_post_dock_fixup(struct acpi_device *adev)
189{ 197{
190 struct acpiphp_context *context = data; 198 struct acpiphp_context *context = acpiphp_grab_context(adev);
191 struct pci_bus *bus = context->func.slot->bus; 199 struct pci_bus *bus;
192 u32 buses; 200 u32 buses;
193 201
194 if (!bus->self) 202 if (!context)
195 return; 203 return;
196 204
205 bus = context->func.slot->bus;
206 if (!bus->self)
207 goto out;
208
197 /* fixup bad _DCK function that rewrites 209 /* fixup bad _DCK function that rewrites
198 * secondary bridge on slot 210 * secondary bridge on slot
199 */ 211 */
200 pci_read_config_dword(bus->self, 212 pci_read_config_dword(bus->self, PCI_PRIMARY_BUS, &buses);
201 PCI_PRIMARY_BUS,
202 &buses);
203 213
204 if (((buses >> 8) & 0xff) != bus->busn_res.start) { 214 if (((buses >> 8) & 0xff) != bus->busn_res.start) {
205 buses = (buses & 0xff000000) 215 buses = (buses & 0xff000000)
@@ -208,33 +218,11 @@ static void post_dock_fixups(acpi_handle not_used, u32 event, void *data)
208 | ((unsigned int)(bus->busn_res.end) << 16); 218 | ((unsigned int)(bus->busn_res.end) << 16);
209 pci_write_config_dword(bus->self, PCI_PRIMARY_BUS, buses); 219 pci_write_config_dword(bus->self, PCI_PRIMARY_BUS, buses);
210 } 220 }
211}
212
213static void dock_event(acpi_handle handle, u32 type, void *data)
214{
215 struct acpiphp_context *context;
216
217 mutex_lock(&acpiphp_context_lock);
218 context = acpiphp_get_context(handle);
219 if (!context || WARN_ON(context->handle != handle)
220 || context->func.parent->is_going_away) {
221 mutex_unlock(&acpiphp_context_lock);
222 return;
223 }
224 get_bridge(context->func.parent);
225 acpiphp_put_context(context);
226 mutex_unlock(&acpiphp_context_lock);
227
228 hotplug_event(handle, type, data);
229 221
230 put_bridge(context->func.parent); 222 out:
223 acpiphp_let_context_go(context);
231} 224}
232 225
233static const struct acpi_dock_ops acpiphp_dock_ops = {
234 .fixup = post_dock_fixups,
235 .handler = dock_event,
236};
237
238/* Check whether the PCI device is managed by native PCIe hotplug driver */ 226/* Check whether the PCI device is managed by native PCIe hotplug driver */
239static bool device_is_managed_by_native_pciehp(struct pci_dev *pdev) 227static bool device_is_managed_by_native_pciehp(struct pci_dev *pdev)
240{ 228{
@@ -264,26 +252,19 @@ static bool device_is_managed_by_native_pciehp(struct pci_dev *pdev)
264 return true; 252 return true;
265} 253}
266 254
267static void acpiphp_dock_init(void *data) 255/**
268{ 256 * acpiphp_add_context - Add ACPIPHP context to an ACPI device object.
269 struct acpiphp_context *context = data; 257 * @handle: ACPI handle of the object to add a context to.
270 258 * @lvl: Not used.
271 get_bridge(context->func.parent); 259 * @data: The object's parent ACPIPHP bridge.
272} 260 * @rv: Not used.
273 261 */
274static void acpiphp_dock_release(void *data) 262static acpi_status acpiphp_add_context(acpi_handle handle, u32 lvl, void *data,
275{ 263 void **rv)
276 struct acpiphp_context *context = data;
277
278 put_bridge(context->func.parent);
279}
280
281/* callback routine to register each ACPI PCI slot object */
282static acpi_status register_slot(acpi_handle handle, u32 lvl, void *data,
283 void **rv)
284{ 264{
285 struct acpiphp_bridge *bridge = data; 265 struct acpiphp_bridge *bridge = data;
286 struct acpiphp_context *context; 266 struct acpiphp_context *context;
267 struct acpi_device *adev;
287 struct acpiphp_slot *slot; 268 struct acpiphp_slot *slot;
288 struct acpiphp_func *newfunc; 269 struct acpiphp_func *newfunc;
289 acpi_status status = AE_OK; 270 acpi_status status = AE_OK;
@@ -293,9 +274,6 @@ static acpi_status register_slot(acpi_handle handle, u32 lvl, void *data,
293 struct pci_dev *pdev = bridge->pci_dev; 274 struct pci_dev *pdev = bridge->pci_dev;
294 u32 val; 275 u32 val;
295 276
296 if (pdev && device_is_managed_by_native_pciehp(pdev))
297 return AE_OK;
298
299 status = acpi_evaluate_integer(handle, "_ADR", NULL, &adr); 277 status = acpi_evaluate_integer(handle, "_ADR", NULL, &adr);
300 if (ACPI_FAILURE(status)) { 278 if (ACPI_FAILURE(status)) {
301 if (status != AE_NOT_FOUND) 279 if (status != AE_NOT_FOUND)
@@ -303,31 +281,34 @@ static acpi_status register_slot(acpi_handle handle, u32 lvl, void *data,
303 "can't evaluate _ADR (%#x)\n", status); 281 "can't evaluate _ADR (%#x)\n", status);
304 return AE_OK; 282 return AE_OK;
305 } 283 }
284 if (acpi_bus_get_device(handle, &adev))
285 return AE_OK;
306 286
307 device = (adr >> 16) & 0xffff; 287 device = (adr >> 16) & 0xffff;
308 function = adr & 0xffff; 288 function = adr & 0xffff;
309 289
310 mutex_lock(&acpiphp_context_lock); 290 acpi_lock_hp_context();
311 context = acpiphp_init_context(handle); 291 context = acpiphp_init_context(adev);
312 if (!context) { 292 if (!context) {
313 mutex_unlock(&acpiphp_context_lock); 293 acpi_unlock_hp_context();
314 acpi_handle_err(handle, "No hotplug context\n"); 294 acpi_handle_err(handle, "No hotplug context\n");
315 return AE_NOT_EXIST; 295 return AE_NOT_EXIST;
316 } 296 }
317 newfunc = &context->func; 297 newfunc = &context->func;
318 newfunc->function = function; 298 newfunc->function = function;
319 newfunc->parent = bridge; 299 newfunc->parent = bridge;
320 mutex_unlock(&acpiphp_context_lock); 300 acpi_unlock_hp_context();
321 301
322 if (acpi_has_method(handle, "_EJ0")) 302 /*
303 * If this is a dock device, its _EJ0 should be executed by the dock
304 * notify handler after calling _DCK.
305 */
306 if (!is_dock_device(adev) && acpi_has_method(handle, "_EJ0"))
323 newfunc->flags = FUNC_HAS_EJ0; 307 newfunc->flags = FUNC_HAS_EJ0;
324 308
325 if (acpi_has_method(handle, "_STA")) 309 if (acpi_has_method(handle, "_STA"))
326 newfunc->flags |= FUNC_HAS_STA; 310 newfunc->flags |= FUNC_HAS_STA;
327 311
328 if (acpi_has_method(handle, "_DCK"))
329 newfunc->flags |= FUNC_HAS_DCK;
330
331 /* search for objects that share the same slot */ 312 /* search for objects that share the same slot */
332 list_for_each_entry(slot, &bridge->slots, node) 313 list_for_each_entry(slot, &bridge->slots, node)
333 if (slot->device == device) 314 if (slot->device == device)
@@ -335,19 +316,26 @@ static acpi_status register_slot(acpi_handle handle, u32 lvl, void *data,
335 316
336 slot = kzalloc(sizeof(struct acpiphp_slot), GFP_KERNEL); 317 slot = kzalloc(sizeof(struct acpiphp_slot), GFP_KERNEL);
337 if (!slot) { 318 if (!slot) {
338 status = AE_NO_MEMORY; 319 acpi_lock_hp_context();
339 goto err; 320 acpiphp_put_context(context);
321 acpi_unlock_hp_context();
322 return AE_NO_MEMORY;
340 } 323 }
341 324
342 slot->bus = bridge->pci_bus; 325 slot->bus = bridge->pci_bus;
343 slot->device = device; 326 slot->device = device;
344 INIT_LIST_HEAD(&slot->funcs); 327 INIT_LIST_HEAD(&slot->funcs);
345 mutex_init(&slot->crit_sect);
346 328
347 list_add_tail(&slot->node, &bridge->slots); 329 list_add_tail(&slot->node, &bridge->slots);
348 330
349 /* Register slots for ejectable functions only. */ 331 /*
350 if (acpi_pci_check_ejectable(pbus, handle) || is_dock_device(handle)) { 332 * Expose slots to user space for functions that have _EJ0 or _RMV or
333 * are located in dock stations. Do not expose them for devices handled
334 * by the native PCIe hotplug (PCIeHP), becuase that code is supposed to
335 * expose slots to user space in those cases.
336 */
337 if ((acpi_pci_check_ejectable(pbus, handle) || is_dock_device(adev))
338 && !(pdev && device_is_managed_by_native_pciehp(pdev))) {
351 unsigned long long sun; 339 unsigned long long sun;
352 int retval; 340 int retval;
353 341
@@ -381,44 +369,16 @@ static acpi_status register_slot(acpi_handle handle, u32 lvl, void *data,
381 &val, 60*1000)) 369 &val, 60*1000))
382 slot->flags |= SLOT_ENABLED; 370 slot->flags |= SLOT_ENABLED;
383 371
384 if (is_dock_device(handle)) {
385 /* we don't want to call this device's _EJ0
386 * because we want the dock notify handler
387 * to call it after it calls _DCK
388 */
389 newfunc->flags &= ~FUNC_HAS_EJ0;
390 if (register_hotplug_dock_device(handle,
391 &acpiphp_dock_ops, context,
392 acpiphp_dock_init, acpiphp_dock_release))
393 pr_debug("failed to register dock device\n");
394 }
395
396 /* install notify handler */
397 if (!(newfunc->flags & FUNC_HAS_DCK)) {
398 status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
399 handle_hotplug_event,
400 context);
401 if (ACPI_FAILURE(status))
402 acpi_handle_err(handle,
403 "failed to install notify handler\n");
404 }
405
406 return AE_OK; 372 return AE_OK;
407
408 err:
409 mutex_lock(&acpiphp_context_lock);
410 acpiphp_put_context(context);
411 mutex_unlock(&acpiphp_context_lock);
412 return status;
413} 373}
414 374
415static struct acpiphp_bridge *acpiphp_handle_to_bridge(acpi_handle handle) 375static struct acpiphp_bridge *acpiphp_dev_to_bridge(struct acpi_device *adev)
416{ 376{
417 struct acpiphp_context *context; 377 struct acpiphp_context *context;
418 struct acpiphp_bridge *bridge = NULL; 378 struct acpiphp_bridge *bridge = NULL;
419 379
420 mutex_lock(&acpiphp_context_lock); 380 acpi_lock_hp_context();
421 context = acpiphp_get_context(handle); 381 context = acpiphp_get_context(adev);
422 if (context) { 382 if (context) {
423 bridge = context->bridge; 383 bridge = context->bridge;
424 if (bridge) 384 if (bridge)
@@ -426,7 +386,7 @@ static struct acpiphp_bridge *acpiphp_handle_to_bridge(acpi_handle handle)
426 386
427 acpiphp_put_context(context); 387 acpiphp_put_context(context);
428 } 388 }
429 mutex_unlock(&acpiphp_context_lock); 389 acpi_unlock_hp_context();
430 return bridge; 390 return bridge;
431} 391}
432 392
@@ -434,22 +394,15 @@ static void cleanup_bridge(struct acpiphp_bridge *bridge)
434{ 394{
435 struct acpiphp_slot *slot; 395 struct acpiphp_slot *slot;
436 struct acpiphp_func *func; 396 struct acpiphp_func *func;
437 acpi_status status;
438 397
439 list_for_each_entry(slot, &bridge->slots, node) { 398 list_for_each_entry(slot, &bridge->slots, node) {
440 list_for_each_entry(func, &slot->funcs, sibling) { 399 list_for_each_entry(func, &slot->funcs, sibling) {
441 acpi_handle handle = func_to_handle(func); 400 struct acpi_device *adev = func_to_acpi_device(func);
442
443 if (is_dock_device(handle))
444 unregister_hotplug_dock_device(handle);
445 401
446 if (!(func->flags & FUNC_HAS_DCK)) { 402 acpi_lock_hp_context();
447 status = acpi_remove_notify_handler(handle, 403 adev->hp->notify = NULL;
448 ACPI_SYSTEM_NOTIFY, 404 adev->hp->fixup = NULL;
449 handle_hotplug_event); 405 acpi_unlock_hp_context();
450 if (ACPI_FAILURE(status))
451 pr_err("failed to remove notify handler\n");
452 }
453 } 406 }
454 slot->flags |= SLOT_IS_GOING_AWAY; 407 slot->flags |= SLOT_IS_GOING_AWAY;
455 if (slot->slot) 408 if (slot->slot)
@@ -460,9 +413,9 @@ static void cleanup_bridge(struct acpiphp_bridge *bridge)
460 list_del(&bridge->list); 413 list_del(&bridge->list);
461 mutex_unlock(&bridge_mutex); 414 mutex_unlock(&bridge_mutex);
462 415
463 mutex_lock(&acpiphp_context_lock); 416 acpi_lock_hp_context();
464 bridge->is_going_away = true; 417 bridge->is_going_away = true;
465 mutex_unlock(&acpiphp_context_lock); 418 acpi_unlock_hp_context();
466} 419}
467 420
468/** 421/**
@@ -492,33 +445,6 @@ static unsigned char acpiphp_max_busnr(struct pci_bus *bus)
492 return max; 445 return max;
493} 446}
494 447
495/**
496 * acpiphp_bus_trim - Trim device objects in an ACPI namespace subtree.
497 * @handle: ACPI device object handle to start from.
498 */
499static void acpiphp_bus_trim(acpi_handle handle)
500{
501 struct acpi_device *adev = NULL;
502
503 acpi_bus_get_device(handle, &adev);
504 if (adev)
505 acpi_bus_trim(adev);
506}
507
508/**
509 * acpiphp_bus_add - Scan ACPI namespace subtree.
510 * @handle: ACPI object handle to start the scan from.
511 */
512static void acpiphp_bus_add(acpi_handle handle)
513{
514 struct acpi_device *adev = NULL;
515
516 acpi_bus_scan(handle);
517 acpi_bus_get_device(handle, &adev);
518 if (acpi_device_enumerated(adev))
519 acpi_device_set_power(adev, ACPI_STATE_D0);
520}
521
522static void acpiphp_set_acpi_region(struct acpiphp_slot *slot) 448static void acpiphp_set_acpi_region(struct acpiphp_slot *slot)
523{ 449{
524 struct acpiphp_func *func; 450 struct acpiphp_func *func;
@@ -558,9 +484,13 @@ static int acpiphp_rescan_slot(struct acpiphp_slot *slot)
558{ 484{
559 struct acpiphp_func *func; 485 struct acpiphp_func *func;
560 486
561 list_for_each_entry(func, &slot->funcs, sibling) 487 list_for_each_entry(func, &slot->funcs, sibling) {
562 acpiphp_bus_add(func_to_handle(func)); 488 struct acpi_device *adev = func_to_acpi_device(func);
563 489
490 acpi_bus_scan(adev->handle);
491 if (acpi_device_enumerated(adev))
492 acpi_device_set_power(adev, ACPI_STATE_D0);
493 }
564 return pci_scan_slot(slot->bus, PCI_DEVFN(slot->device, 0)); 494 return pci_scan_slot(slot->bus, PCI_DEVFN(slot->device, 0));
565} 495}
566 496
@@ -625,32 +555,15 @@ static void __ref enable_slot(struct acpiphp_slot *slot)
625 } 555 }
626} 556}
627 557
628/* return first device in slot, acquiring a reference on it */
629static struct pci_dev *dev_in_slot(struct acpiphp_slot *slot)
630{
631 struct pci_bus *bus = slot->bus;
632 struct pci_dev *dev;
633 struct pci_dev *ret = NULL;
634
635 down_read(&pci_bus_sem);
636 list_for_each_entry(dev, &bus->devices, bus_list)
637 if (PCI_SLOT(dev->devfn) == slot->device) {
638 ret = pci_dev_get(dev);
639 break;
640 }
641 up_read(&pci_bus_sem);
642
643 return ret;
644}
645
646/** 558/**
647 * disable_slot - disable a slot 559 * disable_slot - disable a slot
648 * @slot: ACPI PHP slot 560 * @slot: ACPI PHP slot
649 */ 561 */
650static void disable_slot(struct acpiphp_slot *slot) 562static void disable_slot(struct acpiphp_slot *slot)
651{ 563{
564 struct pci_bus *bus = slot->bus;
565 struct pci_dev *dev, *prev;
652 struct acpiphp_func *func; 566 struct acpiphp_func *func;
653 struct pci_dev *pdev;
654 567
655 /* 568 /*
656 * enable_slot() enumerates all functions in this device via 569 * enable_slot() enumerates all functions in this device via
@@ -658,22 +571,18 @@ static void disable_slot(struct acpiphp_slot *slot)
658 * methods (_EJ0, etc.) or not. Therefore, we remove all functions 571 * methods (_EJ0, etc.) or not. Therefore, we remove all functions
659 * here. 572 * here.
660 */ 573 */
661 while ((pdev = dev_in_slot(slot))) { 574 list_for_each_entry_safe_reverse(dev, prev, &bus->devices, bus_list)
662 pci_stop_and_remove_bus_device(pdev); 575 if (PCI_SLOT(dev->devfn) == slot->device)
663 pci_dev_put(pdev); 576 pci_stop_and_remove_bus_device(dev);
664 }
665 577
666 list_for_each_entry(func, &slot->funcs, sibling) 578 list_for_each_entry(func, &slot->funcs, sibling)
667 acpiphp_bus_trim(func_to_handle(func)); 579 acpi_bus_trim(func_to_acpi_device(func));
668 580
669 slot->flags &= (~SLOT_ENABLED); 581 slot->flags &= (~SLOT_ENABLED);
670} 582}
671 583
672static bool acpiphp_no_hotplug(acpi_handle handle) 584static bool acpiphp_no_hotplug(struct acpi_device *adev)
673{ 585{
674 struct acpi_device *adev = NULL;
675
676 acpi_bus_get_device(handle, &adev);
677 return adev && adev->flags.no_hotplug; 586 return adev && adev->flags.no_hotplug;
678} 587}
679 588
@@ -682,7 +591,7 @@ static bool slot_no_hotplug(struct acpiphp_slot *slot)
682 struct acpiphp_func *func; 591 struct acpiphp_func *func;
683 592
684 list_for_each_entry(func, &slot->funcs, sibling) 593 list_for_each_entry(func, &slot->funcs, sibling)
685 if (acpiphp_no_hotplug(func_to_handle(func))) 594 if (acpiphp_no_hotplug(func_to_acpi_device(func)))
686 return true; 595 return true;
687 596
688 return false; 597 return false;
@@ -747,28 +656,25 @@ static inline bool device_status_valid(unsigned int sta)
747 */ 656 */
748static void trim_stale_devices(struct pci_dev *dev) 657static void trim_stale_devices(struct pci_dev *dev)
749{ 658{
750 acpi_handle handle = ACPI_HANDLE(&dev->dev); 659 struct acpi_device *adev = ACPI_COMPANION(&dev->dev);
751 struct pci_bus *bus = dev->subordinate; 660 struct pci_bus *bus = dev->subordinate;
752 bool alive = false; 661 bool alive = false;
753 662
754 if (handle) { 663 if (adev) {
755 acpi_status status; 664 acpi_status status;
756 unsigned long long sta; 665 unsigned long long sta;
757 666
758 status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); 667 status = acpi_evaluate_integer(adev->handle, "_STA", NULL, &sta);
759 alive = (ACPI_SUCCESS(status) && device_status_valid(sta)) 668 alive = (ACPI_SUCCESS(status) && device_status_valid(sta))
760 || acpiphp_no_hotplug(handle); 669 || acpiphp_no_hotplug(adev);
761 } 670 }
762 if (!alive) { 671 if (!alive)
763 u32 v; 672 alive = pci_device_is_present(dev);
764 673
765 /* Check if the device responds. */
766 alive = pci_bus_read_dev_vendor_id(dev->bus, dev->devfn, &v, 0);
767 }
768 if (!alive) { 674 if (!alive) {
769 pci_stop_and_remove_bus_device(dev); 675 pci_stop_and_remove_bus_device(dev);
770 if (handle) 676 if (adev)
771 acpiphp_bus_trim(handle); 677 acpi_bus_trim(adev);
772 } else if (bus) { 678 } else if (bus) {
773 struct pci_dev *child, *tmp; 679 struct pci_dev *child, *tmp;
774 680
@@ -800,7 +706,6 @@ static void acpiphp_check_bridge(struct acpiphp_bridge *bridge)
800 struct pci_bus *bus = slot->bus; 706 struct pci_bus *bus = slot->bus;
801 struct pci_dev *dev, *tmp; 707 struct pci_dev *dev, *tmp;
802 708
803 mutex_lock(&slot->crit_sect);
804 if (slot_no_hotplug(slot)) { 709 if (slot_no_hotplug(slot)) {
805 ; /* do nothing */ 710 ; /* do nothing */
806 } else if (device_status_valid(get_slot_status(slot))) { 711 } else if (device_status_valid(get_slot_status(slot))) {
@@ -815,7 +720,6 @@ static void acpiphp_check_bridge(struct acpiphp_bridge *bridge)
815 } else { 720 } else {
816 disable_slot(slot); 721 disable_slot(slot);
817 } 722 }
818 mutex_unlock(&slot->crit_sect);
819 } 723 }
820} 724}
821 725
@@ -855,11 +759,11 @@ static void acpiphp_sanitize_bus(struct pci_bus *bus)
855 * ACPI event handlers 759 * ACPI event handlers
856 */ 760 */
857 761
858void acpiphp_check_host_bridge(acpi_handle handle) 762void acpiphp_check_host_bridge(struct acpi_device *adev)
859{ 763{
860 struct acpiphp_bridge *bridge; 764 struct acpiphp_bridge *bridge;
861 765
862 bridge = acpiphp_handle_to_bridge(handle); 766 bridge = acpiphp_dev_to_bridge(adev);
863 if (bridge) { 767 if (bridge) {
864 pci_lock_rescan_remove(); 768 pci_lock_rescan_remove();
865 769
@@ -872,73 +776,52 @@ void acpiphp_check_host_bridge(acpi_handle handle)
872 776
873static int acpiphp_disable_and_eject_slot(struct acpiphp_slot *slot); 777static int acpiphp_disable_and_eject_slot(struct acpiphp_slot *slot);
874 778
875static void hotplug_event(acpi_handle handle, u32 type, void *data) 779static void hotplug_event(u32 type, struct acpiphp_context *context)
876{ 780{
877 struct acpiphp_context *context = data; 781 acpi_handle handle = context->hp.self->handle;
878 struct acpiphp_func *func = &context->func; 782 struct acpiphp_func *func = &context->func;
783 struct acpiphp_slot *slot = func->slot;
879 struct acpiphp_bridge *bridge; 784 struct acpiphp_bridge *bridge;
880 char objname[64];
881 struct acpi_buffer buffer = { .length = sizeof(objname),
882 .pointer = objname };
883 785
884 mutex_lock(&acpiphp_context_lock); 786 acpi_lock_hp_context();
885 bridge = context->bridge; 787 bridge = context->bridge;
886 if (bridge) 788 if (bridge)
887 get_bridge(bridge); 789 get_bridge(bridge);
888 790
889 mutex_unlock(&acpiphp_context_lock); 791 acpi_unlock_hp_context();
890 792
891 pci_lock_rescan_remove(); 793 pci_lock_rescan_remove();
892 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
893 794
894 switch (type) { 795 switch (type) {
895 case ACPI_NOTIFY_BUS_CHECK: 796 case ACPI_NOTIFY_BUS_CHECK:
896 /* bus re-enumerate */ 797 /* bus re-enumerate */
897 pr_debug("%s: Bus check notify on %s\n", __func__, objname); 798 acpi_handle_debug(handle, "Bus check in %s()\n", __func__);
898 pr_debug("%s: re-enumerating slots under %s\n", 799 if (bridge)
899 __func__, objname);
900 if (bridge) {
901 acpiphp_check_bridge(bridge); 800 acpiphp_check_bridge(bridge);
902 } else { 801 else if (!(slot->flags & SLOT_IS_GOING_AWAY))
903 struct acpiphp_slot *slot = func->slot;
904
905 if (slot->flags & SLOT_IS_GOING_AWAY)
906 break;
907
908 mutex_lock(&slot->crit_sect);
909 enable_slot(slot); 802 enable_slot(slot);
910 mutex_unlock(&slot->crit_sect); 803
911 }
912 break; 804 break;
913 805
914 case ACPI_NOTIFY_DEVICE_CHECK: 806 case ACPI_NOTIFY_DEVICE_CHECK:
915 /* device check */ 807 /* device check */
916 pr_debug("%s: Device check notify on %s\n", __func__, objname); 808 acpi_handle_debug(handle, "Device check in %s()\n", __func__);
917 if (bridge) { 809 if (bridge) {
918 acpiphp_check_bridge(bridge); 810 acpiphp_check_bridge(bridge);
919 } else { 811 } else if (!(slot->flags & SLOT_IS_GOING_AWAY)) {
920 struct acpiphp_slot *slot = func->slot;
921 int ret;
922
923 if (slot->flags & SLOT_IS_GOING_AWAY)
924 break;
925
926 /* 812 /*
927 * Check if anything has changed in the slot and rescan 813 * Check if anything has changed in the slot and rescan
928 * from the parent if that's the case. 814 * from the parent if that's the case.
929 */ 815 */
930 mutex_lock(&slot->crit_sect); 816 if (acpiphp_rescan_slot(slot))
931 ret = acpiphp_rescan_slot(slot);
932 mutex_unlock(&slot->crit_sect);
933 if (ret)
934 acpiphp_check_bridge(func->parent); 817 acpiphp_check_bridge(func->parent);
935 } 818 }
936 break; 819 break;
937 820
938 case ACPI_NOTIFY_EJECT_REQUEST: 821 case ACPI_NOTIFY_EJECT_REQUEST:
939 /* request device eject */ 822 /* request device eject */
940 pr_debug("%s: Device eject notify on %s\n", __func__, objname); 823 acpi_handle_debug(handle, "Eject request in %s()\n", __func__);
941 acpiphp_disable_and_eject_slot(func->slot); 824 acpiphp_disable_and_eject_slot(slot);
942 break; 825 break;
943 } 826 }
944 827
@@ -947,106 +830,41 @@ static void hotplug_event(acpi_handle handle, u32 type, void *data)
947 put_bridge(bridge); 830 put_bridge(bridge);
948} 831}
949 832
950static void hotplug_event_work(void *data, u32 type) 833static int acpiphp_hotplug_notify(struct acpi_device *adev, u32 type)
951{ 834{
952 struct acpiphp_context *context = data; 835 struct acpiphp_context *context;
953 acpi_handle handle = context->handle;
954
955 acpi_scan_lock_acquire();
956 836
957 hotplug_event(handle, type, context); 837 context = acpiphp_grab_context(adev);
838 if (!context)
839 return -ENODATA;
958 840
959 acpi_scan_lock_release(); 841 hotplug_event(type, context);
960 acpi_evaluate_hotplug_ost(handle, type, ACPI_OST_SC_SUCCESS, NULL); 842 acpiphp_let_context_go(context);
961 put_bridge(context->func.parent); 843 return 0;
962} 844}
963 845
964/** 846/**
965 * handle_hotplug_event - handle ACPI hotplug event 847 * acpiphp_enumerate_slots - Enumerate PCI slots for a given bus.
966 * @handle: Notify()'ed acpi_handle 848 * @bus: PCI bus to enumerate the slots for.
967 * @type: Notify code
968 * @data: pointer to acpiphp_context structure
969 * 849 *
970 * Handles ACPI event notification on slots. 850 * A "slot" is an object associated with a PCI device number. All functions
971 */ 851 * (PCI devices) with the same bus and device number belong to the same slot.
972static void handle_hotplug_event(acpi_handle handle, u32 type, void *data)
973{
974 struct acpiphp_context *context;
975 u32 ost_code = ACPI_OST_SC_SUCCESS;
976 acpi_status status;
977
978 switch (type) {
979 case ACPI_NOTIFY_BUS_CHECK:
980 case ACPI_NOTIFY_DEVICE_CHECK:
981 break;
982 case ACPI_NOTIFY_EJECT_REQUEST:
983 ost_code = ACPI_OST_SC_EJECT_IN_PROGRESS;
984 acpi_evaluate_hotplug_ost(handle, type, ost_code, NULL);
985 break;
986
987 case ACPI_NOTIFY_DEVICE_WAKE:
988 return;
989
990 case ACPI_NOTIFY_FREQUENCY_MISMATCH:
991 acpi_handle_err(handle, "Device cannot be configured due "
992 "to a frequency mismatch\n");
993 goto out;
994
995 case ACPI_NOTIFY_BUS_MODE_MISMATCH:
996 acpi_handle_err(handle, "Device cannot be configured due "
997 "to a bus mode mismatch\n");
998 goto out;
999
1000 case ACPI_NOTIFY_POWER_FAULT:
1001 acpi_handle_err(handle, "Device has suffered a power fault\n");
1002 goto out;
1003
1004 default:
1005 acpi_handle_warn(handle, "Unsupported event type 0x%x\n", type);
1006 ost_code = ACPI_OST_SC_UNRECOGNIZED_NOTIFY;
1007 goto out;
1008 }
1009
1010 mutex_lock(&acpiphp_context_lock);
1011 context = acpiphp_get_context(handle);
1012 if (!context || WARN_ON(context->handle != handle)
1013 || context->func.parent->is_going_away)
1014 goto err_out;
1015
1016 get_bridge(context->func.parent);
1017 acpiphp_put_context(context);
1018 status = acpi_hotplug_execute(hotplug_event_work, context, type);
1019 if (ACPI_SUCCESS(status)) {
1020 mutex_unlock(&acpiphp_context_lock);
1021 return;
1022 }
1023 put_bridge(context->func.parent);
1024
1025 err_out:
1026 mutex_unlock(&acpiphp_context_lock);
1027 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE;
1028
1029 out:
1030 acpi_evaluate_hotplug_ost(handle, type, ost_code, NULL);
1031}
1032
1033/*
1034 * Create hotplug slots for the PCI bus.
1035 * It should always return 0 to avoid skipping following notifiers.
1036 */ 852 */
1037void acpiphp_enumerate_slots(struct pci_bus *bus) 853void acpiphp_enumerate_slots(struct pci_bus *bus)
1038{ 854{
1039 struct acpiphp_bridge *bridge; 855 struct acpiphp_bridge *bridge;
856 struct acpi_device *adev;
1040 acpi_handle handle; 857 acpi_handle handle;
1041 acpi_status status; 858 acpi_status status;
1042 859
1043 if (acpiphp_disabled) 860 if (acpiphp_disabled)
1044 return; 861 return;
1045 862
1046 handle = ACPI_HANDLE(bus->bridge); 863 adev = ACPI_COMPANION(bus->bridge);
1047 if (!handle) 864 if (!adev)
1048 return; 865 return;
1049 866
867 handle = adev->handle;
1050 bridge = kzalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL); 868 bridge = kzalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL);
1051 if (!bridge) { 869 if (!bridge) {
1052 acpi_handle_err(handle, "No memory for bridge object\n"); 870 acpi_handle_err(handle, "No memory for bridge object\n");
@@ -1074,10 +892,10 @@ void acpiphp_enumerate_slots(struct pci_bus *bus)
1074 * parent is going to be handled by pciehp, in which case this 892 * parent is going to be handled by pciehp, in which case this
1075 * bridge is not interesting to us either. 893 * bridge is not interesting to us either.
1076 */ 894 */
1077 mutex_lock(&acpiphp_context_lock); 895 acpi_lock_hp_context();
1078 context = acpiphp_get_context(handle); 896 context = acpiphp_get_context(adev);
1079 if (!context) { 897 if (!context) {
1080 mutex_unlock(&acpiphp_context_lock); 898 acpi_unlock_hp_context();
1081 put_device(&bus->dev); 899 put_device(&bus->dev);
1082 pci_dev_put(bridge->pci_dev); 900 pci_dev_put(bridge->pci_dev);
1083 kfree(bridge); 901 kfree(bridge);
@@ -1087,17 +905,17 @@ void acpiphp_enumerate_slots(struct pci_bus *bus)
1087 context->bridge = bridge; 905 context->bridge = bridge;
1088 /* Get a reference to the parent bridge. */ 906 /* Get a reference to the parent bridge. */
1089 get_bridge(context->func.parent); 907 get_bridge(context->func.parent);
1090 mutex_unlock(&acpiphp_context_lock); 908 acpi_unlock_hp_context();
1091 } 909 }
1092 910
1093 /* must be added to the list prior to calling register_slot */ 911 /* Must be added to the list prior to calling acpiphp_add_context(). */
1094 mutex_lock(&bridge_mutex); 912 mutex_lock(&bridge_mutex);
1095 list_add(&bridge->list, &bridge_list); 913 list_add(&bridge->list, &bridge_list);
1096 mutex_unlock(&bridge_mutex); 914 mutex_unlock(&bridge_mutex);
1097 915
1098 /* register all slot objects under this bridge */ 916 /* register all slot objects under this bridge */
1099 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, 1, 917 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, 1,
1100 register_slot, NULL, bridge, NULL); 918 acpiphp_add_context, NULL, bridge, NULL);
1101 if (ACPI_FAILURE(status)) { 919 if (ACPI_FAILURE(status)) {
1102 acpi_handle_err(handle, "failed to register slots\n"); 920 acpi_handle_err(handle, "failed to register slots\n");
1103 cleanup_bridge(bridge); 921 cleanup_bridge(bridge);
@@ -1105,7 +923,10 @@ void acpiphp_enumerate_slots(struct pci_bus *bus)
1105 } 923 }
1106} 924}
1107 925
1108/* Destroy hotplug slots associated with the PCI bus */ 926/**
927 * acpiphp_remove_slots - Remove slot objects associated with a given bus.
928 * @bus: PCI bus to remove the slot objects for.
929 */
1109void acpiphp_remove_slots(struct pci_bus *bus) 930void acpiphp_remove_slots(struct pci_bus *bus)
1110{ 931{
1111 struct acpiphp_bridge *bridge; 932 struct acpiphp_bridge *bridge;
@@ -1136,13 +957,10 @@ int acpiphp_enable_slot(struct acpiphp_slot *slot)
1136 if (slot->flags & SLOT_IS_GOING_AWAY) 957 if (slot->flags & SLOT_IS_GOING_AWAY)
1137 return -ENODEV; 958 return -ENODEV;
1138 959
1139 mutex_lock(&slot->crit_sect);
1140 /* configure all functions */ 960 /* configure all functions */
1141 if (!(slot->flags & SLOT_ENABLED)) 961 if (!(slot->flags & SLOT_ENABLED))
1142 enable_slot(slot); 962 enable_slot(slot);
1143 963
1144 mutex_unlock(&slot->crit_sect);
1145
1146 pci_unlock_rescan_remove(); 964 pci_unlock_rescan_remove();
1147 return 0; 965 return 0;
1148} 966}
@@ -1158,8 +976,6 @@ static int acpiphp_disable_and_eject_slot(struct acpiphp_slot *slot)
1158 if (slot->flags & SLOT_IS_GOING_AWAY) 976 if (slot->flags & SLOT_IS_GOING_AWAY)
1159 return -ENODEV; 977 return -ENODEV;
1160 978
1161 mutex_lock(&slot->crit_sect);
1162
1163 /* unconfigure all functions */ 979 /* unconfigure all functions */
1164 disable_slot(slot); 980 disable_slot(slot);
1165 981
@@ -1173,7 +989,6 @@ static int acpiphp_disable_and_eject_slot(struct acpiphp_slot *slot)
1173 break; 989 break;
1174 } 990 }
1175 991
1176 mutex_unlock(&slot->crit_sect);
1177 return 0; 992 return 0;
1178} 993}
1179 994
@@ -1181,9 +996,15 @@ int acpiphp_disable_slot(struct acpiphp_slot *slot)
1181{ 996{
1182 int ret; 997 int ret;
1183 998
999 /*
1000 * Acquire acpi_scan_lock to ensure that the execution of _EJ0 in
1001 * acpiphp_disable_and_eject_slot() will be synchronized properly.
1002 */
1003 acpi_scan_lock_acquire();
1184 pci_lock_rescan_remove(); 1004 pci_lock_rescan_remove();
1185 ret = acpiphp_disable_and_eject_slot(slot); 1005 ret = acpiphp_disable_and_eject_slot(slot);
1186 pci_unlock_rescan_remove(); 1006 pci_unlock_rescan_remove();
1007 acpi_scan_lock_release();
1187 return ret; 1008 return ret;
1188} 1009}
1189 1010
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 25f0bc659164..d911e0c1f359 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -616,15 +616,11 @@ static int pci_pm_prepare(struct device *dev)
616 int error = 0; 616 int error = 0;
617 617
618 /* 618 /*
619 * PCI devices suspended at run time need to be resumed at this 619 * Devices having power.ignore_children set may still be necessary for
620 * point, because in general it is necessary to reconfigure them for 620 * suspending their children in the next phase of device suspend.
621 * system suspend. Namely, if the device is supposed to wake up the
622 * system from the sleep state, we may need to reconfigure it for this
623 * purpose. In turn, if the device is not supposed to wake up the
624 * system from the sleep state, we'll have to prevent it from signaling
625 * wake-up.
626 */ 621 */
627 pm_runtime_resume(dev); 622 if (dev->power.ignore_children)
623 pm_runtime_resume(dev);
628 624
629 if (drv && drv->pm && drv->pm->prepare) 625 if (drv && drv->pm && drv->pm->prepare)
630 error = drv->pm->prepare(dev); 626 error = drv->pm->prepare(dev);
@@ -654,6 +650,16 @@ static int pci_pm_suspend(struct device *dev)
654 goto Fixup; 650 goto Fixup;
655 } 651 }
656 652
653 /*
654 * PCI devices suspended at run time need to be resumed at this point,
655 * because in general it is necessary to reconfigure them for system
656 * suspend. Namely, if the device is supposed to wake up the system
657 * from the sleep state, we may need to reconfigure it for this purpose.
658 * In turn, if the device is not supposed to wake up the system from the
659 * sleep state, we'll have to prevent it from signaling wake-up.
660 */
661 pm_runtime_resume(dev);
662
657 pci_dev->state_saved = false; 663 pci_dev->state_saved = false;
658 if (pm->suspend) { 664 if (pm->suspend) {
659 pci_power_t prev = pci_dev->current_state; 665 pci_power_t prev = pci_dev->current_state;
@@ -808,6 +814,14 @@ static int pci_pm_freeze(struct device *dev)
808 return 0; 814 return 0;
809 } 815 }
810 816
817 /*
818 * This used to be done in pci_pm_prepare() for all devices and some
819 * drivers may depend on it, so do it here. Ideally, runtime-suspended
820 * devices should not be touched during freeze/thaw transitions,
821 * however.
822 */
823 pm_runtime_resume(dev);
824
811 pci_dev->state_saved = false; 825 pci_dev->state_saved = false;
812 if (pm->freeze) { 826 if (pm->freeze) {
813 int error; 827 int error;
@@ -915,6 +929,9 @@ static int pci_pm_poweroff(struct device *dev)
915 goto Fixup; 929 goto Fixup;
916 } 930 }
917 931
932 /* The reason to do that is the same as in pci_pm_suspend(). */
933 pm_runtime_resume(dev);
934
918 pci_dev->state_saved = false; 935 pci_dev->state_saved = false;
919 if (pm->poweroff) { 936 if (pm->poweroff) {
920 int error; 937 int error;
diff --git a/drivers/pcmcia/sa11xx_base.c b/drivers/pcmcia/sa11xx_base.c
index 6eecd7cddf57..54d3089d157b 100644
--- a/drivers/pcmcia/sa11xx_base.c
+++ b/drivers/pcmcia/sa11xx_base.c
@@ -125,9 +125,6 @@ sa1100_pcmcia_frequency_change(struct soc_pcmcia_socket *skt,
125 if (freqs->new < freqs->old) 125 if (freqs->new < freqs->old)
126 sa1100_pcmcia_set_mecr(skt, freqs->new); 126 sa1100_pcmcia_set_mecr(skt, freqs->new);
127 break; 127 break;
128 case CPUFREQ_RESUMECHANGE:
129 sa1100_pcmcia_set_mecr(skt, freqs->new);
130 break;
131 } 128 }
132 129
133 return 0; 130 return 0;
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index 5ae65c11d544..5f67843c7fb7 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -27,8 +27,6 @@ config ACER_WMI
27 depends on ACPI_WMI 27 depends on ACPI_WMI
28 select INPUT_SPARSEKMAP 28 select INPUT_SPARSEKMAP
29 # Acer WMI depends on ACPI_VIDEO when ACPI is enabled 29 # Acer WMI depends on ACPI_VIDEO when ACPI is enabled
30 # but for select to work, need to select ACPI_VIDEO's dependencies, ick
31 select VIDEO_OUTPUT_CONTROL if ACPI
32 select ACPI_VIDEO if ACPI 30 select ACPI_VIDEO if ACPI
33 ---help--- 31 ---help---
34 This is a driver for newer Acer (and Wistron) laptops. It adds 32 This is a driver for newer Acer (and Wistron) laptops. It adds
diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
index be02bcc346d3..e6f336270c21 100644
--- a/drivers/platform/x86/fujitsu-laptop.c
+++ b/drivers/platform/x86/fujitsu-laptop.c
@@ -66,7 +66,6 @@
66#include <linux/backlight.h> 66#include <linux/backlight.h>
67#include <linux/input.h> 67#include <linux/input.h>
68#include <linux/kfifo.h> 68#include <linux/kfifo.h>
69#include <linux/video_output.h>
70#include <linux/platform_device.h> 69#include <linux/platform_device.h>
71#include <linux/slab.h> 70#include <linux/slab.h>
72#if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE) 71#if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE)
diff --git a/drivers/powercap/intel_rapl.c b/drivers/powercap/intel_rapl.c
index 3c6768378a94..61b51e17d932 100644
--- a/drivers/powercap/intel_rapl.c
+++ b/drivers/powercap/intel_rapl.c
@@ -834,7 +834,7 @@ static int rapl_write_data_raw(struct rapl_domain *rd,
834} 834}
835 835
836static const struct x86_cpu_id energy_unit_quirk_ids[] = { 836static const struct x86_cpu_id energy_unit_quirk_ids[] = {
837 { X86_VENDOR_INTEL, 6, 0x37},/* VLV */ 837 { X86_VENDOR_INTEL, 6, 0x37},/* Valleyview */
838 {} 838 {}
839}; 839};
840 840
@@ -947,11 +947,11 @@ static void package_power_limit_irq_restore(int package_id)
947} 947}
948 948
949static const struct x86_cpu_id rapl_ids[] = { 949static const struct x86_cpu_id rapl_ids[] = {
950 { X86_VENDOR_INTEL, 6, 0x2a},/* SNB */ 950 { X86_VENDOR_INTEL, 6, 0x2a},/* Sandy Bridge */
951 { X86_VENDOR_INTEL, 6, 0x2d},/* SNB EP */ 951 { X86_VENDOR_INTEL, 6, 0x2d},/* Sandy Bridge EP */
952 { X86_VENDOR_INTEL, 6, 0x37},/* VLV */ 952 { X86_VENDOR_INTEL, 6, 0x37},/* Valleyview */
953 { X86_VENDOR_INTEL, 6, 0x3a},/* IVB */ 953 { X86_VENDOR_INTEL, 6, 0x3a},/* Ivy Bridge */
954 { X86_VENDOR_INTEL, 6, 0x45},/* HSW */ 954 { X86_VENDOR_INTEL, 6, 0x45},/* Haswell */
955 /* TODO: Add more CPU IDs after testing */ 955 /* TODO: Add more CPU IDs after testing */
956 {} 956 {}
957}; 957};
@@ -1147,6 +1147,11 @@ static int rapl_check_domain(int cpu, int domain)
1147 if (rdmsrl_safe_on_cpu(cpu, msr, &val1)) 1147 if (rdmsrl_safe_on_cpu(cpu, msr, &val1))
1148 return -ENODEV; 1148 return -ENODEV;
1149 1149
1150 /* PP1/uncore/graphics domain may not be active at the time of
1151 * driver loading. So skip further checks.
1152 */
1153 if (domain == RAPL_DOMAIN_PP1)
1154 return 0;
1150 /* energy counters roll slowly on some domains */ 1155 /* energy counters roll slowly on some domains */
1151 while (++retry < 10) { 1156 while (++retry < 10) {
1152 usleep_range(10000, 15000); 1157 usleep_range(10000, 15000);
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index be33d2b0613b..7e0b62602632 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -1041,8 +1041,7 @@ static int sci_notifier(struct notifier_block *self,
1041 1041
1042 sci_port = container_of(self, struct sci_port, freq_transition); 1042 sci_port = container_of(self, struct sci_port, freq_transition);
1043 1043
1044 if ((phase == CPUFREQ_POSTCHANGE) || 1044 if (phase == CPUFREQ_POSTCHANGE) {
1045 (phase == CPUFREQ_RESUMECHANGE)) {
1046 struct uart_port *port = &sci_port->port; 1045 struct uart_port *port = &sci_port->port;
1047 1046
1048 spin_lock_irqsave(&port->lock, flags); 1047 spin_lock_irqsave(&port->lock, flags);
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index dade5b7699bc..97a8f3a12a7b 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -27,12 +27,6 @@ config VGASTATE
27 tristate 27 tristate
28 default n 28 default n
29 29
30config VIDEO_OUTPUT_CONTROL
31 tristate "Lowlevel video output switch controls"
32 help
33 This framework adds support for low-level control of the video
34 output switch.
35
36config VIDEOMODE_HELPERS 30config VIDEOMODE_HELPERS
37 bool 31 bool
38 32
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index ae17ddf49a00..08d6a4ab3ace 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -172,8 +172,6 @@ obj-$(CONFIG_FB_SIMPLE) += simplefb.o
172# the test framebuffer is last 172# the test framebuffer is last
173obj-$(CONFIG_FB_VIRTUAL) += vfb.o 173obj-$(CONFIG_FB_VIRTUAL) += vfb.o
174 174
175#video output switch sysfs driver
176obj-$(CONFIG_VIDEO_OUTPUT_CONTROL) += output.o
177obj-$(CONFIG_VIDEOMODE_HELPERS) += display_timing.o videomode.o 175obj-$(CONFIG_VIDEOMODE_HELPERS) += display_timing.o videomode.o
178ifeq ($(CONFIG_OF),y) 176ifeq ($(CONFIG_OF),y)
179obj-$(CONFIG_VIDEOMODE_HELPERS) += of_display_timing.o of_videomode.o 177obj-$(CONFIG_VIDEOMODE_HELPERS) += of_display_timing.o of_videomode.o
diff --git a/drivers/video/output.c b/drivers/video/output.c
deleted file mode 100644
index 1446c49fe6af..000000000000
--- a/drivers/video/output.c
+++ /dev/null
@@ -1,133 +0,0 @@
1/*
2 * output.c - Display Output Switch driver
3 *
4 * Copyright (C) 2006 Luming Yu <luming.yu@intel.com>
5 *
6 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or (at
11 * your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 *
22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23 */
24#include <linux/module.h>
25#include <linux/video_output.h>
26#include <linux/slab.h>
27#include <linux/err.h>
28#include <linux/ctype.h>
29
30
31MODULE_DESCRIPTION("Display Output Switcher Lowlevel Control Abstraction");
32MODULE_LICENSE("GPL");
33MODULE_AUTHOR("Luming Yu <luming.yu@intel.com>");
34
35static ssize_t state_show(struct device *dev, struct device_attribute *attr,
36 char *buf)
37{
38 ssize_t ret_size = 0;
39 struct output_device *od = to_output_device(dev);
40 if (od->props)
41 ret_size = sprintf(buf,"%.8x\n",od->props->get_status(od));
42 return ret_size;
43}
44
45static ssize_t state_store(struct device *dev, struct device_attribute *attr,
46 const char *buf,size_t count)
47{
48 char *endp;
49 struct output_device *od = to_output_device(dev);
50 int request_state = simple_strtoul(buf,&endp,0);
51 size_t size = endp - buf;
52
53 if (isspace(*endp))
54 size++;
55 if (size != count)
56 return -EINVAL;
57
58 if (od->props) {
59 od->request_state = request_state;
60 od->props->set_state(od);
61 }
62 return count;
63}
64static DEVICE_ATTR_RW(state);
65
66static void video_output_release(struct device *dev)
67{
68 struct output_device *od = to_output_device(dev);
69 kfree(od);
70}
71
72static struct attribute *video_output_attrs[] = {
73 &dev_attr_state.attr,
74 NULL,
75};
76ATTRIBUTE_GROUPS(video_output);
77
78static struct class video_output_class = {
79 .name = "video_output",
80 .dev_release = video_output_release,
81 .dev_groups = video_output_groups,
82};
83
84struct output_device *video_output_register(const char *name,
85 struct device *dev,
86 void *devdata,
87 struct output_properties *op)
88{
89 struct output_device *new_dev;
90 int ret_code = 0;
91
92 new_dev = kzalloc(sizeof(struct output_device),GFP_KERNEL);
93 if (!new_dev) {
94 ret_code = -ENOMEM;
95 goto error_return;
96 }
97 new_dev->props = op;
98 new_dev->dev.class = &video_output_class;
99 new_dev->dev.parent = dev;
100 dev_set_name(&new_dev->dev, "%s", name);
101 dev_set_drvdata(&new_dev->dev, devdata);
102 ret_code = device_register(&new_dev->dev);
103 if (ret_code) {
104 kfree(new_dev);
105 goto error_return;
106 }
107 return new_dev;
108
109error_return:
110 return ERR_PTR(ret_code);
111}
112EXPORT_SYMBOL(video_output_register);
113
114void video_output_unregister(struct output_device *dev)
115{
116 if (!dev)
117 return;
118 device_unregister(&dev->dev);
119}
120EXPORT_SYMBOL(video_output_unregister);
121
122static void __exit video_output_class_exit(void)
123{
124 class_unregister(&video_output_class);
125}
126
127static int __init video_output_class_init(void)
128{
129 return class_register(&video_output_class);
130}
131
132postcore_initcall(video_output_class_init);
133module_exit(video_output_class_exit);
diff --git a/drivers/xen/xen-acpi-cpuhotplug.c b/drivers/xen/xen-acpi-cpuhotplug.c
index 80875fb770ed..3e62ee4b3b66 100644
--- a/drivers/xen/xen-acpi-cpuhotplug.c
+++ b/drivers/xen/xen-acpi-cpuhotplug.c
@@ -313,7 +313,7 @@ static void acpi_processor_hotplug_notify(acpi_handle handle,
313 goto out; 313 goto out;
314 } 314 }
315 315
316 (void) acpi_evaluate_hotplug_ost(handle, event, ost_code, NULL); 316 (void) acpi_evaluate_ost(handle, event, ost_code, NULL);
317 317
318out: 318out:
319 acpi_scan_lock_release(); 319 acpi_scan_lock_release();
diff --git a/drivers/xen/xen-acpi-memhotplug.c b/drivers/xen/xen-acpi-memhotplug.c
index f8d18626969a..34e40b733f9a 100644
--- a/drivers/xen/xen-acpi-memhotplug.c
+++ b/drivers/xen/xen-acpi-memhotplug.c
@@ -285,7 +285,7 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
285 return; 285 return;
286 } 286 }
287 287
288 (void) acpi_evaluate_hotplug_ost(handle, event, ost_code, NULL); 288 (void) acpi_evaluate_ost(handle, event, ost_code, NULL);
289 return; 289 return;
290} 290}
291 291
diff --git a/drivers/xen/xen-acpi-pad.c b/drivers/xen/xen-acpi-pad.c
index 40c4bc06b5fa..f83b754505f8 100644
--- a/drivers/xen/xen-acpi-pad.c
+++ b/drivers/xen/xen-acpi-pad.c
@@ -77,27 +77,14 @@ static int acpi_pad_pur(acpi_handle handle)
77 return num; 77 return num;
78} 78}
79 79
80/* Notify firmware how many CPUs are idle */
81static void acpi_pad_ost(acpi_handle handle, int stat,
82 uint32_t idle_nums)
83{
84 union acpi_object params[3] = {
85 {.type = ACPI_TYPE_INTEGER,},
86 {.type = ACPI_TYPE_INTEGER,},
87 {.type = ACPI_TYPE_BUFFER,},
88 };
89 struct acpi_object_list arg_list = {3, params};
90
91 params[0].integer.value = ACPI_PROCESSOR_AGGREGATOR_NOTIFY;
92 params[1].integer.value = stat;
93 params[2].buffer.length = 4;
94 params[2].buffer.pointer = (void *)&idle_nums;
95 acpi_evaluate_object(handle, "_OST", &arg_list, NULL);
96}
97
98static void acpi_pad_handle_notify(acpi_handle handle) 80static void acpi_pad_handle_notify(acpi_handle handle)
99{ 81{
100 int idle_nums; 82 int idle_nums;
83 struct acpi_buffer param = {
84 .length = 4,
85 .pointer = (void *)&idle_nums,
86 };
87
101 88
102 mutex_lock(&xen_cpu_lock); 89 mutex_lock(&xen_cpu_lock);
103 idle_nums = acpi_pad_pur(handle); 90 idle_nums = acpi_pad_pur(handle);
@@ -109,7 +96,8 @@ static void acpi_pad_handle_notify(acpi_handle handle)
109 idle_nums = xen_acpi_pad_idle_cpus(idle_nums) 96 idle_nums = xen_acpi_pad_idle_cpus(idle_nums)
110 ?: xen_acpi_pad_idle_cpus_num(); 97 ?: xen_acpi_pad_idle_cpus_num();
111 if (idle_nums >= 0) 98 if (idle_nums >= 0)
112 acpi_pad_ost(handle, 0, idle_nums); 99 acpi_evaluate_ost(handle, ACPI_PROCESSOR_AGGREGATOR_NOTIFY,
100 0, &param);
113 mutex_unlock(&xen_cpu_lock); 101 mutex_unlock(&xen_cpu_lock);
114} 102}
115 103
diff --git a/include/acpi/acbuffer.h b/include/acpi/acbuffer.h
index c927a0b1de78..88cb477524a6 100644
--- a/include/acpi/acbuffer.h
+++ b/include/acpi/acbuffer.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/acconfig.h b/include/acpi/acconfig.h
index 3ea214cff349..932a60d6ed82 100644
--- a/include/acpi/acconfig.h
+++ b/include/acpi/acconfig.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/acexcep.h b/include/acpi/acexcep.h
index 4e280bd226dd..8b06e4c1dd5d 100644
--- a/include/acpi/acexcep.h
+++ b/include/acpi/acexcep.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/acnames.h b/include/acpi/acnames.h
index 1f36777e26fe..3dd6e838dc30 100644
--- a/include/acpi/acnames.h
+++ b/include/acpi/acnames.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/acoutput.h b/include/acpi/acoutput.h
index 4607b027a657..1baae6edda89 100644
--- a/include/acpi/acoutput.h
+++ b/include/acpi/acoutput.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/acpi.h b/include/acpi/acpi.h
index 618787715d56..ca0cb603b171 100644
--- a/include/acpi/acpi.h
+++ b/include/acpi/acpi.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -62,5 +62,8 @@
62#include <acpi/acrestyp.h> /* Resource Descriptor structs */ 62#include <acpi/acrestyp.h> /* Resource Descriptor structs */
63#include <acpi/acpiosxf.h> /* OSL interfaces (ACPICA-to-OS) */ 63#include <acpi/acpiosxf.h> /* OSL interfaces (ACPICA-to-OS) */
64#include <acpi/acpixf.h> /* ACPI core subsystem external interfaces */ 64#include <acpi/acpixf.h> /* ACPI core subsystem external interfaces */
65#ifdef ACPI_NATIVE_INTERFACE_HEADER
66#include ACPI_NATIVE_INTERFACE_HEADER
67#endif
65 68
66#endif /* __ACPI_H__ */ 69#endif /* __ACPI_H__ */
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 8256eb4ad057..84a2e29a2314 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -49,8 +49,8 @@ acpi_evaluate_reference(acpi_handle handle,
49 struct acpi_object_list *arguments, 49 struct acpi_object_list *arguments,
50 struct acpi_handle_list *list); 50 struct acpi_handle_list *list);
51acpi_status 51acpi_status
52acpi_evaluate_hotplug_ost(acpi_handle handle, u32 source_event, 52acpi_evaluate_ost(acpi_handle handle, u32 source_event, u32 status_code,
53 u32 status_code, struct acpi_buffer *status_buf); 53 struct acpi_buffer *status_buf);
54 54
55acpi_status 55acpi_status
56acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld_info **pld); 56acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld_info **pld);
@@ -133,10 +133,24 @@ struct acpi_scan_handler {
133 struct list_head list_node; 133 struct list_head list_node;
134 int (*attach)(struct acpi_device *dev, const struct acpi_device_id *id); 134 int (*attach)(struct acpi_device *dev, const struct acpi_device_id *id);
135 void (*detach)(struct acpi_device *dev); 135 void (*detach)(struct acpi_device *dev);
136 void (*bind)(struct device *phys_dev);
137 void (*unbind)(struct device *phys_dev);
136 struct acpi_hotplug_profile hotplug; 138 struct acpi_hotplug_profile hotplug;
137}; 139};
138 140
139/* 141/*
142 * ACPI Hotplug Context
143 * --------------------
144 */
145
146struct acpi_hotplug_context {
147 struct acpi_device *self;
148 int (*notify)(struct acpi_device *, u32);
149 void (*uevent)(struct acpi_device *, u32);
150 void (*fixup)(struct acpi_device *);
151};
152
153/*
140 * ACPI Driver 154 * ACPI Driver
141 * ----------- 155 * -----------
142 */ 156 */
@@ -190,7 +204,9 @@ struct acpi_device_flags {
190 u32 initialized:1; 204 u32 initialized:1;
191 u32 visited:1; 205 u32 visited:1;
192 u32 no_hotplug:1; 206 u32 no_hotplug:1;
193 u32 reserved:24; 207 u32 hotplug_notify:1;
208 u32 is_dock_station:1;
209 u32 reserved:22;
194}; 210};
195 211
196/* File System */ 212/* File System */
@@ -329,6 +345,7 @@ struct acpi_device {
329 struct acpi_device_perf performance; 345 struct acpi_device_perf performance;
330 struct acpi_device_dir dir; 346 struct acpi_device_dir dir;
331 struct acpi_scan_handler *handler; 347 struct acpi_scan_handler *handler;
348 struct acpi_hotplug_context *hp;
332 struct acpi_driver *driver; 349 struct acpi_driver *driver;
333 void *driver_data; 350 void *driver_data;
334 struct device dev; 351 struct device dev;
@@ -351,6 +368,24 @@ static inline void acpi_set_device_status(struct acpi_device *adev, u32 sta)
351 *((u32 *)&adev->status) = sta; 368 *((u32 *)&adev->status) = sta;
352} 369}
353 370
371static inline void acpi_set_hp_context(struct acpi_device *adev,
372 struct acpi_hotplug_context *hp,
373 int (*notify)(struct acpi_device *, u32),
374 void (*uevent)(struct acpi_device *, u32),
375 void (*fixup)(struct acpi_device *))
376{
377 hp->self = adev;
378 hp->notify = notify;
379 hp->uevent = uevent;
380 hp->fixup = fixup;
381 adev->hp = hp;
382}
383
384void acpi_initialize_hp_context(struct acpi_device *adev,
385 struct acpi_hotplug_context *hp,
386 int (*notify)(struct acpi_device *, u32),
387 void (*uevent)(struct acpi_device *, u32));
388
354/* acpi_device.dev.bus == &acpi_bus_type */ 389/* acpi_device.dev.bus == &acpi_bus_type */
355extern struct bus_type acpi_bus_type; 390extern struct bus_type acpi_bus_type;
356 391
@@ -381,6 +416,8 @@ extern int unregister_acpi_notifier(struct notifier_block *);
381 */ 416 */
382 417
383int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device); 418int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device);
419struct acpi_device *acpi_bus_get_acpi_device(acpi_handle handle);
420void acpi_bus_put_acpi_device(struct acpi_device *adev);
384acpi_status acpi_bus_get_status_handle(acpi_handle handle, 421acpi_status acpi_bus_get_status_handle(acpi_handle handle,
385 unsigned long long *sta); 422 unsigned long long *sta);
386int acpi_bus_get_status(struct acpi_device *device); 423int acpi_bus_get_status(struct acpi_device *device);
@@ -402,6 +439,8 @@ static inline bool acpi_bus_can_wakeup(acpi_handle handle) { return false; }
402 439
403void acpi_scan_lock_acquire(void); 440void acpi_scan_lock_acquire(void);
404void acpi_scan_lock_release(void); 441void acpi_scan_lock_release(void);
442void acpi_lock_hp_context(void);
443void acpi_unlock_hp_context(void);
405int acpi_scan_add_handler(struct acpi_scan_handler *handler); 444int acpi_scan_add_handler(struct acpi_scan_handler *handler);
406int acpi_bus_register_driver(struct acpi_driver *driver); 445int acpi_bus_register_driver(struct acpi_driver *driver);
407void acpi_bus_unregister_driver(struct acpi_driver *driver); 446void acpi_bus_unregister_driver(struct acpi_driver *driver);
@@ -418,10 +457,6 @@ static inline bool acpi_device_enumerated(struct acpi_device *adev)
418 return adev && adev->flags.initialized && adev->flags.visited; 457 return adev && adev->flags.initialized && adev->flags.visited;
419} 458}
420 459
421typedef void (*acpi_hp_callback)(void *data, u32 src);
422
423acpi_status acpi_hotplug_execute(acpi_hp_callback func, void *data, u32 src);
424
425/** 460/**
426 * module_acpi_driver(acpi_driver) - Helper macro for registering an ACPI driver 461 * module_acpi_driver(acpi_driver) - Helper macro for registering an ACPI driver
427 * @__acpi_driver: acpi_driver struct 462 * @__acpi_driver: acpi_driver struct
diff --git a/include/acpi/acpi_drivers.h b/include/acpi/acpi_drivers.h
index b124fdb26046..d504613bbf80 100644
--- a/include/acpi/acpi_drivers.h
+++ b/include/acpi/acpi_drivers.h
@@ -109,36 +109,14 @@ void pci_acpi_crs_quirks(void);
109/*-------------------------------------------------------------------------- 109/*--------------------------------------------------------------------------
110 Dock Station 110 Dock Station
111 -------------------------------------------------------------------------- */ 111 -------------------------------------------------------------------------- */
112struct acpi_dock_ops {
113 acpi_notify_handler fixup;
114 acpi_notify_handler handler;
115 acpi_notify_handler uevent;
116};
117 112
118#ifdef CONFIG_ACPI_DOCK 113#ifdef CONFIG_ACPI_DOCK
119extern int is_dock_device(acpi_handle handle); 114extern int is_dock_device(struct acpi_device *adev);
120extern int register_hotplug_dock_device(acpi_handle handle,
121 const struct acpi_dock_ops *ops,
122 void *context,
123 void (*init)(void *),
124 void (*release)(void *));
125extern void unregister_hotplug_dock_device(acpi_handle handle);
126#else 115#else
127static inline int is_dock_device(acpi_handle handle) 116static inline int is_dock_device(struct acpi_device *adev)
128{ 117{
129 return 0; 118 return 0;
130} 119}
131static inline int register_hotplug_dock_device(acpi_handle handle,
132 const struct acpi_dock_ops *ops,
133 void *context,
134 void (*init)(void *),
135 void (*release)(void *))
136{
137 return -ENODEV;
138}
139static inline void unregister_hotplug_dock_device(acpi_handle handle)
140{
141}
142#endif /* CONFIG_ACPI_DOCK */ 120#endif /* CONFIG_ACPI_DOCK */
143 121
144#endif /*__ACPI_DRIVERS_H__*/ 122#endif /*__ACPI_DRIVERS_H__*/
diff --git a/include/acpi/acpiosxf.h b/include/acpi/acpiosxf.h
index 01e6c6d8b7e1..f6f5f8af2112 100644
--- a/include/acpi/acpiosxf.h
+++ b/include/acpi/acpiosxf.h
@@ -7,7 +7,7 @@
7 *****************************************************************************/ 7 *****************************************************************************/
8 8
9/* 9/*
10 * Copyright (C) 2000 - 2013, Intel Corp. 10 * Copyright (C) 2000 - 2014, Intel Corp.
11 * All rights reserved. 11 * All rights reserved.
12 * 12 *
13 * Redistribution and use in source and binary forms, with or without 13 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h
index fea6773f87fc..b0b01b13ea99 100644
--- a/include/acpi/acpixf.h
+++ b/include/acpi/acpixf.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -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 0x20131218 49#define ACPI_CA_VERSION 0x20140214
50 50
51#include <acpi/acconfig.h> 51#include <acpi/acconfig.h>
52#include <acpi/actypes.h> 52#include <acpi/actypes.h>
@@ -230,6 +230,10 @@ acpi_attach_data(acpi_handle object, acpi_object_handler handler, void *data);
230acpi_status acpi_detach_data(acpi_handle object, acpi_object_handler handler); 230acpi_status acpi_detach_data(acpi_handle object, acpi_object_handler handler);
231 231
232acpi_status 232acpi_status
233acpi_get_data_full(acpi_handle object, acpi_object_handler handler, void **data,
234 void (*callback)(void *));
235
236acpi_status
233acpi_get_data(acpi_handle object, acpi_object_handler handler, void **data); 237acpi_get_data(acpi_handle object, acpi_object_handler handler, void **data);
234 238
235acpi_status 239acpi_status
diff --git a/include/acpi/acrestyp.h b/include/acpi/acrestyp.h
index cbf4bf977f75..eb760ca0b2e0 100644
--- a/include/acpi/acrestyp.h
+++ b/include/acpi/acrestyp.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/actbl.h b/include/acpi/actbl.h
index 325aeae1fa99..3b30e36b53b5 100644
--- a/include/acpi/actbl.h
+++ b/include/acpi/actbl.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/actbl1.h b/include/acpi/actbl1.h
index 4ec8c194bfe5..212c65de75df 100644
--- a/include/acpi/actbl1.h
+++ b/include/acpi/actbl1.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/actbl2.h b/include/acpi/actbl2.h
index 094a906a0e98..f3372441e3a5 100644
--- a/include/acpi/actbl2.h
+++ b/include/acpi/actbl2.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/actbl3.h b/include/acpi/actbl3.h
index 01c2a9013e40..c2295cc4a5c0 100644
--- a/include/acpi/actbl3.h
+++ b/include/acpi/actbl3.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h
index 68a3ada689c9..e76356574374 100644
--- a/include/acpi/actypes.h
+++ b/include/acpi/actypes.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -55,18 +55,16 @@
55#error ACPI_MACHINE_WIDTH not defined 55#error ACPI_MACHINE_WIDTH not defined
56#endif 56#endif
57 57
58/*! [Begin] no source code translation */
59
60/* 58/*
61 * Data type ranges 59 * Data type ranges
62 * Note: These macros are designed to be compiler independent as well as 60 * Note: These macros are designed to be compiler independent as well as
63 * working around problems that some 32-bit compilers have with 64-bit 61 * working around problems that some 32-bit compilers have with 64-bit
64 * constants. 62 * constants.
65 */ 63 */
66#define ACPI_UINT8_MAX (UINT8) (~((UINT8) 0)) /* 0xFF */ 64#define ACPI_UINT8_MAX (u8) (~((u8) 0)) /* 0xFF */
67#define ACPI_UINT16_MAX (UINT16)(~((UINT16) 0)) /* 0xFFFF */ 65#define ACPI_UINT16_MAX (u16)(~((u16) 0)) /* 0xFFFF */
68#define ACPI_UINT32_MAX (UINT32)(~((UINT32) 0)) /* 0xFFFFFFFF */ 66#define ACPI_UINT32_MAX (u32)(~((u32) 0)) /* 0xFFFFFFFF */
69#define ACPI_UINT64_MAX (UINT64)(~((UINT64) 0)) /* 0xFFFFFFFFFFFFFFFF */ 67#define ACPI_UINT64_MAX (u64)(~((u64) 0)) /* 0xFFFFFFFFFFFFFFFF */
70#define ACPI_ASCII_MAX 0x7F 68#define ACPI_ASCII_MAX 0x7F
71 69
72/* 70/*
@@ -77,18 +75,18 @@
77 * 75 *
78 * 1) The following types are of fixed size for all targets (16/32/64): 76 * 1) The following types are of fixed size for all targets (16/32/64):
79 * 77 *
80 * BOOLEAN Logical boolean 78 * u8 Logical boolean
81 * 79 *
82 * UINT8 8-bit (1 byte) unsigned value 80 * u8 8-bit (1 byte) unsigned value
83 * UINT16 16-bit (2 byte) unsigned value 81 * u16 16-bit (2 byte) unsigned value
84 * UINT32 32-bit (4 byte) unsigned value 82 * u32 32-bit (4 byte) unsigned value
85 * UINT64 64-bit (8 byte) unsigned value 83 * u64 64-bit (8 byte) unsigned value
86 * 84 *
87 * INT16 16-bit (2 byte) signed value 85 * s16 16-bit (2 byte) signed value
88 * INT32 32-bit (4 byte) signed value 86 * s32 32-bit (4 byte) signed value
89 * INT64 64-bit (8 byte) signed value 87 * s64 64-bit (8 byte) signed value
90 * 88 *
91 * COMPILER_DEPENDENT_UINT64/INT64 - These types are defined in the 89 * COMPILER_DEPENDENT_UINT64/s64 - These types are defined in the
92 * compiler-dependent header(s) and were introduced because there is no common 90 * compiler-dependent header(s) and were introduced because there is no common
93 * 64-bit integer type across the various compilation models, as shown in 91 * 64-bit integer type across the various compilation models, as shown in
94 * the table below. 92 * the table below.
@@ -110,11 +108,11 @@
110 * usually used for memory allocation, efficient loop counters, and array 108 * usually used for memory allocation, efficient loop counters, and array
111 * indexes. The types are similar to the size_t type in the C library and are 109 * indexes. The types are similar to the size_t type in the C library and are
112 * required because there is no C type that consistently represents the native 110 * required because there is no C type that consistently represents the native
113 * data width. ACPI_SIZE is needed because there is no guarantee that a 111 * data width. acpi_size is needed because there is no guarantee that a
114 * kernel-level C library is present. 112 * kernel-level C library is present.
115 * 113 *
116 * ACPI_SIZE 16/32/64-bit unsigned value 114 * acpi_size 16/32/64-bit unsigned value
117 * ACPI_NATIVE_INT 16/32/64-bit signed value 115 * acpi_native_int 16/32/64-bit signed value
118 */ 116 */
119 117
120/******************************************************************************* 118/*******************************************************************************
@@ -123,13 +121,15 @@
123 * 121 *
124 ******************************************************************************/ 122 ******************************************************************************/
125 123
126typedef unsigned char BOOLEAN; 124#ifndef ACPI_USE_SYSTEM_INTTYPES
127typedef unsigned char UINT8; 125
128typedef unsigned short UINT16; 126typedef unsigned char u8;
129typedef COMPILER_DEPENDENT_UINT64 UINT64; 127typedef unsigned char u8;
130typedef COMPILER_DEPENDENT_INT64 INT64; 128typedef unsigned short u16;
129typedef COMPILER_DEPENDENT_UINT64 u64;
130typedef COMPILER_DEPENDENT_INT64 s64;
131 131
132/*! [End] no source code translation !*/ 132#endif /* ACPI_USE_SYSTEM_INTTYPES */
133 133
134/* 134/*
135 * Value returned by acpi_os_get_thread_id. There is no standard "thread_id" 135 * Value returned by acpi_os_get_thread_id. There is no standard "thread_id"
@@ -149,12 +149,12 @@ typedef COMPILER_DEPENDENT_INT64 INT64;
149 149
150#if ACPI_MACHINE_WIDTH == 64 150#if ACPI_MACHINE_WIDTH == 64
151 151
152/*! [Begin] no source code translation (keep the typedefs as-is) */ 152#ifndef ACPI_USE_SYSTEM_INTTYPES
153 153
154typedef unsigned int UINT32; 154typedef unsigned int u32;
155typedef int INT32; 155typedef int s32;
156 156
157/*! [End] no source code translation !*/ 157#endif /* ACPI_USE_SYSTEM_INTTYPES */
158 158
159typedef s64 acpi_native_int; 159typedef s64 acpi_native_int;
160 160
@@ -188,12 +188,12 @@ typedef u64 acpi_physical_address;
188 188
189#elif ACPI_MACHINE_WIDTH == 32 189#elif ACPI_MACHINE_WIDTH == 32
190 190
191/*! [Begin] no source code translation (keep the typedefs as-is) */ 191#ifndef ACPI_USE_SYSTEM_INTTYPES
192 192
193typedef unsigned int UINT32; 193typedef unsigned int u32;
194typedef int INT32; 194typedef int s32;
195 195
196/*! [End] no source code translation !*/ 196#endif /* ACPI_USE_SYSTEM_INTTYPES */
197 197
198typedef s32 acpi_native_int; 198typedef s32 acpi_native_int;
199 199
diff --git a/include/acpi/platform/acenv.h b/include/acpi/platform/acenv.h
index b402eb67af83..e863dd5c4e04 100644
--- a/include/acpi/platform/acenv.h
+++ b/include/acpi/platform/acenv.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/platform/acgcc.h b/include/acpi/platform/acgcc.h
index e077ce6c38ca..a476b9118b49 100644
--- a/include/acpi/platform/acgcc.h
+++ b/include/acpi/platform/acgcc.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h
index 008aa287c7a9..93c55ed7c53d 100644
--- a/include/acpi/platform/aclinux.h
+++ b/include/acpi/platform/aclinux.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2013, Intel Corp. 8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -52,6 +52,14 @@
52 52
53#ifdef __KERNEL__ 53#ifdef __KERNEL__
54 54
55#define ACPI_USE_SYSTEM_INTTYPES
56
57/* Compile for reduced hardware mode only with this kernel config */
58
59#ifdef CONFIG_ACPI_REDUCED_HARDWARE_ONLY
60#define ACPI_REDUCED_HARDWARE 1
61#endif
62
55#include <linux/string.h> 63#include <linux/string.h>
56#include <linux/kernel.h> 64#include <linux/kernel.h>
57#include <linux/ctype.h> 65#include <linux/ctype.h>
@@ -83,6 +91,16 @@
83#include <ctype.h> 91#include <ctype.h>
84#include <unistd.h> 92#include <unistd.h>
85 93
94/* Disable kernel specific declarators */
95
96#ifndef __init
97#define __init
98#endif
99
100#ifndef __iomem
101#define __iomem
102#endif
103
86/* Host-dependent types and defines for user-space ACPICA */ 104/* Host-dependent types and defines for user-space ACPICA */
87 105
88#define ACPI_FLUSH_CPU_CACHE() 106#define ACPI_FLUSH_CPU_CACHE()
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 1151a1dcfe41..6a15dddbaa09 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -108,6 +108,10 @@ static inline void acpi_initrd_override(void *data, size_t size)
108} 108}
109#endif 109#endif
110 110
111#define BAD_MADT_ENTRY(entry, end) ( \
112 (!entry) || (unsigned long)entry + sizeof(*entry) > end || \
113 ((struct acpi_subtable_header *)entry)->length < sizeof(*entry))
114
111char * __acpi_map_table (unsigned long phys_addr, unsigned long size); 115char * __acpi_map_table (unsigned long phys_addr, unsigned long size);
112void __acpi_unmap_table(char *map, unsigned long size); 116void __acpi_unmap_table(char *map, unsigned long size);
113int early_acpi_boot_init(void); 117int early_acpi_boot_init(void);
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 4d89e0e6f9cc..2d2e62c8666a 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -74,6 +74,8 @@ struct cpufreq_policy {
74 unsigned int max; /* in kHz */ 74 unsigned int max; /* in kHz */
75 unsigned int cur; /* in kHz, only needed if cpufreq 75 unsigned int cur; /* in kHz, only needed if cpufreq
76 * governors are used */ 76 * governors are used */
77 unsigned int suspend_freq; /* freq to set during suspend */
78
77 unsigned int policy; /* see above */ 79 unsigned int policy; /* see above */
78 struct cpufreq_governor *governor; /* see below */ 80 struct cpufreq_governor *governor; /* see below */
79 void *governor_data; 81 void *governor_data;
@@ -83,6 +85,7 @@ struct cpufreq_policy {
83 * called, but you're in IRQ context */ 85 * called, but you're in IRQ context */
84 86
85 struct cpufreq_real_policy user_policy; 87 struct cpufreq_real_policy user_policy;
88 struct cpufreq_frequency_table *freq_table;
86 89
87 struct list_head policy_list; 90 struct list_head policy_list;
88 struct kobject kobj; 91 struct kobject kobj;
@@ -224,6 +227,7 @@ struct cpufreq_driver {
224 int (*bios_limit) (int cpu, unsigned int *limit); 227 int (*bios_limit) (int cpu, unsigned int *limit);
225 228
226 int (*exit) (struct cpufreq_policy *policy); 229 int (*exit) (struct cpufreq_policy *policy);
230 void (*stop_cpu) (struct cpufreq_policy *policy);
227 int (*suspend) (struct cpufreq_policy *policy); 231 int (*suspend) (struct cpufreq_policy *policy);
228 int (*resume) (struct cpufreq_policy *policy); 232 int (*resume) (struct cpufreq_policy *policy);
229 struct freq_attr **attr; 233 struct freq_attr **attr;
@@ -296,6 +300,15 @@ cpufreq_verify_within_cpu_limits(struct cpufreq_policy *policy)
296 policy->cpuinfo.max_freq); 300 policy->cpuinfo.max_freq);
297} 301}
298 302
303#ifdef CONFIG_CPU_FREQ
304void cpufreq_suspend(void);
305void cpufreq_resume(void);
306int cpufreq_generic_suspend(struct cpufreq_policy *policy);
307#else
308static inline void cpufreq_suspend(void) {}
309static inline void cpufreq_resume(void) {}
310#endif
311
299/********************************************************************* 312/*********************************************************************
300 * CPUFREQ NOTIFIER INTERFACE * 313 * CPUFREQ NOTIFIER INTERFACE *
301 *********************************************************************/ 314 *********************************************************************/
@@ -306,8 +319,6 @@ cpufreq_verify_within_cpu_limits(struct cpufreq_policy *policy)
306/* Transition notifiers */ 319/* Transition notifiers */
307#define CPUFREQ_PRECHANGE (0) 320#define CPUFREQ_PRECHANGE (0)
308#define CPUFREQ_POSTCHANGE (1) 321#define CPUFREQ_POSTCHANGE (1)
309#define CPUFREQ_RESUMECHANGE (8)
310#define CPUFREQ_SUSPENDCHANGE (9)
311 322
312/* Policy Notifiers */ 323/* Policy Notifiers */
313#define CPUFREQ_ADJUST (0) 324#define CPUFREQ_ADJUST (0)
@@ -463,7 +474,6 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
463int cpufreq_frequency_table_get_index(struct cpufreq_policy *policy, 474int cpufreq_frequency_table_get_index(struct cpufreq_policy *policy,
464 unsigned int freq); 475 unsigned int freq);
465 476
466void cpufreq_frequency_table_update_policy_cpu(struct cpufreq_policy *policy);
467ssize_t cpufreq_show_cpus(const struct cpumask *mask, char *buf); 477ssize_t cpufreq_show_cpus(const struct cpumask *mask, char *buf);
468 478
469#ifdef CONFIG_CPU_FREQ 479#ifdef CONFIG_CPU_FREQ
@@ -490,9 +500,6 @@ struct cpufreq_frequency_table *cpufreq_frequency_get_table(unsigned int cpu);
490/* the following are really really optional */ 500/* the following are really really optional */
491extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs; 501extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs;
492extern struct freq_attr *cpufreq_generic_attr[]; 502extern struct freq_attr *cpufreq_generic_attr[];
493void cpufreq_frequency_table_get_attr(struct cpufreq_frequency_table *table,
494 unsigned int cpu);
495void cpufreq_frequency_table_put_attr(unsigned int cpu);
496int cpufreq_table_validate_and_show(struct cpufreq_policy *policy, 503int cpufreq_table_validate_and_show(struct cpufreq_policy *policy,
497 struct cpufreq_frequency_table *table); 504 struct cpufreq_frequency_table *table);
498 505
@@ -500,10 +507,4 @@ unsigned int cpufreq_generic_get(unsigned int cpu);
500int cpufreq_generic_init(struct cpufreq_policy *policy, 507int cpufreq_generic_init(struct cpufreq_policy *policy,
501 struct cpufreq_frequency_table *table, 508 struct cpufreq_frequency_table *table,
502 unsigned int transition_latency); 509 unsigned int transition_latency);
503static inline int cpufreq_generic_exit(struct cpufreq_policy *policy)
504{
505 cpufreq_frequency_table_put_attr(policy->cpu);
506 return 0;
507}
508
509#endif /* _LINUX_CPUFREQ_H */ 510#endif /* _LINUX_CPUFREQ_H */
diff --git a/include/linux/pci-acpi.h b/include/linux/pci-acpi.h
index 5a462c4e5009..637a608ded0b 100644
--- a/include/linux/pci-acpi.h
+++ b/include/linux/pci-acpi.h
@@ -59,12 +59,12 @@ static inline void acpi_pci_slot_remove(struct pci_bus *bus) { }
59void acpiphp_init(void); 59void acpiphp_init(void);
60void acpiphp_enumerate_slots(struct pci_bus *bus); 60void acpiphp_enumerate_slots(struct pci_bus *bus);
61void acpiphp_remove_slots(struct pci_bus *bus); 61void acpiphp_remove_slots(struct pci_bus *bus);
62void acpiphp_check_host_bridge(acpi_handle handle); 62void acpiphp_check_host_bridge(struct acpi_device *adev);
63#else 63#else
64static inline void acpiphp_init(void) { } 64static inline void acpiphp_init(void) { }
65static inline void acpiphp_enumerate_slots(struct pci_bus *bus) { } 65static inline void acpiphp_enumerate_slots(struct pci_bus *bus) { }
66static inline void acpiphp_remove_slots(struct pci_bus *bus) { } 66static inline void acpiphp_remove_slots(struct pci_bus *bus) { }
67static inline void acpiphp_check_host_bridge(acpi_handle handle) { } 67static inline void acpiphp_check_host_bridge(struct acpi_device *adev) { }
68#endif 68#endif
69 69
70#else /* CONFIG_ACPI */ 70#else /* CONFIG_ACPI */
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 8c6583a53a06..d915d0345fa1 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -264,9 +264,9 @@ typedef struct pm_message {
264 * registers, so that it is fully operational. 264 * registers, so that it is fully operational.
265 * 265 *
266 * @runtime_idle: Device appears to be inactive and it might be put into a 266 * @runtime_idle: Device appears to be inactive and it might be put into a
267 * low-power state if all of the necessary conditions are satisfied. Check 267 * low-power state if all of the necessary conditions are satisfied.
268 * these conditions and handle the device as appropriate, possibly queueing 268 * Check these conditions, and return 0 if it's appropriate to let the PM
269 * a suspend request for it. The return value is ignored by the PM core. 269 * core queue a suspend request for the device.
270 * 270 *
271 * Refer to Documentation/power/runtime_pm.txt for more information about the 271 * Refer to Documentation/power/runtime_pm.txt for more information about the
272 * role of the above callbacks in device runtime power management. 272 * role of the above callbacks in device runtime power management.
@@ -352,7 +352,7 @@ const struct dev_pm_ops name = { \
352 352
353/* 353/*
354 * Use this for defining a set of PM operations to be used in all situations 354 * Use this for defining a set of PM operations to be used in all situations
355 * (sustem suspend, hibernation or runtime PM). 355 * (system suspend, hibernation or runtime PM).
356 * NOTE: In general, system suspend callbacks, .suspend() and .resume(), should 356 * NOTE: In general, system suspend callbacks, .suspend() and .resume(), should
357 * be different from the corresponding runtime PM callbacks, .runtime_suspend(), 357 * be different from the corresponding runtime PM callbacks, .runtime_suspend(),
358 * and .runtime_resume(), because .runtime_suspend() always works on an already 358 * and .runtime_resume(), because .runtime_suspend() always works on an already
@@ -379,7 +379,7 @@ const struct dev_pm_ops name = { \
379 * 379 *
380 * ON No transition. 380 * ON No transition.
381 * 381 *
382 * FREEZE System is going to hibernate, call ->prepare() and ->freeze() 382 * FREEZE System is going to hibernate, call ->prepare() and ->freeze()
383 * for all devices. 383 * for all devices.
384 * 384 *
385 * SUSPEND System is going to suspend, call ->prepare() and ->suspend() 385 * SUSPEND System is going to suspend, call ->prepare() and ->suspend()
@@ -423,7 +423,7 @@ const struct dev_pm_ops name = { \
423 423
424#define PM_EVENT_INVALID (-1) 424#define PM_EVENT_INVALID (-1)
425#define PM_EVENT_ON 0x0000 425#define PM_EVENT_ON 0x0000
426#define PM_EVENT_FREEZE 0x0001 426#define PM_EVENT_FREEZE 0x0001
427#define PM_EVENT_SUSPEND 0x0002 427#define PM_EVENT_SUSPEND 0x0002
428#define PM_EVENT_HIBERNATE 0x0004 428#define PM_EVENT_HIBERNATE 0x0004
429#define PM_EVENT_QUIESCE 0x0008 429#define PM_EVENT_QUIESCE 0x0008
@@ -542,6 +542,8 @@ struct dev_pm_info {
542 unsigned int async_suspend:1; 542 unsigned int async_suspend:1;
543 bool is_prepared:1; /* Owned by the PM core */ 543 bool is_prepared:1; /* Owned by the PM core */
544 bool is_suspended:1; /* Ditto */ 544 bool is_suspended:1; /* Ditto */
545 bool is_noirq_suspended:1;
546 bool is_late_suspended:1;
545 bool ignore_children:1; 547 bool ignore_children:1;
546 bool early_init:1; /* Owned by the PM core */ 548 bool early_init:1; /* Owned by the PM core */
547 spinlock_t lock; 549 spinlock_t lock;
@@ -582,6 +584,7 @@ struct dev_pm_info {
582 unsigned long accounting_timestamp; 584 unsigned long accounting_timestamp;
583#endif 585#endif
584 struct pm_subsys_data *subsys_data; /* Owned by the subsystem. */ 586 struct pm_subsys_data *subsys_data; /* Owned by the subsystem. */
587 void (*set_latency_tolerance)(struct device *, s32);
585 struct dev_pm_qos *qos; 588 struct dev_pm_qos *qos;
586}; 589};
587 590
@@ -612,11 +615,11 @@ struct dev_pm_domain {
612 * message is implicit: 615 * message is implicit:
613 * 616 *
614 * ON Driver starts working again, responding to hardware events 617 * ON Driver starts working again, responding to hardware events
615 * and software requests. The hardware may have gone through 618 * and software requests. The hardware may have gone through
616 * a power-off reset, or it may have maintained state from the 619 * a power-off reset, or it may have maintained state from the
617 * previous suspend() which the driver will rely on while 620 * previous suspend() which the driver will rely on while
618 * resuming. On most platforms, there are no restrictions on 621 * resuming. On most platforms, there are no restrictions on
619 * availability of resources like clocks during resume(). 622 * availability of resources like clocks during resume().
620 * 623 *
621 * Other transitions are triggered by messages sent using suspend(). All 624 * Other transitions are triggered by messages sent using suspend(). All
622 * these transitions quiesce the driver, so that I/O queues are inactive. 625 * these transitions quiesce the driver, so that I/O queues are inactive.
@@ -626,21 +629,21 @@ struct dev_pm_domain {
626 * differ according to the message: 629 * differ according to the message:
627 * 630 *
628 * SUSPEND Quiesce, enter a low power device state appropriate for 631 * SUSPEND Quiesce, enter a low power device state appropriate for
629 * the upcoming system state (such as PCI_D3hot), and enable 632 * the upcoming system state (such as PCI_D3hot), and enable
630 * wakeup events as appropriate. 633 * wakeup events as appropriate.
631 * 634 *
632 * HIBERNATE Enter a low power device state appropriate for the hibernation 635 * HIBERNATE Enter a low power device state appropriate for the hibernation
633 * state (eg. ACPI S4) and enable wakeup events as appropriate. 636 * state (eg. ACPI S4) and enable wakeup events as appropriate.
634 * 637 *
635 * FREEZE Quiesce operations so that a consistent image can be saved; 638 * FREEZE Quiesce operations so that a consistent image can be saved;
636 * but do NOT otherwise enter a low power device state, and do 639 * but do NOT otherwise enter a low power device state, and do
637 * NOT emit system wakeup events. 640 * NOT emit system wakeup events.
638 * 641 *
639 * PRETHAW Quiesce as if for FREEZE; additionally, prepare for restoring 642 * PRETHAW Quiesce as if for FREEZE; additionally, prepare for restoring
640 * the system from a snapshot taken after an earlier FREEZE. 643 * the system from a snapshot taken after an earlier FREEZE.
641 * Some drivers will need to reset their hardware state instead 644 * Some drivers will need to reset their hardware state instead
642 * of preserving it, to ensure that it's never mistaken for the 645 * of preserving it, to ensure that it's never mistaken for the
643 * state which that earlier snapshot had set up. 646 * state which that earlier snapshot had set up.
644 * 647 *
645 * A minimally power-aware driver treats all messages as SUSPEND, fully 648 * A minimally power-aware driver treats all messages as SUSPEND, fully
646 * reinitializes its device during resume() -- whether or not it was reset 649 * reinitializes its device during resume() -- whether or not it was reset
@@ -717,14 +720,26 @@ static inline void dpm_for_each_dev(void *data, void (*fn)(struct device *, void
717{ 720{
718} 721}
719 722
720#define pm_generic_prepare NULL 723#define pm_generic_prepare NULL
721#define pm_generic_suspend NULL 724#define pm_generic_suspend_late NULL
722#define pm_generic_resume NULL 725#define pm_generic_suspend_noirq NULL
723#define pm_generic_freeze NULL 726#define pm_generic_suspend NULL
724#define pm_generic_thaw NULL 727#define pm_generic_resume_early NULL
725#define pm_generic_restore NULL 728#define pm_generic_resume_noirq NULL
726#define pm_generic_poweroff NULL 729#define pm_generic_resume NULL
727#define pm_generic_complete NULL 730#define pm_generic_freeze_noirq NULL
731#define pm_generic_freeze_late NULL
732#define pm_generic_freeze NULL
733#define pm_generic_thaw_noirq NULL
734#define pm_generic_thaw_early NULL
735#define pm_generic_thaw NULL
736#define pm_generic_restore_noirq NULL
737#define pm_generic_restore_early NULL
738#define pm_generic_restore NULL
739#define pm_generic_poweroff_noirq NULL
740#define pm_generic_poweroff_late NULL
741#define pm_generic_poweroff NULL
742#define pm_generic_complete NULL
728#endif /* !CONFIG_PM_SLEEP */ 743#endif /* !CONFIG_PM_SLEEP */
729 744
730/* How to reorder dpm_list after device_move() */ 745/* How to reorder dpm_list after device_move() */
diff --git a/include/linux/pm_qos.h b/include/linux/pm_qos.h
index 5a95013905c8..9ab4bf7c4646 100644
--- a/include/linux/pm_qos.h
+++ b/include/linux/pm_qos.h
@@ -32,7 +32,10 @@ enum pm_qos_flags_status {
32#define PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC) 32#define PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC)
33#define PM_QOS_NETWORK_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC) 33#define PM_QOS_NETWORK_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC)
34#define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0 34#define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0
35#define PM_QOS_DEV_LAT_DEFAULT_VALUE 0 35#define PM_QOS_RESUME_LATENCY_DEFAULT_VALUE 0
36#define PM_QOS_LATENCY_TOLERANCE_DEFAULT_VALUE 0
37#define PM_QOS_LATENCY_TOLERANCE_NO_CONSTRAINT (-1)
38#define PM_QOS_LATENCY_ANY ((s32)(~(__u32)0 >> 1))
36 39
37#define PM_QOS_FLAG_NO_POWER_OFF (1 << 0) 40#define PM_QOS_FLAG_NO_POWER_OFF (1 << 0)
38#define PM_QOS_FLAG_REMOTE_WAKEUP (1 << 1) 41#define PM_QOS_FLAG_REMOTE_WAKEUP (1 << 1)
@@ -49,7 +52,8 @@ struct pm_qos_flags_request {
49}; 52};
50 53
51enum dev_pm_qos_req_type { 54enum dev_pm_qos_req_type {
52 DEV_PM_QOS_LATENCY = 1, 55 DEV_PM_QOS_RESUME_LATENCY = 1,
56 DEV_PM_QOS_LATENCY_TOLERANCE,
53 DEV_PM_QOS_FLAGS, 57 DEV_PM_QOS_FLAGS,
54}; 58};
55 59
@@ -77,6 +81,7 @@ struct pm_qos_constraints {
77 struct plist_head list; 81 struct plist_head list;
78 s32 target_value; /* Do not change to 64 bit */ 82 s32 target_value; /* Do not change to 64 bit */
79 s32 default_value; 83 s32 default_value;
84 s32 no_constraint_value;
80 enum pm_qos_type type; 85 enum pm_qos_type type;
81 struct blocking_notifier_head *notifiers; 86 struct blocking_notifier_head *notifiers;
82}; 87};
@@ -87,9 +92,11 @@ struct pm_qos_flags {
87}; 92};
88 93
89struct dev_pm_qos { 94struct dev_pm_qos {
90 struct pm_qos_constraints latency; 95 struct pm_qos_constraints resume_latency;
96 struct pm_qos_constraints latency_tolerance;
91 struct pm_qos_flags flags; 97 struct pm_qos_flags flags;
92 struct dev_pm_qos_request *latency_req; 98 struct dev_pm_qos_request *resume_latency_req;
99 struct dev_pm_qos_request *latency_tolerance_req;
93 struct dev_pm_qos_request *flags_req; 100 struct dev_pm_qos_request *flags_req;
94}; 101};
95 102
@@ -142,7 +149,8 @@ int dev_pm_qos_remove_global_notifier(struct notifier_block *notifier);
142void dev_pm_qos_constraints_init(struct device *dev); 149void dev_pm_qos_constraints_init(struct device *dev);
143void dev_pm_qos_constraints_destroy(struct device *dev); 150void dev_pm_qos_constraints_destroy(struct device *dev);
144int dev_pm_qos_add_ancestor_request(struct device *dev, 151int dev_pm_qos_add_ancestor_request(struct device *dev,
145 struct dev_pm_qos_request *req, s32 value); 152 struct dev_pm_qos_request *req,
153 enum dev_pm_qos_req_type type, s32 value);
146#else 154#else
147static inline enum pm_qos_flags_status __dev_pm_qos_flags(struct device *dev, 155static inline enum pm_qos_flags_status __dev_pm_qos_flags(struct device *dev,
148 s32 mask) 156 s32 mask)
@@ -185,7 +193,9 @@ static inline void dev_pm_qos_constraints_destroy(struct device *dev)
185 dev->power.power_state = PMSG_INVALID; 193 dev->power.power_state = PMSG_INVALID;
186} 194}
187static inline int dev_pm_qos_add_ancestor_request(struct device *dev, 195static inline int dev_pm_qos_add_ancestor_request(struct device *dev,
188 struct dev_pm_qos_request *req, s32 value) 196 struct dev_pm_qos_request *req,
197 enum dev_pm_qos_req_type type,
198 s32 value)
189 { return 0; } 199 { return 0; }
190#endif 200#endif
191 201
@@ -195,10 +205,12 @@ void dev_pm_qos_hide_latency_limit(struct device *dev);
195int dev_pm_qos_expose_flags(struct device *dev, s32 value); 205int dev_pm_qos_expose_flags(struct device *dev, s32 value);
196void dev_pm_qos_hide_flags(struct device *dev); 206void dev_pm_qos_hide_flags(struct device *dev);
197int dev_pm_qos_update_flags(struct device *dev, s32 mask, bool set); 207int dev_pm_qos_update_flags(struct device *dev, s32 mask, bool set);
208s32 dev_pm_qos_get_user_latency_tolerance(struct device *dev);
209int dev_pm_qos_update_user_latency_tolerance(struct device *dev, s32 val);
198 210
199static inline s32 dev_pm_qos_requested_latency(struct device *dev) 211static inline s32 dev_pm_qos_requested_resume_latency(struct device *dev)
200{ 212{
201 return dev->power.qos->latency_req->data.pnode.prio; 213 return dev->power.qos->resume_latency_req->data.pnode.prio;
202} 214}
203 215
204static inline s32 dev_pm_qos_requested_flags(struct device *dev) 216static inline s32 dev_pm_qos_requested_flags(struct device *dev)
@@ -214,8 +226,12 @@ static inline int dev_pm_qos_expose_flags(struct device *dev, s32 value)
214static inline void dev_pm_qos_hide_flags(struct device *dev) {} 226static inline void dev_pm_qos_hide_flags(struct device *dev) {}
215static inline int dev_pm_qos_update_flags(struct device *dev, s32 m, bool set) 227static inline int dev_pm_qos_update_flags(struct device *dev, s32 m, bool set)
216 { return 0; } 228 { return 0; }
229static inline s32 dev_pm_qos_get_user_latency_tolerance(struct device *dev)
230 { return PM_QOS_LATENCY_TOLERANCE_NO_CONSTRAINT; }
231static inline int dev_pm_qos_update_user_latency_tolerance(struct device *dev, s32 val)
232 { return 0; }
217 233
218static inline s32 dev_pm_qos_requested_latency(struct device *dev) { return 0; } 234static inline s32 dev_pm_qos_requested_resume_latency(struct device *dev) { return 0; }
219static inline s32 dev_pm_qos_requested_flags(struct device *dev) { return 0; } 235static inline s32 dev_pm_qos_requested_flags(struct device *dev) { return 0; }
220#endif 236#endif
221 237
diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
index 16c9a62fa1c0..2a5897a4afbc 100644
--- a/include/linux/pm_runtime.h
+++ b/include/linux/pm_runtime.h
@@ -26,9 +26,13 @@
26#ifdef CONFIG_PM 26#ifdef CONFIG_PM
27extern int pm_generic_runtime_suspend(struct device *dev); 27extern int pm_generic_runtime_suspend(struct device *dev);
28extern int pm_generic_runtime_resume(struct device *dev); 28extern int pm_generic_runtime_resume(struct device *dev);
29extern int pm_runtime_force_suspend(struct device *dev);
30extern int pm_runtime_force_resume(struct device *dev);
29#else 31#else
30static inline int pm_generic_runtime_suspend(struct device *dev) { return 0; } 32static inline int pm_generic_runtime_suspend(struct device *dev) { return 0; }
31static inline int pm_generic_runtime_resume(struct device *dev) { return 0; } 33static inline int pm_generic_runtime_resume(struct device *dev) { return 0; }
34static inline int pm_runtime_force_suspend(struct device *dev) { return 0; }
35static inline int pm_runtime_force_resume(struct device *dev) { return 0; }
32#endif 36#endif
33 37
34#ifdef CONFIG_PM_RUNTIME 38#ifdef CONFIG_PM_RUNTIME
diff --git a/include/linux/video_output.h b/include/linux/video_output.h
deleted file mode 100644
index ed5cdeb3604d..000000000000
--- a/include/linux/video_output.h
+++ /dev/null
@@ -1,57 +0,0 @@
1/*
2 *
3 * Copyright (C) 2006 Luming Yu <luming.yu@intel.com>
4 *
5 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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 as published by
9 * the Free Software Foundation; either version 2 of the License, or (at
10 * your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20 *
21 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22 */
23#ifndef _LINUX_VIDEO_OUTPUT_H
24#define _LINUX_VIDEO_OUTPUT_H
25#include <linux/device.h>
26#include <linux/err.h>
27struct output_device;
28struct output_properties {
29 int (*set_state)(struct output_device *);
30 int (*get_status)(struct output_device *);
31};
32struct output_device {
33 int request_state;
34 struct output_properties *props;
35 struct device dev;
36};
37#define to_output_device(obj) container_of(obj, struct output_device, dev)
38#if defined(CONFIG_VIDEO_OUTPUT_CONTROL) || defined(CONFIG_VIDEO_OUTPUT_CONTROL_MODULE)
39struct output_device *video_output_register(const char *name,
40 struct device *dev,
41 void *devdata,
42 struct output_properties *op);
43void video_output_unregister(struct output_device *dev);
44#else
45static struct output_device *video_output_register(const char *name,
46 struct device *dev,
47 void *devdata,
48 struct output_properties *op)
49{
50 return ERR_PTR(-ENODEV);
51}
52static void video_output_unregister(struct output_device *dev)
53{
54 return;
55}
56#endif
57#endif
diff --git a/include/trace/events/power.h b/include/trace/events/power.h
index e5bf9a76f169..9a7e08d61258 100644
--- a/include/trace/events/power.h
+++ b/include/trace/events/power.h
@@ -407,8 +407,8 @@ DECLARE_EVENT_CLASS(dev_pm_qos_request,
407 TP_printk("device=%s type=%s new_value=%d", 407 TP_printk("device=%s type=%s new_value=%d",
408 __get_str(name), 408 __get_str(name),
409 __print_symbolic(__entry->type, 409 __print_symbolic(__entry->type,
410 { DEV_PM_QOS_LATENCY, "DEV_PM_QOS_LATENCY" }, 410 { DEV_PM_QOS_RESUME_LATENCY, "DEV_PM_QOS_RESUME_LATENCY" },
411 { DEV_PM_QOS_FLAGS, "DEV_PM_QOS_FLAGS" }), 411 { DEV_PM_QOS_FLAGS, "DEV_PM_QOS_FLAGS" }),
412 __entry->new_value) 412 __entry->new_value)
413); 413);
414 414
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index 37170d4dd9a6..f4f2073711d3 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -973,16 +973,20 @@ static ssize_t resume_show(struct kobject *kobj, struct kobj_attribute *attr,
973static ssize_t resume_store(struct kobject *kobj, struct kobj_attribute *attr, 973static ssize_t resume_store(struct kobject *kobj, struct kobj_attribute *attr,
974 const char *buf, size_t n) 974 const char *buf, size_t n)
975{ 975{
976 unsigned int maj, min;
977 dev_t res; 976 dev_t res;
978 int ret = -EINVAL; 977 int len = n;
978 char *name;
979 979
980 if (sscanf(buf, "%u:%u", &maj, &min) != 2) 980 if (len && buf[len-1] == '\n')
981 goto out; 981 len--;
982 name = kstrndup(buf, len, GFP_KERNEL);
983 if (!name)
984 return -ENOMEM;
982 985
983 res = MKDEV(maj,min); 986 res = name_to_dev_t(name);
984 if (maj != MAJOR(res) || min != MINOR(res)) 987 kfree(name);
985 goto out; 988 if (!res)
989 return -EINVAL;
986 990
987 lock_system_sleep(); 991 lock_system_sleep();
988 swsusp_resume_device = res; 992 swsusp_resume_device = res;
@@ -990,9 +994,7 @@ static ssize_t resume_store(struct kobject *kobj, struct kobj_attribute *attr,
990 printk(KERN_INFO "PM: Starting manual resume from disk\n"); 994 printk(KERN_INFO "PM: Starting manual resume from disk\n");
991 noresume = 0; 995 noresume = 0;
992 software_resume(); 996 software_resume();
993 ret = n; 997 return n;
994 out:
995 return ret;
996} 998}
997 999
998power_attr(resume); 1000power_attr(resume);
diff --git a/kernel/power/main.c b/kernel/power/main.c
index 1d1bf630e6e9..6271bc4073ef 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -282,8 +282,8 @@ struct kobject *power_kobj;
282 * state - control system power state. 282 * state - control system power state.
283 * 283 *
284 * show() returns what states are supported, which is hard-coded to 284 * show() returns what states are supported, which is hard-coded to
285 * 'standby' (Power-On Suspend), 'mem' (Suspend-to-RAM), and 285 * 'freeze' (Low-Power Idle), 'standby' (Power-On Suspend),
286 * 'disk' (Suspend-to-Disk). 286 * 'mem' (Suspend-to-RAM), and 'disk' (Suspend-to-Disk).
287 * 287 *
288 * store() accepts one of those strings, translates it into the 288 * store() accepts one of those strings, translates it into the
289 * proper enumerated value, and initiates a suspend transition. 289 * proper enumerated value, and initiates a suspend transition.
diff --git a/kernel/power/power.h b/kernel/power/power.h
index 7d4b7ffb3c1d..1ca753106557 100644
--- a/kernel/power/power.h
+++ b/kernel/power/power.h
@@ -49,6 +49,8 @@ static inline char *check_image_kernel(struct swsusp_info *info)
49 */ 49 */
50#define SPARE_PAGES ((1024 * 1024) >> PAGE_SHIFT) 50#define SPARE_PAGES ((1024 * 1024) >> PAGE_SHIFT)
51 51
52asmlinkage int swsusp_save(void);
53
52/* kernel/power/hibernate.c */ 54/* kernel/power/hibernate.c */
53extern bool freezer_test_done; 55extern bool freezer_test_done;
54 56
diff --git a/kernel/power/qos.c b/kernel/power/qos.c
index 8dff9b48075a..884b77058864 100644
--- a/kernel/power/qos.c
+++ b/kernel/power/qos.c
@@ -66,6 +66,7 @@ static struct pm_qos_constraints cpu_dma_constraints = {
66 .list = PLIST_HEAD_INIT(cpu_dma_constraints.list), 66 .list = PLIST_HEAD_INIT(cpu_dma_constraints.list),
67 .target_value = PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE, 67 .target_value = PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE,
68 .default_value = PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE, 68 .default_value = PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE,
69 .no_constraint_value = PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE,
69 .type = PM_QOS_MIN, 70 .type = PM_QOS_MIN,
70 .notifiers = &cpu_dma_lat_notifier, 71 .notifiers = &cpu_dma_lat_notifier,
71}; 72};
@@ -79,6 +80,7 @@ static struct pm_qos_constraints network_lat_constraints = {
79 .list = PLIST_HEAD_INIT(network_lat_constraints.list), 80 .list = PLIST_HEAD_INIT(network_lat_constraints.list),
80 .target_value = PM_QOS_NETWORK_LAT_DEFAULT_VALUE, 81 .target_value = PM_QOS_NETWORK_LAT_DEFAULT_VALUE,
81 .default_value = PM_QOS_NETWORK_LAT_DEFAULT_VALUE, 82 .default_value = PM_QOS_NETWORK_LAT_DEFAULT_VALUE,
83 .no_constraint_value = PM_QOS_NETWORK_LAT_DEFAULT_VALUE,
82 .type = PM_QOS_MIN, 84 .type = PM_QOS_MIN,
83 .notifiers = &network_lat_notifier, 85 .notifiers = &network_lat_notifier,
84}; 86};
@@ -93,6 +95,7 @@ static struct pm_qos_constraints network_tput_constraints = {
93 .list = PLIST_HEAD_INIT(network_tput_constraints.list), 95 .list = PLIST_HEAD_INIT(network_tput_constraints.list),
94 .target_value = PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE, 96 .target_value = PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE,
95 .default_value = PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE, 97 .default_value = PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE,
98 .no_constraint_value = PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE,
96 .type = PM_QOS_MAX, 99 .type = PM_QOS_MAX,
97 .notifiers = &network_throughput_notifier, 100 .notifiers = &network_throughput_notifier,
98}; 101};
@@ -128,7 +131,7 @@ static const struct file_operations pm_qos_power_fops = {
128static inline int pm_qos_get_value(struct pm_qos_constraints *c) 131static inline int pm_qos_get_value(struct pm_qos_constraints *c)
129{ 132{
130 if (plist_head_empty(&c->list)) 133 if (plist_head_empty(&c->list))
131 return c->default_value; 134 return c->no_constraint_value;
132 135
133 switch (c->type) { 136 switch (c->type) {
134 case PM_QOS_MIN: 137 case PM_QOS_MIN:
@@ -170,6 +173,7 @@ int pm_qos_update_target(struct pm_qos_constraints *c, struct plist_node *node,
170{ 173{
171 unsigned long flags; 174 unsigned long flags;
172 int prev_value, curr_value, new_value; 175 int prev_value, curr_value, new_value;
176 int ret;
173 177
174 spin_lock_irqsave(&pm_qos_lock, flags); 178 spin_lock_irqsave(&pm_qos_lock, flags);
175 prev_value = pm_qos_get_value(c); 179 prev_value = pm_qos_get_value(c);
@@ -205,13 +209,15 @@ int pm_qos_update_target(struct pm_qos_constraints *c, struct plist_node *node,
205 209
206 trace_pm_qos_update_target(action, prev_value, curr_value); 210 trace_pm_qos_update_target(action, prev_value, curr_value);
207 if (prev_value != curr_value) { 211 if (prev_value != curr_value) {
208 blocking_notifier_call_chain(c->notifiers, 212 ret = 1;
209 (unsigned long)curr_value, 213 if (c->notifiers)
210 NULL); 214 blocking_notifier_call_chain(c->notifiers,
211 return 1; 215 (unsigned long)curr_value,
216 NULL);
212 } else { 217 } else {
213 return 0; 218 ret = 0;
214 } 219 }
220 return ret;
215} 221}
216 222
217/** 223/**
diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c
index d9f61a145802..149e745eaa52 100644
--- a/kernel/power/snapshot.c
+++ b/kernel/power/snapshot.c
@@ -1268,7 +1268,7 @@ static void free_unnecessary_pages(void)
1268 * [number of saveable pages] - [number of pages that can be freed in theory] 1268 * [number of saveable pages] - [number of pages that can be freed in theory]
1269 * 1269 *
1270 * where the second term is the sum of (1) reclaimable slab pages, (2) active 1270 * where the second term is the sum of (1) reclaimable slab pages, (2) active
1271 * and (3) inactive anonymouns pages, (4) active and (5) inactive file pages, 1271 * and (3) inactive anonymous pages, (4) active and (5) inactive file pages,
1272 * minus mapped file pages. 1272 * minus mapped file pages.
1273 */ 1273 */
1274static unsigned long minimum_image_size(unsigned long saveable) 1274static unsigned long minimum_image_size(unsigned long saveable)
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index 62ee437b5c7e..90b3d9366d1a 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -39,7 +39,7 @@ static const struct platform_suspend_ops *suspend_ops;
39 39
40static bool need_suspend_ops(suspend_state_t state) 40static bool need_suspend_ops(suspend_state_t state)
41{ 41{
42 return !!(state > PM_SUSPEND_FREEZE); 42 return state > PM_SUSPEND_FREEZE;
43} 43}
44 44
45static DECLARE_WAIT_QUEUE_HEAD(suspend_freeze_wait_head); 45static DECLARE_WAIT_QUEUE_HEAD(suspend_freeze_wait_head);
diff --git a/kernel/power/wakelock.c b/kernel/power/wakelock.c
index 8f50de394d22..019069c84ff6 100644
--- a/kernel/power/wakelock.c
+++ b/kernel/power/wakelock.c
@@ -18,6 +18,8 @@
18#include <linux/rbtree.h> 18#include <linux/rbtree.h>
19#include <linux/slab.h> 19#include <linux/slab.h>
20 20
21#include "power.h"
22
21static DEFINE_MUTEX(wakelocks_lock); 23static DEFINE_MUTEX(wakelocks_lock);
22 24
23struct wakelock { 25struct wakelock {