From patchwork Mon Oct 16 22:52:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10010027 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 436CA601D5 for ; Mon, 16 Oct 2017 22:52:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 339B2286A9 for ; Mon, 16 Oct 2017 22:52:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 27640286E7; Mon, 16 Oct 2017 22:52:37 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham 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 701EC286A9 for ; Mon, 16 Oct 2017 22:52:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757225AbdJPWwf (ORCPT ); Mon, 16 Oct 2017 18:52:35 -0400 Received: from mail-pf0-f171.google.com ([209.85.192.171]:48627 "EHLO mail-pf0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757223AbdJPWwe (ORCPT ); Mon, 16 Oct 2017 18:52:34 -0400 Received: by mail-pf0-f171.google.com with SMTP id b79so16875982pfk.5 for ; Mon, 16 Oct 2017 15:52:33 -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=GACiJuaQw2Du9pkcRzdIQ5a8lGnQsUUnPstf2T/+G3c=; b=I3nYFR9OPdrGEqmY5rZfwttrp2wZb8OM2o/6EGVzmormsNEF9nw6MCYOFx1LGGv/fB IE6csypBelxuIWU7t7rk0LF90AP2MnZaVZ25xHmQSvvsMzpOauA4HTjN9WN0K5e2kDN+ bYgR9f7OJw9Qz7Mcbd4NF1gaIdBviEA32k0Xw= 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=GACiJuaQw2Du9pkcRzdIQ5a8lGnQsUUnPstf2T/+G3c=; b=YkF+5OjBwBiXkQll9V/1bIj9O8gbeXY2DXiSJGp2JaExwYk+I9qJ1wcVQPoPMUszBj +m5OpTu2myudXWJiLxBfQqMX7LhpcWSvb3x0wK4dKjDDJ0gu9F53BNqX7rdlqpR3e7tD Yj+gOrrdX4kJl0/iRrD/0w1YFDkVYnhWn8ANgSCHtTqMVspb4LHQ+czExpoXQKh/UyIb wHKeyIJxuo4s1ITXR670E/AeNeeKPyNbkTXupAZdnqCIkc1gJvAmRm+TJBsYbj5d9Kek LRabsCr9UW7++O7EByeVGZApWwY+wvrNEXCxredAWcU8w7TKtV5jyCp4dEdo27ZY4OLH o3QQ== X-Gm-Message-State: AMCzsaUIW5QqOZJY6YTwVXdW7UfIENFnu3sKvkfA4EzzXFxt5vvFLYzc fd0ORrF995CWInDO7QDhxUHies6dV88= X-Google-Smtp-Source: AOwi7QCrFIvttRyEhl6CRtRv9beoE2yiRsdmeUOIKH/Uqlmq0FE+8pNdesPZksPuW+5/XcnQrdfY4g== X-Received: by 10.159.253.71 with SMTP id b7mr10441348plx.169.1508194353487; Mon, 16 Oct 2017 15:52:33 -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 q16sm14544603pgq.79.2017.10.16.15.52.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Oct 2017 15:52:32 -0700 (PDT) Date: Mon, 16 Oct 2017 15:52:31 -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/cxgb4: Convert timers to use timer_setup() Message-ID: <20171016225231.GA98935@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 and drops a redundant initialization. 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/cxgb4/cm.c | 13 +++++-------- drivers/infiniband/hw/cxgb4/iw_cxgb4.h | 1 - drivers/infiniband/hw/cxgb4/qp.c | 1 - 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c index e395afcd7d33..919b68422a5e 100644 --- a/drivers/infiniband/hw/cxgb4/cm.c +++ b/drivers/infiniband/hw/cxgb4/cm.c @@ -144,7 +144,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 c4iw_ep *ep, int status); static int sched(struct c4iw_dev *dev, struct sk_buff *skb); @@ -189,8 +189,6 @@ static void start_ep_timer(struct c4iw_ep *ep) clear_bit(TIMEOUT, &ep->com.flags); c4iw_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); } @@ -2107,7 +2105,6 @@ static int c4iw_reconnect(struct c4iw_ep *ep) __u8 *ra; pr_debug("qp %p cm_id %p\n", ep->com.qp, ep->com.cm_id); - init_timer(&ep->timer); c4iw_init_wr_wait(ep->com.wr_waitp); /* When MPA revision is different on nodes, the node with MPA_rev=2 @@ -2585,7 +2582,7 @@ static int pass_accept_req(struct c4iw_dev *dev, struct sk_buff *skb) pr_debug("tx_chan %u smac_idx %u rss_qid %u\n", child_ep->tx_chan, child_ep->smac_idx, child_ep->rss_qid); - init_timer(&child_ep->timer); + timer_setup(&child_ep->timer, ep_timeout, 0); cxgb4_insert_tid(t, child_ep, hwtid, child_ep->com.local_addr.ss_family); insert_ep_tid(child_ep); @@ -3210,7 +3207,7 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) goto fail1; } - 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), @@ -4122,9 +4119,9 @@ static void process_work(struct work_struct *work) static DECLARE_WORK(skb_work, process_work); -static void ep_timeout(unsigned long arg) +static void ep_timeout(struct timer_list *t) { - struct c4iw_ep *ep = (struct c4iw_ep *)arg; + struct c4iw_ep *ep = from_timer(ep, t, timer); int kickit = 0; spin_lock(&timeout_lock); diff --git a/drivers/infiniband/hw/cxgb4/iw_cxgb4.h b/drivers/infiniband/hw/cxgb4/iw_cxgb4.h index d730bb735d74..788ddb6aa57b 100644 --- a/drivers/infiniband/hw/cxgb4/iw_cxgb4.h +++ b/drivers/infiniband/hw/cxgb4/iw_cxgb4.h @@ -537,7 +537,6 @@ struct c4iw_qp { struct mutex mutex; struct kref kref; wait_queue_head_t wait; - struct timer_list timer; int sq_sig_all; struct work_struct free_work; struct c4iw_ucontext *ucontext; diff --git a/drivers/infiniband/hw/cxgb4/qp.c b/drivers/infiniband/hw/cxgb4/qp.c index 56655a000121..57b23e33eb8b 100644 --- a/drivers/infiniband/hw/cxgb4/qp.c +++ b/drivers/infiniband/hw/cxgb4/qp.c @@ -1929,7 +1929,6 @@ struct ib_qp *c4iw_create_qp(struct ib_pd *pd, struct ib_qp_init_attr *attrs, qhp->ucontext = ucontext; } qhp->ibqp.qp_num = qhp->wq.sq.qid; - init_timer(&(qhp->timer)); INIT_LIST_HEAD(&qhp->db_fc_entry); pr_debug("sq id %u size %u memsize %zu num_entries %u rq id %u size %u memsize %zu num_entries %u\n", qhp->wq.sq.qid, qhp->wq.sq.size, qhp->wq.sq.memsize,