From: Dave Kilroy <kilroyd@googlemail.com>
To: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Jussi Kivilinna <jussi.kivilinna@mbnet.fi>,
linux-wireless@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] rtlwifi: usb: allocate URB control message setup_packet and data buffer separately
Date: Sun, 17 Feb 2013 01:51:33 +0000 [thread overview]
Message-ID: <512037A5.2010203@gmail.com> (raw)
In-Reply-To: <51201AB8.4060700@lwfinger.net>
On 16/02/2013 23:48, Larry Finger wrote:
> On 02/16/2013 05:00 PM, Jussi Kivilinna wrote:
>> rtlwifi allocates both setup_packet and data buffer of control
>> message urb,
>> using shared kmalloc in _usbctrl_vendorreq_async_write. Structure
>> used for
>> allocating is:
>> struct {
>> u8 data[254];
>> struct usb_ctrlrequest dr;
>> };
>>
>> Because 'struct usb_ctrlrequest' is __packed, setup packet is
>> unaligned and
>> DMA mapping of both 'data' and 'dr' confuses ARM/sunxi, leading to
>> memory
>> corruptions and freezes.
>>
>> Patch changes setup packet to be allocated separately.
>
> I am not crazy about the overhead in allocating two different blocks
> for each output packet, but if it is necessary, then it has to happen.
>> static int _usbctrl_vendorreq_async_write(struct usb_device *udev,
>> u8 request,
>> @@ -55,39 +59,47 @@ static int _usbctrl_vendorreq_async_write(struct
>> usb_device *udev, u8 request,
>> u8 reqtype;
>> struct usb_ctrlrequest *dr;
>> struct urb *urb;
>> - struct rtl819x_async_write_data {
>> - u8 data[REALTEK_USB_VENQT_MAX_BUF_SIZE];
>> - struct usb_ctrlrequest dr;
>> - } *buf;
>
If dr isn't at the appropriate alignment, wouldn't padding out the data
buffer achieve the same thing? Something like:
struct rtl819x_async_write_data {
- u8 data[REALTEK_USB_VENQT_MAX_BUF_SIZE];
+ u8 data[ALIGN(REALTEK_USB_VENQT_MAX_BUF_SIZE, ALIGNMENT)];
struct usb_ctrlrequest dr;
} *buf;
Where ALIGNMENT is whatever the required alignment is.
Dave.
next prev parent reply other threads:[~2013-02-17 1:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-16 23:00 [PATCH] rtlwifi: usb: allocate URB control message setup_packet and data buffer separately Jussi Kivilinna
2013-02-16 23:48 ` Larry Finger
2013-02-17 1:51 ` Dave Kilroy [this message]
2013-02-17 8:38 ` Jussi Kivilinna
2013-02-17 8:39 ` Jussi Kivilinna
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=512037A5.2010203@gmail.com \
--to=kilroyd@googlemail.com \
--cc=Larry.Finger@lwfinger.net \
--cc=jussi.kivilinna@mbnet.fi \
--cc=linux-wireless@vger.kernel.org \
--cc=stable@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;
as well as URLs for NNTP newsgroup(s).