From patchwork Sun Aug 9 13:24:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 52107 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by patches.linaro.org (Postfix) with ESMTPS id 0A9B42152A for ; Sun, 9 Aug 2015 13:34:59 +0000 (UTC) Received: by wijp15 with SMTP id p15sf30649214wij.3 for ; Sun, 09 Aug 2015 06:34:58 -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: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=q79oVZw+lAPM95AtXCm3JcpzBfpgQ4QKlNeZZw6IBNU=; b=VikLTIRk/O25V8wq04JBUdc4Kw0LaUYQC2TT8l0Q5HtgAjokScqLxZDPrhYt8ZBeba s1+QI3d9xGQ8N6R6APYPxYinONwg69nQgc4S7cYU9QDYZwHX8HKCcqiCyDeO4lvP2wdU qNPM2PToL7BzPWtMaRQmaYyWfN9o3gwgK0qpXtVyrmDC7D2cTuRkVf/ketEOtlHPsDh7 +l/ptjgGFtbwVz//Sjp7PK+bJz9FUcP/krnhZQ23L3UgCnhlgUMfmr6XqhgAHR8tedXs xElIF0Zp77JJuB/viw3q9rQPv3tvSdXwqo4ZCvB9VJf6/ud8qmhsYmh8mYHpFG7+rGMK JYHA== X-Gm-Message-State: ALoCoQnnbLiVo4F8/D+C0pcxNfHqEsy94lpqTW2oIjc+caEuNH3F81xd6Is8TT2X7kih98YxtBIv X-Received: by 10.194.179.42 with SMTP id dd10mr4902384wjc.7.1439127298362; Sun, 09 Aug 2015 06:34:58 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.204.40 with SMTP id kv8ls592709lac.94.gmail; Sun, 09 Aug 2015 06:34:58 -0700 (PDT) X-Received: by 10.112.198.100 with SMTP id jb4mr16135864lbc.97.1439127298123; Sun, 09 Aug 2015 06:34:58 -0700 (PDT) Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com. [209.85.217.176]) by mx.google.com with ESMTPS id lo16si5896383lbb.83.2015.08.09.06.34.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 09 Aug 2015 06:34:57 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) client-ip=209.85.217.176; Received: by lbbpu9 with SMTP id pu9so55120989lbb.3 for ; Sun, 09 Aug 2015 06:34:57 -0700 (PDT) X-Received: by 10.152.22.133 with SMTP id d5mr9977324laf.112.1439127297701; Sun, 09 Aug 2015 06:34:57 -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.7.198 with SMTP id l6csp1431596lba; Sun, 9 Aug 2015 06:34:56 -0700 (PDT) X-Received: by 10.140.40.168 with SMTP id x37mr30174521qgx.24.1439127296562; Sun, 09 Aug 2015 06:34:56 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id f100si5585928qge.26.2015.08.09.06.34.55; Sun, 09 Aug 2015 06:34:56 -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 CDA2461CBD; Sun, 9 Aug 2015 13:34:55 +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 618366217E; Sun, 9 Aug 2015 13:27:13 +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 410C261F6B; Sun, 9 Aug 2015 13:27:01 +0000 (UTC) Received: from mail-ob0-f181.google.com (mail-ob0-f181.google.com [209.85.214.181]) by lists.linaro.org (Postfix) with ESMTPS id 4276B61E69 for ; Sun, 9 Aug 2015 13:25:02 +0000 (UTC) Received: by obbhe7 with SMTP id he7so11280189obb.0 for ; Sun, 09 Aug 2015 06:25:01 -0700 (PDT) X-Received: by 10.60.155.176 with SMTP id vx16mr15302011oeb.63.1439126701712; Sun, 09 Aug 2015 06:25:01 -0700 (PDT) Received: from localhost.localdomain (cpe-24-28-70-239.austin.res.rr.com. [24.28.70.239]) by smtp.gmail.com with ESMTPSA id rg1sm10096074oeb.11.2015.08.09.06.25.00 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 09 Aug 2015 06:25:01 -0700 (PDT) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Sun, 9 Aug 2015 08:24:45 -0500 Message-Id: <1439126687-19932-12-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1439126687-19932-1-git-send-email-bill.fischofer@linaro.org> References: <1439126687-19932-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv13 11/13] linux-generic: schedule: implement odp_schedule_release_ordered() 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: bill.fischofer@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.176 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 Permit events to be removed from an ordered flow. Signed-off-by: Bill Fischofer --- platform/linux-generic/odp_queue.c | 72 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/platform/linux-generic/odp_queue.c b/platform/linux-generic/odp_queue.c index 4d3c548..518df0f 100644 --- a/platform/linux-generic/odp_queue.c +++ b/platform/linux-generic/odp_queue.c @@ -908,3 +908,75 @@ void odp_queue_param_init(odp_queue_param_t *params) { memset(params, 0, sizeof(odp_queue_param_t)); } + +/* These routines exists here rather than in odp_schedule + * because they operate on queue interenal structures + */ +int odp_schedule_release_ordered(odp_event_t ev) +{ + odp_buffer_t placeholder_buf; + odp_buffer_hdr_t *placeholder_buf_hdr, *reorder_buf; + odp_buffer_hdr_t *buf_hdr = + odp_buf_to_hdr(odp_buffer_from_event(ev)); + queue_entry_t *origin_qe = buf_hdr->origin_qe; + + /* Can't release if we didn't originate from an ordered queue */ + if (!origin_qe) + return -1; + + /* Buffer is no longer associated with an ordered queue */ + buf_hdr->origin_qe = NULL; + + /* Sustaining buffers can be released without further action */ + if (buf_hdr->flags.sustain) + return 0; + + /* Must lock the origin queue to process the release */ + LOCK(&origin_qe->s.lock); + + /* If we are the first or second element in the current order, + * we can release immediately since there can be no confusion about + * intermediate elements + */ + if (buf_hdr->order <= origin_qe->s.order_out + 1) { + order_release(origin_qe, 1); + + /* check if this release allows us to unblock waiters */ + reorder_buf = origin_qe->s.reorder_head; + if (reorder_buf && + reorder_buf->order <= origin_qe->s.order_out) + origin_qe->s.reorder_head = reorder_buf->next; + else + reorder_buf = NULL; + UNLOCK(&origin_qe->s.lock); + if (reorder_buf) + odp_queue_enq(reorder_buf->target_qe->s.handle, + (odp_event_t)reorder_buf->handle.handle); + return 0; + } + + /* If we are beyond the second element in the expected order, we need + * a placeholder to represent our "place in line". Just use an element + * from the same pool the buffer being released is from. + */ + placeholder_buf = odp_buffer_alloc(buf_hdr->pool_hdl); + + /* Can't release if no placeholder is available */ + if (odp_unlikely(placeholder_buf == ODP_BUFFER_INVALID)) { + UNLOCK(&origin_qe->s.lock); + buf_hdr->origin_qe = origin_qe; + return -1; + } + + placeholder_buf_hdr = odp_buf_to_hdr(placeholder_buf); + + /* Copy info to placeholder and add it to the reorder queue */ + placeholder_buf_hdr->origin_qe = origin_qe; + placeholder_buf_hdr->order = buf_hdr->order; + placeholder_buf_hdr->flags.sustain = 0; + + reorder_enq(NULL, origin_qe, placeholder_buf_hdr); + + UNLOCK(&origin_qe->s.lock); + return 0; +}