From patchwork Thu Apr 26 16:26:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrien Mazarguil X-Patchwork-Id: 39050 X-Patchwork-Delegate: shahafs@mellanox.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B6B348E60; Thu, 26 Apr 2018 18:26:28 +0200 (CEST) Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) by dpdk.org (Postfix) with ESMTP id C03818E60 for ; Thu, 26 Apr 2018 18:26:27 +0200 (CEST) Received: by mail-wr0-f196.google.com with SMTP id o4-v6so7122327wrm.0 for ; Thu, 26 Apr 2018 09:26:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=mJ9mYbhPa7yuCo44+dZy831eqd362zslJC7swJXrC6c=; b=bNMj0Tdy2yUuZsqIH94PNgqdQO+PPfJX1CWFoCvyeiUoHPiInps0QtoNiB4SdeAzJz 8lG5B8HNLV4pWv6YIVfhqix1NDc5OPJFdd3K0LHhPHwqRs1/fisBCg4S2aYfTgmBnd4U uMoRQX1YIGUnXTDdCMsWPz1Df9eh0o4AWATWZmUWhaE9sB9JbqdamPH9jmhQ+BaSIQ70 RDX7kA19sacyfkmpaiRGJVRGXhFxGCmjR4iT/Z6Saveo4vIDRjOBZzMVIWU0+Vky7Fib h/qXHwNmQc9Xxnigs2uYKEwouXe0wCuyGE7LxtsNRU+iEFFdcHh8i8RqrF2fTZ3PSIqO tLPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=mJ9mYbhPa7yuCo44+dZy831eqd362zslJC7swJXrC6c=; b=GbzM18/nqxdTVcPsw8RFzjMYK+TokISme3yXXcjXbPILccSoLH3eO/+fLezVETD6RO enb5PI/cLrPjI+v64rr28knha7Sktmhi9ySvRavk33L300Z4rA6uBVqEJdeZaOnRZuAj lNR9usQ0VWjUe3yJP5fDe0H3Tr+wv89jYMawBjvoU/3pTdkkuvD4pRmlGbIJ3/AxoTN2 XmlH0qiZITd2nGax/0kvnPBlhnoMp9itvj7z8jzqAtleQ6cOFwB3TqGgpNaeuCHajnwl PI1v/jN1WLT5dk6yNGKjLzszgPEz0MLawVpV51ZbMyV2bAioUfr2TTBeUZzC4KC9o1pG KXaw== X-Gm-Message-State: ALQs6tC6U61Gjv8EQMv3VEys7UK8DwEW1BR4V1yq5q+RxxdrlQkdEYNK 9EKjdOHdhM6CwpWKX3ZNaRIqCg== X-Google-Smtp-Source: AIpwx4/5KIY+IhoZGLcRgn6biMw9gmP24Ax0qUTg8U0aANTbMIhwYhZpY66ZergkAo8PVrMTiC06MA== X-Received: by 2002:adf:bd86:: with SMTP id l6-v6mr26855787wrh.266.1524759987463; Thu, 26 Apr 2018 09:26:27 -0700 (PDT) Received: from 6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id m134sm5138863wmg.4.2018.04.26.09.26.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Apr 2018 09:26:26 -0700 (PDT) Date: Thu, 26 Apr 2018 18:26:13 +0200 From: Adrien Mazarguil To: Shahaf Shuler Cc: Ferruh Yigit , dev@dpdk.org, stable@dpdk.org Message-ID: <20180426162142.6617-1-adrien.mazarguil@6wind.com> References: <20180425153739.9157-1-adrien.mazarguil@6wind.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20180425153739.9157-1-adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.11.0 Subject: [dpdk-dev] [PATCH v2 1/3] net/mlx4: fix Rx resource leak in case of error X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" When creation of a flow rule fails during dev_start(), the usage count of the common RSS context is not decremented, which triggers an assertion failure in debug mode during dev_close(). This is addressed by tracking the initialization status of the common RSS context in order to add missing cleanup code. A similar issue exists in mlx4_rxq_attach(), where usage count is incremented on a Rx queue but not released in case of error. This may lead to the above issue since RSS contexts created by flow rules attach themselves to Rx queues, incrementing their usage count. Fixes: 5697a4142107 ("net/mlx4: relax Rx queue configuration order") Cc: stable@dpdk.org Signed-off-by: Adrien Mazarguil --- drivers/net/mlx4/mlx4.c | 6 ++++-- drivers/net/mlx4/mlx4.h | 1 + drivers/net/mlx4/mlx4_rxq.c | 7 +++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index 970d20dd1..3dd72dbf5 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -61,6 +61,8 @@ const char *pmd_mlx4_init_params[] = { NULL, }; +static void mlx4_dev_stop(struct rte_eth_dev *dev); + /** * DPDK callback for Ethernet device configuration. * @@ -143,8 +145,7 @@ mlx4_dev_start(struct rte_eth_dev *dev) dev->rx_pkt_burst = mlx4_rx_burst; return 0; err: - /* Rollback. */ - priv->started = 0; + mlx4_dev_stop(dev); return ret; } @@ -194,6 +195,7 @@ mlx4_dev_close(struct rte_eth_dev *dev) dev->tx_pkt_burst = mlx4_tx_burst_removed; rte_wmb(); mlx4_flow_clean(priv); + mlx4_rss_deinit(priv); for (i = 0; i != dev->data->nb_rx_queues; ++i) mlx4_rx_queue_release(dev->data->rx_queues[i]); for (i = 0; i != dev->data->nb_tx_queues; ++i) diff --git a/drivers/net/mlx4/mlx4.h b/drivers/net/mlx4/mlx4.h index 45846554b..415b7d40f 100644 --- a/drivers/net/mlx4/mlx4.h +++ b/drivers/net/mlx4/mlx4.h @@ -103,6 +103,7 @@ struct priv { uint32_t vf:1; /**< This is a VF device. */ uint32_t intr_alarm:1; /**< An interrupt alarm is scheduled. */ uint32_t isolated:1; /**< Toggle isolated mode. */ + uint32_t rss_init:1; /**< Common RSS context is initialized. */ uint32_t hw_csum:1; /**< Checksum offload is supported. */ uint32_t hw_csum_l2tun:1; /**< Checksum support for L2 tunnels. */ uint32_t hw_fcs_strip:1; /**< FCS stripping toggling is supported. */ diff --git a/drivers/net/mlx4/mlx4_rxq.c b/drivers/net/mlx4/mlx4_rxq.c index b430678c7..65f099423 100644 --- a/drivers/net/mlx4/mlx4_rxq.c +++ b/drivers/net/mlx4/mlx4_rxq.c @@ -336,6 +336,8 @@ mlx4_rss_init(struct priv *priv) unsigned int i; int ret; + if (priv->rss_init) + return 0; /* Prepare range for RSS contexts before creating the first WQ. */ ret = mlx4_glue->dv_set_context_attr (priv->ctx, @@ -418,6 +420,7 @@ mlx4_rss_init(struct priv *priv) } wq_num_prev = wq_num; } + priv->rss_init = 1; return 0; error: ERROR("cannot initialize common RSS resources (queue %u): %s: %s", @@ -446,6 +449,8 @@ mlx4_rss_deinit(struct priv *priv) { unsigned int i; + if (!priv->rss_init) + return; for (i = 0; i != priv->dev->data->nb_rx_queues; ++i) { struct rxq *rxq = priv->dev->data->rx_queues[i]; @@ -454,6 +459,7 @@ mlx4_rss_deinit(struct priv *priv) mlx4_rxq_detach(rxq); } } + priv->rss_init = 0; } /** @@ -606,6 +612,7 @@ mlx4_rxq_attach(struct rxq *rxq) claim_zero(mlx4_glue->destroy_wq(wq)); if (cq) claim_zero(mlx4_glue->destroy_cq(cq)); + --rxq->usecnt; rte_errno = ret; ERROR("error while attaching Rx queue %p: %s: %s", (void *)rxq, msg, strerror(ret));