All of lore.kernel.org
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <k.kozlowski@samsung.com>
To: Sebastian Reichel <sre@kernel.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Len Brown <lenb@kernel.org>,
	Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>,
	David Woodhouse <dwmw2@infradead.org>,
	Pavel Machek <pavel@ucw.cz>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org,
	linux-pm@vger.kernel.org
Subject: Re: [RFC PATCHv2 00/19] power_supply: Allow safe usage of power supply
Date: Wed, 21 Jan 2015 16:42:43 +0100	[thread overview]
Message-ID: <1421854963.12894.1.camel@AMDC1943> (raw)
In-Reply-To: <20150121152216.GD13715@earth.universe>

On śro, 2015-01-21 at 16:22 +0100, Sebastian Reichel wrote:
> Hi Krzysztof,
> 
> On Mon, Jan 05, 2015 at 04:47:43PM +0100, Krzysztof Kozlowski wrote:
> > This is RFC, please don't apply yet but let me know if this approach
> > is OK.
> 
> I just reviewed the patchset. It looks fine to me.

Great! Thanks for looking at patchset. I'll start working on next
version adjusting all drivers.

> 
> > TLDR
> > ====
> > Patchset tries to fix following race scenario:
> > 
> > Thread 1: charger manager, CONSUMER
> > Thread 2: power supply driver, PROVIDER
> > 
> > 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()
> > 
> > To properly fix the race the patchset:
> > 1. Adds power_supply_get_property()-like API for safe access by consumer.
> > 2. Moves ownership of power_supply structure from driver (provider) to
> >    power supply core.
> > 3. Adds power_supply_put() which will reclaim memory.
> 
> Looks fine to me, thanks for doing this :)
> 
> > Description
> > =========== 
> > This is a little different than my previous approaches [1][2] for fixing
> > usage of power supply by some consumer, if driver implementing it is
> > unbound.
> > 
> > The patchset is quite big and touches power supply API so a lot of
> > changes in drivers are needed. These changes *are not finished yet*.
> > I've done them only for:
> >  - bq24190_charger.c
> >  - charger-manager.c
> >  - max14577_charger.c
> >  - max17040_battery.c
> >  - max17042_battery.c
> >  - sbs-battery.c
> >  - tps65090-charger.c
> > So allyesconfig won't build.
> >
> > If this approach is OK, I'll prepare full patchset changing all the
> > drivers.
> 
> Please do :)
> 
> > My previous approach [1][2] limited the race but did not close it.
> > Still the consumer of power supply by calling power_supply_get_propert(psy...)
> > may reference invalid memory because the producer freed it.
> > 
> > Actually, because struct power_supply is exposed to consumers, the
> > core should be the owner of it. This is accomplished in patch 11/19
> > ("power_supply: Change ownership from driver to core").
> > 
> > What the patchset does in steps
> > ===============================
> > 1. Some preparation steps are necessary - patch 1 and 2. The driver
> >    implementing power supply won't be able to fill structure before
> >    calling power_supply_register(). So 'power_supply_config'
> >    is introduced in patch 2 ("power_supply: Move run-time configuration
> >    to separate structure"). Unfortunately this touches all drivers.
> 
> $ grep -l power_supply_register **/*.c | grep -v mod.c | grep -v drivers/power
> drivers/acpi/ac.c
> drivers/acpi/battery.c
> drivers/acpi/sbs.c
> drivers/hid/hid-input.c
> drivers/hid/hid-sony.c
> drivers/hid/hid-wiimote-modules.c
> drivers/hid/wacom_sys.c
> drivers/platform/x86/compal-laptop.c
> drivers/staging/nvec/nvec_power.c
> 
> Please make sure to CC the respective maintainers for the patchset
> (e.g. current patch 14 and 15 should have CC'd x86 maintainers), so
> that they can Acknowledge the patchset.

Right. Probably maintainers should receive full patchset anyway. The
address list will be quite big.

> 
> > 2. Safe API wrappers (and usage counter) are added (power_supply_*()).
> > 3. Patch 11: ownership of 'struct power_supply' is moved from driver
> >    to the core.
> > 4. power_supply_put() is added which reclaims resources.
> 
> Looks fine to me.
> 
> > The patchset is rebased on next-20141226. It should be pulled at once.
> > Bisectability is preserved.
> 
> Fine with me, but I need acks from all involved maintainers. So for the
> patchset:
> 
> Reviewed-By: Sebastian Reichel <sre@kernel.org>

Thanks!

Best regards,
Krzysztof




WARNING: multiple messages have this Message-ID (diff)
From: k.kozlowski@samsung.com (Krzysztof Kozlowski)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCHv2 00/19] power_supply: Allow safe usage of power supply
Date: Wed, 21 Jan 2015 16:42:43 +0100	[thread overview]
Message-ID: <1421854963.12894.1.camel@AMDC1943> (raw)
In-Reply-To: <20150121152216.GD13715@earth.universe>

On ?ro, 2015-01-21 at 16:22 +0100, Sebastian Reichel wrote:
> Hi Krzysztof,
> 
> On Mon, Jan 05, 2015 at 04:47:43PM +0100, Krzysztof Kozlowski wrote:
> > This is RFC, please don't apply yet but let me know if this approach
> > is OK.
> 
> I just reviewed the patchset. It looks fine to me.

Great! Thanks for looking at patchset. I'll start working on next
version adjusting all drivers.

> 
> > TLDR
> > ====
> > Patchset tries to fix following race scenario:
> > 
> > Thread 1: charger manager, CONSUMER
> > Thread 2: power supply driver, PROVIDER
> > 
> > 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()
> > 
> > To properly fix the race the patchset:
> > 1. Adds power_supply_get_property()-like API for safe access by consumer.
> > 2. Moves ownership of power_supply structure from driver (provider) to
> >    power supply core.
> > 3. Adds power_supply_put() which will reclaim memory.
> 
> Looks fine to me, thanks for doing this :)
> 
> > Description
> > =========== 
> > This is a little different than my previous approaches [1][2] for fixing
> > usage of power supply by some consumer, if driver implementing it is
> > unbound.
> > 
> > The patchset is quite big and touches power supply API so a lot of
> > changes in drivers are needed. These changes *are not finished yet*.
> > I've done them only for:
> >  - bq24190_charger.c
> >  - charger-manager.c
> >  - max14577_charger.c
> >  - max17040_battery.c
> >  - max17042_battery.c
> >  - sbs-battery.c
> >  - tps65090-charger.c
> > So allyesconfig won't build.
> >
> > If this approach is OK, I'll prepare full patchset changing all the
> > drivers.
> 
> Please do :)
> 
> > My previous approach [1][2] limited the race but did not close it.
> > Still the consumer of power supply by calling power_supply_get_propert(psy...)
> > may reference invalid memory because the producer freed it.
> > 
> > Actually, because struct power_supply is exposed to consumers, the
> > core should be the owner of it. This is accomplished in patch 11/19
> > ("power_supply: Change ownership from driver to core").
> > 
> > What the patchset does in steps
> > ===============================
> > 1. Some preparation steps are necessary - patch 1 and 2. The driver
> >    implementing power supply won't be able to fill structure before
> >    calling power_supply_register(). So 'power_supply_config'
> >    is introduced in patch 2 ("power_supply: Move run-time configuration
> >    to separate structure"). Unfortunately this touches all drivers.
> 
> $ grep -l power_supply_register **/*.c | grep -v mod.c | grep -v drivers/power
> drivers/acpi/ac.c
> drivers/acpi/battery.c
> drivers/acpi/sbs.c
> drivers/hid/hid-input.c
> drivers/hid/hid-sony.c
> drivers/hid/hid-wiimote-modules.c
> drivers/hid/wacom_sys.c
> drivers/platform/x86/compal-laptop.c
> drivers/staging/nvec/nvec_power.c
> 
> Please make sure to CC the respective maintainers for the patchset
> (e.g. current patch 14 and 15 should have CC'd x86 maintainers), so
> that they can Acknowledge the patchset.

Right. Probably maintainers should receive full patchset anyway. The
address list will be quite big.

> 
> > 2. Safe API wrappers (and usage counter) are added (power_supply_*()).
> > 3. Patch 11: ownership of 'struct power_supply' is moved from driver
> >    to the core.
> > 4. power_supply_put() is added which reclaims resources.
> 
> Looks fine to me.
> 
> > The patchset is rebased on next-20141226. It should be pulled at once.
> > Bisectability is preserved.
> 
> Fine with me, but I need acks from all involved maintainers. So for the
> patchset:
> 
> Reviewed-By: Sebastian Reichel <sre@kernel.org>

Thanks!

Best regards,
Krzysztof

  reply	other threads:[~2015-01-21 15:42 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-05 15:47 [RFC PATCHv2 00/19] power_supply: Allow safe usage of power supply Krzysztof Kozlowski
2015-01-05 15:47 ` Krzysztof Kozlowski
2015-01-05 15:47 ` [RFC PATCHv2 01/19] power_supply: Add driver private data Krzysztof Kozlowski
2015-01-05 15:47   ` Krzysztof Kozlowski
2015-01-05 15:47 ` [RFC PATCHv2 02/19] power_supply: Move run-time configuration to separate structure Krzysztof Kozlowski
2015-01-05 15:47   ` Krzysztof Kozlowski
2015-01-05 15:47 ` [RFC PATCHv2 03/19] power_supply: Add API for safe access of power supply function attrs Krzysztof Kozlowski
2015-01-05 15:47   ` Krzysztof Kozlowski
2015-01-05 15:47 ` [RFC PATCHv2 04/19] power_supply: sysfs: Use power_supply_*() API for accessing " Krzysztof Kozlowski
2015-01-05 15:47   ` Krzysztof Kozlowski
2015-01-05 15:47 ` [RFC PATCHv2 05/19] power: 88pm860x_charger: " Krzysztof Kozlowski
2015-01-05 15:47   ` Krzysztof Kozlowski
2015-01-05 15:47 ` [RFC PATCHv2 06/19] power: ab8500: " Krzysztof Kozlowski
2015-01-05 15:47   ` Krzysztof Kozlowski
2015-01-05 15:47 ` [RFC PATCHv2 07/19] mfd: " Krzysztof Kozlowski
2015-01-05 15:47   ` Krzysztof Kozlowski
2015-01-20 13:36   ` Lee Jones
2015-01-20 13:36     ` Lee Jones
2015-01-20 14:16     ` Krzysztof Kozlowski
2015-01-20 14:16       ` Krzysztof Kozlowski
2015-01-20 15:51       ` Lee Jones
2015-01-20 15:51         ` Lee Jones
2015-01-20 16:01         ` Krzysztof Kozlowski
2015-01-20 16:01           ` Krzysztof Kozlowski
2015-01-20 16:26           ` Lee Jones
2015-01-20 16:26             ` Lee Jones
2015-01-20 16:26             ` Lee Jones
2015-01-20 16:06         ` Pavel Machek
2015-01-20 16:06           ` Pavel Machek
2015-01-05 15:47 ` [RFC PATCHv2 08/19] power: apm_power: " Krzysztof Kozlowski
2015-01-05 15:47   ` Krzysztof Kozlowski
2015-01-05 15:47 ` [RFC PATCHv2 09/19] power: bq2415x_charger: " Krzysztof Kozlowski
2015-01-05 15:47   ` Krzysztof Kozlowski
2015-01-05 15:47 ` [RFC PATCHv2 10/19] power: charger-manager: " Krzysztof Kozlowski
2015-01-05 15:47   ` Krzysztof Kozlowski
2015-01-05 15:47 ` [RFC PATCHv2 11/19] power_supply: Change ownership from driver to core Krzysztof Kozlowski
2015-01-05 15:47   ` Krzysztof Kozlowski
2015-01-05 15:47 ` [RFC PATCHv2 12/19] power_supply: Add power_supply_put for decrementing device reference counter Krzysztof Kozlowski
2015-01-05 15:47   ` Krzysztof Kozlowski
2015-01-05 15:47 ` [RFC PATCHv2 13/19] power: charger-manager: Decrement the power supply's " Krzysztof Kozlowski
2015-01-05 15:47   ` Krzysztof Kozlowski
2015-01-05 15:47 ` [RFC PATCHv2 14/19] x86/olpc/xo1/sci: Use newly added power_supply_put API Krzysztof Kozlowski
2015-01-05 15:47   ` Krzysztof Kozlowski
2015-01-05 15:47 ` [RFC PATCHv2 15/19] x86/olpc/xo15/sci: " Krzysztof Kozlowski
2015-01-05 15:47   ` Krzysztof Kozlowski
2015-01-05 15:47 ` [RFC PATCHv2 16/19] power: 88pm860x_charger: Decrement the power supply's device reference counter Krzysztof Kozlowski
2015-01-05 15:47   ` Krzysztof Kozlowski
2015-01-05 15:48 ` [RFC PATCHv2 17/19] power: bq2415x_charger: " Krzysztof Kozlowski
2015-01-05 15:48   ` Krzysztof Kozlowski
2015-01-05 15:48 ` [RFC PATCHv2 18/19] mfd: ab8500: " Krzysztof Kozlowski
2015-01-05 15:48   ` Krzysztof Kozlowski
2015-01-20 13:36   ` Lee Jones
2015-01-20 13:36     ` Lee Jones
2015-01-05 15:48 ` [RFC PATCHv2 19/19] arm: mach-pxa: " Krzysztof Kozlowski
2015-01-05 15:48   ` Krzysztof Kozlowski
2015-01-21 15:22 ` [RFC PATCHv2 00/19] power_supply: Allow safe usage of power supply Sebastian Reichel
2015-01-21 15:22   ` Sebastian Reichel
2015-01-21 15:42   ` Krzysztof Kozlowski [this message]
2015-01-21 15:42     ` Krzysztof Kozlowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1421854963.12894.1.camel@AMDC1943 \
    --to=k.kozlowski@samsung.com \
    --cc=dbaryshkov@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=rjw@rjwysocki.net \
    --cc=sre@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.