Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4272571ybi; Tue, 18 Jun 2019 15:09:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqw8AnsU3GLNOVf9nS+U+gNOq4KtyyzxEkgj8BqV68I9VzFOrU33FB3MrSsX0NJf9S+bXROb X-Received: by 2002:a17:90a:3310:: with SMTP id m16mr7354471pjb.7.1560895774031; Tue, 18 Jun 2019 15:09:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560895774; cv=none; d=google.com; s=arc-20160816; b=PW6vyxkbF6P7PJt3jA/1VxAxubLqwperLqFrgB/h/ey7zmq7cznSDoYX3FqCFzBj/x uuSas/JgY8nBNaZqZ0EF0Cd4oAoWzzdio9YSZkOcfRwFF9jSEs9YR0t6QghJ6on6kAye dnz0Nu1Axp3JX6R5mNccxO2PiBua502OL2w5cm80lNCPPMQkOQ1O/W5IIkFQ3Za+bUJJ FyLQXknPIFiDZn8jVh58G+sNWqfoecxkf8uzoacfwYX5TBlAcx5bDiqNaWWwbBKSgcnu PdJyQCgYfzNI/xC2ZYQk4Z1QPQcwwSXnsB6dYiTpBZ+x2T+HgGqApw0n4gBNXNyPSkOX fOTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=cJhXDMxlF4zheXAyGu3M3eT8etAp0t6lqkCYLG9eTSw=; b=FEb76JFLBR+wRur+okmv9VpEH4nvmbcozRaPMrO33sNUjrEJdU7dKUFf6Dv3py3sK6 W8wvb45T5Q3Zjn09W5sjohtoSfcXSuTe6VrmICaynlgSlXhw+gmVGIii8ZhNcEUPt5kW 6sAW78tW+IRXwhe3jiuGGT4zo1jI9cAImzID8kxpJjI0G2Fi7AKou3Buubikgr42iqev /1QqfbqQBAqT2dUYIsxgrr/+grHEzyQKKItkbWBgxHtlmEKNP6u1LRDZUKZx/6Ty1PG8 5HSLt0a1LnSqJVmbstfGx/Zn1+Gph8+BsEApmzb74BThNUB29vWU8EGRiN+aWt9dUVNX DbGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CXSwSzE5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w6si1177910pgs.103.2019.06.18.15.09.16; Tue, 18 Jun 2019 15:09:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CXSwSzE5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730695AbfFRWJD (ORCPT + 99 others); Tue, 18 Jun 2019 18:09:03 -0400 Received: from mail-qk1-f196.google.com ([209.85.222.196]:35363 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729982AbfFRWJD (ORCPT ); Tue, 18 Jun 2019 18:09:03 -0400 Received: by mail-qk1-f196.google.com with SMTP id l128so9664380qke.2; Tue, 18 Jun 2019 15:09:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=cJhXDMxlF4zheXAyGu3M3eT8etAp0t6lqkCYLG9eTSw=; b=CXSwSzE51QWj1ILTdavUUdyYP6c4dh8l3QvL7B3g8uOCApTR6sH8sOoBVhsk4iv/DQ bPZ8eHn0JGlb6n/uQjDOa2kCLmHO1TBHobdkQLUmLw96ZmSkkcGN0N2PkPhWo2mBzA8q PqQWcSY5ifW+THF7Ldb/w5H+s+wlfgUqKiMFFcPht5P/iu0P4+jNPG7yiRvGkcqyM71Q O70Z9qefifoLXxhXkfDbkbguuacRR1mIAo51BlFGFExnioxXH+6IfPoQ0wMak8BQnhBl 4/b3W4G5sdCGu7wjwqMbPL3nXRRF14AWAecpm927lNfcVpp4XFzlxQ9L+Hmge+AQ5GbK a8nw== 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:mime-version :content-transfer-encoding; bh=cJhXDMxlF4zheXAyGu3M3eT8etAp0t6lqkCYLG9eTSw=; b=V9OP3x7fnQAI2Am3nPFENN78C/i0qMAbX5ivUu5xF1moDxbeK/niRgFjUhCsPYPuh/ sGEiaXyEkSlr6CshX8D3WJR9jJI0s2OlPhAUvKxCWa48jZhUQvMN+w5CMEbA/bWBOMDj IgycaTUvMMq3vad4bntlm/MOxy46QacCLyR+FZ0hcYIv1E47pyCG3VjwYcNVO1dAd3+M VyidWarOBUUP1NdJ8cuQXFRtsHoHROgvvFqhEGrn60kGYLkaojfbe7pb+Wobsy5yaonu VrD9Y6yEsseqg1PAVdfQb8hpul0D9PL0OhUpiTJUer04B0HBOMIZtsj5FrHOJ5qJpJPy vMWQ== X-Gm-Message-State: APjAAAWFu/Ei8vzYi87xRnFDwKF5w24uLkYbhQTMuUA4bbOAUrMIZqm0 q5F0xsexRhgyFUBI7JCm6OQ= X-Received: by 2002:a37:9c16:: with SMTP id f22mr96843097qke.261.1560895741514; Tue, 18 Jun 2019 15:09:01 -0700 (PDT) Received: from localhost.localdomain (mtrlpq02hsy-lp140-01-174-93-144-21.dsl.bell.ca. [174.93.144.21]) by smtp.gmail.com with ESMTPSA id 41sm11912767qtp.32.2019.06.18.15.09.00 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 18 Jun 2019 15:09:00 -0700 (PDT) From: Detlev Casanova To: Jeff Kirsher , "David S. Miller" , intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Detlev Casanova Subject: [PATCH v2] e1000e: Make watchdog use delayed work Date: Tue, 18 Jun 2019 18:08:46 -0400 Message-Id: <20190618220846.19486-1-detlev.casanova@gmail.com> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use delayed work instead of timers to run the watchdog of the e1000e driver. Simplify the code with one less middle function. Signed-off-by: Detlev Casanova --- drivers/net/ethernet/intel/e1000e/e1000.h | 3 +- drivers/net/ethernet/intel/e1000e/netdev.c | 54 ++++++++++++---------- 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/e1000.h b/drivers/net/ethernet/intel/e1000e/e1000.h index be13227f1697..942ab74030ca 100644 --- a/drivers/net/ethernet/intel/e1000e/e1000.h +++ b/drivers/net/ethernet/intel/e1000e/e1000.h @@ -186,12 +186,11 @@ struct e1000_phy_regs { /* board specific private data structure */ struct e1000_adapter { - struct timer_list watchdog_timer; struct timer_list phy_info_timer; struct timer_list blink_timer; struct work_struct reset_task; - struct work_struct watchdog_task; + struct delayed_work watchdog_task; const struct e1000_info *ei; diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index 0e09bede42a2..22a5d594115f 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -39,6 +39,8 @@ static int debug = -1; module_param(debug, int, 0); MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)"); +static struct workqueue_struct *e1000_workqueue; + static const struct e1000_info *e1000_info_tbl[] = { [board_82571] = &e1000_82571_info, [board_82572] = &e1000_82572_info, @@ -1780,7 +1782,8 @@ static irqreturn_t e1000_intr_msi(int __always_unused irq, void *data) } /* guard against interrupt when we're going down */ if (!test_bit(__E1000_DOWN, &adapter->state)) - mod_timer(&adapter->watchdog_timer, jiffies + 1); + queue_delayed_work(e1000_workqueue, + &adapter->watchdog_task, 1); } /* Reset on uncorrectable ECC error */ @@ -1860,7 +1863,8 @@ static irqreturn_t e1000_intr(int __always_unused irq, void *data) } /* guard against interrupt when we're going down */ if (!test_bit(__E1000_DOWN, &adapter->state)) - mod_timer(&adapter->watchdog_timer, jiffies + 1); + queue_delayed_work(e1000_workqueue, + &adapter->watchdog_task, 1); } /* Reset on uncorrectable ECC error */ @@ -1905,7 +1909,8 @@ static irqreturn_t e1000_msix_other(int __always_unused irq, void *data) hw->mac.get_link_status = true; /* guard against interrupt when we're going down */ if (!test_bit(__E1000_DOWN, &adapter->state)) - mod_timer(&adapter->watchdog_timer, jiffies + 1); + queue_delayed_work(e1000_workqueue, + &adapter->watchdog_task, 1); } if (!test_bit(__E1000_DOWN, &adapter->state)) @@ -4278,7 +4283,6 @@ void e1000e_down(struct e1000_adapter *adapter, bool reset) napi_synchronize(&adapter->napi); - del_timer_sync(&adapter->watchdog_timer); del_timer_sync(&adapter->phy_info_timer); spin_lock(&adapter->stats64_lock); @@ -5150,25 +5154,11 @@ static void e1000e_check_82574_phy_workaround(struct e1000_adapter *adapter) } } -/** - * e1000_watchdog - Timer Call-back - * @data: pointer to adapter cast into an unsigned long - **/ -static void e1000_watchdog(struct timer_list *t) -{ - struct e1000_adapter *adapter = from_timer(adapter, t, watchdog_timer); - - /* Do the rest outside of interrupt context */ - schedule_work(&adapter->watchdog_task); - - /* TODO: make this use queue_delayed_work() */ -} - static void e1000_watchdog_task(struct work_struct *work) { struct e1000_adapter *adapter = container_of(work, struct e1000_adapter, - watchdog_task); + watchdog_task.work); struct net_device *netdev = adapter->netdev; struct e1000_mac_info *mac = &adapter->hw.mac; struct e1000_phy_info *phy = &adapter->hw.phy; @@ -5395,8 +5385,8 @@ static void e1000_watchdog_task(struct work_struct *work) /* Reset the timer */ if (!test_bit(__E1000_DOWN, &adapter->state)) - mod_timer(&adapter->watchdog_timer, - round_jiffies(jiffies + 2 * HZ)); + queue_delayed_work(e1000_workqueue, &adapter->watchdog_task, + round_jiffies(2 * HZ)); } #define E1000_TX_FLAGS_CSUM 0x00000001 @@ -7251,11 +7241,20 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto err_eeprom; } - timer_setup(&adapter->watchdog_timer, e1000_watchdog, 0); + e1000_workqueue = alloc_workqueue("%s", WQ_MEM_RECLAIM, 0, + e1000e_driver_name); + + if (!e1000_workqueue) { + err = -ENOMEM; + goto err_workqueue; + } + + INIT_DELAYED_WORK(&adapter->watchdog_task, e1000_watchdog_task); + queue_delayed_work(e1000_workqueue, &adapter->watchdog_task, 0); + timer_setup(&adapter->phy_info_timer, e1000_update_phy_info, 0); INIT_WORK(&adapter->reset_task, e1000_reset_task); - INIT_WORK(&adapter->watchdog_task, e1000_watchdog_task); INIT_WORK(&adapter->downshift_task, e1000e_downshift_workaround); INIT_WORK(&adapter->update_phy_task, e1000e_update_phy_task); INIT_WORK(&adapter->print_hang_task, e1000_print_hw_hang); @@ -7349,6 +7348,9 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent) return 0; err_register: + flush_workqueue(e1000_workqueue); + destroy_workqueue(e1000_workqueue); +err_workqueue: if (!(adapter->flags & FLAG_HAS_AMT)) e1000e_release_hw_control(adapter); err_eeprom: @@ -7395,15 +7397,17 @@ static void e1000_remove(struct pci_dev *pdev) */ if (!down) set_bit(__E1000_DOWN, &adapter->state); - del_timer_sync(&adapter->watchdog_timer); del_timer_sync(&adapter->phy_info_timer); cancel_work_sync(&adapter->reset_task); - cancel_work_sync(&adapter->watchdog_task); cancel_work_sync(&adapter->downshift_task); cancel_work_sync(&adapter->update_phy_task); cancel_work_sync(&adapter->print_hang_task); + cancel_delayed_work(&adapter->watchdog_task); + flush_workqueue(e1000_workqueue); + destroy_workqueue(e1000_workqueue); + if (adapter->flags & FLAG_HAS_HW_TIMESTAMP) { cancel_work_sync(&adapter->tx_hwtstamp_work); if (adapter->tx_hwtstamp_skb) { -- 2.22.0