Skip to contentSkip to conversation

USB: yurex: remove allocation of coherent buffer for setup-packet buffer

PATCH In review Tomoki Sekiyama 2 participants 5 messages Mar 28, 2012 – Mar 29, 2012 USB

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 USB: yurex: remove allocation of coherent buffer for setup-packet buffer

Removes allocation of coherent buffer for the control-request setup-packet buffer from the yurex driver. Using coherent buffers for setup-packet is obsoleted and does not work with some USB host implementations.

This patch also fixes missing URB_NO_TRANSFER_DMA_MAP flag in urb.

---
 drivers/usb/misc/yurex.c |   10 +++-------
 1 files changed, 3 insertions(+), 7 deletions(-)
drivers/usb/misc/yurex.c +3 -7
index 897edda..7020146 100644
@@ -99,9 +99,7 @@ static void yurex_delete(struct kref *kref)
 	usb_put_dev(dev->udev);
 	if (dev->cntl_urb) {
 		usb_kill_urb(dev->cntl_urb);
-		if (dev->cntl_req)
-			usb_free_coherent(dev->udev, YUREX_BUF_SIZE,
-				dev->cntl_req, dev->cntl_urb->setup_dma);
+		kfree(dev->cntl_req);
 		if (dev->cntl_buffer)
 			usb_free_coherent(dev->udev, YUREX_BUF_SIZE,
 				dev->cntl_buffer, dev->cntl_urb->transfer_dma);
@@ -234,9 +232,7 @@ static int yurex_probe(struct usb_interface *interface, const struct usb_device_
 	}
 
 	/* allocate buffer for control req */
-	dev->cntl_req = usb_alloc_coherent(dev->udev, YUREX_BUF_SIZE,
-					   GFP_KERNEL,
-					   &dev->cntl_urb->setup_dma);
+	dev->cntl_req = kmalloc(YUREX_BUF_SIZE, GFP_KERNEL);
 	if (!dev->cntl_req) {
 		err("Could not allocate cntl_req");
 		goto error;
@@ -286,7 +282,7 @@ static int yurex_probe(struct usb_interface *interface, const struct usb_device_
 			 usb_rcvintpipe(dev->udev, dev->int_in_endpointAddr),
 			 dev->int_buffer, YUREX_BUF_SIZE, yurex_interrupt,
 			 dev, 1);
-	dev->cntl_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
+	dev->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
 	if (usb_submit_urb(dev->urb, GFP_KERNEL)) {
 		retval = -EIO;
 		err("Could not submitting URB");
Signature · 1 line
1.7.7.6
#1 lore raw

Hello.

Quoted 5 lines · Tomoki Sekiyama

Removes allocation of coherent buffer for the control-request setup-packet buffer from the yurex driver. Using coherent buffers for setup-packet is obsoleted and does not work with some USB host implementations.

This patch also fixes missing URB_NO_TRANSFER_DMA_MAP flag in urb.

Looks like the patch should be split into two then as it does two different
things.

Quoted 32 lines
---
  drivers/usb/misc/yurex.c |   10 +++-------
  1 files changed, 3 insertions(+), 7 deletions(-)
drivers/usb/misc/yurex.c +2 -6
index 897edda..7020146 100644
@@ -99,9 +99,7 @@ static void yurex_delete(struct kref *kref)
  	usb_put_dev(dev->udev);
  	if (dev->cntl_urb) {
  		usb_kill_urb(dev->cntl_urb);
-		if (dev->cntl_req)
-			usb_free_coherent(dev->udev, YUREX_BUF_SIZE,
-				dev->cntl_req, dev->cntl_urb->setup_dma);
+		kfree(dev->cntl_req);
  		if (dev->cntl_buffer)
  			usb_free_coherent(dev->udev, YUREX_BUF_SIZE,
  				dev->cntl_buffer, dev->cntl_urb->transfer_dma);
@@ -234,9 +232,7 @@ static int yurex_probe(struct usb_interface *interface, const struct usb_device_
  	}
 
  	/* allocate buffer for control req */
-	dev->cntl_req = usb_alloc_coherent(dev->udev, YUREX_BUF_SIZE,
-					   GFP_KERNEL,
-					&dev->cntl_urb->setup_dma);
+	dev->cntl_req = kmalloc(YUREX_BUF_SIZE, GFP_KERNEL);
  	if (!dev->cntl_req) {
  		err("Could not allocate cntl_req");
  		goto error;

drivers/usb/misc/yurex.c static int yurex_probe(struct usb_interface *interface, const struct usb_device_ · line 288

Quoted 8 lines
drivers/usb/misc/yurex.c +1 -1
@@ -286,7 +282,7 @@ static int yurex_probe(struct usb_interface *interface, const struct usb_device_
  			 usb_rcvintpipe(dev->udev, dev->int_in_endpointAddr),
  			 dev->int_buffer, YUREX_BUF_SIZE, yurex_interrupt,
  			 dev, 1);
-	dev->cntl_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
+	dev->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
  	if (usb_submit_urb(dev->urb, GFP_KERNEL)) {
  		retval = -EIO;
  		err("Could not submitting URB");

WBR, Sergei

#2 lore raw

Hello,

2012年3月29日20:57 Sergei Shtylyov <[email protected]>:

Quoted 8 lines

Hello.

Quoted 3 lines · Tomoki Sekiyama

Removes allocation of coherent buffer for the control-request setup-packet buffer from the yurex driver. Using coherent buffers for setup-packet is obsoleted and does not work with some USB host implementations.

Quoted 6 lines
Quoted 1 line

This patch also fixes missing URB_NO_TRANSFER_DMA_MAP flag in urb.

  Looks like the patch should be split into two then as it does two different things.

WBR, Sergei

OK, I will split this patch into two pieces and re-send them.

Thank you,

Tomoki Sekiyama

#3 lore raw

PATCH 1/2 USB: yurex: Remove allocation of coherent buffer for setup-packet buffer

Removes allocation of coherent buffer for the control-request setup-packet buffer from the yurex driver. Using coherent buffers for setup-packet is obsolete and does not work with some USB host implementations.

---
 drivers/usb/misc/yurex.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)
drivers/usb/misc/yurex.c +2 -6
index 897edda..a4a76fc 100644
@@ -99,9 +99,7 @@ static void yurex_delete(struct kref *kref)
 	usb_put_dev(dev->udev);
 	if (dev->cntl_urb) {
 		usb_kill_urb(dev->cntl_urb);
-		if (dev->cntl_req)
-			usb_free_coherent(dev->udev, YUREX_BUF_SIZE,
-				dev->cntl_req, dev->cntl_urb->setup_dma);
+		kfree(dev->cntl_req);
 		if (dev->cntl_buffer)
 			usb_free_coherent(dev->udev, YUREX_BUF_SIZE,
 				dev->cntl_buffer, dev->cntl_urb->transfer_dma);
@@ -234,9 +232,7 @@ static int yurex_probe(struct usb_interface *interface, const struct usb_device_
 	}
 
 	/* allocate buffer for control req */
-	dev->cntl_req = usb_alloc_coherent(dev->udev, YUREX_BUF_SIZE,
-					   GFP_KERNEL,
-					   &dev->cntl_urb->setup_dma);
+	dev->cntl_req = kmalloc(YUREX_BUF_SIZE, GFP_KERNEL);
 	if (!dev->cntl_req) {
 		err("Could not allocate cntl_req");
 		goto error;
Signature · 1 line
1.7.7.6
#4 lore raw

PATCH 2/2 USB: yurex: Fix missing URB_NO_TRANSFER_DMA_MAP flag in urb

In reply to Sergei Shtylyov

Current probing code is setting URB_NO_TRANSFER_DMA_MAP flag into a wrong urb structure, and this causes BUG_ON with some USB host implementations. This patch fixes the issue.

---
 drivers/usb/misc/yurex.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/usb/misc/yurex.c +1 -1
index a4a76fc..7020146 100644
@@ -282,7 +282,7 @@ static int yurex_probe(struct usb_interface *interface, const struct usb_device_
 			 usb_rcvintpipe(dev->udev, dev->int_in_endpointAddr),
 			 dev->int_buffer, YUREX_BUF_SIZE, yurex_interrupt,
 			 dev, 1);
-	dev->cntl_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
+	dev->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
 	if (usb_submit_urb(dev->urb, GFP_KERNEL)) {
 		retval = -EIO;
 		err("Could not submitting URB");

-- 1.7.7.6