Skip to contentSkip to conversation

usb: gadget: udc: lpc32xx: allocate descriptor with GFP_ATOMIC

PATCH Superseded Alexandre Belloni 4 participants 6 messages May 10, 2019 – Jun 18, 2019

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: gadget: udc: lpc32xx: allocate descriptor with GFP_ATOMIC

Gadget drivers may queue request in interrupt context. This would lead to a descriptor allocation in that context. In that case we would hit BUG_ON(in_interrupt()) in __get_vm_area_node.

---
 drivers/usb/gadget/udc/lpc32xx_udc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/udc/lpc32xx_udc.c +1 -1
index d8f1c60793ed..b706d9c85a35 100644
@@ -938,7 +938,7 @@ static struct lpc32xx_usbd_dd_gad *udc_dd_alloc(struct lpc32xx_udc *udc)
 	struct lpc32xx_usbd_dd_gad	*dd;
 
 	dd = (struct lpc32xx_usbd_dd_gad *) dma_pool_alloc(
-			udc->dd_cache, (GFP_KERNEL | GFP_DMA), &dma);
+			udc->dd_cache, (GFP_ATOMIC | GFP_DMA), &dma);
 	if (dd)
 		dd->this_dma = dma;
 
Signature · 1 line
2.21.0
#1 lore raw
Quoted 3 lines · Alexandre Belloni

Gadget drivers may queue request in interrupt context. This would lead to a descriptor allocation in that context. In that case we would hit BUG_ON(in_interrupt()) in __get_vm_area_node.

[]

drivers/usb/gadget/udc/lpc32xx_udc.c

Quoted 1 line
drivers/usb/gadget/udc/lpc32xx_udc.c +0 -0

[]

drivers/usb/gadget/udc/lpc32xx_udc.c static struct lpc32xx_usbd_dd_gad *udc_dd_alloc(struct lpc32xx_udc *udc) · line 941

Quoted 6 lines
drivers/usb/gadget/udc/lpc32xx_udc.c +1 -1
@@ -938,7 +938,7 @@ static struct lpc32xx_usbd_dd_gad *udc_dd_alloc(struct lpc32xx_udc *udc)
 	struct lpc32xx_usbd_dd_gad	*dd;
 
 	dd = (struct lpc32xx_usbd_dd_gad *) dma_pool_alloc(
-			udc->dd_cache, (GFP_KERNEL | GFP_DMA), &dma);
+			udc->dd_cache, (GFP_ATOMIC | GFP_DMA), &dma);

trivia:

This could fit nicely on a single line without the unnecessary cast and the unnecessary parentheses around the GFP_ types.

Tested-by on v1 1/1
#2 lore raw
In reply to Alexandre Belloni

Tested with a board containing LPC3250 SOC and STOTG04 PHY by using serial gadget.

Needed patch series starting with "[PATCH 0/5] usb: gadget: udc: lpc32xx: add stotg04 phy support" also.

Regards,
James Grant.

Quoted 14 lines · Alexandre Belloni

Gadget drivers may queue request in interrupt context. This would lead to a descriptor allocation in that context. In that case we would hit BUG_ON(in_interrupt()) in __get_vm_area_node.

---
  drivers/usb/gadget/udc/lpc32xx_udc.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/udc/lpc32xx_udc.c +0 -0
index d8f1c60793ed..b706d9c85a35 100644

drivers/usb/gadget/udc/lpc32xx_udc.c static struct lpc32xx_usbd_dd_gad *udc_dd_alloc(struct lpc32xx_udc *udc) · line 944

Quoted 8 lines
drivers/usb/gadget/udc/lpc32xx_udc.c +1 -1
@@ -938,7 +938,7 @@ static struct lpc32xx_usbd_dd_gad *udc_dd_alloc(struct lpc32xx_udc *udc)
  	struct lpc32xx_usbd_dd_gad	*dd;
 
  	dd = (struct lpc32xx_usbd_dd_gad *) dma_pool_alloc(
-			udc->dd_cache, (GFP_KERNEL | GFP_DMA), &dma);
+			udc->dd_cache, (GFP_ATOMIC | GFP_DMA), &dma);
  	if (dd)
  		dd->this_dma = dma;
 

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#3 lore raw
In reply to Alexandre Belloni
Quoted 14 lines · Alexandre Belloni

