Message ID | 20230105132457.4125372-3-treapking@chromium.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Register Type-C mode-switch in DP bridge endpoints | expand |
On Thu, Jan 05, 2023 at 09:24:50PM +0800, Pin-yen Lin wrote: > From: Prashant Malani <pmalani@chromium.org> > > When using OF graph, the fw_devlink code will create links between the > individual port driver (cros-ec-typec here) and the parent device for > a Type-C switch (like mode-switch). Since the mode-switch will in turn > have the usb-c-connector (i.e the child of the port driver) as a > supplier, fw_devlink will not be able to resolve the cyclic dependency > correctly. > > As a result, the mode-switch driver probe() never runs, so mode-switches > are never registered. Because of that, the port driver probe constantly > fails with -EPROBE_DEFER, because the Type-C connector class requires all > switch devices to be registered prior to port registration. > > To break this deadlock and allow the mode-switch registration to occur, > purge all the usb-c-connector nodes' absent suppliers. This eliminates > the connector as a supplier for a switch and allows it to be probed. > Signed-off-by: Prashant Malani <pmalani@chromium.org> > > Signed-off-by: Pin-yen Lin <treapking@chromium.org> Tag block mustn't have the blank line(s). ... > + /* > + * OF graph may have set up some device links with switches, since > + * connectors have their own compatible. Purge these to avoid a deadlock > + * in switch probe (the switch mistakenly assumes the connector is a > + * supplier). > + */ Perhaps even /* * OF graph may have set up some device links with switches, * since connectors have their own compatible. Purge these * to avoid a deadlock in switch probe (the switch mistakenly * assumes the connector is a supplier). */ ? > + if (dev->of_node) I would use if (dev_of_node(dev)), but it's up to you and maintainers. > + device_for_each_child_node(dev, fwnode) > + fw_devlink_purge_absent_suppliers(fwnode);
Hi Andy, Thanks for the review. On Thu, Jan 5, 2023 at 11:34 PM Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote: > > On Thu, Jan 05, 2023 at 09:24:50PM +0800, Pin-yen Lin wrote: > > From: Prashant Malani <pmalani@chromium.org> > > > > When using OF graph, the fw_devlink code will create links between the > > individual port driver (cros-ec-typec here) and the parent device for > > a Type-C switch (like mode-switch). Since the mode-switch will in turn > > have the usb-c-connector (i.e the child of the port driver) as a > > supplier, fw_devlink will not be able to resolve the cyclic dependency > > correctly. > > > > As a result, the mode-switch driver probe() never runs, so mode-switches > > are never registered. Because of that, the port driver probe constantly > > fails with -EPROBE_DEFER, because the Type-C connector class requires all > > switch devices to be registered prior to port registration. > > > > To break this deadlock and allow the mode-switch registration to occur, > > purge all the usb-c-connector nodes' absent suppliers. This eliminates > > the connector as a supplier for a switch and allows it to be probed. > > > Signed-off-by: Prashant Malani <pmalani@chromium.org> > > > > Signed-off-by: Pin-yen Lin <treapking@chromium.org> > > Tag block mustn't have the blank line(s). > > ... > > > + /* > > + * OF graph may have set up some device links with switches, since > > + * connectors have their own compatible. Purge these to avoid a deadlock > > + * in switch probe (the switch mistakenly assumes the connector is a > > + * supplier). > > + */ > > Perhaps even > > /* > * OF graph may have set up some device links with switches, > * since connectors have their own compatible. Purge these > * to avoid a deadlock in switch probe (the switch mistakenly > * assumes the connector is a supplier). > */ > > ? I can update this in v8, though I wonder why shorter comments are preferred as they haven't exceeded the 80-character length requirement. > > > + if (dev->of_node) > > I would use if (dev_of_node(dev)), but it's up to you and maintainers. dev_of_node looks a bit better as it checks the enabled config for us. I'll update this in v8. > > > + device_for_each_child_node(dev, fwnode) > > + fw_devlink_purge_absent_suppliers(fwnode); > > -- > With Best Regards, > Andy Shevchenko > > Best regards, Pin-yen
diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index 2a7ff14dc37e..30cf03c2e95d 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -382,6 +382,16 @@ static int cros_typec_init_ports(struct cros_typec_data *typec) return -EINVAL; } + /* + * OF graph may have set up some device links with switches, since + * connectors have their own compatible. Purge these to avoid a deadlock + * in switch probe (the switch mistakenly assumes the connector is a + * supplier). + */ + if (dev->of_node) + device_for_each_child_node(dev, fwnode) + fw_devlink_purge_absent_suppliers(fwnode); + /* DT uses "reg" to specify port number. */ port_prop = dev->of_node ? "reg" : "port-number"; device_for_each_child_node(dev, fwnode) {