Received: by 10.223.185.116 with SMTP id b49csp6096402wrg; Thu, 8 Mar 2018 01:33:49 -0800 (PST) X-Google-Smtp-Source: AG47ELsKf42pd99M+Vd2S+PLAPLXzsS8PdoelyOgvzA2phCYwODxQibczt8xotMNsE9Q5uGbBgcQ X-Received: by 2002:a17:902:7b95:: with SMTP id w21-v6mr14836642pll.260.1520501629001; Thu, 08 Mar 2018 01:33:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520501628; cv=none; d=google.com; s=arc-20160816; b=ZsyvKaNSqSh5QRnhpKTFU4lcpDe13HcN4pSC3K4Lg7Exabt1z5DX494V/BY57GfvlM HFIAgdeK5CkPchC9Db8MLVtgpc3p4eXWyQtBIZEk/mB2POsjdjvGQhyYZymjmDCa0kb1 iV+ItidL3r58FYXJOhgn/F4yL+tddppYJpOzE8YHglUvBGpTsyS/HpcDsB/GvYfZFI3m 0jqDDOYgei8pEpzVTvi2oOUhP0e2n77/OzKqJuLzBHrAWvmNePRrrBoOVHusrXFJdYUH A1qBj6tAjSmt4aqHUdN97F/HyNEi0AmO8DG0NGPGYhS6HYC9+NiJGLEuYFK7HR5HmHgH cNSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=7yHaKjCOnU0ESxjmO9a2nsprPm6FhWUrd4Kdsb0wRvs=; b=DYm5OBsOOPaGHVEy/YdfCLp0qDxCSTFm0EJrjCbD/gqfVbk8f22l2DcRqlv2nENfh8 J7VDjXmbnC+KCSU9EYTogJ1BcYa+mAYoRyATg0bgmV0KkgSc/4riTW1SA5T2/UR5RjPh uasWjdEl5T6mjawhZYl3Syrj87BHYRhTQBEqcLmL6MNcMaTTI4C8pNA2lLa320Lx0xiP lzKGuiA/R/a1Fq93DPrTQegQ4RY6hYNo9wUFuVF0102d1YP+p1LUnw/nfdspciX9x8uM EActTGtIt2XKk/3/UirXa4DkFvNVFei2rppOgFLKDNIsPY+RxeS+E6vSSoJBHZigkGCA 3UXg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i131si12798949pgc.186.2018.03.08.01.33.34; Thu, 08 Mar 2018 01:33:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755591AbeCHJcC (ORCPT + 99 others); Thu, 8 Mar 2018 04:32:02 -0500 Received: from nala.villavu.com ([188.165.243.101]:45479 "EHLO nala.villavu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755564AbeCHJb7 (ORCPT ); Thu, 8 Mar 2018 04:31:59 -0500 Received: from a82-161-36-93.adsl.xs4all.nl ([82.161.36.93] helo=chrometwo.fritz.box) by nala.villavu.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1etru1-0000g2-47; Thu, 08 Mar 2018 10:31:57 +0100 From: Merlijn Wajer To: b-liu@ti.com Cc: merlijn@wizzup.org, ivo.g.dimitrov.75@gmail.com, linux-omap@vger.kernel.org, Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH] usb: musb: Fix external abort in musb_remove Date: Thu, 8 Mar 2018 10:31:21 +0100 Message-Id: <20180308093121.11943-1-merlijn@wizzup.org> X-Mailer: git-send-email 2.16.2 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This fixes an oops on unbind / module unload. The fix is similar to the one in this commit: 0c3aae9bd59978fb8c3557d7883380bef0f2cfa1 (USB: musb: fix late external abort on suspend), which only fixes the issue for musb_suspend. musb_remove function now also flushes any work and also calls musb_platform_exit before disabling runtime pm. Signed-off-by: Merlijn Wajer --- If I understand commit 0c3aae9bd59978fb8c3557d7883380bef0f2cfa1 correctly, this patch should also be backported to 4.9 (and newer kernels). I have verified that this works on the Nokia N900, RX-51. The problem did not occur on the Motorola Droid 4, but I have yet to test if this patch causes issues there. drivers/usb/musb/musb_core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index e2e95071328a..4fb0f345c04e 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -2472,13 +2472,19 @@ static int musb_remove(struct platform_device *pdev) musb_platform_disable(musb); spin_lock_irqsave(&musb->lock, flags); musb_disable_interrupts(musb); + + musb->flush_irq_work = true; + while (flush_delayed_work(&musb->irq_work)) + ; + musb->flush_irq_work = false; + musb_writeb(musb->mregs, MUSB_DEVCTL, 0); + musb_platform_exit(musb); spin_unlock_irqrestore(&musb->lock, flags); pm_runtime_dont_use_autosuspend(musb->controller); pm_runtime_put_sync(musb->controller); pm_runtime_disable(musb->controller); - musb_platform_exit(musb); musb_phy_callback = NULL; if (musb->dma_controller) musb_dma_controller_destroy(musb->dma_controller); -- 2.16.2