From patchwork Tue Oct 17 00:29:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 826598 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="jDHnLOsH"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yGGQ51tRNz9s0Z for ; Tue, 17 Oct 2017 11:33:33 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755463AbdJQAdR (ORCPT ); Mon, 16 Oct 2017 20:33:17 -0400 Received: from mail-pf0-f181.google.com ([209.85.192.181]:49328 "EHLO mail-pf0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933191AbdJQAaL (ORCPT ); Mon, 16 Oct 2017 20:30:11 -0400 Received: by mail-pf0-f181.google.com with SMTP id i5so43024pfe.6 for ; Mon, 16 Oct 2017 17:30:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=a8vRDKEWHx4+KYniHz5kUlnsA7wSuKEbhoLRYCSsUSA=; b=jDHnLOsHQPxI6cADZ/DXje9UqtAI059XhHJDKSItjA+uzSeTkQfs2Yk6YiWyOMThaV RAHQzW86K1mXG1tChtlkivxe9V3pXdTJANmwDwLn8wuyaOq1ovYB/yYzjt1wK8CRizMc GSK5WPBMh1pq8FMN4fAuOumpsaAHEik+ZiEQk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=a8vRDKEWHx4+KYniHz5kUlnsA7wSuKEbhoLRYCSsUSA=; b=TESupJIubMKyKRxNiCPQt4wktapDMK2DwcR+ZJQNu7U11rR91aUJIbYi0IWcotJsRP 3Ld3p9Gwx2TS6aCPlUsn8gBQlPgiVQ2AFmBKuZRG6QyfqdTwS/N9ZJSqXriTXhVs+d2N NnBBXPNw0qd5x6/LKQr/m5JcQ8ip/vmSht6PbqmyQkE+i2CgjU8/7vfE/SIkoPqsVeRi 58httZUBJo3cNPCJk9/Myo7z1UR5AJc9wZFVHCBI2jP69WWSBjJSnOXCkg95cWbygE8I A4TGjLKPINlXOIIku7slEtGn5ImDXZq34j/Rs0hcElPOrc2srkIOFtL8NdJ8tP+CNPRZ Ifgw== X-Gm-Message-State: AMCzsaV4LH7hPQnjB7ebvZgvn74s4uZUwybuOa4PrKMM5f4UiFKSLVP3 2KxiN6sWROj7hapHxcPEVyZ6XA== X-Google-Smtp-Source: AOwi7QCgH5dr4zsDu4pvUNab9RCgsdUyikO8yCyY7L9j1i4QkGyWOivObwb0RQ7orK3SGZPlsm8MLw== X-Received: by 10.99.117.74 with SMTP id f10mr9482808pgn.27.1508200210589; Mon, 16 Oct 2017 17:30:10 -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 y3sm15732722pfe.68.2017.10.16.17.30.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Oct 2017 17:30:04 -0700 (PDT) From: Kees Cook To: "David S. Miller" Cc: Kees Cook , Chas Williams <3chas3@gmail.com>, linux-atm-general@lists.sourceforge.net, netdev@vger.kernel.org, Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH 20/58] atm: idt77252: Convert timers to use timer_setup() Date: Mon, 16 Oct 2017 17:29:04 -0700 Message-Id: <1508200182-104605-21-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508200182-104605-1-git-send-email-keescook@chromium.org> References: <1508200182-104605-1-git-send-email-keescook@chromium.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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. This required adding a pointer back to vc_map, and adjusting the locking around removal a bit. Cc: Chas Williams <3chas3@gmail.com> Cc: linux-atm-general@lists.sourceforge.net Cc: netdev@vger.kernel.org Signed-off-by: Kees Cook --- drivers/atm/idt77252.c | 21 ++++++++++++--------- drivers/atm/idt77252.h | 3 +++ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c index 47f3c4ae0594..0e3b9c44c808 100644 --- a/drivers/atm/idt77252.c +++ b/drivers/atm/idt77252.c @@ -2073,21 +2073,19 @@ idt77252_rate_logindex(struct idt77252_dev *card, int pcr) } static void -idt77252_est_timer(unsigned long data) +idt77252_est_timer(struct timer_list *t) { - struct vc_map *vc = (struct vc_map *)data; + struct rate_estimator *est = from_timer(est, t, timer); + struct vc_map *vc = est->vc; struct idt77252_dev *card = vc->card; - struct rate_estimator *est; unsigned long flags; u32 rate, cps; u64 ncells; u8 lacr; spin_lock_irqsave(&vc->lock, flags); - est = vc->estimator; - if (!est) + if (!vc->estimator) goto out; - ncells = est->cells; rate = ((u32)(ncells - est->last_cells)) << (7 - est->interval); @@ -2126,10 +2124,11 @@ idt77252_init_est(struct vc_map *vc, int pcr) est->maxcps = pcr < 0 ? -pcr : pcr; est->cps = est->maxcps; est->avcps = est->cps << 5; + est->vc = vc; est->interval = 2; /* XXX: make this configurable */ est->ewma_log = 2; /* XXX: make this configurable */ - setup_timer(&est->timer, idt77252_est_timer, (unsigned long)vc); + timer_setup(&est->timer, idt77252_est_timer, 0); mod_timer(&est->timer, jiffies + ((HZ / 4) << est->interval)); return est; @@ -2209,16 +2208,20 @@ static int idt77252_init_ubr(struct idt77252_dev *card, struct vc_map *vc, struct atm_vcc *vcc, struct atm_qos *qos) { + struct rate_estimator *est = NULL; unsigned long flags; int tcr; spin_lock_irqsave(&vc->lock, flags); if (vc->estimator) { - del_timer(&vc->estimator->timer); - kfree(vc->estimator); + est = vc->estimator; vc->estimator = NULL; } spin_unlock_irqrestore(&vc->lock, flags); + if (est) { + del_timer_sync(&est->timer); + kfree(est); + } tcr = atm_pcr_goal(&qos->txtp); if (tcr == 0) diff --git a/drivers/atm/idt77252.h b/drivers/atm/idt77252.h index 3a82cc23a053..9339197d701c 100644 --- a/drivers/atm/idt77252.h +++ b/drivers/atm/idt77252.h @@ -184,6 +184,8 @@ struct aal1 { unsigned char sequence; }; +struct vc_map; + struct rate_estimator { struct timer_list timer; unsigned int interval; @@ -193,6 +195,7 @@ struct rate_estimator { long avcps; u32 cps; u32 maxcps; + struct vc_map *vc; }; struct vc_map {