All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/7] usb: gadget: gr_udc: OF and ep.maxpacket_limit improvements and fix of GFP_KERNEL in atomic context
@ 2014-03-27 15:15 ` Andreas Larsson
  0 siblings, 0 replies; 16+ messages in thread
From: Andreas Larsson @ 2014-03-27 15:15 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman
  Cc: Mark Rutland, Dan Carpenter, linux-usb, linux-kernel, devicetree,
	software

This patchset:
 - Adds some OF related improvements suggested by Mark
   Rutland.
 - Adds ep.maxpacket_limit to the debugfs file and adds a check if
   gr_ep_enable is called with a maxpacket value greater than
   ep.maxpacket_limit.
 - Fixes a bug where GFP_KERNEL was used in atomic context

Andreas Larsson (7):
  usb: gadget: gr_udc: Make struct platform_device variable name
    clearer and use platform_set/get_drvdata
  usb: gadget: gr_udc: Expand devicetree documentation
  usb: gadget: gr_udc: Use platform_get_irq instead of
    irq_of_parse_and_map
  usb: gadget: gr_udc: Use of_property_read_u32_index to access arrays
  usb: gadget: gr_udc: Add ep.maxpacket_limit to debugfs information
  usb: gadget: gr_udc: Return error code when trying to set
    ep.maxpacket > ep.maxpacket_limit
  usb: gadget: gr_udc: Use GFP_ATOMIC when allocating under help
    spinlock

 Documentation/devicetree/bindings/usb/gr-udc.txt |   22 +++++----
 drivers/usb/gadget/gr_udc.c                      |   53 ++++++++++++----------
 2 files changed, 42 insertions(+), 33 deletions(-)

-- 
1.7.10.4


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

* [PATCH v2 0/7] usb: gadget: gr_udc: OF and ep.maxpacket_limit improvements and fix of GFP_KERNEL in atomic context
@ 2014-03-27 15:15 ` Andreas Larsson
  0 siblings, 0 replies; 16+ messages in thread
From: Andreas Larsson @ 2014-03-27 15:15 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman
  Cc: Mark Rutland, Dan Carpenter, linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	software-FkzTOoA/JUlBDgjK7y7TUQ

This patchset:
 - Adds some OF related improvements suggested by Mark
   Rutland.
 - Adds ep.maxpacket_limit to the debugfs file and adds a check if
   gr_ep_enable is called with a maxpacket value greater than
   ep.maxpacket_limit.
 - Fixes a bug where GFP_KERNEL was used in atomic context

Andreas Larsson (7):
  usb: gadget: gr_udc: Make struct platform_device variable name
    clearer and use platform_set/get_drvdata
  usb: gadget: gr_udc: Expand devicetree documentation
  usb: gadget: gr_udc: Use platform_get_irq instead of
    irq_of_parse_and_map
  usb: gadget: gr_udc: Use of_property_read_u32_index to access arrays
  usb: gadget: gr_udc: Add ep.maxpacket_limit to debugfs information
  usb: gadget: gr_udc: Return error code when trying to set
    ep.maxpacket > ep.maxpacket_limit
  usb: gadget: gr_udc: Use GFP_ATOMIC when allocating under help
    spinlock

 Documentation/devicetree/bindings/usb/gr-udc.txt |   22 +++++----
 drivers/usb/gadget/gr_udc.c                      |   53 ++++++++++++----------
 2 files changed, 42 insertions(+), 33 deletions(-)

-- 
1.7.10.4

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

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

* [PATCH v2 1/7] usb: gadget: gr_udc: Make struct platform_device variable name clearer and use platform_set/get_drvdata
  2014-03-27 15:15 ` Andreas Larsson
  (?)
@ 2014-03-27 15:15 ` Andreas Larsson
  -1 siblings, 0 replies; 16+ messages in thread
From: Andreas Larsson @ 2014-03-27 15:15 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman
  Cc: Mark Rutland, Dan Carpenter, linux-usb, linux-kernel, devicetree,
	software

Rename struct platform_device pointers from ofdev to pdev for clarity.
Suggested by Mark Rutland.

Signed-off-by: Andreas Larsson <andreas@gaisler.com>
---
Differences since v1: use platform_set/get_drvdata

 drivers/usb/gadget/gr_udc.c |   18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/gadget/gr_udc.c b/drivers/usb/gadget/gr_udc.c
