From patchwork Tue Jun 30 10:16:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 50446 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 50402229DF for ; Tue, 30 Jun 2015 10:17:52 +0000 (UTC) Received: by wiar9 with SMTP id r9sf4864722wia.1 for ; Tue, 30 Jun 2015 03:17:51 -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=qUNPtxr0yVZwubTjoycl9bQcTVSKU23SWa2UvzrCn74=; b=ZGm+TlRnLTFVVplMMmVNkjGqk6XPimAWuQbcnFiBM3Xj5NtP1NBRzRQ65I3xV9Wg7Z FHyKJZM2Hsr3jlNsGhWuf0vv/z+qrJRNhDsNKNi/+THWX1vQ6ERy4jdwRNrUPF8l67Ij DXpINRh3B7C3PLpazNm6/MZWWvTlM/hm2KmFan5S8BlKptRLor5HJgFBjHScEq3tdtkW klU7o17Q4CcUmC//bY6XsuygkME/6UEcc/iTgzSgkUZ6H+p8rz8mQrTXQu+NBLiH9UtA yMfef2nkf7ShMRVXWLt4ovE+BukHzAm/3CKcUjNt84yrsvVV9EXjafL1xF0AU2V4R709 sRZg== X-Gm-Message-State: ALoCoQkifP/m84C15EseyQCXMqf+sxUDiYDy/xUU8umXWHvCA9l2kIer8Ro5RAt7LmrGlsF5c9D8 X-Received: by 10.112.181.37 with SMTP id dt5mr194489lbc.10.1435659471479; Tue, 30 Jun 2015 03:17:51 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.207.38 with SMTP id lt6ls23047lac.50.gmail; Tue, 30 Jun 2015 03:17:51 -0700 (PDT) X-Received: by 10.112.202.234 with SMTP id kl10mr18783372lbc.51.1435659471324; Tue, 30 Jun 2015 03:17:51 -0700 (PDT) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id h3si37696919lbj.145.2015.06.30.03.17.51 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Jun 2015 03:17:51 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by laar3 with SMTP id r3so7240178laa.0 for ; Tue, 30 Jun 2015 03:17:51 -0700 (PDT) X-Received: by 10.112.220.7 with SMTP id ps7mr18697092lbc.72.1435659471170; Tue, 30 Jun 2015 03:17:51 -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 hn6csp2332814lbb; Tue, 30 Jun 2015 03:17:50 -0700 (PDT) X-Received: by 10.140.84.242 with SMTP id l105mr24542856qgd.93.1435659469729; Tue, 30 Jun 2015 03:17:49 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 21si44520388qhh.85.2015.06.30.03.17.48; Tue, 30 Jun 2015 03:17:49 -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 6A2DD61E11; Tue, 30 Jun 2015 10:17:48 +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 3463961D76; Tue, 30 Jun 2015 10:17:41 +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 79C8561E06; Tue, 30 Jun 2015 10:17:39 +0000 (UTC) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com [209.85.215.41]) by lists.linaro.org (Postfix) with ESMTPS id 848A361B50 for ; Tue, 30 Jun 2015 10:17:38 +0000 (UTC) Received: by lagc2 with SMTP id c2so7129028lag.3 for ; Tue, 30 Jun 2015 03:17:37 -0700 (PDT) X-Received: by 10.112.210.9 with SMTP id mq9mr18837890lbc.4.1435659457384; Tue, 30 Jun 2015 03:17:37 -0700 (PDT) Received: from khorivan.synapse.com ([213.179.252.35]) by mx.google.com with ESMTPSA id f5sm11540466lbd.41.2015.06.30.03.17.35 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 30 Jun 2015 03:17:36 -0700 (PDT) From: Ivan Khoronzhuk To: lng-odp@lists.linaro.org, ola.liljedahl@linaro.org, taras.kondratiuk@linaro.org Date: Tue, 30 Jun 2015 13:16:55 +0300 Message-Id: <1435659415-16841-1-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <5587F31A.6060806@linaro.org> References: <5587F31A.6060806@linaro.org> X-Topics: timers patch Subject: [lng-odp] [PATCH] linux-generic: timer: use timer handles as buffer handles 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: ivan.khoronzhuk@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.48 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 It's more generic implementation simplify reusing timer API for other platforms. Signed-off-by: Ivan Khoronzhuk Reviewed-by: Ola Liljedahl --- I've checked this patch with Keystone implementation. .../linux-generic/include/odp_timer_internal.h | 9 ------- platform/linux-generic/odp_timer.c | 31 ++++++++++++---------- 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/platform/linux-generic/include/odp_timer_internal.h b/platform/linux-generic/include/odp_timer_internal.h index 90af62c..8b0e93d 100644 --- a/platform/linux-generic/include/odp_timer_internal.h +++ b/platform/linux-generic/include/odp_timer_internal.h @@ -39,13 +39,4 @@ typedef struct odp_timeout_hdr_stride { uint8_t pad[ODP_CACHE_LINE_SIZE_ROUNDUP(sizeof(odp_timeout_hdr_t))]; } 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 bd1b778..68d7b11 100644 --- a/platform/linux-generic/odp_timer.c +++ b/platform/linux-generic/odp_timer.c @@ -78,7 +78,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); } /****************************************************************************** @@ -421,7 +427,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); @@ -566,7 +573,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); @@ -815,19 +823,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); @@ -840,20 +846,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)