From: Marek Vasut <marex@denx.de>
To: Hans de Goede <hdegoede@redhat.com>, Sebastian Reichel <sre@kernel.org>
Cc: linux-pm@vger.kernel.org
Subject: Re: [PATCH 03/10] power: supply: bq25890: Fix usb-notifier probe and remove races
Date: Sun, 27 Nov 2022 22:19:37 +0100 [thread overview]
Message-ID: <37d21fd9-cd80-45c0-695b-bc121c43833b@denx.de> (raw)
In-Reply-To: <20221127180233.103678-4-hdegoede@redhat.com>
On 11/27/22 19:02, Hans de Goede wrote:
> There are 2 races surrounding the usb-notifier:
>
> 1. The notifier, and thus usb_work, may run before the bq->charger
> power_supply class device is registered. But usb_work may call
> power_supply_changed() which relies on the psy device being registered.
>
> 2. usb_work may be pending/running at remove() time, so it needs to be
> cancelled on remove after unregistering the usb-notifier.
>
> Fix 1. by moving usb-notifier registration to after the power_supply
> registration.
>
> Fix 2. by adding a cancel_work_sync() call directly after the usb-notifier
> unregistration.
>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
> drivers/power/supply/bq25890_charger.c | 26 +++++++++++---------------
> 1 file changed, 11 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c
> index 30d77afab839..032a10a3877b 100644
> --- a/drivers/power/supply/bq25890_charger.c
> +++ b/drivers/power/supply/bq25890_charger.c
> @@ -1387,16 +1387,10 @@ static int bq25890_probe(struct i2c_client *client)
> if (ret)
> return ret;
>
> - if (!IS_ERR_OR_NULL(bq->usb_phy)) {
> - INIT_WORK(&bq->usb_work, bq25890_usb_work);
> - bq->usb_nb.notifier_call = bq25890_usb_notifier;
> - usb_register_notifier(bq->usb_phy, &bq->usb_nb);
> - }
> -
> ret = bq25890_power_supply_init(bq);
> if (ret < 0) {
> dev_err(dev, "Failed to register power supply\n");
> - goto err_unregister_usb_notifier;
> + return ret;
You can even use 'return dev_err_probe()' above ^ to simplify that piece
of code now.
Reviewed-by: Marek Vasut <marex@denx.de>
next prev parent reply other threads:[~2022-11-27 21:36 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-27 18:02 [PATCH 00/10] power: supply: bq25890: Fixes for 6.2 + further work for 6.3 Hans de Goede
2022-11-27 18:02 ` [PATCH 01/10] power: supply: bq25890: Only use pdata->regulator_init_data for vbus Hans de Goede
2022-11-27 21:16 ` Marek Vasut
2022-11-27 23:30 ` Sebastian Reichel
2022-11-27 18:02 ` [PATCH 02/10] power: supply: bq25890: Ensure pump_express_work is cancelled on remove Hans de Goede
2022-11-27 21:17 ` Marek Vasut
2022-11-27 23:17 ` Sebastian Reichel
2022-11-28 7:20 ` Hans de Goede
2022-11-27 18:02 ` [PATCH 03/10] power: supply: bq25890: Fix usb-notifier probe and remove races Hans de Goede
2022-11-27 21:19 ` Marek Vasut [this message]
2022-11-27 18:02 ` [PATCH 04/10] power: supply: bq25890: Factor out chip state update Hans de Goede
2022-11-27 18:02 ` [PATCH 05/10] power: supply: bq25890: Add HiZ mode support Hans de Goede
2022-11-27 18:02 ` [PATCH 06/10] power: supply: bq25890: Fix setting of F_CONV_RATE rate when disabling HiZ mode Hans de Goede
2022-11-27 21:24 ` Marek Vasut
2022-11-27 18:02 ` [PATCH 07/10] power: supply: bq25890: Always take HiZ mode into account for ADC rate Hans de Goede
2022-11-27 21:25 ` Marek Vasut
2022-11-27 18:02 ` [PATCH 08/10] power: supply: bq25890: Support boards with more then one charger IC Hans de Goede
2022-11-27 21:27 ` Marek Vasut
2022-11-27 18:02 ` [PATCH 09/10] power: supply: bq25890: Add support for having a secondary " Hans de Goede
2022-11-27 21:33 ` Marek Vasut
2022-11-27 18:02 ` [PATCH 10/10] power: supply: bq25890: Add new linux,iinlim-percentage property Hans de Goede
2022-11-27 21:34 ` Marek Vasut
2022-11-28 9:16 ` Hans de Goede
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=37d21fd9-cd80-45c0-695b-bc121c43833b@denx.de \
--to=marex@denx.de \
--cc=hdegoede@redhat.com \
--cc=linux-pm@vger.kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox