From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f195.google.com (mail-wr0-f195.google.com [209.85.128.195]) by dpdk.org (Postfix) with ESMTP id 83CE32BE2 for ; Tue, 1 May 2018 12:46:54 +0200 (CEST) Received: by mail-wr0-f195.google.com with SMTP id v15-v6so10476287wrm.10 for ; Tue, 01 May 2018 03:46:54 -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; bh=0ztMkDV7RH8dopJ6uq4FZVoOTR6UJ1mgIV/o0IzHm20=; b=mNSk6FdI4sRY0N8roeEmn9veRgZp0lNtSLAWCGi+3fkHuL+nIyTQzOP/KkwcgysZUF zs+NVUzZK0YHAwfL+zK3N8L2Pf8JOLF0zgyIPk0VIMUepS9VHcdSvKnW660YIf9yVrXK wHikq1cdHQw8jv4DtLbGREHnN0PkSnv3Wk7Q8hxq1BQLUcbP64tEr4ebA3WG1i11tb2X IrgrS4dVaIZbr7tkc4ONzmctvQE7hWNtm6j2UzHNackn8KIcXjEqhS0rNvkrkoitIqq1 Xrh3NAN86aoggzop80fRB0NXR075LhNnKQrGum14ZrtLO1SZEXfeSFWCXI2COB2q9DUs lo5g== 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=0ztMkDV7RH8dopJ6uq4FZVoOTR6UJ1mgIV/o0IzHm20=; b=VcqzMnsNUIICfUyx34yq0L9XaILZoRUmiDv4ZpaCvvRp/W0IT5R8TxEEAx87l8qnkl Qgl7zhV4yMa4UfRGkmU37I0rXmyDR1MTcWcgFMQrRGcncA/L0GPoa1yuaoHClThve9rj X1vWxrLd9m8olVyoO9jbZ1IFuobQmiagcU/lfBBWd5smrvKJ7vrZjnnA0fpCKmJ4d20Y b+vknqECRAFbxg4gQ1qgEkdht8VMPDbvBwUiL7crNSjeDHJWaRlw836SorFOgvVeItq+ 0KYbvGIqxDshUDoqk+/FnlqM1UeUIPQ4uSoN2WV3KZrn82+vcGa5j+xT/ZQeLM7B8maq 7vfg== X-Gm-Message-State: ALQs6tAtZASpKSQvbiaS1/pYE0s8GdnuJSAn2jXIfzhzqDK8qgMquO0y j6/eDE1p2pfDxFOs8CXg6zwpkTIcyS4= X-Google-Smtp-Source: AB8JxZp+GhwJqcrgpcKeDXzOHwhuZQ1QbfRl14aVvRCi6i4Ymf+YugzSxwwB2tN55PEZh2l9D+XXGw== X-Received: by 2002:adf:a00d:: with SMTP id k13-v6mr11182988wrk.39.1525171614483; Tue, 01 May 2018 03:46:54 -0700 (PDT) Received: from localhost (slip139-92-244-193.lon.uk.prserv.net. [139.92.244.193]) by smtp.gmail.com with ESMTPSA id u35-v6sm9401924wrc.29.2018.05.01.03.46.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 01 May 2018 03:46:53 -0700 (PDT) From: luca.boccassi@gmail.com To: Hyong Youb Kim Cc: John Daley , dpdk stable Date: Tue, 1 May 2018 11:44:37 +0100 Message-Id: <20180501104509.17238-14-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180501104509.17238-1-luca.boccassi@gmail.com> References: <20180501104509.17238-1-luca.boccassi@gmail.com> Subject: [dpdk-stable] patch 'net/enic: allocate stats DMA buffer upfront during probe' has been queued to LTS release 16.11.7 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2018 10:46:55 -0000 Hi, FYI, your patch has been queued to LTS release 16.11.7 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 05/03/18. So please shout if anyone has objections. Thanks. Luca Boccassi --- >>From acf47335cb9ed18b4b31ee7661d624f57920dce6 Mon Sep 17 00:00:00 2001 From: Hyong Youb Kim Date: Wed, 7 Mar 2018 18:46:58 -0800 Subject: [PATCH] net/enic: allocate stats DMA buffer upfront during probe [ upstream commit 8d782f3f89e1dcd0c8af1c3c93501d7a06159d66 ] The driver provides a DMA buffer to the firmware when it requests port stats. The NIC then fills that buffer with latest stats. Currently, the driver allocates the DMA buffer the first time it requests stats and saves it for later use. This can lead to crashes when primary/secondary processes are involved. For example, the following sequence crashes the secondary process. 1. Start a primary app that does not call rte_eth_stats_get() 2. dpdk-procinfo -- --stats dpdk-procinfo crashes while trying to allocate the stats DMA buffer because the alloc function pointer (vdev.alloc_consistent) is valid only in the primary process, not in the secondary process. Overwriting the alloc function pointer in the secondary process is not an option, as it will simply make the pointer invalid in the primary process. Instead, allocate the DMA buffer during probe so that only the primary process does both allocate and free. This allows the secondary process to dump stats as well. Fixes: 9913fbb91df0 ("enic/base: common code") Signed-off-by: Hyong Youb Kim Reviewed-by: John Daley --- drivers/net/enic/base/vnic_dev.c | 24 ++++++++++++++---------- drivers/net/enic/base/vnic_dev.h | 1 + drivers/net/enic/enic_main.c | 9 +++++++++ 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/drivers/net/enic/base/vnic_dev.c b/drivers/net/enic/base/vnic_dev.c index 1cd031acd..6e33c841c 100644 --- a/drivers/net/enic/base/vnic_dev.c +++ b/drivers/net/enic/base/vnic_dev.c @@ -538,17 +538,9 @@ int vnic_dev_stats_dump(struct vnic_dev *vdev, struct vnic_stats **stats) { u64 a0, a1; int wait = 1000; - static u32 instance; - char name[NAME_MAX]; - if (!vdev->stats) { - snprintf((char *)name, sizeof(name), - "vnic_stats-%d", instance++); - vdev->stats = vdev->alloc_consistent(vdev->priv, - sizeof(struct vnic_stats), &vdev->stats_pa, (u8 *)name); - if (!vdev->stats) - return -ENOMEM; - } + if (!vdev->stats) + return -ENOMEM; *stats = vdev->stats; a0 = vdev->stats_pa; @@ -940,6 +932,18 @@ u32 vnic_dev_get_intr_coal_timer_max(struct vnic_dev *vdev) return vdev->intr_coal_timer_info.max_usec; } +int vnic_dev_alloc_stats_mem(struct vnic_dev *vdev) +{ + char name[NAME_MAX]; + static u32 instance; + + snprintf((char *)name, sizeof(name), "vnic_stats-%u", instance++); + vdev->stats = vdev->alloc_consistent(vdev->priv, + sizeof(struct vnic_stats), + &vdev->stats_pa, (u8 *)name); + return vdev->stats == NULL ? -ENOMEM : 0; +} + void vnic_dev_unregister(struct vnic_dev *vdev) { if (vdev) { diff --git a/drivers/net/enic/base/vnic_dev.h b/drivers/net/enic/base/vnic_dev.h index 06ebd4cea..7af91cfc4 100644 --- a/drivers/net/enic/base/vnic_dev.h +++ b/drivers/net/enic/base/vnic_dev.h @@ -191,6 +191,7 @@ struct vnic_dev *vnic_dev_register(struct vnic_dev *vdev, void *priv, struct rte_pci_device *pdev, struct vnic_dev_bar *bar, unsigned int num_bars); struct rte_pci_device *vnic_dev_get_pdev(struct vnic_dev *vdev); +int vnic_dev_alloc_stats_mem(struct vnic_dev *vdev); int vnic_dev_cmd_init(struct vnic_dev *vdev, int fallback); int vnic_dev_get_size(void); int vnic_dev_int13(struct vnic_dev *vdev, u64 arg, u32 op); diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c index 63d0c50d6..bcac51b55 100644 --- a/drivers/net/enic/enic_main.c +++ b/drivers/net/enic/enic_main.c @@ -1377,6 +1377,15 @@ int enic_probe(struct enic *enic) enic_alloc_consistent, enic_free_consistent); + /* + * Allocate the consistent memory for stats upfront so both primary and + * secondary processes can dump stats. + */ + err = vnic_dev_alloc_stats_mem(enic->vdev); + if (err) { + dev_err(enic, "Failed to allocate cmd memory, aborting\n"); + goto err_out_unregister; + } /* Issue device open to get device in known state */ err = enic_dev_open(enic); if (err) { -- 2.14.2