platform/kernel/linux-starfive.git
7 years agoMerge branch 'psy-arm-at91-immutable' into psy-next
Sebastian Reichel [Mon, 16 Jan 2017 22:22:53 +0000 (23:22 +0100)]
Merge branch 'psy-arm-at91-immutable' into psy-next

7 years agopower: reset: at91-poweroff: timely shutdown LPDDR memories
Alexandre Belloni [Tue, 25 Oct 2016 09:37:59 +0000 (11:37 +0200)]
power: reset: at91-poweroff: timely shutdown LPDDR memories

LPDDR memories can only handle up to 400 uncontrolled power off. Ensure the
proper power off sequence is used before shutting down the platform.

Cc: <stable@vger.kernel.org> # 4.4+
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agoARM: at91: define LPDDR types
Alexandre Belloni [Tue, 25 Oct 2016 09:37:58 +0000 (11:37 +0200)]
ARM: at91: define LPDDR types

The Atmel MPDDR controller support LPDDR2 and LPDDR3 memories, add their
types.

Cc: <stable@vger.kernel.org> # 4.4+
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: Add support for MAX14656 USB charger detector
Alexander Kurz [Wed, 19 Oct 2016 16:04:49 +0000 (18:04 +0200)]
power: supply: Add support for MAX14656 USB charger detector

The MAX14656 USB charger detector, also known as "AL32" is used to detect
the presence and capabilities of attached USB chargers. The device is
attached via I2C plus one interrupt line to signalize events.

The device can be found in LG smartphones like LS665 and LS770, compatible
devices are present in 4th/5th generation Amazon Kindle readers referenced
in source code packages as "Maxim AL32".

The initial version of this driver has been extracted from LG source code
package LGLS665_Android_Lollipop_LS665ZV3, enriched with information from
the Kindle_src_4.1.3 source code package and adapted to the current power
class sysfs interface. Non-Standard Apple chargers which the device may
detect are mapped to the USB Battery Charging Specification Revision 1.2
class USB_DCP.

Signed-off-by: Alexander Kurz <akurz@blala.de>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agodt-bindings: power: supply: Add max14656_charger_detector
Alexander Kurz [Wed, 19 Oct 2016 16:04:48 +0000 (18:04 +0200)]
dt-bindings: power: supply: Add max14656_charger_detector

Signed-off-by: Alexander Kurz <akurz@blala.de>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: qcom_smbb: Add otg regulator for control of vbus
Bird, Tim [Tue, 18 Oct 2016 00:42:51 +0000 (17:42 -0700)]
power: supply: qcom_smbb: Add otg regulator for control of vbus

Add a regulator to control the OTG chargepath switch.  This
is used by USB code to control VBUS direction - out for host mode
on the OTG port, and in for charging mode.

Signed-off-by: Tim Bird <tim.bird@sonymobile.com>
Acked-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
Reviewed-by: Andy Gross <andy.gross@linaro.org>
[stephen.boyd@linaro.org: Fix supply name, constify ops, drop
machine.h and of_regulator.h includes]
Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agodt-bindings: power: supply: Add otg regulator binding
Bird, Tim [Tue, 18 Oct 2016 00:42:50 +0000 (17:42 -0700)]
dt-bindings: power: supply: Add otg regulator binding

Add a binding for the regulator which controls the OTG chargepath switch.
The OTG switch gets its power from pm8941_5vs1, and that should be
expressed as a usb_otg_in-supply property in the DT node for the
charger driver.  The regulator name is "otg-vbus".

Signed-off-by: Tim Bird <tim.bird@sonymobile.com>
Acked-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
Reviewed-by: Andy Gross <andy.gross@linaro.org>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: bq27xxx: adds device tree binding documentation.
Chris Lapa [Wed, 11 Jan 2017 01:44:48 +0000 (12:44 +1100)]
power: supply: bq27xxx: adds device tree binding documentation.

The bq27xxx binding is a standard i2c style binding, however the
deprecated compatible fields and different revisions warrant its own
documentation.

Signed-off-by: Chris Lapa <chris@lapa.com.au>
Acked-by: Pali Rohár <pali.rohar@gmail.com>
Reviewed-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: bq27xxx: adds specific support for bq27520-g4 revision.
Chris Lapa [Wed, 11 Jan 2017 01:44:47 +0000 (12:44 +1100)]
power: supply: bq27xxx: adds specific support for bq27520-g4 revision.

This commit adds the BQ27520G4 chip definition to specifically match the
bq27520-G4 functionality as described in the datasheet.

Signed-off-by: Chris Lapa <chris@lapa.com.au>
Acked-by: Pali Rohár <pali.rohar@gmail.com>
Reviewed-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: bq27xxx: adds specific support for bq27520-g3 revision.
Chris Lapa [Wed, 11 Jan 2017 01:44:46 +0000 (12:44 +1100)]
power: supply: bq27xxx: adds specific support for bq27520-g3 revision.

This commit adds the BQ27520G3 chip definition to specifically match the
bq27520-G3 functionality as described in the datasheet.

Signed-off-by: Chris Lapa <chris@lapa.com.au>
Acked-by: Pali Rohár <pali.rohar@gmail.com>
Reviewed-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: bq27xxx: adds specific support for bq27520-g2 revision.
Chris Lapa [Wed, 11 Jan 2017 01:44:45 +0000 (12:44 +1100)]
power: supply: bq27xxx: adds specific support for bq27520-g2 revision.

This commit adds the BQ27520G2 chip definition to specifically match the
bq27520-G2 functionality as described in the datasheet.

Signed-off-by: Chris Lapa <chris@lapa.com.au>
Acked-by: Pali Rohár <pali.rohar@gmail.com>
Reviewed-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: bq27xxx: adds specific support for bq27520-g1 revision.
Chris Lapa [Wed, 11 Jan 2017 01:44:44 +0000 (12:44 +1100)]
power: supply: bq27xxx: adds specific support for bq27520-g1 revision.

This commit adds the BQ27520G1 chip definition to specifically match the
bq27520-G1 functionality as described in the datasheet.

Signed-off-by: Chris Lapa <chris@lapa.com.au>
Acked-by: Pali Rohár <pali.rohar@gmail.com>
Reviewed-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: bq27xxx: adds specific support for bq27510-g3 revision.
Chris Lapa [Wed, 11 Jan 2017 01:44:43 +0000 (12:44 +1100)]
power: supply: bq27xxx: adds specific support for bq27510-g3 revision.

This commit adds the BQ27510G3 chip definition to specifically match the
bq27510-G3 functionality as described in the datasheet.

Signed-off-by: Chris Lapa <chris@lapa.com.au>
Acked-by: Pali Rohár <pali.rohar@gmail.com>
Reviewed-by: Andrew F. Davis <afd@ti.com>
Tested-by: Chris Lapa <chris@lapa.com.au>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: bq27xxx: adds specific support for bq27510-g2 revision.
Chris Lapa [Wed, 11 Jan 2017 01:44:42 +0000 (12:44 +1100)]
power: supply: bq27xxx: adds specific support for bq27510-g2 revision.

This commit adds the BQ27510G2 chip definition to specifically match the
bq27510-G2 functionality as described in the datasheet.

