From patchwork Tue Oct 10 22:06:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9998059 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 96C9E603B5 for ; Tue, 10 Oct 2017 22:06:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8981E287BD for ; Tue, 10 Oct 2017 22:06:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7E86B287DB; Tue, 10 Oct 2017 22:06:15 +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.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM 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 11D9C287BD for ; Tue, 10 Oct 2017 22:06:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756713AbdJJWGE (ORCPT ); Tue, 10 Oct 2017 18:06:04 -0400 Received: from mail-pf0-f169.google.com ([209.85.192.169]:43247 "EHLO mail-pf0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756684AbdJJWGD (ORCPT ); Tue, 10 Oct 2017 18:06:03 -0400 Received: by mail-pf0-f169.google.com with SMTP id d2so15481290pfh.0 for ; Tue, 10 Oct 2017 15:06:02 -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=K10UAI/DsS/VD6sj4Fqqh/qnqVkCU4PPa1Vb/b9ugNI=; b=Pjx8Bor25fHP3sQu0Svkez/lnwZztFVp9ef+dnJ8eFEIBcg9jyIZqmR6SI9/OPlHZe IOAIM2QRiAfK9D4SVBe1TE2Ys7iKgPLSqoJNd6bNtLq8jpsB+RtBdHlyaxVcBPhY5eVW uK7nlZhJCOLkYg85ivrfaZ+JolHjrxgMsyux4= 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=K10UAI/DsS/VD6sj4Fqqh/qnqVkCU4PPa1Vb/b9ugNI=; b=hrfyqGsyO9IiRrSJcpbGYE42XF787DxOrnfW1396Ji8VrYkuyZd9UrHbHNbfyaZcdd TH+jYjtI/ecoQQ+Cv6za3zhbHFQ/4DpBWx3BR7O3YAPXRVpg+9foqN49lW8liN3hZQcr x3Oj6HhZ2lHoME8ecCYjmQSsd6B9RTI9T5dV91a8WkWIgTVnC50QAHLZEZgst5aoTIzc NOSVD5JRLK1Z0cMnizfKSUsjyLObi2l2FXHOgaw+YUJdkpOS3EVgKSAplVBCc4N7dUHF 9ehSZgUtgk+Z8Ij7yg62ykaMbTo+6ltmheAFTQ9VuJazG/k3Rly04iJK8PgcCwDkJa6g GTww== X-Gm-Message-State: AMCzsaUf0VWTIHjZrNGjMZ6BGH1x/90uSztZr/kBw9rNCRW19x5x3VMk 85rihcER/j1JtmizrC7KrXAyMw== X-Google-Smtp-Source: AOwi7QCvi63NS7MrWpbv8gd62TgitLXgPuAXc5rcSonubTysbGqZTP76PCIXQHP8RDGVHqnUFNXiuQ== X-Received: by 10.101.64.11 with SMTP id f11mr11309575pgp.217.1507673162463; Tue, 10 Oct 2017 15:06:02 -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 a1sm18716397pgu.47.2017.10.10.15.06.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Oct 2017 15:06:01 -0700 (PDT) Date: Tue, 10 Oct 2017 15:06:00 -0700 From: Kees Cook To: "Martin K. Petersen" Cc: Tyrel Datwyler , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , "James E.J. Bottomley" , linux-scsi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH] scsi: ibmvscsi: Convert timers to use timer_setup() Message-ID: <20171010220600.GA97572@beast> MIME-Version: 1.0 Content-Disposition: inline Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@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. Cc: "Martin K. Petersen" Cc: Tyrel Datwyler Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Michael Ellerman Cc: "James E.J. Bottomley" Cc: linux-scsi@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org Signed-off-by: Kees Cook --- This requires commit 686fef928bba ("timer: Prepare to change timer callback argument type") in v4.14-rc3, but should be otherwise stand-alone. --- drivers/scsi/ibmvscsi/ibmvfc.c | 14 ++++++-------- drivers/scsi/ibmvscsi/ibmvscsi.c | 7 +++---- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c index b491af31a5f8..0d2f7eb3acb6 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc.c +++ b/drivers/scsi/ibmvscsi/ibmvfc.c @@ -1393,8 +1393,9 @@ static int ibmvfc_map_sg_data(struct scsi_cmnd *scmd, * * Called when an internally generated command times out **/ -static void ibmvfc_timeout(struct ibmvfc_event *evt) +static void ibmvfc_timeout(struct timer_list *t) { + struct ibmvfc_event *evt = from_timer(evt, t, timer); struct ibmvfc_host *vhost = evt->vhost; dev_err(vhost->dev, "Command timed out (%p). Resetting connection\n", evt); ibmvfc_reset_host(vhost); @@ -1424,12 +1425,10 @@ static int ibmvfc_send_event(struct ibmvfc_event *evt, BUG(); list_add_tail(&evt->queue, &vhost->sent); - init_timer(&evt->timer); + timer_setup(&evt->timer, ibmvfc_timeout, 0); if (timeout) { - evt->timer.data = (unsigned long) evt; evt->timer.expires = jiffies + (timeout * HZ); - evt->timer.function = (void (*)(unsigned long))ibmvfc_timeout; add_timer(&evt->timer); } @@ -3692,8 +3691,9 @@ static void ibmvfc_tgt_adisc_cancel_done(struct ibmvfc_event *evt) * out, reset the CRQ. When the ADISC comes back as cancelled, * log back into the target. **/ -static void ibmvfc_adisc_timeout(struct ibmvfc_target *tgt) +static void ibmvfc_adisc_timeout(struct timer_list *t) { + struct ibmvfc_target *tgt = from_timer(tgt, t, timer); struct ibmvfc_host *vhost = tgt->vhost; struct ibmvfc_event *evt; struct ibmvfc_tmf *tmf; @@ -3778,9 +3778,7 @@ static void ibmvfc_tgt_adisc(struct ibmvfc_target *tgt) if (timer_pending(&tgt->timer)) mod_timer(&tgt->timer, jiffies + (IBMVFC_ADISC_TIMEOUT * HZ)); else { - tgt->timer.data = (unsigned long) tgt; tgt->timer.expires = jiffies + (IBMVFC_ADISC_TIMEOUT * HZ); - tgt->timer.function = (void (*)(unsigned long))ibmvfc_adisc_timeout; add_timer(&tgt->timer); } @@ -3912,7 +3910,7 @@ static int ibmvfc_alloc_target(struct ibmvfc_host *vhost, u64 scsi_id) tgt->vhost = vhost; tgt->need_login = 1; tgt->cancel_key = vhost->task_set++; - init_timer(&tgt->timer); + timer_setup(&tgt->timer, ibmvfc_adisc_timeout, 0); kref_init(&tgt->kref); ibmvfc_init_tgt(tgt, ibmvfc_tgt_implicit_logout); spin_lock_irqsave(vhost->host->host_lock, flags); diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c index 7d156b161482..17df76f0be3c 100644 --- a/drivers/scsi/ibmvscsi/ibmvscsi.c +++ b/drivers/scsi/ibmvscsi/ibmvscsi.c @@ -837,8 +837,9 @@ static void ibmvscsi_reset_host(struct ibmvscsi_host_data *hostdata) * * Called when an internally generated command times out */ -static void ibmvscsi_timeout(struct srp_event_struct *evt_struct) +static void ibmvscsi_timeout(struct timer_list *t) { + struct srp_event_struct *evt_struct = from_timer(evt_struct, t, timer); struct ibmvscsi_host_data *hostdata = evt_struct->hostdata; dev_err(hostdata->dev, "Command timed out (%x). Resetting connection\n", @@ -927,11 +928,9 @@ static int ibmvscsi_send_srp_event(struct srp_event_struct *evt_struct, */ list_add_tail(&evt_struct->list, &hostdata->sent); - init_timer(&evt_struct->timer); + timer_setup(&evt_struct->timer, ibmvscsi_timeout, 0); if (timeout) { - evt_struct->timer.data = (unsigned long) evt_struct; evt_struct->timer.expires = jiffies + (timeout * HZ); - evt_struct->timer.function = (void (*)(unsigned long))ibmvscsi_timeout; add_timer(&evt_struct->timer); }