Linux USB
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 4.19 76/87] USB: typec: tcpm: Add a 30ms room for tPSSourceOn in PR_SWAP
From: Sasha Levin @ 2020-12-23  2:20 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Kyle Tso, Guenter Roeck, Heikki Krogerus, Badhri Jagan Sridharan,
	Will McVicker, Greg Kroah-Hartman, Sasha Levin, linux-usb
In-Reply-To: <20201223022103.2792705-1-sashal@kernel.org>

From: Kyle Tso <kyletso@google.com>

[ Upstream commit fe79d5de77204dd946cfad76a9bec23354b1a500 ]

TCPM state machine needs 20-25ms to enter the ErrorRecovery state after
tPSSourceOn timer timeouts. Change the timer from max 480ms to 450ms to
ensure that the timer complies with the Spec. In order to keep the
flexibility for other usecases using tPSSourceOn, add another timer only
for PR_SWAP.

Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: Badhri Jagan Sridharan <badhri@google.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Kyle Tso <kyletso@google.com>
Signed-off-by: Will McVicker <willmcvicker@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/20201210160521.3417426-5-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/usb/typec/tcpm.c | 2 +-
 include/linux/usb/pd.h   | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
index 9c901e3b17472..95e4725eaf3f7 100644
--- a/drivers/usb/typec/tcpm.c
+++ b/drivers/usb/typec/tcpm.c
@@ -3455,7 +3455,7 @@ static void run_state_machine(struct tcpm_port *port)
 			tcpm_set_state(port, ERROR_RECOVERY, 0);
 			break;
 		}
-		tcpm_set_state(port, ERROR_RECOVERY, PD_T_PS_SOURCE_ON);
+		tcpm_set_state(port, ERROR_RECOVERY, PD_T_PS_SOURCE_ON_PRS);
 		break;
 	case PR_SWAP_SRC_SNK_SINK_ON:
 		tcpm_set_state(port, SNK_STARTUP, 0);
diff --git a/include/linux/usb/pd.h b/include/linux/usb/pd.h
index bdf4c88d2aa0a..1a29a7351fbed 100644
--- a/include/linux/usb/pd.h
+++ b/include/linux/usb/pd.h
@@ -441,6 +441,7 @@ static inline unsigned int rdo_max_power(u32 rdo)
 #define PD_T_DRP_SRC		30
 #define PD_T_PS_SOURCE_OFF	920
 #define PD_T_PS_SOURCE_ON	480
+#define PD_T_PS_SOURCE_ON_PRS	450	/* 390 - 480ms */
 #define PD_T_PS_HARD_RESET	30
 #define PD_T_SRC_RECOVER	760
 #define PD_T_SRC_RECOVER_MAX	1000
-- 
2.27.0


^ permalink raw reply related

* [PATCH AUTOSEL 4.19 26/87] media: zr364xx: propagate errors from zr364xx_start_readpipe()
From: Sasha Levin @ 2020-12-23  2:20 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Evgeny Novikov, Hans Verkuil, Mauro Carvalho Chehab, Sasha Levin,
	linux-usb, linux-media
In-Reply-To: <20201223022103.2792705-1-sashal@kernel.org>

From: Evgeny Novikov <novikov@ispras.ru>

[ Upstream commit af0321a5be3e5647441eb6b79355beaa592df97a ]

zr364xx_start_readpipe() can fail but callers do not care about that.
This can result in various negative consequences. The patch adds missed
error handling.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Evgeny Novikov <novikov@ispras.ru>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/media/usb/zr364xx/zr364xx.c | 31 ++++++++++++++++++++++-------
 1 file changed, 24 insertions(+), 7 deletions(-)

diff --git a/drivers/media/usb/zr364xx/zr364xx.c b/drivers/media/usb/zr364xx/zr364xx.c
index 501030bb2e7d0..ff2d07fa1c6a6 100644
--- a/drivers/media/usb/zr364xx/zr364xx.c
+++ b/drivers/media/usb/zr364xx/zr364xx.c
@@ -1349,6 +1349,7 @@ static int zr364xx_board_init(struct zr364xx_camera *cam)
 {
 	struct zr364xx_pipeinfo *pipe = cam->pipe;
 	unsigned long i;
+	int err;
 
 	DBG("board init: %p\n", cam);
 	memset(pipe, 0, sizeof(*pipe));
@@ -1381,9 +1382,8 @@ static int zr364xx_board_init(struct zr364xx_camera *cam)
 
 	if (i == 0) {
 		printk(KERN_INFO KBUILD_MODNAME ": out of memory. Aborting\n");
-		kfree(cam->pipe->transfer_buffer);
-		cam->pipe->transfer_buffer = NULL;
-		return -ENOMEM;
+		err = -ENOMEM;
+		goto err_free;
 	} else
 		cam->buffer.dwFrames = i;
 
@@ -1398,9 +1398,17 @@ static int zr364xx_board_init(struct zr364xx_camera *cam)
 	/*** end create system buffers ***/
 
 	/* start read pipe */
-	zr364xx_start_readpipe(cam);
+	err = zr364xx_start_readpipe(cam);
+	if (err)
+		goto err_free;
+
 	DBG(": board initialized\n");
 	return 0;
+
+err_free:
+	kfree(cam->pipe->transfer_buffer);
+	cam->pipe->transfer_buffer = NULL;
+	return err;
 }
 
 static int zr364xx_probe(struct usb_interface *intf,
@@ -1597,10 +1605,19 @@ static int zr364xx_resume(struct usb_interface *intf)
 	if (!cam->was_streaming)
 		return 0;
 
-	zr364xx_start_readpipe(cam);
+	res = zr364xx_start_readpipe(cam);
+	if (res)
+		return res;
+
 	res = zr364xx_prepare(cam);
-	if (!res)
-		zr364xx_start_acquire(cam);
+	if (res)
+		goto err_prepare;
+
+	zr364xx_start_acquire(cam);
+	return 0;
+
+err_prepare:
+	zr364xx_stop_readpipe(cam);
 	return res;
 }
 #endif
-- 
2.27.0


^ permalink raw reply related

* Re: [RESEND] usb: dwc3: meson-g12a: disable clk on error handling path in probe
From: Zheng Zengkai @ 2020-12-23  2:13 UTC (permalink / raw)
  To: balbi, gregkh, khilman, narmstrong, jbrunet, martin.blumenstingl
  Cc: linux-usb, linux-arm-kernel, linux-amlogic, linux-kernel
In-Reply-To: <20201215025459.91794-1-zhengzengkai@huawei.com>

Hi everyone,

Friendly ping:

Just want to know why this patch was ignored,

Am I missing something?

Merry Christmas and Happy New Year!

