hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/include/linux/mlx5/doorbell.h
....@@ -36,46 +36,25 @@
3636 #define MLX5_BF_OFFSET 0x800
3737 #define MLX5_CQ_DOORBELL 0x20
3838
39
-#if BITS_PER_LONG == 64
4039 /* Assume that we can just write a 64-bit doorbell atomically. s390
4140 * actually doesn't have writeq() but S/390 systems don't even have
4241 * PCI so we won't worry about it.
42
+ *
43
+ * Note that the write is not atomic on 32-bit systems! In contrast to 64-bit
44
+ * ones, it requires proper locking. mlx5_write64 doesn't do any locking, so use
45
+ * it at your own discretion, protected by some kind of lock on 32 bits.
46
+ *
47
+ * TODO: use write{q,l}_relaxed()
4348 */
4449
45
-#define MLX5_DECLARE_DOORBELL_LOCK(name)
46
-#define MLX5_INIT_DOORBELL_LOCK(ptr) do { } while (0)
47
-#define MLX5_GET_DOORBELL_LOCK(ptr) (NULL)
48
-
49
-static inline void mlx5_write64(__be32 val[2], void __iomem *dest,
50
- spinlock_t *doorbell_lock)
50
+static inline void mlx5_write64(__be32 val[2], void __iomem *dest)
5151 {
52
+#if BITS_PER_LONG == 64
5253 __raw_writeq(*(u64 *)val, dest);
53
-}
54
-
5554 #else
56
-
57
-/* Just fall back to a spinlock to protect the doorbell if
58
- * BITS_PER_LONG is 32 -- there's no portable way to do atomic 64-bit
59
- * MMIO writes.
60
- */
61
-
62
-#define MLX5_DECLARE_DOORBELL_LOCK(name) spinlock_t name;
63
-#define MLX5_INIT_DOORBELL_LOCK(ptr) spin_lock_init(ptr)
64
-#define MLX5_GET_DOORBELL_LOCK(ptr) (ptr)
65
-
66
-static inline void mlx5_write64(__be32 val[2], void __iomem *dest,
67
- spinlock_t *doorbell_lock)
68
-{
69
- unsigned long flags;
70
-
71
- if (doorbell_lock)
72
- spin_lock_irqsave(doorbell_lock, flags);
7355 __raw_writel((__force u32) val[0], dest);
7456 __raw_writel((__force u32) val[1], dest + 4);
75
- if (doorbell_lock)
76
- spin_unlock_irqrestore(doorbell_lock, flags);
77
-}
78
-
7957 #endif
58
+}
8059
8160 #endif /* MLX5_DOORBELL_H */