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 2FFEDC79F80 for ; Fri, 4 Sep 2026 08:43:56 +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:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=7FkHDnS01ZrIUIFEZvu4Ez5qiW1Xnkoau5FbL5ZwNaU=; b=idIvWnEe6p8Sd/GMU0Ancf6tKX yPW6m1ZOvut6LKgt68i5aLO9b9DX/Qt4OOtDnl1n5V1AMK5En4LMXXfqSwiFbdElnaDAViQFgWjmd z/diFKHuA2+RhV65i0SJRvUcpY5B26XOVtI5MUPXL+uIqSUihzyR26W0s8fHmXRRrlTOb23OiKpx3 aQAzMoUGMwsiU7SOR0YnEec3dnqEezdC68NGrgAozGRxA4RTDVPrW/k+S3YOJBqsME09iwEpc4qFb T++htoioAr2aJKnNmxbevGkI5oHNLJcN92YctOpI4R3L7k7zVIPWN/6UXSDrml5Qf5hW3JK2OE7c1 CLeg34bA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1x2PWd-00000001Q6h-0rzq; Fri, 04 Sep 2026 08:43:55 +0000 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1x2PWa-00000001Q5H-1jfB for linux-mediatek@lists.infradead.org; Fri, 04 Sep 2026 08:43:53 +0000 Received: by mail-pj1-x102f.google.com with SMTP id 98e67ed59e1d1-398b3d66515so848879a91.0 for ; Fri, 04 Sep 2026 01:43:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1788511431; x=1789116231; darn=lists.infradead.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=7FkHDnS01ZrIUIFEZvu4Ez5qiW1Xnkoau5FbL5ZwNaU=; b=KwMxB0GB+/qlQ7DZ+Df0Gc1aZdG6KkQuuYn9fq7PaCg9aNVbV7y+wG1idZH4asMtbu aZegh43vEcrSMe3e3J+IeOhAIYc5hlc4ZlMULPFqlGMHf5EcNBXOwSo1Gxo4nPFH/bY2 snSBh93szvXyEKcgG/uqvguaRa+3cNU7Hmebc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788511431; x=1789116231; 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=7FkHDnS01ZrIUIFEZvu4Ez5qiW1Xnkoau5FbL5ZwNaU=; b=NPA3gQ9PeWoWWW3TgvwDqVymBHDGaOWSkY78kHg979dsdYgZ7xbc3gw0e26neI9Pcx CZtMJX/Ha1T6Dc27BGBlsuNsubnRxR14Ox5CPr/VBobV74+F5JAD8PSgCS/TYBmL0Ev7 SbeHxQWfHttKbfj6ajejYKJw39vg2KltW38sziTVcqUEJDTJGD8MVMh/aOvLVjYxgeqt 10W6GYRgYeNRzcgfEbFVTtAQxNgNxUjTRMswf2EDslftOrr0PsvhhQmHNeRbXBPSMp2q xUGZdaNSv/JSgLJIbhj4hbJCWFy0cZLlkvuI1/j0USG9shcgJv02JxcXnMYgOxOhsm06 ZsKg== X-Forwarded-Encrypted: i=1; AKwUvBxMa3RI63/nNNVW1vttip0/PGry8AuuVKtMpW5GKlAe08i03GrZuEPgk8lVgzxiNsXTkU7oX3g1FsRQlzAKyQ==@lists.infradead.org X-Gm-Message-State: AFuF++l6cUQ7pKZu0eOcZK1SXN9W2f8VN1VnoDb6xioEJBdcWUOwB7zw rfAm3dYPVEQmiKQgve04pXM2iQV13nvTdibkJW9GukdoqOpEHumcEuXUU4NYbmhk8w== X-Gm-Gg: AYBFou2S9CWYkc02zdb6iIsv02FW/BrY2I7axqJXHgX/498eJpOD0jFfDvHAcrCqXmv OqE7Akc6GyOlrzirpFubyUDblVKmlvwQ0KXbjmMHxNoT6EY5MXA950PGyxTrVDLp0fYJHfbZGzT eJocXBu/wKMf56v2MXTf021Xg2LXuY7OUoJjCV5RXnV6RFHmshjsEoTrHmaENnp9lorFED+hgQu SfigmEgdeUE5+SnavOIyojttYAZW8838CchuD9RK7w7Pcp23AYy49VlZMRGlYfiOYxHkStwtxqg Zzxj9JGLcoeIm/nyI0QCbLePf6EjfExMOXc0pDOF6DkhUsnVHwgjpV6b5qPV82UjhOSlJkbKuYa VY32vb8reqfZmyRVnQ2/3YILf7BvbtgAu3uxIqWzBoYkRxb37nAbkUORbaMaYqjOkkZRbRa+Jw3 0pVRlO4XBSWMiC3lkJxSE5OVvFtjmR97pVRjbLV+Sx78cd3hQhHSnSR5el1wGiw3hogiRF2J9tE TlsQ4XMho5YH/r+XJxkpMcpaOu4Jc2DY0ELBKX4x1n87jdTZO6R41E= X-Received: by 2002:a17:90b:264c:b0:36b:bec8:94c5 with SMTP id 98e67ed59e1d1-39b2612f7dbmr7487531a91.10.1788511431512; Fri, 04 Sep 2026 01:43:51 -0700 (PDT) Received: from wenst-7875.tpe.corp.google.com ([2a00:79e0:201d:8:343:bf21:3095:9c5]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-39b260fdf9asm3343538a91.9.2026.09.04.01.43.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2026 01:43:11 -0700 (PDT) From: Chen-Yu Tsai To: Bartosz Golaszewski , Greg Kroah-Hartman , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , "Rafael J. Wysocki" , Danilo Krummrich , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno Cc: Wei Deng , Konrad Dybcio , Chen-Yu Tsai , linux-acpi@vger.kernel.org, driver-core@lists.linux.dev, linux-pm@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam , Alan Stern , Bartosz Golaszewski Subject: [PATCH v8 06/16] usb: hub: Associate port@ fwnode with USB port device Date: Fri, 4 Sep 2026 16:41:45 +0800 Message-ID: <20260904084158.1341550-7-wenst@chromium.org> X-Mailer: git-send-email 2.55.0.979.g7e5102b832-goog In-Reply-To: <20260904084158.1341550-1-wenst@chromium.org> References: <20260904084158.1341550-1-wenst@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260904_014352_450494_B56E05D6 X-CRM114-Status: GOOD ( 18.21 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org When a USB hub port is connected to a connector in a firmware node graph, the port itself has a node in the graph. Associate the port's firmware node with the USB port's device, usb_port::dev. This is used in later changes for the M.2 slot power sequencing provider to match against the requesting port. To avoid potential conflicts with ACPI firmware nodes and then causing power management issues, only assign the firmware node if the hub's firmware node is not an ACPI firmware node. Reviewed-by: Andy Shevchenko Reviewed-by: Bartosz Golaszewski Signed-off-by: Chen-Yu Tsai --- Changes since v5: - Added extra |struct fwnode_handle *| local variables to shorten lines (Andy) - Added comment about passing fwnode_graph_get_port_by_id() return value directly to device_set_node() (Andy) Changes since v4: - Dropped unused |hdev| variable - Added flags for fwnode_graph_get_port_by_id() with FWNODE_GRAPH_DEVICE_DISABLED so that even incomplete ports can be connected Changes since v3: - Added missing fwnode_handle_put() Changes since v2: - Skip assignment if hub firmware node is ACPI node --- drivers/usb/core/port.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c index b4452b665f59..c0a51d9b06a6 100644 --- a/drivers/usb/core/port.c +++ b/drivers/usb/core/port.c @@ -7,6 +7,7 @@ * Author: Lan Tianyu */ +#include #include #include #include @@ -358,6 +359,11 @@ static void usb_port_device_release(struct device *dev) { struct usb_port *port_dev = to_usb_port(dev); + /* + * At this point ACPI nodes and swnodes have been removed by + * device_platform_notify_remove() in device_del(). + */ + fwnode_handle_put(dev_fwnode(dev)); kfree(port_dev->req); kfree(port_dev); } @@ -754,6 +760,7 @@ int usb_hub_create_port_device(struct usb_hub *hub, int port1) { struct usb_port *port_dev; struct usb_device *hdev = hub->hdev; + struct fwnode_handle *fwnode = dev_fwnode(&hdev->dev); int retval; port_dev = kzalloc_obj(*port_dev); @@ -782,6 +789,24 @@ int usb_hub_create_port_device(struct usb_hub *hub, int port1) port_dev->dev.driver = &usb_port_driver; dev_set_name(&port_dev->dev, "%s-port%d", dev_name(&hub->hdev->dev), port1); + + /* + * ACPI FW nodes are associated later when device_register() happens. + * Skip assigning one here to avoid potential conflicts. + */ + if (!is_acpi_node(fwnode)) { + struct fwnode_handle *port; + + /* + * fwnode_graph_get_port_by_id() returns either a valid fwnode handle + * or NULL. Passing NULL to device_set_node() clears any associated + * fwnode. It is effectively a no-op here, since no fwnode has been + * assigned to the newly created device yet. + */ + port = fwnode_graph_get_port_by_id(fwnode, port1, FWNODE_GRAPH_DEVICE_DISABLED); + device_set_node(&port_dev->dev, port); + } + mutex_init(&port_dev->status_lock); retval = device_register(&port_dev->dev); if (retval) { -- 2.55.0.979.g7e5102b832-goog