From patchwork Mon Jan 8 13:01:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 123707 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2707653qgn; Mon, 8 Jan 2018 05:12:13 -0800 (PST) X-Google-Smtp-Source: ACJfBou+BSUaPEexDkRkWpueuuOaiX96spVj1oeUU0gi56KwzrkjSJ5WoR+P1KihwjtuVJaj+pIl X-Received: by 10.101.90.71 with SMTP id z7mr49361pgs.15.1515417133230; Mon, 08 Jan 2018 05:12:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515417133; cv=none; d=google.com; s=arc-20160816; b=lC1VcINlc87nOyR1QOH1aOOJYdQ6PcGxj6FCtFwVlhCWkxIz0009iZ8DrY00imi6th G4N5OM77i+KlpsAKXRmzz0NL/McSmgf9QE1+mbHk0c7x89wNU72XIXB95pl+dhDoBF/1 VQGwoF5bfge6xZ07aGLW5k4dNkk2zGlMvm9JY3qAZ/QRsmtCBXm5yHBcgib11qkgVhfA jLylJRKRdqFM2ksi5z7BAF/v32uGE1ywaiSPEXURhVpShSjHp7I+Rg9NrBlDRM2cUnlb HxSvZWLF+5sleW1pJWXtStbNoXMPPN/v7GZ5HrTAFI44iNMNt1sURMNIVQAJ9+jn4sMk O6rg== 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=hSoB2N/ffIKzZB1YMe++ltFvyEMrYrUt7xxbcqaiIZg=; b=hblr7bSj6A3t6GyDgSHDofGskrqig7bbNc40E9I0LV2Q1M8g5vi0DCfbC5+EiJhkXh Ud81abw4rI++9VVzo6KqJgj2S9FnJ6PNgxhXYwyJAoAz8LY4naRARXiAiC6YvfN8F/0D 25tM8Prs3luAhQQkr8VgStK1JAlB9t3h0GbVHhFs8kJwBy0iwztjvHpPmAkCRnNihN9Q kLDFc9YbiJS90PADgnl6YB/nv32xltqsGLI0FPsepp0VhX1pDdovo3U5+jNe+xLjshkN et+4HoExU5qO9jSd31c74IcVrP/MFZj8P8gwPojFr8tt61pESPiH1JIIx2UNGCWiE84o Rzzw== 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 j22si8369083pff.69.2018.01.08.05.12.12; Mon, 08 Jan 2018 05:12:13 -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 S933243AbeAHNML (ORCPT + 28 others); Mon, 8 Jan 2018 08:12:11 -0500 Received: from mout.kundenserver.de ([212.227.126.130]:58482 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933019AbeAHNBy (ORCPT ); Mon, 8 Jan 2018 08:01:54 -0500 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue007 [212.227.15.129]) with ESMTPA (Nemesis) id 0Mfepz-1eDqTj29kZ-00P22d; Mon, 08 Jan 2018 14:01:20 +0100 From: Arnd Bergmann To: Kishon Vijay Abraham I Cc: Eric Anholt , Florian Fainelli , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Rob Herring , linux-usb@vger.kernel.org, Arnd Bergmann , stable@vger.kernel.org, Stefan Wahren , Felipe Balbi , Andrzej Pietrasiewicz , linux-kernel@vger.kernel.org Subject: [PATCH] phy: work around 'phys' references to usb-phy devices Date: Mon, 8 Jan 2018 14:01:10 +0100 Message-Id: <20180108130116.80148-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:Kit/WCG6tod4AitxD6DcDbniAYCipq3oGEUpQJ0wRp4iUoS4HQR 12ezRMcQWMexnATkW+ZdTVGK6jU1DFMxgC5WPSNlLs9crvyqD/vs+68/F+ELLEh4e155V1q FAYUPKv69ZM0XNTsQ45zBGqAZ80gkUA9n6aMH+NEWL8oEKQhAQe1iVRQUuRn052Onng7zGb 97Vqyq1wNAMtnHBge1iKA== X-UI-Out-Filterresults: notjunk:1; V01:K0:VcbQF5DBAbg=:qcA4+QHJ3WHjdM5JuYWO6w Yatj0MiyWOuD1KQvRdbkiwFabuSt/7Dz9Q1RAbdkqzRXaK7nGAOSBY5JVHAh0x4UsFw1r3Twt SP7gM2a2Q/U0/69gdM6A9BcQVETY+Y0cVdanXGtJxOaw/co71EGX82SVClfx/AszQ+/jmlpLm hFsJFeApLIRQc8kjwKW+4NKT/L4BJClNAQ17XUwWzTAjbjvaajZbTRi8OI/QBaQI7JOxl3uaO pNWPC75mb1mjiHE8DFlBgH7grN67WJdqdwrpFTefLJDvngHWVwrTi6SWK3OQ1RXS04vKevDks /0GaihlFVFegb6q04p2/BW1tYQENozWt/PuYGgVnTbkz363p5emSUTfZchtwClmg+Ve2xgHnN uZzCE0ZgQzCiBvB09IZQRHmE3uYmuuKCBYy1x7d0PJL+rL7FxtibNECEZ3iJAO3CXa/Rf3e6W XzaXA1f28fwPglu+nX83OZWnkxF9d4nPT18rfnvCVS1VCxHwfmQPd4wxRgNGZ2xLhij/rF9SS Oix63gKf0SWUkmlEnn9B/xp2h12/hejRpKL6FMMPnouhqbbCloRi0etZ97l8XQ922jEG1idg4 Y3WG5bq5CUIxv+9D6UwirCtp0vOFbdzkOFQnSg7km/J6pRpJBEcWX8UqDFzMDFRYd5o5BDwNi mPzaIj5zo/Zn3NsesmvqgsDD3Kk94ybYtg/sKLyFusu5norfOawonXZMcTBsn/LuK4Fni12Gx EPXK2x9tO4oUvJ6IuwxjSbtDX32QqWssm6Jz+w== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Stefan Wahren reports a problem with a warning fix that was merged for v4.15: we had lots of device nodes with a 'phys' property pointing to a device node that is not compliant with the binding documented in Documentation/devicetree/bindings/phy/phy-bindings.txt This generally works because USB HCD drivers that support both the generic phy subsystem and the older usb-phy subsystem ignore most errors from phy_get() and related calls and then use the usb-phy driver instead. However, usb_add_hcd() (along with the respective functions in dwc2 and dwc3) propagate the EPROBE_DEFER return code so we can try again whenever the driver gets loaded. In case the driver is written for the usb-phy subsystem (like usb-generic-phy aka usb-nop-xceiv), we will never load a generic-phy driver for it, and keep failing here. There is only a small number of remaining usb-phy drivers that support device tree, so this adds a workaround by providing a full list of the potentially affected drivers, and always failing the probe with -ENODEV here, which is the same behavior that we used to get with incorrect device tree files. Since we generally want older kernels to also want to work with the fixed devicetree files, it would be good to backport the patch into stable kernels as well (3.13+ are possibly affected). Reverting back to the DTS sources that work would in theory fix USB support for now, but in the long run we'd run into the same problem again when the drivers get ported from usb-phy to generic-phy. Fixes: 014d6da6cb25 ("ARM: dts: bcm283x: Fix DTC warnings about missing phy-cells") Link: https://marc.info/?l=linux-usb&m=151518314314753&w=2 Cc: stable@vger.kernel.org Cc: Stefan Wahren Cc: Felipe Balbi Signed-off-by: Arnd Bergmann --- This obviously needs to be tested, I wrote this up as a reply to Stefan's bug report. I'm fairly sure that I covered all usb-phy driver strings here. My goal is to have a fix merged into 4.15 rather than reverting all the DT fixes. --- drivers/phy/phy-core.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) -- 2.9.0 diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index b4964b067aec..bb4dd2a2de2d 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -387,6 +387,24 @@ int phy_calibrate(struct phy *phy) } EXPORT_SYMBOL_GPL(phy_calibrate); +static struct of_device_id __maybe_unused legacy_usbphy[] = { + { .compatible = "fsl,imx23-usbphy" }, + { .compatible = "fsl,imx6q-usbphy" }, + { .compatible = "fsl,imx6sl-usbphy" }, + { .compatible = "fsl,imx6sx-usbphy" }, + { .compatible = "fsl,imx6ul-usbphy" }, + { .compatible = "fsl,vf610-usbphy" }, + { .compatible = "nvidia,tegra20-usb-phy" }, + { .compatible = "nvidia,tegra30-usb-phy" }, + { .compatible = "nxp,isp1301" }, + { .compatible = "ti,am335x-usb-ctrl-module" }, + { .compatible = "ti,am335x-usb-phy" }, + { .compatible = "ti,keystone-usbphy" }, + { .compatible = "ti,twl6030-usb" }, + { .compatible = "usb-nop-xceiv" }, + {}, +}; + /** * _of_phy_get() - lookup and obtain a reference to a phy by phandle * @np: device_node for which to get the phy @@ -410,6 +428,15 @@ static struct phy *_of_phy_get(struct device_node *np, int index) if (ret) return ERR_PTR(-ENODEV); + /* + * Some USB host controllers use a "phys" property to refer to + * a device that does not have a generic phy driver but that + * has a driver for the older usb-phy framework. + * We must not return -EPROBE_DEFER for those, so bail out early. + */ + if (of_match_node(legacy_usbphy, args.np)) + return ERR_PTR(-ENODEV); + mutex_lock(&phy_provider_mutex); phy_provider = of_phy_provider_lookup(args.np); if (IS_ERR(phy_provider) || !try_module_get(phy_provider->owner)) {