From patchwork Tue Mar 10 14:43:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ola Liljedahl X-Patchwork-Id: 45581 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f198.google.com (mail-we0-f198.google.com [74.125.82.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5E3DA2151D for ; Tue, 10 Mar 2015 14:44:15 +0000 (UTC) Received: by wevk48 with SMTP id k48sf1759850wev.0 for ; Tue, 10 Mar 2015 07:44:14 -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: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=k0G4pwI3fN2fF5n7BlVGl41NNXYEqpx6YyBEVZOOoN4=; b=O7GksfQThy/9EpSWTeQUeO0/68dbXj3mVTMeRq6Ctx0LKbSeQjQhf69EA6PnJHDBAD irRptCy8uUVsvR3fIi73AQim8bt/v+mz3jaT2PY1SxHfNGbqVkOper47h0cM/9gYY2gr RCzZRnMoCZeSG92CZRwV8IM8hjeg8KYcdzkrBfy0P3wJW4t2xWH7xg/h8iTqwdFxTUg4 ptpf7yYZOeKetcSTNPWj8Jyk/F87Ty75xQuJA5n2tDx6atcDCIZCO59Nfm2Cpad7EBuZ sol2lP25a4ZZb8pksYVmWCLCP3BMjjjSIFARvh3a3ZjKDItDAWBHTVtNnBaei3OHy85B kVHA== X-Gm-Message-State: ALoCoQkeVrD91VOh5HN4fl3qODSeDjLbTkhom0p4NHV8cMJx9SYGNBK9IHeWjRL69im3iX9QcmH7 X-Received: by 10.152.8.73 with SMTP id p9mr388301laa.6.1425998654730; Tue, 10 Mar 2015 07:44:14 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.181.137 with SMTP id dw9ls31326lac.85.gmail; Tue, 10 Mar 2015 07:44:14 -0700 (PDT) X-Received: by 10.152.7.212 with SMTP id l20mr19210902laa.68.1425998654429; Tue, 10 Mar 2015 07:44:14 -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 v7si408452lbw.153.2015.03.10.07.44.14 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Mar 2015 07:44:14 -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 lbiz12 with SMTP id z12so2164797lbi.12 for ; Tue, 10 Mar 2015 07:44:14 -0700 (PDT) X-Received: by 10.152.121.33 with SMTP id lh1mr30814833lab.86.1425998654328; Tue, 10 Mar 2015 07:44:14 -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.35.133 with SMTP id h5csp2175713lbj; Tue, 10 Mar 2015 07:44:13 -0700 (PDT) X-Received: by 10.55.50.79 with SMTP id y76mr41681337qky.20.1425998652793; Tue, 10 Mar 2015 07:44:12 -0700 (PDT) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id m87si617799qkh.91.2015.03.10.07.44.10 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 10 Mar 2015 07:44:12 -0700 (PDT) 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 1YVLOC-0001Yx-5i; Tue, 10 Mar 2015 14:44:08 +0000 Received: from mail-lb0-f169.google.com ([209.85.217.169]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YVLO6-0001Ys-DR for lng-odp@lists.linaro.org; Tue, 10 Mar 2015 14:44:02 +0000 Received: by lbiz12 with SMTP id z12so2162666lbi.12 for ; Tue, 10 Mar 2015 07:43:56 -0700 (PDT) X-Received: by 10.152.197.34 with SMTP id ir2mr30681630lac.36.1425998636211; Tue, 10 Mar 2015 07:43:56 -0700 (PDT) Received: from macmini.lan (78-82-119-153.tn.glocalnet.net. [78.82.119.153]) by mx.google.com with ESMTPSA id kv10sm157442lac.23.2015.03.10.07.43.54 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Mar 2015 07:43:55 -0700 (PDT) From: Ola Liljedahl To: lng-odp@lists.linaro.org Date: Tue, 10 Mar 2015 15:43:49 +0100 Message-Id: <1425998629-21691-1-git-send-email-ola.liljedahl@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: timers patch Subject: [lng-odp] [PATCH] linux-generic: odp_timer: set user_ptr for cancelled timeout 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: ola.liljedahl@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 Ensure that the timeout user_ptr and timer fields are set when the corresponding timer is immediately cancelled. https://bugs.linaro.org/show_bug.cgi?id=1313 Signed-off-by: Ola Liljedahl --- (This document/code contribution attached is provided under the terms of agreement LES-LTM-21309) Passes odp_timer validation with the new odp_timer_cancel() test from Petri. platform/linux-generic/odp_timer.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/platform/linux-generic/odp_timer.c b/platform/linux-generic/odp_timer.c index 61a02b6..6b48d2e 100644 --- a/platform/linux-generic/odp_timer.c +++ b/platform/linux-generic/odp_timer.c @@ -421,6 +421,16 @@ static bool timer_reset(uint32_t idx, #endif } else { /* We have a new timeout buffer which replaces any old one */ + /* Fill in header fields if timeout event */ + if (_odp_buffer_type(*tmo_buf) == ODP_EVENT_TIMEOUT) { + /* Convert from buffer to timeout hdr */ + odp_timeout_hdr_t *tmo_hdr = + timeout_hdr_from_buf(*tmo_buf); + tmo_hdr->timer = tp_idx_to_handle(tp, idx); + tmo_hdr->user_ptr = tp->timers[idx].user_ptr; + /* expiration field filled in when timer expires */ + } + /* Else ignore buffers of other types */ odp_buffer_t old_buf = ODP_BUFFER_INVALID; #ifdef ODP_ATOMIC_U128 tick_buf_t new, old; @@ -556,16 +566,16 @@ static unsigned timer_expire(odp_timer_pool *tp, uint32_t idx, uint64_t tick) _odp_atomic_flag_clear(IDX2LOCK(idx)); #endif if (odp_likely(tmo_buf != ODP_BUFFER_INVALID)) { - /* Fill in metadata fields in system timeout buffer */ + /* Fill in expiration tick if timeout event */ if (_odp_buffer_type(tmo_buf) == ODP_EVENT_TIMEOUT) { /* Convert from buffer to timeout hdr */ odp_timeout_hdr_t *tmo_hdr = timeout_hdr_from_buf(tmo_buf); - tmo_hdr->timer = tp_idx_to_handle(tp, idx); tmo_hdr->expiration = exp_tck; - tmo_hdr->user_ptr = tim->user_ptr; + /* timer and user_ptr fields filled in when timer + * was set */ } - /* Else ignore buffers of other types */ + /* Else ignore events of other types */ /* Post the timeout to the destination queue */ int rc = odp_queue_enq(tim->queue, odp_buffer_to_event(tmo_buf));