Commit 08cc5616 authored by Lukas Wunner's avatar Lukas Wunner Committed by Greg Kroah-Hartman

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: default avatarLukas Wunner <lukas@wunner.de>
Signed-off-by: default avatarMathias Nyman <mathias.nyman@linux.intel.com>
Link: https://lore.kernel.org/r/20231019102924.2797346-10-mathias.nyman@linux.intel.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 01e6e143
...@@ -1952,8 +1952,7 @@ static void xhci_set_hc_event_deq(struct xhci_hcd *xhci, struct xhci_interrupter ...@@ -1952,8 +1952,7 @@ static void xhci_set_hc_event_deq(struct xhci_hcd *xhci, struct xhci_interrupter
*/ */
xhci_dbg_trace(xhci, trace_xhci_dbg_init, xhci_dbg_trace(xhci, trace_xhci_dbg_init,
"// Write event ring dequeue pointer, preserving EHB bit"); "// Write event ring dequeue pointer, preserving EHB bit");
xhci_write_64(xhci, ((u64) deq & (u64) ~ERST_PTR_MASK), xhci_write_64(xhci, deq & ERST_PTR_MASK, &ir->ir_set->erst_dequeue);
&ir->ir_set->erst_dequeue);
} }
static void xhci_add_in_port(struct xhci_hcd *xhci, unsigned int num_ports, static void xhci_add_in_port(struct xhci_hcd *xhci, unsigned int num_ports,
......
...@@ -3013,13 +3013,12 @@ static void xhci_update_erst_dequeue(struct xhci_hcd *xhci, ...@@ -3013,13 +3013,12 @@ static void xhci_update_erst_dequeue(struct xhci_hcd *xhci,
* Per 4.9.4, Software writes to the ERDP register shall * Per 4.9.4, Software writes to the ERDP register shall
* always advance the Event Ring Dequeue Pointer value. * always advance the Event Ring Dequeue Pointer value.
*/ */
if ((temp_64 & (u64) ~ERST_PTR_MASK) == if ((temp_64 & ERST_PTR_MASK) == (deq & ERST_PTR_MASK))
((u64) deq & (u64) ~ERST_PTR_MASK))
return; return;
/* Update HC event ring dequeue pointer */ /* Update HC event ring dequeue pointer */
temp_64 = ir->event_ring->deq_seg->num & ERST_DESI_MASK; temp_64 = ir->event_ring->deq_seg->num & ERST_DESI_MASK;
temp_64 |= ((u64) deq & (u64) ~ERST_PTR_MASK); temp_64 |= deq & ERST_PTR_MASK;
} }
/* Clear the event handler busy flag (RW1C) */ /* Clear the event handler busy flag (RW1C) */
......
...@@ -520,7 +520,7 @@ int xhci_run(struct usb_hcd *hcd) ...@@ -520,7 +520,7 @@ int xhci_run(struct usb_hcd *hcd)
xhci_dbg_trace(xhci, trace_xhci_dbg_init, "xhci_run"); xhci_dbg_trace(xhci, trace_xhci_dbg_init, "xhci_run");
temp_64 = xhci_read_64(xhci, &ir->ir_set->erst_dequeue); temp_64 = xhci_read_64(xhci, &ir->ir_set->erst_dequeue);
temp_64 &= ~ERST_PTR_MASK; temp_64 &= ERST_PTR_MASK;
xhci_dbg_trace(xhci, trace_xhci_dbg_init, xhci_dbg_trace(xhci, trace_xhci_dbg_init,
"ERST deq = 64'h%0lx", (long unsigned int) temp_64); "ERST deq = 64'h%0lx", (long unsigned int) temp_64);
......
...@@ -525,7 +525,7 @@ struct xhci_intr_reg { ...@@ -525,7 +525,7 @@ struct xhci_intr_reg {
* a work queue (or delayed service routine)? * a work queue (or delayed service routine)?
*/ */
#define ERST_EHB (1 << 3) #define ERST_EHB (1 << 3)
#define ERST_PTR_MASK (0xf) #define ERST_PTR_MASK (GENMASK_ULL(63, 4))
/** /**
* struct xhci_run_regs * struct xhci_run_regs
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment