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 88EBBA0C4C for ; Mon, 12 Jul 2021 15:13:10 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7EAFB406B4; Mon, 12 Jul 2021 15:13:10 +0200 (CEST) Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) by mails.dpdk.org (Postfix) with ESMTP id F11E2406B4 for ; Mon, 12 Jul 2021 15:13:09 +0200 (CEST) Received: by mail-wm1-f46.google.com with SMTP id k32so8175587wms.4 for ; Mon, 12 Jul 2021 06:13:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KeLVJHUEAJf+06rV4TGbUVJUB72sa14HsJDXqUhab7U=; b=tMmEWWd1zfYyvhm6TKaChZYKk0Lzd3KTqv/xh8sbNaUOHhZgjRilHcQ7kQR/Wgosu5 VG7532lGdjD7DPe4h376UjoztWoAtMWrwq7LJjx8VCqHTfQ/+mbi/Se6BmbL6ceBgQ8e ypzGmL4MJbmi2Vp2LigwmFPjrY1FhLga3AoDGzmDFo7WL8wec3yHtsGz54KwvHR/7e0V uYkZfzWrgbLxKFlGcMFx1U1ZtLVyZLM1w9g2Sit7a/bx6A4DUSZrVSnDLXEg8EkRjg0R 1q8pVsjkxF29yu91b7Ke46/u5AnU+zSaV/ZFDFCeXeg+Wcc/9HAuemojV/cI/skpP1il MtvQ== 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:mime-version:content-transfer-encoding; bh=KeLVJHUEAJf+06rV4TGbUVJUB72sa14HsJDXqUhab7U=; b=NJrukA8KtlCFIevV2ls6F18qswi9YPf25yJDrK7fb+6RFpCh8p9csAsxC0Jk2bJDOV w+i0qI4gQL3Ty0f4aXC0UNNKBPYBuxw02Se4KUe0nkQQywPI0FCrpUGPJYtf41VoJ8i4 bekdgiqCN9vpChSqIOWRHX+w1G7N2XrDIQXWhoAv2XrO4XkZZpNnDCSA6LhwYffjnW2h oNDm2DYTaKkFO4O3KUb7y+rmu8fXLf6nzLpZ69akCoV0S7N1QSqU8/T0iXDEAVq0UIps XI5fe6IobF1IJGdAQAj7zH9jkXN76O8hybgdmnHDkabueKQ+S7E9DIHaMEJPPSI4nQqq Z/0A== X-Gm-Message-State: AOAM533yqkzLiBTwrLLKMpOdzputRw21INo8b24i93wm7vUkA+kjVbBh 9lAC7YctZjkzCgg6L0oVMOc= X-Google-Smtp-Source: ABdhPJxJvADpp+3MSUqGT0JT32T/H3bilPQ9sD8YCf5hEbJ72rYkSvy+WTEGrFbTE3UGXe8VnqrYDA== X-Received: by 2002:a7b:c111:: with SMTP id w17mr14408588wmi.163.1626095589781; Mon, 12 Jul 2021 06:13:09 -0700 (PDT) Received: from localhost ([2a01:4b00:f41a:3600:360b:9754:2e3a:c344]) by smtp.gmail.com with ESMTPSA id x1sm12652840wmc.31.2021.07.12.06.13.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jul 2021 06:13:09 -0700 (PDT) From: luca.boccassi@gmail.com To: David Marchand Cc: Min Hu , Haiyue Wang , dpdk stable Date: Mon, 12 Jul 2021 14:04:54 +0100 Message-Id: <20210712130551.2462159-59-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210712130551.2462159-1-luca.boccassi@gmail.com> References: <20210712130551.2462159-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'drivers/net: fix memzone allocations for DMA memory' has been queued to stable release 20.11.3 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 Sender: "stable" Hi, FYI, your patch has been queued to stable release 20.11.3 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 07/14/21. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/9df1311d3319ca9c645ef9b0c932d438142dbb71 Thanks. Luca Boccassi --- >From 9df1311d3319ca9c645ef9b0c932d438142dbb71 Mon Sep 17 00:00:00 2001 From: David Marchand Date: Tue, 6 Jul 2021 10:57:50 +0200 Subject: [PATCH] drivers/net: fix memzone allocations for DMA memory [ upstream commit d07fc02fb4b38c0dded75d2d21b976d68b494f0e ] Caught by code review. Using a random name for memzone allocations can result in init failures in the unlikely case that a name collision occurs. Use a simple sequential generator on 64 bits. Fixes: 3f50f072ff06 ("i40e: fix memzone freeing") Fixes: 22b123a36d07 ("net/avf: initialize PMD") Fixes: 5f0978e96220 ("net/ice/base: add OS specific implementation") Fixes: 737f30e1c3ab ("net/hns3: support command interface with firmware") Signed-off-by: David Marchand Acked-by: Min Hu (Connor) Acked-by: Haiyue Wang --- drivers/common/iavf/iavf_impl.c | 5 +++-- drivers/net/hns3/hns3_cmd.c | 4 +++- drivers/net/i40e/i40e_ethdev.c | 4 +++- drivers/net/ice/base/ice_osdep.h | 5 +++-- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/common/iavf/iavf_impl.c b/drivers/common/iavf/iavf_impl.c index fc0da31753..f80878b9fd 100644 --- a/drivers/common/iavf/iavf_impl.c +++ b/drivers/common/iavf/iavf_impl.c @@ -6,7 +6,6 @@ #include #include -#include #include #include @@ -19,13 +18,15 @@ iavf_allocate_dma_mem_d(__rte_unused struct iavf_hw *hw, u64 size, u32 alignment) { + static uint64_t iavf_dma_memzone_id; const struct rte_memzone *mz = NULL; char z_name[RTE_MEMZONE_NAMESIZE]; if (!mem) return IAVF_ERR_PARAM; - snprintf(z_name, sizeof(z_name), "iavf_dma_%"PRIu64, rte_rand()); + snprintf(z_name, sizeof(z_name), "iavf_dma_%" PRIu64, + __atomic_fetch_add(&iavf_dma_memzone_id, 1, __ATOMIC_RELAXED)); mz = rte_memzone_reserve_bounded(z_name, size, SOCKET_ID_ANY, RTE_MEMZONE_IOVA_CONTIG, alignment, RTE_PGSIZE_2M); diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c index c6552b45d7..dc65ef8c26 100644 --- a/drivers/net/hns3/hns3_cmd.c +++ b/drivers/net/hns3/hns3_cmd.c @@ -44,10 +44,12 @@ static int hns3_allocate_dma_mem(struct hns3_hw *hw, struct hns3_cmq_ring *ring, uint64_t size, uint32_t alignment) { + static uint64_t hns3_dma_memzone_id; const struct rte_memzone *mz = NULL; char z_name[RTE_MEMZONE_NAMESIZE]; - snprintf(z_name, sizeof(z_name), "hns3_dma_%" PRIu64, rte_rand()); + snprintf(z_name, sizeof(z_name), "hns3_dma_%" PRIu64, + __atomic_fetch_add(&hns3_dma_memzone_id, 1, __ATOMIC_RELAXED)); mz = rte_memzone_reserve_bounded(z_name, size, SOCKET_ID_ANY, RTE_MEMZONE_IOVA_CONTIG, alignment, RTE_PGSIZE_2M); diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index d617e9c71b..0dc20de9a0 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -4610,13 +4610,15 @@ i40e_allocate_dma_mem_d(__rte_unused struct i40e_hw *hw, u64 size, u32 alignment) { + static uint64_t i40e_dma_memzone_id; const struct rte_memzone *mz = NULL; char z_name[RTE_MEMZONE_NAMESIZE]; if (!mem) return I40E_ERR_PARAM; - snprintf(z_name, sizeof(z_name), "i40e_dma_%"PRIu64, rte_rand()); + snprintf(z_name, sizeof(z_name), "i40e_dma_%" PRIu64, + __atomic_fetch_add(&i40e_dma_memzone_id, 1, __ATOMIC_RELAXED)); mz = rte_memzone_reserve_bounded(z_name, size, SOCKET_ID_ANY, RTE_MEMZONE_IOVA_CONTIG, alignment, RTE_PGSIZE_2M); if (!mz) diff --git a/drivers/net/ice/base/ice_osdep.h b/drivers/net/ice/base/ice_osdep.h index 818bfa3b89..be51c64b67 100644 --- a/drivers/net/ice/base/ice_osdep.h +++ b/drivers/net/ice/base/ice_osdep.h @@ -21,7 +21,6 @@ #include #include #include -#include #include #include "ice_alloc.h" @@ -245,13 +244,15 @@ static inline void * ice_alloc_dma_mem(__rte_unused struct ice_hw *hw, struct ice_dma_mem *mem, u64 size) { + static uint64_t ice_dma_memzone_id; const struct rte_memzone *mz = NULL; char z_name[RTE_MEMZONE_NAMESIZE]; if (!mem) return NULL; - snprintf(z_name, sizeof(z_name), "ice_dma_%"PRIu64, rte_rand()); + snprintf(z_name, sizeof(z_name), "ice_dma_%" PRIu64, + __atomic_fetch_add(&ice_dma_memzone_id, 1, __ATOMIC_RELAXED)); mz = rte_memzone_reserve_bounded(z_name, size, SOCKET_ID_ANY, 0, 0, RTE_PGSIZE_2M); if (!mz) -- 2.30.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-07-12 13:41:39.713627984 +0100 +++ 0059-drivers-net-fix-memzone-allocations-for-DMA-memory.patch 2021-07-12 13:41:36.486122527 +0100 @@ -1 +1 @@ -From d07fc02fb4b38c0dded75d2d21b976d68b494f0e Mon Sep 17 00:00:00 2001 +From 9df1311d3319ca9c645ef9b0c932d438142dbb71 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit d07fc02fb4b38c0dded75d2d21b976d68b494f0e ] + @@ -16 +17,0 @@ -Cc: stable@dpdk.org @@ -29 +30 @@ -index 0c7d5c0dae..8919b0e7c3 100644 +index fc0da31753..f80878b9fd 100644 @@ -58 +59 @@ -index 44a4e2860d..175d48d14b 100644 +index c6552b45d7..dc65ef8c26 100644 @@ -76 +77 @@ -index 5b0a7f2537..7b230e2ed1 100644 +index d617e9c71b..0dc20de9a0 100644 @@ -79 +80 @@ -@@ -4554,13 +4554,15 @@ i40e_allocate_dma_mem_d(__rte_unused struct i40e_hw *hw, +@@ -4610,13 +4610,15 @@ i40e_allocate_dma_mem_d(__rte_unused struct i40e_hw *hw, @@ -97 +98 @@ -index 878c5597d4..154fe96e93 100644 +index 818bfa3b89..be51c64b67 100644 @@ -108 +109 @@ -@@ -260,13 +259,15 @@ static inline void * +@@ -245,13 +244,15 @@ static inline void *