From patchwork Sun Aug 7 14:32:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 73397 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp2804499qga; Sun, 7 Aug 2016 07:32:43 -0700 (PDT) X-Received: by 10.55.79.4 with SMTP id d4mr24102578qkb.95.1470580363616; Sun, 07 Aug 2016 07:32:43 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id w7si14927852qka.156.2016.08.07.07.32.43; Sun, 07 Aug 2016 07:32:43 -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 D131A60DE5; Sun, 7 Aug 2016 14:32:42 +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, URIBL_BLOCKED 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 DD60760DDF; Sun, 7 Aug 2016 14:32:38 +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 43F7060DE2; Sun, 7 Aug 2016 14:32:37 +0000 (UTC) Received: from mail-oi0-f42.google.com (mail-oi0-f42.google.com [209.85.218.42]) by lists.linaro.org (Postfix) with ESMTPS id 7BED860DDD for ; Sun, 7 Aug 2016 14:32:36 +0000 (UTC) Received: by mail-oi0-f42.google.com with SMTP id j185so418478203oih.0 for ; Sun, 07 Aug 2016 07:32:36 -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=fDMHiXiQWmeSJRsIr3p90F4EcAr5SOp+zs2mCXrhdmk=; b=NFfxu18+FRibzQ4WjbPuuMnAUKW+nQzkqEbNbH4WeGq0C+pcA9PrtcR0cpOZ9qAHtC VZ6oFeAhSYQ33zrBo2lc+b9mk0hms7lidV1fFbQZrnkDBsVpZxtRqgb+N0WdppMWW/Uf 7oSEUx35wLEwTl2N28/+MNH5H1RHy7z0Xzdkx5/YWe480FMdsKJzRKT03Esp/RsOcDag aGiuIcmuNkBvg7+yFE6TxpZkzJttLKD/UDJaInY7oRCc6xIUhDUEMY2gE+abjhUt6xTp ax6RMnB1mN8UEahMNykqe+LRkUQktEij/LRkmZ9aaFaPnkxG7yJghHISeh4fm3meiZX6 7j/g== X-Gm-Message-State: AEkoouvJNQk1H2mOR32KxKoDVpVDlTFt6bA0o+LVEblMVLkdGOxLMve4e4cH+dPps2WJLPymL7g= X-Received: by 10.157.41.40 with SMTP id d37mr21826369otb.69.1470580355974; Sun, 07 Aug 2016 07:32:35 -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 n18sm7351461ota.27.2016.08.07.07.32.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 07 Aug 2016 07:32:35 -0700 (PDT) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Sun, 7 Aug 2016 09:32:32 -0500 Message-Id: <1470580352-11514-1-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.7.4 X-Topics: patch Subject: [lng-odp] [PATCH] 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 --- 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 e668bf9..07db534 100644 --- a/platform/linux-generic/odp_traffic_mngr.c +++ b/platform/linux-generic/odp_traffic_mngr.c @@ -2613,6 +2613,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(); @@ -2629,9 +2636,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;