linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* drivers: usb: host: Fix GFP_KERNEL in spinlock context
@ 2017-12-22  5:49 shrikant.maurya
  0 siblings, 0 replies; 3+ messages in thread
From: shrikant.maurya @ 2017-12-22  5:49 UTC (permalink / raw)
  To: ok, gregkh
  Cc: linux-kernel, linux-usb, Shrikant Maurya, Suniel Mahesh,
	Raghu Bharadwaj, Karthik Tummala

From: Shrikant Maurya <shrikant.maurya@techveda.org>

As reported by Jia-Ju Bai (https://lkml.org/lkml/2017/12/11/872):
API's are using GFP_KERNEL to allocate memory, which may sleep.
To ensure atomicity such allocations must be avoided in critical
sections under spinlock.
Fixed by moving part of the code which is using GFP_KERNEL for
memory allocation out of spinlock.

Reported-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: Shrikant Maurya <shrikant.maurya@techveda.org>
Signed-off-by: Suniel Mahesh <sunil.m@techveda.org>
Signed-off-by: Raghu Bharadwaj <raghu@techveda.org>
Signed-off-by: Karthik Tummala <karthik@techveda.org>
---
Note:
- trace of device_init_wakeup() leads to creation of a struct
  wakeup_source object and addition of the object to the list
  of wakeup sources. While allocating wakeup_source object, API
  is using GFP_KERNEL. This particular section is removed out of
  spinlock.
- Changeset was compile tested and built(ARCH=arm) on linux-next
  (latest).
- No build issues reported.
- Changeset was not tested on hardware.
- Please discard this changeset, if this is not
  making the code any better.
---
 drivers/usb/host/isp116x-hcd.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c
index 5f9234b..47334e8 100644
--- a/drivers/usb/host/isp116x-hcd.c
+++ b/drivers/usb/host/isp116x-hcd.c
@@ -1319,6 +1319,11 @@ static int isp116x_start(struct usb_hcd *hcd)
 	u32 val;
 	unsigned long flags;
 
+	if (board->remote_wakeup_enable) {
+		if (!device_can_wakeup(hcd->self.controller))
+			device_init_wakeup(hcd->self.controller, 1);
+	}
+
 	spin_lock_irqsave(&isp116x->lock, flags);
 
 	/* clear interrupt status and disable all interrupt sources */
@@ -1369,11 +1374,8 @@ static int isp116x_start(struct usb_hcd *hcd)
 	isp116x->rhdescb = isp116x_read_reg32(isp116x, HCRHDESCB);
 
 	val = 0;
-	if (board->remote_wakeup_enable) {
-		if (!device_can_wakeup(hcd->self.controller))
-			device_init_wakeup(hcd->self.controller, 1);
+	if (board->remote_wakeup_enable)
 		val |= RH_HS_DRWE;
-	}
 	isp116x_write_reg32(isp116x, HCRHSTATUS, val);
 	isp116x->rhstatus = isp116x_read_reg32(isp116x, HCRHSTATUS);
 

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

* drivers: usb: host: Fix GFP_KERNEL in spinlock context
@ 2017-12-22  7:13 Greg Kroah-Hartman
  0 siblings, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2017-12-22  7:13 UTC (permalink / raw)
  To: shrikant.maurya
  Cc: ok, linux-kernel, linux-usb, Suniel Mahesh, Raghu Bharadwaj,
	Karthik Tummala

On Fri, Dec 22, 2017 at 11:19:24AM +0530, shrikant.maurya@techveda.org wrote:
> From: Shrikant Maurya <shrikant.maurya@techveda.org>
> 
> As reported by Jia-Ju Bai (https://lkml.org/lkml/2017/12/11/872):
> API's are using GFP_KERNEL to allocate memory, which may sleep.
> To ensure atomicity such allocations must be avoided in critical
> sections under spinlock.
> Fixed by moving part of the code which is using GFP_KERNEL for
> memory allocation out of spinlock.
> 
> Reported-by: Jia-Ju Bai <baijiaju1990@gmail.com>
> Signed-off-by: Shrikant Maurya <shrikant.maurya@techveda.org>
> Signed-off-by: Suniel Mahesh <sunil.m@techveda.org>
> Signed-off-by: Raghu Bharadwaj <raghu@techveda.org>
> Signed-off-by: Karthik Tummala <karthik@techveda.org>
> ---
> Note:
> - trace of device_init_wakeup() leads to creation of a struct
>   wakeup_source object and addition of the object to the list
>   of wakeup sources. While allocating wakeup_source object, API
>   is using GFP_KERNEL. This particular section is removed out of
>   spinlock.
> - Changeset was compile tested and built(ARCH=arm) on linux-next
>   (latest).
> - No build issues reported.
> - Changeset was not tested on hardware.

No one was able to test on the hardware itself?  Ideally I'd like to see
that happen to verify nothing breaks here.  No one has this chip on any
devices?

thanks,

greg k-h
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* drivers: usb: host: Fix GFP_KERNEL in spinlock context
@ 2017-12-22  7:50 shrikant.maurya
  0 siblings, 0 replies; 3+ messages in thread
From: shrikant.maurya @ 2017-12-22  7:50 UTC (permalink / raw)
  To: Greg KH
  Cc: ok, linux-kernel, linux-usb, Suniel Mahesh, Raghu Bharadwaj,
	Karthik Tummala

On Friday 22 December 2017 12:43 PM, Greg KH wrote:
> On Fri, Dec 22, 2017 at 11:19:24AM +0530, shrikant.maurya@techveda.org wrote:
>> From: Shrikant Maurya <shrikant.maurya@techveda.org>
>>
>> As reported by Jia-Ju Bai (https://lkml.org/lkml/2017/12/11/872):
>> API's are using GFP_KERNEL to allocate memory, which may sleep.
>> To ensure atomicity such allocations must be avoided in critical
>> sections under spinlock.
>> Fixed by moving part of the code which is using GFP_KERNEL for
>> memory allocation out of spinlock.
>>
>> Reported-by: Jia-Ju Bai <baijiaju1990@gmail.com>
>> Signed-off-by: Shrikant Maurya <shrikant.maurya@techveda.org>
>> Signed-off-by: Suniel Mahesh <sunil.m@techveda.org>
>> Signed-off-by: Raghu Bharadwaj <raghu@techveda.org>
>> Signed-off-by: Karthik Tummala <karthik@techveda.org>
>> ---
>> Note:
>> - trace of device_init_wakeup() leads to creation of a struct
>>   wakeup_source object and addition of the object to the list
>>   of wakeup sources. While allocating wakeup_source object, API
>>   is using GFP_KERNEL. This particular section is removed out of
>>   spinlock.
>> - Changeset was compile tested and built(ARCH=arm) on linux-next
>>   (latest).
>> - No build issues reported.
>> - Changeset was not tested on hardware.
> No one was able to test on the hardware itself?  Ideally I'd like to see
> that happen to verify nothing breaks here.  No one has this chip on any
> devices?
>
> thanks,
Sorry Greg, we dont have the chip / hardware, and we are aware that it should
be hardware tested. we were looking at the software aspect.

thanks,
shrikanth
> greg k-h
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2017-12-22  7:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-22  7:13 drivers: usb: host: Fix GFP_KERNEL in spinlock context Greg Kroah-Hartman
  -- strict thread matches above, loose matches on Subject: below --
2017-12-22  7:50 shrikant.maurya
2017-12-22  5:49 shrikant.maurya

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