From dda8e0e48723fc90e6222fcc1b04b94f240ae9b2 Mon Sep 17 00:00:00 2001 From: Gavin Hu Date: Mon, 16 Sep 2019 19:27:18 +0800 Subject: [PATCH 1/1] net/bnxt: enforce IO barrier for doorbell command The doorbell ringing operation requires a rte_io_mb immediately to make the command complete and visible to the device before reading the response, otherwise it may read stale or invalid responses. Fixes: ca241d9a0952 ("net/bnxt: use I/O device memory read/write API") Cc: stable@dpdk.org Signed-off-by: Gavin Hu Acked-by: Ajit Khaparde --- drivers/net/bnxt/bnxt_hwrm.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index d7c33d21e2..cdb6fa4f7e 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -146,6 +146,12 @@ static int bnxt_hwrm_send_message(struct bnxt *bp, void *msg, /* Ring channel doorbell */ bar = (uint8_t *)bp->bar0 + mb_trigger_offset; rte_write32(1, bar); + /* + * Make sure the channel doorbell ring command complete before + * reading the response to avoid getting stale or invalid + * responses. + */ + rte_io_mb(); /* Poll for the valid bit */ for (i = 0; i < timeout; i++) { -- 2.20.1