From patchwork Sat May 30 21:55:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 218117 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1144BC433DF for ; Sat, 30 May 2020 22:00:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DEE062076B for ; Sat, 30 May 2020 22:00:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bBMnXoV6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729382AbgE3WAT (ORCPT ); Sat, 30 May 2020 18:00:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728741AbgE3WAR (ORCPT ); Sat, 30 May 2020 18:00:17 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F351C03E969 for ; Sat, 30 May 2020 15:00:17 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id n5so7646796wmd.0 for ; Sat, 30 May 2020 15:00:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=crG4E3kuy2W2YxYv21NV8BPelIbycfVrq+mYiF0r58w=; b=bBMnXoV6RvCWShsWlYmuBJ/UUCMJh++fwfIPV7Zaleure8uEvpQu67u95Vf80ivSpS ZjZGMmuKAZzzHgS0ZVXO5P0+4zF/d+KmGylNl7NM+LO3KeEfFSIS//DKAGClUgUjCrkm HRaeN7HbyXvfVbfMjTBAHvyv9m6l6b5SI+CO0khbzrgh0bbwO0zab4wY9oY76S0k6UjO +uwf3oNifHi6hCDlMqRK6h8j8EINDVtXuYqOwwovfkh+a7nPJ0jAPpbn4JENlnGVecoL lGbfLAB2pwlbtqpuhbLuBSoVOl1Y5ZX/lxdyELjhitmfqoZm1h9E73ylP0fBRxSBc/7B xafA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=crG4E3kuy2W2YxYv21NV8BPelIbycfVrq+mYiF0r58w=; b=IOfamQvSo2l7NWiLyDHc4TkCaxS5e6agmeGRcOH95uGLfvu2vKKvUNTl72tdSlTft6 VvjskUPgUf4kISmDEFL0aiGrXd7u8wgzL8H1q18nx1vBQrGtAHvGfkHT5GAElaMnRYSd 33WzT3snFrlZaKUXwl3z5y7DwUT6G+ZtfjAdFRJNSkrdvJpSeuDuyKRx2xDZoLhc1ZNZ UM71ST0dICukOCpa/PasrbC3dX+LtN8CN8SY4xyEewxLVIlztMb5Pq4D0qX3JmvAOLdw 2XRvIKLnWN/ZPQO5/k7nNQJnwZ8ExM1Ip8otYstQ32viJkrK1mmmLKxYsRwQtkD6axk4 Yokw== X-Gm-Message-State: AOAM532nxoy2liLz4cX324UGZD8Yq+Rs45sHjgJqQDbNbMw6wnUFMlEs 2236G2eNsFhbxPFLVf/I0PDqThIt X-Google-Smtp-Source: ABdhPJz36E2/K2avV+W0jIj9jxujyFl2a3Y+wGWdGGEy9LCQ2uTOf3A1+TUB50OkFLTMLFH1Biwn5w== X-Received: by 2002:a1c:22d7:: with SMTP id i206mr14414930wmi.186.1590876015861; Sat, 30 May 2020 15:00:15 -0700 (PDT) Received: from ?IPv6:2003:ea:8f23:5700:8c73:80e5:b6ba:d8b0? (p200300ea8f2357008c7380e5b6bad8b0.dip0.t-ipconnect.de. [2003:ea:8f23:5700:8c73:80e5:b6ba:d8b0]) by smtp.googlemail.com with ESMTPSA id l204sm5920092wmf.19.2020.05.30.15.00.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 30 May 2020 15:00:15 -0700 (PDT) Subject: [PATCH net-next 2/6] r8169: enable WAKE_PHY as only WoL source when runtime-suspending From: Heiner Kallweit To: Realtek linux nic maintainers , David Miller , Jakub Kicinski Cc: "netdev@vger.kernel.org" References: <443c14ac-24b8-58ba-05aa-3803f1e5f4ab@gmail.com> Message-ID: <770d03ee-a3df-3be5-ff42-811d54055f30@gmail.com> Date: Sat, 30 May 2020 23:55:30 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.8.1 MIME-Version: 1.0 In-Reply-To: <443c14ac-24b8-58ba-05aa-3803f1e5f4ab@gmail.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We go to runtime-suspend few secs after cable removal. As cable is removed "physical link up" is the only meaningful WoL source. Signed-off-by: Heiner Kallweit --- drivers/net/ethernet/realtek/r8169_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index 810398ef7..6fcd35ac8 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -4884,7 +4884,7 @@ static int rtl8169_runtime_suspend(struct device *device) return 0; rtl_lock_work(tp); - __rtl8169_set_wol(tp, WAKE_ANY); + __rtl8169_set_wol(tp, WAKE_PHY); rtl_unlock_work(tp); rtl8169_net_suspend(tp); From patchwork Sat May 30 21:57:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 218116 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 873D7C433E0 for ; Sat, 30 May 2020 22:00:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5F2F820776 for ; Sat, 30 May 2020 22:00:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WpGwjJXJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729397AbgE3WAX (ORCPT ); Sat, 30 May 2020 18:00:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729361AbgE3WAV (ORCPT ); Sat, 30 May 2020 18:00:21 -0400 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FAF9C03E969 for ; Sat, 30 May 2020 15:00:21 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id h5so1747942wrc.7 for ; Sat, 30 May 2020 15:00:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=ieWtCakj/v4SpzQWaaN0FVFlpC/V1OHkYE8bfoCFu/U=; b=WpGwjJXJv/cuY/qJ9ajoLy8xmOgYCScoTyIG7Zqo2PUcWZHSyu9xt4BCXvu7bSU/Cv 1ZOtvDwLwy10PE1gwt81ycvBmwFYxJBt+34c6elOR/qxl5qobod5Z+i+PqhRm8vK1F+k Skj9ZB5ygrjM+HqhbPz2vAiIt8H8yssmbCpJOHHEapuaNE94i+jlY/rcYtyj3/IGaV8+ 9A5/dS24CGY/pEFGhzpufYLVctQ13ku9lToB6Xj1X3avuCDdl9S8y+tL5FX4f/EB/3Lq cfbUMAp5NX4R9fmKAbuVBmlV0C27/a9D7iZCetU55A6PTmiRspXzoCw06l9oo1YHzQyn s1gQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=ieWtCakj/v4SpzQWaaN0FVFlpC/V1OHkYE8bfoCFu/U=; b=sM94dmoiiinMFlyos7QXI9vx5Vv5DzaRp2t3bcjkdD3aBLM9C8wl+wUd0fTF2lWW8X PZJj+3+Sl5x1zwE5k/Jx17K9TvLUbOBhOlOTfMLl/u/jGG8cZbfSYcepJvrgM6qLhnWb TgWqtT45aTB4UJWdDi0/wo+ExJYP2L0+UwmBdEjyYvLAw58/c97LFNHZmmFiiP+wNdV0 LeyF8IhofigbEg5s0lwd9Gc0OktI0ozK/SyMwdn2u3/jk++puiwELGyybxJlgI76BwEQ 1fLpiVuNyJK5HyGbOCvP1FJ/Yhdtk5VHu3OYQMPNddb6c+TaxMmOgrcTqkNo3O5FXfXb 5w+Q== X-Gm-Message-State: AOAM530Qd5DXZwqRzm5D2VYH7ElaGfIECVg8OtulUBfnPYbh7m+/2s9z vuTgurfB4/l7c5N+p7wgaqSxPv2h X-Google-Smtp-Source: ABdhPJyktxnht8cwjbHMZh5l69dSK1n62Wh2MLofbBNc0QeIEjRP41C6xlCDPEDUGHGp3dXQeCJd5Q== X-Received: by 2002:adf:e744:: with SMTP id c4mr16032350wrn.71.1590876019820; Sat, 30 May 2020 15:00:19 -0700 (PDT) Received: from ?IPv6:2003:ea:8f23:5700:8c73:80e5:b6ba:d8b0? (p200300ea8f2357008c7380e5b6bad8b0.dip0.t-ipconnect.de. [2003:ea:8f23:5700:8c73:80e5:b6ba:d8b0]) by smtp.googlemail.com with ESMTPSA id j5sm15200684wrm.57.2020.05.30.15.00.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 30 May 2020 15:00:19 -0700 (PDT) Subject: [PATCH net-next 4/6] r8169: move some calls to rtl8169_hw_reset From: Heiner Kallweit To: Realtek linux nic maintainers , David Miller , Jakub Kicinski Cc: "netdev@vger.kernel.org" References: <443c14ac-24b8-58ba-05aa-3803f1e5f4ab@gmail.com> Message-ID: Date: Sat, 30 May 2020 23:57:10 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.8.1 MIME-Version: 1.0 In-Reply-To: <443c14ac-24b8-58ba-05aa-3803f1e5f4ab@gmail.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Move calls that are needed before and after calling rtl8169_hw_reset() into this function. This requires to move the function in the code. Signed-off-by: Heiner Kallweit --- drivers/net/ethernet/realtek/r8169_main.c | 75 +++++++++++------------ 1 file changed, 36 insertions(+), 39 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index 43652c450..5f3c50fb0 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -2530,36 +2530,6 @@ static void rtl_enable_rxdvgate(struct rtl8169_private *tp) rtl_wait_txrx_fifo_empty(tp); } -static void rtl8169_hw_reset(struct rtl8169_private *tp) -{ - /* Disable interrupts */ - rtl8169_irq_mask_and_ack(tp); - - rtl_rx_close(tp); - - switch (tp->mac_version) { - case RTL_GIGA_MAC_VER_27: - case RTL_GIGA_MAC_VER_28: - case RTL_GIGA_MAC_VER_31: - rtl_loop_wait_low(tp, &rtl_npq_cond, 20, 2000); - break; - case RTL_GIGA_MAC_VER_34 ... RTL_GIGA_MAC_VER_38: - RTL_W8(tp, ChipCmd, RTL_R8(tp, ChipCmd) | StopReq); - rtl_loop_wait_high(tp, &rtl_txcfg_empty_cond, 100, 666); - break; - case RTL_GIGA_MAC_VER_40 ... RTL_GIGA_MAC_VER_61: - rtl_enable_rxdvgate(tp); - fsleep(2000); - break; - default: - RTL_W8(tp, ChipCmd, RTL_R8(tp, ChipCmd) | StopReq); - udelay(100); - break; - } - - rtl_hw_reset(tp); -} - static void rtl_set_tx_config_registers(struct rtl8169_private *tp) { u32 val = TX_DMA_BURST << TxDMAShift | @@ -3958,6 +3928,42 @@ static void rtl8169_tx_clear(struct rtl8169_private *tp) netdev_reset_queue(tp->dev); } +static void rtl8169_hw_reset(struct rtl8169_private *tp) +{ + /* Give a racing hard_start_xmit a few cycles to complete. */ + synchronize_rcu(); + + /* Disable interrupts */ + rtl8169_irq_mask_and_ack(tp); + + rtl_rx_close(tp); + + switch (tp->mac_version) { + case RTL_GIGA_MAC_VER_27: + case RTL_GIGA_MAC_VER_28: + case RTL_GIGA_MAC_VER_31: + rtl_loop_wait_low(tp, &rtl_npq_cond, 20, 2000); + break; + case RTL_GIGA_MAC_VER_34 ... RTL_GIGA_MAC_VER_38: + RTL_W8(tp, ChipCmd, RTL_R8(tp, ChipCmd) | StopReq); + rtl_loop_wait_high(tp, &rtl_txcfg_empty_cond, 100, 666); + break; + case RTL_GIGA_MAC_VER_40 ... RTL_GIGA_MAC_VER_61: + rtl_enable_rxdvgate(tp); + fsleep(2000); + break; + default: + RTL_W8(tp, ChipCmd, RTL_R8(tp, ChipCmd) | StopReq); + fsleep(100); + break; + } + + rtl_hw_reset(tp); + + rtl8169_tx_clear(tp); + rtl8169_init_ring_indexes(tp); +} + static void rtl_reset_work(struct rtl8169_private *tp) { struct net_device *dev = tp->dev; @@ -3965,16 +3971,12 @@ static void rtl_reset_work(struct rtl8169_private *tp) napi_disable(&tp->napi); netif_stop_queue(dev); - synchronize_rcu(); rtl8169_hw_reset(tp); for (i = 0; i < NUM_RX_DESC; i++) rtl8169_mark_to_asic(tp->RxDescArray + i); - rtl8169_tx_clear(tp); - rtl8169_init_ring_indexes(tp); - napi_enable(&tp->napi); rtl_hw_start(tp); netif_wake_queue(dev); @@ -4636,11 +4638,6 @@ static void rtl8169_down(struct net_device *dev) rtl8169_hw_reset(tp); - /* Give a racing hard_start_xmit a few cycles to complete. */ - synchronize_rcu(); - - rtl8169_tx_clear(tp); - rtl8169_rx_clear(tp); rtl_pll_power_down(tp); From patchwork Sat May 30 21:58:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 218115 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B71CCC433E0 for ; Sat, 30 May 2020 22:00:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 90FCA2076B for ; Sat, 30 May 2020 22:00:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VaIHU7wk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729414AbgE3WA0 (ORCPT ); Sat, 30 May 2020 18:00:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729394AbgE3WAW (ORCPT ); Sat, 30 May 2020 18:00:22 -0400 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61F6BC03E969 for ; Sat, 30 May 2020 15:00:22 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id j10so7655561wrw.8 for ; Sat, 30 May 2020 15:00:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=HVsMpGoGIHGR133lf3XM6reFNWpHA57wOr0SnKR8xrs=; b=VaIHU7wkiGFwl9KR7hjnFcuJ4jo8Q9XKGokgwiHIxJ5qBgn6Bx4/2f7fYbG8CO1T0n ex1SlE9KXFSK4SMMnlqlkpqM+pFPt+LyLyeWmm/TMWNZkBrzBm7iCtwYiimjocvOmu/x cNWx8LR6OJednJgVKbPe3VVXUsm+Z5VYnFiByFO5CfqDvuCSLxVdp8cuqJXAHZfjAtCm olCEKp/zh+AzOElG/8JJ/VySSuFKlTKJBQZ3UmhihgQh/lVkPwSGTYyEKsl5KopmTvST shUfRo1qP3OyULMCa3gQG9tTYEVTWDBqV/ysRhl3z4YVoo2ZvaRdmYvtavqXZi7cNIjN Wv/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=HVsMpGoGIHGR133lf3XM6reFNWpHA57wOr0SnKR8xrs=; b=Us8NtVqv301kZ8A+nEQ0XOkwt8OAGNf5k9Vv/zu1QM5Ewls0nHKtX+kP0eFXppBNn1 eLmSY+7cify2uQVwUkLH5KXABvdW5UQbPrE17Tl9DifjkSQUdB/ZKADF8bSbzo+uvUx4 aujDSjQ6tQkujeYtI1PeRXPOCsozs68HEsjyenLfgHwrTGwfXWmTAd1mI4NkmZCR+ufd t8dQ6cEAvCy1Nx5blUjhEwUY4Lls4kchxnYH9UimRne63EXy6aPx7Aojz0wBDAjB1Xj4 MF8Kp+9VzF1YqZYKWAi/bUaHl14DdUQ0danCbqTpwpqlqAzSBUfoDrCAWTOPlQIQWoIb 2zXQ== X-Gm-Message-State: AOAM532mMLYHIzMKU1t9XAm704o577+zjCUvmjB+8vh+jhRQTMLNa0vL ayJAzwXmptETEx5XTv3Rx34gYc3e X-Google-Smtp-Source: ABdhPJxqsbBE5XNAXTY83kKVn8H3wsqGL48x/Bjvip664l4jwH8fYKAy4Wm4xb7zHZLa6RS6Xy5gow== X-Received: by 2002:adf:ed01:: with SMTP id a1mr16109763wro.271.1590876020826; Sat, 30 May 2020 15:00:20 -0700 (PDT) Received: from ?IPv6:2003:ea:8f23:5700:8c73:80e5:b6ba:d8b0? (p200300ea8f2357008c7380e5b6bad8b0.dip0.t-ipconnect.de. [2003:ea:8f23:5700:8c73:80e5:b6ba:d8b0]) by smtp.googlemail.com with ESMTPSA id o15sm5561161wmm.31.2020.05.30.15.00.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 30 May 2020 15:00:20 -0700 (PDT) Subject: [PATCH net-next 5/6] r8169: make rtl8169_down central chip quiesce function From: Heiner Kallweit To: Realtek linux nic maintainers , David Miller , Jakub Kicinski Cc: "netdev@vger.kernel.org" References: <443c14ac-24b8-58ba-05aa-3803f1e5f4ab@gmail.com> Message-ID: <9acbefbd-1542-c1b5-14ae-8a98eb5d8390@gmail.com> Date: Sat, 30 May 2020 23:58:35 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.8.1 MIME-Version: 1.0 In-Reply-To: <443c14ac-24b8-58ba-05aa-3803f1e5f4ab@gmail.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Functionality for quiescing the chip is spread across different functions currently. Move it to rtl8169_down(). Signed-off-by: Heiner Kallweit --- drivers/net/ethernet/realtek/r8169_main.c | 33 ++++++++--------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index 5f3c50fb0..fd93377f9 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -4627,20 +4627,21 @@ static int r8169_phy_connect(struct rtl8169_private *tp) return 0; } -static void rtl8169_down(struct net_device *dev) +static void rtl8169_down(struct rtl8169_private *tp) { - struct rtl8169_private *tp = netdev_priv(dev); + rtl_lock_work(tp); - phy_stop(tp->phydev); + /* Clear all task flags */ + bitmap_zero(tp->wk.flags, RTL_FLAG_MAX); + phy_stop(tp->phydev); napi_disable(&tp->napi); - netif_stop_queue(dev); rtl8169_hw_reset(tp); - rtl8169_rx_clear(tp); - rtl_pll_power_down(tp); + + rtl_unlock_work(tp); } static int rtl8169_close(struct net_device *dev) @@ -4653,12 +4654,9 @@ static int rtl8169_close(struct net_device *dev) /* Update counters before going down */ rtl8169_update_counters(tp); - rtl_lock_work(tp); - /* Clear all task flags */ - bitmap_zero(tp->wk.flags, RTL_FLAG_MAX); - - rtl8169_down(dev); - rtl_unlock_work(tp); + netif_stop_queue(dev); + rtl8169_down(tp); + rtl8169_rx_clear(tp); cancel_work_sync(&tp->wk.work); @@ -4817,17 +4815,8 @@ static void rtl8169_net_suspend(struct rtl8169_private *tp) if (!netif_running(tp->dev)) return; - phy_stop(tp->phydev); netif_device_detach(tp->dev); - - rtl_lock_work(tp); - napi_disable(&tp->napi); - /* Clear all task flags */ - bitmap_zero(tp->wk.flags, RTL_FLAG_MAX); - - rtl_unlock_work(tp); - - rtl_pll_power_down(tp); + rtl8169_down(tp); } #ifdef CONFIG_PM