diff mbox series

[v6,10/10] drivers/char: use smp barriers in xhci driver

Message ID 992c6512e54435a006c6de28515d1242518cb974.1662124370.git-series.marmarek@invisiblethingslab.com (mailing list archive)
State Superseded
Headers show
Series Add Xue - console over USB 3 Debug Capability | expand

Commit Message

Marek Marczykowski-Górecki Sept. 2, 2022, 1:17 p.m. UTC
All (interesting) data is in plain WB cached memory, and the few BAR
register that are configured have a UC mapping, which orders properly
WRT other writes on x86.

Suggested-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
---
New in v6
---
 xen/drivers/char/xhci-dbc.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

Comments

Jan Beulich Sept. 6, 2022, 9:23 a.m. UTC | #1
On 02.09.2022 15:17, Marek Marczykowski-Górecki wrote:
> All (interesting) data is in plain WB cached memory, and the few BAR
> register that are configured have a UC mapping, which orders properly
> WRT other writes on x86.
> 
> Suggested-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>

As said in reply to Andrew's comment: What about non-x86? Drivers like
this one, even if presently depending on X86 in Kconfig, shouldn't be
making assumptions like this. Such is imo only appropriate when a
driver conceivably would only ever be useful on x86.

Jan
diff mbox series

Patch

diff --git a/xen/drivers/char/xhci-dbc.c b/xen/drivers/char/xhci-dbc.c
index 829f1d1d910f..03df4d82a623 100644
--- a/xen/drivers/char/xhci-dbc.c
+++ b/xen/drivers/char/xhci-dbc.c
@@ -666,7 +666,7 @@  static void dbc_pop_events(struct dbc *dbc)
 
     BUILD_BUG_ON((1 << XHCI_TRB_SHIFT) != sizeof(struct xhci_trb));
 
-    rmb();
+    smp_rmb();
 
     while ( xhci_trb_cyc(event) == er->cyc )
     {
@@ -710,7 +710,7 @@  static void dbc_pop_events(struct dbc *dbc)
     }
 
     erdp = er->dma + (er->deq << XHCI_TRB_SHIFT);
-    wmb();
+    smp_wmb();
     writeq(erdp, &reg->erdp);
 }
 
@@ -847,9 +847,9 @@  static void dbc_enable_dbc(struct dbc *dbc)
 {
     struct dbc_reg *reg = dbc->dbc_reg;
 
-    wmb();
+    smp_wmb();
     writel(readl(&reg->ctrl) | (1U << DBC_CTRL_DCE), &reg->ctrl);
-    wmb();
+    smp_wmb();
 
     while ( (readl(&reg->ctrl) & (1U << DBC_CTRL_DCE)) == 0 )
         cpu_relax();
@@ -858,9 +858,9 @@  static void dbc_enable_dbc(struct dbc *dbc)
     if ( !dbc->open )
         dbc_reset_debug_port(dbc);
 
-    wmb();
+    smp_wmb();
     writel(readl(&reg->portsc) | (1U << DBC_PSC_PED), &reg->portsc);
-    wmb();
+    smp_wmb();
 
     while ( (readl(&reg->ctrl) & (1U << DBC_CTRL_DCR)) == 0 )
         cpu_relax();
@@ -871,7 +871,7 @@  static void dbc_disable_dbc(struct dbc *dbc)
     struct dbc_reg *reg = dbc->dbc_reg;
 
     writel(readl(&reg->portsc) & ~(1U << DBC_PSC_PED), &reg->portsc);
-    wmb();
+    smp_wmb();
     writel(readl(&reg->ctrl) & ~(1U << DBC_CTRL_DCE), &reg->ctrl);
 
     while ( readl(&reg->ctrl) & (1U << DBC_CTRL_DCE) )
@@ -1032,7 +1032,7 @@  static bool dbc_ensure_running(struct dbc *dbc)
     {
         writel(ctrl | (1U << DBC_CTRL_DRC), &reg->ctrl);
         writel(readl(&reg->portsc) | (1U << DBC_PSC_PED), &reg->portsc);
-        wmb();
+        smp_wmb();
         dbc_ring_doorbell(dbc, dbc->dbc_iring.db);
         dbc_ring_doorbell(dbc, dbc->dbc_oring.db);
     }
@@ -1074,7 +1074,7 @@  static void dbc_flush(struct dbc *dbc, struct xhci_trb_ring *trb,
         }
     }
 
-    wmb();
+    smp_wmb();
     dbc_ring_doorbell(dbc, trb->db);
 }
 
@@ -1101,7 +1101,7 @@  static void dbc_enqueue_in(struct dbc *dbc, struct xhci_trb_ring *trb,
     dbc_push_trb(dbc, trb, wrk->dma + wrk->enq,
                  dbc_work_ring_space_to_end(wrk));
 
-    wmb();
+    smp_wmb();
     writel(db, &reg->db);
 }