15 Oct, 2015

1 commit

  • for_each_child_of_node performs an of_node_get on each iteration, so
    a break out of the loop requires an of_node_put.

    The semantic patch that fixes this problem is as follows
    (http://coccinelle.lip6.fr):

    //
    @@
    expression root,e;
    local idexpression child;
    @@

    for_each_child_of_node(root, child) {
    ... when != of_node_put(child)
    when != e = child
    (
    return child;
    |
    + of_node_put(child);
    ? return ...;
    )
    ...
    }
    //

    Signed-off-by: Julia Lawall
    Reviewed-by: Krzysztof Kozlowski
    Signed-off-by: Sebastian Reichel

    Julia Lawall
     

03 Aug, 2015

1 commit

  • The thermal code uses int, long and unsigned long for temperatures
    in different places.

    Using an unsigned type limits the thermal framework to positive
    temperatures without need. Also several drivers currently will report
    temperatures near UINT_MAX for temperatures below 0°C. This will probably
    immediately shut the machine down due to overtemperature if started below
    0°C.

    'long' is 64bit on several architectures. This is not needed since INT_MAX °mC
    is above the melting point of all known materials.

    Consistently use a plain 'int' for temperatures throughout the thermal code and
    the drivers. This only changes the places in the drivers where the temperature
    is passed around as pointer, when drivers internally use another type this is
    not changed.

    Signed-off-by: Sascha Hauer
    Acked-by: Geert Uytterhoeven
    Reviewed-by: Jean Delvare
    Reviewed-by: Lukasz Majewski
    Reviewed-by: Darren Hart
    Reviewed-by: Heiko Stuebner
    Reviewed-by: Peter Feuerer
    Cc: Punit Agrawal
    Cc: Zhang Rui
    Cc: Eduardo Valentin
    Cc: linux-pm@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Cc: Jean Delvare
    Cc: Peter Feuerer
    Cc: Heiko Stuebner
    Cc: Lukasz Majewski
    Cc: Stephen Warren
    Cc: Thierry Reding
    Cc: linux-acpi@vger.kernel.org
    Cc: platform-driver-x86@vger.kernel.org
    Cc: linux-arm-kernel@lists.infradead.org
    Cc: linux-omap@vger.kernel.org
    Cc: linux-samsung-soc@vger.kernel.org
    Cc: Guenter Roeck
    Cc: Rafael J. Wysocki
    Cc: Maxime Ripard
    Cc: Darren Hart
    Cc: lm-sensors@lm-sensors.org
    Signed-off-by: Zhang Rui

    Sascha Hauer
     

24 May, 2015

1 commit


24 Mar, 2015

1 commit

  • If power_supply_register() fails do not dereference returned ERR_PTR.
    The pointer was dereferenced to print name of battery which registration
    failed. Instead use the name from the power supply description passed to
    the power_supply_register() function.

    Signed-off-by: Krzysztof Kozlowski
    Reported-by: Dan Carpenter
    Signed-off-by: Sebastian Reichel

    Krzysztof Kozlowski
     

20 Mar, 2015

1 commit


14 Mar, 2015

4 commits

  • Use power_supply_put() to decrement the power supply's device reference
    counter.

    Signed-off-by: Krzysztof Kozlowski
    Acked-by: Pavel Machek
    Reviewed-by: Bartlomiej Zolnierkiewicz
    Reviewed-by: Sebastian Reichel
    Signed-off-by: Sebastian Reichel

    Krzysztof Kozlowski
     
  • Change the ownership of power_supply structure from each driver
    implementing the class to the power supply core.

    The patch changes power_supply_register() function thus all drivers
    implementing power supply class are adjusted.

    Each driver provides the implementation of power supply. However it
    should not be the owner of power supply class instance because it is
    exposed by core to other subsystems with power_supply_get_by_name().
    These other subsystems have no knowledge when the driver will unregister
    the power supply. This leads to several issues when driver is unbound -
    mostly because user of power supply accesses freed memory.

    Instead let the core own the instance of struct 'power_supply'. Other
    users of this power supply will still access valid memory because it
    will be freed when device reference count reaches 0. Currently this
    means "it will leak" but power_supply_put() call in next patches will
    solve it.

    This solves invalid memory references in following race condition
    scenario:

    Thread 1: charger manager
    Thread 2: power supply driver, used by charger manager

    THREAD 1 (charger manager) THREAD 2 (power supply driver)
    ========================== ==============================
    psy = power_supply_get_by_name()
    Driver unbind, .remove
    power_supply_unregister()
    Device fully removed
    psy->get_property()

    The 'get_property' call is executed in invalid context because the driver was
    unbound and struct 'power_supply' memory was freed.

    This could be observed easily with charger manager driver (here compiled
    with max17040 fuel gauge):

    $ cat /sys/devices/virtual/power_supply/cm-battery/capacity &
    $ echo "1-0036" > /sys/bus/i2c/drivers/max17040/unbind
    [ 55.725123] Unable to handle kernel NULL pointer dereference at virtual address 00000000
    [ 55.732584] pgd = d98d4000
    [ 55.734060] [00000000] *pgd=5afa2831, *pte=00000000, *ppte=00000000
    [ 55.740318] Internal error: Oops: 80000007 [#1] PREEMPT SMP ARM
    [ 55.746210] Modules linked in:
    [ 55.749259] CPU: 1 PID: 2936 Comm: cat Tainted: G W 3.19.0-rc1-next-20141226-00048-gf79f475f3c44-dirty #1496
    [ 55.760190] Hardware name: SAMSUNG EXYNOS (Flattened Device Tree)
    [ 55.766270] task: d9b76f00 ti: daf54000 task.ti: daf54000
    [ 55.771647] PC is at 0x0
    [ 55.774182] LR is at charger_get_property+0x2f4/0x36c
    [ 55.779201] pc : [] lr : [] psr: 60000013
    [ 55.779201] sp : daf55e90 ip : 00000003 fp : 00000000
    [ 55.790657] r10: 00000000 r9 : c06e2878 r8 : d9b26c68
    [ 55.795865] r7 : dad81610 r6 : daec7410 r5 : daf55ebc r4 : 00000000
    [ 55.802367] r3 : 00000000 r2 : daf55ebc r1 : 0000002a r0 : d9b26c68
    [ 55.808879] Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user
    [ 55.815994] Control: 10c5387d Table: 598d406a DAC: 00000015
    [ 55.821723] Process cat (pid: 2936, stack limit = 0xdaf54210)
    [ 55.827451] Stack: (0xdaf55e90 to 0xdaf56000)
    [ 55.831795] 5e80: 60000013 c01459c4 0000002a c06f8ef8
    [ 55.839956] 5ea0: db651000 c06f8ef8 daebac00 c04cb668 daebac08 c0346864 00000000 c01459c4
    [ 55.848115] 5ec0: d99eaa80 c06f8ef8 00000fff 00001000 db651000 c027f25c c027f240 d99eaa80
    [ 55.856274] 5ee0: d9a06c00 c0146218 daf55f18 00001000 d99eaa80 db4c18c0 00000001 00000001
    [ 55.864468] 5f00: daf55f80 c0144c78 c0144c54 c0107f90 00015000 d99eaab0 00000000 00000000
    [ 55.872603] 5f20: 000051c7 00000000 db4c18c0 c04a9370 00015000 00001000 daf55f80 00001000
    [ 55.880763] 5f40: daf54000 00015000 00000000 c00e53dc db4c18c0 c00e548c 0000000d 00008124
    [ 55.888937] 5f60: 00000001 00000000 00000000 db4c18c0 db4c18c0 00001000 00015000 c00e5550
    [ 55.897099] 5f80: 00000000 00000000 00001000 00001000 00015000 00000003 00000003 c000f364
    [ 55.905239] 5fa0: 00000000 c000f1a0 00001000 00015000 00000003 00015000 00001000 0001333c
    [ 55.913399] 5fc0: 00001000 00015000 00000003 00000003 00000002 00000000 00000000 00000000
    [ 55.921560] 5fe0: 7fffe000 be999850 0000a225 b6f3c19c 60000010 00000003 00000000 00000000
    [ 55.929744] [] (charger_get_property) from [] (power_supply_show_property+0x48/0x20c)
    [ 55.939286] [] (power_supply_show_property) from [] (dev_attr_show+0x1c/0x48)
    [ 55.948130] [] (dev_attr_show) from [] (sysfs_kf_seq_show+0x84/0x104)
    [ 55.956298] [] (sysfs_kf_seq_show) from [] (kernfs_seq_show+0x24/0x28)
    [ 55.964536] [] (kernfs_seq_show) from [] (seq_read+0x1b0/0x484)
    [ 55.972172] [] (seq_read) from [] (__vfs_read+0x18/0x4c)
    [ 55.979188] [] (__vfs_read) from [] (vfs_read+0x7c/0x100)
    [ 55.986304] [] (vfs_read) from [] (SyS_read+0x40/0x8c)
    [ 55.993164] [] (SyS_read) from [] (ret_fast_syscall+0x0/0x48)
    [ 56.000626] Code: bad PC value
    [ 56.011652] ---[ end trace 7b64343fbdae8ef1 ]---

    Signed-off-by: Krzysztof Kozlowski
    Reviewed-by: Bartlomiej Zolnierkiewicz

    [for the nvec part]
    Reviewed-by: Marc Dietrich

    [for compal-laptop.c]
    Acked-by: Darren Hart

    [for the mfd part]
    Acked-by: Lee Jones

    [for the hid part]
    Acked-by: Jiri Kosina

    [for the acpi part]
    Acked-by: Rafael J. Wysocki

    Signed-off-by: Sebastian Reichel

    Krzysztof Kozlowski
     
  • Replace direct calls to power supply function attributes with wrappers.
    Wrappers provide safe access in case of unregistering the power
    supply (e.g. by removing the driver). Replace:
    - get_property -> power_supply_get_property

    Signed-off-by: Krzysztof Kozlowski
    Acked-by: Jonghwa Lee
    Acked-by: Pavel Machek
    Reviewed-by: Bartlomiej Zolnierkiewicz
    Reviewed-by: Sebastian Reichel
    Signed-off-by: Sebastian Reichel

    Krzysztof Kozlowski
     
  • Add new structure 'power_supply_config' for holding run-time
    initialization data like of_node, supplies and private driver data.

    The power_supply_register() function is changed so all power supply
    drivers need updating.

    When registering the power supply this new 'power_supply_config' should be
    used instead of directly initializing 'struct power_supply'. This allows
    changing the ownership of power_supply structure from driver to the
    power supply core in next patches.

    When a driver does not use of_node or supplies then it should use NULL
    as config. If driver uses of_node or supplies then it should allocate
    config on stack and initialize it with proper values.

    Signed-off-by: Krzysztof Kozlowski
    Reviewed-by: Bartlomiej Zolnierkiewicz
    Acked-by: Pavel Machek

    [for the nvec part]
    Reviewed-by: Marc Dietrich

    [for drivers/platform/x86/compal-laptop.c]
    Reviewed-by: Darren Hart

    [for drivers/hid/*]
    Reviewed-by: Jiri Kosina

    Signed-off-by: Sebastian Reichel

    Krzysztof Kozlowski
     

22 Jan, 2015

1 commit

  • To guerantee proper charing and managing batteries even in suspend,
    charger-manager has used rtc device with rtc framework interface.
    However, it is better to use alarmtimer for cleaner and more appropriate
    operation.
    This patch makes driver to use alarmtimer for polling work in suspend and
    removes all deprecated codes related with using rtc interface.

    Signed-off-by: Jonghwa Lee
    Signed-off-by: Sebastian Reichel

    Jonghwa Lee
     

15 Dec, 2014

1 commit

  • Pull driver core update from Greg KH:
    "Here's the set of driver core patches for 3.19-rc1.

    They are dominated by the removal of the .owner field in platform
    drivers. They touch a lot of files, but they are "simple" changes,
    just removing a line in a structure.

    Other than that, a few minor driver core and debugfs changes. There
    are some ath9k patches coming in through this tree that have been
    acked by the wireless maintainers as they relied on the debugfs
    changes.

    Everything has been in linux-next for a while"

    * tag 'driver-core-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (324 commits)
    Revert "ath: ath9k: use debugfs_create_devm_seqfile() helper for seq_file entries"
    fs: debugfs: add forward declaration for struct device type
    firmware class: Deletion of an unnecessary check before the function call "vunmap"
    firmware loader: fix hung task warning dump
    devcoredump: provide a one-way disable function
    device: Add dev__once variants
    ath: ath9k: use debugfs_create_devm_seqfile() helper for seq_file entries
    ath: use seq_file api for ath9k debugfs files
    debugfs: add helper function to create device related seq_file
    drivers/base: cacheinfo: remove noisy error boot message
    Revert "core: platform: add warning if driver has no owner"
    drivers: base: support cpu cache information interface to userspace via sysfs
    drivers: base: add cpu_device_create to support per-cpu devices
    topology: replace custom attribute macros with standard DEVICE_ATTR*
    cpumask: factor out show_cpumap into separate helper function
    driver core: Fix unbalanced device reference in drivers_probe
    driver core: fix race with userland in device_add()
    sysfs/kernfs: make read requests on pre-alloc files use the buffer.
    sysfs/kernfs: allow attributes to request write buffer be pre-allocated.
    fs: sysfs: return EGBIG on write if offset is larger than file size
    ...

    Linus Torvalds
     

28 Oct, 2014

3 commits

  • The charger manager obtained in probe references to power supplies for
    all chargers with power_supply_get_by_name() for later usage. However
    if such charger driver was removed then this reference would point to
    old power supply (from driver which was removed).

    This lead to accessing invalid memory which could be observed with:
    $ echo "max77693-charger" > /sys/bus/platform/drivers/max77693-charger/unbind
    $ grep . /sys/devices/virtual/power_supply/battery/charger.0/*
    $ grep . /sys/devices/virtual/power_supply/battery/*
    [ 15.339817] Unable to handle kernel paging request at virtual address 0001c12c
    [ 15.346187] pgd = edd08000
    [ 15.348814] [0001c12c] *pgd=6dce2831, *pte=00000000, *ppte=00000000
    [ 15.355075] Internal error: Oops: 80000007 [#1] PREEMPT SMP ARM
    [ 15.360967] Modules linked in:
    [ 15.364010] CPU: 2 PID: 1388 Comm: grep Not tainted 3.17.0-next-20141007-00027-ga95e761db1b0 #245
    [ 15.372859] task: ee03ad00 ti: edcf6000 task.ti: edcf6000
    [ 15.378241] PC is at 0x1c12c
    [ 15.381113] LR is at is_ext_pwr_online+0x30/0x6c
    [ 15.385706] pc : [] lr : [] psr: a0000013
    [ 15.385706] sp : edcf7e88 ip : 00000000 fp : 00000000
    [ 15.397161] r10: eeb02c08 r9 : c04b1f84 r8 : eeb02c00
    [ 15.402369] r7 : edc69a10 r6 : eea6ac10 r5 : eea6ac10 r4 : 00000004
    [ 15.408878] r3 : 0001c12c r2 : edcf7e8c r1 : 00000004 r0 : ee914418
    [ 15.415390] Flags: NzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user
    [ 15.422506] Control: 10c5387d Table: 6dd0804a DAC: 00000015
    [ 15.428236] Process grep (pid: 1388, stack limit = 0xedcf6240)
    [ 15.434050] Stack: (0xedcf7e88 to 0xedcf8000)
    [ 15.438395] 7e80: ee03ad00 00000000 edcf7f80 eea6aca8 edcf7ec4 c033b7b0
    [ 15.446554] 7ea0: 00000001 ee1cc3f0 00000004 c06e1e44 eebdc000 c06e1e44 eeb02c00 c0337144
    [ 15.454713] 7ec0: ee2dac68 c005cffc ee1cc3c0 c06e1e44 00000fff 00001000 eebdc000 c0278ca8
    [ 15.462872] 7ee0: c0278c8c ee1cc3c0 eeb7ce00 c014422c edcf7f20 00008000 ee1cc3c0 ee9a48c0
    [ 15.471030] 7f00: 00000001 00000001 edcf7f80 c0142d94 c0142d70 c01060f4 00021000 ee1cc3f0
    [ 15.479190] 7f20: 00000000 00000000 c06a2150 eebdc000 2e7ec000 ee9a48c0 00008000 00021000
    [ 15.487349] 7f40: edcf7f80 00008000 edcf6000 00021000 00021000 c00e39a4 00000000 ee9a48c0
    [ 15.495508] 7f60: 00004000 00000000 00000000 ee9a48c0 ee9a48c0 00008000 00021000 c00e3aa0
    [ 15.503668] 7f80: 00000000 00000000 0001f2e0 0001f2e0 00021000 00001000 00000003 c000f364
    [ 15.511826] 7fa0: 00000000 c000f1a0 0001f2e0 00021000 00000003 00021000 00008000 00000000
    [ 15.519986] 7fc0: 0001f2e0 00021000 00001000 00000003 00000001 000205e8 00000000 00021000
    [ 15.528145] 7fe0: 00008000 bebbe910 0000a7ad b6edc49c 60000010 00000003 aaaaaaaa aaaaaaaa
    [ 15.536320] [] (is_ext_pwr_online) from [] (charger_get_property+0x170/0x314)
    [ 15.545164] [] (charger_get_property) from [] (power_supply_show_property+0x48/0x20c)
    [ 15.554719] [] (power_supply_show_property) from [] (dev_attr_show+0x1c/0x48)
    [ 15.563577] [] (dev_attr_show) from [] (sysfs_kf_seq_show+0x84/0x104)
    [ 15.571725] [] (sysfs_kf_seq_show) from [] (kernfs_seq_show+0x24/0x28)
    [ 15.579973] [] (kernfs_seq_show) from [] (seq_read+0x1b0/0x484)
    [ 15.587614] [] (seq_read) from [] (vfs_read+0x88/0x144)
    [ 15.594552] [] (vfs_read) from [] (SyS_read+0x40/0x8c)
    [ 15.601417] [] (SyS_read) from [] (ret_fast_syscall+0x0/0x48)
    [ 15.608877] Code: bad PC value
    [ 15.611991] ---[ end trace a88fcc95208db283 ]---

    The charger-manager should get reference to charger power supply on
    each use of get_property callback.

    Signed-off-by: Krzysztof Kozlowski
    Cc:
    Fixes: 3bb3dbbd56ea ("power_supply: Add initial Charger-Manager driver")
    Signed-off-by: Sebastian Reichel

    Krzysztof Kozlowski
     
  • The charger manager obtained reference to fuel gauge power supply in probe
    with power_supply_get_by_name() for later usage. However if fuel gauge
    driver was removed and re-added then this reference would point to old
    power supply (from driver which was removed).

    This lead to accessing old (and probably invalid) memory which could be
    observed with:
    $ echo "12-0036" > /sys/bus/i2c/drivers/max17042/unbind
    $ echo "12-0036" > /sys/bus/i2c/drivers/max17042/bind
    $ cat /sys/devices/virtual/power_supply/battery/capacity
    [ 240.480084] INFO: task cat:1393 blocked for more than 120 seconds.
    [ 240.484799] Not tainted 3.17.0-next-20141007-00028-ge60b6dd79570 #203
    [ 240.491782] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
    [ 240.499589] cat D c0469530 0 1393 1 0x00000000
    [ 240.505947] [] (__schedule) from [] (schedule_preempt_disabled+0x14/0x20)
    [ 240.514449] [] (schedule_preempt_disabled) from [] (mutex_lock_nested+0x1bc/0x458)
    [ 240.523736] [] (mutex_lock_nested) from [] (regmap_read+0x30/0x60)
    [ 240.531647] [] (regmap_read) from [] (max17042_get_property+0x2e8/0x350)
    [ 240.540055] [] (max17042_get_property) from [] (charger_get_property+0x264/0x348)
    [ 240.549252] [] (charger_get_property) from [] (power_supply_show_property+0x48/0x1e0)
    [ 240.558808] [] (power_supply_show_property) from [] (dev_attr_show+0x1c/0x48)
    [ 240.567664] [] (dev_attr_show) from [] (sysfs_kf_seq_show+0x84/0x104)
    [ 240.575814] [] (sysfs_kf_seq_show) from [] (kernfs_seq_show+0x24/0x28)
    [ 240.584061] [] (kernfs_seq_show) from [] (seq_read+0x1b0/0x484)
    [ 240.591702] [] (seq_read) from [] (vfs_read+0x88/0x144)
    [ 240.598640] [] (vfs_read) from [] (SyS_read+0x40/0x8c)
    [ 240.605507] [] (SyS_read) from [] (ret_fast_syscall+0x0/0x48)
    [ 240.612952] 4 locks held by cat/1393:
    [ 240.616589] #0: (&p->lock){+.+.+.}, at: [] seq_read+0x30/0x484
    [ 240.623414] #1: (&of->mutex){+.+.+.}, at: [] kernfs_seq_start+0x1c/0x8c
    [ 240.631086] #2: (s_active#31){++++.+}, at: [] kernfs_seq_start+0x24/0x8c
    [ 240.638777] #3: (&map->mutex){+.+...}, at: [] regmap_read+0x30/0x60

    The charger-manager should get reference to fuel gauge power supply on
    each use of get_property callback. The thermal zone 'tzd' field of
    power supply should not be used because of the same reason.

    Additionally this change solves also the issue with nested
    thermal_zone_get_temp() calls and related false lockdep positive for
    deadlock for thermal zone's mutex [1]. When fuel gauge is used as source of
    temperature then the charger manager forwards its get_temp calls to fuel
    gauge thermal zone. So actually different mutexes are used (one for
    charger manager thermal zone and second for fuel gauge thermal zone) but
    for lockdep this is one class of mutex.

    The recursion is removed by retrieving temperature through power
    supply's get_property().

    In case external thermal zone is used ('cm-thermal-zone' property is
    present in DTS) the recursion does not exist. Charger manager simply
    exports POWER_SUPPLY_PROP_TEMP_AMBIENT property (instead of
    POWER_SUPPLY_PROP_TEMP) thus no thermal zone is created for this power
    supply.

    [1] https://lkml.org/lkml/2014/10/6/309

    Signed-off-by: Krzysztof Kozlowski
    Cc:
    Fixes: 3bb3dbbd56ea ("power_supply: Add initial Charger-Manager driver")
    Signed-off-by: Sebastian Reichel

    Krzysztof Kozlowski
     
  • The charger manager supports POWER_SUPPLY_PROP_TEMP property and acts
    as a thermal zone if any of these conditions match:
    1. Fuel gauge used by charger manager supports POWER_SUPPLY_PROP_TEMP.
    2. 'cm-thermal-zone' property is present in DTS (then it will supersede
    the fuel gauge temperature property).

    However in case 1 (fuel gauge reports temperature and 'cm-thermal-zone'
    is not set) the charger manager forwards its get_temp calls to fuel
    gauge thermal zone.

    This leads to reporting by lockdep a false positive deadlock for thermal
    zone's mutex because of nested calls to thermal_zone_get_temp(). This is
    false positive because these are different mutexes: one for charger
    manager thermal zone and second for fuel gauge thermal zone.

    Get rid of false lockdep alert and recursive call by setting
    'no_thermal' property for this power supply class. The thermal zone for
    charger manager won't be created (user space does not use it anyway).

    The lockdep report:
    [ 2.540339] charger-manager charger-manager@0: Ignoring full-battery voltage threshold as it is not supplied
    [ 2.540351] charger-manager charger-manager@0: Ignoring full-battery full capacity threshold as it is not supplied
    [ 2.546296]
    [ 2.546302] =============================================
    [ 2.546305] [ INFO: possible recursive locking detected ]
    [ 2.546312] 3.17.0-rc6-next-20140926-00012-gbb13895e46af-dirty #39 Not tainted
    [ 2.546316] ---------------------------------------------
    [ 2.546321] swapper/0/1 is trying to acquire lock:
    [ 2.546348] (&tz->lock){+.+...}, at: [] thermal_zone_get_temp+0x38/0x68
    [ 2.546352]
    [ 2.546352] but task is already holding lock:
    [ 2.546369] (&tz->lock){+.+...}, at: [] thermal_zone_get_temp+0x38/0x68
    [ 2.546373]
    [ 2.546373] other info that might help us debug this:
    [ 2.546376] Possible unsafe locking scenario:
    [ 2.546376]
    [ 2.546378] CPU0
    [ 2.546380] ----
    [ 2.546386] lock(&tz->lock);
    [ 2.546392] lock(&tz->lock);
    [ 2.546394]
    [ 2.546394] *** DEADLOCK ***
    [ 2.546394]
    [ 2.546397] May be due to missing lock nesting notation
    [ 2.546397]
    [ 2.546401] 2 locks held by swapper/0/1:
    [ 2.546430] #0: (&dev->mutex){......}, at: [] __driver_attach+0x58/0x98
    [ 2.546448] #1: (&tz->lock){+.+...}, at: [] thermal_zone_get_temp+0x38/0x68
    [ 2.546451]
    [ 2.546451] stack backtrace:
    [ 2.546460] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.17.0-rc6-next-20140926-00012-gbb13895e46af-dirty #39
    [ 2.546497] [] (unwind_backtrace) from [] (show_stack+0x10/0x14)
    [ 2.546526] [] (show_stack) from [] (dump_stack+0x70/0xbc)
    [ 2.546554] [] (dump_stack) from [] (validate_chain.isra.24+0x718/0x890)
    [ 2.546569] [] (validate_chain.isra.24) from [] (__lock_acquire+0x498/0xa78)
    [ 2.546581] [] (__lock_acquire) from [] (lock_acquire+0x78/0xb8)
    [ 2.546594] [] (lock_acquire) from [] (mutex_lock_nested+0x64/0x458)
    [ 2.546605] [] (mutex_lock_nested) from [] (thermal_zone_get_temp+0x38/0x68)
    [ 2.546634] [] (thermal_zone_get_temp) from [] (charger_get_property+0x10c/0x348)
    [ 2.546649] [] (charger_get_property) from [] (power_supply_read_temp+0x28/0x58)
    [ 2.546662] [] (power_supply_read_temp) from [] (thermal_zone_get_temp+0x4c/0x68)
    [ 2.546676] [] (thermal_zone_get_temp) from [] (thermal_zone_device_update+0x24/0x9c)
    [ 2.546687] [] (thermal_zone_device_update) from [] (thermal_zone_device_register+0x424/0x550)
    [ 2.546701] [] (thermal_zone_device_register) from [] (__power_supply_register+0x2a4/0x348)
    [ 2.546714] [] (__power_supply_register) from [] (charger_manager_probe+0x600/0xe5c)
    [ 2.546727] [] (charger_manager_probe) from [] (platform_drv_probe+0x48/0xa4)
    [ 2.546746] [] (platform_drv_probe) from [] (driver_probe_device+0x10c/0x224)
    [ 2.546760] [] (driver_probe_device) from [] (__driver_attach+0x94/0x98)
    [ 2.546772] [] (__driver_attach) from [] (bus_for_each_dev+0x54/0x88)
    [ 2.546784] [] (bus_for_each_dev) from [] (bus_add_driver+0xd4/0x1d0)
    [ 2.546797] [] (bus_add_driver) from [] (driver_register+0x78/0xf4)
    [ 2.546809] [] (driver_register) from [] (do_one_initcall+0x80/0x1d4)
    [ 2.546829] [] (do_one_initcall) from [] (kernel_init_freeable+0x10c/0x1d8)
    [ 2.546847] [] (kernel_init_freeable) from [] (kernel_init+0x8/0xec)
    [ 2.546863] [] (kernel_init) from [] (ret_from_fork+0x14/0x2c)
    [ 2.551396] charger-manager charger-manager@0: 'chg-reg' regulator's externally_control is 0

    Signed-off-by: Krzysztof Kozlowski
    Signed-off-by: Sebastian Reichel

    Krzysztof Kozlowski
     

20 Oct, 2014

1 commit


26 Sep, 2014

1 commit

  • NULL pointer exception happens during charger-manager probe if
    'cm-fuel-gauge' property is not present.

    [ 2.448536] Unable to handle kernel NULL pointer dereference at virtual address 00000000
    [ 2.456572] pgd = c0004000
    [ 2.459217] [00000000] *pgd=00000000
    [ 2.462759] Internal error: Oops: 5 [#1] PREEMPT SMP ARM
    [ 2.468047] Modules linked in:
    [ 2.471089] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.17.0-rc6-00251-ge44cf96cd525-dirty #969
    [ 2.479765] task: ea890000 ti: ea87a000 task.ti: ea87a000
    [ 2.485161] PC is at strcmp+0x4/0x30
    [ 2.488719] LR is at power_supply_match_device_by_name+0x10/0x1c
    [ 2.494695] pc : [] lr : [] psr: a0000113
    [ 2.494695] sp : ea87bde0 ip : 00000000 fp : eaa97010
    [ 2.506150] r10: 00000004 r9 : ea97269c r8 : ea3bbfd0
    [ 2.511360] r7 : eaa97000 r6 : c030fe28 r5 : 00000000 r4 : ea3b0000
    [ 2.517869] r3 : 0000006d r2 : 00000000 r1 : 00000000 r0 : c057c195
    [ 2.524381] Flags: NzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel
    [ 2.531671] Control: 10c5387d Table: 4000404a DAC: 00000015
    [ 2.537399] Process swapper/0 (pid: 1, stack limit = 0xea87a240)
    [ 2.543388] Stack: (0xea87bde0 to 0xea87c000)
    [ 2.547733] bde0: ea3b0210 c026b1c8 eaa97010 eaa97000 eaa97010 eabb60a8 ea3b0210 00000000
    [ 2.555891] be00: 00000008 ea2db210 ea1a3410 c030fee0 ea3bbf90 c03138fc c068969c c013526c
    [ 2.564050] be20: eaa040c0 00000000 c068969c 00000000 eaa040c0 ea2da300 00000002 00000000
    [ 2.572208] be40: 00000001 ea2da3c0 00000000 00000001 00000000 eaa97010 c068969c 00000000
    [ 2.580367] be60: 00000000 c068969c 00000000 00000002 00000000 c026b71c c026b6f0 eaa97010
    [ 2.588527] be80: c0e82530 c026a330 00000000 eaa97010 c068969c eaa97044 00000000 c061df50
    [ 2.596686] bea0: ea87a000 c026a4dc 00000000 c068969c c026a448 c0268b5c ea8054a8 eaa8fd50
    [ 2.604845] bec0: c068969c ea2db180 c06801f8 c0269b18 c0590f68 c068969c c0656c98 c068969c
    [ 2.613004] bee0: c0656c98 ea3bbe40 c06988c0 c026aaf0 00000000 c0656c98 c0656c98 c00088a4
    [ 2.621163] bf00: 00000000 c0055f48 00000000 00000004 00000000 ea890000 c05dbc54 c062c178
    [ 2.629323] bf20: c0603518 c005f674 00000001 ea87a000 eb7ff83b c0476440 00000091 c003d41c
    [ 2.637482] bf40: c05db344 00000007 eb7ff858 00000007 c065a76c c0647d24 00000007 c062c170
    [ 2.645642] bf60: c06988c0 00000091 c062c178 c0603518 00000000 c0603cc4 00000007 00000007
    [ 2.653801] bf80: c0603518 c0c0c0c0 00000000 c0453948 00000000 00000000 00000000 00000000
    [ 2.661959] bfa0: 00000000 c0453950 00000000 c000e728 00000000 00000000 00000000 00000000
    [ 2.670118] bfc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
    [ 2.678277] bfe0: 00000000 00000000 00000000 00000000 00000013 00000000 c0c0c0c0 c0c0c0c0
    [ 2.686454] [] (strcmp) from [] (power_supply_match_device_by_name+0x10/0x1c)
    [ 2.695303] [] (power_supply_match_device_by_name) from [] (class_find_device+0x54/0xac)
    [ 2.705106] [] (class_find_device) from [] (power_supply_get_by_name+0x1c/0x30)
    [ 2.714137] [] (power_supply_get_by_name) from [] (charger_manager_probe+0x3d8/0xe58)
    [ 2.723683] [] (charger_manager_probe) from [] (platform_drv_probe+0x2c/0x5c)
    [ 2.732532] [] (platform_drv_probe) from [] (driver_probe_device+0x10c/0x224)
    [ 2.741384] [] (driver_probe_device) from [] (__driver_attach+0x94/0x98)
    [ 2.749813] [] (__driver_attach) from [] (bus_for_each_dev+0x54/0x88)
    [ 2.757969] [] (bus_for_each_dev) from [] (bus_add_driver+0xd4/0x1d0)
    [ 2.766123] [] (bus_add_driver) from [] (driver_register+0x78/0xf4)
    [ 2.774110] [] (driver_register) from [] (do_one_initcall+0x80/0x1bc)
    [ 2.782276] [] (do_one_initcall) from [] (kernel_init_freeable+0x100/0x1cc)
    [ 2.790952] [] (kernel_init_freeable) from [] (kernel_init+0x8/0xec)
    [ 2.799029] [] (kernel_init) from [] (ret_from_fork+0x14/0x2c)
    [ 2.806572] Code: e12fff1e e1a03000 eafffff7 e4d03001 (e4d12001)
    [ 2.812832] ---[ end trace 7f12556111b9e7ef ]---

    Signed-off-by: Krzysztof Kozlowski
    Cc:
    Fixes: 856ee6115e2d ("charger-manager: Support deivce tree in charger manager driver")
    Signed-off-by: Sebastian Reichel

    Krzysztof Kozlowski
     

07 Sep, 2014

3 commits

  • Casting the return value which is a void pointer is redundant.
    The conversion from void pointer to any other pointer type is
    guaranteed by the C programming language.

    Signed-off-by: Jingoo Han
    Signed-off-by: Sebastian Reichel

    Jingoo Han
     
  • This patch check the charging state after completed initialization of charger-
    manager and update current charging state. If charger-manager never check and
    update current charging state, charger-manager would have the mismatch issue
    between real state of cable connection and the charging state of charger-manager
    until first polling time of charger-manager.

    Signed-off-by: Chanwoo Choi
    Acked-by: Myungjoo Ham
    Signed-off-by: Sebastian Reichel

    Chanwoo Choi
     
  • This patch fix minor issue about checking wrong return type.

    The of_cm_parse_desc() return ERR_PTR(errnor number) when some error happen
    in this function. But, charger_manager_probe() has only checked whether
    desc is NULL or not. If of_cm_parse_desc() returns ERR_PTR(-ENOMEM), desc
    isn't NULL but desc is (void *)(-ENOMEM). Althouhg some error happen for parsing
    DT, charger_manager_probe() can't detect error of desc instance.

    Signed-off-by: Chanwoo Choi
    Acked-by: Myungjoo Ham
    Signed-off-by: Sebastian Reichel

    Chanwoo Choi
     

24 Dec, 2013

3 commits

  • Fixes the following warning:

    drivers/power/charger-manager.c:1539:21: warning: symbol
    'of_cm_parse_desc' was not declared. Should it be static?

    Signed-off-by: Anton Vorontsov

    Anton Vorontsov
     
  • Charger-manager can parse charger_desc data from devicetree which is used
    to register charger manager.

    Signed-off-by: Jonghwa Lee
    Signed-off-by: Myungjoo Ham
    Signed-off-by: Anton Vorontsov

    Jonghwa Lee
     
  • Charger-manager driver used to check battery temperature through the
    callback function passed by platform data. Unfortunatley, without that
    pre-defined callback function, charger-manager can't get battery's
    temperature at all. Also passing callback function through platform data
    ruins DT support for charger-manager.

    This patch mondifies charger-manager driver to get temperature of battery
    without pre-defined callback function. Now, charger-manager can use either
    of battery thermometer in fuel-gauge and ouside of battery. It uses
    thermal framework interface for outer thermometer if thermal fw is
    enabled. Otherwise, it tries to use fuel-gauge's through the power supply
    interface.

    Signed-off-by: Jonghwa Lee
    Signed-off-by: Myungjoo Ham
    Signed-off-by: Anton Vorontsov

    Jonghwa Lee
     

26 Oct, 2013

1 commit


29 Jun, 2013

2 commits

  • This patch fixes return value checking of regulator_get() in
    charger-manager driver. The API, regulator_get(), returns ERR_PTR() when
    it fails to get regulator with given name, not NULL.

    Signed-off-by: Jonghwa Lee
    Signed-off-by: Myungjoo Ham
    Acked-by: Chanwoo Choi
    Signed-off-by: Anton Vorontsov

    Jonghwa Lee
     
  • This patch prevents NULL pointer error cauesed by unregistering
    unregistered exton notifier block. At the probing time of charger manager,
    it tries to remove extcon notifier block when it fails to initialize them.
    It has to be applied for only registered one. Otherwise, it'd make kernel
    panic. To make it work right, it checks extcon_specific_cable_nb's
    extcon_dev node. If extcon cable notifier block was registered
    successfully, it has proper extcon_dev pointer if not so it has NULL
    pointer.

    Signed-off-by: Jonghwa Lee
    Signed-off-by: Myungjoo Ham
    Acked-by: Chanwoo Choi
    Signed-off-by: Anton Vorontsov

    Jonghwa Lee
     

10 Jun, 2013

1 commit

  • Make sure that dev_ calls are newline terminated.
    Add #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt to prefix
    all pr_ calls with "charger-manager: "

    Fix a couple of typos.
    Fix formats with terminating n that should be \n.
    Coalesce formats for easier grep.
    Align arguments to open parenthesis for these dev_ calls.
    Add missing spaces after coalescing multiple string segments.

    Signed-off-by: Joe Perches
    Acked-by: Kees Cook
    Signed-off-by: Anton Vorontsov

    Joe Perches
     

07 Jun, 2013

1 commit


17 Apr, 2013

1 commit


06 Jan, 2013

2 commits

  • There's no need to test whether a (delayed) work item in pending
    before queueing, flushing or cancelling it. Most uses are unnecessary
    and quite a few of them are buggy.

    Remove unnecessary pending tests and rewrite _setup_polling() so that
    it uses mod_delayed_work() if the next polling interval is sooner than
    currently scheduled. queue_delayed_work() is used otherwise.

    Only compile tested. I noticed that two work items - setup_polling
    and cm_monitor_work - schedule each other. It's a very unusual
    construct and I'm fairly sure it's racy. You can't break such
    circular dependency by calling cancel on each. I strongly recommend
    revising the mechanism.

    Signed-off-by: Tejun Heo
    Cc: Anton Vorontsov
    Cc: David Woodhouse
    Cc: Donggeun Kim
    Cc: MyungJoo Ham
    Signed-off-by: Anton Vorontsov

    Tejun Heo
     
  • This patch split _probe function for readability because _probe function
    is longer than 400 line.

    Signed-off-by: Chanwoo Choi
    Signed-off-by: Myungjoo Ham
    Signed-off-by: Kyungmin Park
    Signed-off-by: Anton Vorontsov

    Chanwoo Choi
     

17 Dec, 2012

2 commits

  • This patch check difference value between current voltage of battery and
    desc->fullbatt_uV whether positve or negative number. If difference value
    is negative number when current voltage of battery is larger than
    desc->fullbatt_uV, charger-manager return immediately because battery is
    fully charged.

    Signed-off-by: Chanwoo Choi
    Signed-off-by: Myungjoo Ham
    Signed-off-by: Kyungmin Park
    Signed-off-by: Anton Vorontsov

    Chanwoo Choi
     
  • This patch fix bug related to checking fully charged state of battery when
    charger-manager call is_full_charged() function. After reading property of
    charger/fuel-gauge through power_supply API, val.intval is more than 1.
    So, is_full_charged() function always return true. If true, battery means
    fully charged state.

    Signed-off-by: Chanwoo Choi
    Signed-off-by: Myungjoo Ham
    Signed-off-by: Kyungmin Park
    Signed-off-by: Anton Vorontsov

    Chanwoo Choi
     

29 Nov, 2012

2 commits


07 Oct, 2012

1 commit

  • Pull battery updates from Anton Vorontsov:
    "1. New drivers:
    - Marvell 88pm860x charger and battery drivers;
    - Texas Instruments LP8788 charger driver;
    2. Two new power supply properties: whether a battery is authentic,
    and chargers' maximal currents and voltages;
    3. A lot of TI LP8727 Charger cleanups;
    4. New features for Charger Manager, mainly now we can disable
    specific regulators;
    5. Random fixes and cleanups for other drivers."

    Fix up trivial conflicts in

    * tag 'for-v3.7' of git://git.infradead.org/battery-2.6: (52 commits)
    pda_power: Remove ac_draw_failed goto and label
    charger-manager: Add support sysfs entry for charger
    charger-manager: Support limit of maximum possible
    charger-manager: Check fully charged state of battery periodically
    lp8727_charger: More pure cosmetic improvements
    lp8727_charger: Fix checkpatch warning
    lp8727_charger: Add description in the private data
    lp8727_charger: Fix a typo - chg_parm to chg_param
    lp8727_charger: Make some cosmetic changes in lp8727_delayed_func()
    lp8727_charger: Clean up lp8727_charger_changed()
    lp8727_charger: Return if the battery is discharging
    lp8727_charger: Make lp8727_charger_get_propery() simpler
    lp8727_charger: Make lp8727_ctrl_switch() inline
    lp8727_charger: Make lp8727_init_device() shorter
    lp8727_charger: Clean up lp8727_is_charger_attached()
    lp8727_charger: Use specific definition
    lp8727_charger: Clean up lp8727 definitions
    lp8727_charger: Use the definition rather than enum
    lp8727_charger: Fix code for getting battery temp
    lp8727_charger: Clear interrrupts at inital time
    ...

    Linus Torvalds
     

22 Sep, 2012

1 commit

  • This patch add support sysfs entry for each charger(regulator).
    Charger-manager use one or more chargers for charging battery but some
    charger isn't necessary on specific scenario. So, if some charger isn't
    needed, can disable specific charger through 'externally_control' entry
    while system is on state and confirm the information(name, state) of
    charger.

    The list of added sysfs entry
    - /sys/class/power_supply/battery/chargers/charger.[index]/name
    show name of charger(regulator)
    - /sys/class/power_supply/battery/chargers/charger.[index]/state
    show either enabled or disabled state of charger
    - /sys/class/power_supply/battery/chargers/charger.[index]/externally_control

    If 'externally_control' of specific charger is 1, Charger-manager cannot
    enable regulator for charging when charger cable is attached and charger
    must be maintained with disabled state. If 'externally_control' is zero,
    Charger-manager usually can control to enable/disable regulator.

    Signed-off-by: Chanwoo Choi
    Signed-off-by: Myungjoo Ham
    Signed-off-by: Kyungmin Park
    Signed-off-by: Anton Vorontsov

    Chanwoo Choi
     

21 Sep, 2012

2 commits

  • This patch check maximum possible duration of charging/discharging.

    If whole charging duration exceed 'desc->charging_max_duration_ms', cm
    stop charging to prevent overcharge/overheat. And if discharging duration
    exceed, charger cable is attached, after full-batt, cm start charging to
    maintain fully charged state for battery.

    Signed-off-by: Chanwoo Choi
    Signed-off-by: Myungjoo Ham
    Signed-off-by: Kyungmin Park
    Signed-off-by: Anton Vorontsov

    Chanwoo Choi
     
  • This patch check periodically fully charged state of battery to protect
    overcharge and overheat. If battery is fully charged, stop charging and
    check droped voltage with 'fullbatt_vchkdrop_ms' period. When voltage of
    battery is more droped than 'fullbatt_vchkdrop_uV' voltage,
    charger-manager will restart charging for battery.

    Signed-off-by: Chanwoo Choi
    Signed-off-by: Myungjoo Ham
    Signed-off-by: Kyungmin Park
    Signed-off-by: Anton Vorontsov

    Chanwoo Choi
     

23 Aug, 2012

2 commits