| Message ID | 20260430110652.558622-14-vladimir.oltean@nxp.com (mailing list archive) |
|---|---|
| State | New |
| Headers |
Return-Path: <linux-sunxi+bounces-23017-sunxi=pue.re@lists.linux.dev> X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mxe881.netcup.net (Postfix) with ESMTPS id E0C381C00DB for <noreply@patchwork.local>; Thu, 30 Apr 2026 13:14:04 +0200 (CEST) Authentication-Results: mxe881; dkim=pass header.d=nxp.com; spf=pass (sender IP is 172.232.135.74) smtp.mailfrom=linux-sunxi+bounces-23017-noreply=patchwork.local@lists.linux.dev smtp.helo=sto.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.232.135.74 as permitted sender) client-ip=172.232.135.74; envelope-from=linux-sunxi+bounces-23017-noreply=patchwork.local@lists.linux.dev; helo=sto.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sto.lore.kernel.org (Postfix) with ESMTP id 7909C30275F4 for <noreply@patchwork.local>; Thu, 30 Apr 2026 11:10:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4F6EF426D0A; Thu, 30 Apr 2026 11:07:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="OS4W385L" X-Original-To: linux-sunxi@lists.linux.dev Received: from AM0PR83CU005.outbound.protection.outlook.com (mail-westeuropeazon11010066.outbound.protection.outlook.com [52.101.69.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7608342668E; Thu, 30 Apr 2026 11:07:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.69.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777547251; cv=fail; b=LzA5TV6yVJ+xFuoEXdqkLrc347tX3wNbEJZgPuJ1cyuRGNvRQ+lWTPfkDeKOgq3YeKIVVBqSbddG3WTjgrkdnLK2+UndCn6kgt/rOE/aRVMZARCWy2ZnfsD1yNd8YHqa2Ueip1ck73IdQ400SxcCv3Tynd2CkN/iO2xfz2q2ewM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777547251; c=relaxed/simple; bh=JA1wlI+Rk4wgphhwBe1Sa2SdSQbR3QKCFlO/K33XZvI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=GIgY+HYahmD5rQs4jGNyJ+3DO8ToSutGuq8eRnZl3ylI2Mr0e90/eLwOL2NWdLtVntvX0TeFJHWyqsuVCZy92vZN13DxE1RzBplqS0f+aGifEPCbqsn1yUqI6P43Vyc3KmJ7R2xULF6ib+ySwM2LlG2qdic72+oahD3YDaj6HHw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=OS4W385L; arc=fail smtp.client-ip=52.101.69.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pW4EGFoqCjIysdC097hAU45P2c234hYNFeLuCqFJF7rAav6pMRs1q7PAeNaxwHtolSI/nJESKYiP7Zu/juR1bk92mutNw8J5uczS+W5e0OvgRJzacDnBe3MZ8sOSlhcLwSNdRnnJHqAvS7aBow1IThmMGerLAaSZthqqeEIkjo6VHlE57duwotelwkT4Bm+G8/qQUgSYAtzX+H5fg+Ekp7qjbN2zHIxrmEzqIXhLpyIT0L2BwKkvtPAxPuCHBOUF0Ps9W5wXw3si4pQQcoLQ0fEVDFtoCIgCoB2lZ6RSdhv++JMKjiEQX9KJUfEAE+0HGhFiLCgnDiwgdVFeb6a2RQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=s1+waZ1NoHfTKKwg2bMbaGUn+fU0KQ45RvLq4x+bwzw=; b=aKna1yOP0pXNudbemWT0VbQ+6PzRMDaMJlU/ZHEfGPFPV8uOoRVoSzpUw0fC089GYWhjyLRFvJVFZ0H3O98xClHlDYuU5qoijSJJKaG2MGeRd65hweMw++0yNb7/TvcdUaoB+v5O6voL7BxgdjnMmw+bWBCqbtwrFDx4UOC7u1cGGeIcVRzlvDpffBELBAWI9z8jxYhmCjsWyVSpR+hz4tBWwADAf67li0L2Wyq7R6GAAeEGEDzYcnJxmdxxzU0nENMkrbHByazdyvtOnw47Xy2mATAs2N4IpWqZMcf7/ooTmTvzzKN6TpaBpoNrzkjUOFgFK3vpTY1Im6OmevtNew== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=s1+waZ1NoHfTKKwg2bMbaGUn+fU0KQ45RvLq4x+bwzw=; b=OS4W385LMbqzvSz3/NG/95JH4Dx0NXTl8ynWGoU1Xl5SH9E+rehIaAk88lHWrax0OzfqJRbvm4KOaZc31SiZMlbxQ6W2hDjNskASKQPq9aE9XBx9VPJgzIjt0Ds0u4JkMLLpqd05oE19hkBAAIbJS+WKSbD/TgP/iN3+Q/ffc66VtnZ0qTPoQqk1q94dLjfXdcF4qyxxXS2JrE3Amdgn3HzFZgE6HvNNXnqKQ9M3XQ6IR1kUNixNXZaCUOVRYEeo4OUJkHpykCRnAuh/Hkq469RWAYTWlROoJOh9W4698kjqEzAkxplvQCGUCCD/iBMySsexE/ep007hpE6X8hXvYg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8585.eurprd04.prod.outlook.com (2603:10a6:20b:438::13) by VI1PR04MB7182.eurprd04.prod.outlook.com (2603:10a6:800:121::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9870.20; Thu, 30 Apr 2026 11:07:20 +0000 Received: from AM9PR04MB8585.eurprd04.prod.outlook.com ([fe80::f010:fca8:7ef:62f4]) by AM9PR04MB8585.eurprd04.prod.outlook.com ([fe80::f010:fca8:7ef:62f4%4]) with mapi id 15.20.9846.025; Thu, 30 Apr 2026 11:07:19 +0000 From: Vladimir Oltean <vladimir.oltean@nxp.com> To: linux-phy@lists.infradead.org Cc: Vinod Koul <vkoul@kernel.org>, Neil Armstrong <neil.armstrong@linaro.org>, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-can@vger.kernel.org, linux-gpio@vger.kernel.org, linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-pci@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-scsi@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, linux-usb@vger.kernel.org, netdev@vger.kernel.org, spacemit@lists.linux.dev, UNGLinuxDriver@microchip.com, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, JC Kuo <jckuo@nvidia.com>, Johan Hovold <johan+linaro@kernel.org>, Jonathan Hunter <jonathanh@nvidia.com>, Mathias Nyman <mathias.nyman@intel.com>, Thierry Reding <thierry.reding@gmail.com> Subject: [PATCH v7 phy-next 13/27] usb: host: tegra: avoid direct dereference of phy->dev.of_node Date: Thu, 30 Apr 2026 14:06:38 +0300 Message-Id: <20260430110652.558622-14-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260430110652.558622-1-vladimir.oltean@nxp.com> References: <20260430110652.558622-1-vladimir.oltean@nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: AM0PR10CA0024.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::34) To AM9PR04MB8585.eurprd04.prod.outlook.com (2603:10a6:20b:438::13) Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: <linux-sunxi.lists.linux.dev> List-Subscribe: <mailto:linux-sunxi+subscribe@lists.linux.dev> List-Unsubscribe: <mailto:linux-sunxi+unsubscribe@lists.linux.dev> MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8585:EE_|VI1PR04MB7182:EE_ X-MS-Office365-Filtering-Correlation-Id: 52fd3690-f475-4c00-6515-08dea6a8a51f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|10070799003|7416014|376014|366016|19092799006|1800799024|18002099003|56012099003|22082099003; X-Microsoft-Antispam-Message-Info: 4+auyliHqMWcWlb/BBUzy8o59JcvstdZG1jTXR6QPjlyyN40OpPIQy6SOB24Pku+5jGMlz/bTxszsctoiVUWbKkU75Z88naWXTxwJW/b1TPVGwbY1UNw8pWZUBMlzQv989z0dHuspUoDRhkBCYCBv5DLtio9XcVsbMkB75oZS0iaw3qThQV962WnYU7Vx20jNYbwHFiTPXMFMI0Ut9agrnlfCPeSfVdyihMymBanaTnuw3dvyAcQ8opwnVE6xicjRNHV54hj+9GYiqd/zpL+qnRwlUY9o3roRPTVqpY38TnQJ5Po0JIJz2TTSzDR9613qqKfBtDG1IsZLBXvtOplw9EXZDJW6U6m/5DzZ+7VmIMcza17iCz5zgrAZXTNjBetOtkkatnB5F4Lw4HZSgwgQn4/B8cqBbjFozdkexlOCFUYpTWFZJBjryHRwFnCj0ABzy6Pn4QMxv1vXUwi6Q4rbmx3Pnwg3ia+LW4eUmctV+gtRpWNn6bs/ZFYKmvgklhLgFD3W+75dsV8VMHozsYGYTalx3pfOsiw6J2LiLEHyAphMznbX+c8HuPfQUY0ua10azexVLYWPTCFU3Bk/wTf8PcEaW/zXECbeDAASo2EcpJTwY4dIUzYuMgNOik5S/w5jaVR+v+dh5R/PazAiIlm9lTQACIOr0k94d4DAo8JMnc617DNZA3vliA6LYKesUvHhVuvjC5/YnivKBNzHtFVzGDlhEuW2e5frIPz4slfK4g= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8585.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(10070799003)(7416014)(376014)(366016)(19092799006)(1800799024)(18002099003)(56012099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ejeNE77tNWA8whavWKA98Z2JuCE+lFvf9t22SRh7Il4S6imZPAeYRMXMs2mIbI/eN8UyeAk/XOpubyq49cukFZT+sKDdMd5SrzYrh/DB1EA4p2s+4c6mPsfZvBr8M8K1wKJKLninSJ/rqcthK+6SDEvAOX00Fiqm02RNPvFGQAdDI2B6syMhpdTphIjjvaYXFNzB5ODMAZ4PylizRqwOKzedqUR+1MLNzC7kU31VnBy2f+GG2McWh+vLCLywex3Ed2wZ5vEDOx0W0OwWIQjbYQVVNoa4I1EzwZAT4JnxW76amzN/DuMhX97uAaott/RzQaLn8c1LrNX6hRkGFVe+/czv1TgT5CrYejGLmTHH+o6oe+shlCKUgQCTyA7DKjuuCZAcAuHDFiUw3Q8CXMv/fL/Qq9Bz34DwFfs9A+b28pcoCssnMvkrehxeTDLRX3Vat/m86siXLZUNnvSNTKLkhSLFkVu6stKsm0di6L6EbAMwsDVoZXnp2XTmCH3qGOml5+f8CsdNdFPRRiAp4FBQu+9fogqOTvEU4QsuH8hXM2vKcluAE9K8V87d7dmPqEuZg4vN6PNPOBnuPYDvLjNP3Ow4joAVzvOFezl5Ai8ZMi6Pre68bM+idEAkiUQP01cAmL4YvHAjaENuvxcwUajCl7pbqc0SZqEMFOYYcx6F17RwBU5ipWEesrDd/5etUpgXhDUxGOWQfEN506ZK54ZR0VAB725w9l5oNi6WKnUwJvtKDngiDhQ85PV/eNOLkrgpVUbGX1D8pxT3bPjiYnr9bAbOU2RKTF8VOEkVBmtdlTam0iH3+EVtpn5fvDcJaGVRfD7x5ujQEnLVO1OD8EY30/nX5mnMZ2ZbZKffKRa4rHyiRIeCt1kxX+NE0WzxwgbkOcaWUE4kwWNiZVlGz5SbYYAOVeTrUtOG1QEEs6jAcnuSjV+G6VjgNI76XnoxUqND/kUZy6yPIIersFIM1t09ym6QFyZJcCl293ykHVB+h9kJSgkPKlLPAYttZ13Mc5cXFaqqjckvVC8d+idevnfCyDeN2XkKHcSndVRvHnEZhfilY+2RUElYsUs2BpoBSY3v+xtRUr1sjXgeIkfG5RKVv4h2kF+WIS/x1OiPXV2BACJaOwKFVsU2kbKHKU+nKqPiuSGaUmJ6T981KxdmaPRUX/cKvklMSS8EEIwVpBlkiOcsRHzIzxGpFAFMa+KYht7/rDNq9J3dN0LO1ZUKtPTXy1Lmz0urBFYJBuk4ty8BSxBW9giHWzBLpJ6sxJNxQL54yqOUpQBjgeOnla3OqA/JoJF7zUw+BqRDawSt1PY9et8KC8IM8rI5kGzYuMzZlMKN/lnO4Vi3sObLBIeDwmewHx9JVEEoyEOPmrra2lyglIjbvd8/wBlSJPhXjZWypdE2ipVXXAC0g2EOXk6gykFsfnhrKqI2HO6P+eSV87wMthw8R+47EpRzup+Ke/vX5ueI8CAf7D6V1j8ZbqxeX5W7dyPNIlYj3Hpu9hyH6JhocSDSHXwH3d4yVXIOP6hTJtlCL8ETbKlM0B33TkIk+5pGzswLLEEwk7hnL3ndvdm7A3jicL57pLTtgz3649sonIUjIdt2ZSsuBVCukWTy48ySBMWklnA0whO8G3+Cd1c/Tq/6DjY5np0B6Ql0+x9TXYYT9zZJ1OmPj0XCArka/Lgdvy7pTiAOEo71cCNygTaESsG6mnEhjoQCvmI/CHEI9y95Utd9WlAODQuwhcHNYqFjMEVPj0OjARPYOQmewgCZGkDrWVrRZmhPb3CX88MGuJfW X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 52fd3690-f475-4c00-6515-08dea6a8a51f X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8585.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Apr 2026 11:07:18.9863 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: SfzNIqasEQy5HBJVCRiv+Dpquo4AFCA9ROamUuADWr7yKkG4/H48RyLodqCX7mUbhN/ZTDkkPGYmWEI6nAqshw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB7182 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= |
| Series |
Split Generic PHY consumer and provider
|
|
Commit Message
Vladimir Oltean
April 30, 2026, 11:06 a.m. UTC
A piece of context which seems relevant here is that the USB subsystem
is transitioning from struct usb_phy to struct phy (belonging to the
Generic PHY subsystem). Commit 1a229d8690a0 ("Revert "usb: phy: add usb
phy notify port status API"") seems to confirm that this is the case.
In the transition process, some PHY provider drivers register themselves
as both Generic PHY and USB PHY in an attempt to bridge the API gap.
Such is the case with drivers/phy/tegra/xusb.c, accessed here by the
Tegra USB host driver. This USB host expects the PHY device behind the
Generic PHY to also be a USB PHY, and calls
devm_usb_get_phy_by_node(phy->dev.of_node).
The Generic PHY exposes no API to get the OF node from a PHY device, so
the Tegra USB host driver gets it directly. However, "struct phy" will
be made an opaque pointer, to avoid misuse, so this will no longer be
possible.
Considering the fact that the Generic PHY/USB PHY duality is a
transitional state, I am deliberately not planning to make the life of
this driver any easier by providing a helper to get to the OF node
somehow. Instead, implement a parallel lookup path through which the
Tegra USB host driver can continue to get to the OF node provided by the
padctl component, using the 'phys' phandle.
Secondly (minor issue) the driver uses the phy->dev.of_node again to
print using dev_dbg() that a "remote wake" was detected. Just print the
index at which the PHY appears inside the driver's tegra->phys[] array
instead.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: JC Kuo <jckuo@nvidia.com>
Cc: Johan Hovold <johan+linaro@kernel.org>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Cc: Mathias Nyman <mathias.nyman@intel.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
v5->v7: none
v4->v5: patch is new
---
drivers/usb/host/xhci-tegra.c | 42 ++++++++++++++++++++++-------------
1 file changed, 26 insertions(+), 16 deletions(-)
Comments
Sashiko says: > commit 037a329bd1e70f26b8d861fb06f3bbc539fb2c49 > Author: Vladimir Oltean <vladimir.oltean@nxp.com> > usb: host: tegra: avoid direct dereference of phy->dev.of_node > > This commit updates the Tegra USB host driver to retrieve the PHY OF node > using the "phys" phandle rather than directly accessing phy->dev.of_node. > This addresses an upcoming change where struct phy will become an opaque > pointer. It also simplifies a debug message to log the array index. > > > diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c > > index d2214d309e96..99b0ac9763f9 100644 > > --- a/drivers/usb/host/xhci-tegra.c > > +++ b/drivers/usb/host/xhci-tegra.c > > @@ -1491,6 +1491,7 @@ static int tegra_xhci_id_notify(struct notifier_block *nb, > > > > static int tegra_xusb_init_usb_phy(struct tegra_xusb *tegra) > > { > > + struct device_node *np = dev_of_node(tegra->dev); > > unsigned int i; > > > > tegra->usbphy = devm_kcalloc(tegra->dev, tegra->num_usb_phys, > > @@ -1504,23 +1505,33 @@ static int tegra_xusb_init_usb_phy(struct tegra_xusb *tegra) > > tegra->otg_usb3_port = -EINVAL; > > > > for (i = 0; i < tegra->num_usb_phys; i++) { > > - struct phy *phy = tegra_xusb_get_phy(tegra, "usb2", i); > > + struct of_phandle_args args; > > + struct usb_phy *usbphy; > > + int index, err; > > + char prop[8]; > > > > - if (!phy) > > + snprintf(prop, sizeof(prop), "usb2-%d", i); > > + > > + /* > > + * usb-phy is optional, continue if it's not available. > > + */ > > + index = of_property_match_string(np, "phy-names", prop); > > + if (index < 0) > > continue; > > > > - tegra->usbphy[i] = devm_usb_get_phy_by_node(tegra->dev, > > - phy->dev.of_node, > > - &tegra->id_nb); > > - if (!IS_ERR(tegra->usbphy[i])) { > > - dev_dbg(tegra->dev, "usbphy-%d registered", i); > > - otg_set_host(tegra->usbphy[i]->otg, &tegra->hcd->self); > > - } else { > > - /* > > - * usb-phy is optional, continue if its not available. > > - */ > > - tegra->usbphy[i] = NULL; > > - } > > + err = of_parse_phandle_with_args(np, "phys", "#phy-cells", > > + index, &args); > > + if (err) > > + continue; > > The call to of_parse_phandle_with_args() increments the reference count > of the device tree node and populates it in args.np. The new code passes > args.np to devm_usb_get_phy_by_node(), but does not appear to call > of_node_put() to drop the reference when it is done. Does this leak the > device node reference on both the success and error paths of the loop? I've added an of_node_put(args.np) after devm_usb_get_phy_by_node() for v8. > > + > > + usbphy = devm_usb_get_phy_by_node(tegra->dev, args.np, > > + &tegra->id_nb); > > Also in tegra_xusb_init_usb_phy(), the single notifier block instance > tegra->id_nb is passed to devm_usb_get_phy_by_node() for every USB PHY > being processed. Because the struct notifier_block API uses an embedded next > pointer for its singly-linked list, does registering the exact same object > to multiple independent PHY notifier chains overwrite its next pointer and > corrupt the lists? If this is a problem, it is a pre-existing and completely unrelated problem which I don't have knowledge how to handle, so I will leave it alone. > > + if (IS_ERR(usbphy)) > > + continue; > > + > > + tegra->usbphy[i] = usbphy; > > + dev_dbg(tegra->dev, "usbphy-%d registered", i); > > + otg_set_host(tegra->usbphy[i]->otg, &tegra->hcd->self); > > } > > > > return 0; > [...] > > drivers/usb/host/xhci-tegra.c | 42 ++++++++++++++++++++++------------- > > 1 file changed, 26 insertions(+), 16 deletions(-) > > > > @@ -2168,8 +2179,7 @@ static void tegra_xhci_disable_phy_wake(struct tegra_xusb *tegra) > > continue; > > > > if (tegra_xusb_padctl_remote_wake_detected(padctl, tegra->phys[i])) > > - dev_dbg(tegra->dev, "%pOF remote wake detected\n", > > - tegra->phys[i]->dev.of_node); > > + dev_dbg(tegra->dev, "PHY %d remote wake detected\n", i); > > > > tegra_xusb_padctl_disable_phy_wake(padctl, tegra->phys[i]); > > } > > In tegra_xhci_disable_phy_wake(), the loop counter i is declared as an > unsigned int. The updated dev_dbg() message formats this variable using > the %d specifier. This isn't a bug since the values are bounded by > tegra->num_phys, but should it use %u to match the unsigned integer type? I've changed to %u printing for v8.
diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c index d2214d309e96..99b0ac9763f9 100644 --- a/drivers/usb/host/xhci-tegra.c +++ b/drivers/usb/host/xhci-tegra.c @@ -1491,6 +1491,7 @@ static int tegra_xhci_id_notify(struct notifier_block *nb, static int tegra_xusb_init_usb_phy(struct tegra_xusb *tegra) { + struct device_node *np = dev_of_node(tegra->dev); unsigned int i; tegra->usbphy = devm_kcalloc(tegra->dev, tegra->num_usb_phys, @@ -1504,23 +1505,33 @@ static int tegra_xusb_init_usb_phy(struct tegra_xusb *tegra) tegra->otg_usb3_port = -EINVAL; for (i = 0; i < tegra->num_usb_phys; i++) { - struct phy *phy = tegra_xusb_get_phy(tegra, "usb2", i); + struct of_phandle_args args; + struct usb_phy *usbphy; + int index, err; + char prop[8]; - if (!phy) + snprintf(prop, sizeof(prop), "usb2-%d", i); + + /* + * usb-phy is optional, continue if it's not available. + */ + index = of_property_match_string(np, "phy-names", prop); + if (index < 0) continue; - tegra->usbphy[i] = devm_usb_get_phy_by_node(tegra->dev, - phy->dev.of_node, - &tegra->id_nb); - if (!IS_ERR(tegra->usbphy[i])) { - dev_dbg(tegra->dev, "usbphy-%d registered", i); - otg_set_host(tegra->usbphy[i]->otg, &tegra->hcd->self); - } else { - /* - * usb-phy is optional, continue if its not available. - */ - tegra->usbphy[i] = NULL; - } + err = of_parse_phandle_with_args(np, "phys", "#phy-cells", + index, &args); + if (err) + continue; + + usbphy = devm_usb_get_phy_by_node(tegra->dev, args.np, + &tegra->id_nb); + if (IS_ERR(usbphy)) + continue; + + tegra->usbphy[i] = usbphy; + dev_dbg(tegra->dev, "usbphy-%d registered", i); + otg_set_host(tegra->usbphy[i]->otg, &tegra->hcd->self); } return 0; @@ -2168,8 +2179,7 @@ static void tegra_xhci_disable_phy_wake(struct tegra_xusb *tegra) continue; if (tegra_xusb_padctl_remote_wake_detected(padctl, tegra->phys[i])) - dev_dbg(tegra->dev, "%pOF remote wake detected\n", - tegra->phys[i]->dev.of_node); + dev_dbg(tegra->dev, "PHY %d remote wake detected\n", i); tegra_xusb_padctl_disable_phy_wake(padctl, tegra->phys[i]); }