index f984ee7..ae5bebe 100644
--- a/drivers/usb/gadget/gr_udc.c
+++ b/drivers/usb/gadget/gr_udc.c
@@ -2065,9 +2065,9 @@ static int gr_udc_init(struct gr_udc *dev)
 	return 0;
 }
 
-static int gr_remove(struct platform_device *ofdev)
+static int gr_remove(struct platform_device *pdev)
 {
-	struct gr_udc *dev = dev_get_drvdata(&ofdev->dev);
+	struct gr_udc *dev = platform_get_drvdata(pdev);
 
 	if (dev->added)
 		usb_del_gadget_udc(&dev->gadget); /* Shuts everything down */
@@ -2077,7 +2077,7 @@ static int gr_remove(struct platform_device *ofdev)
 	gr_dfs_delete(dev);
 	if (dev->desc_pool)
 		dma_pool_destroy(dev->desc_pool);
-	dev_set_drvdata(&ofdev->dev, NULL);
+	platform_set_drvdata(pdev, NULL);
 
 	gr_free_request(&dev->epi[0].ep, &dev->ep0reqi->req);
 	gr_free_request(&dev->epo[0].ep, &dev->ep0reqo->req);
@@ -2090,7 +2090,7 @@ static int gr_request_irq(struct gr_udc *dev, int irq)
 					 IRQF_SHARED, driver_name, dev);
 }
 
-static int gr_probe(struct platform_device *ofdev)
+static int gr_probe(struct platform_device *pdev)
 {
 	struct gr_udc *dev;
 	struct resource *res;
@@ -2098,12 +2098,12 @@ static int gr_probe(struct platform_device *ofdev)
 	int retval;
 	u32 status;
 
-	dev = devm_kzalloc(&ofdev->dev, sizeof(*dev), GFP_KERNEL);
+	dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
 	if (!dev)
 		return -ENOMEM;
-	dev->dev = &ofdev->dev;
+	dev->dev = &pdev->dev;
 
-	res = platform_get_resource(ofdev, IORESOURCE_MEM, 0);
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	regs = devm_ioremap_resource(dev->dev, res);
 	if (IS_ERR(regs))
 		return PTR_ERR(regs);
@@ -2132,7 +2132,7 @@ static int gr_probe(struct platform_device *ofdev)
 	spin_lock_init(&dev->lock);
 	dev->regs = regs;
 
-	dev_set_drvdata(&ofdev->dev, dev);
+	platform_set_drvdata(pdev, dev);
 
 	/* Determine number of endpoints and data interface mode */
 	status = gr_read32(&dev->regs->status);
@@ -2204,7 +2204,7 @@ out:
 	spin_unlock(&dev->lock);
 
 	if (retval)
-		gr_remove(ofdev);
+		gr_remove(pdev);
 
 	return retval;
 }
-- 
1.7.10.4


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

* [PATCH v2 2/7] usb: gadget: gr_udc: Expand devicetree documentation
@ 2014-03-27 15:15   ` Andreas Larsson
  0 siblings, 0 replies; 16+ messages in thread
From: Andreas Larsson @ 2014-03-27 15:15 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman
  Cc: Mark Rutland, Dan Carpenter, linux-usb, linux-kernel, devicetree,
	software

Provide more information on the two different interrupt cases and more
information of endpoint buffer sizes. Suggested by Mark Rutland.

Signed-off-by: Andreas Larsson <andreas@gaisler.com>
---
Differences since v1: none

 Documentation/devicetree/bindings/usb/gr-udc.txt |   22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/gr-udc.txt b/Documentation/devicetree/bindings/usb/gr-udc.txt
index 0c5118f..e944522 100644
--- a/Documentation/devicetree/bindings/usb/gr-udc.txt
+++ b/Documentation/devicetree/bindings/usb/gr-udc.txt
@@ -12,17 +12,23 @@ Required properties:
 
 - reg : Address and length of the register set for the device
 
-- interrupts : Interrupt numbers for this device
+- interrupts : Interrupt numbers for this device. Either one interrupt number
+	for all interrupts, or one for status related interrupts, one for IN
+	endpoint related interrupts and one for OUT endpoint related interrupts.
 
 Optional properties:
 
-- epobufsizes : An array of buffer sizes for OUT endpoints. If the property is
-	not present, or for endpoints outside of the array, 1024 is assumed by
-	the driver.
-
-- epibufsizes : An array of buffer sizes for IN endpoints. If the property is
-	not present, or for endpoints outside of the array, 1024 is assumed by
-	the driver.
+- epobufsizes : Array of buffer sizes for OUT endpoints when they differ
+	from the default size of 1024. The array is indexed by the OUT endpoint
+	number. If the property is present it typically contains one entry for
+	each OUT endpoint of the core. Fewer entries overrides the default sizes
+	only for as many endpoints as the array contains.
+
+- epibufsizes : Array of buffer sizes for IN endpoints when they differ
+	from the default size of 1024. The array is indexed by the IN endpoint
+	number. If the property is present it typically contains one entry for
+	each IN endpoint of the core. Fewer entries overrides the default sizes
+	only for as many endpoints as the array contains.
 
 For further information look in the documentation for the GLIB IP core library:
 http://www.gaisler.com/products/grlib/grip.pdf
-- 
1.7.10.4


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

* [PATCH v2 2/7] usb: gadget: gr_udc: Expand devicetree documentation
@ 2014-03-27 15:15   ` Andreas Larsson
  0 siblings, 0 replies; 16+ messages in thread