Signed-off-by: Chris Lapa <chris@lapa.com.au>
Acked-by: Pali Rohár <pali.rohar@gmail.com>
Reviewed-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: bq27xxx: adds specific support for bq27510-g1 revision.
Chris Lapa [Wed, 11 Jan 2017 01:44:41 +0000 (12:44 +1100)]
power: supply: bq27xxx: adds specific support for bq27510-g1 revision.

This commit adds the BQ27510G1 chip definition to specifically match the
bq27510-G1 functionality as described in the datasheet.

Signed-off-by: Chris Lapa <chris@lapa.com.au>
Acked-by: Pali Rohár <pali.rohar@gmail.com>
Reviewed-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: bq27xxx: adds specific support for bq27500/1 revision.
Chris Lapa [Wed, 11 Jan 2017 01:44:40 +0000 (12:44 +1100)]
power: supply: bq27xxx: adds specific support for bq27500/1 revision.

This commit adds the BQ27500 chip definition to specifically match the
bq27500/1 functionality as described in the datasheet.

Signed-off-by: Chris Lapa <chris@lapa.com.au>
Acked-by: Pali Rohár <pali.rohar@gmail.com>
Reviewed-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: bq27xxx: rename BQ27510 allow for deprecation in future.
Chris Lapa [Wed, 11 Jan 2017 01:44:39 +0000 (12:44 +1100)]
power: supply: bq27xxx: rename BQ27510 allow for deprecation in future.

The BQ2751X definition exists only to satisfy backwards compatibility.

Signed-off-by: Chris Lapa <chris@lapa.com.au>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: bq27xxx: rename BQ27500 allow for deprecation in future.
Chris Lapa [Wed, 11 Jan 2017 01:44:38 +0000 (12:44 +1100)]
power: supply: bq27xxx: rename BQ27500 allow for deprecation in future.

The BQ2750X definition exists only to satisfy backwards compatibility.

Signed-off-by: Chris Lapa <chris@lapa.com.au>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: axp20x_usb_power: fix warning on 64bit
Michal Suchanek [Tue, 10 Jan 2017 17:48:12 +0000 (18:48 +0100)]
power: supply: axp20x_usb_power: fix warning on 64bit

Casting of_device_get_match_data return value to int causes warning on 64bit
architectures.

../drivers/power/supply/axp20x_usb_power.c: In function
'axp20x_usb_power_probe':
../drivers/power/supply/axp20x_usb_power.c:297:21: warning: cast from
pointer to integer of different size [-Wpointer-to-int-cast]

