All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] usb: isp1760: cleanups and sleep in atomic
@ 2021-07-27 10:05 Rui Miguel Silva
  2021-07-27 10:05 ` [PATCH 1/3] usb: isp1760: remove debug message as error Rui Miguel Silva
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Rui Miguel Silva @ 2021-07-27 10:05 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Dan Carpenter; +Cc: linux-usb, Rui Miguel Silva

This series includes one debug message cleanup, fix in the error
handling of the cache pointers and a field register poll fix in sleep
in atomic context reported by Dan Carpenter.

Cheers,
  Rui

general note: beginning next week and for two weeks I will have
limited access to email.

Rui Miguel Silva (3):
  usb: isp1760: remove debug message as error
  usb: isp1760: do not sleep in field register poll
  usb: isp1760: rework cache initialization error handling

 drivers/usb/isp1760/isp1760-hcd.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

-- 
2.32.0


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

* [PATCH 1/3] usb: isp1760: remove debug message as error
  2021-07-27 10:05 [PATCH 0/3] usb: isp1760: cleanups and sleep in atomic Rui Miguel Silva
@ 2021-07-27 10:05 ` Rui Miguel Silva
  2021-07-27 10:05 ` [PATCH 2/3] usb: isp1760: do not sleep in field register poll Rui Miguel Silva
  2021-07-27 10:05 ` [PATCH 3/3] usb: isp1760: rework cache initialization error handling Rui Miguel Silva
  2 siblings, 0 replies; 8+ messages in thread
From: Rui Miguel Silva @ 2021-07-27 10:05 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Dan Carpenter; +Cc: linux-usb, Rui Miguel Silva

Remove debug message leftover from the boot error buffer.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
---
 drivers/usb/isp1760/isp1760-hcd.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/usb/isp1760/isp1760-hcd.c b/drivers/usb/isp1760/isp1760-hcd.c
index 27168b4a4ef2..a745c4c2b773 100644
--- a/drivers/usb/isp1760/isp1760-hcd.c
+++ b/drivers/usb/isp1760/isp1760-hcd.c
@@ -733,7 +733,6 @@ static int isp1760_hc_setup(struct usb_hcd *hcd)
 
 	/* Change bus pattern */
 	scratch = isp1760_hcd_read(hcd, HC_CHIP_ID_HIGH);
-	dev_err(hcd->self.controller, "Scratch test 0x%08x\n", scratch);
 	scratch = isp1760_hcd_read(hcd, HC_SCRATCH);
 	if (scratch != pattern) {
 		dev_err(hcd->self.controller, "Scratch test failed. 0x%08x\n", scratch);
-- 
2.32.0


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

* [PATCH 2/3] usb: isp1760: do not sleep in field register poll
  2021-07-27 10:05 [PATCH 0/3] usb: isp1760: cleanups and sleep in atomic Rui Miguel Silva
  2021-07-27 10:05 ` [PATCH 1/3] usb: isp1760: remove debug message as error Rui Miguel Silva
@ 2021-07-27 10:05 ` Rui Miguel Silva
  2021-09-24 15:35   ` Rui Miguel Silva
  2021-07-27 10:05 ` [PATCH 3/3] usb: isp1760: rework cache initialization error handling Rui Miguel Silva
  2 siblings, 1 reply; 8+ messages in thread
From: Rui Miguel Silva @ 2021-07-27 10:05 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Dan Carpenter; +Cc: linux-usb, Rui Miguel Silva

When polling for a setup or clear of a register field we were sleeping
in atomic context but using a very tight sleep interval.

Since the use cases for this poll mechanism are only in setup and
stop paths, and in practice this poll is not used most of the times
but needs to be there to comply to hardware setup times, remove the
sleep time and make the poll loop tighter.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
---
 drivers/usb/isp1760/isp1760-hcd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/isp1760/isp1760-hcd.c b/drivers/usb/isp1760/isp1760-hcd.c
index a745c4c2b773..a018394d54f8 100644
--- a/drivers/usb/isp1760/isp1760-hcd.c
+++ b/drivers/usb/isp1760/isp1760-hcd.c
@@ -250,7 +250,7 @@ static int isp1760_hcd_set_and_wait(struct usb_hcd *hcd, u32 field,
 	isp1760_hcd_set(hcd, field);
 
 	return regmap_field_read_poll_timeout(priv->fields[field], val,
-					      val, 10, timeout_us);
+					      val, 0, timeout_us);
 }
 
 static int isp1760_hcd_set_and_wait_swap(struct usb_hcd *hcd, u32 field,
@@ -262,7 +262,7 @@ static int isp1760_hcd_set_and_wait_swap(struct usb_hcd *hcd, u32 field,
 	isp1760_hcd_set(hcd, field);
 
 	return regmap_field_read_poll_timeout(priv->fields[field], val,
-					      !val, 10, timeout_us);
+					      !val, 0, timeout_us);
 }
 
 static int isp1760_hcd_clear_and_wait(struct usb_hcd *hcd, u32 field,
@@ -274,7 +274,7 @@ static int isp1760_hcd_clear_and_wait(struct usb_hcd *hcd, u32 field,
 	isp1760_hcd_clear(hcd, field);
 
 	return regmap_field_read_poll_timeout(priv->fields[field], val,
-					      !val, 10, timeout_us);
+					      !val, 0, timeout_us);
 }
 
 static bool isp1760_hcd_is_set(struct usb_hcd *hcd, u32 field)
