Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8e10ab0d authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "power: smb-lib: Fix mutex deadlock during PD hard reset"

parents 92ae1289 4568f636
Loading
Loading
Loading
Loading
+7 −13
Original line number Original line Diff line number Diff line
@@ -3123,7 +3123,9 @@ static int smblib_cc2_sink_removal_exit(struct smb_charger *chg)
		return 0;
		return 0;


	chg->cc2_detach_wa_active = false;
	chg->cc2_detach_wa_active = false;
	chg->in_chg_lock = true;
	cancel_work_sync(&chg->rdstd_cc2_detach_work);
	cancel_work_sync(&chg->rdstd_cc2_detach_work);
	chg->in_chg_lock = false;
	smblib_reg_block_restore(chg, cc2_detach_settings);
	smblib_reg_block_restore(chg, cc2_detach_settings);
	return 0;
	return 0;
}
}
@@ -4757,7 +4759,6 @@ static void rdstd_cc2_detach_work(struct work_struct *work)
{
{
	int rc;
	int rc;
	u8 stat4, stat5;
	u8 stat4, stat5;
	bool lock = false;
	struct smb_charger *chg = container_of(work, struct smb_charger,
	struct smb_charger *chg = container_of(work, struct smb_charger,
						rdstd_cc2_detach_work);
						rdstd_cc2_detach_work);


@@ -4826,22 +4827,15 @@ static void rdstd_cc2_detach_work(struct work_struct *work)
	 * during pd_hard_reset from the function smblib_cc2_sink_removal_exit
	 * during pd_hard_reset from the function smblib_cc2_sink_removal_exit
	 * which is called in the same lock context that we try to acquire in
	 * which is called in the same lock context that we try to acquire in
	 * this work routine.
	 * this work routine.
	 * Check if this work is running during pd_hard_reset and use trylock
	 * Check if this work is running during pd_hard_reset and skip holding
	 * instead of mutex_lock to prevent any deadlock if mutext is already
	 * mutex if lock is already held.
	 * held.
	 */
	 */
	if (chg->pd_hard_reset) {
	if (!chg->in_chg_lock)
		if (mutex_trylock(&chg->lock))
			lock = true;
	} else {
		mutex_lock(&chg->lock);
		mutex_lock(&chg->lock);
		lock = true;
	}

	smblib_usb_typec_change(chg);
	smblib_usb_typec_change(chg);

	if (!chg->in_chg_lock)
	if (lock)
		mutex_unlock(&chg->lock);
		mutex_unlock(&chg->lock);

	return;
	return;


rerun:
rerun:
+1 −0
Original line number Original line Diff line number Diff line
@@ -355,6 +355,7 @@ struct smb_charger {
	bool			otg_present;
	bool			otg_present;
	bool			is_audio_adapter;
	bool			is_audio_adapter;
	bool			disable_stat_sw_override;
	bool			disable_stat_sw_override;
	bool			in_chg_lock;


	/* workaround flag */
	/* workaround flag */
	u32			wa_flags;
	u32			wa_flags;