linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Antti Seppälä" <a.seppala@gmail.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: Doug Anderson <dianders@chromium.org>,
	Minas Harutyunyan <hminas@synopsys.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Boris ARZUR <boris@konbu.org>,
	linux-usb@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
	Felipe Balbi <balbi@kernel.org>,
	Stefan Wahren <stefan.wahren@i2se.com>,
	Martin Schiller <ms@dev.tdt.de>
Subject: Re: [RFT PATCH 1/4] usb: dwc2: Simplify and fix DMA alignment code
Date: Sun, 1 Mar 2020 18:51:55 +0200	[thread overview]
Message-ID: <CAKv9HNZjWKS1thKZ84FwYabHr-o2Q-T9xc4V2Oz6NtiuogQfRQ@mail.gmail.com> (raw)
In-Reply-To: <28e29bb7-b536-dd0f-d410-f4add6b2a9ab@roeck-us.net>

On Sun, 1 Mar 2020 at 18:24, Guenter Roeck <linux@roeck-us.net> wrote:
>
> Hi Antti,
>
> On 3/1/20 7:51 AM, Antti Seppälä wrote:
> > On Sat, 29 Feb 2020 at 18:33, Antti Seppälä <a.seppala@gmail.com> wrote:
> >>
> >> On Sat, 29 Feb 2020 at 17:25, Guenter Roeck <linux@roeck-us.net> wrote:
> >>>
> >>> Sigh. It would have been too simple. Too bad I can't test myself.
> >>> I'd like to know if this is because URB_NO_TRANSFER_DMA_MAP is set on a
> >>> transfer, or because the beginning of the buffer indeed needs to be aligned
> >>> to the DMA cache line size on that system. In the latter case, the question
> >>> is why the alignment to DWC2_USB_DMA_ALIGN (=4) works. In the former case,
> >>> question would be why the realignment does any good in the first place.
> >>>
> >>> Any chance you can add some test code to help figuring out what exactly
> >>> goes wrong ?
> >>>
> >>
> >> Sure, I can try to help. Just let me know what code you would like to
> >> insert and where and I'll see what I can do.
> >>
> >
> > So I did some further research on this and it turns out that:
> >  - URB_NO_TRANSFER_DMA_MAP is not set on the offending transfers so
> > the issue really is buffer alignment
> >  - DWC2_USB_DMA_ALIGN=4 "works" because in my limited testcase (usb
> > 4g-dongle utilized via qmi-wwan) all transfers are unaligned. That is,
> > every urb->transfer_buffer is misaligned by 2 bytes == unaligned
> >  - I can fix both issues and thus make the patch work on MIPS by
> > modifying it like this:
> >
> > -#define DWC2_USB_DMA_ALIGN 4
> > +#define DWC2_USB_DMA_ALIGN dma_get_cache_alignment()
> >
> >  struct dma_aligned_buffer {
> >         void *old_xfer_buffer;
> > -       u8 data[0];
> > +       u8 data[0] ____cacheline_aligned;
> >  };
> >
>
> Thanks for the additional testing. That means that the existing code
> is already broken, or am I missing something ?
>

Yes, I believe the existing code is broken if 4 byte aligned transfers
occur. I seem to have no easy way to prove that though as none of my
devices generate those.

> Updating DWC2_USB_DMA_ALIGN to dma_get_cache_alignment() was part
> of my initial fix, but then I abandoned it because I thought, well,
> the existing alignment works, so that can't be the problem.
>
> Anyway, using ____cacheline_aligned is an excellent idea. I'll make
> the changes suggested above for the next version of my series.
>

Great. In the meanwhile I'll continue testing and will report back if
I find anything new.

-- 
Antti

  reply	other threads:[~2020-03-01 16:52 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-26 21:04 [RFT PATCH 0/4] usb: dwc2: Fixes and improvements Guenter Roeck
2020-02-26 21:04 ` [RFT PATCH 1/4] usb: dwc2: Simplify and fix DMA alignment code Guenter Roeck
2020-02-27 22:06   ` Doug Anderson
2020-02-27 22:27     ` Guenter Roeck
2020-02-28  4:28       ` Guenter Roeck
2020-02-28 16:14         ` Doug Anderson
2020-02-28 17:59           ` Guenter Roeck
2020-02-29  7:46             ` Antti Seppälä
2020-02-29 15:25               ` Guenter Roeck
2020-02-29 16:33                 ` Antti Seppälä
2020-03-01 15:51                   ` Antti Seppälä
2020-03-01 16:24                     ` Guenter Roeck
2020-03-01 16:51                       ` Antti Seppälä [this message]
2020-03-01 17:13                         ` Guenter Roeck
2020-02-28 16:26     ` Stefan Wahren
2020-02-26 21:04 ` [RFT PATCH 2/4] usb: dwc2: Do not update data length if it is 0 on inbound transfers Guenter Roeck
2020-02-27 22:06   ` Doug Anderson
2020-02-28  0:32     ` Guenter Roeck
2020-02-26 21:04 ` [RFT PATCH 3/4] usb: dwc2: Abort transaction after errors with unknown reason Guenter Roeck
2020-02-27 22:06   ` Doug Anderson
2020-02-28  0:36     ` Guenter Roeck
2020-02-26 21:04 ` [RFT PATCH 4/4] usb: dwc2: Make "trimming xfer length" a debug message Guenter Roeck
2020-02-27 22:07   ` Doug Anderson
2020-02-28  0:38     ` Guenter Roeck
2020-02-29  1:50 ` [RFT PATCH 0/4] usb: dwc2: Fixes and improvements Boris ARZUR
2021-01-12 19:40 ` Nicolas Saenz Julienne
2021-01-12 19:44 ` Nicolas Saenz Julienne
2021-01-13  4:48   ` Guenter Roeck

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=CAKv9HNZjWKS1thKZ84FwYabHr-o2Q-T9xc4V2Oz6NtiuogQfRQ@mail.gmail.com \
    --to=a.seppala@gmail.com \
    --cc=balbi@kernel.org \
    --cc=boris@konbu.org \
    --cc=dianders@chromium.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hminas@synopsys.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=ms@dev.tdt.de \
    --cc=stefan.wahren@i2se.com \
    /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).