Fixes: 0dcc70ca8644 ("power: supply: axp20x_usb_power: use of_device_id
    data field instead of device_is_compatible")
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: bq27xxx: move overtemp tests to a switch statement.
Chris Lapa [Mon, 9 Jan 2017 00:47:35 +0000 (11:47 +1100)]
power: supply: bq27xxx: move overtemp tests to a switch statement.

This is done for readability as the upcoming commits will add a lot of
cases.

tested: no

Signed-off-by: Chris Lapa <chris@lapa.com.au>
Acked-by: Pali Rohár <pali.rohar@gmail.com>
Reviewed-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agodt-bindings: power: supply: Update TPS65217 properties
Milo Kim [Fri, 9 Dec 2016 06:28:32 +0000 (15:28 +0900)]
dt-bindings: power: supply: Update TPS65217 properties

Add interrupt specifiers for USB and AC charger input. Interrupt numbers
are from the datasheet.
Fix wrong property for compatible string.

Signed-off-by: Milo Kim <woogyom.kim@gmail.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: remove Intel Moorestown battery support
Andy Shevchenko [Thu, 5 Jan 2017 11:38:06 +0000 (13:38 +0200)]
power: supply: remove Intel Moorestown battery support

The Moorestown support was removed by commit 1a8359e411eb ("x86/mid: Remove
Intel Moorestown").

Remove this leftover.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: gpio_charger: switch to using GPIO descriptors
Linus Walleij [Mon, 26 Dec 2016 20:18:55 +0000 (21:18 +0100)]
power: supply: gpio_charger: switch to using GPIO descriptors

The GPIO charger is using a mix of the legacy GPIO interface
and <linux/of_gpio.h> which is not the modern way to use GPIOs.

Refactor like this:

- Use a GPIO descriptor for the GPIO line used to monitor the
  charger.
- Fetch the descriptor with devm_gpiod_get() as the first
  method.
- If this fails and we are *not* using device tree, then
  start looking to see if we can use platform data instead.
- After looking up and requesting a GPIO number with the
  legacy API, convert it to a descriptor.

This way we can later isolate and drop the legacy code as
more platforms move over to using descriptors.

Cc: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: fix spelling mistake: supply: "Celcius" -> "Celsius"
Colin Ian King [Wed, 28 Dec 2016 21:59:26 +0000 (21:59 +0000)]
power: supply: fix spelling mistake: supply: "Celcius" -> "Celsius"

trivial fix to spelling mistake in comments in the headers

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: wm97xx_battery: remove redundant 2nd null check on pdata
Colin Ian King [Thu, 29 Dec 2016 15:23:12 +0000 (15:23 +0000)]
power: supply: wm97xx_battery: remove redundant 2nd null check on pdata

pdata is being null checked twice, the 2nd check is redundant code
and can be removed.

Fixes CoverityScan CID 1392340 "Logically dead code"

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: axp288_fuel_gauge: Remove unnecessary irq?_en register writes
Hans de Goede [Thu, 22 Dec 2016 12:00:11 +0000 (13:00 +0100)]
power: supply: axp288_fuel_gauge: Remove unnecessary irq?_en register writes

Setting the irq_enable bits is taken care of by the irq chip when we
request the irqs and the driver should not be meddling with the
irq?_en registers itself.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: bq24735: bring down the noise level
Peter Rosin [Wed, 21 Dec 2016 21:29:53 +0000 (22:29 +0100)]
power: supply: bq24735: bring down the noise level

If there is no ti,ac-detect-gpios configured, it is normal to
have failed reads of the options register. So, hold back on the
log spamming.

Signed-off-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: bq24735: allow polling even if there is no ac-detect gpio
Peter Rosin [Wed, 21 Dec 2016 21:29:52 +0000 (22:29 +0100)]
power: supply: bq24735: allow polling even if there is no ac-detect gpio

It is possible to verify AC adapter presence via a register read, without
any physical connection to the ACOK pin on the charger. Allow this.

Signed-off-by: Peter Rosin <peda@axentia.se>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: axp288_charger: Use one notifier_block per extcon cable
Hans de Goede [Wed, 21 Dec 2016 17:28:23 +0000 (18:28 +0100)]
power: supply: axp288_charger: Use one notifier_block per extcon cable

Prior to this commit the code was using 1 notifier_block for all
types of charger cable, this is incorrect as the notifier_block
becomes part of a linked-list and now the same notifier_block
is part of 3 linked lists.

This commit fixes this by using a separate nb per extcon cable.

Note this happened to work fine sofar because axp288_charger was the only
listener, so when added to each of the 3 notifier chains, the next pointer
in the nb would be set to 0, so we've 3 heads pointing to the same nb,
with its next pointing to NULL. But as soon as we mix in a second extcon
consumer things will go boom.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: axp288_charger: Fix the module not auto-loading
Hans de Goede [Wed, 21 Dec 2016 14:36:57 +0000 (15:36 +0100)]
power: supply: axp288_charger: Fix the module not auto-loading

Add a MODULE_DEVICE_TABLE to fix the module not auto-loading.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: axp288_charger: Remove unnecessary irq?_en register writes
Hans de Goede [Wed, 21 Dec 2016 14:36:56 +0000 (15:36 +0100)]
power: supply: axp288_charger: Remove unnecessary irq?_en register writes

Setting the irq_enable bits is taken care of by the irq chip when we
request the irqs and the driver should not be meddling with the
irq?_en registers itself.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: axp288_charger: Fix wrong regmap_update_bits
Hans de Goede [Wed, 21 Dec 2016 14:36:55 +0000 (15:36 +0100)]
power: supply: axp288_charger: Fix wrong regmap_update_bits

To set a bit to 1 one needs to pass the mask for the bit to set
as second argument into regmap_update_bits, not "1".

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: axp288_charger: Get and process initial hardware-state
Hans de Goede [Wed, 21 Dec 2016 14:36:54 +0000 (15:36 +0100)]
power: supply: axp288_charger: Get and process initial hardware-state

Do not wait for an extcon notification before processing the cable
states, instead queue the otg / cable work on probe to make sure we
immediately process the initial hardware state.

Note this also requiree moving the getting of the USB_HOST cable state
from the extcon notifier to the workqueue function.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: axp288_charger: Some minor cleanups
Hans de Goede [Wed, 21 Dec 2016 14:36:53 +0000 (15:36 +0100)]
power: supply: axp288_charger: Some minor cleanups

Remove info->health, info->present and info->online caching, as no code
is reading the cached values.

Remove if (changed) check before calling power_supply_changed(), we
return early from axp288_charger_extcon_evt_worker if nothing has
changed, so the check is not needed.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: axp288_charger: Handle charger type changing without disconnect
Hans de Goede [Wed, 21 Dec 2016 14:36:52 +0000 (15:36 +0100)]
power: supply: axp288_charger: Handle charger type changing without disconnect

Deal with the charger type changing without a vbus-disconnect being
reported in between the 2 charger type states:

-Do not return from axp288_charger_extcon_evt_worker early in this case
 (track old_chg_type)
-Make calling axp288_charger_enable_charger with the same value as before
 a nop, to avoid the need for the caller to check this
-Do no do a dev_err when axp288_charger_enable_charger returns an error,
 axp288_charger_enable_charger already returns an error itself
-Disable the charger before changing the charge-current setting (nop if
 vbus was seen as disconnected before the change)

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: axp288_charger: Actually get and use the USB_HOST extcon device
Hans de Goede [Wed, 21 Dec 2016 14:36:51 +0000 (15:36 +0100)]
power: supply: axp288_charger: Actually get and use the USB_HOST extcon device

Nothing was setting info->otg.cable, so the extcon_get_cable_state_
calls on it would always return -EINVAL.

This commit fixes this by actually setting info->otg.cable using the new
extcon_get_extcon_dev_by_cable_id function.

This commit also makes failing to register the extcon notifier for the
USB_HOST cable an error rather then a warning, because we MUST have this
notfier to properly disable the VBUS path when in host mode so that we're
not drawing current from the 5V boost converter which is supplying power
to the otg port when in host mode.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: axp288_charger: Move init_hw_regs call before supply registration
Hans de Goede [Wed, 21 Dec 2016 14:36:50 +0000 (15:36 +0100)]
power: supply: axp288_charger: Move init_hw_regs call before supply registration

Move the charger_init_hw_regs() above the power_supply_register call,
the axp288_charger_usb_set_property() uses axp288_chrg_info.max_cv and
.max_cc which get set by charger_init_hw_regs().

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: axp288_charger: Register extcon notifers after power_supply
Hans de Goede [Wed, 21 Dec 2016 14:36:49 +0000 (15:36 +0100)]
power: supply: axp288_charger: Register extcon notifers after power_supply

The extcon notifier work calls power_supply_changed on the power_supply
we register, so the extcon notifiers should be registered after we
register the power_supply.

While touching this code anyways, refactor the code for the 3 cable types
into a loop to avoid code repetition.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: axp288_charger: Use devm_power_supply_register
Hans de Goede [Wed, 21 Dec 2016 14:36:48 +0000 (15:36 +0100)]
power: supply: axp288_charger: Use devm_power_supply_register

Use devm_power_supply_register instead of power_supply_register,
this avoids the need to do manual cleanup and results in quite
a nice code cleanup.

Note it may seem excessive to add a "struct device *dev" helper local
variable for the 1 time it is used in this patch, but future patches
in this series also use it.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agoMerge branch 'psy-mfd-axp288-immutable' into psy-next
Sebastian Reichel [Wed, 4 Jan 2017 21:01:42 +0000 (22:01 +0100)]
Merge branch 'psy-mfd-axp288-immutable' into psy-next

7 years agopower: supply: add sbs-charger driver
Nicolas Saenz Julienne [Tue, 20 Dec 2016 15:31:13 +0000 (16:31 +0100)]
power: supply: add sbs-charger driver

This adds support for sbs-charger compilant chips as defined here:
http://sbs-forum.org/specs/sbc110.pdf

This was tested on a arm board connected to an LTC4100 battery charger
chip.

Signed-off-by: Nicolas Saenz Julienne <nicolas.saenz@prodys.net>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agodt-bindings: power: supply: sbs-charger bindings
Nicolas Saenz Julienne [Tue, 20 Dec 2016 15:31:14 +0000 (16:31 +0100)]
dt-bindings: power: supply: sbs-charger bindings

Adds device tree documentation for SBS charger compilant devices as defined
here: http://sbs-forum.org/specs/sbc110.pdf

Signed-off-by: Nicolas Saenz Julienne <nicolas.saenz@prodys.net>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: bq24735: always check for AC adapter presence in probe
Peter Rosin [Tue, 20 Dec 2016 11:33:02 +0000 (12:33 +0100)]
power: supply: bq24735: always check for AC adapter presence in probe

So what if there is a status_gpio specified? bq24735_charger_is_present()
do have a working fallback for the case of no status_gpio.

Simplify this by not special casing setups w/o status_gpio, folding
two consecutive if-blocks in the process.

Signed-off-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: bq24735: configure the charger as part of enabling it
Peter Rosin [Tue, 20 Dec 2016 11:33:01 +0000 (12:33 +0100)]
power: supply: bq24735: configure the charger as part of enabling it

During probe, it makes no sense to take care to first not issue any
i2c commands to verify if the connected part really is a bq24735, to
later simply fail the probe in the next step when trying to configure
the charger. So, delay configuration of the charging parameters until
the charger is accessible (i.e. when the AC adapter is present) as
part of enabling the charging.

This also fixes the rather serious issue that the charging parameters
are lost when the AC adapter is disconnected.

Signed-off-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: bq24735: move down bq24735_{en,dis}able_charging
Peter Rosin [Tue, 20 Dec 2016 11:33:00 +0000 (12:33 +0100)]
power: supply: bq24735: move down bq24735_{en,dis}able_charging

bq24735_enable_charging() needs to call bq24735_config_charging(),
which is something to change later, this is just a preparatory patch.

Signed-off-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: tps65217: Use generic charger name
Milo Kim [Sun, 18 Dec 2016 02:54:32 +0000 (11:54 +0900)]
power: supply: tps65217: Use generic charger name

"tps65217-charger" is more appropriate name because the driver supports
not only AC but also USB charger.

Signed-off-by: Milo Kim <woogyom.kim@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: tps65217: Use generic name for get_property()
Milo Kim [Sun, 18 Dec 2016 02:54:31 +0000 (11:54 +0900)]
power: supply: tps65217: Use generic name for get_property()

Rename it as tps65217_charger_get_property().

Signed-off-by: Milo Kim <woogyom.kim@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: tps65217: Use generic name for power supply property
Milo Kim [Sun, 18 Dec 2016 02:54:30 +0000 (11:54 +0900)]
power: supply: tps65217: Use generic name for power supply property

Replace 'ac_props' with 'charger_props'.

Signed-off-by: Milo Kim <woogyom.kim@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: tps65217: Use generic name for power supply structure
Milo Kim [Sun, 18 Dec 2016 02:54:29 +0000 (11:54 +0900)]
power: supply: tps65217: Use generic name for power supply structure

Replace 'ac' of tps65217_charger structure with 'psy'.

Signed-off-by: Milo Kim <woogyom.kim@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: tps65217: Use generic name for charger online
Milo Kim [Sun, 18 Dec 2016 02:54:28 +0000 (11:54 +0900)]
power: supply: tps65217: Use generic name for charger online

This driver supports AC and USB chargers. Generic name is preferred.
Replace 'ac_online' with 'online'.

Signed-off-by: Milo Kim <woogyom.kim@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: tps65217: Support USB charger interrupt
Milo Kim [Sun, 18 Dec 2016 02:54:27 +0000 (11:54 +0900)]
power: supply: tps65217: Support USB charger interrupt

TPS65217 has two charger interrupts - AC and USB power status change.

Interrupt number in the TPS65217 driver data:
  IRQ number is only used on requesting the interrupt, so no need to keep
  it inside the driver data.

Interrupt handler:
  Check not only AC but also USB charger status.
  In both cases, enable charging operation.

Interrupt request:
  If an interrupt number is invalid, then use legacy polling thread.
  Otherwise, create IRQ threads to handle AC and USB charger event.

Signed-off-by: Milo Kim <woogyom.kim@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: tps65217: Use 'poll_task' on unloading the module
Milo Kim [Sun, 18 Dec 2016 02:54:26 +0000 (11:54 +0900)]
power: supply: tps65217: Use 'poll_task' on unloading the module

Use the task_struct variable for running polling thread. If polling task
is activated, then use it to stop running thread.
This is a preceding step of supporting two interrupts of TPS65217 charger,
so checking single IRQ number is not appropriate when the module is removed.

Signed-off-by: Milo Kim <woogyom.kim@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: qcom_smbb: Replace the deprecated extcon API
Chanwoo Choi [Wed, 30 Nov 2016 05:57:32 +0000 (14:57 +0900)]
power: supply: qcom_smbb: Replace the deprecated extcon API

This patch replaces the deprecated extcon API as following:
- extcon_set_cable_state_() -> extcon_set_state_sync()

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: axp288_charger: Replace the extcon API
Chanwoo Choi [Wed, 30 Nov 2016 05:57:31 +0000 (14:57 +0900)]
power: supply: axp288_charger: Replace the extcon API

This patch uses the resource-managed extcon API for extcon_register_notifier()
and replaces the deprecated extcon API as following:
- extcon_get_cable_state_() -> extcon_get_state()

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: max8997_charger: Using device managed API and remove OOM print
Srikant Ritolia [Thu, 8 Dec 2016 09:12:37 +0000 (14:42 +0530)]
power: supply: max8997_charger: Using device managed API and remove OOM print

Use managed resource function devm_power_supply_register instead of
power_supply_register to simplify the error path by allowing unregistering
to happen automatically on error and remove.
Removing max8997_battery_remove function also as it is now redundant.

Also removing out of memory printk message after kzalloc as there is
already enough information on failure.

Signed-off-by: Srikant Ritolia <s.ritolia@samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: axp20x_usb_power: add 100mA max current limit for AXP223
Quentin Schulz [Fri, 9 Dec 2016 11:04:13 +0000 (12:04 +0100)]
power: supply: axp20x_usb_power: add 100mA max current limit for AXP223

The X-Powers AXP223 shares most of its behaviour with the AXP221 PMIC
but allows the VBUS power supply max current to be set to 100mA (like
the AXP209 PMIC).

This basically adds a new compatible to the VBUS power supply driver and
adds a check on the compatible when setting current max limit.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Acked-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agodt-bindings: power: supply: axp20x_usb_power: add axp223 compatible
Quentin Schulz [Fri, 9 Dec 2016 11:04:12 +0000 (12:04 +0100)]
dt-bindings: power: supply: axp20x_usb_power: add axp223 compatible

This adds the "x-powers,axp223-usb-power-supply" to the list of
compatibles for AXP20X VBUS power supply driver.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Rob Herring <robh@kernel.org>
Acked-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: axp20x_usb_power: set min voltage and max current from sysfs
Quentin Schulz [Fri, 9 Dec 2016 11:04:11 +0000 (12:04 +0100)]
power: supply: axp20x_usb_power: set min voltage and max current from sysfs

AXP20X and AXP22X PMICs allow setting the min voltage and max current of
VBUS power supply. This adds entries in sysfs to allow to do so.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Acked-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: axp20x_usb_power: use of_device_id data field instead of device_is_com...
Quentin Schulz [Fri, 9 Dec 2016 11:04:09 +0000 (12:04 +0100)]
power: supply: axp20x_usb_power: use of_device_id data field instead of device_is_compatible

This replaces calls to of_device_is_compatible to check data field of
of_device_id matched when probing the driver.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Acked-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: bq24735-charger: optionally poll the ac-detect gpio
Peter Rosin [Thu, 15 Dec 2016 09:28:46 +0000 (10:28 +0100)]
power: supply: bq24735-charger: optionally poll the ac-detect gpio

If the ac-detect gpio does not support interrupts, provide a fallback
to poll the gpio at a configurable interval.

Signed-off-by: Peter Rosin <peda@axentia.se>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: axp288_fuel_gauge: Read 12 bit values 2 registers at a time
Hans de Goede [Wed, 14 Dec 2016 16:38:52 +0000 (17:38 +0100)]
power: supply: axp288_fuel_gauge: Read 12 bit values 2 registers at a time

In order for the MSB -> LSB latching to work correctly we must read the
2 8 bit registers of a 12 bit value in one consecutive read.

This fixes voltage_ocv reporting inconsistent values on my tablet.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: axp288_fuel_gauge: Read 15 bit values 2 registers at a time
Hans de Goede [Wed, 14 Dec 2016 16:38:51 +0000 (17:38 +0100)]
power: supply: axp288_fuel_gauge: Read 15 bit values 2 registers at a time

In order for the MSB -> LSB latching to work correctly we must read the
2 8 bit registers of a 15 bit value in one consecutive read.

This fixes charge_full reporting 3498768 on some reads and 3354624 one
other reads on my tablet (for the 3354624 value the raw LSB is 0x00).

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: axp288_fuel_gauge: Fix fuel_gauge_reg_readb return on error
Hans de Goede [Wed, 14 Dec 2016 16:38:50 +0000 (17:38 +0100)]
power: supply: axp288_fuel_gauge: Fix fuel_gauge_reg_readb return on error

If reading the register fails, return the actual error code, instead
of the uninitialized val variable;

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agodt-bindings: power: supply: bq24735: reverse the polarity of ac-detect
Peter Rosin [Fri, 16 Dec 2016 09:44:00 +0000 (10:44 +0100)]
dt-bindings: power: supply: bq24735: reverse the polarity of ac-detect

The ACOK pin on the bq24735 is active-high, of course meaning that when
AC is OK the pin is high. However, all Tegra dts files have incorrectly
specified active-high even though the signal is inverted on the Tegra
boards. This has worked since the Linux driver has also inverted the
meaning of the GPIO. Fix this situation by simply specifying in the
bindings what everybody else agrees on; that the ti,ac-detect-gpios is
active on AC adapter absence.

Signed-off-by: Peter Rosin <peda@axentia.se>
Acked-by: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: bq24735-charger: simplify register update to stop charging
Peter Rosin [Tue, 13 Dec 2016 23:56:43 +0000 (00:56 +0100)]
power: supply: bq24735-charger: simplify register update to stop charging

Providing value bits outside of the mask is pointless.

Signed-off-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: axp288_fuel_gauge: Drop platform_data dependency
Hans de Goede [Wed, 14 Dec 2016 16:38:53 +0000 (17:38 +0100)]
power: supply: axp288_fuel_gauge: Drop platform_data dependency

When the axp288_faul_gauge driver was originally merged, it was
merged with a dependency on some other driver providing platform
data for it.

However the battery-data-framework which should provide that data
never got merged, resulting in x86 tablets / laptops with an axp288
having no working battery monitor, as before this commit the driver
would simply return -ENODEV if there is no platform data.

This commit removes the dependency on the platform_data instead
checking that the firmware has initialized the fuel-gauge and
reading the info back from the pmic.

What is missing from the read-back info is the table to map raw adc
values to temperature, so this commit drops the temperature and
temperature limits properties. The min voltage, charge design and
model name info is also missing. Note that none of these are really
important for userspace to have.

All other functionality is preserved and actually made available
by this commit.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=88471
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: axp288_charger: Drop platform_data dependency
Hans de Goede [Wed, 21 Dec 2016 14:36:47 +0000 (15:36 +0100)]
power: supply: axp288_charger: Drop platform_data dependency

When the axp288_charger driver was originally merged, it was merged with
a dependency on some other driver providing platform data for it.

However the battery-data-framework which should provide that data never
got merged, so the axp288_charger as merged upstream has never worked,
its probe method simply always returns -ENODEV.

This commit removes the dependency on the platform_data instead reading
back the charging current and charging voltage that the firmware has set
and using those values as the maximum values the user may set.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agopower: supply: axp288_charger: Make charger_init_hw_regs propagate i2c errors
Hans de Goede [Wed, 21 Dec 2016 14:36:46 +0000 (15:36 +0100)]
power: supply: axp288_charger: Make charger_init_hw_regs propagate i2c errors

Make charger_init_hw_regs propagate i2c errors, instead of only warning
about them and then ignoring them.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
7 years agoLinux 4.10-rc1
Linus Torvalds [Mon, 26 Dec 2016 00:13:08 +0000 (16:13 -0800)]
Linux 4.10-rc1

7 years agopowerpc: Fix build warning on 32-bit PPC
Larry Finger [Fri, 23 Dec 2016 03:06:53 +0000 (21:06 -0600)]
powerpc: Fix build warning on 32-bit PPC

I am getting the following warning when I build kernel 4.9-git on my
PowerBook G4 with a 32-bit PPC processor:

    AS      arch/powerpc/kernel/misc_32.o
  arch/powerpc/kernel/misc_32.S:299:7: warning: "CONFIG_FSL_BOOKE" is not defined [-Wundef]

This problem is evident after commit 989cea5c14be ("kbuild: prevent
lib-ksyms.o rebuilds"); however, this change in kbuild only exposes an
error that has been in the code since 2005 when this source file was
created.  That was with commit 9994a33865f4 ("powerpc: Introduce
entry_{32,64}.S, misc_{32,64}.S, systbl.S").

The offending line does not make a lot of sense.  This error does not
seem to cause any errors in the executable, thus I am not recommending
that it be applied to any stable versions.

Thanks to Nicholas Piggin for suggesting this solution.

Fixes: 9994a33865f4 ("powerpc: Introduce entry_{32,64}.S, misc_{32,64}.S, systbl.S")
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
7 years agoavoid spurious "may be used uninitialized" warning
Linus Torvalds [Sun, 25 Dec 2016 22:56:58 +0000 (14:56 -0800)]
avoid spurious "may be used uninitialized" warning

The timer type simplifications caused a new gcc warning:

  drivers/base/power/domain.c: In function ‘genpd_runtime_suspend’:
  drivers/base/power/domain.c:562:14: warning: ‘time_start’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     elapsed_ns = ktime_to_ns(ktime_sub(ktime_get(), time_start));

despite the actual use of "time_start" not having changed in any way.
It appears that simply changing the type of ktime_t from a union to a
plain scalar type made gcc check the use.

The variable wasn't actually used uninitialized, but gcc apparently
failed to notice that the conditional around the use was exactly the
same as the conditional around the initialization of that variable.

Add an unnecessary initialization just to shut up the compiler.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
7 years agoMerge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sun, 25 Dec 2016 22:30:04 +0000 (14:30 -0800)]
Merge branch 'timers-urgent-for-linus' of git://git./linux/kernel/git/tip/tip

Pull timer type cleanups from Thomas Gleixner:
 "This series does a tree wide cleanup of types related to
  timers/timekeeping.

   - Get rid of cycles_t and use a plain u64. The type is not really
     helpful and caused more confusion than clarity

   - Get rid of the ktime union. The union has become useless as we use
     the scalar nanoseconds storage unconditionally now. The 32bit
     timespec alike storage got removed due to the Y2038 limitations
     some time ago.

     That leaves the odd union access around for no reason. Clean it up.

  Both changes have been done with coccinelle and a small amount of
  manual mopping up"

* 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  ktime: Get rid of ktime_equal()
  ktime: Cleanup ktime_set() usage
  ktime: Get rid of the union
  clocksource: Use a plain u64 instead of cycle_t

7 years agoMerge branch 'smp-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sun, 25 Dec 2016 22:05:56 +0000 (14:05 -0800)]
Merge branch 'smp-urgent-for-linus' of git://git./linux/kernel/git/tip/tip

Pull SMP hotplug notifier removal from Thomas Gleixner:
 "This is the final cleanup of the hotplug notifier infrastructure. The
  series has been reintgrated in the last two days because there came a
  new driver using the old infrastructure via the SCSI tree.

  Summary:

   - convert the last leftover drivers utilizing notifiers

   - fixup for a completely broken hotplug user

   - prevent setup of already used states

   - removal of the notifiers

   - treewide cleanup of hotplug state names

   - consolidation of state space

  There is a sphinx based documentation pending, but that needs review
  from the documentation folks"

* 'smp-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  irqchip/armada-xp: Consolidate hotplug state space
  irqchip/gic: Consolidate hotplug state space
  coresight/etm3/4x: Consolidate hotplug state space
  cpu/hotplug: Cleanup state names
  cpu/hotplug: Remove obsolete cpu hotplug register/unregister functions
  staging/lustre/libcfs: Convert to hotplug state machine
  scsi/bnx2i: Convert to hotplug state machine
  scsi/bnx2fc: Convert to hotplug state machine
  cpu/hotplug: Prevent overwriting of callbacks
  x86/msr: Remove bogus cleanup from the error path
  bus: arm-ccn: Prevent hotplug callback leak
  perf/x86/intel/cstate: Prevent hotplug callback leak
  ARM/imx/mmcd: Fix broken cpu hotplug handling
  scsi: qedi: Convert to hotplug state machine

7 years agoMerge branch 'turbostat' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux
Linus Torvalds [Sun, 25 Dec 2016 22:01:28 +0000 (14:01 -0800)]
Merge branch 'turbostat' of git://git./linux/kernel/git/lenb/linux

Pull turbostat updates from Len Brown.

* 'turbostat' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux:
  tools/power turbostat: remove obsolete -M, -m, -C, -c options
  tools/power turbostat: Make extensible via the --add parameter
  tools/power turbostat: Denverton uses a 25 MHz crystal, not 19.2 MHz
  tools/power turbostat: line up headers when -M is used
  tools/power turbostat: fix SKX PKG_CSTATE_LIMIT decoding
  tools/power turbostat: Support Knights Mill (KNM)
  tools/power turbostat: Display HWP OOB status
  tools/power turbostat: fix Denverton BCLK
  tools/power turbostat: use intel-family.h model strings
  tools/power/turbostat: Add Denverton RAPL support
  tools/power/turbostat: Add Denverton support
  tools/power/turbostat: split core MSR support into status + limit
  tools/power turbostat: fix error case overflow read of slm_freq_table[]
  tools/power turbostat: Allocate correct amount of fd and irq entries
  tools/power turbostat: switch to tab delimited output
  tools/power turbostat: Gracefully handle ACPI S3
  tools/power turbostat: tidy up output on Joule counter overflow

7 years agomm: add PageWaiters indicating tasks are waiting for a page bit
Nicholas Piggin [Sun, 25 Dec 2016 03:00:30 +0000 (13:00 +1000)]
mm: add PageWaiters indicating tasks are waiting for a page bit

Add a new page flag, PageWaiters, to indicate the page waitqueue has
tasks waiting. This can be tested rather than testing waitqueue_active
which requires another cacheline load.

This bit is always set when the page has tasks on page_waitqueue(page),
and is set and cleared under the waitqueue lock. It may be set when
there are no tasks on the waitqueue, which will cause a harmless extra
wakeup check that will clears the bit.

The generic bit-waitqueue infrastructure is no longer used for pages.
Instead, waitqueues are used directly with a custom key type. The
generic code was not flexible enough to have PageWaiters manipulation
under the waitqueue lock (which simplifies concurrency).

This improves the performance of page lock intensive microbenchmarks by
2-3%.

Putting two bits in the same word opens the opportunity to remove the
memory barrier between clearing the lock bit and testing the waiters
bit, after some work on the arch primitives (e.g., ensuring memory
operand widths match and cover both bits).

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Bob Peterson <rpeterso@redhat.com>
Cc: Steven Whitehouse <swhiteho@redhat.com>
Cc: Andrew Lutomirski <luto@kernel.org>
Cc: Andreas Gruenbacher <agruenba@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Mel Gorman <mgorman@techsingularity.net>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
7 years agomm: Use owner_priv bit for PageSwapCache, valid when PageSwapBacked
Nicholas Piggin [Sun, 25 Dec 2016 03:00:29 +0000 (13:00 +1000)]
mm: Use owner_priv bit for PageSwapCache, valid when PageSwapBacked

A page is not added to the swap cache without being swap backed,
so PageSwapBacked mappings can use PG_owner_priv_1 for PageSwapCache.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Acked-by: Hugh Dickins <hughd@google.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Bob Peterson <rpeterso@redhat.com>
Cc: Steven Whitehouse <swhiteho@redhat.com>
Cc: Andrew Lutomirski <luto@kernel.org>
Cc: Andreas Gruenbacher <agruenba@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Mel Gorman <mgorman@techsingularity.net>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
7 years agoktime: Get rid of ktime_equal()
Thomas Gleixner [Sun, 25 Dec 2016 11:43:07 +0000 (12:43 +0100)]
ktime: Get rid of ktime_equal()

No point in going through loops and hoops instead of just comparing the
values.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
7 years agoktime: Cleanup ktime_set() usage
Thomas Gleixner [Sun, 25 Dec 2016 11:30:41 +0000 (12:30 +0100)]
ktime: Cleanup ktime_set() usage

ktime_set(S,N) was required for the timespec storage type and is still
useful for situations where a Seconds and Nanoseconds part of a time value
needs to be converted. For anything where the Seconds argument is 0, this
is pointless and can be replaced with a simple assignment.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
7 years agoktime: Get rid of the union
Thomas Gleixner [Sun, 25 Dec 2016 10:38:40 +0000 (11:38 +0100)]
ktime: Get rid of the union

ktime is a union because the initial implementation stored the time in
scalar nanoseconds on 64 bit machine and in a endianess optimized timespec
variant for 32bit machines. The Y2038 cleanup removed the timespec variant
and switched everything to scalar nanoseconds. The union remained, but
become completely pointless.

Get rid of the union and just keep ktime_t as simple typedef of type s64.

The conversion was done with coccinelle and some manual mopping up.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
7 years agoclocksource: Use a plain u64 instead of cycle_t
Thomas Gleixner [Wed, 21 Dec 2016 19:32:01 +0000 (20:32 +0100)]
clocksource: Use a plain u64 instead of cycle_t

There is no point in having an extra type for extra confusion. u64 is
unambiguous.

Conversion was done with the following coccinelle script:

@rem@
@@
-typedef u64 cycle_t;

@fix@
typedef cycle_t;
@@
-cycle_t
+u64

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: John Stultz <john.stultz@linaro.org>
7 years agoirqchip/armada-xp: Consolidate hotplug state space
Thomas Gleixner [Wed, 21 Dec 2016 19:19:57 +0000 (20:19 +0100)]
irqchip/armada-xp: Consolidate hotplug state space

The mpic is either the main interrupt controller or is cascaded behind a
GIC. The mpic is single instance and the modes are mutually exclusive, so
there is no reason to have seperate cpu hotplug states.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Sebastian Siewior <bigeasy@linutronix.de>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Link: http://lkml.kernel.org/r/20161221192112.333161745@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
7 years agoirqchip/gic: Consolidate hotplug state space
Thomas Gleixner [Wed, 21 Dec 2016 19:19:56 +0000 (20:19 +0100)]
irqchip/gic: Consolidate hotplug state space

Even if both drivers are compiled in only one instance can run on a given
system depending on the available GIC version.

So having seperate hotplug states for them is pointless.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Sebastian Siewior <bigeasy@linutronix.de>
Link: http://lkml.kernel.org/r/20161221192112.252416267@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
7 years agocoresight/etm3/4x: Consolidate hotplug state space
Thomas Gleixner [Wed, 21 Dec 2016 19:19:55 +0000 (20:19 +0100)]
coresight/etm3/4x: Consolidate hotplug state space

Even if both drivers are compiled in only one instance can run on a given
system depending on the available tracer cell.

So having seperate hotplug states for them is pointless.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sebastian Siewior <bigeasy@linutronix.de>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Link: http://lkml.kernel.org/r/20161221192112.162765484@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
7 years agocpu/hotplug: Cleanup state names
Thomas Gleixner [Wed, 21 Dec 2016 19:19:54 +0000 (20:19 +0100)]
cpu/hotplug: Cleanup state names

When the state names got added a script was used to add the extra argument
to the calls. The script basically converted the state constant to a
string, but the cleanup to convert these strings into meaningful ones did
not happen.

Replace all the useless strings with 'subsys/xxx/yyy:state' strings which
are used in all the other places already.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sebastian Siewior <bigeasy@linutronix.de>
Link: http://lkml.kernel.org/r/20161221192112.085444152@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
7 years agocpu/hotplug: Remove obsolete cpu hotplug register/unregister functions
Thomas Gleixner [Wed, 21 Dec 2016 19:19:53 +0000 (20:19 +0100)]
cpu/hotplug: Remove obsolete cpu hotplug register/unregister functions

hotcpu_notifier(), cpu_notifier(), __hotcpu_notifier(), __cpu_notifier(),
register_hotcpu_notifier(), register_cpu_notifier(),
__register_hotcpu_notifier(), __register_cpu_notifier(),
unregister_hotcpu_notifier(), unregister_cpu_notifier(),
__unregister_hotcpu_notifier(), __unregister_cpu_notifier()

are unused now. Remove them and all related code.

Remove also the now pointless cpu notifier error injection mechanism. The
states can be executed step by step and error rollback is the same as cpu
down, so any state transition can be tested w/o requiring the notifier
error injection.

Some CPU hotplug states are kept as they are (ab)used for hotplug state
tracking.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: rt@linutronix.de
Link: http://lkml.kernel.org/r/20161221192112.005642358@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
7 years agostaging/lustre/libcfs: Convert to hotplug state machine
Anna-Maria Gleixner [Wed, 21 Dec 2016 19:19:52 +0000 (20:19 +0100)]
staging/lustre/libcfs: Convert to hotplug state machine

Install the callbacks via the state machine. No functional change.

Signed-off-by: Anna-Maria Gleixner <anna-maria@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: devel@driverdev.osuosl.org
Cc: Andreas Dilger <andreas.dilger@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Oleg Drokin <oleg.drokin@intel.com>
Cc: rt@linutronix.de
Cc: lustre-devel@lists.lustre.org
Link: http://lkml.kernel.org/r/20161202110027.htzzeervzkoc4muv@linutronix.de
Link: http://lkml.kernel.org/r/20161221192111.922872524@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
7 years agoscsi/bnx2i: Convert to hotplug state machine
Sebastian Andrzej Siewior [Wed, 21 Dec 2016 19:19:51 +0000 (20:19 +0100)]
scsi/bnx2i: Convert to hotplug state machine

Install the callbacks via the state machine. No functional change.

This is the minimal fixup so we can remove the hotplug notifier mess
completely.

The real rework of this driver to use work queues is still stuck in
review/testing on the SCSI mailing list.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>
Cc: linux-scsi@vger.kernel.org
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Chad Dupuis <chad.dupuis@qlogic.com>
Cc: QLogic-Storage-Upstream@qlogic.com
Cc: Johannes Thumshirn <jth@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>
Link: http://lkml.kernel.org/r/20161221192111.836895753@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
7 years agoscsi/bnx2fc: Convert to hotplug state machine
Sebastian Andrzej Siewior [Wed, 21 Dec 2016 19:19:50 +0000 (20:19 +0100)]
scsi/bnx2fc: Convert to hotplug state machine

Install the callbacks via the state machine. No functional change.

This is the minimal fixup so we can remove the hotplug notifier mess
completely.

The real rework of this driver to use work queues is still stuck in
review/testing on the SCSI mailing list.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>
Cc: linux-scsi@vger.kernel.org
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Chad Dupuis <chad.dupuis@qlogic.com>
Cc: QLogic-Storage-Upstream@qlogic.com
Cc: Johannes Thumshirn <jth@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>
Link: http://lkml.kernel.org/r/20161221192111.757309869@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
7 years agocpu/hotplug: Prevent overwriting of callbacks
Thomas Gleixner [Wed, 21 Dec 2016 19:19:49 +0000 (20:19 +0100)]
cpu/hotplug: Prevent overwriting of callbacks

Developers manage to overwrite states blindly without thought. That's fatal
and hard to debug. Add sanity checks to make it fail.

This requries to restructure the code so that the dynamic state allocation
happens in the same lock protected section as the actual store. Otherwise
the previous assignment of 'Reserved' to the name field would trigger the
overwrite check.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sebastian Siewior <bigeasy@linutronix.de>
Link: http://lkml.kernel.org/r/20161221192111.675234535@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
7 years agox86/msr: Remove bogus cleanup from the error path
Thomas Gleixner [Thu, 22 Dec 2016 09:32:38 +0000 (10:32 +0100)]
x86/msr: Remove bogus cleanup from the error path

The error cleanup which is invoked when the hotplug state setup failed
tries to remove the failed state, which is broken.

Fixes: 8fba38c937cd ("x86/msr: Convert to hotplug state machine")
Reported-by: kernel test robot <fengguang.wu@intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Sebastian Siewior <bigeasy@linutronix.de>
7 years agobus: arm-ccn: Prevent hotplug callback leak
Thomas Gleixner [Thu, 22 Dec 2016 10:14:06 +0000 (11:14 +0100)]
bus: arm-ccn: Prevent hotplug callback leak

In case the driver registration fails, the hotplug callback is leaked.

Not fatal, because it's never invoked as there are no instances registered,
but wrong nevertheless.

Fixes: fdc15a36d84e ("bus/arm-ccn: Convert to hotplug statemachine")
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Pawel Moll <pawel.moll@arm.com>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Will Deacon <will.deacon@arm.com>
7 years agoperf/x86/intel/cstate: Prevent hotplug callback leak
Thomas Gleixner [Thu, 22 Dec 2016 10:02:08 +0000 (11:02 +0100)]
perf/x86/intel/cstate: Prevent hotplug callback leak

If the pmu registration fails the registered hotplug callbacks are not
removed. Wrong in any case, but fatal in case of a modular driver.

Replace the nonsensical state names with proper ones while at it.

Fixes: 77c34ef1c319 ("perf/x86/intel/cstate: Convert Intel CSTATE to hotplug state machine")
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Sebastian Siewior <bigeasy@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: stable@vger.kernel.org
7 years agoARM/imx/mmcd: Fix broken cpu hotplug handling
Thomas Gleixner [Wed, 21 Dec 2016 19:19:48 +0000 (20:19 +0100)]
ARM/imx/mmcd: Fix broken cpu hotplug handling

The cpu hotplug support of this perf driver is broken in several ways:

1) It adds a instance before setting up the state.

2) The state for the instance is different from the state of the
   callback. It's just a randomly chosen state.

3) The instance registration is not error checked so nobody noticed that
   the call can never succeed.

