All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kyungmin Park <kmpark@infradead.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/2] usb: gadget: Use unaligned access for wMaxPacketSize
Date: Mon, 13 May 2013 19:50:28 +0900	[thread overview]
Message-ID: <CAH9JG2X0H2yPFQz4RBEwaJQUmkyZFashJY3tnhm4c_1F3bmJ+A@mail.gmail.com> (raw)
In-Reply-To: <1368440618-11359-2-git-send-email-gautam.vivek@samsung.com>

On Mon, May 13, 2013 at 7:23 PM, Vivek Gautam <gautam.vivek@samsung.com>wrote:

> Use get_unaligned() while fetching wMaxPacketSize to avoid
> voilating any alignment rules.
>

It's another story, can we get performance gain with unaligned access
feature? In case of kernel, we got some gains.

Anyway, good job!

Acked-by: Kyungmin Park <kyungmin.park@samsung.com>

>
> Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>
> Cc: Lukasz Majewski <l.majewski@samsung.com>
> Cc: Piotr Wilczek <p.wilczek@samsung.com>
> Cc: Kyungmin Park <kyungmin.park@samsung.com>
> Cc: Lukasz Dalek <luk0104@gmail.com>
> Cc: Marek Vasut <marex@denx.de>
> ---
>
> Just did a build test on u-boot-usb/master branch.
> Need to be tested further.
>
> Based on u-boot-usb/next.
>
>  drivers/usb/gadget/f_mass_storage.c |    3 ++-
>  drivers/usb/gadget/pxa25x_udc.c     |   13 +++++++------
>  2 files changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/usb/gadget/f_mass_storage.c
> b/drivers/usb/gadget/f_mass_storage.c
> index c28866f..45bc132 100644
> --- a/drivers/usb/gadget/f_mass_storage.c
> +++ b/drivers/usb/gadget/f_mass_storage.c
> @@ -2261,7 +2261,8 @@ reset:
>         if (rc)
>                 goto reset;
>         fsg->bulk_out_enabled = 1;
> -       common->bulk_out_maxpacket = le16_to_cpu(d->wMaxPacketSize);
> +       common->bulk_out_maxpacket =
> +
> le16_to_cpu(get_unaligned(&d->wMaxPacketSize));
>         clear_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags);
>
>         /* Allocate the requests */
> diff --git a/drivers/usb/gadget/pxa25x_udc.c
> b/drivers/usb/gadget/pxa25x_udc.c
> index 9ce98f0..085503d 100644
> --- a/drivers/usb/gadget/pxa25x_udc.c
> +++ b/drivers/usb/gadget/pxa25x_udc.c
> @@ -314,7 +314,8 @@ static int pxa25x_ep_enable(struct usb_ep *_ep,
>         if (!_ep || !desc || ep->desc || _ep->name == ep0name
>                         || desc->bDescriptorType != USB_DT_ENDPOINT
>                         || ep->bEndpointAddress != desc->bEndpointAddress
> -                       || ep->fifo_size <
> le16_to_cpu(desc->wMaxPacketSize)) {
> +                       || ep->fifo_size <
> +
>  le16_to_cpu(get_unaligned(&desc->wMaxPacketSize))) {
>                 printf("%s, bad ep or descriptor\n", __func__);
>                 return -EINVAL;
>         }
> @@ -329,9 +330,9 @@ static int pxa25x_ep_enable(struct usb_ep *_ep,
>
>         /* hardware _could_ do smaller, but driver doesn't */
>         if ((desc->bmAttributes == USB_ENDPOINT_XFER_BULK
> -                               && le16_to_cpu(desc->wMaxPacketSize)
> +                       &&
> le16_to_cpu(get_unaligned(&desc->wMaxPacketSize))
>                                                 != BULK_FIFO_SIZE)
> -                       || !desc->wMaxPacketSize) {
> +                       || !get_unaligned(&desc->wMaxPacketSize)) {
>                 printf("%s, bad %s maxpacket\n", __func__, _ep->name);
>                 return -ERANGE;
>         }
> @@ -345,7 +346,7 @@ static int pxa25x_ep_enable(struct usb_ep *_ep,
>         ep->desc = desc;
>         ep->stopped = 0;
>         ep->pio_irqs = 0;
> -       ep->ep.maxpacket = le16_to_cpu(desc->wMaxPacketSize);
> +       ep->ep.maxpacket =
> le16_to_cpu(get_unaligned(&desc->wMaxPacketSize));
>
>         /* flush fifo (mostly for OUT buffers) */
>         pxa25x_ep_fifo_flush(_ep);
> @@ -485,7 +486,7 @@ write_fifo(struct pxa25x_ep *ep, struct pxa25x_request
> *req)
>  {
>         unsigned max;
>
> -       max = le16_to_cpu(ep->desc->wMaxPacketSize);
> +       max = le16_to_cpu(get_unaligned(&ep->desc->wMaxPacketSize));
>         do {
>                 unsigned count;
>                 int is_last, is_short;
> @@ -766,7 +767,7 @@ pxa25x_ep_queue(struct usb_ep *_ep, struct usb_request
> *_req, gfp_t gfp_flags)
>          */
>         if (unlikely(ep->bmAttributes == USB_ENDPOINT_XFER_ISOC
>                         && req->req.length >
> -                       le16_to_cpu(ep->desc->wMaxPacketSize)))
> +
> le16_to_cpu(get_unaligned(&ep->desc->wMaxPacketSize))))
>                 return -EMSGSIZE;
>
>         debug_cond(NOISY, "%s queue req %p, len %d buf %p\n",
> --
> 1.7.6.5
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
>

  reply	other threads:[~2013-05-13 10:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-13 10:23 [U-Boot] [PATCH 1/2] usb: Use get_unaligned() in usb_endpoint_maxp() for wMaxPacketSize Vivek Gautam
2013-05-13 10:23 ` [U-Boot] [PATCH 2/2] usb: gadget: Use unaligned access " Vivek Gautam
2013-05-13 10:50   ` Kyungmin Park [this message]
2013-05-13 11:46     ` Vivek Gautam
2013-05-13 11:56     ` Albert ARIBAUD
2013-05-13 12:03   ` Łukasz Dałek
2013-05-14 13:37   ` Piotr Wilczek
2013-05-14 13:49   ` Marek Vasut

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=CAH9JG2X0H2yPFQz4RBEwaJQUmkyZFashJY3tnhm4c_1F3bmJ+A@mail.gmail.com \
    --to=kmpark@infradead.org \
    --cc=u-boot@lists.denx.de \
    /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 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.