Re: [PATCH v4 05/14] usb: hub: Associate port@ fwnode with USB port device
From: Chen-Yu Tsai
Date: Mon Jul 13 2026 - 02:41:19 EST
On Fri, Jul 10, 2026 at 8:08 PM Greg Kroah-Hartman
<gregkh@xxxxxxxxxxxxxxxxxxx> wrote:
>
> On Thu, Jul 09, 2026 at 05:57:10PM +0800, Chen-Yu Tsai wrote:
> > 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 <andriy.shevchenko@xxxxxxxxxxxxxxx>
> > Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>
> > Signed-off-by: Chen-Yu Tsai <wenst@xxxxxxxxxxxx>
> > ---
> > 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 | 14 ++++++++++++++
> > 1 file changed, 14 insertions(+)
> >
> > diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
> > index b1364f0c384c..e8fb2acd77be 100644
> > --- a/drivers/usb/core/port.c
> > +++ b/drivers/usb/core/port.c
> > @@ -7,6 +7,7 @@
> > * Author: Lan Tianyu <tianyu.lan@xxxxxxxxx>
> > */
> >
> > +#include <linux/acpi.h>
> > #include <linux/kstrtox.h>
> > #include <linux/slab.h>
> > #include <linux/string_choices.h>
> > @@ -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);
> > }
> > @@ -780,6 +786,13 @@ 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(dev_fwnode(&hdev->dev)))
> > + device_set_node(&port_dev->dev,
> > + fwnode_graph_get_port_by_id(dev_fwnode(&hdev->dev), port1));
> > mutex_init(&port_dev->status_lock);
> > retval = device_register(&port_dev->dev);
> > if (retval) {
> > @@ -852,6 +865,7 @@ int usb_hub_create_port_device(struct usb_hub *hub, int port1)
> >
> > void usb_hub_remove_port_device(struct usb_hub *hub, int port1)
> > {
> > + struct usb_device *hdev = hub->hdev;
> > struct usb_port *port_dev = hub->ports[port1 - 1];
> > struct usb_port *peer;
>
> Is this last variable addition not needed here? It's not used.
Indeed it is not used. It was left over from me figuring out how to release
the fwnode handle. Will drop it in the next version.
I still have some other comments to cover. And I want to go through the
code one more time to check Sashiko's concerns on the main patch
"usb: hub: Power on connected M.2 E-key connectors with power sequencing API".
ChenYu