4) The state for the multi install callbacks is chosen randomly and
   overwrites existing state. This is now prevented by the core code so the
   call is guaranteed to fail.

5) The error exit path in the init function leaves the instance registered
   and then frees the memory which contains the enqueued hlist node.

6) The remove function is removing the state and not the instance.

Fix it by:

- Setting up the state before adding instances. Use a dynamically allocated
  state for it.

- Installing instances after the state has been set up

- Removing the instance in the error path before freeing memory

- Removing the instance not the state in the driver remove callback

While at is use raw_cpu_processor_id(), because cpu_processor_id() cannot
be used in preemptible context, and set the driver data after successful
registration of the pmu.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Shawn Guo <shawnguo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sebastian Siewior <bigeasy@linutronix.de>
Cc: Frank Li <frank.li@nxp.com>
Cc: Zhengyu Shen <zhengyu.shen@nxp.com>
Link: http://lkml.kernel.org/r/20161221192111.596204211@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
7 years agoscsi: qedi: Convert to hotplug state machine
Thomas Gleixner [Sat, 24 Dec 2016 11:34:02 +0000 (12:34 +0100)]
scsi: qedi: Convert to hotplug state machine

The CPU hotplug code is a trainwreck. It leaks a notifier in case of driver
registration error and the per cpu loop is racy against cpu hotplug. Aside
of that the driver should have been written and merged with the new state
machine interfaces in the first place.

Mop up the mess and Convert it to the hotplug state machine.

Signed-off-by: Thomas Grumpy Gleixner <tglx@linutronix.de>
Cc: Nilesh Javali <nilesh.javali@cavium.com>
Cc: Adheer Chandravanshi <adheer.chandravanshi@qlogic.com>
Cc: Chad Dupuis <chad.dupuis@cavium.com>
Cc: Saurav Kashyap <saurav.kashyap@cavium.com>
Cc: Arun Easi <arun.easi@cavium.com>
Cc: Manish Rangankar <manish.rangankar@cavium.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
7 years agotools/power turbostat: remove obsolete -M, -m, -C, -c options
Len Brown [Sat, 24 Dec 2016 20:18:37 +0000 (15:18 -0500)]
tools/power turbostat: remove obsolete -M, -m, -C, -c options

The new --add option has replaced the -M, -m, -C, -c options
Eg.

-M 0x10 is now --add msr0x10,raw
-m 0x10 is now --add msr0x10,raw,u32
-C 0x10 is now --add msr0x10,delta
-c 0x10 is now --add msr0x10,delta,u32

The --add option can be repeated to add any number of counters,
while the previous options were limited to adding one of each type.

In addition, the --add option can accept a column label,
and can also display a counter as a percentage of elapsed cycles.