-- 
2.32.0


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

* [PATCH 3/3] usb: isp1760: rework cache initialization error handling
  2021-07-27 10:05 [PATCH 0/3] usb: isp1760: cleanups and sleep in atomic Rui Miguel Silva
  2021-07-27 10:05 ` [PATCH 1/3] usb: isp1760: remove debug message as error Rui Miguel Silva
  2021-07-27 10:05 ` [PATCH 2/3] usb: isp1760: do not sleep in field register poll Rui Miguel Silva
@ 2021-07-27 10:05 ` Rui Miguel Silva
  2 siblings, 0 replies; 8+ messages in thread
From: Rui Miguel Silva @ 2021-07-27 10:05 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Dan Carpenter; +Cc: linux-usb, Rui Miguel Silva

If we fail to create qtd cache we were not destroying the
urb_listitem, rework the error handling logic to cope with that.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
---
 drivers/usb/isp1760/isp1760-hcd.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/isp1760/isp1760-hcd.c b/drivers/usb/isp1760/isp1760-hcd.c
index a018394d54f8..825be736be33 100644
--- a/drivers/usb/isp1760/isp1760-hcd.c
+++ b/drivers/usb/isp1760/isp1760-hcd.c
@@ -2527,17 +2527,23 @@ int __init isp1760_init_kmem_once(void)
 			SLAB_MEM_SPREAD, NULL);
 
 	if (!qtd_cachep)
-		return -ENOMEM;
+		goto destroy_urb_listitem;
 
 	qh_cachep = kmem_cache_create("isp1760_qh", sizeof(struct isp1760_qh),
 			0, SLAB_TEMPORARY | SLAB_MEM_SPREAD, NULL);
 
-	if (!qh_cachep) {
-		kmem_cache_destroy(qtd_cachep);
-		return -ENOMEM;
-	}
+	if (!qh_cachep)
+		goto destroy_qtd;
 
 	return 0;
+
+destroy_qtd:
+	kmem_cache_destroy(qtd_cachep);
+
+destroy_urb_listitem:
+	kmem_cache_destroy(urb_listitem_cachep);
+
+	return -ENOMEM;
 }
 
 void isp1760_deinit_kmem_cache(void)
-- 
2.32.0


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

* Re: [PATCH 2/3] usb: isp1760: do not sleep in field register poll
  2021-07-27 10:05 ` [PATCH 2/3] usb: isp1760: do not sleep in field register poll Rui Miguel Silva
