Message ID | 20230413095405.71685-10-hdegoede@redhat.com (mailing list archive) |
---|---|
State | Handled Elsewhere, archived |
Headers | show |
Series | power: supply: bq27xxx/bq25890 status update fixes | expand |
Hi, On 4/13/23 11:54, Hans de Goede wrote: > The bq25892 model relies on external charger-type detection and once > that is done the bq25890_charger code will update the input current > and if pumpexpress is used also the input voltage. > > In this case, when the initial power_supply_changed() call is made > from the interrupt handler, the input settings are 5V/0.5A which > on many devices is not enough power to charge (while the device is on). > > On many devices the fuel-gauge relies in its external_power_changed > callback to timely signal userspace about charging <-> discharging > status changes. Add a power_supply_changed() call after updating > the input current or voltage. This allows the fuel-gauge driver > to timely recheck if the battery is charging after the new input > settings have been applied and then it can immediately notify > userspace about this. > > Fixes: 48f45b094dbb ("power: supply: bq25890: Support higher charging voltages through Pump Express+ protocol") > Fixes: eab25b4f93aa ("power: supply: bq25890: On the bq25892 set the IINLIM based on external charger detection") > Signed-off-by: Hans de Goede <hdegoede@redhat.com> > --- > drivers/power/supply/bq25890_charger.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c > index bfe08d7bfaf3..794512285629 100644 > --- a/drivers/power/supply/bq25890_charger.c > +++ b/drivers/power/supply/bq25890_charger.c > @@ -775,6 +775,7 @@ static void bq25890_charger_external_power_changed(struct power_supply *psy) > } > > bq25890_field_write(bq, F_IINLIM, input_current_limit); > + power_supply_changed(bq->charger); Self NACK I just finished debugging a crash related to a race between external_power_changed() callbacks and these callbacks using the result of power_supply_register(). Referring to the psy for which the external power has changed in external_power_changed() callbacks must always be done through the psy argument. More info in my series fixing these races when I'm done preparting the series. For now please don't merge this patch, note patches 1-8 are still fine. I'll post a v2 series later. Regards, Hans > } > > static int bq25890_get_chip_state(struct bq25890_device *bq, > @@ -1106,6 +1107,8 @@ static void bq25890_pump_express_work(struct work_struct *data) > dev_info(bq->dev, "Hi-voltage charging requested, input voltage is %d mV\n", > voltage); > > + power_supply_changed(bq->charger); > + > return; > error_print: > bq25890_field_write(bq, F_PUMPX_EN, 0);
diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c index bfe08d7bfaf3..794512285629 100644 --- a/drivers/power/supply/bq25890_charger.c +++ b/drivers/power/supply/bq25890_charger.c @@ -775,6 +775,7 @@ static void bq25890_charger_external_power_changed(struct power_supply *psy) } bq25890_field_write(bq, F_IINLIM, input_current_limit); + power_supply_changed(bq->charger); } static int bq25890_get_chip_state(struct bq25890_device *bq, @@ -1106,6 +1107,8 @@ static void bq25890_pump_express_work(struct work_struct *data) dev_info(bq->dev, "Hi-voltage charging requested, input voltage is %d mV\n", voltage); + power_supply_changed(bq->charger); + return; error_print: bq25890_field_write(bq, F_PUMPX_EN, 0);
The bq25892 model relies on external charger-type detection and once that is done the bq25890_charger code will update the input current and if pumpexpress is used also the input voltage. In this case, when the initial power_supply_changed() call is made from the interrupt handler, the input settings are 5V/0.5A which on many devices is not enough power to charge (while the device is on). On many devices the fuel-gauge relies in its external_power_changed callback to timely signal userspace about charging <-> discharging status changes. Add a power_supply_changed() call after updating the input current or voltage. This allows the fuel-gauge driver to timely recheck if the battery is charging after the new input settings have been applied and then it can immediately notify userspace about this. Fixes: 48f45b094dbb ("power: supply: bq25890: Support higher charging voltages through Pump Express+ protocol") Fixes: eab25b4f93aa ("power: supply: bq25890: On the bq25892 set the IINLIM based on external charger detection") Signed-off-by: Hans de Goede <hdegoede@redhat.com> --- drivers/power/supply/bq25890_charger.c | 3 +++ 1 file changed, 3 insertions(+)