Eg. --add msr0x3fe,core,percent,MY_CC3

Signed-off-by: Len Brown <len.brown@intel.com>
7 years agotools/power turbostat: Make extensible via the --add parameter
Len Brown [Fri, 23 Dec 2016 04:57:55 +0000 (23:57 -0500)]
tools/power turbostat: Make extensible via the --add parameter

Create the "--add" parameter.  This can be used to teach an existing
turbostat binary about any number of any type of counter.

turbostat(8) details the syntax for --add.

Signed-off-by: Len Brown <len.brown@intel.com>
7 years agoReplace <asm/uaccess.h> with <linux/uaccess.h> globally
Linus Torvalds [Sat, 24 Dec 2016 19:46:01 +0000 (11:46 -0800)]
Replace <asm/uaccess.h> with <linux/uaccess.h> globally

This was entirely automated, using the script by Al:

  PATT='^[[:blank:]]*#[[:blank:]]*include[[:blank:]]*<asm/uaccess.h>'
  sed -i -e "s!$PATT!#include <linux/uaccess.h>!" \
        $(git grep -l "$PATT"|grep -v ^include/linux/uaccess.h)

to do the replacement at the end of the merge window.

Requested-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
7 years agoMerge branch 'for-next' of git://git.samba.org/sfrench/cifs-2.6
Linus Torvalds [Sat, 24 Dec 2016 19:37:18 +0000 (11:37 -0800)]
Merge branch 'for-next' of git://git.samba.org/sfrench/cifs-2.6