@ 2021-09-24 15:35   ` Rui Miguel Silva
  2021-09-24 16:01     ` Greg Kroah-Hartman
  2021-09-26 12:40     ` Greg Kroah-Hartman
  0 siblings, 2 replies; 8+ messages in thread
From: Rui Miguel Silva @ 2021-09-24 15:35 UTC (permalink / raw)
  To: Greg Kroah-Hartman, stable

Hi Greg,
forgot to ask you, can you please merge this one to stable #5.14.y?
At the time I was not sure if it was getting in final 5.14 or not.

It applies clean on top of 5.14.7.
And without it, it triggers BUG sleep in atomic checks.

upstream commit:
41f673183862a1 usb: isp1760: do not sleep in field register poll
https://lore.kernel.org/r/20210727100516.4190681-3-rui.silva@linaro.org

fixes tag:
Fixes: 1da9e1c06873 ("usb: isp1760: move to regmap for register access")

Thanks in advance,
Cheers,
     Rui

On Tue Jul 27, 2021 at 11:05 AM WEST, Rui Miguel Silva wrote:

---- 8< ----------------------------------------------

> When polling for a setup or clear of a register field we were sleeping
> in atomic context but using a very tight sleep interval.
>
> Since the use cases for this poll mechanism are only in setup and
> stop paths, and in practice this poll is not used most of the times
> but needs to be there to comply to hardware setup times, remove the
> sleep time and make the poll loop tighter.
>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
> ---
>  drivers/usb/isp1760/isp1760-hcd.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/usb/isp1760/isp1760-hcd.c b/drivers/usb/isp1760/isp1760-hcd.c
> index a745c4c2b773..a018394d54f8 100644
> --- a/drivers/usb/isp1760/isp1760-hcd.c
> +++ b/drivers/usb/isp1760/isp1760-hcd.c
> @@ -250,7 +250,7 @@ static int isp1760_hcd_set_and_wait(struct usb_hcd *hcd, u32 field,
>  	isp1760_hcd_set(hcd, field);
>  
>  	return regmap_field_read_poll_timeout(priv->fields[field], val,
> -					      val, 10, timeout_us);
> +					      val, 0, timeout_us);
>  }
>  
>  static int isp1760_hcd_set_and_wait_swap(struct usb_hcd *hcd, u32 field,
> @@ -262,7 +262,7 @@ static int isp1760_hcd_set_and_wait_swap(struct usb_hcd *hcd, u32 field,
>  	isp1760_hcd_set(hcd, field);
>  
>  	return regmap_field_read_poll_timeout(priv->fields[field], val,
> -					      !val, 10, timeout_us);
> +					      !val, 0, timeout_us);
>  }
>  
>  static int isp1760_hcd_clear_and_wait(struct usb_hcd *hcd, u32 field,
> @@ -274,7 +274,7 @@ static int isp1760_hcd_clear_and_wait(struct usb_hcd *hcd, u32 field,
>  	isp1760_hcd_clear(hcd, field);
>  
>  	return regmap_field_read_poll_timeout(priv->fields[field], val,
> -					      !val, 10, timeout_us);
> +					      !val, 0, timeout_us);
>  }
>  
>  static bool isp1760_hcd_is_set(struct usb_hcd *hcd, u32 field)
> -- 
> 2.32.0




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

* Re: [PATCH 2/3] usb: isp1760: do not sleep in field register poll
  2021-09-24 15:35   ` Rui Miguel Silva
