From patchwork Thu Oct 5 00:54:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9986201 X-Patchwork-Delegate: andy.shevchenko@gmail.com 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 1A30D60291 for ; Thu, 5 Oct 2017 00:55:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0BFA628C43 for ; Thu, 5 Oct 2017 00:55:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 005AE28C45; Thu, 5 Oct 2017 00:55:22 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI 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 7968728C43 for ; Thu, 5 Oct 2017 00:55:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753154AbdJEAy0 (ORCPT ); Wed, 4 Oct 2017 20:54:26 -0400 Received: from mail-pf0-f175.google.com ([209.85.192.175]:43694 "EHLO mail-pf0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753185AbdJEAyX (ORCPT ); Wed, 4 Oct 2017 20:54:23 -0400 Received: by mail-pf0-f175.google.com with SMTP id d2so3938138pfh.0 for ; Wed, 04 Oct 2017 17:54:23 -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=Xa8RC3TtZh26LBA+S9lyhzfACApeRcv2Q3MtZBqAomU=; b=MAbju1J3tc+QhzdaqMiRCg4Phbm/4WoZYglx+EBP68B73f2K65Co/IgcH645WzbtUW 4V4Bj49FD4avRtxUQeYqebgZhNjAxeL8tuuOkauBHq/540Wkypty5VsBcIqQMupcqX9v dOHr4HOxyoQ21am6aiJ1NMjEKE3TNzfsHTCVU= 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=Xa8RC3TtZh26LBA+S9lyhzfACApeRcv2Q3MtZBqAomU=; b=NVv0Zhu87cdIsabLkkwX4lMIvkAcaYi4tWGxAGF09yJY4CnhlGBtb0wRUSevQegoPe dYN0NVKs2FDL+LCUM97OY+hgzGWZlAb19lhg2asNI2QhCc/9pAyw6vld2Ix8W37DZdRF 7Fcu5+EX1jw2C8x+lIgwODVp0nUrb+uZhtAeweMj3HBJY5WxwbPKjRI7kUKkIOVQxhoR JsUfvyluu+yG8ea4IuukjcBqPrCOEJ0vErU8A0jUO31On+7QjcFr77UW2xTnwt6e6KUq UgqTWk3NXzK3VOdVScW/iQr3OAziEYf5hSOgKC7jHmEZx+Q9oWrsV5Qb399N2lxkEjC2 SKQA== X-Gm-Message-State: AMCzsaUkA99yAeLapKSaawtPRggMAyAefnLODppMVnd+fSlIoSVjqHK0 XAOSRuTL4HptmfsTcwpFXOo8mg== X-Google-Smtp-Source: AOwi7QBpDldY3m0fa3PR0WJJVzsHsQFiH6D8vGKS4Z51FevgwHTWFl3DLSe6SclNrauyQuD9/8Oa/Q== X-Received: by 10.98.84.66 with SMTP id i63mr10618451pfb.97.1507164863249; Wed, 04 Oct 2017 17:54:23 -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 v41sm22229390pgn.44.2017.10.04.17.54.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Oct 2017 17:54:22 -0700 (PDT) Date: Wed, 4 Oct 2017 17:54:21 -0700 From: Kees Cook To: linux-kernel@vger.kernel.org Cc: Darren Hart , Andy Shevchenko , platform-driver-x86@vger.kernel.org, Thomas Gleixner Subject: [PATCH] intel_ips: Convert timers to use timer_setup() Message-ID: <20171005005421.GA23936@beast> MIME-Version: 1.0 Content-Disposition: inline Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@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. Moves timer structure off stack and into struct ips_driver. Cc: Darren Hart Cc: Andy Shevchenko Cc: platform-driver-x86@vger.kernel.org Cc: Thomas Gleixner 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/platform/x86/intel_ips.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/platform/x86/intel_ips.c b/drivers/platform/x86/intel_ips.c index 58dcee562d64..056afb731d79 100644 --- a/drivers/platform/x86/intel_ips.c +++ b/drivers/platform/x86/intel_ips.c @@ -300,6 +300,7 @@ struct ips_driver { struct task_struct *monitor; struct task_struct *adjust; struct dentry *debug_root; + struct timer_list timer; /* Average CPU core temps (all averages in .01 degrees C for precision) */ u16 ctv1_avg_temp; @@ -942,9 +943,10 @@ static u32 calc_avg_power(struct ips_driver *ips, u32 *array) return avg; } -static void monitor_timeout(unsigned long arg) +static void monitor_timeout(struct timer_list *t) { - wake_up_process((struct task_struct *)arg); + struct ips_driver *ips = from_timer(ips, t, timer); + wake_up_process(ips->monitor); } /** @@ -961,7 +963,6 @@ static void monitor_timeout(unsigned long arg) static int ips_monitor(void *data) { struct ips_driver *ips = data; - struct timer_list timer; unsigned long seqno_timestamp, expire, last_msecs, last_sample_period; int i; u32 *cpu_samples, *mchp_samples, old_cpu_power; @@ -1049,8 +1050,7 @@ static int ips_monitor(void *data) schedule_timeout_interruptible(msecs_to_jiffies(IPS_SAMPLE_PERIOD)); last_sample_period = IPS_SAMPLE_PERIOD; - setup_deferrable_timer_on_stack(&timer, monitor_timeout, - (unsigned long)current); + timer_setup(&ips->timer, monitor_timeout, TIMER_DEFERRABLE); do { u32 cpu_val, mch_val; u16 val; @@ -1107,7 +1107,7 @@ static int ips_monitor(void *data) expire = jiffies + msecs_to_jiffies(IPS_SAMPLE_PERIOD); __set_current_state(TASK_INTERRUPTIBLE); - mod_timer(&timer, expire); + mod_timer(&ips->timer, expire); schedule(); /* Calculate actual sample period for power averaging */ @@ -1116,8 +1116,7 @@ static int ips_monitor(void *data) last_sample_period = 1; } while (!kthread_should_stop()); - del_timer_sync(&timer); - destroy_timer_on_stack(&timer); + del_timer_sync(&ips->timer); dev_dbg(&ips->dev->dev, "ips-monitor thread stopped\n");