Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13428108ybl; Sun, 29 Dec 2019 11:38:05 -0800 (PST) X-Google-Smtp-Source: APXvYqxWcottnFkJsQt44ZviHMOd3kvVbZlIPDTrajb8Jw51ozALMj2MKDoZwYAWbaUulBWWv9rK X-Received: by 2002:a05:6830:2141:: with SMTP id r1mr70404274otd.39.1577648285821; Sun, 29 Dec 2019 11:38:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577648285; cv=none; d=google.com; s=arc-20160816; b=nxWkELlD+IDySR4Hf9m/sa3yN1seF8xw6S4a32zY7oC7Kk/pOevDws4fCxEgdZdHo0 f7ydvFJkzMlvf4CwAqCAxcg0SA++w/lyeIXbxKzUovo2wyyov08BSIC/bJhE861f3hRc TIyMKz38Kin4UZnzLR1m8ln0KsVSvI6gXBW7m3NjUz5hzT6NrCKDUwSaj2iHgR8wQtkM g21J7lPOYuU6IiSRHLdBmdBuz5V48yVEgIM46c9es7xYronJQshX8HQMaavCBwYy+kHB hQ17sQOBrgOI2ffH6Z+mr6P50B6Q2BG8U0/1+Nvc9g23YmhFz0ZGD15B1kvdFZUDlC5e 0+XQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=TCPscDZPfZi5DHV+WStqjnzn5WT4olh82kvU3ogfV7Q=; b=LhCI+Vg3wZSWw8i6XwwsNGq9F309QXH5gdhFNztizmrQsa+WxODDD1TsE1jxjPm1fC VrC61EFa4aRrFvTRe7RHU8rjb0WcthxLN+vjH2X0CNTiMOeYIDmxoCnh6dq2oRkQPWFQ Z3ExCzYOeCukyBjqaPCJUcaedc4oo/1kAWWiOVPK54ByebCaBPpkFXJwG6ZweSoFJ16X xPtTEkrLjecbFb2iAPE2o74R641F649DR+TwIO/s3oLXcrxhkOcD/Gp7+Q9S+sI+H9Cu Y9TevtSyONOzfowfALwjvlD55K2eAfGwh4HlU7lZ0lBZuKaVo62aFCyDSQsSMar2TXtP PhJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZyrsmIJP; 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 h203si19823165oif.3.2019.12.29.11.37.54; Sun, 29 Dec 2019 11:38:05 -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; dkim=pass header.i=@kernel.org header.s=default header.b=ZyrsmIJP; 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 S1729204AbfL2Rbn (ORCPT + 99 others); Sun, 29 Dec 2019 12:31:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:59210 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729194AbfL2Rbk (ORCPT ); Sun, 29 Dec 2019 12:31:40 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CA07E20722; Sun, 29 Dec 2019 17:31:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577640699; bh=gmZzz8RUcAVDI77LGIqj0pmn0yD9rYqUO/EBlGTSvp4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZyrsmIJP5A6mNwiXp7OoOLkJWrqUewLPepFeTgR+XmC0x3xL1NCVv6e9laEdgVcad paPcPw1P1zhMv7s9vdcBX3sNP2+FZ7k4Y6dcAQL95U+t3Sg72o/jKCaAfSXbjLctAr G8HGpVx98m5cNKjm4DEEYH5uxlia6pejnnNRW5Ls= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stephan Gerhold , Kishon Vijay Abraham I , Sasha Levin Subject: [PATCH 4.19 103/219] phy: qcom-usb-hs: Fix extcon double register after power cycle Date: Sun, 29 Dec 2019 18:18:25 +0100 Message-Id: <20191229162524.013561533@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229162508.458551679@linuxfoundation.org> References: <20191229162508.458551679@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stephan Gerhold [ Upstream commit 64f86b9978449ff05bfa6c64b4c5439e21e9c80b ] Commit f0b5c2c96370 ("phy: qcom-usb-hs: Replace the extcon API") switched from extcon_register_notifier() to the resource-managed API, i.e. devm_extcon_register_notifier(). This is problematic in this case, because the extcon notifier is dynamically registered/unregistered whenever the PHY is powered on/off. The resource-managed API does not unregister the notifier until the driver is removed, so as soon as the PHY is power cycled, attempting to register the notifier again results in: double register detected WARNING: CPU: 1 PID: 182 at kernel/notifier.c:26 notifier_chain_register+0x74/0xa0 Call trace: ... extcon_register_notifier+0x74/0xb8 devm_extcon_register_notifier+0x54/0xb8 qcom_usb_hs_phy_power_on+0x1fc/0x208 ... ... and USB stops working after plugging the cable out and in another time. The easiest way to fix this is to make a partial revert of commit f0b5c2c96370 ("phy: qcom-usb-hs: Replace the extcon API") and avoid using the resource-managed API in this case. Fixes: f0b5c2c96370 ("phy: qcom-usb-hs: Replace the extcon API") Signed-off-by: Stephan Gerhold Signed-off-by: Kishon Vijay Abraham I Signed-off-by: Sasha Levin --- drivers/phy/qualcomm/phy-qcom-usb-hs.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-usb-hs.c b/drivers/phy/qualcomm/phy-qcom-usb-hs.c index abbbe75070da..5629d56a6257 100644 --- a/drivers/phy/qualcomm/phy-qcom-usb-hs.c +++ b/drivers/phy/qualcomm/phy-qcom-usb-hs.c @@ -160,8 +160,8 @@ static int qcom_usb_hs_phy_power_on(struct phy *phy) /* setup initial state */ qcom_usb_hs_phy_vbus_notifier(&uphy->vbus_notify, state, uphy->vbus_edev); - ret = devm_extcon_register_notifier(&ulpi->dev, uphy->vbus_edev, - EXTCON_USB, &uphy->vbus_notify); + ret = extcon_register_notifier(uphy->vbus_edev, EXTCON_USB, + &uphy->vbus_notify); if (ret) goto err_ulpi; } @@ -182,6 +182,9 @@ static int qcom_usb_hs_phy_power_off(struct phy *phy) { struct qcom_usb_hs_phy *uphy = phy_get_drvdata(phy); + if (uphy->vbus_edev) + extcon_unregister_notifier(uphy->vbus_edev, EXTCON_USB, + &uphy->vbus_notify); regulator_disable(uphy->v3p3); regulator_disable(uphy->v1p8); clk_disable_unprepare(uphy->sleep_clk); -- 2.20.1