mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sebastian Reichel <sebastian.reichel@collabora.com>
To: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	 Heiko Stuebner <heiko@sntech.de>, Vinod Koul <vkoul@kernel.org>,
	 Neil Armstrong <neil.armstrong@linaro.org>,
	Manivannan Sadhasivam <mani@kernel.org>,
	 "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	 "linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	 "linux-rockchip@lists.infradead.org"
	<linux-rockchip@lists.infradead.org>,
	"linux-phy@lists.infradead.org" <linux-phy@lists.infradead.org>,
	 "kernel@collabora.com" <kernel@collabora.com>,
	Igor Paunovic <royalnet026@gmail.com>
Subject: Re: [PATCH 2/5] usb: dwc3: rockchip: introduce glue driver
Date: Thu, 24 Sep 2026 17:29:40 +0200	[thread overview]
Message-ID: <arU0_rRUerCfhAs0@venus> (raw)
In-Reply-To: <arMkheCePz6PD8NZ@vbox>

[-- Attachment #1: Type: text/plain, Size: 6502 bytes --]

Hi,

On Wed, Sep 23, 2026 at 01:31:03AM +0000, Thinh Nguyen wrote:
> On Tue, Sep 15, 2026, Sebastian Reichel wrote:
> > Introduce Rockchip specific glue code for the Synopsys DWC3 USB driver.
> > For now this handles things identical to the default glue.
> > 
> > Tested-by: Igor Paunovic <royalnet026@gmail.com> # Orange Pi 5 Plus
> > Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> > ---
> >  drivers/usb/dwc3/Kconfig         |  11 ++++
> >  drivers/usb/dwc3/Makefile        |   1 +
> >  drivers/usb/dwc3/core.c          |  15 ++++++
> >  drivers/usb/dwc3/dwc3-rockchip.c | 106 +++++++++++++++++++++++++++++++++++++++
> >  4 files changed, 133 insertions(+)
> > 
> 
> <...>
> 
> >  
> > +/*
> > + * List of compatibles, which have "synopsys,dwc3" as a fallback
> > + * compatible, but have a vendor specific glue driver that should
> > + * be used instead of this one.
> > + */
> 
> Shouldn't these be guarded by CONFIG_USB_DWC3_ROCKCHIP so that
> we can still fall back to the generic DWC3 driver?

I think it's better to not probe at all. The reason for introducing
the new glue driver is avoiding PHY startup problems. They already
happen every now and then (so the bug is not introduced by my USBDP
patches, but rather its an existing race condition). Fixing the hangs
also requires driving the reset notifier from the USBDP PHY, which is
not part of this series. But I doubt we get a lot from making
patch series interdependencies even more complicated by temporarily
continueing to allow using the generic DWC3 driver on Rockchip.

Note that the PHY startup hang probability increases a lot by my
USBDP series. So once that landed the generic code is no longer
usable without doing lots of reboots and getting very lucky.

> > +static const char *const dwc3_compatible_blocklist[] = {
> 
> #if IS_ENABLED(CONFIG_USB_DWC3_ROCKCHIP)
> 
> > +	"rockchip,rk3588-dwc3",
> > +	"rockchip,rk3576-dwc3",
> 
> #endif
> 
> > +};
> > +
> 
> 
> 
> >  static int dwc3_probe(struct platform_device *pdev)
> >  {
> >  	struct dwc3_probe_data probe_data = {};
> >  	struct resource *res;
> >  	struct dwc3 *dwc;
> > +	int i;
> > +
> > +	for (i = 0; i < ARRAY_SIZE(dwc3_compatible_blocklist); i++)
> > +		if (device_is_compatible(&pdev->dev, dwc3_compatible_blocklist[i]))
> > +			return -ENODEV;
> >  
> >  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> >  	if (!res) {
> 
> 
> 
> <...>
> 
> 
> 
> > diff --git a/drivers/usb/dwc3/dwc3-rockchip.c b/drivers/usb/dwc3/dwc3-rockchip.c
> > new file mode 100644
> > index 000000000000..62f2a03b08a2
> > --- /dev/null
> > +++ b/drivers/usb/dwc3/dwc3-rockchip.c
> > @@ -0,0 +1,106 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/* Copyright (c) 2026, Collabora Ltd. */
> > +#include <linux/module.h>
> > +#include <linux/platform_device.h>
> > +#include <linux/pm_runtime.h>
> > +#include "glue.h"
> > +
> > +struct dwc3_rockchip {
> > +	struct dwc3		dwc;
> > +};
> > +
> > +static int dwc3_rockchip_probe(struct platform_device *pdev)
> > +{
> > +	struct dwc3_probe_data probe_data = {};
> > +	struct resource *res;
> > +	struct dwc3_rockchip *dwc_rk;
> > +
> > +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > +	if (!res) {
> > +		dev_err(&pdev->dev, "missing memory resource\n");
> > +		return -ENODEV;
> > +	}
> > +
> > +	dwc_rk = devm_kzalloc(&pdev->dev, sizeof(*dwc_rk), GFP_KERNEL);
> > +	if (!dwc_rk)
> > +		return -ENOMEM;
> > +
> > +	dwc_rk->dwc.dev = &pdev->dev;
> > +	dwc_rk->dwc.glue_ops = NULL;
> > +
> > +	probe_data.dwc = &dwc_rk->dwc;
> > +	probe_data.res = res;
> > +	probe_data.properties = DWC3_DEFAULT_PROPERTIES;
> > +
> > +	return dwc3_core_probe(&probe_data);
> > +}
> > +
> > +static void dwc3_rockchip_remove(struct platform_device *pdev)
> > +{
> > +	dwc3_core_remove(platform_get_drvdata(pdev));
> > +}
> > +
> > +static int __maybe_unused dwc3_rockchip_runtime_suspend(struct device *dev)
> 
> Please use the same PM callback pattern as dwc3-generic-plat.c. That
> should avoid the need for __maybe_unused on each callback.

Will do. FWIW this wastes a bunch of memory for !CONFIG_PM by simply
always including the code, even when it's not needed. I suppose
that's fine as disabled CONFIG_PM is uncommon config anyways.

> > +{
> > +	return dwc3_runtime_suspend(dev_get_drvdata(dev));
> > +}
> > +
> > +static int __maybe_unused dwc3_rockchip_runtime_resume(struct device *dev)
> > +{
> > +	return dwc3_runtime_resume(dev_get_drvdata(dev));
> > +}
> > +
> > +static int __maybe_unused dwc3_rockchip_runtime_idle(struct device *dev)
> > +{
> > +	return dwc3_runtime_idle(dev_get_drvdata(dev));
> > +}
> > +
> > +static int __maybe_unused dwc3_rockchip_suspend(struct device *dev)
> > +{
> > +	return dwc3_pm_suspend(dev_get_drvdata(dev));
> > +}
> > +
> > +static int __maybe_unused dwc3_rockchip_resume(struct device *dev)
> > +{
> > +	return dwc3_pm_resume(dev_get_drvdata(dev));
> > +}
> > +
> > +static void __maybe_unused dwc3_rockchip_complete(struct device *dev)
> > +{
> > +	dwc3_pm_complete(dev_get_drvdata(dev));
> > +}
> > +
> > +static int __maybe_unused dwc3_rockchip_prepare(struct device *dev)
> > +{
> > +	return dwc3_pm_prepare(dev_get_drvdata(dev));
> > +}
> > +
> > +static const struct dev_pm_ops dwc3_rockchip_dev_pm_ops = {
> > +	SET_SYSTEM_SLEEP_PM_OPS(dwc3_rockchip_suspend, dwc3_rockchip_resume)
> > +	SET_RUNTIME_PM_OPS(dwc3_rockchip_runtime_suspend, dwc3_rockchip_runtime_resume,
> > +			   dwc3_rockchip_runtime_idle)
> > +	.complete = pm_sleep_ptr(dwc3_rockchip_complete),
> > +	.prepare = pm_sleep_ptr(dwc3_rockchip_prepare),
> > +};
> > +
> > +static const struct of_device_id dwc3_rockchip_of_match[] = {
> > +	{ .compatible = "rockchip,rk3588-dwc3" },
> > +	{ .compatible = "rockchip,rk3576-dwc3" },
> > +	{ }
> > +};
> > +MODULE_DEVICE_TABLE(of, dwc3_rockchip_of_match);
> > +
> > +static struct platform_driver dwc3_rockchip_driver = {
> > +	.probe		= dwc3_rockchip_probe,
> > +	.remove		= dwc3_rockchip_remove,
> > +	.driver		= {
> > +		.name	= "dwc3-rockchip",
> > +		.pm	= pm_ptr(&dwc3_rockchip_dev_pm_ops),
> > +		.of_match_table	= dwc3_rockchip_of_match,
> > +	},
> > +};
> > +
> > +module_platform_driver(dwc3_rockchip_driver);
> > +
> > +MODULE_LICENSE("GPL");
> > +MODULE_DESCRIPTION("DesignWare DWC3 Rockchip Glue Driver");
> > 
> 
> 
> Thanks,
> Thinh

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2026-09-24 15:30 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-15 15:17 [PATCH 0/5] usb: dwc3: introduce Rockchip " Sebastian Reichel
2026-09-15 15:17 ` [PATCH 1/5] phy: core: add notifier infrastructure Sebastian Reichel
2026-09-15 15:17 ` [PATCH 2/5] usb: dwc3: rockchip: introduce glue driver Sebastian Reichel
2026-09-23  1:31   ` Thinh Nguyen
2026-09-24 15:29     ` Sebastian Reichel [this message]
2026-09-23  5:53   ` Krishna Kurapati
2026-09-24 15:36     ` Sebastian Reichel
2026-09-15 15:17 ` [PATCH 3/5] usb: dwc3: core: add post PHY registration hook for platform glue Sebastian Reichel
2026-09-23  1:48   ` Thinh Nguyen
2026-09-23  5:54   ` Krishna Kurapati
2026-09-15 15:17 ` [PATCH 4/5] usb: dwc3: rockchip: support PHY reset notifications Sebastian Reichel
2026-09-23  1:56   ` Thinh Nguyen
2026-09-15 15:17 ` [PATCH 5/5] usb: dwc3: rockchip: fix USB-C reconnect in gadget mode Sebastian Reichel
2026-09-18  9:10   ` Igor Paunovic
2026-09-23  1:58   ` Thinh Nguyen
2026-09-23  8:59     ` Igor Paunovic
2026-09-24  1:47       ` Thinh Nguyen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=arU0_rRUerCfhAs0@venus \
    --to=sebastian.reichel@collabora.com \
    --cc=Thinh.Nguyen@synopsys.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heiko@sntech.de \
    --cc=kernel@collabora.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mani@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=royalnet026@gmail.com \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®