From patchwork Sun Aug 15 20:15:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 497581 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_HEADER_CTYPE_ONLY, SPF_HELO_NONE, SPF_PASS, T_TVD_MIME_NO_HEADERS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2315AC4320A for ; Sun, 15 Aug 2021 20:16:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 03DFD61181 for ; Sun, 15 Aug 2021 20:15:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230498AbhHOUQ2 (ORCPT ); Sun, 15 Aug 2021 16:16:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229582AbhHOUQ1 (ORCPT ); Sun, 15 Aug 2021 16:16:27 -0400 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16CE2C061764 for ; Sun, 15 Aug 2021 13:15:57 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id bo18so23425789pjb.0 for ; Sun, 15 Aug 2021 13:15:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=q0exBt4B/jgWCBtT3iMRX1mUy0GWZHfoeANY091bjFM=; b=POdwGz0rRoqC3x6ysETWVHgb/eBgXG2GHFya9cn1bA9qmGTgnMpJY7/iDtmgATR90G 6NdZ71tW5DljELX2vykiugL5ZwES+9EJgEM1P2mrJdOFHzOEmue8yJcWWqkNWL13RFxG 2dkHw2+mcc09af0XA3WhNrzj9H20bcesRCgtk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=q0exBt4B/jgWCBtT3iMRX1mUy0GWZHfoeANY091bjFM=; b=Kl3BxCyWr4ymFZYENnzBEOVCQL1Kpr3A43vgP/nxJ5FtPmJkx0PqyIBFBUAtFFCm3L lScfZuJOE91BWeSmkSx7uF9LO1TZn1X5xpB8pcfQIMiet++u4mqc/411e+5FeTRgeWkK qQx8MCI56LvFxgS/PqO7cfcYHzhX9m8THU4XztH2SQkj4vln55JJtU+9oyFiNXrbQWrj 6qu5/5DR5FP8rcxLjhurvEDxWot62dwlyhlr3xQJOZ5QA/gE//tYWsPH3HbKfAXPAesr SznXAV5z8UevgNnaqUSYVTG81fbhiQLGt1xH5c197GcCqHtlv1DjWkdKC1TP1b9MsNK/ 45ng== X-Gm-Message-State: AOAM530sbxhrDkZk+8sYUmh9jOH50WYx00pEh+lQVdfh285cqG5KnFj2 DiWUpU/XlMzt996YB5XRypL1ztLmZlwd5A== X-Google-Smtp-Source: ABdhPJxg58WQ5rbk5WwvpkmSVoUxrOJky3BUoLp+NRzj4nZ4hP4tsWdvBoykuehEIA6TVYryfghEaw== X-Received: by 2002:a63:dc03:: with SMTP id s3mr12834692pgg.88.1629058556401; Sun, 15 Aug 2021 13:15:56 -0700 (PDT) Received: from localhost.swdvt.lab.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id n18sm9098510pfu.3.2021.08.15.13.15.53 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 15 Aug 2021 13:15:56 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, kuba@kernel.org, gospo@broadcom.com Subject: [PATCH net 2/2] bnxt_en: Add missing DMA memory barriers Date: Sun, 15 Aug 2021 16:15:37 -0400 Message-Id: <1629058537-23284-3-git-send-email-michael.chan@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1629058537-23284-1-git-send-email-michael.chan@broadcom.com> References: <1629058537-23284-1-git-send-email-michael.chan@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Each completion ring entry has a valid bit to indicate that the entry contains a valid completion event. The driver's main poll loop __bnxt_poll_work() has the proper dma_rmb() to make sure the valid bit of the next entry has been checked before proceeding further. But when we call bnxt_rx_pkt() to process the RX event, the RX completion event consists of two completion entries and only the first entry has been checked to be valid. We need the same barrier after checking the next completion entry. Add missing dma_rmb() barriers in bnxt_rx_pkt() and other similar locations. Fixes: 67a95e2022c7 ("bnxt_en: Need memory barrier when processing the completion ring.") Reported-by: Lance Richardson Reviewed-by: Andy Gospodarek Reviewed-by: Lance Richardson Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 207ef7dc9bff..8a97640cdfe7 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -1788,6 +1788,10 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, if (!RX_CMP_VALID(rxcmp1, tmp_raw_cons)) return -EBUSY; + /* The valid test of the entry must be done first before + * reading any further. + */ + dma_rmb(); prod = rxr->rx_prod; if (cmp_type == CMP_TYPE_RX_L2_TPA_START_CMP) { @@ -2010,6 +2014,10 @@ static int bnxt_force_rx_discard(struct bnxt *bp, if (!RX_CMP_VALID(rxcmp1, tmp_raw_cons)) return -EBUSY; + /* The valid test of the entry must be done first before + * reading any further. + */ + dma_rmb(); cmp_type = RX_CMP_TYPE(rxcmp); if (cmp_type == CMP_TYPE_RX_L2_CMP) { rxcmp1->rx_cmp_cfa_code_errors_v2 |= @@ -2475,6 +2483,10 @@ static int bnxt_poll_nitroa0(struct napi_struct *napi, int budget) if (!TX_CMP_VALID(txcmp, raw_cons)) break; + /* The valid test of the entry must be done first before + * reading any further. + */ + dma_rmb(); if ((TX_CMP_TYPE(txcmp) & 0x30) == 0x10) { tmp_raw_cons = NEXT_RAW_CMP(raw_cons); cp_cons = RING_CMP(tmp_raw_cons);