8000 v2 dwc2 DMA alignment_buffer handling by P33M · Pull Request #6923 · raspberrypi/linux · GitHub
[go: up one dir, main page]

Skip to content

v2 dwc2 DMA alignment_buffer handling #6923

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 24, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Revert "usb: dwc2: use temporary URB buffer for small control transfers"
This incorrectly matches on urb->setup_packet instead of checking the
pipe type, so recycled URBs were incorrectly matched.

A more comprehensive fix is forthcoming.

This reverts commit 2f27224.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
  • Loading branch information
P33M committed Jun 23, 2025
commit 8831aac19c06a4db91a8b1d4d71e1d405fda1c57
19 changes: 3 additions & 16 deletions drivers/usb/dwc2/hcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2469,23 +2469,10 @@ static int dwc2_alloc_dma_aligned_buffer(struct urb *urb, gfp_t mem_flags)
{
void *kmalloc_ptr;
size_t kmalloc_size;
bool small_ctrl;

if (urb->num_sgs || urb->sg || urb->transfer_buffer_length == 0)
return 0;

/*
* Hardware bug: small IN packets with length < 4 cause a
* 4-byte write to memory. This is only an issue for drivers that
* insist on packing a device's various properties into a struct
* and filling them one at a time with Control transfers (uvcvideo).
* Force the use of align_buf so that the subsequent memcpy puts
* the right number of bytes in the URB's buffer.
*/
small_ctrl = (urb->setup_packet &&
le16_to_cpu(((struct usb_ctrlrequest *)(urb->setup_packet))->wLength) < 4);

if (!small_ctrl && !((uintptr_t)urb->transfer_buffer & (DWC2_USB_DMA_ALIGN - 1)))
if (urb->num_sgs || urb->sg ||
urb->transfer_buffer_length == 0 ||
!((uintptr_t)urb->transfer_buffer & (DWC2_USB_DMA_ALIGN - 1)))
return 0;

/*
Expand Down
0