From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.170 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796352808; b=X2alnoRP+mKoBsj42Npfc7TJEXOX55c9K4gCabKUvNZNeysqRw2BgkfLKNXdeTOv1czs R/CjUKGu9rqGEuSndKTvpmV4ZyRVaO8BaBfFP8uyL5YJmK0onpOtMEX5sBVnHpkQ3H+wO 1kiZgF7hoaKQvYzrsinxhS71eMyif84pvJWtAz2LwnNacSgRCurF9dAiy58t67o9VKmr3 Zm16UL0GUmMQUjlD0cbMRd92mFwuf1lxCaS/uxf3bCgBf2TT9EgJovQ8mQNf8TvOUqhBY 41Jk8CnUIx5VqYBniZEjkK/yeGRZ8dRsU/HwIfrCL4VRDjXZ29E304wzRJvzwoyUgRg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796352808; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=j/N86LiEtK4C/IjrQtPw2DESh3nxExtxnocI3j73d3g=; b=diqq/WnboBnJdqKwYEbe3bJzktoz1J/aJFmsGQDB5XVpclpfd76QNqjsEVhW5frjh1x+ CJ93HY246Si7UshRZTgZaDwoImGRVzBMR1PG0MvkeSiTLWYHDgasFlohyW2746G2o8lyZ QE+i1Lsdim5lqXT6M9USUOqR70MGOd3CbX5WEjTyQSNdJj8tVTjGsv1pYKCh/j03W/C3c chZb557Wp6yhBVrNJysrn6V1eh0BX75UPDp3WH/Wac+ZAfdjGA1Er8Eyx2y2ysg0Ozdn1 4UosDv1y23pHohnUci5WUuAxqs540DsiV+rXHVvUqsgWCN4uyahLeNw/DcPiwGgQURA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=hmjCMFfO; arc=none smtp.remote-ip=209.85.210.170 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C213D606A338 for ; Fri, 4 Dec 2026 02:53:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C213D606A338 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=hmjCMFfO Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-8a06cc097c7so341225b3a.0 for ; Thu, 03 Dec 2026 18:53:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1796352807; x=1796957607; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=j/N86LiEtK4C/IjrQtPw2DESh3nxExtxnocI3j73d3g=; b=hmjCMFfOzzOoq6zeL/nQykIv9ddg9GylZVzBmfZKfPx88LdjzPVl0xyBQj7Zj4ZxaA NVxndCRZpIKbcoln+fuz4pw4h1iwO2ESKcGkQtIewntOac7Qcuv8AX81Z4S05+8bc9i4 PAgCEavMi8uFJCJ88/O1WZhOez0cuxSr7YheM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796352807; x=1796957607; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=j/N86LiEtK4C/IjrQtPw2DESh3nxExtxnocI3j73d3g=; b=oWZN/e7+yF/3eWC7auUxbxHEJOL4h5h2QvIJz+qUHEfbDU8fSSgmtFk8hs+244JVkj O83rS3W+SDEoQsVqt3TedecOCc4qXFG1v90nAPJofBVXCJ7hbY1QYaF3Um6I6zBik++Z 4X8ujWVvKjvizoMgiNqy58iTsVRAATMHRXj61SAA9wk3FANtCgcgKxTvj9s+mUzcHo1K A8N+OayQc8om/zS1BXLIPzaq6O6xvbV+TqoECUPgUKfkq7wHgWpZGQ9OPu7EIM//avRw OyiDQ6O91btCv4C8SXNXI3Go0wNmczzeN5w/ur02R8JUMgGTwSRTrtrRh5aBBBWhd+UP tphw== X-Forwarded-Encrypted: i=1; AL+hErHM6FoN2+SFCq41xXF8XBCA5je3YSHnVRDzx8DZf6NT9uc2on5N7N2p/5Xo+EmgyAUxqbZx7otCd/Ai@vger.kernel.org X-Gm-Message-State: APuU4Z+0k2Bir6eo5GgE1zX/DrmLz7tRYFyT7qRqp0IAAJ5+KHgCLMqq VN0fLruvYK+ahmxDsA+Qt2Ev9P1N6BiNvQD4+wgJqB/4Qws/HAuxF1P+dD42X0GGHg== X-Gm-Gg: AZFdTZc5qSPvxpo2EViIZyOT3ogUUXG9nSsB/m/tNyS04CC9eDt85FSih0/gtX0AccT GkhcbpcTmo4FaO3mqhnTCkyZFhrI7VMWujLoHF1bwdTnp0aJnRu/7IrvWLcxf1cxhOgdjL+I+sT Ri5LvqS8L6uKaDbYOIuKwcnC/rWuyDe45XzcHlgrs3pMMOPphORfJ16G/1KWFisYVrtddKPuz0O Rd6grlFjh47KbzNFmL6zZKwZzyxLS4rT/Zq3z/WLlQh/oNkIipUg7PduTPtnxPqCRtqWkWPMaqI ruxqCtN5gOC5xUDribSMJn6XAqWT3iStiEmAZpixex8e6WMp3oFK7yoQ66pePlzPwr4sKqHC8Pm CXpR7Juz4CbztacvBAwutWcDi0xUqv/3F43bZOCjPcWm5BXet8OnKg4mUbcHtc/curlgXzHkXz/ TnWQkDPJ7f4DEO8UeZq1sHdSHr1FF1jK11AqIQOM+Vy15yvgxwL3MY8Vv/V9c2SJwyn4l0lCkAT zz5destk1zhqtt5oILfrVoGVc17qvIj30O9SPOx/3FdnedHkGl0FxjPUMjVKDjsxtF4MXhDnLum a2QLkCffPlpoBbPuHYJ2mBQqzfCHfshyrqQ3c7YiIS5BRinzwD3fiowLlLvTBeP7UY6JCJsF25u qcFZP X-Received: by 2002:a05:6a00:181b:b0:89f:d449:753c with SMTP id d2e1a72fcca58-8de2c4680c5mr796725b3a.10.1796352807023; Thu, 03 Dec 2026 18:53:27 -0800 (PST) Received: from localhost ([2a00:79e0:203d:7:baaf:2341:c22:c17a]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-8de121f3f95sm539936b3a.11.2026.12.03.18.53.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Dec 2026 18:53:26 -0800 (PST) From: Chen-Yu Tsai To: Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Chen-Yu Tsai , Alan Stern , linux-usb@vger.kernel.org, devicetree@vger.kernel.org, Matthias Kaehlcke , Stephen Boyd , =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= , Johan Hovold , Mathias Nyman , Neil Armstrong , Bjorn Andersson , stable@vger.kernel.org Subject: [PATCH 3/4] usb: misc: onboard_usb_dev: Create pdevs for secondary root hubs Date: Fri, 4 Dec 2026 10:52:41 +0800 Message-ID: <20261204025243.807657-4-wenst@chromium.org> X-Mailer: git-send-email 2.56.1.915.g69d5ec7298-goog In-Reply-To: <20261204025243.807657-1-wenst@chromium.org> References: <20261204025243.807657-1-wenst@chromium.org> X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit onboard_dev_create_pdevs() previously skipped root hubs of secondary (USB 3.x) HCDs because both the primary and secondary root hubs share the same HCD device tree node, and usb_of_get_device_node() did not map root hub port numbers to raw port numbers. Scanning both root hubs would have queried the same 1..maxchild reg values twice; on the second pass, of_platform_device_create() would reject the already-populated (OF_POPULATED) device node and log a "failed to create platform device" error. Now that usb_of_get_device_node() resolves root hub port numbers via usb_hcd_find_raw_port_number(), primary and secondary root hubs on xHCI controllers map to disjoint raw port ranges. Returning early for secondary root hubs means onboard_dev_create_pdevs() now only visits the primary (USB 2.0) root hub's ports and never creates platform devices for standalone USB 3.x onboard devices without a peer-hub (such as USB 3.0 Ethernet or SATA bridges) attached directly to a secondary root hub. On SuperSpeed-first xHCI controllers where raw port 1 belongs to the secondary root hub, this would also regress any such device at reg = <1> that previously matched the unmapped primary root hub index. No in-tree boards are broken by this change: all properly described in-tree USB 3.x onboard devices attached directly to xHCI root hubs are dual-speed hubs with a "peer-hub" property (whose platform device is created via the USB 2.0 peer on the primary root hub), and the USB 3.0-only non-hub devices supported by this driver have no in-tree device tree users yet. The one outlier, meson-libretech-cottonwood.dtsi, describes a GL3510 hub with only its USB 3.0 compatible ("usb5e3,626") and no "peer-hub" property at reg = <1> (a USB 2.0 port on the Amlogic G12B/SM1 DWC3 controller), so its platform device is still created via the primary root hub. Stop skipping secondary root hubs in onboard_dev_create_pdevs() and update its kernel-doc comment to match. Dual-speed onboard hubs with a "peer-hub" property are already deduplicated by the !usb_hcd_is_primary_hcd(hcd) check inside the loop, and each root hub tracks and destroys its own platform devices in its hub->onboard_devs list. This issue was flagged during a review by an AI coding agent (Antigravity). The code change and commit message were drafted by the agent and reviewed by me. Runtime-tested on MT8195 Cherry Dojo with a dual-speed onboard hub (verifying no duplicate platform device is created on the secondary root hub); the standalone USB 3.x device (without peer-hub) path is compile-tested only. Fixes: 8bc063641ceb ("usb: misc: Add onboard_usb_hub driver") Cc: Signed-off-by: Chen-Yu Tsai --- drivers/usb/misc/onboard_usb_dev_pdevs.c | 26 ++++++++---------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/drivers/usb/misc/onboard_usb_dev_pdevs.c b/drivers/usb/misc/onboard_usb_dev_pdevs.c index cdb6949e18ec..5cbc8b632097 100644 --- a/drivers/usb/misc/onboard_usb_dev_pdevs.c +++ b/drivers/usb/misc/onboard_usb_dev_pdevs.c @@ -48,21 +48,16 @@ static bool of_is_onboard_usb_dev(struct device_node *np) * * Root hubs don't have dedicated device tree nodes, but use the node of their * HCD. The primary and secondary HCD are usually represented by a single DT - * node. That means the root hubs of the primary and secondary HCD share the - * same device tree node (the HCD node). As a result this function can be called - * twice with the same DT node for root hubs. We only want to create a single - * platform device for each physical onboard device, hence for root hubs the - * loop is only executed for the root hub of the primary HCD. Since the function - * scans through all child nodes it still creates pdevs for onboard devices - * connected to the root hub of the secondary HCD if needed. + * node, so their root hubs share the same device tree node (the HCD node). + * Because usb_of_get_device_node() maps root hub port numbers to raw port + * numbers, each root hub only visits the child nodes connected to its own + * ports and creates platform devices for onboard devices attached to them. * - * Further there must be only one platform device for onboard hubs with a peer - * hub (the hub is a single physical device). To achieve this two measures are - * taken: pdevs for onboard hubs with a peer are only created when the function - * is called on behalf of the parent hub that is connected to the primary HCD - * (directly or through other hubs). For onboard hubs connected to root hubs - * the function processes the nodes of both peers. A platform device is only - * created if the peer hub doesn't have one already. + * Further, there must be only one platform device for onboard hubs with a peer + * hub (the hub is a single physical device). To achieve this, pdevs for onboard + * hubs with a peer are only created when the function is called on behalf of a + * parent hub that is connected to the primary HCD (directly or through other + * hubs), and only if the peer hub doesn't have one already. */ void onboard_dev_create_pdevs(struct usb_device *parent_hub, struct list_head *pdev_list) { @@ -75,9 +70,6 @@ void onboard_dev_create_pdevs(struct usb_device *parent_hub, struct list_head *p if (!parent_hub->dev.of_node) return; - if (!parent_hub->parent && !usb_hcd_is_primary_hcd(hcd)) - return; - for (i = 1; i <= parent_hub->maxchild; i++) { np = usb_of_get_device_node(parent_hub, i); if (!np) -- 2.56.1.915.g69d5ec7298-goog