From patchwork Sun May 31 06:50:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taras Kondratiuk X-Patchwork-Id: 49268 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id EA6B421420 for ; Sun, 31 May 2015 06:51:10 +0000 (UTC) Received: by laboh3 with SMTP id oh3sf22223970lab.0 for ; Sat, 30 May 2015 23:51:09 -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:message-id:date:from :user-agent:mime-version:to:references:in-reply-to:cc:subject :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:content-type:content-transfer-encoding :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=XLKHqL5yzQsaLE26Q5sSsOz8KpMesjtiWxUY76wa4o8=; b=m35VP3totC8XfrGZGtLO48sMiDEWuJOvNTFdp+wfNo4ei+UObwk17N5HUnFlFYGjLy 1SQr57SJeZTrJtuzNUC2Ar8F5Nxcdn/NletnlqYmyY4KoLWjHXETf5AUjUmjSQKmZ6a0 N43eLRwaUv237HGyjGYFAFBeBS/wSoT1Hh7BgUG48nqH8zTBN9be53+Tb+I6WRB5x63o E+5eIRrsvF5aBHabseb3KyN9URY6r0iJBlhGXUnFXsB235N4yO5RaJchfITTRNyBap8I AH1mxxcETrkLlBTKVZ80l4O1usRUmxQiOCOUjpCXrElDz1NcgcyBt0xJ5D8CuDFh4Ar6 F5eg== X-Gm-Message-State: ALoCoQn2VlZzCcIwFFD20s4o3iiZynps/1y9UlExJ8IY0SVs1EDKtc70zhmYixzycz6kLUNzQBsP X-Received: by 10.180.73.137 with SMTP id l9mr5809522wiv.5.1433055069522; Sat, 30 May 2015 23:51:09 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.65 with SMTP id o1ls535996laj.108.gmail; Sat, 30 May 2015 23:51:09 -0700 (PDT) X-Received: by 10.112.211.134 with SMTP id nc6mr15530354lbc.52.1433055069350; Sat, 30 May 2015 23:51:09 -0700 (PDT) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com. [209.85.215.41]) by mx.google.com with ESMTPS id h8si9104883lbc.56.2015.05.30.23.51.08 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 30 May 2015 23:51:08 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) client-ip=209.85.215.41; Received: by lagv1 with SMTP id v1so81548574lag.3 for ; Sat, 30 May 2015 23:51:08 -0700 (PDT) X-Received: by 10.152.2.133 with SMTP id 5mr14149098lau.36.1433055068609; Sat, 30 May 2015 23:51:08 -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 hn6csp1450002lbb; Sat, 30 May 2015 23:51:07 -0700 (PDT) X-Received: by 10.55.22.74 with SMTP id g71mr29289496qkh.28.1433055067177; Sat, 30 May 2015 23:51:07 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 16si10171985qhd.100.2015.05.30.23.51.05; Sat, 30 May 2015 23:51:07 -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 B6A2661D77; Sun, 31 May 2015 06:51:05 +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_H2, 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 0B41461D09; Sun, 31 May 2015 06:51:00 +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 BC55661D24; Sun, 31 May 2015 06:50:52 +0000 (UTC) Received: from mail-pd0-f173.google.com (mail-pd0-f173.google.com [209.85.192.173]) by lists.linaro.org (Postfix) with ESMTPS id 802E461CF5 for ; Sun, 31 May 2015 06:50:51 +0000 (UTC) Received: by pdbki1 with SMTP id ki1so84539245pdb.1 for ; Sat, 30 May 2015 23:50:50 -0700 (PDT) X-Received: by 10.66.186.103 with SMTP id fj7mr29371016pac.132.1433055050758; Sat, 30 May 2015 23:50:50 -0700 (PDT) Received: from [172.17.85.123] ([12.216.212.50]) by mx.google.com with ESMTPSA id rd7sm10475140pdb.64.2015.05.30.23.50.48 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 30 May 2015 23:50:49 -0700 (PDT) Message-ID: <556AAF47.2030700@linaro.org> Date: Sat, 30 May 2015 23:50:47 -0700 From: Taras Kondratiuk User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Ola Liljedahl References: <1429884635-17042-1-git-send-email-ola.liljedahl@linaro.org> <55532521.10902@linaro.org> In-Reply-To: X-Topics: timers patch Cc: LNG ODP Mailman List Subject: Re: [lng-odp] [PATCH] linux-generic: timer: use plain buffers for timeouts 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: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: taras.kondratiuk@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.215.41 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 On 05/29/2015 07:26 AM, Ola Liljedahl wrote: > On 13 May 2015 at 17:31, Ola Liljedahl > wrote: > > On 13 May 2015 at 12:19, Maxim Uvarov > wrote: > > Patch looks good. Validation test passed. Need one more review. > > Thanks. I did this primarily for KS2 being able to use the > linux-generic timer implementation without any changes. I am waiting > for Taras to verify this. > > Well it seems now that Taras is not going to verify that this patch > solves his problems on KS2. I like the patch anyway and would like to > see it merged. Any reviewers? Sorry for a long delay. I had a slightly different approach in mind. ----8<----------------------------------------------------------------- From: Taras Kondratiuk Date: Sat, 30 May 2015 23:26:19 -0700 Subject: [PATCH] linux-generic: timer: convert odp_timeout_t to event Signed-off-by: Taras Kondratiuk --- .../linux-generic/include/odp/plat/timer_types.h | 8 ++++-- .../linux-generic/include/odp_timer_internal.h | 8 ------ platform/linux-generic/odp_timer.c | 31 ++++++++++++---------- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/platform/linux-generic/include/odp/plat/timer_types.h b/platform/linux-generic/include/odp/plat/timer_types.h index 006683e..d987096 100644 --- a/platform/linux-generic/include/odp/plat/timer_types.h +++ b/platform/linux-generic/include/odp/plat/timer_types.h @@ -18,6 +18,10 @@ extern "C" { #endif +#include +#include +#include + /** @addtogroup odp_timer * @{ **/ @@ -32,9 +36,9 @@ typedef uint32_t odp_timer_t; #define ODP_TIMER_INVALID ((uint32_t)~0U) -typedef void *odp_timeout_t; +typedef odp_handle_t odp_timeout_t; -#define ODP_TIMEOUT_INVALID NULL +#define ODP_TIMEOUT_INVALID (odp_timeout_t)ODP_EVENT_INVALID /** * @} diff --git a/platform/linux-generic/include/odp_timer_internal.h b/platform/linux-generic/include/odp_timer_internal.h index 90af62c..db379ec 100644 --- a/platform/linux-generic/include/odp_timer_internal.h +++ b/platform/linux-generic/include/odp_timer_internal.h @@ -40,12 +40,4 @@ typedef struct odp_timeout_hdr_stride { } odp_timeout_hdr_stride; -/** - * Return the timeout header - */ -static inline odp_timeout_hdr_t *odp_timeout_hdr(odp_buffer_t buf) -{ - return (odp_timeout_hdr_t *)odp_buf_to_hdr(buf); -} - #endif diff --git a/platform/linux-generic/odp_timer.c b/platform/linux-generic/odp_timer.c index b7cb04f..39e76e1 100644 --- a/platform/linux-generic/odp_timer.c +++ b/platform/linux-generic/odp_timer.c @@ -80,7 +80,13 @@ static _odp_atomic_flag_t locks[NUM_LOCKS]; /* Multiple locks per cache line! */ static odp_timeout_hdr_t *timeout_hdr_from_buf(odp_buffer_t buf) { - return (odp_timeout_hdr_t *)odp_buf_to_hdr(buf); + return (odp_timeout_hdr_t *)(void *)odp_buf_to_hdr(buf); +} + +static odp_timeout_hdr_t *timeout_hdr(odp_timeout_t tmo) +{ + odp_buffer_t buf = odp_buffer_from_event(odp_timeout_to_event(tmo)); + return timeout_hdr_from_buf(buf); } /****************************************************************************** @@ -422,7 +428,8 @@ static bool timer_reset(uint32_t idx, } else { /* We have a new timeout buffer which replaces any old one */ /* Fill in some (constant) header fields for timeout events */ - if (_odp_buffer_type(*tmo_buf) == ODP_EVENT_TIMEOUT) { + if (odp_event_type(odp_buffer_to_event(*tmo_buf)) == + ODP_EVENT_TIMEOUT) { /* Convert from buffer to timeout hdr */ odp_timeout_hdr_t *tmo_hdr = timeout_hdr_from_buf(*tmo_buf); @@ -567,7 +574,8 @@ static unsigned timer_expire(odp_timer_pool *tp, uint32_t idx, uint64_t tick) #endif if (odp_likely(tmo_buf != ODP_BUFFER_INVALID)) { /* Fill in expiration tick for timeout events */ - if (_odp_buffer_type(tmo_buf) == ODP_EVENT_TIMEOUT) { + if (odp_event_type(odp_buffer_to_event(tmo_buf)) == + ODP_EVENT_TIMEOUT) { /* Convert from buffer to timeout hdr */ odp_timeout_hdr_t *tmo_hdr = timeout_hdr_from_buf(tmo_buf); @@ -811,19 +819,17 @@ odp_timeout_t odp_timeout_from_event(odp_event_t ev) /* This check not mandated by the API specification */ if (odp_event_type(ev) != ODP_EVENT_TIMEOUT) ODP_ABORT("Event not a timeout"); - return (odp_timeout_t)timeout_hdr_from_buf(odp_buffer_from_event(ev)); + return (odp_timeout_t)ev; } odp_event_t odp_timeout_to_event(odp_timeout_t tmo) { - odp_timeout_hdr_t *tmo_hdr = (odp_timeout_hdr_t *)tmo; - odp_buffer_t buf = odp_hdr_to_buf(&tmo_hdr->buf_hdr); - return odp_buffer_to_event(buf); + return (odp_event_t)tmo; } int odp_timeout_fresh(odp_timeout_t tmo) { - const odp_timeout_hdr_t *hdr = (odp_timeout_hdr_t *)tmo; + const odp_timeout_hdr_t *hdr = timeout_hdr(tmo); odp_timer_t hdl = hdr->timer; odp_timer_pool *tp = handle_to_tp(hdl); uint32_t idx = handle_to_idx(hdl, tp); @@ -836,20 +842,17 @@ int odp_timeout_fresh(odp_timeout_t tmo) odp_timer_t odp_timeout_timer(odp_timeout_t tmo) { - const odp_timeout_hdr_t *hdr = (odp_timeout_hdr_t *)tmo; - return hdr->timer; + return timeout_hdr(tmo)->timer; } uint64_t odp_timeout_tick(odp_timeout_t tmo) { - const odp_timeout_hdr_t *hdr = (odp_timeout_hdr_t *)tmo; - return hdr->expiration; + return timeout_hdr(tmo)->expiration; } void *odp_timeout_user_ptr(odp_timeout_t tmo) { - const odp_timeout_hdr_t *hdr = (odp_timeout_hdr_t *)tmo; - return hdr->user_ptr; + return timeout_hdr(tmo)->user_ptr; } odp_timeout_t odp_timeout_alloc(odp_pool_t pool)