From patchwork Fri May 29 04:32:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Macpaul Lin X-Patchwork-Id: 214977 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_BASE64_TEXT, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DECDEC433E0 for ; Fri, 29 May 2020 04:33:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BB9FD2075A for ; Fri, 29 May 2020 04:33:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="XtDq46ug" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725836AbgE2EdI (ORCPT ); Fri, 29 May 2020 00:33:08 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:54675 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725562AbgE2EdH (ORCPT ); Fri, 29 May 2020 00:33:07 -0400 X-UUID: f0271cf6ad2d45038bb3d5c8fea372a1-20200529 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=NQxTpzWSVt9V/exBuo1GGmsYXw0ueriE8T12aD6F8IM=; b=XtDq46ugdCZakv0oCcUDzadMUYjE6/TWegB2PNYxZtPM4VKPNCYaFG5cpBrlgQkFA3fMlcq1jP/97Wq+wV5Bxua9aLYovYopOJOyv0I3M/UUfMMBAxEOem6HhueJkD/jpW8TnB7qnMZ3lmzTjsOj1sgu4ZW8hLBlX9utYS/Ic04=; X-UUID: f0271cf6ad2d45038bb3d5c8fea372a1-20200529 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 1318030598; Fri, 29 May 2020 12:33:03 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs01n2.mediatek.inc (172.21.101.79) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 29 May 2020 12:32:57 +0800 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by mtkcas08.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 29 May 2020 12:33:02 +0800 From: Macpaul Lin To: Chunfeng Yun , Mathias Nyman , Greg Kroah-Hartman , Matthias Brugger CC: Mediatek WSD Upstream , Macpaul Lin , Macpaul Lin , , , , Subject: [PATCH v2] usb: host: xhci-mtk: avoid runtime suspend when removing hcd Date: Fri, 29 May 2020 12:32:58 +0800 Message-ID: <1590726778-29065-1-git-send-email-macpaul.lin@mediatek.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1590726569-28248-1-git-send-email-macpaul.lin@mediatek.com> References: <1590726569-28248-1-git-send-email-macpaul.lin@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: F7F5029A8E56D799AC15E58E9FB9F79910F4976461FD69A9201D4F2A0F901EDB2000:8 X-MTK: N Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org When runtime suspend was enabled, runtime suspend might happened when xhci is removing hcd. This might cause kernel panic when hcd has been freed but runtime pm suspend related handle need to reference it. Signed-off-by: Macpaul Lin --- drivers/usb/host/xhci-mtk.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) -- 1.7.9.5 diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c index bfbdb3c..641d24e 100644 --- a/drivers/usb/host/xhci-mtk.c +++ b/drivers/usb/host/xhci-mtk.c @@ -587,6 +587,9 @@ static int xhci_mtk_remove(struct platform_device *dev) struct xhci_hcd *xhci = hcd_to_xhci(hcd); struct usb_hcd *shared_hcd = xhci->shared_hcd; + pm_runtime_put_sync(&dev->dev); + pm_runtime_disable(&dev->dev); + usb_remove_hcd(shared_hcd); xhci->shared_hcd = NULL; device_init_wakeup(&dev->dev, false); @@ -597,8 +600,6 @@ static int xhci_mtk_remove(struct platform_device *dev) xhci_mtk_sch_exit(mtk); xhci_mtk_clks_disable(mtk); xhci_mtk_ldos_disable(mtk); - pm_runtime_put_sync(&dev->dev); - pm_runtime_disable(&dev->dev); return 0; }