From: Andreas Larsson @ 2014-03-27 15:15 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman
  Cc: Mark Rutland, Dan Carpenter, linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	software-FkzTOoA/JUlBDgjK7y7TUQ

Provide more information on the two different interrupt cases and more
information of endpoint buffer sizes. Suggested by Mark Rutland.

Signed-off-by: Andreas Larsson <andreas-FkzTOoA/JUlBDgjK7y7TUQ@public.gmane.org>
---
Differences since v1: none

 Documentation/devicetree/bindings/usb/gr-udc.txt |   22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/gr-udc.txt b/Documentation/devicetree/bindings/usb/gr-udc.txt
index 0c5118f..e944522 100644
--- a/Documentation/devicetree/bindings/usb/gr-udc.txt
+++ b/Documentation/devicetree/bindings/usb/gr-udc.txt
@@ -12,17 +12,23 @@ Required properties:
 
 - reg : Address and length of the register set for the device
 
-- interrupts : Interrupt numbers for this device
+- interrupts : Interrupt numbers for this device. Either one interrupt number
+	for all interrupts, or one for status related interrupts, one for IN
+	endpoint related interrupts and one for OUT endpoint related interrupts.
 
 Optional properties:
 
-- epobufsizes : An array of buffer sizes for OUT endpoints. If the property is
-	not present, or for endpoints outside of the array, 1024 is assumed by
-	the driver.
-
-- epibufsizes : An array of buffer sizes for IN endpoints. If the property is
-	not present, or for endpoints outside of the array, 1024 is assumed by
-	the driver.
+- epobufsizes : Array of buffer sizes for OUT endpoints when they differ
+	from the default size of 1024. The array is indexed by the OUT endpoint
+	number. If the property is present it typically contains one entry for
+	each OUT endpoint of the core. Fewer entries overrides the default sizes
+	only for as many endpoints as the array contains.
+
+- epibufsizes : Array of buffer sizes for IN endpoints when they differ
+	from the default size of 1024. The array is indexed by the IN endpoint
+	number. If the property is present it typically contains one entry for
+	each IN endpoint of the core. Fewer entries overrides the default sizes
+	only for as many endpoints as the array contains.
 
 For further information look in the documentation for the GLIB IP core library:
 http://www.gaisler.com/products/grlib/grip.pdf
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v2 3/7] usb: gadget: gr_udc: Use platform_get_irq instead of irq_of_parse_and_map
  2014-03-27 15:15 ` Andreas Larsson
                   ` (2 preceding siblings ...)
  (?)
