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 355F5A0C47 for ; Tue, 10 Aug 2021 17:41:56 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2C9F94014F; Tue, 10 Aug 2021 17:41:56 +0200 (CEST) Received: from smtp-relay-canonical-1.canonical.com (smtp-relay-canonical-1.canonical.com [185.125.188.121]) by mails.dpdk.org (Postfix) with ESMTP id 7699D411CA for ; Tue, 10 Aug 2021 17:41:55 +0200 (CEST) Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPS id 5ECDA3F0B8 for ; Tue, 10 Aug 2021 15:41:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1628610115; bh=KCa/XJUhWLBS53Lb+Z9jxbip4eZadWwdTELJ8Lui8aU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cBE+pMC5+O73zoRlqwAMkNklvG3lz1ahWJIPhn+uDcXaoJYWl5YHWCxcg6laUckzU GqKp25qo7aIRvmKswbtH5LBTuvo1gSK78xlq8KUf/ux34PBsDbG4/cUQrNjbM5oKYQ KURJI6NA+s16BGfZKOzeVW3YwBaX9IaMJsjgpPCW5yzog+xeS04//6GhqMVOd7dhhg l4alfyMzR4jIKCqLIPWSIA6r7CHkyCHWxKLNUE6690fBx/8BM4YdOys+yeId9EmgoS RF6OZN+LbnCKgvlK2wMfbki5MkKjpBrYRt2WjoUEgtu1n7N2h8zr7z8cRuH+bB0krB 8yHGOesOoMtfw== Received: by mail-ed1-f69.google.com with SMTP id eg56-20020a05640228b8b02903be79801f9aso1436593edb.21 for ; Tue, 10 Aug 2021 08:41:55 -0700 (PDT) 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=KCa/XJUhWLBS53Lb+Z9jxbip4eZadWwdTELJ8Lui8aU=; b=Kq5CIMXW46o71Wzw6sRM61R8VjbwXOQghxC5ibQB/EWJJpQ4pSmDDDG+in16mFMf2m k0ik4LQBVU0WLfr/OIWCQwWHqpR/V70XLDTcqy4UdRDEhvwW1fEEeb60yQjFCpufkTPi jTA14dPEsRyu35EDygzsWmB9UXUcwzHjln0vPsW73hA13UZcadFgFdEJNLcdn79Qm2Zd NGgCtTINhap10TzFZ4Cf3MHEf+Tl7M4JzkQGhYPwF4q1S3RsYgVMu2dT5LjdiIVn8kY3 902d20f6WaRuox/pBSM7FMQeIIa9FpjJoMO61uUYOn3GR3BPnMaF4ml8zBZUdWUem7hQ Aj5w== X-Gm-Message-State: AOAM530y/+8ExK1oyMAmTFFrscAIDLVxiIExeUEkdklzDr8I9k/EhYKt c+PQfS4CKYFf2cxTQRwv7SPkySac3vsnL/3W9Pn22ALw8OtN7IVQ40jTkPpSUJVRX4bkpM6fnbB GrHOu/DpiWm/K8EmpdiXb3eFa X-Received: by 2002:a05:6402:1a4c:: with SMTP id bf12mr5635785edb.137.1628610114891; Tue, 10 Aug 2021 08:41:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhuvt260IyccNqkgQKYstxRLAEAFzeGmHjc3fD/v34RLw/tNu8hNW37zLwSE21K+BSFcDYtQ== X-Received: by 2002:a05:6402:1a4c:: with SMTP id bf12mr5635771edb.137.1628610114718; Tue, 10 Aug 2021 08:41:54 -0700 (PDT) Received: from Keschdeichel.fritz.box ([2001:67c:1560:8007::aac:c4ad]) by smtp.gmail.com with ESMTPSA id f20sm6969858ejz.30.2021.08.10.08.41.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Aug 2021 08:41:54 -0700 (PDT) From: christian.ehrhardt@canonical.com To: David Marchand Cc: Min Hu , Haiyue Wang , dpdk stable Date: Tue, 10 Aug 2021 17:39:09 +0200 Message-Id: <20210810154022.749358-29-christian.ehrhardt@canonical.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210810154022.749358-1-christian.ehrhardt@canonical.com> References: <20210810154022.749358-1-christian.ehrhardt@canonical.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 19.11.10 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 19.11.10 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 08/12/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/cpaelzer/dpdk-stable-queue This queued commit can be viewed at: https://github.com/cpaelzer/dpdk-stable-queue/commit/9e9fa80269c4149159457c04714a91d7ae1bcef2 Thanks. Christian Ehrhardt --- >From 9e9fa80269c4149159457c04714a91d7ae1bcef2 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/net/hns3/hns3_cmd.c | 4 +++- drivers/net/i40e/i40e_ethdev.c | 4 +++- drivers/net/iavf/iavf_ethdev.c | 4 +++- drivers/net/ice/base/ice_osdep.h | 5 +++-- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c index ef03d31b22..07a3185f6b 100644 --- a/drivers/net/hns3/hns3_cmd.c +++ b/drivers/net/hns3/hns3_cmd.c @@ -59,10 +59,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 d825ef7296..e057f16e46 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -4604,13 +4604,15 @@ i40e_allocate_dma_mem_d(__attribute__((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/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c index d7d14ee11a..7d4b6b915c 100644 --- a/drivers/net/iavf/iavf_ethdev.c +++ b/drivers/net/iavf/iavf_ethdev.c @@ -1544,13 +1544,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); if (!mz) diff --git a/drivers/net/ice/base/ice_osdep.h b/drivers/net/ice/base/ice_osdep.h index ba0c57e1a9..5970c918d1 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" @@ -241,13 +240,15 @@ static inline void * ice_alloc_dma_mem(__attribute__((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.32.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-08-10 15:11:14.188230281 +0200 +++ 0029-drivers-net-fix-memzone-allocations-for-DMA-memory.patch 2021-08-10 15:11:12.954637638 +0200 @@ -1 +1 @@ -From d07fc02fb4b38c0dded75d2d21b976d68b494f0e Mon Sep 17 00:00:00 2001 +From 9e9fa80269c4149159457c04714a91d7ae1bcef2 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit d07fc02fb4b38c0dded75d2d21b976d68b494f0e ] + @@ -16 +17,0 @@ -Cc: stable@dpdk.org @@ -22 +22,0 @@ - drivers/common/iavf/iavf_impl.c | 5 +++-- @@ -24,0 +25 @@ + drivers/net/iavf/iavf_ethdev.c | 4 +++- @@ -26 +27 @@ - 4 files changed, 12 insertions(+), 6 deletions(-) + 4 files changed, 12 insertions(+), 5 deletions(-) @@ -28,29 +28,0 @@ -diff --git a/drivers/common/iavf/iavf_impl.c b/drivers/common/iavf/iavf_impl.c -index 0c7d5c0dae..8919b0e7c3 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); @@ -58 +30 @@ -index 44a4e2860d..175d48d14b 100644 +index ef03d31b22..07a3185f6b 100644 @@ -61 +33 @@ -@@ -44,10 +44,12 @@ static int +@@ -59,10 +59,12 @@ static int @@ -76 +48 @@ -index 5b0a7f2537..7b230e2ed1 100644 +index d825ef7296..e057f16e46 100644 @@ -79 +51 @@ -@@ -4554,13 +4554,15 @@ i40e_allocate_dma_mem_d(__rte_unused struct i40e_hw *hw, +@@ -4604,13 +4604,15 @@ i40e_allocate_dma_mem_d(__attribute__((unused)) struct i40e_hw *hw, @@ -95,0 +68,21 @@ +diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c +index d7d14ee11a..7d4b6b915c 100644 +--- a/drivers/net/iavf/iavf_ethdev.c ++++ b/drivers/net/iavf/iavf_ethdev.c +@@ -1544,13 +1544,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); + if (!mz) @@ -97 +90 @@ -index 878c5597d4..154fe96e93 100644 +index ba0c57e1a9..5970c918d1 100644 @@ -108,2 +101,2 @@ -@@ -260,13 +259,15 @@ static inline void * - ice_alloc_dma_mem(__rte_unused struct ice_hw *hw, +@@ -241,13 +240,15 @@ static inline void * + ice_alloc_dma_mem(__attribute__((unused)) struct ice_hw *hw,