Netdev List
 help / color / mirror / Atom feed
From: Jussi Kivilinna <jussi.kivilinna@iki.fi>
To: netdev@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-usb@vger.kernel.org,
	"David S. Miller" <davem@davemloft.net>,
	Jan Dumon <j.dumon@option.com>
Subject: [PATCH 1/2] net/usb: hso: allocate URB setup_packets as separate buffers
Date: Wed, 07 Aug 2013 16:29:02 +0300	[thread overview]
Message-ID: <20130807132902.14451.37517.stgit@localhost6.localdomain6> (raw)

URB setup packets must not be allocated as part of larger structure because
DMA coherence issues.

Patch changes hso to allocate ctrl_req_[tr]x members of 'struct hso_serial'
as separate buffers.

Patch is only compile tested.

Cc: <stable@vger.kernel.org>
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
---
 drivers/net/usb/hso.c |   18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index cba1d46..fc082c0 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -237,8 +237,8 @@ struct hso_serial {
 	u16 tx_data_length;	/* should contain allocated length */
 	u16 tx_data_count;
 	u16 tx_buffer_count;
-	struct usb_ctrlrequest ctrl_req_tx;
-	struct usb_ctrlrequest ctrl_req_rx;
+	struct usb_ctrlrequest *ctrl_req_tx;
+	struct usb_ctrlrequest *ctrl_req_rx;
 
 	struct usb_endpoint_descriptor *in_endp;
 	struct usb_endpoint_descriptor *out_endp;
@@ -1847,7 +1847,7 @@ static int hso_mux_serial_read(struct hso_serial *serial)
 				  USB_CDC_GET_ENCAPSULATED_RESPONSE,
 				  serial->parent->port_spec & HSO_PORT_MASK,
 				  serial->rx_urb[0],
-				  &serial->ctrl_req_rx,
+				  serial->ctrl_req_rx,
 				  serial->rx_data[0], serial->rx_data_length);
 }
 
@@ -1916,7 +1916,7 @@ static int hso_mux_serial_write_data(struct hso_serial *serial)
 				  USB_CDC_SEND_ENCAPSULATED_COMMAND,
 				  serial->parent->port_spec & HSO_PORT_MASK,
 				  serial->tx_urb,
-				  &serial->ctrl_req_tx,
+				  serial->ctrl_req_tx,
 				  serial->tx_data, serial->tx_data_count);
 }
 
@@ -2264,6 +2264,10 @@ static void hso_serial_common_free(struct hso_serial *serial)
 	usb_free_urb(serial->tx_urb);
 	kfree(serial->tx_data);
 	tty_port_destroy(&serial->port);
+
+	/* free control URB setup packet buffers */
+	kfree(serial->ctrl_req_tx);
+	kfree(serial->ctrl_req_rx);
 }
 
 static int hso_serial_common_create(struct hso_serial *serial, int num_urbs,
@@ -2292,6 +2296,12 @@ static int hso_serial_common_create(struct hso_serial *serial, int num_urbs,
 	spin_lock_init(&serial->serial_lock);
 	serial->num_rx_urbs = num_urbs;
 
+	/* allocate control URB setup packet buffers */
+	serial->ctrl_req_tx = kzalloc(sizeof(*serial->ctrl_req_tx), GFP_KERNEL);
+	serial->ctrl_req_rx = kzalloc(sizeof(*serial->ctrl_req_rx), GFP_KERNEL);
+	if (!serial->ctrl_req_tx || !serial->ctrl_req_rx)
+		goto exit;
+
 	/* RX, allocate urb and initialize */
 
 	/* prepare our RX buffer */

             reply	other threads:[~2013-08-07 13:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-07 13:29 Jussi Kivilinna [this message]
     [not found] ` <20130807132902.14451.37517.stgit-bi+AKbBUZKagILUCTcTcHdKyNwTtLsGr@public.gmane.org>
2013-08-07 13:29   ` [PATCH 2/2] net/usb: hso: allocate serial_state_notification as separate buffer Jussi Kivilinna
2013-08-07 15:47     ` Dan Williams
2013-08-07 15:46 ` [PATCH 1/2] net/usb: hso: allocate URB setup_packets as separate buffers Dan Williams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130807132902.14451.37517.stgit@localhost6.localdomain6 \
    --to=jussi.kivilinna@iki.fi \
    --cc=davem@davemloft.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=j.dumon@option.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox