From patchwork Tue Oct 17 00:29:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10010525 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 40AE160235 for ; Tue, 17 Oct 2017 00:50:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3182E28720 for ; Tue, 17 Oct 2017 00:50:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 25A9C28726; Tue, 17 Oct 2017 00:50:01 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E01802871D for ; Tue, 17 Oct 2017 00:49:59 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e4G2k-0000ZB-Q5; Tue, 17 Oct 2017 00:47:38 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e4G2i-0000Z5-R6 for xen-devel@lists.xenproject.org; Tue, 17 Oct 2017 00:47:37 +0000 Received: from [85.158.139.211] by server-2.bemta-5.messagelabs.com id 73/F7-23269-82355E95; Tue, 17 Oct 2017 00:47:36 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrDIsWRWlGSWpSXmKPExsVyMfTAWl314Ke RBit2i1h83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBlLt79gL5giWvHw0yKWBsabQl2MXBxCAtMY JV69mcYK4rAILGCWmPV8BhOIIyHQzyox79ELoAwnkJMl8fDCeyYIO03i1fUGqHi1xNpvR9lAb CEBFYnpX6cyQ9hrmSS69vmD2GwC6hLn9y1nB7FFBLQl1h3oAdvGLPCOUeLI+99gDcIC3hIf/8 wFW8AioCpxrvMn2AJeAXeJ1R+nQS2Tk7h5rhOonoODEyg+p5cJxBQScJM4v4Z1AqPgAkaGVYz qxalFZalFupZ6SUWZ6RkluYmZObqGBqZ6uanFxYnpqTmJScV6yfm5mxiB4cYABDsY17Y6H2KU 5GBSEuV1NnwSKcSXlJ9SmZFYnBFfVJqTWnyIUYaDQ0mC93fg00ghwaLU9NSKtMwcYODDpCU4e JREeO2DgNK8xQWJucWZ6RCpU4z2HBfuXPrDxHFs02UgeWDPLSDZcfPuHyYhlrz8vFQpcYipAi BtGaV5cENhkXqJUVZKmJcR6EwhnoLUotzMElT5V4ziHIxKwrxMIMt5MvNK4Ha/AjqLCeisdU5 PQM4qSURISTUwMrjHPZdReScT+uGwNsc68W2zEhxOzBDImz1ld+W0jcv2Nim+vy6ackKY7UR+ zQWLhAMHHq0y7C/M6pRu8WA51xnPcrLhyjPtfvPDEkFTrZVX3TN+pS1YHhW/7OBMw/iDDw9t8 k43T13Se+DM1YNv0ljPRW9/vPDI3u37Nuwx3OdeeDk+9GjKOiWW4oxEQy3mouJEANfpqZnPAg AA X-Env-Sender: keescook@chromium.org X-Msg-Ref: server-13.tower-206.messagelabs.com!1508201254!91738631!1 X-Originating-IP: [209.85.192.173] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 55474 invoked from network); 17 Oct 2017 00:47:35 -0000 Received: from mail-pf0-f173.google.com (HELO mail-pf0-f173.google.com) (209.85.192.173) by server-13.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Oct 2017 00:47:35 -0000 Received: by mail-pf0-f173.google.com with SMTP id 17so60095pfn.12 for ; Mon, 16 Oct 2017 17:47:35 -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=qWUMFu2CQnm9atAyyW5reMD4Czw9wO2vaUi4TdU2afU=; b=fP95FolgGvMc3pQiLf8JH9T7PpfwiHlo1B6KFNkaW9kibItqdS/fUtNDUpQGtIRT0g 5EHXT4+6/GjTdnAUlOf0V1K3BKosaNZxuMkZxih5MSaIDJTIknq/5B7isRM/zoMM74yl mk+dym89RztvqftrKrPEoBFw/BSij/CRn/IlI= 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=qWUMFu2CQnm9atAyyW5reMD4Czw9wO2vaUi4TdU2afU=; b=hq47nLi505OqZdN4Iuqg2x8Ee30ITQD1p7rRAaZSvjNf8ItqwiRHykwudQAdp8wzex cZOMb8E+CDbScboGb5hLDaq3TCAxvF0XKjAwP+8p0tLXkiT1qD30WlivkAAVaEHT1v2g 0LyczYVOYNwaJFTQU32EM/aZePNmeKvfGA5/Dgx2bVist4MGIC8P7VFdid0xhRMJ5qAG vZErGhakMQQnTX4X347tmjluJbhnwdFNZyEIJNcoOQE9LHR+X9stocRUwV3sKPHS/u6Q xAeDq4HytBLPXUeFgs6j5anqcNMu6u7wTvYTOg1V9gQhNmUhD4XKxFQi2fMV6urwszby 4PeA== X-Gm-Message-State: AMCzsaXs13xYDCmgzoQstud9pxiBVw+6pKpf+0aNfFWxQ8HkI1Cr6HJ9 jwsiS9iZLRNqpspM8Kj/+dSV1g== X-Google-Smtp-Source: AOwi7QDAEDq5vNs69H93mY/SxDZTAKKjPrA+BS0dsIRhDQh+gDg7OlE/S6lmysr9Jh5lFx2l93DPLw== X-Received: by 10.159.216.131 with SMTP id s3mr10281946plp.434.1508201253728; Mon, 16 Oct 2017 17:47: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 p70sm17117814pfk.130.2017.10.16.17.47.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Oct 2017 17:47:29 -0700 (PDT) From: Kees Cook To: "David S. Miller" Date: Mon, 16 Oct 2017 17:29:38 -0700 Message-Id: <1508200182-104605-55-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> Cc: Wei Liu , Kees Cook , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Paul Durrant , xen-devel@lists.xenproject.org, Thomas Gleixner Subject: [Xen-devel] [PATCH 54/58] net/xen-netback: Convert timers to use timer_setup() X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" 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: Wei Liu Cc: Paul Durrant Cc: xen-devel@lists.xenproject.org Cc: netdev@vger.kernel.org Signed-off-by: Kees Cook Acked-by: Wei Liu --- drivers/net/xen-netback/common.h | 2 +- drivers/net/xen-netback/interface.c | 2 +- drivers/net/xen-netback/netback.c | 6 ++---- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/net/xen-netback/common.h b/drivers/net/xen-netback/common.h index 5b1d2e8402d9..a46a1e94505d 100644 --- a/drivers/net/xen-netback/common.h +++ b/drivers/net/xen-netback/common.h @@ -307,7 +307,7 @@ static inline struct xenbus_device *xenvif_to_xenbus_device(struct xenvif *vif) return to_xenbus_device(vif->dev->dev.parent); } -void xenvif_tx_credit_callback(unsigned long data); +void xenvif_tx_credit_callback(struct timer_list *t); struct xenvif *xenvif_alloc(struct device *parent, domid_t domid, diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c index dcfcb153918c..5cbe0ae55a07 100644 --- a/drivers/net/xen-netback/interface.c +++ b/drivers/net/xen-netback/interface.c @@ -520,7 +520,7 @@ int xenvif_init_queue(struct xenvif_queue *queue) queue->credit_bytes = queue->remaining_credit = ~0UL; queue->credit_usec = 0UL; - setup_timer(&queue->credit_timeout, xenvif_tx_credit_callback, 0UL); + timer_setup(&queue->credit_timeout, xenvif_tx_credit_callback, 0); queue->credit_window_start = get_jiffies_64(); queue->rx_queue_max = XENVIF_RX_QUEUE_BYTES; diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c index 5042ff8d449a..a27daa23c9dc 100644 --- a/drivers/net/xen-netback/netback.c +++ b/drivers/net/xen-netback/netback.c @@ -183,9 +183,9 @@ static void tx_add_credit(struct xenvif_queue *queue) queue->rate_limited = false; } -void xenvif_tx_credit_callback(unsigned long data) +void xenvif_tx_credit_callback(struct timer_list *t) { - struct xenvif_queue *queue = (struct xenvif_queue *)data; + struct xenvif_queue *queue = from_timer(queue, t, credit_timeout); tx_add_credit(queue); xenvif_napi_schedule_or_enable_events(queue); } @@ -700,8 +700,6 @@ static bool tx_credit_exceeded(struct xenvif_queue *queue, unsigned size) /* Still too big to send right now? Set a callback. */ if (size > queue->remaining_credit) { - queue->credit_timeout.data = - (unsigned long)queue; mod_timer(&queue->credit_timeout, next_credit); queue->credit_window_start = next_credit;