Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

usb: xhci: simplify Isochronous Scheduling Threshold handling

The IST is represented by bits 2:0, with bit 3 indicating the unit of
measurement, Frames or Microframes. Introduce xhci_ist_microframes(),
which returns the IST value in Microframes, simplifying the code and
reducing duplication.

Improve documentation in xhci-caps.h to clarify the IST register specifics,
including the unit conversion details. These change removes the need to
explain it each time the IST values is retrieved.

Signed-off-by: Niklas Neronin <niklas.neronin@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://patch.msgid.link/20251119142417.2820519-20-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Niklas Neronin and committed by
Greg Kroah-Hartman
f724e347 edab0090

+20 -15
+8 -1
drivers/usb/host/xhci-caps.h
··· 24 24 /* 25 25 * bits 3:0 - Isochronous Scheduling Threshold, frames or uframes that SW 26 26 * needs to queue transactions ahead of the HW to meet periodic deadlines. 27 + * - Bits 2:0: Threshold value 28 + * - Bit 3: Unit indicator 29 + * - '1': Threshold in Frames 30 + * - '0': Threshold in Microframes (uframes) 31 + * Note: 1 Frame = 8 Microframes 32 + * xHCI specification section 5.3.4. 27 33 */ 28 - #define HCS_IST(p) (((p) >> 0) & 0xf) 34 + #define HCS_IST_VALUE(p) ((p) & 0x7) 35 + #define HCS_IST_UNIT(p) ((p) & (1 << 3)) 29 36 /* bits 7:4 - Event Ring Segment Table Max, 2^(n) */ 30 37 #define HCS_ERST_MAX(p) (((p) >> 4) & 0xf) 31 38 /* bits 20:8 - Rsvd */
+12 -14
drivers/usb/host/xhci-ring.c
··· 3961 3961 return total_packet_count - 1; 3962 3962 } 3963 3963 3964 + /* Returns the Isochronous Scheduling Threshold in Microframes. 1 Frame is 8 Microframes. */ 3965 + static int xhci_ist_microframes(struct xhci_hcd *xhci) 3966 + { 3967 + int ist = HCS_IST_VALUE(xhci->hcs_params2); 3968 + 3969 + if (HCS_IST_UNIT(xhci->hcs_params2)) 3970 + ist *= 8; 3971 + return ist; 3972 + } 3973 + 3964 3974 /* 3965 3975 * Calculates Frame ID field of the isochronous TRB identifies the 3966 3976 * target frame that the Interval associated with this Isochronous ··· 3990 3980 else 3991 3981 start_frame = (urb->start_frame + index * urb->interval) >> 3; 3992 3982 3993 - /* Isochronous Scheduling Threshold (IST, bits 0~3 in HCSPARAMS2): 3994 - * 3995 - * If bit [3] of IST is cleared to '0', software can add a TRB no 3996 - * later than IST[2:0] Microframes before that TRB is scheduled to 3997 - * be executed. 3998 - * If bit [3] of IST is set to '1', software can add a TRB no later 3999 - * than IST[2:0] Frames before that TRB is scheduled to be executed. 4000 - */ 4001 - ist = HCS_IST(xhci->hcs_params2) & 0x7; 4002 - if (HCS_IST(xhci->hcs_params2) & (1 << 3)) 4003 - ist <<= 3; 3983 + ist = xhci_ist_microframes(xhci); 4004 3984 4005 3985 /* Software shall not schedule an Isoch TD with a Frame ID value that 4006 3986 * is less than the Start Frame ID or greater than the End Frame ID, ··· 4311 4311 * Round up to the next frame and consider the time before trb really 4312 4312 * gets scheduled by hardare. 4313 4313 */ 4314 - ist = HCS_IST(xhci->hcs_params2) & 0x7; 4315 - if (HCS_IST(xhci->hcs_params2) & (1 << 3)) 4316 - ist <<= 3; 4314 + ist = xhci_ist_microframes(xhci); 4317 4315 start_frame += ist + XHCI_CFC_DELAY; 4318 4316 start_frame = roundup(start_frame, 8); 4319 4317