Pull cifs fixes from Steve French:
 "This ncludes various cifs/smb3 bug fixes, mostly for stable as well.

  In the next week I expect that Germano will have some reconnection
  fixes, and also I expect to have the remaining pieces of the snapshot
  enablement and SMB3 ACLs, but wanted to get this set of bug fixes in"

* 'for-next' of git://git.samba.org/sfrench/cifs-2.6:
  cifs_get_root shouldn't use path with tree name
  Fix default behaviour for empty domains and add domainauto option
  cifs: use %16phN for formatting md5 sum
  cifs: Fix smbencrypt() to stop pointing a scatterlist at the stack
  CIFS: Fix a possible double locking of mutex during reconnect
  CIFS: Fix a possible memory corruption during reconnect
  CIFS: Fix a possible memory corruption in push locks
  CIFS: Fix missing nls unload in smb2_reconnect()
  CIFS: Decrease verbosity of ioctl call
  SMB3: parsing for new snapshot timestamp mount parm

7 years agoMerge tag 'watchdog-for-linus-v4.10' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sat, 24 Dec 2016 19:27:45 +0000 (11:27 -0800)]
Merge tag 'watchdog-for-linus-v4.10' of git://git./linux/kernel/git/groeck/linux-staging

Pull watchdog updates from Wim Van Sebroeck and Guenter Roeck:

 - new driver for Add Loongson1 SoC

 - minor cleanup and fixes in various drivers