> dwc3_meson_g12a_probe() does not invoke clk_bulk_disable_unprepare()
> on one error handling path. This patch fixes that.
>
> Fixes: 347052e3bf1b ("usb: dwc3: meson-g12a: fix USB2 PHY initialization on G12A and A1 SoCs")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Zheng Zengkai <zhengzengkai@huawei.com>
> Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> ---
>   drivers/usb/dwc3/dwc3-meson-g12a.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/dwc3/dwc3-meson-g12a.c b/drivers/usb/dwc3/dwc3-meson-g12a.c
> index 417e05381b5d..bdf1f98dfad8 100644
> --- a/drivers/usb/dwc3/dwc3-meson-g12a.c
> +++ b/drivers/usb/dwc3/dwc3-meson-g12a.c
> @@ -754,7 +754,7 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
>   
>   	ret = priv->drvdata->setup_regmaps(priv, base);
>   	if (ret)
> -		return ret;
> +		goto err_disable_clks;
>   
>   	if (priv->vbus) {
>   		ret = regulator_enable(priv->vbus);

^ permalink raw reply

* [PATCH] thunderbolt: Use kmemdup instead of kzmalloc and memcpy
From: Tian Tao @ 2020-12-23  1:26 UTC (permalink / raw)
  To: isaac.hazan, andreas.noever, michael.jamet, mika.westerberg,
	YehezkelShB
  Cc: linux-usb

Fixes coccicheck warning:
drivers/thunderbolt/dma_test.c:302:13-20: WARNING opportunity for kmemdup.

Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
---
 drivers/thunderbolt/dma_test.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/thunderbolt/dma_test.c b/drivers/thunderbolt/dma_test.c
index f924423..955f980 100644
--- a/drivers/thunderbolt/dma_test.c
+++ b/drivers/thunderbolt/dma_test.c
@@ -299,14 +299,12 @@ static int dma_test_submit_tx(struct dma_test *dt, size_t npackets)
 		tf->frame.size = 0; /* means 4096 */
 		tf->dma_test = dt;
 
-		tf->data = kzalloc(DMA_TEST_FRAME_SIZE, GFP_KERNEL);
+		tf->data = kmemdup(dma_test_pattern, DMA_TEST_FRAME_SIZE, GFP_KERNEL);
 		if (!tf->data) {
 			kfree(tf);
 			return -ENOMEM;
 		}
 
-		memcpy(tf->data, dma_test_pattern, DMA_TEST_FRAME_SIZE);
-
 		dma_addr = dma_map_single(dma_dev, tf->data, DMA_TEST_FRAME_SIZE,
 					  DMA_TO_DEVICE);
 		if (dma_mapping_error(dma_dev, dma_addr)) {
-- 
2.7.4


^ permalink raw reply related

* Re: [PATCH] usb: host: xhci-plat: fix support for XHCI_SKIP_PHY_INIT quirk
From: Pali Rohár @ 2020-12-23  1:04 UTC (permalink / raw)
  To: Peter Chen
  Cc: Mathias Nyman, Greg Kroah-Hartman, Jun Li,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
In-Reply-To: <20201223010214.GA18398@b29397-desktop>

On Wednesday 23 December 2020 01:02:43 Peter Chen wrote:
> On 20-12-22 14:30:51, Pali Rohár wrote:
> > On Tuesday 22 December 2020 10:23:27 Pali Rohár wrote:
> > > On Tuesday 22 December 2020 02:14:45 Peter Chen wrote:
> > > > On 20-12-21 16:09:03, Pali Rohár wrote:
> > > > > Currently init_quirk callbacks for xhci platform drivers are called
> > > > > xhci_plat_setup() function which is called after chip reset completes.
> > > > > It happens in the middle of the usb_add_hcd() function.
> > > > > 
> > > > > But XHCI_SKIP_PHY_INIT quirk is checked in the xhci_plat_probe() function
> > > > > prior calling usb_add_hcd() function. Therefore this XHCI_SKIP_PHY_INIT
> > > > > currently does nothing as prior xhci_plat_setup() it is not set.
> > > > > 
> > > > > Quirk XHCI_SKIP_PHY_INIT is only setting hcd->skip_phy_initialization value
> > > > > which really needs to be set prior calling usb_add_hcd() as this function
> > > > > at its beginning skips PHY init if this member is set.
> > > > > 
> > > > > This patch fixes implementation of the XHCI_SKIP_PHY_INIT quirk by calling
> > > > > init_quirk callbacks (via xhci_priv_init_quirk()) prior checking if
> > > > > XHCI_SKIP_PHY_INIT is set.
> > > > > 
> > > > > Fixes: f768e718911e0 ("usb: host: xhci-plat: add priv quirk for skip PHY initialization")
> > > > > Signed-off-by: Pali Rohár <pali@kernel.org>
> 
> Hi Pali,
> 
> I know your case, you need to choose XHCI_SKIP_PHY_INIT quirk
> conditionally, but you may can't add Fixes tag at your patch
> since your issue was existed before my patch.

Ok, no problem, in V2 I will not add it.

> Peter
> 
> 
> > > > > ---
> > > > >  drivers/usb/host/xhci-plat.c | 14 +++++++-------
> > > > >  1 file changed, 7 insertions(+), 7 deletions(-)
> > > > > 
> > > > > diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> > > > > index 4d34f6005381..58704c5b002b 100644
> > > > > --- a/drivers/usb/host/xhci-plat.c
> > > > > +++ b/drivers/usb/host/xhci-plat.c
> > > > > @@ -89,13 +89,6 @@ static void xhci_plat_quirks(struct device *dev, struct xhci_hcd *xhci)
> > > > >  /* called during probe() after chip reset completes */
> > > > >  static int xhci_plat_setup(struct usb_hcd *hcd)
> > > > >  {
> > > > > -	int ret;
> > > > > -
> > > > > -
> > > > > -	ret = xhci_priv_init_quirk(hcd);
> > > > > -	if (ret)
> > > > > -		return ret;
> > > > > -
> > > > >  	return xhci_gen_setup(hcd, xhci_plat_quirks);
> > > > >  }
> > > > >  
> > > > > @@ -330,6 +323,13 @@ static int xhci_plat_probe(struct platform_device *pdev)
> > > > >  
> > > > >  	hcd->tpl_support = of_usb_host_tpl_support(sysdev->of_node);
> > > > >  	xhci->shared_hcd->tpl_support = hcd->tpl_support;
> > > > > +
> > > > > +	if (priv) {
> > > > > +		ret = xhci_priv_init_quirk(hcd);
> > > > > +		if (ret)
> > > > > +			goto disable_usb_phy;
> > > > > +	}
> > > > > +
> > > > >  	if (priv && (priv->quirks & XHCI_SKIP_PHY_INIT))
> > > > >  		hcd->skip_phy_initialization = 1;
> > > > >  
> > > > 
> > > > Hi Pali,
> > > > 
> > > > What's problem you have met? In structure xhci_plat_priv, the quirks are
> > > > defined at .quirks entry which is got at below code. .init_quirk is the
> > > > routine if special initializations are needed.
> > > 
> > > Hello!
> > > 
> > > I'm talking about .init_quirk. And if XHCI_SKIP_PHY_INIT quirk is set in
> > > this function then has no effect.
> > 
> > Ok, this patch is not enough, I will send V2.
> > 
> > > I'm working currently on patch for xhci mvebu which conditionally enable
> > > or disable XHCI_SKIP_PHY_INIT quirk (it is going to fix existing
> > > regression since v5.1 kernel) and without this patch XHCI_SKIP_PHY_INIT
> > > quirk from the init_quirk does not work.
> > 
> > And now I have tested V2 with my mvebu regression fix. I will send it to
> > mailing list for review.
> > 
> > > > 	if (pdev->dev.of_node)
> > > > 		priv_match = of_device_get_match_data(&pdev->dev);
> > > > 	else
> > > > 		priv_match = dev_get_platdata(&pdev->dev);
> > > > 
> > > > 	if (priv_match) {
> > > > 		priv = hcd_to_xhci_priv(hcd);
> > > > 		/* Just copy data for now */
> > > > 		*priv = *priv_match;
> > > > 	}
> > > > -- 
> > > > 
> > > > Thanks,
> > > > Peter Chen
> 
> -- 
> 
> Thanks,
> Peter Chen

^ permalink raw reply

* Re: [PATCH] usb: host: xhci-plat: fix support for XHCI_SKIP_PHY_INIT quirk
From: Peter Chen @ 2020-12-23  1:02 UTC (permalink / raw)
  To: Pali Rohár
  Cc: Mathias Nyman, Greg Kroah-Hartman, Jun Li,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
In-Reply-To: <20201222133051.jfvrgkcdhjnldz3z@pali>

On 20-12-22 14:30:51, Pali Rohár wrote:
> On Tuesday 22 December 2020 10:23:27 Pali Rohár wrote:
> > On Tuesday 22 December 2020 02:14:45 Peter Chen wrote:
> > > On 20-12-21 16:09:03, Pali Rohár wrote:
> > > > Currently init_quirk callbacks for xhci platform drivers are called
> > > > xhci_plat_setup() function which is called after chip reset completes.
> > > > It happens in the middle of the usb_add_hcd() function.
> > > > 
> > > > But XHCI_SKIP_PHY_INIT quirk is checked in the xhci_plat_probe() function
> > > > prior calling usb_add_hcd() function. Therefore this XHCI_SKIP_PHY_INIT
> > > > currently does nothing as prior xhci_plat_setup() it is not set.
> > > > 
> > > > Quirk XHCI_SKIP_PHY_INIT is only setting hcd->skip_phy_initialization value
> > > > which really needs to be set prior calling usb_add_hcd() as this function
> > > > at its beginning skips PHY init if this member is set.
> > > > 
> > > > This patch fixes implementation of the XHCI_SKIP_PHY_INIT quirk by calling
> > > > init_quirk callbacks (via xhci_priv_init_quirk()) prior checking if
> > > > XHCI_SKIP_PHY_INIT is set.
> > > > 
> > > > Fixes: f768e718911e0 ("usb: host: xhci-plat: add priv quirk for skip PHY initialization")
> > > > Signed-off-by: Pali Rohár <pali@kernel.org>

Hi Pali,

I know your case, you need to choose XHCI_SKIP_PHY_INIT quirk
conditionally, but you may can't add Fixes tag at your patch
since your issue was existed before my patch.

Peter


> > > > ---
> > > >  drivers/usb/host/xhci-plat.c | 14 +++++++-------
> > > >  1 file changed, 7 insertions(+), 7 deletions(-)
> > > > 
> > > > diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> > > > index 4d34f6005381..58704c5b002b 100644
> > > > --- a/drivers/usb/host/xhci-plat.c
> > > > +++ b/drivers/usb/host/xhci-plat.c
> > > > @@ -89,13 +89,6 @@ static void xhci_plat_quirks(struct device *dev, struct xhci_hcd *xhci)
> > > >  /* called during probe() after chip reset completes */
> > > >  static int xhci_plat_setup(struct usb_hcd *hcd)
> > > >  {
> > > > -	int ret;
> > > > -
> > > > -
> > > > -	ret = xhci_priv_init_quirk(hcd);
> > > > -	if (ret)
> > > > -		return ret;
> > > > -
> > > >  	return xhci_gen_setup(hcd, xhci_plat_quirks);
> > > >  }
> > > >  
> > > > @@ -330,6 +323,13 @@ static int xhci_plat_probe(struct platform_device *pdev)
> > > >  
> > > >  	hcd->tpl_support = of_usb_host_tpl_support(sysdev->of_node);
> > > >  	xhci->shared_hcd->tpl_support = hcd->tpl_support;
> > > > +
> > > > +	if (priv) {
> > > > +		ret = xhci_priv_init_quirk(hcd);
> > > > +		if (ret)
> > > > +			goto disable_usb_phy;
> > > > +	}
> > > > +
> > > >  	if (priv && (priv->quirks & XHCI_SKIP_PHY_INIT))
> > > >  		hcd->skip_phy_initialization = 1;
> > > >  
> > > 
> > > Hi Pali,
> > > 
> > > What's problem you have met? In structure xhci_plat_priv, the quirks are
> > > defined at .quirks entry which is got at below code. .init_quirk is the
> > > routine if special initializations are needed.
> > 
> > Hello!
> > 
> > I'm talking about .init_quirk. And if XHCI_SKIP_PHY_INIT quirk is set in
> > this function then has no effect.
> 
> Ok, this patch is not enough, I will send V2.
> 
> > I'm working currently on patch for xhci mvebu which conditionally enable
> > or disable XHCI_SKIP_PHY_INIT quirk (it is going to fix existing
> > regression since v5.1 kernel) and without this patch XHCI_SKIP_PHY_INIT
> > quirk from the init_quirk does not work.
> 
> And now I have tested V2 with my mvebu regression fix. I will send it to
> mailing list for review.
> 
> > > 	if (pdev->dev.of_node)
> > > 		priv_match = of_device_get_match_data(&pdev->dev);
> > > 	else
> > > 		priv_match = dev_get_platdata(&pdev->dev);
> > > 
> > > 	if (priv_match) {
> > > 		priv = hcd_to_xhci_priv(hcd);
> > > 		/* Just copy data for now */
> > > 		*priv = *priv_match;
> > > 	}
> > > -- 
> > > 
> > > Thanks,
> > > Peter Chen

-- 

Thanks,
Peter Chen

^ permalink raw reply

* Re: [PATCH] dt-bindings: Drop redundant maxItems/items
From: Mark Brown @ 2020-12-22 17:12 UTC (permalink / raw)
  To: Rob Herring
  Cc: devicetree, linux-kernel, Laurent Pinchart, Vinod Koul,
	Greg Kroah-Hartman, Jassi Brar, dri-devel, dmaengine, alsa-devel,
	linux-usb
In-Reply-To: <20201222040645.1323611-1-robh@kernel.org>

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

On Mon, Dec 21, 2020 at 09:06:45PM -0700, Rob Herring wrote:
> 'maxItems' equal to the 'items' list length is redundant. 'maxItems' is
> preferred for a single entry while greater than 1 should have an 'items'
> list.

Acked-by: Mark Brown <broonie@kernel.org>

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

^ permalink raw reply

* Re: [PATCH] dt-bindings: Drop redundant maxItems/items
From: Jassi Brar @ 2020-12-22 16:39 UTC (permalink / raw)
  To: Rob Herring
  Cc: Devicetree List, Linux Kernel Mailing List, Laurent Pinchart,
	Vinod Koul, Mark Brown, Greg Kroah-Hartman, Jassi Brar, dri-devel,
	dmaengine, alsa-devel, linux-usb
In-Reply-To: <20201222040645.1323611-1-robh@kernel.org>

On Mon, Dec 21, 2020 at 10:10 PM Rob Herring <robh@kernel.org> wrote:
>
> 'maxItems' equal to the 'items' list length is redundant. 'maxItems' is
> preferred for a single entry while greater than 1 should have an 'items'
> list.
>
> A meta-schema check for this is pending once these existing cases are
> fixed.
>
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: Vinod Koul <vkoul@kernel.org>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Jassi Brar <jaswinder.singh@linaro.org>
> Cc: dri-devel@lists.freedesktop.org
> Cc: dmaengine@vger.kernel.org
> Cc: alsa-devel@alsa-project.org
> Cc: linux-usb@vger.kernel.org
> Signed-off-by: Rob Herring <robh@kernel.org>
> ---
>  .../devicetree/bindings/display/xlnx/xlnx,zynqmp-dpsub.yaml    | 1 -
>  Documentation/devicetree/bindings/dma/renesas,rcar-dmac.yaml   | 1 -
>  Documentation/devicetree/bindings/mailbox/arm,mhu.yaml         | 1 -
>  .../devicetree/bindings/sound/nvidia,tegra30-hda.yaml          | 2 --
>  Documentation/devicetree/bindings/usb/renesas,usb-xhci.yaml    | 1 -
>  Documentation/devicetree/bindings/usb/renesas,usbhs.yaml       | 3 ---
>  6 files changed, 9 deletions(-)

Acked-by: Jassi Brar <jassisinghbrar@gmail.com>

^ permalink raw reply

* Re: [PATCH] dt-bindings: Drop redundant maxItems/items
From: Vinod Koul @ 2020-12-22 16:27 UTC (permalink / raw)
  To: Rob Herring
  Cc: devicetree, linux-kernel, Laurent Pinchart, Mark Brown,
	Greg Kroah-Hartman, Jassi Brar, dri-devel, dmaengine, alsa-devel,
	linux-usb
In-Reply-To: <20201222040645.1323611-1-robh@kernel.org>

On 21-12-20, 21:06, Rob Herring wrote:
> 'maxItems' equal to the 'items' list length is redundant. 'maxItems' is
> preferred for a single entry while greater than 1 should have an 'items'
> list.
> 
> A meta-schema check for this is pending once these existing cases are
> fixed.

> ---
>  .../devicetree/bindings/display/xlnx/xlnx,zynqmp-dpsub.yaml    | 1 -
>  Documentation/devicetree/bindings/dma/renesas,rcar-dmac.yaml   | 1 -

Acked-By: Vinod Koul <vkoul@kernel.org>

-- 
~Vinod

^ permalink raw reply

* Re: [PATCH] usb: host: xhci-plat: fix support for XHCI_SKIP_PHY_INIT quirk
From: Pali Rohár @ 2020-12-22 13:30 UTC (permalink / raw)
  To: Peter Chen
  Cc: Mathias Nyman, Greg Kroah-Hartman, Jun Li,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
In-Reply-To: <20201222092327.jq5b7g4bffeccq3o@pali>

On Tuesday 22 December 2020 10:23:27 Pali Rohár wrote:
> On Tuesday 22 December 2020 02:14:45 Peter Chen wrote:
> > On 20-12-21 16:09:03, Pali Rohár wrote:
> > > Currently init_quirk callbacks for xhci platform drivers are called
> > > xhci_plat_setup() function which is called after chip reset completes.
> > > It happens in the middle of the usb_add_hcd() function.
> > > 
> > > But XHCI_SKIP_PHY_INIT quirk is checked in the xhci_plat_probe() function
> > > prior calling usb_add_hcd() function. Therefore this XHCI_SKIP_PHY_INIT
> > > currently does nothing as prior xhci_plat_setup() it is not set.
> > > 
> > > Quirk XHCI_SKIP_PHY_INIT is only setting hcd->skip_phy_initialization value
> > > which really needs to be set prior calling usb_add_hcd() as this function
> > > at its beginning skips PHY init if this member is set.
> > > 
> > > This patch fixes implementation of the XHCI_SKIP_PHY_INIT quirk by calling
> > > init_quirk callbacks (via xhci_priv_init_quirk()) prior checking if
> > > XHCI_SKIP_PHY_INIT is set.
> > > 
> > > Fixes: f768e718911e0 ("usb: host: xhci-plat: add priv quirk for skip PHY initialization")
> > > Signed-off-by: Pali Rohár <pali@kernel.org>
> > > ---
> > >  drivers/usb/host/xhci-plat.c | 14 +++++++-------
> > >  1 file changed, 7 insertions(+), 7 deletions(-)
> > > 
> > > diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> > > index 4d34f6005381..58704c5b002b 100644
> > > --- a/drivers/usb/host/xhci-plat.c
> > > +++ b/drivers/usb/host/xhci-plat.c
> > > @@ -89,13 +89,6 @@ static void xhci_plat_quirks(struct device *dev, struct xhci_hcd *xhci)
> > >  /* called during probe() after chip reset completes */
> > >  static int xhci_plat_setup(struct usb_hcd *hcd)
> > >  {
> > > -	int ret;
> > > -
> > > -
> > > -	ret = xhci_priv_init_quirk(hcd);
> > > -	if (ret)
> > > -		return ret;
> > > -
> > >  	return xhci_gen_setup(hcd, xhci_plat_quirks);
> > >  }
> > >  
> > > @@ -330,6 +323,13 @@ static int xhci_plat_probe(struct platform_device *pdev)
> > >  
> > >  	hcd->tpl_support = of_usb_host_tpl_support(sysdev->of_node);
> > >  	xhci->shared_hcd->tpl_support = hcd->tpl_support;
> > > +
> > > +	if (priv) {
> > > +		ret = xhci_priv_init_quirk(hcd);
> > > +		if (ret)
> > > +			goto disable_usb_phy;
> > > +	}
> > > +
> > >  	if (priv && (priv->quirks & XHCI_SKIP_PHY_INIT))
> > >  		hcd->skip_phy_initialization = 1;
> > >  
> > 
> > Hi Pali,
> > 
> > What's problem you have met? In structure xhci_plat_priv, the quirks are
> > defined at .quirks entry which is got at below code. .init_quirk is the
> > routine if special initializations are needed.
> 
> Hello!
> 
> I'm talking about .init_quirk. And if XHCI_SKIP_PHY_INIT quirk is set in
> this function then has no effect.

Ok, this patch is not enough, I will send V2.

> I'm working currently on patch for xhci mvebu which conditionally enable
> or disable XHCI_SKIP_PHY_INIT quirk (it is going to fix existing
> regression since v5.1 kernel) and without this patch XHCI_SKIP_PHY_INIT
> quirk from the init_quirk does not work.

And now I have tested V2 with my mvebu regression fix. I will send it to
mailing list for review.

> > 	if (pdev->dev.of_node)
> > 		priv_match = of_device_get_match_data(&pdev->dev);
> > 	else
> > 		priv_match = dev_get_platdata(&pdev->dev);
> > 
> > 	if (priv_match) {
> > 		priv = hcd_to_xhci_priv(hcd);
> > 		/* Just copy data for now */
> > 		*priv = *priv_match;
> > 	}
> > -- 
> > 
> > Thanks,
> > Peter Chen

^ permalink raw reply

* USB Gadget via ConfigFS; define custom String Descriptors
From: Ingo Rohloff @ 2020-12-22 11:13 UTC (permalink / raw)
  To: linux-usb

Hello,

before trying to implement something I would like to get some opinions
if what I am thinking of seems to be useful, or if I am on the wrong
track.

I am implementing a USB Gadget.
To configure the gadget I use ConfigFS.
Now what I would like to do is to configure some device specific
string descriptors, which have a fixed, custom index.


Now I know that if you for example create a gadget in configFS
at directory
  usb_gadget/g1

you will get the following standard device string descriptors:
  usb_gadget/g1/strings/0x409
    manufacturer
    product
    serialnumber

You might set the content of these string descriptors by writing to
these files.
The indexes of these string descriptors gets auto-assigned as far as I
understand the Linux source code.
These indexes are then put into the USB device descriptor, which is how
a USB host finds out which indexes to use.


What I now want to do is to define additional string descriptors, with
some fixed, custom indexes.

Questions:

* Is this simply not intended by the USB spec ?

* Is there already a way to do that via ConfigFS,
  which I am not aware of ?

* Does a mechanism to define such custom string descriptors sound
  useful ? So is it worth the effort to implement it ?


Just a super simple proposal how to do that; since I have no experience
what's best for ConfigFS, please advise if you think there is a better
way!
If a user creates a file
   usb_gadget/g1/strings/0x0409/
      custom_34

Then this will be accessible as USB device string descriptor,
with index 0x34. So the two characters after the "_" are interpreted as
two hex digits, which define the index.

Does this sound like a viable strategy to allow custom string
descriptors ?


Ingo

^ permalink raw reply

* Re: [PATCH] usb: musb: add printf attribute to log function
From: Joe Perches @ 2020-12-22  9:52 UTC (permalink / raw)
  To: Greg KH, trix; +Cc: b-liu, linux-usb, linux-kernel
In-Reply-To: <X+Gzvo3vPBFGKAy+@kroah.com>

On Tue, 2020-12-22 at 09:52 +0100, Greg KH wrote:
> On Mon, Dec 21, 2020 at 08:25:47AM -0800, trix@redhat.com wrote:
> > From: Tom Rix <trix@redhat.com>
> > 
> > Attributing the function allows the compiler to more thoroughly
> > check the use of the function with -Wformat and similar flags.
> > 
> > Signed-off-by: Tom Rix <trix@redhat.com>
> > ---
> >  drivers/usb/musb/musb_debug.h | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/drivers/usb/musb/musb_debug.h b/drivers/usb/musb/musb_debug.h
> > index e5b3506c7b3f..dfc0d02695fa 100644
> > --- a/drivers/usb/musb/musb_debug.h
> > +++ b/drivers/usb/musb/musb_debug.h
> > @@ -17,6 +17,7 @@
> >  #define INFO(fmt, args...) yprintk(KERN_INFO, fmt, ## args)
> >  #define ERR(fmt, args...) yprintk(KERN_ERR, fmt, ## args)
> >  
> > 
> > +__printf(2, 3)
> >  void musb_dbg(struct musb *musb, const char *fmt, ...);
> 
> While I understand the need for this, did this find any problems?
> If not, then it's not worth adding,

I have to disagree with that Greg.  While the driver isn't in active
development, a trivial mod to make it less likely a defect is introduced
by any additional code is still a useful addition.

> the driver-specific debugging macros
> should be removed entirely and just use dev_dbg() and friends instead.

Read the suggested change I posted in reply.

btw: the musb_dbg function is actually a trace function and not a
dmesg/logging mechanism.

drivers/usb/musb/musb_trace.c:void musb_dbg(struct musb *musb, const char *fmt, ...)
drivers/usb/musb/musb_trace.c-{
drivers/usb/musb/musb_trace.c-  struct va_format vaf;
drivers/usb/musb/musb_trace.c-  va_list args;
drivers/usb/musb/musb_trace.c-
drivers/usb/musb/musb_trace.c-  va_start(args, fmt);
drivers/usb/musb/musb_trace.c-  vaf.fmt = fmt;
drivers/usb/musb/musb_trace.c-  vaf.va = &args;
drivers/usb/musb/musb_trace.c-
drivers/usb/musb/musb_trace.c-  trace_musb_log(musb, &vaf);
drivers/usb/musb/musb_trace.c-
drivers/usb/musb/musb_trace.c-  va_end(args);
drivers/usb/musb/musb_trace.c-}

drivers/usb/musb/musb_trace.h:TRACE_EVENT(musb_log,
drivers/usb/musb/musb_trace.h-  TP_PROTO(struct musb *musb, struct va_format *vaf),
drivers/usb/musb/musb_trace.h-  TP_ARGS(musb, vaf),
drivers/usb/musb/musb_trace.h-  TP_STRUCT__entry(
drivers/usb/musb/musb_trace.h-          __string(name, dev_name(musb->controller))
drivers/usb/musb/musb_trace.h-          __dynamic_array(char, msg, MUSB_MSG_MAX)
drivers/usb/musb/musb_trace.h-  ),
drivers/usb/musb/musb_trace.h-  TP_fast_assign(
drivers/usb/musb/musb_trace.h-          __assign_str(name, dev_name(musb->controller));
drivers/usb/musb/musb_trace.h-          vsnprintf(__get_str(msg), MUSB_MSG_MAX, vaf->fmt, *vaf->va);
drivers/usb/musb/musb_trace.h-  ),
drivers/usb/musb/musb_trace.h-  TP_printk("%s: %s", __get_str(name), __get_str(msg))
drivers/usb/musb/musb_trace.h-);

Is that trace mechanism useful though?  I think it's somewhat odd.


^ permalink raw reply

* [RFC PATCH v3 1/5] usb: xhci-mtk: improve bandwidth scheduling with multi-TT
From: Chunfeng Yun @ 2020-12-22  9:34 UTC (permalink / raw)
  To: Ikjoon Jang
  Cc: Chunfeng Yun, Tianping Fang, Zhanyong Wang, linux-mediatek,
	linux-usb, linux-kernel, Zhanyong Wang, Yaqii Wu

From: Zhanyong Wang <zhanyong.wang@mediatek.com>

After inserted the usb type-c 3.5mm dongle with headset, dmesg showed:
usb 1-1.1: new full-speed USB device number 5 using xhci-mtk
usb 1-1.1: New USB device found, idVendor=05ac, idProduct=110a, bcdDevice=26.11
usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1.1: Product: USB-C to 3.5mm Headphone Jack Adapter
usb 1-1.1: Manufacturer: Apple, Inc.
usb 1-1.1: SerialNumber: DWH915501TFJKLTAM
xhci-mtk 11200000.xhci: Not enough bandwidth!
usb 1-1.1: can't set config #2, error -28

improve low-speed/full-speed INT/ISOC bandwidth scheduling with USB
muli-TT.

Signed-off-by: Yaqii Wu <yaqii.wu@mediatek.com>
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
v2~v3: no changes
---
 drivers/usb/host/xhci-mtk-sch.c | 91 ++++++++++++++++++++++++++++-----
 drivers/usb/host/xhci-mtk.h     |  8 ++-
 2 files changed, 84 insertions(+), 15 deletions(-)
 mode change 100644 => 100755 drivers/usb/host/xhci-mtk-sch.c

diff --git a/drivers/usb/host/xhci-mtk-sch.c b/drivers/usb/host/xhci-mtk-sch.c
old mode 100644
new mode 100755
index 45c54d56ecbd..94292b9bbc63
--- a/drivers/usb/host/xhci-mtk-sch.c
+++ b/drivers/usb/host/xhci-mtk-sch.c
@@ -383,7 +383,9 @@ static int check_sch_tt(struct usb_device *udev,
 	u32 fs_budget_start;
 	u32 start_ss, last_ss;
 	u32 start_cs, last_cs;
-	int i;
+	u32 num_esit, base;
+	int i, j;
+	u32 tmp;
 
 	start_ss = offset % 8;
 	fs_budget_start = (start_ss + 1) % 8;
@@ -398,10 +400,13 @@ static int check_sch_tt(struct usb_device *udev,
 		if (!(start_ss == 7 || last_ss < 6))
 			return -ERANGE;
 
-		for (i = 0; i < sch_ep->cs_count; i++)
-			if (test_bit(offset + i, tt->split_bit_map))
+		for (i = 0; i < sch_ep->cs_count; i++) {
+			if (test_bit(offset + i, tt->ss_bit_map))
 				return -ERANGE;
 
+			if (test_bit(offset + i, tt->cs_bit_map))
+				return -ERANGE;
+		}
 	} else {
 		u32 cs_count = DIV_ROUND_UP(sch_ep->maxpkt, FS_PAYLOAD_MAX);
 
@@ -428,8 +433,10 @@ static int check_sch_tt(struct usb_device *udev,
 		if (cs_count > 7)
 			cs_count = 7; /* HW limit */
 
-		for (i = 0; i < cs_count + 2; i++) {
-			if (test_bit(offset + i, tt->split_bit_map))
+		if (test_bit(offset, tt->ss_bit_map))
+			return -ERANGE;
+		for (i = 0; i < cs_count; i++) {
+			if (test_bit(offset + 2 + i, tt->cs_bit_map))
 				return -ERANGE;
 		}
 
@@ -445,11 +452,22 @@ static int check_sch_tt(struct usb_device *udev,
 			sch_ep->num_budget_microframes = sch_ep->esit;
 	}
 
+	num_esit = XHCI_MTK_MAX_ESIT / sch_ep->esit;
+	for (i = 0; i < num_esit; i++) {
+		base = sch_ep->offset + i * sch_ep->esit;
+		for (j = 0; j < sch_ep->num_budget_microframes; j++) {
+			tmp = tt->fs_bus_bw[base + j]
+			      + sch_ep->bw_cost_per_microframe;
+			if (tmp > FS_PAYLOAD_MAX)
+				return -ERANGE;
+		}
+	}
+
 	return 0;
 }
 
 static void update_sch_tt(struct usb_device *udev,
-	struct mu3h_sch_ep_info *sch_ep)
+	struct mu3h_sch_ep_info *sch_ep, bool used)
 {
 	struct mu3h_sch_tt *tt = sch_ep->sch_tt;
 	u32 base, num_esit;
@@ -458,11 +476,52 @@ static void update_sch_tt(struct usb_device *udev,
 	num_esit = XHCI_MTK_MAX_ESIT / sch_ep->esit;
 	for (i = 0; i < num_esit; i++) {
 		base = sch_ep->offset + i * sch_ep->esit;
-		for (j = 0; j < sch_ep->num_budget_microframes; j++)
-			set_bit(base + j, tt->split_bit_map);
+		for (j = 0; j < sch_ep->num_budget_microframes; j++) {
+			if (used)
+				set_bit(base + j, tt->split_bit_map);
+			else
+				clear_bit(base + j, tt->split_bit_map);
+		}
+
+		if (sch_ep->ep_type == ISOC_OUT_EP) {
+			for (j = 0; j < sch_ep->num_budget_microframes; j++) {
+				if (used) {
+					set_bit(base + j, tt->ss_bit_map);
+					set_bit(base + j, tt->cs_bit_map);
+					tt->fs_bus_bw[base + j] +=
+						sch_ep->bw_cost_per_microframe;
+				} else {
+					clear_bit(base + j, tt->ss_bit_map);
+					clear_bit(base + j, tt->cs_bit_map);
+					tt->fs_bus_bw[base + j] -=
+						sch_ep->bw_cost_per_microframe;
+				}
+			}
+		} else {
+			if (used)
+				set_bit(base, tt->ss_bit_map);
+			else
+				clear_bit(base, tt->ss_bit_map);
+
+			for (j = 0; j < sch_ep->cs_count; j++) {
+				if (used) {
+					set_bit(base + 2 + j, tt->cs_bit_map);
+
+					tt->fs_bus_bw[base + 2 + j] +=
+						sch_ep->bw_cost_per_microframe;
+				} else {
+					clear_bit(base + 2 + j, tt->cs_bit_map);
+					tt->fs_bus_bw[base + 2 + j] -=
+						sch_ep->bw_cost_per_microframe;
+				}
+			}
+		}
 	}
 
-	list_add_tail(&sch_ep->tt_endpoint, &tt->ep_list);
+	if (used)
+		list_add_tail(&sch_ep->tt_endpoint, &tt->ep_list);
+	else
+		list_del(&sch_ep->tt_endpoint);
 }
 
 static int check_sch_bw(struct usb_device *udev,
@@ -470,6 +529,7 @@ static int check_sch_bw(struct usb_device *udev,
 {
 	u32 offset;
 	u32 esit;
+	u32 boundary;
 	u32 min_bw;
 	u32 min_index;
 	u32 worst_bw;
@@ -487,10 +547,13 @@ static int check_sch_bw(struct usb_device *udev,
 	 */
 	min_bw = ~0;
 	min_index = 0;
+	boundary = esit;
 	min_cs_count = sch_ep->cs_count;
 	min_num_budget = sch_ep->num_budget_microframes;
 	for (offset = 0; offset < esit; offset++) {
 		if (is_fs_or_ls(udev->speed)) {
+			if (sch_ep->ep_type != ISOC_OUT_EP)
+				boundary = esit + 1;
 			ret = check_sch_tt(udev, sch_ep, offset);
 			if (ret)
 				continue;
@@ -498,7 +561,7 @@ static int check_sch_bw(struct usb_device *udev,
 				tt_offset_ok = true;
 		}
 
-		if ((offset + sch_ep->num_budget_microframes) > sch_ep->esit)
+		if ((offset + sch_ep->num_budget_microframes) > boundary)
 			break;
 
 		worst_bw = get_max_bw(sch_bw, sch_ep, offset);
@@ -532,7 +595,7 @@ static int check_sch_bw(struct usb_device *udev,
 		if (!tt_offset_ok)
 			return -ERANGE;
 
-		update_sch_tt(udev, sch_ep);
+		update_sch_tt(udev, sch_ep, 1);
 	}
 
 	/* update bus bandwidth info */
@@ -696,12 +759,12 @@ void xhci_mtk_drop_ep_quirk(struct usb_hcd *hcd, struct usb_device *udev,
 
 	list_for_each_entry(sch_ep, &sch_bw->bw_ep_list, endpoint) {
 		if (sch_ep->ep == ep) {
-			update_bus_bw(sch_bw, sch_ep, 0);
-			list_del(&sch_ep->endpoint);
 			if (is_fs_or_ls(udev->speed)) {
-				list_del(&sch_ep->tt_endpoint);
+				update_sch_tt(udev, sch_ep, 0);
 				drop_tt(udev);
 			}
+			update_bus_bw(sch_bw, sch_ep, 0);
+			list_del(&sch_ep->endpoint);
 			kfree(sch_ep);
 			break;
 		}
diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h
index a93cfe817904..323b281933b9 100644
--- a/drivers/usb/host/xhci-mtk.h
+++ b/drivers/usb/host/xhci-mtk.h
@@ -21,12 +21,18 @@
 
 /**
  * @split_bit_map: used to avoid split microframes overlay
+ * @ss_bit_map: used to avoid start split microframes overlay
+ * @cs_bit_map: used to avoid complete split microframes overlay
+ * @fs_bus_bw: array to keep track of bandwidth already used at full speed
  * @ep_list: Endpoints using this TT
  * @usb_tt: usb TT related
  * @tt_port: TT port number
  */
 struct mu3h_sch_tt {
 	DECLARE_BITMAP(split_bit_map, XHCI_MTK_MAX_ESIT);
+	DECLARE_BITMAP(ss_bit_map, XHCI_MTK_MAX_ESIT);
+	DECLARE_BITMAP(cs_bit_map, XHCI_MTK_MAX_ESIT + 1);
+	u32 fs_bus_bw[XHCI_MTK_MAX_ESIT];
 	struct list_head ep_list;
 	struct usb_tt *usb_tt;
 	int tt_port;
@@ -42,7 +48,7 @@ struct mu3h_sch_tt {
  * two bandwidth domains, one for IN eps and another for OUT eps.
  */
 struct mu3h_sch_bw_info {
-	u32 bus_bw[XHCI_MTK_MAX_ESIT];
+	u32 bus_bw[XHCI_MTK_MAX_ESIT + 1];
 	struct list_head bw_ep_list;
 };
 
-- 
2.18.0


^ permalink raw reply related

* [RFC PATCH v3 2/5] usb: xhci-mtk: add mt8192 wakeup
From: Chunfeng Yun @ 2020-12-22  9:34 UTC (permalink / raw)
  To: Ikjoon Jang
  Cc: Chunfeng Yun, Tianping Fang, Zhanyong Wang, linux-mediatek,
	linux-usb, linux-kernel, Zhanyong Wang
In-Reply-To: <1608629682-8535-1-git-send-email-chunfeng.yun@mediatek.com>

From: Zhanyong Wang <zhanyong.wang@mediatek.com>

need to add wakeup solution as V3
since not support presently.

Signed-off-by: Zhanyong Wang <zhanyong.wang@mediatek.com>
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
v2~v3: no changes
---
 drivers/usb/host/xhci-mtk.c | 9 +++++++++
 1 file changed, 9 insertions(+)
 mode change 100644 => 100755 drivers/usb/host/xhci-mtk.c

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
old mode 100644
new mode 100755
index 8f321f39ab96..565ce4c16206
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -68,9 +68,13 @@
 #define SSC_IP_SLEEP_EN	BIT(4)
 #define SSC_SPM_INT_EN		BIT(1)
 
+/* mt8192 etc */
+#define SSC_IP_SLEEP_EN_V3	BIT(6)
+
 enum ssusb_uwk_vers {
 	SSUSB_UWK_V1 = 1,
 	SSUSB_UWK_V2,
+	SSUSB_UWK_V3,
 };
 
 static int xhci_mtk_host_enable(struct xhci_hcd_mtk *mtk)
@@ -305,6 +309,11 @@ static void usb_wakeup_ip_sleep_set(struct xhci_hcd_mtk *mtk, bool enable)
 		msk = SSC_IP_SLEEP_EN | SSC_SPM_INT_EN;
 		val = enable ? msk : 0;
 		break;
+	case SSUSB_UWK_V3:
+		reg = mtk->uwk_reg_base + PERI_SSUSB_SPM_CTRL;
+		msk = SSC_IP_SLEEP_EN_V3 | SSC_SPM_INT_EN;
+		val = enable ? msk : 0;
+		break;
 	default:
 		return;
 	}
-- 
2.18.0


^ permalink raw reply related

* [RFC PATCH v3 3/5] usb: xhci-mtk: fix random remote wakeup
From: Chunfeng Yun @ 2020-12-22  9:34 UTC (permalink / raw)
  To: Ikjoon Jang
  Cc: Chunfeng Yun, Tianping Fang, Zhanyong Wang, linux-mediatek,
	linux-usb, linux-kernel
In-Reply-To: <1608629682-8535-1-git-send-email-chunfeng.yun@mediatek.com>

Wakeup_signal will toggle status according to ssusb_ip_sleep
signal after debounc time, add a delay time to avoid spurious
wakeup event.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
v3: new patch
---
 drivers/usb/host/xhci-mtk.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index 565ce4c16206..34bd3de090b1 100755
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -172,7 +172,10 @@ static int xhci_mtk_host_disable(struct xhci_hcd_mtk *mtk)
 	if (ret) {
 		dev_err(mtk->dev, "ip sleep failed!!!\n");
 		return ret;
+	} else {
+		usleep_range(200, 250);
 	}
+
 	return 0;
 }
 
-- 
2.18.0


^ permalink raw reply related

* [RFC PATCH v3 4/5] usb: xhci-mtk: add support runtime pm
From: Chunfeng Yun @ 2020-12-22  9:34 UTC (permalink / raw)
  To: Ikjoon Jang
  Cc: Chunfeng Yun, Tianping Fang, Zhanyong Wang, linux-mediatek,
	linux-usb, linux-kernel, CK Hu, Zhanyong Wang
In-Reply-To: <1608629682-8535-1-git-send-email-chunfeng.yun@mediatek.com>

From: CK Hu <ck.hu@mediatek.com>

add support runtime pm feature

Signed-off-by: Zhanyong Wang <zhanyong.wang@mediatek.com>
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
v3:
  1. fix some issues
  2. remove attribute files

v2: fix error caused by request irq suggested by CK
---
 drivers/usb/host/xhci-mtk.c | 285 +++++++++++++++++++++++++++++++++++-
 drivers/usb/host/xhci-mtk.h |  14 ++
 2 files changed, 294 insertions(+), 5 deletions(-)
 mode change 100755 => 100644 drivers/usb/host/xhci-mtk.c

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
old mode 100755
new mode 100644
index 34bd3de090b1..c07d54acbcb7
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -14,6 +14,7 @@
 #include <linux/mfd/syscon.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/of_irq.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 #include <linux/regmap.h>
@@ -77,6 +78,72 @@ enum ssusb_uwk_vers {
 	SSUSB_UWK_V3,
 };
 
+int xhci_mtk_runtime_ready;
+
+static int xhci_mtk_runtime_resume(struct device *dev);
+
+static void xhci_mtk_seal_work(struct work_struct *work)
+{
+	struct xhci_hcd_mtk *mtk =
+			container_of(work, struct xhci_hcd_mtk, seal.work);
+	struct usb_hcd *hcd = mtk->hcd;
+	struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+
+	xhci_dbg(xhci, "spm unseals xHCI controller %i\n", mtk->seal_status);
+	if (mtk->seal_status == SEAL_SUSPENDED) {
+		mtk->seal_status = SEAL_RESUMING;
+		pm_runtime_mark_last_busy(mtk->dev);
+		pm_runtime_put_sync_autosuspend(mtk->dev);
+	} else {
+		/*
+		 * FIXME: Sometimes seal_status will keep it on SEAL_RESUMING staus not to expect
+		 * since pm_runtime_put_sync_autosuspend doesn't invoke runtime_resume of callback.
+		 * and to survey why not to invoke runtime_resume callback named
+		 * xhci_mtk_runtime_resume in time in short feature, Herely provide one solution
+		 * that make sure seal_status to match h/w state machine,and MTK xHCI clocks
+		 * on as soon as unseal event received.
+		 */
+		if (mtk->seal_status == SEAL_RESUMING)
+			xhci_mtk_runtime_resume(mtk->dev);
+		else
+			xhci_warn(xhci,
+				"Ignore seal wakeup source disordered in xHCI controller\n");
+	}
+}
+
+static irqreturn_t xhci_mtk_seal_irq(int irq, void *data)
+{
+	struct xhci_hcd_mtk *mtk = data;
+	struct usb_hcd *hcd = mtk->hcd;
+	struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+
+	xhci_dbg(xhci, "seal irq ISR invoked\n");
+
+	schedule_delayed_work(&mtk->seal, 0);
+
+	return IRQ_HANDLED;
+}
+
+static void xhci_mtk_seal_wakeup_enable(struct xhci_hcd_mtk *mtk, bool enable)
+{
+	struct irq_desc *desc;
+	struct device *dev = mtk->dev;
+
+	if (mtk && mtk->seal_irq) {
+		desc = irq_to_desc(mtk->seal_irq);
+		if (enable) {
+			desc->irq_data.chip->irq_ack(&desc->irq_data);
+			enable_irq(mtk->seal_irq);
+			dev_dbg(dev, "%s: enable_irq %i\n",
+				 __func__, mtk->seal_irq);
+		} else {
+			disable_irq(mtk->seal_irq);
+			dev_dbg(dev, "%s: disable_irq %i\n",
+				 __func__, mtk->seal_irq);
+		}
+	}
+}
+
 static int xhci_mtk_host_enable(struct xhci_hcd_mtk *mtk)
 {
 	struct mu3c_ippc_regs __iomem *ippc = mtk->ippc_regs;
@@ -347,7 +414,6 @@ static int usb_wakeup_of_property_parse(struct xhci_hcd_mtk *mtk,
 			mtk->uwk_reg_base, mtk->uwk_vers);
 
 	return PTR_ERR_OR_ZERO(mtk->uwk);
-
 }
 
 static void usb_wakeup_set(struct xhci_hcd_mtk *mtk, bool enable)
@@ -482,9 +548,11 @@ static int xhci_mtk_probe(struct platform_device *pdev)
 		return ret;
 	}
 
+	pm_runtime_set_active(dev);
+	pm_runtime_use_autosuspend(dev);
+	pm_runtime_set_autosuspend_delay(dev,
+				CONFIG_USB_AUTOSUSPEND_DELAY * 1000);
 	pm_runtime_enable(dev);
-	pm_runtime_get_sync(dev);
-	device_enable_async_suspend(dev);
 
 	ret = xhci_mtk_ldos_enable(mtk);
 	if (ret)
@@ -499,6 +567,14 @@ static int xhci_mtk_probe(struct platform_device *pdev)
 		ret = irq;
 		goto disable_clk;
 	}
+	dev_dbg(dev, "irq %i\n", irq);
+
+	mtk->seal_irq = platform_get_irq_optional(pdev, 1);
+	if (mtk->seal_irq < 0) {
+		ret = mtk->seal_irq;
+		goto disable_clk;
+	}
+	dev_dbg(dev, "seal_irq %i\n", mtk->seal_irq);
 
 	hcd = usb_create_hcd(driver, dev, dev_name(dev));
 	if (!hcd) {
@@ -565,6 +641,27 @@ static int xhci_mtk_probe(struct platform_device *pdev)
 	if (ret)
 		goto dealloc_usb2_hcd;
 
+	INIT_DELAYED_WORK(&mtk->seal, xhci_mtk_seal_work);
+	snprintf(mtk->seal_descr, sizeof(mtk->seal_descr), "seal%s:usb%d",
+		 hcd->driver->description, hcd->self.busnum);
+	ret = devm_request_irq(dev, mtk->seal_irq, &xhci_mtk_seal_irq,
+			  IRQF_TRIGGER_FALLING,	mtk->seal_descr, mtk);
+	if (ret != 0) {
+		dev_err(dev, "seal request interrupt %d failed\n",
+			mtk->seal_irq);
+		goto dealloc_usb2_hcd;
+	}
+	xhci_mtk_seal_wakeup_enable(mtk, false);
+
+	device_enable_async_suspend(dev);
+	xhci_mtk_runtime_ready = 1;
+
+	pm_runtime_mark_last_busy(dev);
+	pm_runtime_put_autosuspend(dev);
+
+	dev_dbg(dev, "%s: xhci_mtk_runtime_ready %i",
+		 __func__, xhci_mtk_runtime_ready);
+
 	return 0;
 
 dealloc_usb2_hcd:
@@ -587,7 +684,7 @@ static int xhci_mtk_probe(struct platform_device *pdev)
 	xhci_mtk_ldos_disable(mtk);
 
 disable_pm:
-	pm_runtime_put_sync(dev);
+	pm_runtime_put_sync_autosuspend(dev);
 	pm_runtime_disable(dev);
 	return ret;
 }
@@ -602,6 +699,7 @@ static int xhci_mtk_remove(struct platform_device *dev)
 	pm_runtime_put_noidle(&dev->dev);
 	pm_runtime_disable(&dev->dev);
 
+	xhci_mtk_runtime_ready = 0;
 	usb_remove_hcd(shared_hcd);
 	xhci->shared_hcd = NULL;
 	device_init_wakeup(&dev->dev, false);
@@ -638,6 +736,7 @@ static int __maybe_unused xhci_mtk_suspend(struct device *dev)
 	xhci_mtk_host_disable(mtk);
 	xhci_mtk_clks_disable(mtk);
 	usb_wakeup_set(mtk, true);
+
 	return 0;
 }
 
@@ -659,10 +758,185 @@ static int __maybe_unused xhci_mtk_resume(struct device *dev)
 	return 0;
 }
 
+static int __maybe_unused xhci_mtk_bus_status(struct device *dev)
+{
+	struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev);
+	struct usb_hcd *hcd;
+	struct xhci_hcd *xhci;
+	struct xhci_hub *usb2_rhub;
+	struct xhci_hub *usb3_rhub;
+	struct xhci_bus_state *bus_state;
+	struct xhci_port *port;
+	u32	usb2_suspended_ports = -1;
+	u32	usb3_suspended_ports = -1;
+	u16 status;
+	int num_ports;
+	int ret = 0;
+	int i;
+
+	if (!mtk->hcd)
+		return -ESHUTDOWN;
+
+	hcd = mtk->hcd;
+	xhci = hcd_to_xhci(hcd);
+	if ((xhci->xhc_state & XHCI_STATE_REMOVING) ||
+			(xhci->xhc_state & XHCI_STATE_HALTED)) {
+		return -ESHUTDOWN;
+	}
+
+	usb2_rhub = &xhci->usb2_rhub;
+	if (usb2_rhub) {
+		bus_state  = &usb2_rhub->bus_state;
+		num_ports  = usb2_rhub->num_ports;
+		usb2_suspended_ports  = bus_state->suspended_ports;
+		usb2_suspended_ports ^= (BIT(num_ports) - 1);
+		usb2_suspended_ports &= (BIT(num_ports) - 1);
+		for (i = 0; i < num_ports; i++) {
+			if (usb2_suspended_ports & (1UL << i)) {
+				port = usb2_rhub->ports[i];
+				status = readl(port->addr);
+
+				xhci_dbg(xhci,
+					  "USB20: portsc[%i]: 0x%04X\n",
+					  i, status);
+
+				if (!(status & PORT_CONNECT))
+					usb2_suspended_ports &= ~(1UL << i);
+			}
+		}
+
+		if (usb2_suspended_ports) {
+			ret = -EBUSY;
+			goto ebusy;
+		}
+	}
+
+	usb3_rhub = &xhci->usb3_rhub;
+	if (usb3_rhub) {
+		bus_state  = &usb3_rhub->bus_state;
+		num_ports  = usb3_rhub->num_ports;
+		usb3_suspended_ports  = bus_state->suspended_ports;
+		usb3_suspended_ports ^= (BIT(num_ports) - 1);
+		usb3_suspended_ports &= (BIT(num_ports) - 1);
+		for (i = 0; i < num_ports; i++) {
+			if (usb3_suspended_ports & BIT(i)) {
+				port = usb3_rhub->ports[i];
+				status = readl(port->addr);
+
+				xhci_dbg(xhci, "USB3: portsc[%i]: 0x%04X\n",
+					  i, status);
+
+				if (!(status & PORT_CONNECT))
+					usb3_suspended_ports &= ~BIT(i);
+			}
+		}
+
+		if (usb3_suspended_ports) {
+			ret = -EBUSY;
+			goto ebusy;
+		}
+	}
+
+ebusy:
+	xhci_dbg(xhci, "%s: USB2: 0x%08X, USB3: 0x%08X ret: %i\n",
+		  __func__, usb2_suspended_ports,
+		  usb3_suspended_ports, ret);
+
+	return ret;
+}
+
+static int __maybe_unused xhci_mtk_runtime_suspend(struct device *dev)
+{
+	bool wakeup = device_may_wakeup(dev);
+	struct xhci_hcd_mtk  *mtk = dev_get_drvdata(dev);
+	struct usb_hcd *hcd;
+	struct xhci_hcd *xhci;
+	int ret = 0;
+
+	if (!mtk->hcd)
+		return -ESHUTDOWN;
+
+	hcd = mtk->hcd;
+	xhci = hcd_to_xhci(hcd);
+	if ((xhci->xhc_state & XHCI_STATE_REMOVING) ||
+			(xhci->xhc_state & XHCI_STATE_HALTED)) {
+		return -ESHUTDOWN;
+	}
+
+	mtk->seal_status = SEAL_BUSY;
+	ret = xhci_mtk_bus_status(dev);
+	if (wakeup && !ret) {
+		mtk->seal_status = SEAL_SUSPENDING;
+		xhci_mtk_suspend(dev);
+		xhci_mtk_seal_wakeup_enable(mtk, true);
+		mtk->seal_status = SEAL_SUSPENDED;
+		xhci_dbg(xhci, "%s: seals xHCI controller\n", __func__);
+	}
+
+	xhci_dbg(xhci, "%s: seals wakeup = %i, ret = %i!\n",
+		  __func__, wakeup, ret);
+
+	return ret;
+}
+
+static int __maybe_unused xhci_mtk_runtime_resume(struct device *dev)
+{
+	bool wakeup = device_may_wakeup(dev);
+	struct xhci_hcd_mtk  *mtk = dev_get_drvdata(dev);
+	struct usb_hcd *hcd;
+	struct xhci_hcd *xhci;
+
+	if (!mtk->hcd)
+		return -ESHUTDOWN;
+
+	hcd = mtk->hcd;
+	xhci = hcd_to_xhci(hcd);
+	if ((xhci->xhc_state & XHCI_STATE_REMOVING) ||
+			(xhci->xhc_state & XHCI_STATE_HALTED)) {
+		return -ESHUTDOWN;
+	}
+
+	/*
+	 *  list cases by one extra interrupt named seal to process!!!
+	 *  Who to process these module reinitilization after SPM wakeup
+	 *  case 1: usb remote wakeup, therefore xHCI need reinitilizate also.
+	 *  case 2: other-wakeup-source wakeup, therefore, xHCI need reinit
+	 *  case 3: usb client driver can invoke it in runtime mechanism
+	 *  case 4: user active
+	 */
+	if (wakeup) {
+		xhci_mtk_seal_wakeup_enable(mtk, false);
+		xhci_mtk_resume(dev);
+		xhci_dbg(xhci, "%s: unseals xHCI controller\n", __func__);
+	}
+	mtk->seal_status = SEAL_RESUMED;
+
+	xhci_dbg(xhci, "%s: unseals wakeup = %i\n", __func__, wakeup);
+
+	return 0;
+}
+
+static int __maybe_unused xhci_mtk_runtime_idle(struct device *dev)
+{
+	int ret = 0;
+
+	dev_dbg(dev, "%s: xhci_mtk_runtime_ready %i",
+		 __func__, xhci_mtk_runtime_ready);
+
+	if (!xhci_mtk_runtime_ready)
+		ret = -EAGAIN;
+
+	return ret;
+}
+
 static const struct dev_pm_ops xhci_mtk_pm_ops = {
 	SET_SYSTEM_SLEEP_PM_OPS(xhci_mtk_suspend, xhci_mtk_resume)
+	SET_RUNTIME_PM_OPS(xhci_mtk_runtime_suspend,
+			   xhci_mtk_runtime_resume,
+			   xhci_mtk_runtime_idle)
 };
-#define DEV_PM_OPS IS_ENABLED(CONFIG_PM) ? &xhci_mtk_pm_ops : NULL
+
+#define DEV_PM_OPS (IS_ENABLED(CONFIG_PM) ? &xhci_mtk_pm_ops : NULL)
 
 #ifdef CONFIG_OF
 static const struct of_device_id mtk_xhci_of_match[] = {
@@ -686,6 +960,7 @@ MODULE_ALIAS("platform:xhci-mtk");
 
 static int __init xhci_mtk_init(void)
 {
+	xhci_mtk_runtime_ready = 0;
 	xhci_init_driver(&xhci_mtk_hc_driver, &xhci_mtk_overrides);
 	return platform_driver_register(&mtk_xhci_driver);
 }
diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h
index 323b281933b9..103d83ce6a3e 100644
--- a/drivers/usb/host/xhci-mtk.h
+++ b/drivers/usb/host/xhci-mtk.h
@@ -133,6 +133,14 @@ struct mu3c_ippc_regs {
 	__le32 reserved3[33]; /* 0x80 ~ 0xff */
 };
 
+enum xhci_mtk_seal {
+	SEAL_BUSY = 0,
+	SEAL_SUSPENDING,
+	SEAL_SUSPENDED,
+	SEAL_RESUMING,
+	SEAL_RESUMED
+};
+
 struct xhci_hcd_mtk {
 	struct device *dev;
 	struct usb_hcd *hcd;
@@ -158,6 +166,12 @@ struct xhci_hcd_mtk {
 	struct regmap *uwk;
 	u32 uwk_reg_base;
 	u32 uwk_vers;
+
+	/* usb eint wakeup source */
+	int seal_irq;
+	enum xhci_mtk_seal seal_status;
+	struct delayed_work  seal;
+	char   seal_descr[32];	/* "seal" + driver + bus # */
 };
 
 static inline struct xhci_hcd_mtk *hcd_to_mtk(struct usb_hcd *hcd)
-- 
2.18.0


^ permalink raw reply related

* [RFC PATCH v3 5/5] arm64: dts: mt8192: add SSUSB related nodes
From: Chunfeng Yun @ 2020-12-22  9:34 UTC (permalink / raw)
  To: Ikjoon Jang
  Cc: Chunfeng Yun, Tianping Fang, Zhanyong Wang, linux-mediatek,
	linux-usb, linux-kernel, Zhanyong Wang
In-Reply-To: <1608629682-8535-1-git-send-email-chunfeng.yun@mediatek.com>

From: Zhanyong Wang <zhanyong.wang@mediatek.com>

Add SSUSB related nodes for mt8192

Signed-off-by: Zhanyong Wang <zhanyong.wang@mediatek.com>
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
v3: rename node as 'usb' instead of xhci

v2: include phy.h file

Depends on:
https://patchwork.kernel.org/patch/11713559/
[v4,1/3] arm64: dts: Add Mediatek SoC MT8192 and evaluation board dts and Makefile
---
 arch/arm64/boot/dts/mediatek/mt8192.dtsi | 49 ++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8192.dtsi b/arch/arm64/boot/dts/mediatek/mt8192.dtsi
index 69d45c7b31f1..82d9f6eee404 100644
--- a/arch/arm64/boot/dts/mediatek/mt8192.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8192.dtsi
@@ -9,6 +9,7 @@
 #include <dt-bindings/interrupt-controller/arm-gic.h>
 #include <dt-bindings/interrupt-controller/irq.h>
 #include <dt-bindings/pinctrl/mt8192-pinfunc.h>
+#include <dt-bindings/phy/phy.h>
 
 / {
 	compatible = "mediatek,mt8192";
@@ -416,6 +417,54 @@
 			status = "disabled";
 		};
 
+		xhci: usb@11200000 {
+			compatible = "mediatek,mt8192-xhci",
+				     "mediatek,mtk-xhci";
+			reg = <0 0x11200000 0 0x1000>,
+			      <0 0x11203e00 0 0x0100>;
+			reg-names = "mac", "ippc";
+			interrupts-extended = <&gic GIC_SPI 97 IRQ_TYPE_LEVEL_HIGH 0>,
+					      <&pio 211 IRQ_TYPE_LEVEL_LOW>;
+			phys = <&u2port0 PHY_TYPE_USB2>,
+			       <&u3port0 PHY_TYPE_USB3>;
+			assigned-clocks = <&topckgen CLK_TOP_USB_TOP_SEL>,
+					  <&topckgen CLK_TOP_SSUSB_XHCI_SEL>;
+			assigned-clock-parents = <&topckgen CLK_TOP_UNIVPLL_D5_D4>,
+						 <&topckgen CLK_TOP_UNIVPLL_D5_D4>;
+			clocks = <&infracfg CLK_INFRA_SSUSB>,
+				 <&infracfg CLK_INFRA_SSUSB_XHCI>,
+				 <&apmixedsys CLK_APMIXED_USBPLL>;
+			clock-names = "sys_ck", "xhci_ck", "ref_ck";
+			mediatek,syscon-wakeup = <&pericfg 0x420 3>;
+			#address-cells = <2>;
+			#size-cells = <2>;
+		};
+
+		u3phy0: usb-phy@11e40000 {
+			compatible = "mediatek,mt8192-tphy",
+				     "mediatek,generic-tphy-v2";
+			#address-cells = <2>;
+			#size-cells = <2>;
+			ranges;
+			status = "okay";
+
+			u2port0: usb-phy@11e40000 {
+				reg = <0 0x11e40000 0 0x700>;
+				clocks = <&clk26m>;
+				clock-names = "ref";
+				#phy-cells = <1>;
+				status = "okay";
+			};
+
+			u3port0: usb-phy@11e40700 {
+				reg = <0 0x11e40700 0 0x900>;
+				clocks = <&clk26m>;
+				clock-names = "ref";
+				#phy-cells = <1>;
+				status = "okay";
+			};
+		};
+
 		audsys: syscon@11210000 {
 			compatible = "mediatek,mt8192-audsys", "syscon";
 			reg = <0 0x11210000 0 0x1000>;
-- 
2.18.0


^ permalink raw reply related

* Re: [PATCH] usb: host: xhci-plat: fix support for XHCI_SKIP_PHY_INIT quirk
From: Pali Rohár @ 2020-12-22  9:23 UTC (permalink / raw)
  To: Peter Chen
  Cc: Mathias Nyman, Greg Kroah-Hartman, Jun Li,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
In-Reply-To: <20201222021416.GB4706@b29397-desktop>

On Tuesday 22 December 2020 02:14:45 Peter Chen wrote:
> On 20-12-21 16:09:03, Pali Rohár wrote:
> > Currently init_quirk callbacks for xhci platform drivers are called
> > xhci_plat_setup() function which is called after chip reset completes.
> > It happens in the middle of the usb_add_hcd() function.
> > 
> > But XHCI_SKIP_PHY_INIT quirk is checked in the xhci_plat_probe() function
> > prior calling usb_add_hcd() function. Therefore this XHCI_SKIP_PHY_INIT
> > currently does nothing as prior xhci_plat_setup() it is not set.
> > 
> > Quirk XHCI_SKIP_PHY_INIT is only setting hcd->skip_phy_initialization value
> > which really needs to be set prior calling usb_add_hcd() as this function
> > at its beginning skips PHY init if this member is set.
> > 
> > This patch fixes implementation of the XHCI_SKIP_PHY_INIT quirk by calling
> > init_quirk callbacks (via xhci_priv_init_quirk()) prior checking if
> > XHCI_SKIP_PHY_INIT is set.
> > 
> > Fixes: f768e718911e0 ("usb: host: xhci-plat: add priv quirk for skip PHY initialization")
> > Signed-off-by: Pali Rohár <pali@kernel.org>
> > ---
> >  drivers/usb/host/xhci-plat.c | 14 +++++++-------
> >  1 file changed, 7 insertions(+), 7 deletions(-)
> > 
> > diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> > index 4d34f6005381..58704c5b002b 100644
> > --- a/drivers/usb/host/xhci-plat.c
> > +++ b/drivers/usb/host/xhci-plat.c
> > @@ -89,13 +89,6 @@ static void xhci_plat_quirks(struct device *dev, struct xhci_hcd *xhci)
> >  /* called during probe() after chip reset completes */
> >  static int xhci_plat_setup(struct usb_hcd *hcd)
> >  {
> > -	int ret;
> > -
> > -
> > -	ret = xhci_priv_init_quirk(hcd);
> > -	if (ret)
> > -		return ret;
> > -
> >  	return xhci_gen_setup(hcd, xhci_plat_quirks);
> >  }
> >  
> > @@ -330,6 +323,13 @@ static int xhci_plat_probe(struct platform_device *pdev)
> >  
> >  	hcd->tpl_support = of_usb_host_tpl_support(sysdev->of_node);
> >  	xhci->shared_hcd->tpl_support = hcd->tpl_support;
> > +
> > +	if (priv) {
> > +		ret = xhci_priv_init_quirk(hcd);
> > +		if (ret)
> > +			goto disable_usb_phy;
> > +	}
> > +
> >  	if (priv && (priv->quirks & XHCI_SKIP_PHY_INIT))
> >  		hcd->skip_phy_initialization = 1;
> >  
> 
> Hi Pali,
> 
> What's problem you have met? In structure xhci_plat_priv, the quirks are
> defined at .quirks entry which is got at below code. .init_quirk is the
> routine if special initializations are needed.

Hello!

I'm talking about .init_quirk. And if XHCI_SKIP_PHY_INIT quirk is set in
this function then has no effect.

I'm working currently on patch for xhci mvebu which conditionally enable
or disable XHCI_SKIP_PHY_INIT quirk (it is going to fix existing
regression since v5.1 kernel) and without this patch XHCI_SKIP_PHY_INIT
quirk from the init_quirk does not work.

> 	if (pdev->dev.of_node)
> 		priv_match = of_device_get_match_data(&pdev->dev);
> 	else
> 		priv_match = dev_get_platdata(&pdev->dev);
> 
> 	if (priv_match) {
> 		priv = hcd_to_xhci_priv(hcd);
> 		/* Just copy data for now */
> 		*priv = *priv_match;
> 	}
> -- 
> 
> Thanks,
> Peter Chen

^ permalink raw reply

* Re: Correct ordering of phy_init and phy_power_on
From: Ahmad Fatoum @ 2020-12-22  9:08 UTC (permalink / raw)
  To: Kishon Vijay Abraham I, Vinod Koul, Minas Harutyunyan, linux-usb
  Cc: linux-kernel@vger.kernel.org, Pengutronix Kernel Team,
	Jules Maselbas
In-Reply-To: <014e75a5-ab7b-55be-e554-14ef7550b360@ti.com>

Hello Kishon,

On 21.12.20 04:15, Kishon Vijay Abraham I wrote:
>> So how was it meant to be?
> 
> It is intended to be ->init() and then ->power_on(). So ideally it
> should be the way dwc3 is.

Thanks. Should we do something about the inconsistency?

Amend documentation and maybe print a warning when order is wrong,
so users are encouraged to fix their drivers?

The way it is, you can't properly mix some of the PHY and USB controller drivers.

Cheers,
Ahmad

> 
> Thanks,
> Kishon
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

^ permalink raw reply

* Re: [PATCH v1 17/30] mmc: sdhci-tegra: Support OPP and core voltage scaling
From: Viresh Kumar @ 2020-12-22  8:54 UTC (permalink / raw)
  To: Frank Lee
  Cc: Dmitry Osipenko, Thierry Reding, Jonathan Hunter, Alan Stern,
	Peter Chen, Mark Brown, Liam Girdwood, Adrian Hunter,
	Krzysztof Kozlowski, Greg Kroah-Hartman, Lee Jones,
	Uwe Kleine-König, Ulf Hansson, Mauro Carvalho Chehab,
	Rob Herring, Marek Szyprowski, Peter Geis, Nicolas Chauvet,
	driver-dev, linux-pwm, linux-samsung-soc, DTML,
	open list:ULTRA-WIDEBAND (UWB) SUBSYSTEM:,
	open list:SECURE DIGITAL HO..., Linux Kernel Mailing List,
	dri-devel, linux-tegra@vger.kernel.org,
	linux-media@vger.kernel.org
In-Reply-To: <CAEExFWuF82B3bPn8T8_vkHODNwP89MDrNOqu-MhObzqTfiYODw@mail.gmail.com>

On Mon, 9 Nov 2020 at 16:51, Frank Lee <tiny.windzz@gmail.com> wrote:
> On Mon, Nov 9, 2020 at 1:53 PM Viresh Kumar <viresh.kumar@linaro.org> wrote:

> > > devm_pm_opp_set_supported_hw()
> > > devm_pm_opp_set_regulators() [if we won't use GENPD]
> > > devm_pm_opp_set_clkname()
> > > devm_pm_opp_of_add_table()
> >
> > I tried to look earlier for the stuff already merged in and didn't
> > find a lot of stuff where the devm_* could be used, maybe I missed
> > some of it.
> >
> > Frank, would you like to refresh your series based on suggestions from
> > Dmitry and make other drivers adapt to the new APIs ?
>
> I am glad to do this.:)

Frank,

Dmitry has submitted a series with a patch that does stuff like this since you
never resent your patches.

http://lore.kernel.org/lkml/20201217180638.22748-14-digetx@gmail.com

Since you were the first one to get to this, I would still like to
give you a chance
to get these patches merged under your authorship, otherwise I would be going
to pick patches from Dmitry.

--
viresh

^ permalink raw reply

* Re: [PATCH] usb: musb: add printf attribute to log function
From: Greg KH @ 2020-12-22  8:52 UTC (permalink / raw)
  To: trix; +Cc: b-liu, linux-usb, linux-kernel
In-Reply-To: <20201221162547.3756889-1-trix@redhat.com>

On Mon, Dec 21, 2020 at 08:25:47AM -0800, trix@redhat.com wrote:
> From: Tom Rix <trix@redhat.com>
> 
> Attributing the function allows the compiler to more thoroughly
> check the use of the function with -Wformat and similar flags.
> 
> Signed-off-by: Tom Rix <trix@redhat.com>
> ---
>  drivers/usb/musb/musb_debug.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/usb/musb/musb_debug.h b/drivers/usb/musb/musb_debug.h
> index e5b3506c7b3f..dfc0d02695fa 100644
> --- a/drivers/usb/musb/musb_debug.h
> +++ b/drivers/usb/musb/musb_debug.h
> @@ -17,6 +17,7 @@
>  #define INFO(fmt, args...) yprintk(KERN_INFO, fmt, ## args)
>  #define ERR(fmt, args...) yprintk(KERN_ERR, fmt, ## args)
>  
> +__printf(2, 3)
>  void musb_dbg(struct musb *musb, const char *fmt, ...);

While I understand the need for this, did this find any problems?  If
not, then it's not worth adding, the driver-specific debugging macros
should be removed entirely and just use dev_dbg() and friends instead.

thanks,

greg k-h

^ permalink raw reply

* Re: [PATCH] dt-bindings: Drop redundant maxItems/items
From: Laurent Pinchart @ 2020-12-22  7:00 UTC (permalink / raw)
  To: Rob Herring
  Cc: devicetree, linux-kernel, Vinod Koul, Mark Brown,
	Greg Kroah-Hartman, Jassi Brar, dri-devel, dmaengine, alsa-devel,
	linux-usb
In-Reply-To: <20201222040645.1323611-1-robh@kernel.org>

Hi Rob,

Thank you for the patch.

On Mon, Dec 21, 2020 at 09:06:45PM -0700, Rob Herring wrote:
> 'maxItems' equal to the 'items' list length is redundant. 'maxItems' is
> preferred for a single entry while greater than 1 should have an 'items'
> list.
> 
> A meta-schema check for this is pending once these existing cases are
> fixed.
> 
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: Vinod Koul <vkoul@kernel.org>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Jassi Brar <jaswinder.singh@linaro.org>
> Cc: dri-devel@lists.freedesktop.org
> Cc: dmaengine@vger.kernel.org
> Cc: alsa-devel@alsa-project.org
> Cc: linux-usb@vger.kernel.org
> Signed-off-by: Rob Herring <robh@kernel.org>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  .../devicetree/bindings/display/xlnx/xlnx,zynqmp-dpsub.yaml    | 1 -
>  Documentation/devicetree/bindings/dma/renesas,rcar-dmac.yaml   | 1 -
>  Documentation/devicetree/bindings/mailbox/arm,mhu.yaml         | 1 -
>  .../devicetree/bindings/sound/nvidia,tegra30-hda.yaml          | 2 --
>  Documentation/devicetree/bindings/usb/renesas,usb-xhci.yaml    | 1 -
>  Documentation/devicetree/bindings/usb/renesas,usbhs.yaml       | 3 ---
>  6 files changed, 9 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/display/xlnx/xlnx,zynqmp-dpsub.yaml b/Documentation/devicetree/bindings/display/xlnx/xlnx,zynqmp-dpsub.yaml
> index 7b9d468c3e52..403d57977ee7 100644
> --- a/Documentation/devicetree/bindings/display/xlnx/xlnx,zynqmp-dpsub.yaml
> +++ b/Documentation/devicetree/bindings/display/xlnx/xlnx,zynqmp-dpsub.yaml
> @@ -98,7 +98,6 @@ properties:
>      maxItems: 1
>  
>    dmas:
> -    maxItems: 4
>      items:
>        - description: Video layer, plane 0 (RGB or luma)
>        - description: Video layer, plane 1 (U/V or U)
> diff --git a/Documentation/devicetree/bindings/dma/renesas,rcar-dmac.yaml b/Documentation/devicetree/bindings/dma/renesas,rcar-dmac.yaml
> index b548e4723936..c07eb6f2fc8d 100644
> --- a/Documentation/devicetree/bindings/dma/renesas,rcar-dmac.yaml
> +++ b/Documentation/devicetree/bindings/dma/renesas,rcar-dmac.yaml
> @@ -73,7 +73,6 @@ properties:
>      maxItems: 1
>  
>    clock-names:
> -    maxItems: 1
>      items:
>        - const: fck
>  
> diff --git a/Documentation/devicetree/bindings/mailbox/arm,mhu.yaml b/Documentation/devicetree/bindings/mailbox/arm,mhu.yaml
> index d43791a2dde7..d07eb00b97c8 100644
> --- a/Documentation/devicetree/bindings/mailbox/arm,mhu.yaml
> +++ b/Documentation/devicetree/bindings/mailbox/arm,mhu.yaml
> @@ -61,7 +61,6 @@ properties:
>        - description: low-priority non-secure
>        - description: high-priority non-secure
>        - description: Secure
> -    maxItems: 3
>  
>    clocks:
>      maxItems: 1
> diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra30-hda.yaml b/Documentation/devicetree/bindings/sound/nvidia,tegra30-hda.yaml
> index e543a6123792..b55775e21de6 100644
> --- a/Documentation/devicetree/bindings/sound/nvidia,tegra30-hda.yaml
> +++ b/Documentation/devicetree/bindings/sound/nvidia,tegra30-hda.yaml
> @@ -44,7 +44,6 @@ properties:
>      maxItems: 3
>  
>    clock-names:
> -    maxItems: 3
>      items:
>        - const: hda
>        - const: hda2hdmi
> @@ -54,7 +53,6 @@ properties:
>      maxItems: 3
>  
>    reset-names:
> -    maxItems: 3
>      items:
>        - const: hda
>        - const: hda2hdmi
> diff --git a/Documentation/devicetree/bindings/usb/renesas,usb-xhci.yaml b/Documentation/devicetree/bindings/usb/renesas,usb-xhci.yaml
> index 0f078bd0a3e5..22603256ddf8 100644
> --- a/Documentation/devicetree/bindings/usb/renesas,usb-xhci.yaml
> +++ b/Documentation/devicetree/bindings/usb/renesas,usb-xhci.yaml
> @@ -51,7 +51,6 @@ properties:
>      maxItems: 1
>  
>    phy-names:
> -    maxItems: 1
>      items:
>        - const: usb
>  
> diff --git a/Documentation/devicetree/bindings/usb/renesas,usbhs.yaml b/Documentation/devicetree/bindings/usb/renesas,usbhs.yaml
> index 737c1f47b7de..54c361d4a7af 100644
> --- a/Documentation/devicetree/bindings/usb/renesas,usbhs.yaml
> +++ b/Documentation/devicetree/bindings/usb/renesas,usbhs.yaml
> @@ -74,11 +74,8 @@ properties:
>  
>    phys:
>      maxItems: 1
> -    items:
> -      - description: phandle + phy specifier pair.
>  
>    phy-names:
> -    maxItems: 1
>      items:
>        - const: usb
>  

-- 
Regards,

Laurent Pinchart

^ permalink raw reply

* Re: [PATCH] dt-bindings: Drop redundant maxItems/items
From: Sam Ravnborg @ 2020-12-22  6:39 UTC (permalink / raw)
  To: Rob Herring
  Cc: devicetree, alsa-devel, Greg Kroah-Hartman, linux-usb,
	linux-kernel, dri-devel, Jassi Brar, Vinod Koul, Mark Brown,
	Laurent Pinchart, dmaengine
In-Reply-To: <20201222040645.1323611-1-robh@kernel.org>

Hi Rob,

On Mon, Dec 21, 2020 at 09:06:45PM -0700, Rob Herring wrote:
> 'maxItems' equal to the 'items' list length is redundant. 'maxItems' is
> preferred for a single entry while greater than 1 should have an 'items'
> list.
> 
> A meta-schema check for this is pending once these existing cases are
> fixed.
> 
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: Vinod Koul <vkoul@kernel.org>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Jassi Brar <jaswinder.singh@linaro.org>
> Cc: dri-devel@lists.freedesktop.org
> Cc: dmaengine@vger.kernel.org
> Cc: alsa-devel@alsa-project.org
> Cc: linux-usb@vger.kernel.org
> Signed-off-by: Rob Herring <robh@kernel.org>

With one comment below,
Acked-by: Sam Ravnborg <sam@ravnborg.org>

> ---
> diff --git a/Documentation/devicetree/bindings/usb/renesas,usbhs.yaml b/Documentation/devicetree/bindings/usb/renesas,usbhs.yaml
> index 737c1f47b7de..54c361d4a7af 100644
> --- a/Documentation/devicetree/bindings/usb/renesas,usbhs.yaml
> +++ b/Documentation/devicetree/bindings/usb/renesas,usbhs.yaml
> @@ -74,11 +74,8 @@ properties:
>  
>    phys:
>      maxItems: 1
> -    items:
> -      - description: phandle + phy specifier pair.

The description may help some people, so keeping the
description and deleting maxItems would maybe be better.

	Sam

^ permalink raw reply

* [PATCH] dt-bindings: Drop redundant maxItems/items
From: Rob Herring @ 2020-12-22  4:06 UTC (permalink / raw)
  To: devicetree
  Cc: linux-kernel, Laurent Pinchart, Vinod Koul, Mark Brown,
	Greg Kroah-Hartman, Jassi Brar, dri-devel, dmaengine, alsa-devel,
	linux-usb

'maxItems' equal to the 'items' list length is redundant. 'maxItems' is
preferred for a single entry while greater than 1 should have an 'items'
list.

A meta-schema check for this is pending once these existing cases are
fixed.

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Vinod Koul <vkoul@kernel.org>
Cc: Mark Brown <broonie@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jassi Brar <jaswinder.singh@linaro.org>
Cc: dri-devel@lists.freedesktop.org
Cc: dmaengine@vger.kernel.org
Cc: alsa-devel@alsa-project.org
Cc: linux-usb@vger.kernel.org
Signed-off-by: Rob Herring <robh@kernel.org>
---
 .../devicetree/bindings/display/xlnx/xlnx,zynqmp-dpsub.yaml    | 1 -
 Documentation/devicetree/bindings/dma/renesas,rcar-dmac.yaml   | 1 -
 Documentation/devicetree/bindings/mailbox/arm,mhu.yaml         | 1 -
 .../devicetree/bindings/sound/nvidia,tegra30-hda.yaml          | 2 --
 Documentation/devicetree/bindings/usb/renesas,usb-xhci.yaml    | 1 -
 Documentation/devicetree/bindings/usb/renesas,usbhs.yaml       | 3 ---
 6 files changed, 9 deletions(-)

diff --git a/Documentation/devicetree/bindings/display/xlnx/xlnx,zynqmp-dpsub.yaml b/Documentation/devicetree/bindings/display/xlnx/xlnx,zynqmp-dpsub.yaml
index 7b9d468c3e52..403d57977ee7 100644
--- a/Documentation/devicetree/bindings/display/xlnx/xlnx,zynqmp-dpsub.yaml
+++ b/Documentation/devicetree/bindings/display/xlnx/xlnx,zynqmp-dpsub.yaml
@@ -98,7 +98,6 @@ properties:
     maxItems: 1
 
   dmas:
-    maxItems: 4
     items:
       - description: Video layer, plane 0 (RGB or luma)
       - description: Video layer, plane 1 (U/V or U)
diff --git a/Documentation/devicetree/bindings/dma/renesas,rcar-dmac.yaml b/Documentation/devicetree/bindings/dma/renesas,rcar-dmac.yaml
index b548e4723936..c07eb6f2fc8d 100644
--- a/Documentation/devicetree/bindings/dma/renesas,rcar-dmac.yaml
+++ b/Documentation/devicetree/bindings/dma/renesas,rcar-dmac.yaml
@@ -73,7 +73,6 @@ properties:
     maxItems: 1
 
   clock-names:
-    maxItems: 1
     items:
       - const: fck
 
diff --git a/Documentation/devicetree/bindings/mailbox/arm,mhu.yaml b/Documentation/devicetree/bindings/mailbox/arm,mhu.yaml
index d43791a2dde7..d07eb00b97c8 100644
--- a/Documentation/devicetree/bindings/mailbox/arm,mhu.yaml
+++ b/Documentation/devicetree/bindings/mailbox/arm,mhu.yaml
@@ -61,7 +61,6 @@ properties:
       - description: low-priority non-secure
       - description: high-priority non-secure
       - description: Secure
-    maxItems: 3
 
   clocks:
     maxItems: 1
diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra30-hda.yaml b/Documentation/devicetree/bindings/sound/nvidia,tegra30-hda.yaml
index e543a6123792..b55775e21de6 100644
--- a/Documentation/devicetree/bindings/sound/nvidia,tegra30-hda.yaml
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra30-hda.yaml
@@ -44,7 +44,6 @@ properties:
     maxItems: 3
 
   clock-names:
-    maxItems: 3
     items:
       - const: hda
       - const: hda2hdmi
@@ -54,7 +53,6 @@ properties:
     maxItems: 3
 
   reset-names:
-    maxItems: 3
     items:
       - const: hda
       - const: hda2hdmi
diff --git a/Documentation/devicetree/bindings/usb/renesas,usb-xhci.yaml b/Documentation/devicetree/bindings/usb/renesas,usb-xhci.yaml
index 0f078bd0a3e5..22603256ddf8 100644
--- a/Documentation/devicetree/bindings/usb/renesas,usb-xhci.yaml
+++ b/Documentation/devicetree/bindings/usb/renesas,usb-xhci.yaml
@@ -51,7 +51,6 @@ properties:
     maxItems: 1
 
   phy-names:
-    maxItems: 1
     items:
       - const: usb
 
diff --git a/Documentation/devicetree/bindings/usb/renesas,usbhs.yaml b/Documentation/devicetree/bindings/usb/renesas,usbhs.yaml
index 737c1f47b7de..54c361d4a7af 100644
--- a/Documentation/devicetree/bindings/usb/renesas,usbhs.yaml
+++ b/Documentation/devicetree/bindings/usb/renesas,usbhs.yaml
@@ -74,11 +74,8 @@ properties:
 
   phys:
     maxItems: 1
-    items:
-      - description: phandle + phy specifier pair.
 
   phy-names:
-    maxItems: 1
     items:
       - const: usb
 
-- 
2.27.0


^ permalink raw reply related

* Re: port power is on again after turning off by user space
From: Alan Stern @ 2020-12-22  2:35 UTC (permalink / raw)
  To: Peter Chen; +Cc: Jun Li, linux-usb@vger.kernel.org, Frank Li
In-Reply-To: <20201222020215.GA4706@b29397-desktop>

On Tue, Dec 22, 2020 at 02:02:44AM +0000, Peter Chen wrote:
> On 20-12-21 11:25:51, Alan Stern wrote:
> > Okay.  This can be done as follows:
> > 
> > while (1) {
> > - Check Flash Drive is there (eg, cat /proc/partitions)
> > - Claim port 1 on 1-1
> > - Turn port 1 at 1-1 off
> > - Check Flash Drive is gone
> > - Release port 1 on 1-1
> > - Turn port 1 at 1-1 on
> > - Delay for 10 seconds (time for device probing)
> > }
> > 
> > 
> > > > On the other hand, if the port is managed by the kernel then the kernel 
> > > > (not the user) should be responsible for deciding whether or not to 
> > > > turn off the port's power.
> > > > 
> > > > If there's some real reason for turning the port power off for an 
> > > > extended period of time, the user can claim the port and turn off the 
> > > > power.  Then later on, the user can release the port and turn the power 
> > > > back on.
> > > > 
> > > 
> > > Yes, I think this is one of the use cases. We want power power control
> > > at one application (A), but different with our test application(B), it means
> > > if the user claims the port, and power off using A, then the A will end.
> > > After the B finished running, A runs again for power on, but at this time,
> > > the port owner has changed.
> > 
> > Yes, that won't work.  If you want to keep the port power turned off 
> > then you have to keep the usbfs device file open -- which means your 
> > program A must not end and then restart.
> > 
> > (Acutally, I'm not certain about that.  If you claim a port, turn off 
> > its power, and then release the port, I don't remember whether the hub 
> > driver will then turn the power back on right away.  It might not.  
> > But in any case, it isn't good programming to release a port without 
> > turning its power back on.)
> > 
> > Can A be rewritten so that it doesn't end when B is running?
> > 
> 
> Of course. I think the similar use case like below:
> 
> Program A (Port power control program)
> 
> while (1) {
> 	- Wait "turn off" command;
> 	- Claim requested port;
> 	- Turn off requested port;
> 	- Wait "turn on" command;
> 	- Turn on requested port
> 	- Release requested port;

You have to be a little careful about this.  Let's say you turn on the 
port power.  THen the device will connect and be enumerated.

But if you haven't released the port at this point, the kernel won't 
select a configuration for the device; it will leave the device in the 
unconfigured state.  Perhaps the code in usb_hub_release_port() and 
usb_hub_release_all_ports() needs to be changed; perhaps these routines 
should select and install a configuration if the child device isn't 
already configured.

For the time being, the safest approach is to release the port first 
and then turn on the power.  Of course, that's not ideal either because 
it would mean changing the power setting for a port you don't own.  But 
right now that's the best you can do.

> };
> 
> Program B actually is a script:
> 
> {
> while [ "$i" -lt 10000 ];
> do
> - Check Flash Drive is there (eg, cat /proc/partitions);
> - Send "turn off" command;
> - Wait 5 seconds, and check if Flash Drive has gone;
> - Send "turn on" command;
> - i=`expr $i + 1`;
> done
> terminate program A;
> };
> 
> I need to find communication solution between program A and script B.
> Or would you have any suggestions to design such kinds of test case?

Normally programs like this would communicate by a pipe or a Unix 
socket.  One way to make this work is for program B to run A in the 
background before the "while" loop starts, so that B could control 
the standard input and output files that A uses.  That's probably the 
approach I would take.

Alan Stern

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox