From patchwork Wed Aug 10 20:41:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 73694 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp585923qga; Wed, 10 Aug 2016 13:41:54 -0700 (PDT) X-Received: by 10.55.129.1 with SMTP id c1mr3505756qkd.53.1470861714398; Wed, 10 Aug 2016 13:41:54 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 11si25279331qko.102.2016.08.10.13.41.53; Wed, 10 Aug 2016 13:41:54 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 08A84607A3; Wed, 10 Aug 2016 20:41:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id B6F476072B; Wed, 10 Aug 2016 20:41:32 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id ACD756072B; Wed, 10 Aug 2016 20:41:30 +0000 (UTC) Received: from mail-oi0-f49.google.com (mail-oi0-f49.google.com [209.85.218.49]) by lists.linaro.org (Postfix) with ESMTPS id 7352C606A6 for ; Wed, 10 Aug 2016 20:41:29 +0000 (UTC) Received: by mail-oi0-f49.google.com with SMTP id f189so75321110oig.3 for ; Wed, 10 Aug 2016 13:41:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=RpsxDdkLG6r0nUjVZrfWbvxcAeSS9NRWqSM6aJxI2Tc=; b=UMp34eXFOsMX/nxPir/lAQDV8k6UMR86D4eC+58R/XTt6MyqDrMFkXCgv2bsFCit7T Ubu98NR8b3/q0bGWZS7bZJWT9UblM8goNyQ0mvtavRkqPbISRxIlsa3JZw2WQIm1uixH m4REXj8g1o9PHFzwJZKEUyueJ/Wjmri0eKE3Jy/0uUnCMm6o1nEj3qIX4KF7S73RYcJw Cx2wzZ3jQX/X9i4AKs9YcN46wpPbvvjJJqoIx6lNtVdIrKcG0kCr3sO5mbC0zwsFirGs W4QhOr/Css62LBQkA6qMZhwVgWZ4Bw301/ahuQxlwVNkCwaNstgn+pOWRpfLpOh1RPml 34Hg== X-Gm-Message-State: AEkoouv276dYVfksf23lxKoThmQFbhVUPw0P9ltJOotYiF/N/xOCQ4CmAFPDJpuq63rLjAOKt8Q= X-Received: by 10.157.16.61 with SMTP id h58mr2854126ote.96.1470861688933; Wed, 10 Aug 2016 13:41:28 -0700 (PDT) Received: from localhost.localdomain (cpe-66-68-129-43.austin.res.rr.com. [66.68.129.43]) by smtp.gmail.com with ESMTPSA id t139sm20772773oie.6.2016.08.10.13.41.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 Aug 2016 13:41:28 -0700 (PDT) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Wed, 10 Aug 2016 15:41:26 -0500 Message-Id: <1470861686-15663-1-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.7.4 X-Topics: patch Subject: [lng-odp] [PATCHv2] linux-generic: tm: handle pktout queue check properly X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Resolve bug https://bugs.linaro.org/show_bug.cgi?id=2458 by only checking for a proper pktout_queue count if the egress_kind is ODP_TM_EGRESS_PKT_IO. This check is also moved before locking and allocating a tm_system struct to avoid deadlocks and memory leaks that were another side-effect of this bug. Signed-off-by: Bill Fischofer --- Note: This patch should be applied on top of patch http://patches.opendataplane.org/patch/6801/ platform/linux-generic/odp_traffic_mngr.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/platform/linux-generic/odp_traffic_mngr.c b/platform/linux-generic/odp_traffic_mngr.c index 37d3323..a5271ed 100644 --- a/platform/linux-generic/odp_traffic_mngr.c +++ b/platform/linux-generic/odp_traffic_mngr.c @@ -2818,6 +2818,13 @@ odp_tm_t odp_tm_create(const char *name, uint32_t max_tm_queues, max_sorted_lists; int rc; + /* If we are using pktio output (usual case) get the first associated + * pktout_queue for this pktio and fail if there isn't one. + */ + if (egress->egress_kind == ODP_TM_EGRESS_PKT_IO && + odp_pktout_queue(egress->pktio, &pktout, 1) != 1) + return ODP_TM_INVALID; + /* Allocate tm_system_t record. */ odp_ticketlock_lock(&tm_create_lock); tm_system = tm_system_alloc(); @@ -2834,9 +2841,6 @@ odp_tm_t odp_tm_create(const char *name, return ODP_TM_INVALID; } - if (odp_pktout_queue(egress->pktio, &pktout, 1) != 1) - return ODP_TM_INVALID; - tm_system->pktout = pktout; tm_system->name_tbl_id = name_tbl_id; max_tm_queues = requirements->max_tm_queues;