Re: [PATCH] usb: dwc2: extend treatment for incomplete transfer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 23 Feb 2020 at 15:45, Guenter Roeck <linux@xxxxxxxxxxxx> wrote:
>
> On 2/23/20 3:00 AM, Antti Seppälä wrote:
> > Hi Guenter,
> >
> > On Wed, 19 Feb 2020 at 23:11, Guenter Roeck <linux@xxxxxxxxxxxx> wrote:
> >>
> >> Yes, those patches didn't address the core problem. Can you test with the
> >> attached two patches ?
> >>
> >> Thanks,
> >> Guenter
> >
> > I took a look at your patch (usb: dwc2: Simplify DMA alignment code)
> > and I don't believe it is correct.
> >
> > The patch re-introduces the dma_aligned_buffer struct and takes some
> > care to align the beginning of the struct to dma cache lines. However
> > we should be aligning the data[0] pointer inside the struct instead.
> > With the code in the patch data[0] gets pushed to be at an offset from
> > the alignment by kmalloc_ptr and old_xfer_buffer pointers. In other
> > words data[0] is now not aligned to dma cache boundaries.
> >
>
> I thought so too initially. However,
>
> temp = PTR_ALIGN(kmalloc_ptr + 1, TEGRA_USB_DMA_ALIGN) - 1;
>
> aligns the structure pointer such that its _end_ is DMA-aligned,
> which is ->data[0].
>

Hmm, looks like you're right. I somehow missed the - 1 at the end.
Sorry for the noise I guess.

Would be nice to know what makes the previous code prone to pointer
corruption issues though. With the added padding that pointer should
also be on another dma cache line.
-- 
Antti




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux