net/usb: catc: allocate URB setup_packet as separate buffer
Subsystems (3)
PATCH 1/2 net/usb: catc: allocate URB setup_packet as separate buffer
URB setup packet must not be allocated as part of larger structure because DMA coherence issues.
Patch changes catc to allocate ctrl_dr member as separate buffer.
Patch is only compile tested.
--- drivers/net/usb/catc.c | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-)
drivers/net/usb/catc.c +25 -15
@@ -173,7 +173,7 @@ struct catc {u8 rx_buf[RX_MAX_BURST * (PKT_SZ +2 )];u8 irq_buf[2 ];u8 ctrl_buf[64 ]; -struct usb_ctrlrequest ctrl_dr; +struct usb_ctrlrequest *ctrl_dr;struct timer_list timer;u8 stats_buf[8 ];
@@ -485,7 +485,7 @@ static void catc_ctrl_run(struct catc *catc)struct ctrl_queue *q = catc->ctrl_queue + catc->ctrl_tail;struct usb_device *usbdev = catc->usbdev;struct urb *urb = catc->ctrl_urb; -struct usb_ctrlrequest *dr = &catc->ctrl_dr; +struct usb_ctrlrequest *dr = catc->ctrl_dr;int status; dr->bRequest = q->request;
@@ -779,7 +779,7 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *idstruct net_device *netdev;struct catc *catc;u8 broadcast[6 ]; -int i, pktsz; +int i, pktsz, err;if (usb_set_interface (usbdev, intf->altsetting->desc.bInterfaceNumber,1 )) {
@@ -793,6 +793,12 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id catc =netdev_priv (netdev); + catc->ctrl_dr =kzalloc (sizeof (*catc->ctrl_dr),GFP_KERNEL ); +if (!catc->ctrl_dr) { + err = -ENOMEM ; + goto err_free_dev; + } + netdev->netdev_ops = &catc_netdev_ops; netdev->watchdog_timeo =TX_TIMEOUT ;SET_ETHTOOL_OPS (netdev, &ops);
@@ -814,12 +820,8 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *idif ((!catc->ctrl_urb) || (!catc->tx_urb) || (!catc->rx_urb) || (!catc->irq_urb)) {dev_err (&intf->dev,"No free urbs available.\n" ); -usb_free_urb (catc->ctrl_urb); -usb_free_urb (catc->tx_urb); -usb_free_urb (catc->rx_urb); -usb_free_urb (catc->irq_urb); -free_netdev (netdev); -return -ENOMEM ; + err = -ENOMEM ; + goto err_free; }/* The F5U011 has the same vendor/product as the netmate but a device version of 0x130 */
@@ -918,14 +920,21 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *idSET_NETDEV_DEV (netdev, &intf->dev);if (register_netdev (netdev) !=0 ) {usb_set_intfdata (intf,NULL ); -usb_free_urb (catc->ctrl_urb); -usb_free_urb (catc->tx_urb); -usb_free_urb (catc->rx_urb); -usb_free_urb (catc->irq_urb); -free_netdev (netdev); -return -EIO ; + err = -EIO ; + goto err_free; }return 0 ; + +err_free: +usb_free_urb (catc->ctrl_urb); +usb_free_urb (catc->tx_urb); +usb_free_urb (catc->rx_urb); +usb_free_urb (catc->irq_urb); +kfree (catc->ctrl_dr); +err_free_dev: +free_netdev (netdev); + +return err; }static void catc_disconnect (struct usb_interface *intf)
@@ -939,6 +948,7 @@ static void catc_disconnect(struct usb_interface *intf)usb_free_urb (catc->tx_urb);usb_free_urb (catc->rx_urb);usb_free_urb (catc->irq_urb); +kfree (catc->ctrl_dr);free_netdev (catc->netdev); } }
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 2/2 net/usb: catc: allocate URB transfer_buffers as separate buffers
URB transfer_buffer must not be allocated as part of larger structure because DMA coherence issues.
Patch changes catc to allocate tx_buf, rx_buf, irq_buf and ctrl_buf members as separate buffers.
Patch is only compile tested.
--- drivers/net/usb/catc.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-)
drivers/net/usb/catc.c +23 -7
@@ -169,10 +169,10 @@ struct catc {unsigned int ctrl_head, ctrl_tail;spinlock_t tx_lock, ctrl_lock; -u8 tx_buf[2 ][TX_MAX_BURST * (PKT_SZ +2 )]; -u8 rx_buf[RX_MAX_BURST * (PKT_SZ +2 )]; -u8 irq_buf[2 ]; -u8 ctrl_buf[64 ]; +u8 *tx_buf[2 ]; +u8 *rx_buf; +u8 *irq_buf; +u8 *ctrl_buf;struct usb_ctrlrequest *ctrl_dr;struct timer_list timer;
@@ -794,9 +794,15 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id catc =netdev_priv (netdev); catc->ctrl_dr =kzalloc (sizeof (*catc->ctrl_dr),GFP_KERNEL ); -if (!catc->ctrl_dr) { + catc->tx_buf[0 ] =kzalloc (TX_MAX_BURST * (PKT_SZ +2 ),GFP_KERNEL ); + catc->tx_buf[1 ] =kzalloc (TX_MAX_BURST * (PKT_SZ +2 ),GFP_KERNEL ); + catc->rx_buf =kzalloc (RX_MAX_BURST * (PKT_SZ +2 ),GFP_KERNEL ); + catc->irq_buf =kzalloc (2 ,GFP_KERNEL ); + catc->ctrl_buf =kzalloc (64 ,GFP_KERNEL ); +if (!catc->ctrl_dr || !catc->ctrl_buf || !catc->tx_buf[0 ] || + !catc->tx_buf[1 ] || !catc->rx_buf || !catc->irq_buf) { err = -ENOMEM ; - goto err_free_dev; + goto err_free_buf; } netdev->netdev_ops = &catc_netdev_ops;
@@ -930,8 +936,13 @@ err_free:usb_free_urb (catc->tx_urb);usb_free_urb (catc->rx_urb);usb_free_urb (catc->irq_urb); +err_free_buf: +kfree (catc->ctrl_buf); +kfree (catc->irq_buf); +kfree (catc->rx_buf); +kfree (catc->tx_buf[1 ]); +kfree (catc->tx_buf[0 ]);kfree (catc->ctrl_dr); -err_free_dev:free_netdev (netdev);return err;
@@ -948,6 +959,11 @@ static void catc_disconnect(struct usb_interface *intf)usb_free_urb (catc->tx_urb);usb_free_urb (catc->rx_urb);usb_free_urb (catc->irq_urb); +kfree (catc->ctrl_buf); +kfree (catc->irq_buf); +kfree (catc->rx_buf); +kfree (catc->tx_buf[1 ]); +kfree (catc->tx_buf[0 ]);kfree (catc->ctrl_dr);free_netdev (catc->netdev); }
A message that is not in the archive (sent off-list or not yet received): 20130807132629.14001.2370.stgit-bi+AKbBUZKagILUCTcTcHdKyNwTtLsGr@public.gmane.org
From: Jussi Kivilinna <[email protected]>
Date: Wed, 07 Aug 2013 16:26:29 +0300
Quoted 9 lines
URB setup packet must not be allocated as part of larger structure because DMA coherence issues.
Patch changes catc to allocate
ctrl_drmember as separate buffer.Patch is only compile tested.
Cc <[email protected]>Signed-off-by Jussi Kivilinna <[email protected]>
I absolutely do not agree with your adding the stable CC: tag for a patch which has only been compile tested.
This applies to all of your other patches you submitted in this cluster too.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 8 lines · David Miller
From: Jussi Kivilinna <[email protected]>
Date: Wed, 07 Aug 2013 16:26:29 +0300Quoted 5 lines
URB setup packet must not be allocated as part of larger structure because DMA coherence issues.
Patch changes catc to allocate
ctrl_drmember as separate buffer.
Quoted 7 lines
Quoted 4 lines
Patch is only compile tested.
Cc <[email protected]>Signed-off-by Jussi Kivilinna <[email protected]>I absolutely do not agree with your adding the stable CC: tag for a patch which has only been compile tested.
Agreed, this was not brightest of ideas. I won't do it again.
-Jussi
Quoted 4 lines
This applies to all of your other patches you submitted in this cluster too.