Commit c6132f6f authored by Michael Chan's avatar Michael Chan Committed by David S. Miller

bnxt_en: Fix 64-bit doorbell operation on 32-bit kernels

The driver requires 64-bit doorbell writes to be atomic on 32-bit
architectures.  So we redefined writeq as a new macro with spinlock
protection on 32-bit architectures.  This created a new warning when
we added a new file in a recent patchset.  writeq is defined on many
32-bit architectures to do the memory write non-atomically and it
generated a new macro redefined warning.  This warning was fixed
incorrectly in the recent patch.

Fix this properly by adding a new bnxt_writeq() function that will
do the non-atomic write under spinlock on 32-bit systems.  All callers
in the driver will now call bnxt_writeq() instead.

v2: Need to pass in bp to bnxt_writeq()
    Use lo_hi_writeq() [suggested by Florian]
Reported-by: default avatarkernel test robot <lkp@intel.com>
Fixes: f9ff5782 ("bnxt_en: introduce new firmware message API based on DMA pools")
Reviewed-by: default avatarEdwin Peer <edwin.peer@broadcom.com>
Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9e9fb765
...@@ -305,13 +305,15 @@ static bool bnxt_vf_pciid(enum board_idx idx) ...@@ -305,13 +305,15 @@ static bool bnxt_vf_pciid(enum board_idx idx)
writel(DB_CP_FLAGS | RING_CMP(idx), (db)->doorbell) writel(DB_CP_FLAGS | RING_CMP(idx), (db)->doorbell)
#define BNXT_DB_NQ_P5(db, idx) \ #define BNXT_DB_NQ_P5(db, idx) \
writeq((db)->db_key64 | DBR_TYPE_NQ | RING_CMP(idx), (db)->doorbell) bnxt_writeq(bp, (db)->db_key64 | DBR_TYPE_NQ | RING_CMP(idx), \
(db)->doorbell)
#define BNXT_DB_CQ_ARM(db, idx) \ #define BNXT_DB_CQ_ARM(db, idx) \
writel(DB_CP_REARM_FLAGS | RING_CMP(idx), (db)->doorbell) writel(DB_CP_REARM_FLAGS | RING_CMP(idx), (db)->doorbell)
#define BNXT_DB_NQ_ARM_P5(db, idx) \ #define BNXT_DB_NQ_ARM_P5(db, idx) \
writeq((db)->db_key64 | DBR_TYPE_NQ_ARM | RING_CMP(idx), (db)->doorbell) bnxt_writeq(bp, (db)->db_key64 | DBR_TYPE_NQ_ARM | RING_CMP(idx),\
(db)->doorbell)
static void bnxt_db_nq(struct bnxt *bp, struct bnxt_db_info *db, u32 idx) static void bnxt_db_nq(struct bnxt *bp, struct bnxt_db_info *db, u32 idx)
{ {
...@@ -332,8 +334,8 @@ static void bnxt_db_nq_arm(struct bnxt *bp, struct bnxt_db_info *db, u32 idx) ...@@ -332,8 +334,8 @@ static void bnxt_db_nq_arm(struct bnxt *bp, struct bnxt_db_info *db, u32 idx)
static void bnxt_db_cq(struct bnxt *bp, struct bnxt_db_info *db, u32 idx) static void bnxt_db_cq(struct bnxt *bp, struct bnxt_db_info *db, u32 idx)
{ {
if (bp->flags & BNXT_FLAG_CHIP_P5) if (bp->flags & BNXT_FLAG_CHIP_P5)
writeq(db->db_key64 | DBR_TYPE_CQ_ARMALL | RING_CMP(idx), bnxt_writeq(bp, db->db_key64 | DBR_TYPE_CQ_ARMALL |
db->doorbell); RING_CMP(idx), db->doorbell);
else else
BNXT_DB_CQ(db, idx); BNXT_DB_CQ(db, idx);
} }
...@@ -2638,7 +2640,7 @@ static void __bnxt_poll_cqs_done(struct bnxt *bp, struct bnxt_napi *bnapi, ...@@ -2638,7 +2640,7 @@ static void __bnxt_poll_cqs_done(struct bnxt *bp, struct bnxt_napi *bnapi,
if (cpr2 && cpr2->had_work_done) { if (cpr2 && cpr2->had_work_done) {
db = &cpr2->cp_db; db = &cpr2->cp_db;
writeq(db->db_key64 | dbr_type | bnxt_writeq(bp, db->db_key64 | dbr_type |
RING_CMP(cpr2->cp_raw_cons), db->doorbell); RING_CMP(cpr2->cp_raw_cons), db->doorbell);
cpr2->had_work_done = 0; cpr2->had_work_done = 0;
} }
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <net/dst_metadata.h> #include <net/dst_metadata.h>
#include <net/xdp.h> #include <net/xdp.h>
#include <linux/dim.h> #include <linux/dim.h>
#include <linux/io-64-nonatomic-lo-hi.h>
#ifdef CONFIG_TEE_BNXT_FW #ifdef CONFIG_TEE_BNXT_FW
#include <linux/firmware/broadcom/tee_bnxt_fw.h> #include <linux/firmware/broadcom/tee_bnxt_fw.h>
#endif #endif
...@@ -1981,7 +1982,7 @@ struct bnxt { ...@@ -1981,7 +1982,7 @@ struct bnxt {
struct mutex sriov_lock; struct mutex sriov_lock;
#endif #endif
#ifndef writeq #if BITS_PER_LONG == 32
/* ensure atomic 64-bit doorbell writes on 32-bit systems. */ /* ensure atomic 64-bit doorbell writes on 32-bit systems. */
spinlock_t db_lock; spinlock_t db_lock;
#endif #endif
...@@ -2110,24 +2111,36 @@ static inline u32 bnxt_tx_avail(struct bnxt *bp, struct bnxt_tx_ring_info *txr) ...@@ -2110,24 +2111,36 @@ static inline u32 bnxt_tx_avail(struct bnxt *bp, struct bnxt_tx_ring_info *txr)
((txr->tx_prod - txr->tx_cons) & bp->tx_ring_mask); ((txr->tx_prod - txr->tx_cons) & bp->tx_ring_mask);
} }
#ifndef writeq static inline void bnxt_writeq(struct bnxt *bp, u64 val,
#define writeq(val64, db) \ volatile void __iomem *addr)
do { \ {
spin_lock(&bp->db_lock); \ #if BITS_PER_LONG == 32
writel((val64) & 0xffffffff, db); \ spin_lock(&bp->db_lock);
writel((val64) >> 32, (db) + 4); \ lo_hi_writeq(val, addr);
spin_unlock(&bp->db_lock); \ spin_unlock(&bp->db_lock);
} while (0) #else
writeq(val, addr);
#endif
}
#define writeq_relaxed writeq static inline void bnxt_writeq_relaxed(struct bnxt *bp, u64 val,
volatile void __iomem *addr)
{
#if BITS_PER_LONG == 32
spin_lock(&bp->db_lock);
lo_hi_writeq_relaxed(val, addr);
spin_unlock(&bp->db_lock);
#else
writeq_relaxed(val, addr);
#endif #endif
}
/* For TX and RX ring doorbells with no ordering guarantee*/ /* For TX and RX ring doorbells with no ordering guarantee*/
static inline void bnxt_db_write_relaxed(struct bnxt *bp, static inline void bnxt_db_write_relaxed(struct bnxt *bp,
struct bnxt_db_info *db, u32 idx) struct bnxt_db_info *db, u32 idx)
{ {
if (bp->flags & BNXT_FLAG_CHIP_P5) { if (bp->flags & BNXT_FLAG_CHIP_P5) {
writeq_relaxed(db->db_key64 | idx, db->doorbell); bnxt_writeq_relaxed(bp, db->db_key64 | idx, db->doorbell);
} else { } else {
u32 db_val = db->db_key32 | idx; u32 db_val = db->db_key32 | idx;
...@@ -2142,7 +2155,7 @@ static inline void bnxt_db_write(struct bnxt *bp, struct bnxt_db_info *db, ...@@ -2142,7 +2155,7 @@ static inline void bnxt_db_write(struct bnxt *bp, struct bnxt_db_info *db,
u32 idx) u32 idx)
{ {
if (bp->flags & BNXT_FLAG_CHIP_P5) { if (bp->flags & BNXT_FLAG_CHIP_P5) {
writeq(db->db_key64 | idx, db->doorbell); bnxt_writeq(bp, db->db_key64 | idx, db->doorbell);
} else { } else {
u32 db_val = db->db_key32 | idx; u32 db_val = db->db_key32 | idx;
......
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