acpi: ec_sys: access user space with get_user()/put_user()

User space pointer may not be dereferenced. Use get_user()/put_user()
instead and check their return codes.

Signed-off-by: Vasiliy Kulikov <segooon@gmail.com>
Signed-off-by: Thomas Renninger <trenn@suse.de>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPI / resources: call acpi_get_override_irq() only for legacy IRQ resources

acpi_get_override_irq() was added because there was a problem with buggy
BIOSes passing wrong IRQ() resource for the RTC IRQ. Commit that added
the workaround is 61fd47e0c8476 (ACPI: fix two IRQ8 issues in IOAPIC
mode).

With ACPI 5 enumerated devices there are typically one or more extended IRQ
resources for a device (and these IRQs can be shared). However, the
acpi_get_override_irq() workaround forces all IRQs in range 0 - 15 (the
legacy ISA IRQs) to be edge triggered, active high as can be seen from the
dmesg below:

	ACPI: IRQ 6 override to edge, high
	ACPI: IRQ 7 override to edge, high
	ACPI: IRQ 7 override to edge, high
	ACPI: IRQ 13 override to edge, high

Also /proc/interrupts for the I2C controllers (INT33C2 and INT33C3) shows
the same thing:

	7:          4          0          0          0   IO-APIC-edge INT33C2:00, INT33C3:00

The _CSR method for INT33C2 (and INT33C3) device returns following
resource:

	Interrupt (ResourceConsumer, Level, ActiveLow, Shared,,, )
	{
		0x00000007,
	}

which states that this is supposed to be level triggered, active low,
shared IRQ instead.

Fix this by making sure that acpi_get_override_irq() gets only called when
we are dealing with legacy IRQ() or IRQNoFlags() descriptors.

While we are there correct pr_warning() to print the right triggering
value.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPI: implement acpi_os_get_timer() in accordance with the spec

ACPI Timer() opcode should return monotonically increasing clock with 100ns
granularity according the ACPI 5.0 spec.

Testing the current Timer() implementation with following ASL code (and an
additional debug print in acpi_os_sleep() to get the sleep times dumped out
to dmesg):

	// Test: 10ms
	Store(Timer, Local1)
	Sleep(10)
	Divide(Subtract(Timer, Local1), 10000,, Local1)
	Sleep(Local1)

	// Test: 200ms
	Store(Timer, Local1)
	Sleep(200)
	Divide(Subtract(Timer, Local1), 10000,, Local1)
	Sleep(Local1)

	// Test 1300ms
	Store(Timer, Local1)
	Sleep(1300)
	Divide(Subtract(Timer, Local1), 10000,, Local1)
	Sleep(Local1)

The second sleep value is calculated using Timer(). If the implementation
is good enough we should be able to get the second value pretty close to
the first.

However, the current Timer() gives pretty bad sleep times:

	[   11.488100] ACPI: acpi_os_get_timer() TBD
	[   11.492150] ACPI: Sleep(10)
	[   11.502993] ACPI: Sleep(0)
	[   11.506315] ACPI: Sleep(200)
	[   11.706237] ACPI: Sleep(0)
	[   11.709550] ACPI: Sleep(1300)
	[   13.008929] ACPI: Sleep(0)

Fix this with the help of ktime_get(). Once the fix is applied and run
against the same ASL code we get:

	[   11.486786] ACPI: Sleep(10)
	[   11.499029] ACPI: Sleep(12)
	[   11.512350] ACPI: Sleep(200)
	[   11.712282] ACPI: Sleep(200)
	[   11.912170] ACPI: Sleep(1300)
	[   13.211577] ACPI: Sleep(1300)

That is much more closer to the values we expected.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
x86 / ACPI / sleep: Provide registration for acpi_suspend_lowlevel.

Which by default will be x86_acpi_suspend_lowlevel.
This registration allows us to register another callback
if there is a need to use another platform specific callback.

Signed-off-by: Liang Tang <liang.tang@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Tested-by: Ben Guthro <benjamin.guthro@citrix.com>
Acked-by: "H. Peter Anvin" <hpa@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
xen / ACPI / sleep: Register an acpi_suspend_lowlevel callback.

We piggyback on "x86/acpi: Provide registration for acpi_suspend_lowlevel."
to register a Xen version of the callback. The callback does not
do anything special - except it omits the x86_acpi_suspend_lowlevel.

This is necessary b/c during suspend the generic code tries to write
cr3 values that clashes with what the hypervisor has set up for the guest.

Signed-off-by: Liang Tang <liang.tang@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Tested-by: Ben Guthro <benjamin.guthro@citrix.com>
Acked-by: H. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPI / video: Add "Asus UL30A" to ACPI video detect blacklist

Like on UL30VT, the ACPI video driver can't control backlight correctly on
Asus UL30A.  Vendor driver (asus-laptop) can work.  This patch is to
add "Asus UL30A" to ACPI video detect blacklist in order to use
asus-laptop for video control on the "Asus UL30A" rather than ACPI
video driver.

Signed-off-by: Bastian Triller <bastian.triller@gmail.com>
Cc: All <stable@vger.kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Merge branch 'acpi-fixes-next' into linux-next

* acpi-fixes-next:
  ACPI / video: Add "Asus UL30A" to ACPI video detect blacklist
Merge branch 'pm-cpufreq-fixes-next' into linux-next

* pm-cpufreq-fixes-next:
  cpufreq: arm_big_little_dt: Instantiate as platform_driver
  cpufreq: arm_big_little_dt: Register driver only if DT has valid data
  cpufreq / e_powersaver: Fix linker error when ACPI processor is a module
  cpufreq / intel_pstate: Add additional supported CPU ID
  cpufreq: Drop rwsem lock around CPUFREQ_GOV_POLICY_EXIT
Merge branch 'linux-next' into bleeding-edge

* linux-next:
  ACPI / video: Add "Asus UL30A" to ACPI video detect blacklist
ACPI / APEI: Update EINJ documentation for param1/param2

To ensure EINJ working well when injecting errors via EINJ
table, add some attentions for param1/param2.

Signed-off-by: Chen Gong <gong.chen@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Merge branch 'acpi-assorted-next' into bleeding-edge

* acpi-assorted-next:
  ACPI / APEI: Update EINJ documentation for param1/param2
  xen / ACPI / sleep: Register an acpi_suspend_lowlevel callback.
  x86 / ACPI / sleep: Provide registration for acpi_suspend_lowlevel.
  ACPI: implement acpi_os_get_timer() in accordance with the spec
  ACPI / resources: call acpi_get_override_irq() only for legacy IRQ resources
  acpi: ec_sys: access user space with get_user()/put_user()