From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1783E45AA5 for ; Fri, 4 Oct 2024 03:05:41 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0B8DB40696; Fri, 4 Oct 2024 03:05:41 +0200 (CEST) Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by mails.dpdk.org (Postfix) with ESMTP id 3C7934065E for ; Fri, 4 Oct 2024 03:05:38 +0200 (CEST) Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e035949cc4eso2445492276.1 for ; Thu, 03 Oct 2024 18:05:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1728003937; x=1728608737; darn=dpdk.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=rzZ38K8KwbsDPud8OdmHx5OvqwGG/I3Nc1W9gLbNW54=; b=t99tGzcU0iyq6/UseeI6Y/XWxVpFvRyIxOWImBlRMHwKcRQjDlFXNgXMDxuhO/qG2V 1aQwU0tlrdWpVRXoYNc++lL3+6YrPnaXn2BKjNQ9iwRB3Cx84G7HWOIj46WRZqM0sjwZ ZrOSgBpSUGHofhSt3r64fd/iomLEev1gAWF2PzjkABnue7X61Bbq+LOr1V0bx6dS2EFW z8JM9z1Hxqe9Um/W7f+Bhs2jNELMudIcq2LKKp/1/qdFPCV6L/5LbDKJleXHFoX2loJX 1AIxXupZ13+eMVUZe+X27+Q5FdOsro2X7NylHRhrpGmgM5BoWZIlTkewoxOhPnokEtZw 8OtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728003937; x=1728608737; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=rzZ38K8KwbsDPud8OdmHx5OvqwGG/I3Nc1W9gLbNW54=; b=FH5XtBAL4D08+9DVLvo4izBiVkkQ1k4F+Oa63bratByZGLf/DQLzTXBpt9RQ/3Qju5 1oH5+lftecOUXYaPpQmnHHh7Y92BQbn7X6Bxv3EnkBpmxcGbrmCT6mrD34U1+F7KPZ4k +NI5XreZcEgRManhIzNaQ8LFAiDMT7FwipGrxiKzJCrjMyiuBFTjCT9Z1FFM4q8oZkQs 02GfH+WvgZLBZpGSRy7APLC+GecRfwRhpEB8aeOsHJ0f7Z95VPGgAYeC6cqIq2raA3X6 5QmKB2YU77020FXkwlVE+qMSHCVjNyuk9alAbvdgrER/HfNOvs6BVuPY5JXsoHpqZZA0 B0kA== X-Forwarded-Encrypted: i=1; AJvYcCV5Y2jYxjUhm/9Hak+aIvoxD3MYSTwmx9LkGl63nahIVC9eDf4RNGoW78Pe5zUlpLbCWEGAC38=@dpdk.org X-Gm-Message-State: AOJu0YwL0JftH56LP8hdmxEwtxtzUZVIiQrNzoL7EgxPt+o88XADYVkc m906mSk2oK+a1SkLfiTBE6C23ZmQ6p1ErqIRabA6ZlCTdv2DBibGuGC1AzcmNKcpAclCYSwqHSc T5uOKEFXjbg== X-Google-Smtp-Source: AGHT+IHwExxludYmW0LXBsZmdYL9BWovzK9y6Knjyruktr1XWR2aRPjerAaknQRY891PW06aAobxYZatfkQm8w== X-Received: from joshwash.sea.corp.google.com ([2620:15c:11c:202:c808:ef77:413b:184d]) (user=joshwash job=sendgmr) by 2002:a05:6902:180a:b0:e25:e5b9:8114 with SMTP id 3f1490d57ef6-e28936d0652mr1936276.4.1728003937459; Thu, 03 Oct 2024 18:05:37 -0700 (PDT) Date: Thu, 3 Oct 2024 18:05:35 -0700 Mime-Version: 1.0 X-Mailer: git-send-email 2.47.0.rc0.187.ge670bccf7e-goog Message-ID: <20241004010535.239103-1-joshwash@google.com> Subject: [PATCH] net/gve: add IO memory barriers before reading descriptors From: Joshua Washington To: Jeroen de Borst , Rushil Gupta , Joshua Washington , Junfeng Guo Cc: dev@dpdk.org, stable@dpdk.org, Ferruh Yigit , Praveen Kaligineedi Content-Type: text/plain; charset="UTF-8" X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Without memory barriers, there is no guarantee that the CPU will actually wait until after the descriptor has been fully written before loading descriptor data. In this case, it is possible that stale data is read and acted on by the driver when processing TX or RX completions. This change adds read memory barriers just after the generation bit is read in both the RX and the TX path to ensure that the NIC has properly passed ownership to the driver before descriptor data is read in full. Note that memory barriers should not be needed after writing the RX buffer queue/TX descriptor queue tails because rte_write32 includes an implicit write memory barrier. Fixes: 4022f9999f56 ("net/gve: support basic Tx data path for DQO") Fixes: 45da16b5b181 ("net/gve: support basic Rx data path for DQO") Cc: junfeng.guo@intel.com Cc: stable@dpdk.org Signed-off-by: Joshua Washington Reviewed-by: Praveen Kaligineedi Reviewed-by: Rushil Gupta --- drivers/net/gve/gve_rx_dqo.c | 2 ++ drivers/net/gve/gve_tx_dqo.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/drivers/net/gve/gve_rx_dqo.c b/drivers/net/gve/gve_rx_dqo.c index 5371bab77d..285c6ddd61 100644 --- a/drivers/net/gve/gve_rx_dqo.c +++ b/drivers/net/gve/gve_rx_dqo.c @@ -132,6 +132,8 @@ gve_rx_burst_dqo(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) if (rx_desc->generation != rxq->cur_gen_bit) break; + rte_io_rmb(); + if (unlikely(rx_desc->rx_error)) { rxq->stats.errors++; continue; diff --git a/drivers/net/gve/gve_tx_dqo.c b/drivers/net/gve/gve_tx_dqo.c index 731c287224..6984f92443 100644 --- a/drivers/net/gve/gve_tx_dqo.c +++ b/drivers/net/gve/gve_tx_dqo.c @@ -24,6 +24,8 @@ gve_tx_clean_dqo(struct gve_tx_queue *txq) if (compl_desc->generation != txq->cur_gen_bit) return; + rte_io_rmb(); + compl_tag = rte_le_to_cpu_16(compl_desc->completion_tag); aim_txq = txq->txqs[compl_desc->id]; -- 2.47.0.rc0.187.ge670bccf7e-goog