From patchwork Wed Mar 11 15:36:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ola Liljedahl X-Patchwork-Id: 45683 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6E7A3214BF for ; Wed, 11 Mar 2015 15:42:27 +0000 (UTC) Received: by lbdu14 with SMTP id u14sf7401623lbd.3 for ; Wed, 11 Mar 2015 08:42:26 -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=49OW5Bg4SZY24jn5us/zR9Ps6fFmlZwx/jhuh4zFMiY=; b=Wbfjz1Hw9W/jJ5xAVg9ZQJeqI+whhJZXbW1Wgx4WsoCLuOwQ6+T5eP5lhD+ju1viQt 9RnCEffoNgpKbT3KW0n/RssMF+S6uY25v+PqfYmT9eRRdvqFmjLonjGbcaW4P2TKnvYp 6btehOWTV0qqqf//RP310kwCAFhKXMPv1FrJiYPSWpWqySMFvv8jVNXFRZbBklpUKhKO dbFp2wrP0OD4z8fUi39LB2xpi7NkFHYQYYWBBroIKrWm1QLWR6g74StXH1AdxMbSja2X Tqp6trm44ZR5cqbW+Z0VH+0DaNT7QoxtZT0pnezbavORUk0jvxRl/ZlSud5bKRUHdmzH THrQ== X-Gm-Message-State: ALoCoQnuptU+CqLzMu5AxTwh0h4hENTyLXp4cZUsTJXa0c+OAuG6xTcDXLFyxEgYyYj1RdB1HNy3 X-Received: by 10.180.11.34 with SMTP id n2mr6066903wib.2.1426088546172; Wed, 11 Mar 2015 08:42:26 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.121.5 with SMTP id lg5ls145083lab.106.gmail; Wed, 11 Mar 2015 08:42:25 -0700 (PDT) X-Received: by 10.152.43.229 with SMTP id z5mr28191402lal.48.1426088545939; Wed, 11 Mar 2015 08:42:25 -0700 (PDT) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id m5si2497622laj.177.2015.03.11.08.42.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Mar 2015 08:42:25 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by labmn12 with SMTP id mn12so9758247lab.0 for ; Wed, 11 Mar 2015 08:42:25 -0700 (PDT) X-Received: by 10.152.116.11 with SMTP id js11mr13208491lab.106.1426088545662; Wed, 11 Mar 2015 08:42:25 -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 h5csp2859092lbj; Wed, 11 Mar 2015 08:42:24 -0700 (PDT) X-Received: by 10.55.42.17 with SMTP id q17mr62605311qkh.61.1426088226874; Wed, 11 Mar 2015 08:37:06 -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 145si3706910qht.77.2015.03.11.08.37.05 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 11 Mar 2015 08:37:06 -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 1YVigx-0007Z5-26; Wed, 11 Mar 2015 15:37:03 +0000 Received: from mail-la0-f53.google.com ([209.85.215.53]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YVigr-0007Yy-0N for lng-odp@lists.linaro.org; Wed, 11 Mar 2015 15:36:57 +0000 Received: by lams18 with SMTP id s18so9698342lam.2 for ; Wed, 11 Mar 2015 08:36:51 -0700 (PDT) X-Received: by 10.152.116.65 with SMTP id ju1mr14901652lab.32.1426088211275; Wed, 11 Mar 2015 08:36:51 -0700 (PDT) Received: from macmini.lan (78-82-119-153.tn.glocalnet.net. [78.82.119.153]) by mx.google.com with ESMTPSA id ko6sm784059lbb.36.2015.03.11.08.36.49 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Mar 2015 08:36:49 -0700 (PDT) From: Ola Liljedahl To: lng-odp@lists.linaro.org Date: Wed, 11 Mar 2015 16:36:45 +0100 Message-Id: <1426088205-17923-1-git-send-email-ola.liljedahl@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: timers patch Subject: [lng-odp] [PATCHv2] 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.215.51 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 Reviewed-by: Bill Fischofer --- (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. v2: Updated some comments in odp_timer.c to make the meaning clearer. 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..b7cb04f 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 some (constant) header fields for timeout events */ + 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 for timeout events */ 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));