linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] usb: typec: tcpm: Don't block probing of consumers of "connector" nodes
@ 2021-05-06  0:44 Saravana Kannan
  2021-05-06  2:01 ` John Stultz
  0 siblings, 1 reply; 3+ messages in thread
From: Saravana Kannan @ 2021-05-06  0:44 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki, Guenter Roeck,
	Heikki Krogerus, Len Brown, Saravana Kannan
  Cc: John Stultz, kernel-team, linux-kernel, linux-usb, linux-acpi

fw_devlink expects DT device nodes with "compatible" property to have
struct devices created for them. Since the connector node might not be
populated as a device, mark it as such so that fw_devlink knows not to
wait on this fwnode being populated as a struct device.

Without this patch, USB functionality can be broken on some boards.

Fixes: f7514a663016 ("of: property: fw_devlink: Add support for remote-endpoint")
Reported-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Saravana Kannan <saravanak@google.com>
---
Greg,

Probably better to take this in driver-core in case I need more fixes
for fw_devlink on top of this. Those fixes are more likely to land in
driver-core.

Hi John,

Can you please test this and give a Tested-by?

-Saravana

 drivers/base/core.c           | 3 ++-
 drivers/usb/typec/tcpm/tcpm.c | 9 +++++++++
 include/linux/fwnode.h        | 1 +
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index 4a8bf8cda52b..628e33939aca 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -150,7 +150,7 @@ void fwnode_links_purge(struct fwnode_handle *fwnode)
 	fwnode_links_purge_consumers(fwnode);
 }
 
-static void fw_devlink_purge_absent_suppliers(struct fwnode_handle *fwnode)
+void fw_devlink_purge_absent_suppliers(struct fwnode_handle *fwnode)
 {
 	struct fwnode_handle *child;
 
@@ -164,6 +164,7 @@ static void fw_devlink_purge_absent_suppliers(struct fwnode_handle *fwnode)
 	fwnode_for_each_available_child_node(fwnode, child)
 		fw_devlink_purge_absent_suppliers(child);
 }
+EXPORT_SYMBOL_GPL(fw_devlink_purge_absent_suppliers);
 
 #ifdef CONFIG_SRCU
 static DEFINE_MUTEX(device_links_lock);
diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index c4fdc00a3bc8..bffa342d4e38 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -5754,6 +5754,15 @@ static int tcpm_fw_get_caps(struct tcpm_port *port,
 	if (!fwnode)
 		return -EINVAL;
 
+	/*
+	 * This fwnode has a "compatible" property, but is never populated as a
+	 * struct device. Instead we simply parse it to read the properties.
+	 * This it breaks fw_devlink=on. To maintain backward compatibility
+	 * with existing DT files, we work around this by deleting any
+	 * fwnode_links to/from this fwnode.
+	 */
+	fw_devlink_purge_absent_suppliers(fwnode);
+
 	/* USB data support is optional */
 	ret = fwnode_property_read_string(fwnode, "data-role", &cap_str);
 	if (ret == 0) {
diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h
index ed4e67a7ff1c..59828516ebaf 100644
--- a/include/linux/fwnode.h
+++ b/include/linux/fwnode.h
@@ -187,5 +187,6 @@ extern u32 fw_devlink_get_flags(void);
 extern bool fw_devlink_is_strict(void);
 int fwnode_link_add(struct fwnode_handle *con, struct fwnode_handle *sup);
 void fwnode_links_purge(struct fwnode_handle *fwnode);
+void fw_devlink_purge_absent_suppliers(struct fwnode_handle *fwnode);
 
 #endif
-- 
2.31.1.527.g47e6f16901-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] usb: typec: tcpm: Don't block probing of consumers of "connector" nodes
  2021-05-06  0:44 [PATCH v1] usb: typec: tcpm: Don't block probing of consumers of "connector" nodes Saravana Kannan
@ 2021-05-06  2:01 ` John Stultz
  2021-05-10 14:29   ` Greg Kroah-Hartman
  0 siblings, 1 reply; 3+ messages in thread
From: John Stultz @ 2021-05-06  2:01 UTC (permalink / raw)
  To: Saravana Kannan
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Guenter Roeck,
	Heikki Krogerus, Len Brown, Android Kernel Team, lkml,
	Linux USB List, ACPI Devel Maling List

On Wed, May 5, 2021 at 5:44 PM Saravana Kannan <saravanak@google.com> wrote:
>
> fw_devlink expects DT device nodes with "compatible" property to have
> struct devices created for them. Since the connector node might not be
> populated as a device, mark it as such so that fw_devlink knows not to
> wait on this fwnode being populated as a struct device.
>
> Without this patch, USB functionality can be broken on some boards.
>
> Fixes: f7514a663016 ("of: property: fw_devlink: Add support for remote-endpoint")
> Reported-by: John Stultz <john.stultz@linaro.org>
> Signed-off-by: Saravana Kannan <saravanak@google.com>

Tested-by: John Stultz <john.stultz@linaro.org>

Thanks so much for this fix! HiKey960 is back to booting properly!
-john

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] usb: typec: tcpm: Don't block probing of consumers of "connector" nodes
  2021-05-06  2:01 ` John Stultz
@ 2021-05-10 14:29   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2021-05-10 14:29 UTC (permalink / raw)
  To: John Stultz
  Cc: Saravana Kannan, Rafael J. Wysocki, Guenter Roeck,
	Heikki Krogerus, Len Brown, Android Kernel Team, lkml,
	Linux USB List, ACPI Devel Maling List

On Wed, May 05, 2021 at 07:01:04PM -0700, John Stultz wrote:
> On Wed, May 5, 2021 at 5:44 PM Saravana Kannan <saravanak@google.com> wrote:
> >
> > fw_devlink expects DT device nodes with "compatible" property to have
> > struct devices created for them. Since the connector node might not be
> > populated as a device, mark it as such so that fw_devlink knows not to
> > wait on this fwnode being populated as a struct device.
> >
> > Without this patch, USB functionality can be broken on some boards.
> >
> > Fixes: f7514a663016 ("of: property: fw_devlink: Add support for remote-endpoint")
> > Reported-by: John Stultz <john.stultz@linaro.org>
> > Signed-off-by: Saravana Kannan <saravanak@google.com>
> 
> Tested-by: John Stultz <john.stultz@linaro.org>
> 
> Thanks so much for this fix! HiKey960 is back to booting properly!
> -john

Now queued up, thanks.

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-10 14:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-06  0:44 [PATCH v1] usb: typec: tcpm: Don't block probing of consumers of "connector" nodes Saravana Kannan
2021-05-06  2:01 ` John Stultz
2021-05-10 14:29   ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).