Gadget drivers may queue request in interrupt context. This would lead to a descriptor allocation in that context. In that case we would hit BUG_ON(in_interrupt()) in __get_vm_area_node.

---
 drivers/usb/gadget/udc/lpc32xx_udc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/udc/lpc32xx_udc.c +0 -0
index d8f1c60793ed..b706d9c85a35 100644

drivers/usb/gadget/udc/lpc32xx_udc.c static struct lpc32xx_usbd_dd_gad *udc_dd_alloc(struct lpc32xx_udc *udc) · line 941

Quoted 5 lines
drivers/usb/gadget/udc/lpc32xx_udc.c +1 -1
@@ -938,7 +938,7 @@ static struct lpc32xx_usbd_dd_gad *udc_dd_alloc(struct lpc32xx_udc *udc)
 	struct lpc32xx_usbd_dd_gad	*dd;
 
 	dd = (struct lpc32xx_usbd_dd_gad *) dma_pool_alloc(
-			udc->dd_cache, (GFP_KERNEL | GFP_DMA), &dma);
+			udc->dd_cache, (GFP_ATOMIC | GFP_DMA), &dma);

doesn't apply:

checking file drivers/usb/gadget/udc/lpc32xx_udc.c Hunk #1 FAILED at 938.

Signature · 1 line
balbi
#4 lore raw

Hi,

Quoted 18 lines · Felipe Balbi
Quoted 16 lines · Alexandre Belloni

Gadget drivers may queue request in interrupt context. This would lead to a descriptor allocation in that context. In that case we would hit BUG_ON(in_interrupt()) in __get_vm_area_node.

---
 drivers/usb/gadget/udc/lpc32xx_udc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/udc/lpc32xx_udc.c +0 -0
index d8f1c60793ed..b706d9c85a35 100644
@@ -938,7 +938,7 @@ static struct lpc32xx_usbd_dd_gad *udc_dd_alloc(struct lpc32xx_udc *udc)
 	struct lpc32xx_usbd_dd_gad	*dd;
 
Quoted 9 lines

drivers/usb/gadget/udc/lpc32xx_udc.c static struct lpc32xx_usbd_dd_gad *udc_dd_alloc(struct lpc32xx_udc *udc) · line 941

Quoted 3 lines
drivers/usb/gadget/udc/lpc32xx_udc.c +1 -1
 	dd = (struct lpc32xx_usbd_dd_gad *) dma_pool_alloc(
-			udc->dd_cache, (GFP_KERNEL | GFP_DMA), &dma);
+			udc->dd_cache, (GFP_ATOMIC | GFP_DMA), &dma);

doesn't apply:

checking file drivers/usb/gadget/udc/lpc32xx_udc.c Hunk #1 FAILED at 938.

You already applied it for v5.2-rc5

Signature · 3 lines
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#5 lore raw

Hi,

Quoted 27 lines · Alexandre Belloni

Hi,

Quoted 24 lines · Felipe Balbi
Quoted 14 lines · Alexandre Belloni

Gadget drivers may queue request in interrupt context. This would lead to a descriptor allocation in that context. In that case we would hit BUG_ON(in_interrupt()) in __get_vm_area_node.

---
 drivers/usb/gadget/udc/lpc32xx_udc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/udc/lpc32xx_udc.c +0 -0
index d8f1c60793ed..b706d9c85a35 100644

drivers/usb/gadget/udc/lpc32xx_udc.c static struct lpc32xx_usbd_dd_gad *udc_dd_alloc(struct lpc32xx_udc *udc) · line 941

Quoted 5 lines
drivers/usb/gadget/udc/lpc32xx_udc.c +1 -1
@@ -938,7 +938,7 @@ static struct lpc32xx_usbd_dd_gad *udc_dd_alloc(struct lpc32xx_udc *udc)
 	struct lpc32xx_usbd_dd_gad	*dd;
 
 	dd = (struct lpc32xx_usbd_dd_gad *) dma_pool_alloc(
-			udc->dd_cache, (GFP_KERNEL | GFP_DMA), &dma);
+			udc->dd_cache, (GFP_ATOMIC | GFP_DMA), &dma);

doesn't apply:

Quoted 5 lines
Quoted 3 lines

checking file drivers/usb/gadget/udc/lpc32xx_udc.c Hunk #1 FAILED at 938.

You already applied it for v5.2-rc5

d'oh!

Guess I haven't looked at my inbox in a while :-p

thanks

Signature · 1 line
balbi