On 2019-02-19 11:59, Stanislaw Gruszka wrote: > On Mon, Feb 18, 2019 at 11:19:40PM +0100, Stefan Wahren wrote: >> Hi, >> >> > Stanislaw Gruszka <sgruszka@xxxxxxxxxx> hat am 18. Februar 2019 um 14:52 geschrieben: >> > >> > >> > On Sat, Feb 16, 2019 at 08:17:07PM +0100, Stefan Wahren wrote: >> > > this is a misunderstanding. The warning is about memory alignment to 32 bit addresses, not about page alignment. This is a typical ARM restriction. Maybe we need to make sure in mt76 that the DMA buffer needs to be aligned. But it's also possible that the warning isn't the root cause of our problem. >> > > >> > >> > I see, it needs 4 bytes alignment . There is already dwc2 code checks >> > that and allocate new buffer if the alignment is not right: >> > dwc2_alloc_dma_aligned_buffer(), but it does nothing if urb->sg >> > is not NULL. I thought mt76usb already provide aligned buffers, but >> > looks it does not for one TX special case, which are PROBE REQUEST >> > frames. Other frames are aligned by inserting L2 header pad. One >> > solution for this would be just submit urb with NULL sg (same as >> > Lorenzo's patches do, but still allocating buffers via buf->sg), >> > but I think, you have right, we should provide 4 bytes aligned buffers >> > by default as other DMA hardware may require that. I'm attaching yet >> > another patch to test, which fix up alignment for PROBE REQUEST frames. >> > >> > > > Attached patch should fix this, plese test, thanks in advance. >> >> i saw Felix decided to use Lorenzo's approach. >> >> The patches 1,3,5 applied on today's next fixed only the warning and wifi is still broken (authentication timeout). >> >> Here are the logs for multi_v7_defconfig: >> https://gist.github.com/lategoodbye/0a7c5cea7dbf25d0de7944c05d229d79 > > It would be interesting why urb->num_sgs = 0 & urb->sg cause > the troubles. This is how usb_sg_init() submit urbs for sg_tablesize = 0 > controllers. So either are there are some requirement on urb->sg > mapped via dma_map_page() (which mt76usb does not meet) not needed > for urb->transfer_buffer mapped via dma_map_single() or there > is something wrong in dwc2 with sg and this driver will not > work with urb_sg_init() as well. I don't have hardware to investigate > this and don't want to bother you with more patches. I think the conditions for skipping the alloc of the DMA aligned buffer in dwc2 are a bit quirky: if (urb->num_sgs || urb->sg || urb->transfer_buffer_length == 0 || !((uintptr_t)urb->transfer_buffer & (DWC2_USB_DMA_ALIGN - 1))) return 0; It would probably make more sense to write: if ((urb->num_sgs && urb->sg && urb->transfer_buffer_length == 0) || !((uintptr_t)urb->transfer_buffer & (DWC2_USB_DMA_ALIGN - 1))) return 0; It would still need some extra code for the urb->num_sgs==1 case though. That code was originally written for the nvidia tegra host controller driver and copied to dwc2. Maybe at the time they just didn't want to write extra code dealing with urb->sg because nobody was using it for single-buffer transfers, or they didn't have a test case. Either way, while it might be a good idea to improve dwc2 and tegra, I still think avoiding the use of urb->sg in single buffer cases is a good idea. One advantage is that less memory needs to be allocated. - Felix