Skip to content

Commit 08cc561

Browse files
l1kgregkh
authored andcommitted
xhci: Clean up ERST_PTR_MASK inversion
Mathias notes that the ERST_PTR_MASK macro is named as if it's masking the Event Ring Dequeue Pointer in the ERDP register, but in actuality it's masking the inverse. Invert the macro's value for clarity. Migrate it to the modern GENMASK_ULL() syntax to avoid u64 casts. Signed-off-by: Lukas Wunner <lukas@wunner.de> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://lore.kernel.org/r/20231019102924.2797346-10-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 01e6e14 commit 08cc561

File tree

4 files changed

+5
-7
lines changed

4 files changed

+5
-7
lines changed

drivers/usb/host/xhci-mem.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1952,8 +1952,7 @@ static void xhci_set_hc_event_deq(struct xhci_hcd *xhci, struct xhci_interrupter
19521952
*/
19531953
xhci_dbg_trace(xhci, trace_xhci_dbg_init,
19541954
"// Write event ring dequeue pointer, preserving EHB bit");
1955-
xhci_write_64(xhci, ((u64) deq & (u64) ~ERST_PTR_MASK),
1956-
&ir->ir_set->erst_dequeue);
1955+
xhci_write_64(xhci, deq & ERST_PTR_MASK, &ir->ir_set->erst_dequeue);
19571956
}
19581957

19591958
static void xhci_add_in_port(struct xhci_hcd *xhci, unsigned int num_ports,

drivers/usb/host/xhci-ring.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3013,13 +3013,12 @@ static void xhci_update_erst_dequeue(struct xhci_hcd *xhci,
30133013
* Per 4.9.4, Software writes to the ERDP register shall
30143014
* always advance the Event Ring Dequeue Pointer value.
30153015
*/
3016-
if ((temp_64 & (u64) ~ERST_PTR_MASK) ==
3017-
((u64) deq & (u64) ~ERST_PTR_MASK))
3016+
if ((temp_64 & ERST_PTR_MASK) == (deq & ERST_PTR_MASK))
30183017
return;
30193018

30203019
/* Update HC event ring dequeue pointer */
30213020
temp_64 = ir->event_ring->deq_seg->num & ERST_DESI_MASK;
3022-
temp_64 |= ((u64) deq & (u64) ~ERST_PTR_MASK);
3021+
temp_64 |= deq & ERST_PTR_MASK;
30233022
}
30243023

30253024
/* Clear the event handler busy flag (RW1C) */

drivers/usb/host/xhci.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ int xhci_run(struct usb_hcd *hcd)
520520
xhci_dbg_trace(xhci, trace_xhci_dbg_init, "xhci_run");
521521

522522
temp_64 = xhci_read_64(xhci, &ir->ir_set->erst_dequeue);
523-
temp_64 &= ~ERST_PTR_MASK;
523+
temp_64 &= ERST_PTR_MASK;
524524
xhci_dbg_trace(xhci, trace_xhci_dbg_init,
525525
"ERST deq = 64'h%0lx", (long unsigned int) temp_64);
526526

drivers/usb/host/xhci.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ struct xhci_intr_reg {
525525
* a work queue (or delayed service routine)?
526526
*/
527527
#define ERST_EHB (1 << 3)
528-
#define ERST_PTR_MASK (0xf)
528+
#define ERST_PTR_MASK (GENMASK_ULL(63, 4))
529529

530530
/**
531531
* struct xhci_run_regs

0 commit comments

Comments
 (0)