@ 2014-03-27 15:15 ` Andreas Larsson
  -1 siblings, 0 replies; 16+ messages in thread
From: Andreas Larsson @ 2014-03-27 15:15 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman
  Cc: Mark Rutland, Dan Carpenter, linux-usb, linux-kernel, devicetree,
	software

Use platform_get_irq as no mapping needs to be done. No functional difference
for SPARC which is the typical environment for the driver though. Suggested by
Mark Rutland.

Signed-off-by: Andreas Larsson <andreas@gaisler.com>
---
Differences since v1: none

 drivers/usb/gadget/gr_udc.c |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/gadget/gr_udc.c b/drivers/usb/gadget/gr_udc.c
index ae5bebe..7a99254 100644
--- a/drivers/usb/gadget/gr_udc.c
+++ b/drivers/usb/gadget/gr_udc.c
@@ -2108,20 +2108,22 @@ static int gr_probe(struct platform_device *pdev)
 	if (IS_ERR(regs))
 		return PTR_ERR(regs);
 
-	dev->irq = irq_of_parse_and_map(dev->dev->of_node, 0);
-	if (!dev->irq) {
+	dev->irq = platform_get_irq(pdev, 0);
+	if (dev->irq <= 0) {
 		dev_err(dev->dev, "No irq found\n");
 		return -ENODEV;
 	}
 
 	/* Some core configurations has separate irqs for IN and OUT events */
-	dev->irqi = irq_of_parse_and_map(dev->dev->of_node, 1);
-	if (dev->irqi) {
-		dev->irqo = irq_of_parse_and_map(dev->dev->of_node, 2);
-		if (!dev->irqo) {
+	dev->irqi = platform_get_irq(pdev, 1);
+	if (dev->irqi > 0) {
+		dev->irqo = platform_get_irq(pdev, 2);
+		if (dev->irqo <= 0) {
 			dev_err(dev->dev, "Found irqi but not irqo\n");
 			return -ENODEV;
 		}
+	} else {
+		dev->irqi = 0;
 	}
 
 	dev->gadget.name = driver_name;
-- 
1.7.10.4


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

* [PATCH v2 4/7] usb: gadget: gr_udc: Use of_property_read_u32_index to access arrays
@ 2014-03-27 15:15   ` Andreas Larsson
  0 siblings, 0 replies; 16+ messages in thread
From: Andreas Larsson @ 2014-03-27 15:15 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman
  Cc: Mark Rutland, Dan Carpenter, linux-usb, linux-kernel, devicetree,
	software

Use an appropriate accessor function for property arrays to make the code nicer
and make the code correct if it would ever run on little endian architectures.
Suggested by Mark Rutland.

Signed-off-by: Andreas Larsson <andreas@gaisler.com>
---
Differences since v1: none

 drivers/usb/gadget/gr_udc.c |   12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/gadget/gr_udc.c b/drivers/usb/gadget/gr_udc.c
index 7a99254..0f3a953 100644
--- a/drivers/usb/gadget/gr_udc.c
+++ b/drivers/usb/gadget/gr_udc.c
@@ -2020,9 +2020,7 @@ static int gr_udc_init(struct gr_udc *dev)
 	u32 dmactrl_val;
 	int i;
 	int ret = 0;
-	u32 *bufsizes;
 	u32 bufsize;
-	int len;
 
 	gr_set_address(dev, 0);
 
@@ -2033,19 +2031,17 @@ static int gr_udc_init(struct gr_udc *dev)
 	INIT_LIST_HEAD(&dev->ep_list);
 	gr_set_ep0state(dev, GR_EP0_DISCONNECT);
 
-	bufsizes = (u32 *)of_get_property(np, "epobufsizes", &len);
-	len /= sizeof(u32);
 	for (i = 0; i < dev->nepo; i++) {
-		bufsize = (bufsizes && i < len) ? bufsizes[i] : 1024;
+		if (of_property_read_u32_index(np, "epobufsizes", i, &bufsize))
+			bufsize = 1024;
 		ret = gr_ep_init(dev, i, 0, bufsize);
 		if (ret)
 			return ret;
 	}
 