* tag 'watchdog-for-linus-v4.10' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging:
  watchdog: it87_wdt: add IT8620E ID
  watchdog: mpc8xxx: Remove unneeded linux/miscdevice.h include
  watchdog: octeon: Remove unneeded linux/miscdevice.h include
  watchdog: bcm2835_wdt: set WDOG_HW_RUNNING bit when appropriate
  watchdog: loongson1: Add Loongson1 SoC watchdog driver
  watchdog: cpwd: remove memory allocate failure message
  watchdog: da9062/61: watchdog driver
  intel-mid_wdt: Error code is just an integer
  intel-mid_wdt: make sure watchdog is not running at startup
  watchdog: mei_wdt: request stop on reboot to prevent false positive event
  watchdog: hpwdt: changed maintainer information
  watchdog: jz4740: Fix modular build
  watchdog: qcom: fix kernel panic due to external abort on non-linefetch
  watchdog: davinci: add support for deferred probing
  watchdog: meson: Remove unneeded platform MODULE_ALIAS
  watchdog: Standardize leading tabs and spaces in Kconfig file
  watchdog: max77620_wdt: fix module autoload
  watchdog: bcm7038_wdt: fix module autoload

7 years agoMerge tag 'ntb-4.10' of git://github.com/jonmason/ntb
Linus Torvalds [Sat, 24 Dec 2016 19:23:24 +0000 (11:23 -0800)]
Merge tag 'ntb-4.10' of git://github.com/jonmason/ntb

Pull NTB update from Jon Mason:

 - NTB bug fixes for removing an unnecessary call to ntb_peer_spad_read,
   and correcting a free_irq inconsistency

 - add Intel SKX support

 - change the AMD NTB maintainer, and fix some bugs present there

* tag 'ntb-4.10' of git://github.com/jonmason/ntb:
  ntb_transport: Remove unnecessary call to ntb_peer_spad_read
  NTB: Fix 'request_irq()' and 'free_irq()' inconsistancy
  ntb: fix SKX NTB config space size register offsets
  NTB: correct ntb_peer_spad_read for case when callback is not supplied.
  MAINTAINERS: Change in maintainer for AMD NTB
  ntb_transport: Limit memory windows based on available, scratchpads
  NTB: Register and offset values fix for memory window
  NTB: add support for hotplug feature
  ntb: Adding Skylake Xeon NTB support