@ 2021-09-24 16:01     ` Greg Kroah-Hartman
  2021-09-25  9:34       ` Rui Miguel Silva
  2021-09-26 12:40     ` Greg Kroah-Hartman
  1 sibling, 1 reply; 8+ messages in thread
From: Greg Kroah-Hartman @ 2021-09-24 16:01 UTC (permalink / raw)
  To: Rui Miguel Silva; +Cc: stable

On Fri, Sep 24, 2021 at 04:35:40PM +0100, Rui Miguel Silva wrote:
> Hi Greg,
> forgot to ask you, can you please merge this one to stable #5.14.y?
> At the time I was not sure if it was getting in final 5.14 or not.
> 
> It applies clean on top of 5.14.7.
> And without it, it triggers BUG sleep in atomic checks.
> 
> upstream commit:
> 41f673183862a1 usb: isp1760: do not sleep in field register poll
> https://lore.kernel.org/r/20210727100516.4190681-3-rui.silva@linaro.org
> 
> fixes tag:
> Fixes: 1da9e1c06873 ("usb: isp1760: move to regmap for register access")

Sure, will queue it up after this next round of stable kernels are
released in a few days.

thanks,

greg k-h

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

* Re: [PATCH 2/3] usb: isp1760: do not sleep in field register poll
  2021-09-24 16:01     ` Greg Kroah-Hartman
@ 2021-09-25  9:34       ` Rui Miguel Silva
  0 siblings, 0 replies; 8+ messages in thread
From: Rui Miguel Silva @ 2021-09-25  9:34 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: stable

Hey Greg,
On Fri Sep 24, 2021 at 5:01 PM WEST, Greg Kroah-Hartman wrote:

> On Fri, Sep 24, 2021 at 04:35:40PM +0100, Rui Miguel Silva wrote:
> > Hi Greg,
> > forgot to ask you, can you please merge this one to stable #5.14.y?
> > At the time I was not sure if it was getting in final 5.14 or not.
> > 
> > It applies clean on top of 5.14.7.
> > And without it, it triggers BUG sleep in atomic checks.
> > 
> > upstream commit:
> > 41f673183862a1 usb: isp1760: do not sleep in field register poll
> > https://lore.kernel.org/r/20210727100516.4190681-3-rui.silva@linaro.org
> > 
> > fixes tag:
> > Fixes: 1da9e1c06873 ("usb: isp1760: move to regmap for register access")
>
> Sure, will queue it up after this next round of stable kernels are
> released in a few days.

Thanks a lot.

------
Cheers,
     Rui

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

* Re: [PATCH 2/3] usb: isp1760: do not sleep in field register poll
  2021-09-24 15:35   ` Rui Miguel Silva
  2021-09-24 16:01     ` Greg Kroah-Hartman
@ 2021-09-26 12:40     ` Greg Kroah-Hartman
  1 sibling, 0 replies; 8+ messages in thread
From: Greg Kroah-Hartman @ 2021-09-26 12:40 UTC (permalink / raw)
  To: Rui Miguel Silva; +Cc: stable

On Fri, Sep 24, 2021 at 04:35:40PM +0100, Rui Miguel Silva wrote:
> Hi Greg,
> forgot to ask you, can you please merge this one to stable #5.14.y?
> At the time I was not sure if it was getting in final 5.14 or not.
> 
> It applies clean on top of 5.14.7.
> And without it, it triggers BUG sleep in atomic checks.
> 
> upstream commit:
> 41f673183862a1 usb: isp1760: do not sleep in field register poll
> https://lore.kernel.org/r/20210727100516.4190681-3-rui.silva@linaro.org
> 
> fixes tag:
> Fixes: 1da9e1c06873 ("usb: isp1760: move to regmap for register access")
> 
> Thanks in advance,

Now queued up, thanks.

greg k-h

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

end of thread, other threads:[~2021-09-26 12:40 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-27 10:05 [PATCH 0/3] usb: isp1760: cleanups and sleep in atomic Rui Miguel Silva
2021-07-27 10:05 ` [PATCH 1/3] usb: isp1760: remove debug message as error Rui Miguel Silva
2021-07-27 10:05 ` [PATCH 2/3] usb: isp1760: do not sleep in field register poll Rui Miguel Silva
2021-09-24 15:35   ` Rui Miguel Silva
2021-09-24 16:01     ` Greg Kroah-Hartman
2021-09-25  9:34       ` Rui Miguel Silva
2021-09-26 12:40     ` Greg Kroah-Hartman
2021-07-27 10:05 ` [PATCH 3/3] usb: isp1760: rework cache initialization error handling Rui Miguel Silva

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.