-	bufsizes = (u32 *)of_get_property(np, "epibufsizes", &len);
-	len /= sizeof(u32);
 	for (i = 0; i < dev->nepi; i++) {
-		bufsize = (bufsizes && i < len) ? bufsizes[i] : 1024;
+		if (of_property_read_u32_index(np, "epibufsizes", i, &bufsize))
+			bufsize = 1024;
 		ret = gr_ep_init(dev, i, 1, bufsize);
 		if (ret)
 			return ret;
-- 
1.7.10.4


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

* [PATCH v2 4/7] usb: gadget: gr_udc: Use of_property_read_u32_index to access arrays
@ 2014-03-27 15:15   ` Andreas Larsson
  0 siblings, 0 replies; 16+ messages in thread
From: Andreas Larsson @ 2014-03-27 15:15 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman
  Cc: Mark Rutland, Dan Carpenter, linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	software-FkzTOoA/JUlBDgjK7y7TUQ

Use an appropriate accessor function for property arrays to make the code nicer
and make the code correct if it would ever run on little endian architectures.
Suggested by Mark Rutland.

Signed-off-by: Andreas Larsson <andreas-FkzTOoA/JUlBDgjK7y7TUQ@public.gmane.org>
---
Differences since v1: none

 drivers/usb/gadget/gr_udc.c |   12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/gadget/gr_udc.c b/drivers/usb/gadget/gr_udc.c
index 7a99254..0f3a953 100644
--- a/drivers/usb/gadget/gr_udc.c
+++ b/drivers/usb/gadget/gr_udc.c
@@ -2020,9 +2020,7 @@ static int gr_udc_init(struct gr_udc *dev)
 	u32 dmactrl_val;
 	int i;
 	int ret = 0;
-	u32 *bufsizes;
 	u32 bufsize;
-	int len;
 
 	gr_set_address(dev, 0);
 
@@ -2033,19 +2031,17 @@ static int gr_udc_init(struct gr_udc *dev)
 	INIT_LIST_HEAD(&dev->ep_list);
 	gr_set_ep0state(dev, GR_EP0_DISCONNECT);
 
-	bufsizes = (u32 *)of_get_property(np, "epobufsizes", &len);
-	len /= sizeof(u32);
 	for (i = 0; i < dev->nepo; i++) {
-		bufsize = (bufsizes && i < len) ? bufsizes[i] : 1024;
+		if (of_property_read_u32_index(np, "epobufsizes", i, &bufsize))
+			bufsize = 1024;
 		ret = gr_ep_init(dev, i, 0, bufsize);
 		if (ret)
 			return ret;
 	}
 
-	bufsizes = (u32 *)of_get_property(np, "epibufsizes", &len);
-	len /= sizeof(u32);
 	for (i = 0; i < dev->nepi; i++) {
-		bufsize = (bufsizes && i < len) ? bufsizes[i] : 1024;
+		if (of_property_read_u32_index(np, "epibufsizes", i, &bufsize))
+			bufsize = 1024;
 		ret = gr_ep_init(dev, i, 1, bufsize);
 		if (ret)
 			return ret;
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v2 5/7] usb: gadget: gr_udc: Add ep.maxpacket_limit to debugfs information
  2014-03-27 15:15 ` Andreas Larsson
                   ` (4 preceding siblings ...)
  (?)
@ 2014-03-27 15:15 ` Andreas Larsson
  -1 siblings, 0 replies; 16+ messages in thread
From: Andreas Larsson @ 2014-03-27 15:15 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman
  Cc: Mark Rutland, Dan Carpenter, linux-usb, linux-kernel, devicetree,
	software

Add information on ep.maxpacket_limit for each endpoint in the debugfs
information.

Signed-off-by: Andreas Larsson <andreas@gaisler.com>
---
Differences since v1: none

 drivers/usb/gadget/gr_udc.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/gadget/gr_udc.c b/drivers/usb/gadget/gr_udc.c
index 0f3a953..253e608 100644
--- a/drivers/usb/gadget/gr_udc.c
+++ b/drivers/usb/gadget/gr_udc.c
@@ -143,6 +143,7 @@ static void gr_seq_ep_show(struct seq_file *seq, struct gr_ep *ep)
 	seq_printf(seq, "  wedged = %d\n", ep->wedged);
 	seq_printf(seq, "  callback = %d\n", ep->callback);
 	seq_printf(seq, "  maxpacket = %d\n", ep->ep.maxpacket);
+	seq_printf(seq, "  maxpacket_limit = %d\n", ep->ep.maxpacket_limit);
 	seq_printf(seq, "  bytes_per_buffer = %d\n", ep->bytes_per_buffer);
 	if (mode == 1 || mode == 3)
 		seq_printf(seq, "  nt = %d\n",
-- 
1.7.10.4


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

* [PATCH v2 6/7] usb: gadget: gr_udc: Return error code when trying to set ep.maxpacket > ep.maxpacket_limit
@ 2014-03-27 15:15   ` Andreas Larsson
  0 siblings, 0 replies; 16+ messages in thread
From: Andreas Larsson @ 2014-03-27 15:15 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman
  Cc: Mark Rutland, Dan Carpenter, linux-usb, linux-kernel, devicetree,
	software

Make gr_ep_enable fail properly when a call requests a larger ep.maxpacket than
ep.maxpacket_limit.

Signed-off-by: Andreas Larsson <andreas@gaisler.com>
---
Differences since v1: none

 drivers/usb/gadget/gr_udc.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/gadget/gr_udc.c b/drivers/usb/gadget/gr_udc.c
index 253e608..72458be 100644
--- a/drivers/usb/gadget/gr_udc.c
+++ b/drivers/usb/gadget/gr_udc.c
@@ -1542,6 +1542,10 @@ static int gr_ep_enable(struct usb_ep *_ep,
 	} else if (max == 0) {
 		dev_err(dev->dev, "Max payload cannot be set to 0\n");
 		return -EINVAL;
+	} else if (max > ep->ep.maxpacket_limit) {
+		dev_err(dev->dev, "Requested max payload %d > limit %d\n",
+			max, ep->ep.maxpacket_limit);
+		return -EINVAL;
 	}
 
 	spin_lock(&ep->dev->lock);
-- 
1.7.10.4


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

* [PATCH v2 6/7] usb: gadget: gr_udc: Return error code when trying to set ep.maxpacket > ep.maxpacket_limit
@ 2014-03-27 15:15   ` Andreas Larsson
  0 siblings, 0 replies; 16+ messages in thread
From: Andreas Larsson @ 2014-03-27 15:15 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman
  Cc: Mark Rutland, Dan Carpenter, linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	software-FkzTOoA/JUlBDgjK7y7TUQ

Make gr_ep_enable fail properly when a call requests a larger ep.maxpacket than
ep.maxpacket_limit.

Signed-off-by: Andreas Larsson <andreas-FkzTOoA/JUlBDgjK7y7TUQ@public.gmane.org>
---
Differences since v1: none

 drivers/usb/gadget/gr_udc.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/gadget/gr_udc.c b/drivers/usb/gadget/gr_udc.c
index 253e608..72458be 100644
--- a/drivers/usb/gadget/gr_udc.c
+++ b/drivers/usb/gadget/gr_udc.c
@@ -1542,6 +1542,10 @@ static int gr_ep_enable(struct usb_ep *_ep,
 	} else if (max == 0) {
 		dev_err(dev->dev, "Max payload cannot be set to 0\n");
 		return -EINVAL;
+	} else if (max > ep->ep.maxpacket_limit) {
+		dev_err(dev->dev, "Requested max payload %d > limit %d\n",
+			max, ep->ep.maxpacket_limit);
+		return -EINVAL;
 	}
 
 	spin_lock(&ep->dev->lock);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 7/7] usb: gadget: gr_udc: Use GFP_ATOMIC when allocating under help spinlock
  2014-03-27 15:15 ` Andreas Larsson
                   ` (6 preceding siblings ...)
  (?)
@ 2014-03-27 15:15 ` Andreas Larsson
  2014-04-01 10:15     ` Andreas Larsson
  -1 siblings, 1 reply; 16+ messages in thread
From: Andreas Larsson @ 2014-03-27 15:15 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman
  Cc: Mark Rutland, Dan Carpenter, linux-usb, linux-kernel, devicetree,
	software

As gr_ep_init must be called with dev->lock held, GFP_KERNEL must not be used.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

Signed-off-by: Andreas Larsson <andreas@gaisler.com>
---
New patch but needs patch 1/7 to apply

 drivers/usb/gadget/gr_udc.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/gr_udc.c b/drivers/usb/gadget/gr_udc.c
index 72458be..4966971 100644
--- a/drivers/usb/gadget/gr_udc.c
+++ b/drivers/usb/gadget/gr_udc.c
@@ -1990,8 +1990,8 @@ static int gr_ep_init(struct gr_udc *dev, int num, int is_in, u32 maxplimit)
 	INIT_LIST_HEAD(&ep->queue);
 
 	if (num == 0) {
-		_req = gr_alloc_request(&ep->ep, GFP_KERNEL);
-		buf = devm_kzalloc(dev->dev, PAGE_SIZE, GFP_DMA | GFP_KERNEL);
+		_req = gr_alloc_request(&ep->ep, GFP_ATOMIC);
+		buf = devm_kzalloc(dev->dev, PAGE_SIZE, GFP_DMA | GFP_ATOMIC);
 		if (!_req || !buf) {
 			/* possible _req freed by gr_probe via gr_remove */
 			return -ENOMEM;
-- 
1.7.10.4


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

* [PATCH v2 7/7] usb: gadget: gr_udc: Use GFP_ATOMIC when allocating under held spinlock
@ 2014-04-01 10:15     ` Andreas Larsson
  0 siblings, 0 replies; 16+ messages in thread
From: Andreas Larsson @ 2014-04-01 10:15 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman
  Cc: Mark Rutland, Dan Carpenter, linux-usb, linux-kernel, devicetree,
	software

As gr_ep_init must be called with dev->lock held, GFP_KERNEL must not be used.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

Signed-off-by: Andreas Larsson <andreas@gaisler.com>
---
Differences since v1: Fixed typo in commit message
 drivers/usb/gadget/gr_udc.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/gr_udc.c b/drivers/usb/gadget/gr_udc.c
index 72458be..4966971 100644
--- a/drivers/usb/gadget/gr_udc.c
+++ b/drivers/usb/gadget/gr_udc.c
@@ -1990,8 +1990,8 @@ static int gr_ep_init(struct gr_udc *dev, int num, int is_in, u32 maxplimit)
 	INIT_LIST_HEAD(&ep->queue);
 
 	if (num == 0) {
-		_req = gr_alloc_request(&ep->ep, GFP_KERNEL);
-		buf = devm_kzalloc(dev->dev, PAGE_SIZE, GFP_DMA | GFP_KERNEL);
+		_req = gr_alloc_request(&ep->ep, GFP_ATOMIC);
+		buf = devm_kzalloc(dev->dev, PAGE_SIZE, GFP_DMA | GFP_ATOMIC);
 		if (!_req || !buf) {
 			/* possible _req freed by gr_probe via gr_remove */
 			return -ENOMEM;
-- 
1.7.10.4


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

* [PATCH v2 7/7] usb: gadget: gr_udc: Use GFP_ATOMIC when allocating under held spinlock
@ 2014-04-01 10:15     ` Andreas Larsson
  0 siblings, 0 replies; 16+ messages in thread
From: Andreas Larsson @ 2014-04-01 10:15 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman
  Cc: Mark Rutland, Dan Carpenter, linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	software-FkzTOoA/JUlBDgjK7y7TUQ

As gr_ep_init must be called with dev->lock held, GFP_KERNEL must not be used.

Reported-by: Dan Carpenter <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>

Signed-off-by: Andreas Larsson <andreas-FkzTOoA/JUlBDgjK7y7TUQ@public.gmane.org>
---
Differences since v1: Fixed typo in commit message
 drivers/usb/gadget/gr_udc.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/gr_udc.c b/drivers/usb/gadget/gr_udc.c
index 72458be..4966971 100644
--- a/drivers/usb/gadget/gr_udc.c
+++ b/drivers/usb/gadget/gr_udc.c
@@ -1990,8 +1990,8 @@ static int gr_ep_init(struct gr_udc *dev, int num, int is_in, u32 maxplimit)
 	INIT_LIST_HEAD(&ep->queue);
 
 	if (num == 0) {
-		_req = gr_alloc_request(&ep->ep, GFP_KERNEL);
-		buf = devm_kzalloc(dev->dev, PAGE_SIZE, GFP_DMA | GFP_KERNEL);
+		_req = gr_alloc_request(&ep->ep, GFP_ATOMIC);
+		buf = devm_kzalloc(dev->dev, PAGE_SIZE, GFP_DMA | GFP_ATOMIC);
 		if (!_req || !buf) {
 			/* possible _req freed by gr_probe via gr_remove */
 			return -ENOMEM;
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH v2 0/7] usb: gadget: gr_udc: OF and ep.maxpacket_limit improvements and fix of GFP_KERNEL in atomic context
@ 2014-04-15 11:41   ` Andreas Larsson
  0 siblings, 0 replies; 16+ messages in thread
From: Andreas Larsson @ 2014-04-15 11:41 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman
  Cc: Mark Rutland, Dan Carpenter, linux-usb, linux-kernel, devicetree,
	software

On 2014-03-27 16:15, Andreas Larsson wrote:
> This patchset:
>   - Adds some OF related improvements suggested by Mark
>     Rutland.
>   - Adds ep.maxpacket_limit to the debugfs file and adds a check if
>     gr_ep_enable is called with a maxpacket value greater than
>     ep.maxpacket_limit.
>   - Fixes a bug where GFP_KERNEL was used in atomic context
>
> Andreas Larsson (7):
>    usb: gadget: gr_udc: Make struct platform_device variable name
>      clearer and use platform_set/get_drvdata
>    usb: gadget: gr_udc: Expand devicetree documentation
>    usb: gadget: gr_udc: Use platform_get_irq instead of
>      irq_of_parse_and_map
>    usb: gadget: gr_udc: Use of_property_read_u32_index to access arrays
>    usb: gadget: gr_udc: Add ep.maxpacket_limit to debugfs information
>    usb: gadget: gr_udc: Return error code when trying to set
>      ep.maxpacket > ep.maxpacket_limit
>    usb: gadget: gr_udc: Use GFP_ATOMIC when allocating under help
>      spinlock
>
>   Documentation/devicetree/bindings/usb/gr-udc.txt |   22 +++++----
>   drivers/usb/gadget/gr_udc.c                      |   53 ++++++++++++----------
>   2 files changed, 42 insertions(+), 33 deletions(-)


Anyone got feedback or reasons this cannot be accepted?

Best regards,
Andreas Larsson

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

* Re: [PATCH v2 0/7] usb: gadget: gr_udc: OF and ep.maxpacket_limit improvements and fix of GFP_KERNEL in atomic context
@ 2014-04-15 11:41   ` Andreas Larsson
  0 siblings, 0 replies; 16+ messages in thread
From: Andreas Larsson @ 2014-04-15 11:41 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman
  Cc: Mark Rutland, Dan Carpenter, linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	software-FkzTOoA/JUlBDgjK7y7TUQ

On 2014-03-27 16:15, Andreas Larsson wrote:
> This patchset:
>   - Adds some OF related improvements suggested by Mark
>     Rutland.
>   - Adds ep.maxpacket_limit to the debugfs file and adds a check if
>     gr_ep_enable is called with a maxpacket value greater than
>     ep.maxpacket_limit.
>   - Fixes a bug where GFP_KERNEL was used in atomic context
>
> Andreas Larsson (7):
>    usb: gadget: gr_udc: Make struct platform_device variable name
>      clearer and use platform_set/get_drvdata
>    usb: gadget: gr_udc: Expand devicetree documentation
>    usb: gadget: gr_udc: Use platform_get_irq instead of
>      irq_of_parse_and_map
>    usb: gadget: gr_udc: Use of_property_read_u32_index to access arrays
>    usb: gadget: gr_udc: Add ep.maxpacket_limit to debugfs information
>    usb: gadget: gr_udc: Return error code when trying to set
>      ep.maxpacket > ep.maxpacket_limit
>    usb: gadget: gr_udc: Use GFP_ATOMIC when allocating under help
>      spinlock
>
>   Documentation/devicetree/bindings/usb/gr-udc.txt |   22 +++++----
>   drivers/usb/gadget/gr_udc.c                      |   53 ++++++++++++----------
>   2 files changed, 42 insertions(+), 33 deletions(-)


Anyone got feedback or reasons this cannot be accepted?

Best regards,
Andreas Larsson
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2014-04-15 11:42 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-27 15:15 [PATCH v2 0/7] usb: gadget: gr_udc: OF and ep.maxpacket_limit improvements and fix of GFP_KERNEL in atomic context Andreas Larsson
2014-03-27 15:15 ` Andreas Larsson
2014-03-27 15:15 ` [PATCH v2 1/7] usb: gadget: gr_udc: Make struct platform_device variable name clearer and use platform_set/get_drvdata Andreas Larsson
2014-03-27 15:15 ` [PATCH v2 2/7] usb: gadget: gr_udc: Expand devicetree documentation Andreas Larsson
2014-03-27 15:15   ` Andreas Larsson
2014-03-27 15:15 ` [PATCH v2 3/7] usb: gadget: gr_udc: Use platform_get_irq instead of irq_of_parse_and_map Andreas Larsson
2014-03-27 15:15 ` [PATCH v2 4/7] usb: gadget: gr_udc: Use of_property_read_u32_index to access arrays Andreas Larsson
2014-03-27 15:15   ` Andreas Larsson
2014-03-27 15:15 ` [PATCH v2 5/7] usb: gadget: gr_udc: Add ep.maxpacket_limit to debugfs information Andreas Larsson
2014-03-27 15:15 ` [PATCH v2 6/7] usb: gadget: gr_udc: Return error code when trying to set ep.maxpacket > ep.maxpacket_limit Andreas Larsson
2014-03-27 15:15   ` Andreas Larsson
2014-03-27 15:15 ` [PATCH 7/7] usb: gadget: gr_udc: Use GFP_ATOMIC when allocating under help spinlock Andreas Larsson
2014-04-01 10:15   ` [PATCH v2 7/7] usb: gadget: gr_udc: Use GFP_ATOMIC when allocating under held spinlock Andreas Larsson
2014-04-01 10:15     ` Andreas Larsson
2014-04-15 11:41 ` [PATCH v2 0/7] usb: gadget: gr_udc: OF and ep.maxpacket_limit improvements and fix of GFP_KERNEL in atomic context Andreas Larsson
2014-04-15 11:41   ` Andreas Larsson

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.