From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D47ECFF885A for ; Tue, 5 May 2026 10:07:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=N7o3waI5FbchNnvXZdyzkDg7hgQMLHpwHSQRK8/XvEo=; b=lGUICLuTwmdT7cmPuXImTwmXeY fmWi5fJR6d7VLlGkiKN7POZ5GJqVNwNUjkCgBD/BNzoY05FYdZBO2qUaf2RTDl7/xBAh4OG2ZdZWX v1yX9Yl1YQziUQcbMTpsftxAff63eOx0nQyI+cJ/9HBc/+C5TogzR+d9SDa/zF4SXKanDHcCzEysr BUjxHX6IC9zKuqCNJ96HaoP6H4neO0QevXxzQenq1np4/Ou/1JNaPpoolY1ntEIu91SflfxFDjDfw 1c6amWqa2o1lrVdwcYVRUBigmpIfu1Y01asZ3r4hdWN9y4dkaywKtHQ2FLsHSUf2EiuUhw5CvpZ/T mnm5A5LA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1wKCgh-0000000Fn95-3sz9; Tue, 05 May 2026 10:07:35 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1wKCfe-0000000FlZ9-3ln1; Tue, 05 May 2026 10:06:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=MIME-Version:Content-Type: Content-Transfer-Encoding:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:Content-ID:Content-Description; bh=N7o3waI5FbchNnvXZdyzkDg7hgQMLHpwHSQRK8/XvEo=; b=VqPWh+yeq9pF9MaZ/5c5FNf9yb P8/OIN0Xaw5urTl63KF6UK+5ssDNuyFx2BypGUCncW+ud1+L4F5ykB/yNHNs+hWYre2MC7yIO/Xqc q1ZOnphX6AuTrQNKU2JtnCaHZwmQFAAUOEd4FmljGTbMQ+v0K6Ld0tFL7SHETwr2l9CTkMtT37GeE l7enLHWGTTN+mv5AZsRNlUNtq5e2WeWO/mNr++QmYRIZ68WzcxDaVyOs0GjuDwvs2Nn8IsZnAwoEX nQ5Y5V8rReWELT7F+3Y4gpQOA+IIyhuP0xoE1x1fZbVygESKcBruYC2rHOTaA+QCXpbasLKpONjwS hyIGbiwA==; Received: from mail-norwayeastazon11013038.outbound.protection.outlook.com ([40.107.159.38] helo=OSPPR02CU001.outbound.protection.outlook.com) by desiato.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1wKCfc-0000000D7jp-02hP; Tue, 05 May 2026 10:06:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RZE4cQEM1/2ImQvHPkl/8EHgazHQ1lPBi3H1IAvWWd78QglcRcOlWkiXMj8izwgslCObUFSGnXpEbBorp+FZo2SM+2V7XweswgnO0RlIJT4sJw1wSEOWJvT8hFFI1/TnJdZWWv+/ambgrSbd9tdaaIOEhYg0peOrw/xrFRXbfN4rfgnrueK02ZsVt/ypzesa8tsVLRYxLS7F+mNDgiUuKBUtiBMSZ3jPdMUfhQlvQ44R3b8tZqx3cajrYKyyQCxXfnEBzmXp+W+FwZ6imHgnsdu/8zDL+SqCu2xd6L9tAPPA6kdd3d2sGuYfdSc3bU7cXirrusSCZj0zcwz5JvbsjQ== 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=N7o3waI5FbchNnvXZdyzkDg7hgQMLHpwHSQRK8/XvEo=; b=mHDF64k+6oA+QFfMW3Zgwd3/nbTzHohtoNma0IcHDq2dWLqzRmWhW9ZiWqQ8QPBw6ZW38nfUI98I+OsqVbfwwcBhJ+urR+h091A5LB3SIxoc0imxD7OmOu9qhFakpe7M9IPE/ytrmicfY4NIrdYunMK+mIQfOHmsmyaiFGOuMePWQjdiY6iBhqFQDDwV/O82tNGF9z8b2kvk3tYdNw6AK9MRyUbVjaNCW/NX5nsGRoTLZJC1sQ4VpVq1bF1qhrygNAfd3WEXG4KE42fkh86/yfuz46F6t9jS2kWxE1DudsyWlyFlCcFzQzheCbdV+OWUofQ7nndz7DGgd4sDGCyVFg== 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=N7o3waI5FbchNnvXZdyzkDg7hgQMLHpwHSQRK8/XvEo=; b=QoEgxe1hRP4uF8soPSoD7NC3h9vrL2Dg6OPBNe8nmNb6fROKE4FyOrWgoLeXt5DKGC+G8WmAcDVWLNXRfo0G0AZwe6luxVg3GxE0DSkcwJQ22pzT2uoGMUERt/k2oPjobTV6+WLvF5ngouqjArA8XNiszuNOuDHs95MSVyyQWMlW2rCv2pWXAMtoMirXDlyxk3NX/4PCDIOz3WU+z7zcKYCDFmzAixzPsEv9OtdvkFdymypypfsV1R8gKJmU3ad8wCh8Ycdg1HacKh6bcj0lyVCU3DHI6nTqJ18Z2Eli5jYaGAmvb46ecL/YySLTr1YyJ3qq/bW7LBTYw+en27VGRQ== 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 DB9PR04MB8363.eurprd04.prod.outlook.com (2603:10a6:10:24b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9846.26; Tue, 5 May 2026 10:06:12 +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.9870.023; Tue, 5 May 2026 10:06:12 +0000 From: Vladimir Oltean To: linux-phy@lists.infradead.org Cc: Vinod Koul , Neil Armstrong , 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 , JC Kuo , Johan Hovold , Jonathan Hunter , Mathias Nyman , Thierry Reding Subject: [PATCH v8 phy-next 16/31] usb: host: tegra: avoid direct dereference of phy->dev.of_node Date: Tue, 5 May 2026 13:05:08 +0300 Message-Id: <20260505100523.1922388-17-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260505100523.1922388-1-vladimir.oltean@nxp.com> References: <20260505100523.1922388-1-vladimir.oltean@nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: FR4P281CA0029.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:c9::14) To AM9PR04MB8585.eurprd04.prod.outlook.com (2603:10a6:20b:438::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8585:EE_|DB9PR04MB8363:EE_ X-MS-Office365-Filtering-Correlation-Id: 85101bc9-9f4e-4aba-ece7-08deaa8def05 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|19092799006|7416014|366016|22082099003|18002099003|56012099003; X-Microsoft-Antispam-Message-Info: Z1RYYKKCKz/VO+uTid9KKTjcAHO+o3ySmvhph9kUfhA+zpKR51o1AnH6DfYOKnRZ+T1IeUvuW2pEBuWYCWsrDcVCjLJmby5jp4W3LUZ4yWJcLftWOozukU2ElsV3JkzryYfgkIhl9t6YZUe3DeHrGXHiQ4WCopa0C6aOU34ZPrNu8xVfw533csTYo2TAzfDFFwit/wNIyscGwjaOppaQ6CbhtBf8YrDnyHI22ks9uVCnFEBU4/fT7jvYGZtUVzo9BmRKJobOyl5jfRl59UfswuzgRAlqFmzyktfI2d9hon5Yhh5K/351dxJFLA4D9QScuG16TWAFiiU4mdKpd/tOCSMy/YWVFZPOHwGzRN+l7GtKSmBPHjewmcjIT6NnXzGfIhdV8yOTj40wD9tB7FgYIZhKywDAMin+61EBBjEVqWKktdXqc4HkWYDhfmvBPds6zH7pUbzAMLEBwg0H1XrtoQKSW3ws8+RBfR4hW8nJJxq12BVS5M8woKP4t3rMR0JKogvsWIdQwEFevfxnpE+yfA2U3URnUVarEUt4A3V1WWgPSX7Ys9v3lLkxRI/dZJEL3lHqnlxYEJ5MWa6wrW+x34+rcOuPVpf5ZG5drsAwheJql8ixK4gyJmoY/yOCNDjoCTER7ZcsYOuflbaOUBZXG+2Zq4qK/vlGBwNgt3r547VhmwCOJzVapclg8C5C6zF0 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)(376014)(1800799024)(19092799006)(7416014)(366016)(22082099003)(18002099003)(56012099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?S4QM1i+WO3VTisiAYzK0HsrSs8uQa8DSJOycel8hlUGYszfBUv/4mvR3Vy3C?= =?us-ascii?Q?sImtcaI+Is7/sKrHMAGGmVcqMC9cSrYu3yy7ndRVMwwJtb26j11HS2N7jkZR?= =?us-ascii?Q?eQ7iogxlM8xtgYmf7LYKmt8bM0AjbG1cXReMCuBv6OVLqdNAhKkS+W2yIcVR?= =?us-ascii?Q?kamopEyn8cUOziHI7lgUX798zbG8C+lbpOmhNJWbaNY8XwiTo7YXFf2UJsSQ?= =?us-ascii?Q?aai6NIVuFCLfvyi9CWzw8meVzufLILbbxnQ/TE6vW0+7TKtzcqdttRMNxaB0?= =?us-ascii?Q?RBo9MlMMdCllCE57CoIY/NV6mw07r9ekF8C78oxjucNQW1m/zvx00UM+wQDL?= =?us-ascii?Q?+dz0PsimeEyLVDRDVzYFckbEJYHyjB8cyZIU13zvatFxjfaS0H/fRKvvyiVw?= =?us-ascii?Q?MVmdkN8Ni1UljYpQtWyGXcESJ0mPtQYewJ3OMUyHtP0sV3JObjJd0cOugLAE?= =?us-ascii?Q?XLrkxdzZUiD6+ATFCK6E8ktz6h5x6i3Z0T4SHYwTfDtC38n8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+tY7/lWFvh7HH/yrdKEeDWPFExBSCHJkmphdb?= =?us-ascii?Q?p72YKYtzlO0dksQ7BEAWFSKt7ZlNZ4VlYmFbWtm5E5Obu2xYtF5y8p7aYBxI?= =?us-ascii?Q?V/eyU7JPxvwgs9YyJrgO6CEGnZ7Zmep/vSb+/3QoKg21rtqYM7fMw2VY5zcE?= =?us-ascii?Q?CnAd2ikbHqBP1YjWfxM+SRNUyeZ48pon/GxA+bijiSvs2jtfAO2x1movWSuC?= =?us-ascii?Q?SD9OGeuGzKRxFKHPqQH/E9LDInUbMUyOXXUoqIl0HFNA8JxG/GRHGCqX9fhk?= =?us-ascii?Q?DS7iyvxkEVqtFMRieaCZrZ4ogRHOMceNQ3f5lI6qHGVySA6IZL2rJEmL1Xlt?= =?us-ascii?Q?WBJyHQMxOQ=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 85101bc9-9f4e-4aba-ece7-08deaa8def05 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8585.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2026 10:06:11.2812 (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: lsJKMs5ZVBiA7FqFYDRl8rzADDRycG0u5BOC4GT1YkeHMYi/zcEcx0R1gKhfft2bA4T6a4LdhJtz84r+AhTgrw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8363 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260505_110628_100358_090988D8 X-CRM114-Status: GOOD ( 22.00 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 --- Cc: Greg Kroah-Hartman Cc: JC Kuo Cc: Johan Hovold Cc: Jonathan Hunter Cc: Mathias Nyman Cc: Thierry Reding v7->v8: - add missing of_node_put(args.np) in tegra_xusb_init_usb_phy() - replace %d with %u in tegra_xhci_disable_phy_wake() Both pointed out by Sashiko. v5->v7: none v4->v5: patch is new --- drivers/usb/host/xhci-tegra.c | 43 ++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c index d2214d309e96..6724a777ca2a 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,34 @@ 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); + of_node_put(args.np); + 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 +2180,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 %u remote wake detected\n", i); tegra_xusb_padctl_disable_phy_wake(padctl, tegra->phys[i]); } -- 2.34.1