From patchwork Mon Oct 16 22:54:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10010035 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D4FDA601D5 for ; Mon, 16 Oct 2017 22:54:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C2793204FD for ; Mon, 16 Oct 2017 22:54:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B2DB4286A8; Mon, 16 Oct 2017 22:54:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C42262868D for ; Mon, 16 Oct 2017 22:54:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757256AbdJPWyP (ORCPT ); Mon, 16 Oct 2017 18:54:15 -0400 Received: from mail-pg0-f51.google.com ([74.125.83.51]:46599 "EHLO mail-pg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757253AbdJPWyO (ORCPT ); Mon, 16 Oct 2017 18:54:14 -0400 Received: by mail-pg0-f51.google.com with SMTP id k7so7988149pga.3 for ; Mon, 16 Oct 2017 15:54:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=i9qaHyHr3l5OAGs1Km0RPUKNIaDabkX1c+YTNQhhXFA=; b=MDAAIJu1PQ5pxg2yz56cRi/P9jhCih8bMkQVIaoqH1RvNQrG1WZriUJRmLeuyuq1Ed W399C5EcGr9/arLOHIS1P15qrNVU0M9er2f00EY9BfAC+CoNnK1InPmnTzFhesg0id0R Y/A+OjMvUiYD50QNvleGY59kcCy6ntVIgnlSM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=i9qaHyHr3l5OAGs1Km0RPUKNIaDabkX1c+YTNQhhXFA=; b=cRc3dkjlz7GxPegk/WU2TqNKewxE3qX342oy6BYRcfSDlRaMKyCaUwGJf7jjeLFoR9 Sql0XlBahAbjQ6++6+lgg4BTKKMSRsBt0wknIoX17fYkUZMB/qy3ylOopqdyblvVJgwk FMXD2uhfA7SnMR6CiU/W1lS5v1ZNobaka7sBDkHMZ5W6veKYibrOowowh3foRz4p16y1 BUNlgFMzwlcg/lhiz+9LYyg2yBWBZ6KxLW4tv7Em1JYZjViv2uMTaGcGNhD9mUihTQDv vrvK7favd6o4UPUuUb6gb/wOcCkg90RZua5xZSPJ+DFN3lLvz/OXIQ7ZwWwRiik0qjw0 Hhmw== X-Gm-Message-State: AMCzsaVlpsOAHuWuX040E8w6CPMO0dY8UNFzpNHOFH3JaWQA/czgX2AG 5kfzRJlUg2/ynIuSQzviQqi/kw== X-Google-Smtp-Source: ABhQp+R1Qzyxpqmb3zfFgwQZ5cEq1h4R2PS1yRZWJsmSxqvMmaY1MmV7064gkpg9P5sTcqiHRXESpw== X-Received: by 10.84.236.74 with SMTP id h10mr2871601pln.2.1508194453780; Mon, 16 Oct 2017 15:54:13 -0700 (PDT) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id b1sm13438926pgc.67.2017.10.16.15.54.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Oct 2017 15:54:12 -0700 (PDT) Date: Mon, 16 Oct 2017 15:54:11 -0700 From: Kees Cook To: Doug Ledford Cc: Steve Wise , Sean Hefty , Hal Rosenstock , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] RDMA/cxgb3: Convert timers to use timer_setup() Message-ID: <20171016225411.GA98979@beast> MIME-Version: 1.0 Content-Disposition: inline Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In preparation for unconditionally passing the struct timer_list pointer to all timer callbacks, switch to using the new timer_setup() and from_timer() to pass the timer pointer explicitly. Also removes an unused timer. Cc: Steve Wise Cc: Doug Ledford Cc: Sean Hefty Cc: Hal Rosenstock Cc: linux-rdma@vger.kernel.org Signed-off-by: Kees Cook Acked-by: Steve Wise --- drivers/infiniband/hw/cxgb3/iwch_cm.c | 12 +++++------- drivers/infiniband/hw/cxgb3/iwch_provider.c | 1 - drivers/infiniband/hw/cxgb3/iwch_provider.h | 1 - 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/infiniband/hw/cxgb3/iwch_cm.c b/drivers/infiniband/hw/cxgb3/iwch_cm.c index 86975370a4c0..638ac9a06053 100644 --- a/drivers/infiniband/hw/cxgb3/iwch_cm.c +++ b/drivers/infiniband/hw/cxgb3/iwch_cm.c @@ -107,7 +107,7 @@ static struct workqueue_struct *workq; static struct sk_buff_head rxq; static struct sk_buff *get_skb(struct sk_buff *skb, int len, gfp_t gfp); -static void ep_timeout(unsigned long arg); +static void ep_timeout(struct timer_list *t); static void connect_reply_upcall(struct iwch_ep *ep, int status); static void start_ep_timer(struct iwch_ep *ep) @@ -119,8 +119,6 @@ static void start_ep_timer(struct iwch_ep *ep) } else get_ep(&ep->com); ep->timer.expires = jiffies + ep_timeout_secs * HZ; - ep->timer.data = (unsigned long)ep; - ep->timer.function = ep_timeout; add_timer(&ep->timer); } @@ -1399,7 +1397,7 @@ static int pass_accept_req(struct t3cdev *tdev, struct sk_buff *skb, void *ctx) child_ep->l2t = l2t; child_ep->dst = dst; child_ep->hwtid = hwtid; - init_timer(&child_ep->timer); + timer_setup(&child_ep->timer, ep_timeout, 0); cxgb3_insert_tid(tdev, &t3c_client, child_ep, hwtid); accept_cr(child_ep, req->peer_ip, skb); goto out; @@ -1719,9 +1717,9 @@ static int ec_status(struct t3cdev *tdev, struct sk_buff *skb, void *ctx) return CPL_RET_BUF_DONE; } -static void ep_timeout(unsigned long arg) +static void ep_timeout(struct timer_list *t) { - struct iwch_ep *ep = (struct iwch_ep *)arg; + struct iwch_ep *ep = from_timer(ep, t, timer); struct iwch_qp_attributes attrs; unsigned long flags; int abort = 1; @@ -1899,7 +1897,7 @@ int iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) err = -ENOMEM; goto out; } - init_timer(&ep->timer); + timer_setup(&ep->timer, ep_timeout, 0); ep->plen = conn_param->private_data_len; if (ep->plen) memcpy(ep->mpa_pkt + sizeof(struct mpa_message), diff --git a/drivers/infiniband/hw/cxgb3/iwch_provider.c b/drivers/infiniband/hw/cxgb3/iwch_provider.c index 099e76f3758a..a578ca559e11 100644 --- a/drivers/infiniband/hw/cxgb3/iwch_provider.c +++ b/drivers/infiniband/hw/cxgb3/iwch_provider.c @@ -969,7 +969,6 @@ static struct ib_qp *iwch_create_qp(struct ib_pd *pd, insert_mmap(ucontext, mm2); } qhp->ibqp.qp_num = qhp->wq.qpid; - init_timer(&(qhp->timer)); pr_debug("%s sq_num_entries %d, rq_num_entries %d qpid 0x%0x qhp %p dma_addr 0x%llx size %d rq_addr 0x%x\n", __func__, qhp->attr.sq_num_entries, qhp->attr.rq_num_entries, qhp->wq.qpid, qhp, (unsigned long long)qhp->wq.dma_addr, diff --git a/drivers/infiniband/hw/cxgb3/iwch_provider.h b/drivers/infiniband/hw/cxgb3/iwch_provider.h index 9e216edec4c0..2e38ddefea8a 100644 --- a/drivers/infiniband/hw/cxgb3/iwch_provider.h +++ b/drivers/infiniband/hw/cxgb3/iwch_provider.h @@ -168,7 +168,6 @@ struct iwch_qp { atomic_t refcnt; wait_queue_head_t wait; enum IWCH_QP_FLAGS flags; - struct timer_list timer; }; static inline int qp_quiesced(struct iwch_qp *qhp)