Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13329025ybl; Sun, 29 Dec 2019 09:25:27 -0800 (PST) X-Google-Smtp-Source: APXvYqxN1TvFe9CAMDGZ753cOtkmpbl0muDFXNXvJ8kgL86EWzN8ku0FXToVAKxNSrZH4+CUG/jN X-Received: by 2002:a05:6830:1e46:: with SMTP id e6mr63265256otj.245.1577640327558; Sun, 29 Dec 2019 09:25:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577640327; cv=none; d=google.com; s=arc-20160816; b=Cpf7fZ2eJsfjIXNgj7Xe8iPNvtuzh7gFMu+r77PdEwC6DJSc3CyvRfIiQ2XBtYOZON 0hZ8/PQkU2h2FKGK53Ta7a/5IGqE1Wlo+J79pqtgpHQ1QboRQqeiSRQEN9bDUyvxYCKZ 1pqZ9xH6KFnUI11WAx/wb1kVzRQInzzlOXYAKnlLRl2C+iGsheGKkka6HBP+KVkLk4jA 1i34A1saXyBm2am3jXCFYVcCpLdL5qjpufVW1QrdbKYxYNo1rWkPuhpAtjDKjCcC7yYh iYZFdKfevsATsk7Vgxm0ziO5kysE5MHSSdx7IrsndXfnmRfQy9jlIo37iAOzcJKxMYVN FXKQ== 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=fXrkqwDF9OI3ykEefZdllsqoIfAfrnmHvNRbU2X7hyU=; b=OiCLdjeNK972A1e1zCxMLCv9XyLq4JPrcxqiWXMg2vWGp3VMMLyA6CT+tZC08LU1+r eTcfVtw+ki1VpMhH8B0e/lmvrPzxDW5xWQovD4k6l9UxHskVX86lyptOjwQEm2qqvG6A Qjhaq7adRhvGVYneGL1c8+IkvV6R17z3Jnpa2aUNIAPlpI+5xqfCZ6rWWKy8Iqc9V8fe SN7fRl0zt7OI5o8BJoG3vQj8TI/U32HW8uizx5abctxGa7yS8WSQHtMp2vosk/HFG38a Ci1veOoTikyfPaXhzKZqGUlSL8H+F+Ngf/mXigbDOao5rJ7tllSupEyyEtnUNtMJvqd4 fMOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=f54JYa4h; 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 l189si17258777oih.166.2019.12.29.09.25.15; Sun, 29 Dec 2019 09:25:27 -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=f54JYa4h; 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 S1727664AbfL2RYF (ORCPT + 99 others); Sun, 29 Dec 2019 12:24:05 -0500 Received: from mail.kernel.org ([198.145.29.99]:42284 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726915AbfL2RYB (ORCPT ); Sun, 29 Dec 2019 12:24:01 -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 8DF10207FF; Sun, 29 Dec 2019 17:24:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577640241; bh=Io+xQVinOVvEdipXpBskzmqbCCIpeJEJjYxQpzwtCkA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f54JYa4h4qcY0f9LtLTrrexssdfHLUbqEW8wcEEEQfuOTum20/rVdUr7Y7aDTgfCD HXpkRXSulfBP1bivbwOlLJ19edUDPotkeOm6xzAGi9rlyAp5VIHnwsvPRn/c2Q9LkW VA6q5zG6KqGIhV6Zh57O3nLjBo69Q0CZ3FA1YZ30= 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.14 075/161] phy: qcom-usb-hs: Fix extcon double register after power cycle Date: Sun, 29 Dec 2019 18:18:43 +0100 Message-Id: <20191229162422.606808747@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229162355.500086350@linuxfoundation.org> References: <20191229162355.500086350@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 2d0c70b5589f..643934a2a70c 100644 --- a/drivers/phy/qualcomm/phy-qcom-usb-hs.c +++ b/drivers/phy/qualcomm/phy-qcom-usb-hs.c @@ -159,8 +159,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; } @@ -181,6 +181,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