Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3765828pxt; Tue, 10 Aug 2021 10:48:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQGyRu2a79+yac48theAGyqtIeHW2w1SQApmu8hkowVUSqhm/POFzsq/ZuR8KdKKigJ8L2 X-Received: by 2002:a6b:6614:: with SMTP id a20mr1792ioc.142.1628617723824; Tue, 10 Aug 2021 10:48:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628617723; cv=none; d=google.com; s=arc-20160816; b=l8HoCoZ1cYJBDfvMJWMEkw3xUSrtIyoYr4qPYVAfZMNnQsmft5UTdxzDtPgbyDQxQm 4AZ34wT9WA4EpheekEuEeSgOx45oKZwIA912uD85zi4sSmMGNeLhU1IjB4IlURWsSZLa L8MSaP+cH4h5Y9TZ4lbPV+54d//NZXpTFLtpP9uVeDfotIM3um68WQX9QSvoLKkeBMvc TOB4yf3fFLKOpXwxhSfo86F3ynEQd2Mi4TioQAfLtwu4dOENx50U5QZLiSvhtxG1r3Iw dbO7A66SWHKMnsc/Z9zhlZYEoNGQlwYfpVc6dWiW8B4fDBOGVZ/mZoQvUlWxOMKjYvJ4 EqGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1M7bNgG08cAg/VirZ6k6eczMx4EQ5QfSsnKb0CKSY04=; b=0qpB4ZD7vExnyIREfXyEDcWtEtjCH8VkfUFwlsMLn+F1xHjxVRZcFMr4CPESIRpYn5 poABCfn5PUo1FKu9/e/osHjuJ78PAK4QCLBdEVPoW8miFZygV/ozMBJ3xD/cvrOhfC4F YKouieQIYaeZqdh7kuOQlB8Ln/Sz9/Vh1Ngza3f/k9f0JC+RYK9koA/yPcnXlOfXwJAf tOjwEKb33OdKxZmtTGz9zJqxPLk91ZfemGmsajBOBrKyfkGIWXjEDF9XAkdzDT7a1Ji5 SDx28wnHb8ylhUzbrbUWoXgQiuRQIxsMHd3Vlx/emulgEy/b2geEj2tCB2og3eq8HRXw rQeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XHlyZgNz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i12si23106358jan.18.2021.08.10.10.48.32; Tue, 10 Aug 2021 10:48:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XHlyZgNz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235405AbhHJRsI (ORCPT + 99 others); Tue, 10 Aug 2021 13:48:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:41304 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236487AbhHJRow (ORCPT ); Tue, 10 Aug 2021 13:44:52 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A44DF61179; Tue, 10 Aug 2021 17:39:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628617196; bh=3j6OXrGgf1G4CtlBsC9TKuCGsRnMjxBG0w4DxueHQhw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XHlyZgNz76iE9u2OaNRC9R+dUZopbYbecikxkOMBpriMs7v/hENOd29bThHpMHdjU lOiOLqi09zULLnLCrCzi5EdBaYMS6qi1PtXZ4jWJS1gaRRIgLcf0shdP7JDgJJtTZ+ DHAyyKSSuW6KpFgmZVXKzAGdyluDRi+U0tnP7D+M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Skripkin Subject: [PATCH 5.10 088/135] staging: rtl8712: get rid of flush_scheduled_work Date: Tue, 10 Aug 2021 19:30:22 +0200 Message-Id: <20210810172958.748455585@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210810172955.660225700@linuxfoundation.org> References: <20210810172955.660225700@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pavel Skripkin commit 9be550ee43919b070bcd77f9228bdbbbc073245b upstream. This patch is preparation for following patch for error handling refactoring. flush_scheduled_work() takes (wq_completion)events lock and it can lead to deadlock when r871xu_dev_remove() is called from workqueue. To avoid deadlock sutiation we can change flush_scheduled_work() call to flush_work() call for all possibly scheduled works in this driver, since next patch adds device_release_driver() in case of fw load failure. Signed-off-by: Pavel Skripkin Cc: stable Link: https://lore.kernel.org/r/6e028b4c457eeb7156c76c6ea3cdb3cb0207c7e1.1626895918.git.paskripkin@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl8712_led.c | 8 ++++++++ drivers/staging/rtl8712/rtl871x_led.h | 1 + drivers/staging/rtl8712/rtl871x_pwrctrl.c | 8 ++++++++ drivers/staging/rtl8712/rtl871x_pwrctrl.h | 1 + drivers/staging/rtl8712/usb_intf.c | 3 ++- 5 files changed, 20 insertions(+), 1 deletion(-) --- a/drivers/staging/rtl8712/rtl8712_led.c +++ b/drivers/staging/rtl8712/rtl8712_led.c @@ -1820,3 +1820,11 @@ void LedControl871x(struct _adapter *pad break; } } + +void r8712_flush_led_works(struct _adapter *padapter) +{ + struct led_priv *pledpriv = &padapter->ledpriv; + + flush_work(&pledpriv->SwLed0.BlinkWorkItem); + flush_work(&pledpriv->SwLed1.BlinkWorkItem); +} --- a/drivers/staging/rtl8712/rtl871x_led.h +++ b/drivers/staging/rtl8712/rtl871x_led.h @@ -112,6 +112,7 @@ struct led_priv { void r8712_InitSwLeds(struct _adapter *padapter); void r8712_DeInitSwLeds(struct _adapter *padapter); void LedControl871x(struct _adapter *padapter, enum LED_CTL_MODE LedAction); +void r8712_flush_led_works(struct _adapter *padapter); #endif --- a/drivers/staging/rtl8712/rtl871x_pwrctrl.c +++ b/drivers/staging/rtl8712/rtl871x_pwrctrl.c @@ -224,3 +224,11 @@ void r8712_unregister_cmd_alive(struct _ } mutex_unlock(&pwrctrl->mutex_lock); } + +void r8712_flush_rwctrl_works(struct _adapter *padapter) +{ + struct pwrctrl_priv *pwrctrl = &padapter->pwrctrlpriv; + + flush_work(&pwrctrl->SetPSModeWorkItem); + flush_work(&pwrctrl->rpwm_workitem); +} --- a/drivers/staging/rtl8712/rtl871x_pwrctrl.h +++ b/drivers/staging/rtl8712/rtl871x_pwrctrl.h @@ -111,5 +111,6 @@ void r8712_cpwm_int_hdl(struct _adapter void r8712_set_ps_mode(struct _adapter *padapter, uint ps_mode, uint smart_ps); void r8712_set_rpwm(struct _adapter *padapter, u8 val8); +void r8712_flush_rwctrl_works(struct _adapter *padapter); #endif /* __RTL871X_PWRCTRL_H_ */ --- a/drivers/staging/rtl8712/usb_intf.c +++ b/drivers/staging/rtl8712/usb_intf.c @@ -609,7 +609,8 @@ static void r871xu_dev_remove(struct usb padapter->surprise_removed = true; if (pnetdev->reg_state != NETREG_UNINITIALIZED) unregister_netdev(pnetdev); /* will call netdev_close() */ - flush_scheduled_work(); + r8712_flush_rwctrl_works(padapter); + r8712_flush_led_works(padapter); udelay(1); /* Stop driver mlme relation timer */ r8712_stop_drv_timers(padapter);