From patchwork Wed Jul 8 18:01:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zoltan Kiss X-Patchwork-Id: 50905 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 517F9213FD for ; Wed, 8 Jul 2015 18:01:41 +0000 (UTC) Received: by lbbpo10 with SMTP id po10sf26145895lbb.1 for ; Wed, 08 Jul 2015 11:01:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :mime-version:content-type:content-transfer-encoding:errors-to :sender:x-original-sender:x-original-authentication-results :mailing-list; bh=tmraaYH1KHUu6V48gv/viS76xEIveVXGcXVH5HD4S7k=; b=VIaZwUc53OP+fwC6GfLqHGOKrOBIq1PnbX5bsMmTps7H8X/j/LeAL6E59oQauqSAbX N+EpdeDCphtBHHy5C2JUEoUs4bA2drHhLeC9Oh6VqeENYSVoH+TDH34D8M8I6LdFWPBe NmDgkHbmvfPWOhKXDpBdFDP1YLuC17regZ2diI9sWeTYCS1oegPTlgAlDAKRc63PVx+o i5Ga7ssrh/FBcz8Yljv4XOb+/Gm2Rny8g1ztmP1PUABdfIbZ/XiG5ALWydsbbnxf3HW6 42Jqu//X8iKRwno4fKZLhOcEFYIgx5F+rZdcCGKjqMikjb8bSnkzk/RybqEOefo+QPsk iCRg== X-Gm-Message-State: ALoCoQmUNFV33WqPivthyp6zfKC/nrfV0s3XK2JSS2EeDkWGPwTLRZ6TfjWcQbDDoWP42EYI8/9K X-Received: by 10.180.90.106 with SMTP id bv10mr21345264wib.6.1436378500297; Wed, 08 Jul 2015 11:01:40 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.227 with SMTP id t3ls981089laj.72.gmail; Wed, 08 Jul 2015 11:01:40 -0700 (PDT) X-Received: by 10.112.138.199 with SMTP id qs7mr10771870lbb.21.1436378500114; Wed, 08 Jul 2015 11:01:40 -0700 (PDT) Received: from mail-lb0-f170.google.com (mail-lb0-f170.google.com. [209.85.217.170]) by mx.google.com with ESMTPS id dp7si2565804lbc.155.2015.07.08.11.01.40 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Jul 2015 11:01:40 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) client-ip=209.85.217.170; Received: by lbnk3 with SMTP id k3so61051651lbn.1 for ; Wed, 08 Jul 2015 11:01:40 -0700 (PDT) X-Received: by 10.112.198.74 with SMTP id ja10mr10773800lbc.19.1436378499972; Wed, 08 Jul 2015 11:01:39 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp121492lbb; Wed, 8 Jul 2015 11:01:39 -0700 (PDT) X-Received: by 10.55.21.41 with SMTP id f41mr18636535qkh.48.1436378498586; Wed, 08 Jul 2015 11:01:38 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 21si3840404qgn.94.2015.07.08.11.01.36; Wed, 08 Jul 2015 11:01:38 -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; Received: by lists.linaro.org (Postfix, from userid 109) id 33B6061F6C; Wed, 8 Jul 2015 18:01:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252.ec2.internal 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 ip-10-142-244-252.ec2.internal (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 6E83561DF3; Wed, 8 Jul 2015 18:01:31 +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 3C62461E6C; Wed, 8 Jul 2015 18:01:30 +0000 (UTC) Received: from mail-wi0-f179.google.com (mail-wi0-f179.google.com [209.85.212.179]) by lists.linaro.org (Postfix) with ESMTPS id 4E93761D33 for ; Wed, 8 Jul 2015 18:01:29 +0000 (UTC) Received: by wibdq8 with SMTP id dq8so220305532wib.1 for ; Wed, 08 Jul 2015 11:01:28 -0700 (PDT) X-Received: by 10.194.185.236 with SMTP id ff12mr23750845wjc.134.1436378488294; Wed, 08 Jul 2015 11:01:28 -0700 (PDT) Received: from localhost.localdomain ([90.152.119.35]) by smtp.googlemail.com with ESMTPSA id q4sm4619998wja.24.2015.07.08.11.01.26 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Jul 2015 11:01:27 -0700 (PDT) From: Zoltan Kiss To: lng-odp@lists.linaro.org Date: Wed, 8 Jul 2015 19:01:09 +0100 Message-Id: <1436378469-20444-1-git-send-email-zoltan.kiss@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1436202717-13883-1-git-send-email-zoltan.kiss@linaro.org> References: <1436202717-13883-1-git-send-email-zoltan.kiss@linaro.org> X-Topics: patch Cc: Petri Savolainen Subject: [lng-odp] [API-NEXT PATCH v6] queue: handle return value of odp_queue_enq_multi() X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: zoltan.kiss@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Unsent packet has to be released. If the event type is obvious from the context, use directly the relevant release functions, otherwise odp_event(free). Wider error handling is attempted, but this patch can't fix all the flaws in the many calling functions of odp_queue_enq() Signed-off-by: Zoltan Kiss --- v5: fix array use in last hunk v6: handle negative 'ret' in last hunk test/performance/odp_pktio_perf.c | 15 ++++++++++++++- test/performance/odp_scheduling.c | 10 ++++++++-- test/validation/pktio/pktio.c | 5 +++++ test/validation/queue/queue.c | 4 ++++ 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/test/performance/odp_pktio_perf.c b/test/performance/odp_pktio_perf.c index 52bddc4..6e07c9f 100644 --- a/test/performance/odp_pktio_perf.c +++ b/test/performance/odp_pktio_perf.c @@ -270,6 +270,9 @@ static int alloc_packets(odp_event_t *event_tbl, int num_pkts) static int send_packets(odp_queue_t outq, odp_event_t *event_tbl, unsigned num_pkts) { + int ret; + unsigned cnt; + if (num_pkts == 0) return 0; else if (num_pkts == 1) { @@ -281,7 +284,17 @@ static int send_packets(odp_queue_t outq, } } - return odp_queue_enq_multi(outq, event_tbl, num_pkts); + ret = odp_queue_enq_multi(outq, event_tbl, num_pkts); + if (ret == (signed)num_pkts) + return ret; + + if (ret < 0) + ret = 0; + cnt = ret; + do + odp_event_free(event_tbl[cnt]); + while (++cnt < num_pkts); + return ret; } /* diff --git a/test/performance/odp_scheduling.c b/test/performance/odp_scheduling.c index 1283986..8b46eb2 100644 --- a/test/performance/odp_scheduling.c +++ b/test/performance/odp_scheduling.c @@ -535,9 +535,15 @@ static int test_schedule_multi(const char *str, int thr, } /* Assume we can enqueue all events */ - if (odp_queue_enq_multi(queue, ev, MULTI_BUFS_MAX) != - MULTI_BUFS_MAX) { + j = odp_queue_enq_multi(queue, ev, MULTI_BUFS_MAX); + if (j != MULTI_BUFS_MAX) { LOG_ERR(" [%i] Queue enqueue failed.\n", thr); + if (j < 0) + j = 0; + do + odp_event_free(ev[j]); + while (++j < MULTI_BUFS_MAX); + return -1; } } diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c index 9d5af22..ac12759 100644 --- a/test/validation/pktio/pktio.c +++ b/test/validation/pktio/pktio.c @@ -389,6 +389,11 @@ static void pktio_txrx_multi(pktio_info_t *pktio_a, pktio_info_t *pktio_b, ret = odp_queue_enq_multi(pktio_a->outq, tx_ev, num_pkts); if (ret != num_pkts) { CU_FAIL("failed to enqueue test packets"); + if (ret < 0) + ret = 0; + do + odp_packet_free(tx_pkt[ret]); + while (++ret < num_pkts); return; } } diff --git a/test/validation/queue/queue.c b/test/validation/queue/queue.c index 5f05e49..d598dbf 100644 --- a/test/validation/queue/queue.c +++ b/test/validation/queue/queue.c @@ -91,6 +91,10 @@ static void queue_test_sunnydays(void) */ ret = odp_queue_enq_multi(queue_id, enev, MAX_BUFFER_QUEUE); CU_ASSERT(MAX_BUFFER_QUEUE == ret); + i = ret < 0 ? 0 : ret; + for ( ; i < MAX_BUFFER_QUEUE; i++) + odp_event_free(enev[i]); + pev_tmp = deev; do { deq_ret = odp_queue_deq_multi(queue_id, pev_tmp,