From patchwork Tue Feb 24 16:32:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stuart Haslam X-Patchwork-Id: 44953 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A16AF20502 for ; Tue, 24 Feb 2015 16:33:02 +0000 (UTC) Received: by mail-wi0-f199.google.com with SMTP id bs8sf15888370wib.2 for ; Tue, 24 Feb 2015 08:33:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id: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=vi4WmDJ5BKMvZIPzFCeQs8n8LUupDAt5Fi93kFnpg6M=; b=VekGgY6L77pJ/ustqwxLpN+MEtadlEodHxLtFai70hotL/e9Q/b70QOHRcX0r9mi9E KT5kwnr3VIEOMh/wXUxXMppSO9XPlgDOyGyIuBkIir0WK9wdPM0PpV1UQcvlxef1sGA2 eQ/jSWVpaUj1JjBNvuwnMcdPYwMHw/jUUl6+lt3ZDkl0wERwqoMokk+tDxFQR3ftQiEP mC+czpPeDCfJJZL7vuBpgvQcPru13RpeWM4QMPT48q8LU/nC6dG5NI3RsmUvJ2DejOBC TN/ygbeqSpcT1X1pN4uRJpZHEBFTdnu/VBk/iAqRR7DXIG15n6ZeEu752Ft+NvDAnopc Fvbw== X-Gm-Message-State: ALoCoQkj7EDxVT8NuNaOEq8w7UTMS0jN+MnwEvYqC4qE3JM1LOms8JnxUSvl/YqDCtqwbL90CHGs X-Received: by 10.152.29.97 with SMTP id j1mr758359lah.3.1424795581903; Tue, 24 Feb 2015 08:33:01 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.9.168 with SMTP id a8ls635670lab.14.gmail; Tue, 24 Feb 2015 08:33:01 -0800 (PST) X-Received: by 10.112.78.37 with SMTP id y5mr14732876lbw.91.1424795581621; Tue, 24 Feb 2015 08:33:01 -0800 (PST) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com. [209.85.217.179]) by mx.google.com with ESMTPS id z7si8135221lba.103.2015.02.24.08.33.01 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Feb 2015 08:33:01 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by lbvn10 with SMTP id n10so26115029lbv.6 for ; Tue, 24 Feb 2015 08:33:01 -0800 (PST) X-Received: by 10.152.28.5 with SMTP id x5mr14827378lag.112.1424795581440; Tue, 24 Feb 2015 08:33:01 -0800 (PST) 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.35.133 with SMTP id h5csp2022019lbj; Tue, 24 Feb 2015 08:33:00 -0800 (PST) X-Received: by 10.140.40.203 with SMTP id x69mr12150918qgx.15.1424795579875; Tue, 24 Feb 2015 08:32:59 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id 13si29933897qhv.28.2015.02.24.08.32.57 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 24 Feb 2015 08:32:59 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YQIPn-0002TN-An; Tue, 24 Feb 2015 16:32:55 +0000 Received: from mail-wg0-f49.google.com ([74.125.82.49]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YQIPi-0002TE-S7 for lng-odp@lists.linaro.org; Tue, 24 Feb 2015 16:32:50 +0000 Received: by wggy19 with SMTP id y19so6425021wgg.10 for ; Tue, 24 Feb 2015 08:32:45 -0800 (PST) X-Received: by 10.194.6.228 with SMTP id e4mr33657069wja.63.1424795565392; Tue, 24 Feb 2015 08:32:45 -0800 (PST) Received: from e106441.cambridge.arm.com ([2001:41d0:a:3cb4::1]) by mx.google.com with ESMTPSA id g10sm21223210wic.7.2015.02.24.08.32.43 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 24 Feb 2015 08:32:44 -0800 (PST) From: Stuart Haslam To: lng-odp@lists.linaro.org Date: Tue, 24 Feb 2015 16:32:12 +0000 Message-Id: <1424795532-4096-1-git-send-email-stuart.haslam@linaro.org> X-Mailer: git-send-email 2.1.1 X-Topics: patch Subject: [lng-odp] [PATCH] linux-generic: queue: fix PKTIN queue destroy X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 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-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: stuart.haslam@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.179 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 PKTIN queue was not handled correctly. Check queue status instead of queue type in odp_queue_destroy(). In schedule() check for FREE status rather than DESTROYED as the preceeding dequeue will have caused a DESTROYED->FREE transition. Signed-off-by: Taras Kondratiuk Signed-off-by: Stuart Haslam --- This is a slightly modified version of a patch Taras sent a while back, but slipped through the cracks and was never merged; http://lists.linaro.org/pipermail/lng-odp/2014-December/006702.html The changes I've made are to resolve an issue I found while testing that patch; http://lists.linaro.org/pipermail/lng-odp/2015-January/007507.html .../linux-generic/include/odp_queue_internal.h | 4 +-- platform/linux-generic/odp_queue.c | 39 ++++++++++++---------- platform/linux-generic/odp_schedule.c | 2 +- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/platform/linux-generic/include/odp_queue_internal.h b/platform/linux-generic/include/odp_queue_internal.h index bfa36df..65aae14 100644 --- a/platform/linux-generic/include/odp_queue_internal.h +++ b/platform/linux-generic/include/odp_queue_internal.h @@ -121,13 +121,13 @@ static inline queue_entry_t *queue_to_qentry(odp_queue_t handle) return get_qentry(queue_id); } -static inline int queue_is_destroyed(odp_queue_t handle) +static inline int queue_is_free(odp_queue_t handle) { queue_entry_t *queue; queue = queue_to_qentry(handle); - return queue->s.status == QUEUE_STATUS_DESTROYED; + return queue->s.status == QUEUE_STATUS_FREE; } static inline int queue_is_sched(odp_queue_t handle) diff --git a/platform/linux-generic/odp_queue.c b/platform/linux-generic/odp_queue.c index b945e03..477b5e3 100644 --- a/platform/linux-generic/odp_queue.c +++ b/platform/linux-generic/odp_queue.c @@ -259,27 +259,30 @@ int odp_queue_destroy(odp_queue_t handle) queue->s.enqueue = queue_enq_dummy; queue->s.enqueue_multi = queue_enq_multi_dummy; - if (queue->s.type == ODP_QUEUE_TYPE_POLL || - queue->s.type == ODP_QUEUE_TYPE_PKTOUT) { + switch (queue->s.status) { + case QUEUE_STATUS_READY: queue->s.status = QUEUE_STATUS_FREE; queue->s.head = NULL; queue->s.tail = NULL; - } else if (queue->s.type == ODP_QUEUE_TYPE_SCHED) { - if (queue->s.status == QUEUE_STATUS_SCHED) { - /* - * Override dequeue_multi to destroy queue when it will - * be scheduled next time. - */ - queue->s.status = QUEUE_STATUS_DESTROYED; - queue->s.dequeue_multi = queue_deq_multi_destroy; - } else { - /* Queue won't be scheduled anymore */ - odp_buffer_free(queue->s.sched_buf); - queue->s.sched_buf = ODP_BUFFER_INVALID; - queue->s.status = QUEUE_STATUS_FREE; - queue->s.head = NULL; - queue->s.tail = NULL; - } + break; + case QUEUE_STATUS_SCHED: + /* + * Override dequeue_multi to destroy queue when it will + * be scheduled next time. + */ + queue->s.status = QUEUE_STATUS_DESTROYED; + queue->s.dequeue_multi = queue_deq_multi_destroy; + break; + case QUEUE_STATUS_NOTSCHED: + /* Queue won't be scheduled anymore */ + odp_buffer_free(queue->s.sched_buf); + queue->s.sched_buf = ODP_BUFFER_INVALID; + queue->s.status = QUEUE_STATUS_FREE; + queue->s.head = NULL; + queue->s.tail = NULL; + break; + default: + ODP_ABORT("Unexpected queue status\n"); } UNLOCK(&queue->s.lock); diff --git a/platform/linux-generic/odp_schedule.c b/platform/linux-generic/odp_schedule.c index 1a96cd9..dd65168 100644 --- a/platform/linux-generic/odp_schedule.c +++ b/platform/linux-generic/odp_schedule.c @@ -336,7 +336,7 @@ static int schedule(odp_queue_t *out_queue, odp_event_t out_ev[], */ if (odp_queue_type(queue) == ODP_QUEUE_TYPE_PKTIN && - !queue_is_destroyed(queue)) + !queue_is_free(queue)) odp_queue_enq(pri_q, ev); continue;