From patchwork Mon Mar 6 21:23:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 13162358 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53F8BC61DA4 for ; Mon, 6 Mar 2023 21:28:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229545AbjCFV2o (ORCPT ); Mon, 6 Mar 2023 16:28:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229516AbjCFV2k (ORCPT ); Mon, 6 Mar 2023 16:28:40 -0500 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E372B72B36 for ; Mon, 6 Mar 2023 13:28:27 -0800 (PST) Received: by mail-wm1-x329.google.com with SMTP id p26so6543820wmc.4 for ; Mon, 06 Mar 2023 13:28:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678138106; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=syuaSwBNSDtPzsrmU5QAcX/q0F5xd0RoyEs1wJVN19I=; b=l3ljv8LVJIsbcjybxj4jhOtUQW0rCrM41r7irMGigWOOWipeWEpzS8mfCWGRrpueNB oiZFJJpGhowLmcnTqjJ8ekbHiEsANAl3OY6+cBo/RROwPdOsV6sNpgJJzdhdzUS1rUkX DCb4krEug3KRYbRQpAY/isXNEeeERjGztB8N2g6Z/009/vTWfDApwsNyUXYwrqWGSBxW U2AL4idiH75ly9WjqCTEHdzB4VK+G9pIBFq1e8ep6OUnXLvltv0537U0fnUzgUmdqoB2 kSBj3PuQ1ghgcAq4JlIp5lzYz0NTxrbi9K3WDcZrixC8Ek4sTFAQm1/GPNMK+S46Bevw 5GbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678138106; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=syuaSwBNSDtPzsrmU5QAcX/q0F5xd0RoyEs1wJVN19I=; b=hl9i6ww1yNjnM/VgT+2AEwTRJRVzhKKR312tzktW9xW43+tMO4reLyPah61dnVHFSt DfOKnnybrhRINpJKMCFF5AOHeyUb3aH/jXmJz/8z48dQredYnxkXneNqX7VW/wyBtwrD ORQp1+KmZNjGL+4vv/l4zk13B1VTcp2S2vZ76YZhtxm95KGMCrOF1MLmBYBt87BR2Ci3 NxTqz0XNZh40Q6Pt7NQehcMX3fYBTRYh84bMkIS+dZvwRyEj7X/2ubsX2OTJUqh2Ffoh MaozrV0hHo3j+U6RWGFyrhvN2SvVzusab9PI0RhRnrI7lMBLoiYAifImNqBZfElj0r6J iM6A== X-Gm-Message-State: AO0yUKWAZinul903eYe+O8WxqWmuwevrTQ1qfDb/a1tt5fY2RRQMsSbC R+eOnyH6hUAvuK9qfJnVFvE= X-Google-Smtp-Source: AK7set/elRBVLhjzkqYuKd4zUUDmluA3xzjacCLiogAoT09TimIRbA4aUiweHdeqxZz+4cqPpVbbiA== X-Received: by 2002:a05:600c:3587:b0:3ea:e7f6:f8fa with SMTP id p7-20020a05600c358700b003eae7f6f8famr10786364wmq.10.1678138105984; Mon, 06 Mar 2023 13:28:25 -0800 (PST) Received: from ?IPV6:2a01:c22:7bf4:7d00:9590:4142:18ea:aa32? (dynamic-2a01-0c22-7bf4-7d00-9590-4142-18ea-aa32.c22.pool.telefonica.de. [2a01:c22:7bf4:7d00:9590:4142:18ea:aa32]) by smtp.googlemail.com with ESMTPSA id h22-20020a05600c351600b003daf6e3bc2fsm22119584wmq.1.2023.03.06.13.28.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 06 Mar 2023 13:28:25 -0800 (PST) Message-ID: Date: Mon, 6 Mar 2023 22:23:15 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: [PATCH net-next 1/6] r8169: use spinlock to protect mac ocp register access Content-Language: en-US From: Heiner Kallweit To: Paolo Abeni , Jakub Kicinski , David Miller , Eric Dumazet , Realtek linux nic maintainers Cc: "netdev@vger.kernel.org" , Simon Horman , Kai-Heng Feng , =?utf-8?q?Holger_Hoffst=C3=A4t?= =?utf-8?q?te?= References: In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org For disabling ASPM during NAPI poll we'll have to access mac ocp registers in atomic context. This could result in races because a mac ocp read consists of a write to register OCPDR, followed by a read from the same register. Therefore add a spinlock to protect access to mac ocp registers. Reviewed-by: Simon Horman Tested-by: Kai-Heng Feng Tested-by: Holger Hoffstätte Signed-off-by: Heiner Kallweit --- drivers/net/ethernet/realtek/r8169_main.c | 37 ++++++++++++++++++++--- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index 45147a101..259eac5b0 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -613,6 +613,8 @@ struct rtl8169_private { struct work_struct work; } wk; + spinlock_t mac_ocp_lock; + unsigned supports_gmii:1; unsigned aspm_manageable:1; dma_addr_t counters_phys_addr; @@ -847,7 +849,7 @@ static int r8168_phy_ocp_read(struct rtl8169_private *tp, u32 reg) (RTL_R32(tp, GPHY_OCP) & 0xffff) : -ETIMEDOUT; } -static void r8168_mac_ocp_write(struct rtl8169_private *tp, u32 reg, u32 data) +static void __r8168_mac_ocp_write(struct rtl8169_private *tp, u32 reg, u32 data) { if (rtl_ocp_reg_failure(reg)) return; @@ -855,7 +857,16 @@ static void r8168_mac_ocp_write(struct rtl8169_private *tp, u32 reg, u32 data) RTL_W32(tp, OCPDR, OCPAR_FLAG | (reg << 15) | data); } -static u16 r8168_mac_ocp_read(struct rtl8169_private *tp, u32 reg) +static void r8168_mac_ocp_write(struct rtl8169_private *tp, u32 reg, u32 data) +{ + unsigned long flags; + + spin_lock_irqsave(&tp->mac_ocp_lock, flags); + __r8168_mac_ocp_write(tp, reg, data); + spin_unlock_irqrestore(&tp->mac_ocp_lock, flags); +} + +static u16 __r8168_mac_ocp_read(struct rtl8169_private *tp, u32 reg) { if (rtl_ocp_reg_failure(reg)) return 0; @@ -865,12 +876,28 @@ static u16 r8168_mac_ocp_read(struct rtl8169_private *tp, u32 reg) return RTL_R32(tp, OCPDR); } +static u16 r8168_mac_ocp_read(struct rtl8169_private *tp, u32 reg) +{ + unsigned long flags; + u16 val; + + spin_lock_irqsave(&tp->mac_ocp_lock, flags); + val = __r8168_mac_ocp_read(tp, reg); + spin_unlock_irqrestore(&tp->mac_ocp_lock, flags); + + return val; +} + static void r8168_mac_ocp_modify(struct rtl8169_private *tp, u32 reg, u16 mask, u16 set) { - u16 data = r8168_mac_ocp_read(tp, reg); + unsigned long flags; + u16 data; - r8168_mac_ocp_write(tp, reg, (data & ~mask) | set); + spin_lock_irqsave(&tp->mac_ocp_lock, flags); + data = __r8168_mac_ocp_read(tp, reg); + __r8168_mac_ocp_write(tp, reg, (data & ~mask) | set); + spin_unlock_irqrestore(&tp->mac_ocp_lock, flags); } /* Work around a hw issue with RTL8168g PHY, the quirk disables @@ -5176,6 +5203,8 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) tp->eee_adv = -1; tp->ocp_base = OCP_STD_PHY_BASE; + spin_lock_init(&tp->mac_ocp_lock); + dev->tstats = devm_netdev_alloc_pcpu_stats(&pdev->dev, struct pcpu_sw_netstats); if (!dev->tstats) From patchwork Mon Mar 6 21:24:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 13162359 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF8E9C61DA4 for ; Mon, 6 Mar 2023 21:28:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229998AbjCFV2s (ORCPT ); Mon, 6 Mar 2023 16:28:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229516AbjCFV2o (ORCPT ); Mon, 6 Mar 2023 16:28:44 -0500 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16FE265115 for ; Mon, 6 Mar 2023 13:28:28 -0800 (PST) Received: by mail-wr1-x434.google.com with SMTP id f11so10254400wrv.8 for ; Mon, 06 Mar 2023 13:28:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678138107; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=joa9HNCqYKgTx0nZc2iaq9jq6ADI6g6RY46WWp+EnV8=; b=eTmNNE3VmZ1yJSCu2xm6EgrqRdpejjTBZu44enKMRHM0QL5iRB4xQfpCPxVXx+r5Wk qBFZ1ScWr8W5ZOUR2BXXR/dYVkUBd2hAXDzewbwjV2Y3fA+7JCDvcoxjTeacYFQnOR4N eL28S/ml4JMQhRPYWP5wF0Hgg6EMk0wayV/AoCUrtxbhkuuSmt09LlfIQHV+wOOKKwGt wHWF8SsXA9Y5HansVcJkBZBkrTWqO4z52lN4Uc7uPIpVYlMQ0rwZ8GbdD2JpyXX7fwO/ BF5cuYUwAKDJeBpJY1h04INSzh7Y1UTXd26FAg1T0ZjygDME8/t2U5mJ8/8Xrt13nOYr VavA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678138107; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=joa9HNCqYKgTx0nZc2iaq9jq6ADI6g6RY46WWp+EnV8=; b=gyuMn+F60gkPSvs4npfi6dJw7xCdHaPF9Q0v2a+x+9Qgmp8LOis5KY5dYHvmHtDw+U wD3w/GPW5HGd92njGOgrVbhvuJturrqTvCzxoWvtsUg+F/Wk9QwTq5Wf6ppHYd/doII+ PcTYoa58fUbc0QnVmjOop4X3MoY//MvdfcEyR8qYc65v64Jl8LLxHRth4qkLH64gkQCk CG1Zxqqzl9GwbZR2/RPAQOAhDD6rQspUgEoJD/rB5pffkLg+6OdGZogazxF4Gfh/y0jC qRLOhUP2tAvJHDCZO5qf3l41jQRHZjbENLJYfGoIs1NRpMvaPKlbH94rJfivT9ZoICsI 5uJA== X-Gm-Message-State: AO0yUKWUCJwMpSkpOWja7QAgEPse9cYW2cohLthvrIWXHNsemoHQGUA0 V0CKHZSTOMGHWeGeLwx3nGw= X-Google-Smtp-Source: AK7set9q5N2+OhmjdHC+btkww6POMxBiyzOWXYY4kTKZ4xN0/PZwob7WASeSF2TGFuUfzLsmDBP5Bg== X-Received: by 2002:a5d:63c9:0:b0:2c3:d707:7339 with SMTP id c9-20020a5d63c9000000b002c3d7077339mr10915320wrw.6.1678138107121; Mon, 06 Mar 2023 13:28:27 -0800 (PST) Received: from ?IPV6:2a01:c22:7bf4:7d00:9590:4142:18ea:aa32? (dynamic-2a01-0c22-7bf4-7d00-9590-4142-18ea-aa32.c22.pool.telefonica.de. [2a01:c22:7bf4:7d00:9590:4142:18ea:aa32]) by smtp.googlemail.com with ESMTPSA id u12-20020a05600c00cc00b003e1202744f2sm14650409wmm.31.2023.03.06.13.28.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 06 Mar 2023 13:28:26 -0800 (PST) Message-ID: Date: Mon, 6 Mar 2023 22:24:00 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: [PATCH net-next 2/6] r8169: use spinlock to protect access to registers Config2 and Config5 Content-Language: en-US From: Heiner Kallweit To: Paolo Abeni , Jakub Kicinski , David Miller , Eric Dumazet , Realtek linux nic maintainers Cc: "netdev@vger.kernel.org" , Simon Horman , Kai-Heng Feng , =?utf-8?q?Holger_Hoffst=C3=A4t?= =?utf-8?q?te?= References: In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org For disabling ASPM during NAPI poll we'll have to access both registers in atomic context. Use a spinlock to protect access. Reviewed-by: Simon Horman Tested-by: Kai-Heng Feng Tested-by: Holger Hoffstätte Signed-off-by: Heiner Kallweit --- drivers/net/ethernet/realtek/r8169_main.c | 47 ++++++++++++++++++----- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index 259eac5b0..e6f3f1947 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -613,6 +613,7 @@ struct rtl8169_private { struct work_struct work; } wk; + spinlock_t config25_lock; spinlock_t mac_ocp_lock; unsigned supports_gmii:1; @@ -677,6 +678,28 @@ static void rtl_pci_commit(struct rtl8169_private *tp) RTL_R8(tp, ChipCmd); } +static void rtl_mod_config2(struct rtl8169_private *tp, u8 clear, u8 set) +{ + unsigned long flags; + u8 val; + + spin_lock_irqsave(&tp->config25_lock, flags); + val = RTL_R8(tp, Config2); + RTL_W8(tp, Config2, (val & ~clear) | set); + spin_unlock_irqrestore(&tp->config25_lock, flags); +} + +static void rtl_mod_config5(struct rtl8169_private *tp, u8 clear, u8 set) +{ + unsigned long flags; + u8 val; + + spin_lock_irqsave(&tp->config25_lock, flags); + val = RTL_R8(tp, Config5); + RTL_W8(tp, Config5, (val & ~clear) | set); + spin_unlock_irqrestore(&tp->config25_lock, flags); +} + static bool rtl_is_8125(struct rtl8169_private *tp) { return tp->mac_version >= RTL_GIGA_MAC_VER_61; @@ -1363,6 +1386,7 @@ static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts) { WAKE_MAGIC, Config3, MagicPacket } }; unsigned int i, tmp = ARRAY_SIZE(cfg); + unsigned long flags; u8 options; rtl_unlock_config_regs(tp); @@ -1381,12 +1405,14 @@ static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts) r8168_mac_ocp_modify(tp, 0xc0b6, BIT(0), 0); } + spin_lock_irqsave(&tp->config25_lock, flags); for (i = 0; i < tmp; i++) { options = RTL_R8(tp, cfg[i].reg) & ~cfg[i].mask; if (wolopts & cfg[i].opt) options |= cfg[i].mask; RTL_W8(tp, cfg[i].reg, options); } + spin_unlock_irqrestore(&tp->config25_lock, flags); switch (tp->mac_version) { case RTL_GIGA_MAC_VER_02 ... RTL_GIGA_MAC_VER_06: @@ -1398,10 +1424,10 @@ static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts) case RTL_GIGA_MAC_VER_34: case RTL_GIGA_MAC_VER_37: case RTL_GIGA_MAC_VER_39 ... RTL_GIGA_MAC_VER_63: - options = RTL_R8(tp, Config2) & ~PME_SIGNAL; if (wolopts) - options |= PME_SIGNAL; - RTL_W8(tp, Config2, options); + rtl_mod_config2(tp, 0, PME_SIGNAL); + else + rtl_mod_config2(tp, PME_SIGNAL, 0); break; default: break; @@ -2704,8 +2730,8 @@ static void rtl_hw_aspm_clkreq_enable(struct rtl8169_private *tp, bool enable) { /* Don't enable ASPM in the chip if OS can't control ASPM */ if (enable && tp->aspm_manageable) { - RTL_W8(tp, Config5, RTL_R8(tp, Config5) | ASPM_en); - RTL_W8(tp, Config2, RTL_R8(tp, Config2) | ClkReqEn); + rtl_mod_config5(tp, 0, ASPM_en); + rtl_mod_config2(tp, 0, ClkReqEn); switch (tp->mac_version) { case RTL_GIGA_MAC_VER_46 ... RTL_GIGA_MAC_VER_48: @@ -2728,8 +2754,8 @@ static void rtl_hw_aspm_clkreq_enable(struct rtl8169_private *tp, bool enable) break; } - RTL_W8(tp, Config2, RTL_R8(tp, Config2) & ~ClkReqEn); - RTL_W8(tp, Config5, RTL_R8(tp, Config5) & ~ASPM_en); + rtl_mod_config2(tp, ClkReqEn, 0); + rtl_mod_config5(tp, ASPM_en, 0); } udelay(10); @@ -2890,7 +2916,7 @@ static void rtl_hw_start_8168e_1(struct rtl8169_private *tp) RTL_W32(tp, MISC, RTL_R32(tp, MISC) | TXPLA_RST); RTL_W32(tp, MISC, RTL_R32(tp, MISC) & ~TXPLA_RST); - RTL_W8(tp, Config5, RTL_R8(tp, Config5) & ~Spi_en); + rtl_mod_config5(tp, Spi_en, 0); } static void rtl_hw_start_8168e_2(struct rtl8169_private *tp) @@ -2923,7 +2949,7 @@ static void rtl_hw_start_8168e_2(struct rtl8169_private *tp) RTL_W8(tp, DLLPR, RTL_R8(tp, DLLPR) | PFM_EN); RTL_W32(tp, MISC, RTL_R32(tp, MISC) | PWM_EN); - RTL_W8(tp, Config5, RTL_R8(tp, Config5) & ~Spi_en); + rtl_mod_config5(tp, Spi_en, 0); rtl_hw_aspm_clkreq_enable(tp, true); } @@ -2946,7 +2972,7 @@ static void rtl_hw_start_8168f(struct rtl8169_private *tp) RTL_W8(tp, MCU, RTL_R8(tp, MCU) & ~NOW_IS_OOB); RTL_W8(tp, DLLPR, RTL_R8(tp, DLLPR) | PFM_EN); RTL_W32(tp, MISC, RTL_R32(tp, MISC) | PWM_EN); - RTL_W8(tp, Config5, RTL_R8(tp, Config5) & ~Spi_en); + rtl_mod_config5(tp, Spi_en, 0); rtl8168_config_eee_mac(tp); } @@ -5203,6 +5229,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) tp->eee_adv = -1; tp->ocp_base = OCP_STD_PHY_BASE; + spin_lock_init(&tp->config25_lock); spin_lock_init(&tp->mac_ocp_lock); dev->tstats = devm_netdev_alloc_pcpu_stats(&pdev->dev, From patchwork Mon Mar 6 21:24:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 13162360 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4062BC6FD1A for ; Mon, 6 Mar 2023 21:28:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229993AbjCFV2x (ORCPT ); Mon, 6 Mar 2023 16:28:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229990AbjCFV2r (ORCPT ); Mon, 6 Mar 2023 16:28:47 -0500 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09C3D30B32 for ; Mon, 6 Mar 2023 13:28:30 -0800 (PST) Received: by mail-wm1-x336.google.com with SMTP id k37so6595655wms.0 for ; Mon, 06 Mar 2023 13:28:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678138108; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=b9AKknuKKfnLxpDQvjO1K47KXCz0le2zEbS5FuxPY2A=; b=C5OzqlUgqv2DYspkOOUUgJXftI5Ro63jg7RnsuYxFQStKIjlOo4ALUanm/tW+kgvKE 2av1ewkhJt8GtoZlpkmAuQZbFtGK+0nj5gqde/v53id89de42zvsd1smvewd0FkYGKB/ S9XJrSOuE2G2V2ji3INNxsOnnmr0cGZK65yOjahZ6NW2CZ1cmoiq9eS9WzBG498gWvwF JnvOXwTOEbiHmEEK2Ze1CWTkY6adhh90H1qdDR6F64P9foJlVf8YxQiinljHrpCnJOoX HjNWl/qWoGFYh+8SqPMABAwCNigAXO7+7irrGx3LxlqOiDJPqeVkuzfBmIhAuod0QzMT HzGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678138108; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=b9AKknuKKfnLxpDQvjO1K47KXCz0le2zEbS5FuxPY2A=; b=v0a11tRmb8Qn06xxem+C/VTVUQZS7VydcvR+d4GYlhMZlXIlxuelBXvFB0Zv7zS6Aq TURuT+OP7AyplVt0Blpp5T23pizOn3vp/K14g2I76m4ez7cWpWPz0pEi52Opqnn2aO89 Ps+MlNeYgCumR7qkguR/z+jkSu/bt6RLneTxa0wEYhPV9NjbfMUEUbi67GJ/vxF2IibS iDJ6KhfE6zOknUH0uGLSGSB2WQcZBJZKW6WBBxOPPLay4WPVKQJ4x1q6hARA9P/30uhg +wdDquHl2NpF5yUSomXUbL0qOhUniV71iozO8KsGkpwLf4lgFKP7jmJHAV1+Fr3nGUb3 oFrw== X-Gm-Message-State: AO0yUKVwztCxip3M1xSslpvQORuKytY2w4Lc+z4QdbE54LSU5odVHICM RoMBnYCA4iSsxHNvIaxElUM= X-Google-Smtp-Source: AK7set/Mwv2vU/gaIWvQz8HF0nvEnK6JTdSR0PYD8L4lC1HtIhTv551LS52+TyMIe3+6YWI0zugmRw== X-Received: by 2002:a05:600c:4fd6:b0:3df:d8c5:ec18 with SMTP id o22-20020a05600c4fd600b003dfd8c5ec18mr10323478wmq.13.1678138108256; Mon, 06 Mar 2023 13:28:28 -0800 (PST) Received: from ?IPV6:2a01:c22:7bf4:7d00:9590:4142:18ea:aa32? (dynamic-2a01-0c22-7bf4-7d00-9590-4142-18ea-aa32.c22.pool.telefonica.de. [2a01:c22:7bf4:7d00:9590:4142:18ea:aa32]) by smtp.googlemail.com with ESMTPSA id o2-20020a05600c510200b003e208cec49bsm24206909wms.3.2023.03.06.13.28.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 06 Mar 2023 13:28:27 -0800 (PST) Message-ID: <15b30923-0b59-db1e-e64f-3b05b8fcbd01@gmail.com> Date: Mon, 6 Mar 2023 22:24:49 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: [PATCH net-next 3/6] r8169: enable cfg9346 config register access in atomic context Content-Language: en-US From: Heiner Kallweit To: Paolo Abeni , Jakub Kicinski , David Miller , Eric Dumazet , Realtek linux nic maintainers Cc: "netdev@vger.kernel.org" , Simon Horman , Kai-Heng Feng , =?utf-8?q?Holger_Hoffst=C3=A4t?= =?utf-8?q?te?= References: In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org For disabling ASPM during NAPI poll we'll have to unlock access to the config registers in atomic context. Other code parts running with config register access unlocked are partially longer and can sleep. Add a usage counter to enable parallel execution of code parts requiring unlocked config registers. Reviewed-by: Simon Horman Tested-by: Kai-Heng Feng Tested-by: Holger Hoffstätte Signed-off-by: Heiner Kallweit --- drivers/net/ethernet/realtek/r8169_main.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index e6f3f1947..61cbf498f 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -616,6 +616,9 @@ struct rtl8169_private { spinlock_t config25_lock; spinlock_t mac_ocp_lock; + spinlock_t cfg9346_usage_lock; + int cfg9346_usage_count; + unsigned supports_gmii:1; unsigned aspm_manageable:1; dma_addr_t counters_phys_addr; @@ -664,12 +667,22 @@ static inline struct device *tp_to_dev(struct rtl8169_private *tp) static void rtl_lock_config_regs(struct rtl8169_private *tp) { - RTL_W8(tp, Cfg9346, Cfg9346_Lock); + unsigned long flags; + + spin_lock_irqsave(&tp->cfg9346_usage_lock, flags); + if (!--tp->cfg9346_usage_count) + RTL_W8(tp, Cfg9346, Cfg9346_Lock); + spin_unlock_irqrestore(&tp->cfg9346_usage_lock, flags); } static void rtl_unlock_config_regs(struct rtl8169_private *tp) { - RTL_W8(tp, Cfg9346, Cfg9346_Unlock); + unsigned long flags; + + spin_lock_irqsave(&tp->cfg9346_usage_lock, flags); + if (!tp->cfg9346_usage_count++) + RTL_W8(tp, Cfg9346, Cfg9346_Unlock); + spin_unlock_irqrestore(&tp->cfg9346_usage_lock, flags); } static void rtl_pci_commit(struct rtl8169_private *tp) @@ -5229,6 +5242,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) tp->eee_adv = -1; tp->ocp_base = OCP_STD_PHY_BASE; + spin_lock_init(&tp->cfg9346_usage_lock); spin_lock_init(&tp->config25_lock); spin_lock_init(&tp->mac_ocp_lock); From patchwork Mon Mar 6 21:25:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 13162361 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2B24C6FD1C for ; Mon, 6 Mar 2023 21:28:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230039AbjCFV24 (ORCPT ); Mon, 6 Mar 2023 16:28:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230020AbjCFV2v (ORCPT ); Mon, 6 Mar 2023 16:28:51 -0500 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2127974A5C for ; Mon, 6 Mar 2023 13:28:31 -0800 (PST) Received: by mail-wr1-x435.google.com with SMTP id j2so10247587wrh.9 for ; Mon, 06 Mar 2023 13:28:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678138109; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=N9UWUbGKmEfF/ZCXlYPSs/b8L+hGvY0HicAyB0cfmWU=; b=BYUFh8zHKx8f5y4lhD9gTznGbsjDjKaDVNQ4WTJ7VJpfyyY3mq7Mk07SWm977U6K7I LeFmZN5Izi/UIkNPqcizimSUj5nU/FGi4xLCn6+L1dAtkqxQPB5ehVdy54KZMbshmD/B hVouzprxv5za+KoQMjVDIU1I8aws3Poy/mV2hVeScEgXE+udBwIkdRChTodSwkUcJVbD TPpdIGLU/ZNZOTAYbEpLMO4W/yfRSBvk6Tac1dSYn+ZgiKNTGO370GqTnD5H4Ftr8xqf yqHoZ/aT6Bttn3PZIazCt+DDevzNIo0Ecvcy+zeupzJ7ni9BQtqyvXJWkd4T9IDFdG22 llmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678138109; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=N9UWUbGKmEfF/ZCXlYPSs/b8L+hGvY0HicAyB0cfmWU=; b=idonVMRzcElZY/oXYqxy3zSIrsUj3IntwnhEvzllro/H1zPNMFBzZOITry+D+is7fV B/aKDNcF0qKqUSehj5cq3pRsC6kD2kDl8KQwhmfJFMgQvxHwWEubNb1TuGj595tx9y33 IqDeA0XaUHoeUj2BhoPtNKTCmc1e8xYD+uF7oVfU6pdLL/omIBof0ImxyLV59Eb1eyv7 A2JMru02owk2MAyjkZjkvCPD7OIt0gve+PAxeJi19iOryNdSS1CsWFFGUX4Wwh//IrrQ thFCs5+1RnkzI5xKWiIxyMAdABVmd/m+PEa7rOXXjWTtcGzbOlrc/69dJiq5QH0Pr1Li hllA== X-Gm-Message-State: AO0yUKVB5qz6elrDCJPDxoXHdSO4R/vIEmFtaDpzT/b4j1DGlYR176IA vwRxao/pnWWdL9figibi/1Y= X-Google-Smtp-Source: AK7set+suNpvmhZSG0PB+ahcd+KowARy5hF8e4NeYqAYUGWfMTGxGpCMyRtU+3lsVfSxQpB3rzYWeg== X-Received: by 2002:adf:e585:0:b0:2c7:1e52:c5a8 with SMTP id l5-20020adfe585000000b002c71e52c5a8mr7757910wrm.21.1678138109495; Mon, 06 Mar 2023 13:28:29 -0800 (PST) Received: from ?IPV6:2a01:c22:7bf4:7d00:9590:4142:18ea:aa32? (dynamic-2a01-0c22-7bf4-7d00-9590-4142-18ea-aa32.c22.pool.telefonica.de. [2a01:c22:7bf4:7d00:9590:4142:18ea:aa32]) by smtp.googlemail.com with ESMTPSA id c12-20020a5d63cc000000b002c5801aa9b0sm10888506wrw.40.2023.03.06.13.28.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 06 Mar 2023 13:28:29 -0800 (PST) Message-ID: Date: Mon, 6 Mar 2023 22:25:49 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: [PATCH net-next 4/6] r8169: prepare rtl_hw_aspm_clkreq_enable for usage in atomic context Content-Language: en-US From: Heiner Kallweit To: Paolo Abeni , Jakub Kicinski , David Miller , Eric Dumazet , Realtek linux nic maintainers Cc: "netdev@vger.kernel.org" , Simon Horman , Kai-Heng Feng , =?utf-8?q?Holger_Hoffst=C3=A4t?= =?utf-8?q?te?= References: In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Bail out if the function is used with chip versions that don't support ASPM configuration. In addition remove the delay, it tuned out that it's not needed, also vendor driver r8125 doesn't have it. Suggested-by: Kai-Heng Feng Reviewed-by: Simon Horman Tested-by: Kai-Heng Feng Tested-by: Holger Hoffstätte Signed-off-by: Heiner Kallweit --- drivers/net/ethernet/realtek/r8169_main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index 61cbf498f..96af31aea 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -2741,6 +2741,9 @@ static void rtl_disable_exit_l1(struct rtl8169_private *tp) static void rtl_hw_aspm_clkreq_enable(struct rtl8169_private *tp, bool enable) { + if (tp->mac_version < RTL_GIGA_MAC_VER_32) + return; + /* Don't enable ASPM in the chip if OS can't control ASPM */ if (enable && tp->aspm_manageable) { rtl_mod_config5(tp, 0, ASPM_en); @@ -2770,8 +2773,6 @@ static void rtl_hw_aspm_clkreq_enable(struct rtl8169_private *tp, bool enable) rtl_mod_config2(tp, ClkReqEn, 0); rtl_mod_config5(tp, ASPM_en, 0); } - - udelay(10); } static void rtl_set_fifo_size(struct rtl8169_private *tp, u16 rx_stat, From patchwork Mon Mar 6 21:26:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 13162362 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D5B7C6FD1E for ; Mon, 6 Mar 2023 21:28:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230034AbjCFV25 (ORCPT ); Mon, 6 Mar 2023 16:28:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230025AbjCFV2x (ORCPT ); Mon, 6 Mar 2023 16:28:53 -0500 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C58A474DA for ; Mon, 6 Mar 2023 13:28:32 -0800 (PST) Received: by mail-wm1-x32d.google.com with SMTP id fm20-20020a05600c0c1400b003ead37e6588so9139751wmb.5 for ; Mon, 06 Mar 2023 13:28:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678138111; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=soPTZuxKkPs8F671BDUXDGY7ntnppFcO4XnsaBkc22I=; b=M3Pqeo7qCHCdt2exp003r44xWg4XvxyrzpSQB9izPqkIvU7x1m1Bi1aktzUG3nv2Xz To9ukeu0kZ8yE79daSmdC1unYGnokn2/wKEY9DmvGjqAbF88dcqvqTl3141mRmpca3Lu RnUqnzkDfa4czqWNwUKLfxBw1Z1tMOeqb5WtkRFvZR3qODBOwU9Iv8AILJnug6EHFHxA 7qhGIhBMkTuohAWyPmNcqKsBY7GMYEwvj3KvdZ0Gk/YM8cAOemfkCah1Yx1xL/+YX6BG 74lPY/502PgD1CXPLy0+bqQ0g2VwmIOHmz3n5PbJo+5Fjg9z6c+8QXkBJTmkwvv6PueJ sHcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678138111; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=soPTZuxKkPs8F671BDUXDGY7ntnppFcO4XnsaBkc22I=; b=uyNO09+NPI71OgDdTHxbqlESSFyoEoTuBqgKETF0txeygwkEc+80fxZuKPEJgxcKyy dEr7aA5ZGb3bglJ8EOWiR0oNgW/v+XCsvC0p4W45CyYqDST7DAgAFCXfrAezjGC7WIAD CPSTtPDbnaKZQDMGUcT4W911m0MhJ+iiDvXYggGvT4/o3RV1KfuojJxjGv62Abum+gjf 0GvIr+xxYKQweq4UITBxA0ApnMeNeFqrC0LIt+kWwmq0P17ak4SmzHxYcbsqh4QqQ4YW ZzTcX6b09FZdMpHxYTzg3n7t5JuqYOzVA+l7f0LoK3GRjwOewdyzZHqy2iwlNofWU6Be X4zQ== X-Gm-Message-State: AO0yUKVUX08NIZUzdrFwgYH8PtBJXQxtAghRcqOUjGTo7YAxtdQ2Bd41 TT3NkbyaThVgZqVDTp4s/XfOtLZXdEc= X-Google-Smtp-Source: AK7set9tSV5ePU4+bZh11wdi5N1u2vtLUzAItzLXEQ7c2ImZRcOLir5F1qz4HYhUqa+4dwdM/8fRnQ== X-Received: by 2002:a05:600c:3ca3:b0:3db:8de:6993 with SMTP id bg35-20020a05600c3ca300b003db08de6993mr8456246wmb.4.1678138110871; Mon, 06 Mar 2023 13:28:30 -0800 (PST) Received: from ?IPV6:2a01:c22:7bf4:7d00:9590:4142:18ea:aa32? (dynamic-2a01-0c22-7bf4-7d00-9590-4142-18ea-aa32.c22.pool.telefonica.de. [2a01:c22:7bf4:7d00:9590:4142:18ea:aa32]) by smtp.googlemail.com with ESMTPSA id h22-20020a05600c351600b003daf6e3bc2fsm22119735wmq.1.2023.03.06.13.28.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 06 Mar 2023 13:28:30 -0800 (PST) Message-ID: Date: Mon, 6 Mar 2023 22:26:47 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: [PATCH net-next 5/6] r8169: disable ASPM during NAPI poll Content-Language: en-US From: Heiner Kallweit To: Paolo Abeni , Jakub Kicinski , David Miller , Eric Dumazet , Realtek linux nic maintainers Cc: "netdev@vger.kernel.org" , Simon Horman , Kai-Heng Feng , =?utf-8?q?Holger_Hoffst=C3=A4t?= =?utf-8?q?te?= References: In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Several chip versions have problems with ASPM, what may result in rx_missed errors or tx timeouts. The root cause isn't known but experience shows that disabling ASPM during NAPI poll can avoid these problems. Suggested-by: Kai-Heng Feng Reviewed-by: Simon Horman Tested-by: Kai-Heng Feng Tested-by: Holger Hoffstätte Signed-off-by: Heiner Kallweit --- drivers/net/ethernet/realtek/r8169_main.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index 96af31aea..2897b9bf2 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -4577,6 +4577,10 @@ static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance) } if (napi_schedule_prep(&tp->napi)) { + rtl_unlock_config_regs(tp); + rtl_hw_aspm_clkreq_enable(tp, false); + rtl_lock_config_regs(tp); + rtl_irq_disable(tp); __napi_schedule(&tp->napi); } @@ -4636,9 +4640,14 @@ static int rtl8169_poll(struct napi_struct *napi, int budget) work_done = rtl_rx(dev, tp, budget); - if (work_done < budget && napi_complete_done(napi, work_done)) + if (work_done < budget && napi_complete_done(napi, work_done)) { rtl_irq_enable(tp); + rtl_unlock_config_regs(tp); + rtl_hw_aspm_clkreq_enable(tp, true); + rtl_lock_config_regs(tp); + } + return work_done; } From patchwork Mon Mar 6 21:28:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 13162363 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22DCCC6FD1A for ; Mon, 6 Mar 2023 21:29:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229516AbjCFV3C (ORCPT ); Mon, 6 Mar 2023 16:29:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230006AbjCFV2y (ORCPT ); Mon, 6 Mar 2023 16:28:54 -0500 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A694E37F05 for ; Mon, 6 Mar 2023 13:28:33 -0800 (PST) Received: by mail-wm1-x336.google.com with SMTP id l7-20020a05600c1d0700b003eb5e6d906bso6025171wms.5 for ; Mon, 06 Mar 2023 13:28:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678138112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=DGfzjjoiQHuMjP01DyQVjuhjLdCZBikcH33VI7IxHdY=; b=ENPDQJSvRFgkk2v72WVohnmhBqI/M6OvGhETbv58yPG5S5bniWhe7ZQO0Rt57KVtyi +ynd7ycsF8kWebIx2/S3jTNrNJfn5Tq9S+vWyzE8mscCYRfKfrOY4a173liyFykgkSqq lAj2jfK+EdMeJ+cPYex+61s7ftI78FQ7qdpKJiL7ryDaPJXmi2jl9/at9SvibmrZuWiL Gu7HRl1yaauY7QJk13yBJiqp/X93de8mfSa8pX/OYAOlYSUkvz0daC2vcXyIRV6JaIlV c9/1Y8u/QyqVH8ecO4DkGLD5/+MUXR5S1ebYRKXmOWPOxKZtM4mW3VE0gO+MFiOAv+uO uzWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678138112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=DGfzjjoiQHuMjP01DyQVjuhjLdCZBikcH33VI7IxHdY=; b=fB7ycmF72z+teFUfXyYih1PjKskfToUgjmgVOC3GF2c89JJgsYk+UlNddZ6piTXcrd cLzW+V1QIqWKRh/Hs1ans+iIDlmXZ5MZEAcAbZqtdrO+zae2FzBFibVxYiDUo24+TWss XwJwi2xH9K8ctCHMPYNJoDNfrskFEHAKHdJ+6Zw0aqYaNrWepMHaQoS00vOdxQE3KHo4 umXsWqAZGm7vRj0giERpa3/EmGHVsdGOM1glkC3ip4X5NUif4sNGEZG8W581TMwZV11z ESFwyrGDkDzQjGDoUOwewuL8cAlqhW9ZVDGg0SEX6/kj+wPyN3esIrPMEDpiTQFnaTJr edtA== X-Gm-Message-State: AO0yUKW2LSAyIc0Ojy76nHZNT5YtPfNOTrnDT3rX9XfqWku4a4akcL0w CtEoQuL/G3fZslUo/JtEtQ8= X-Google-Smtp-Source: AK7set9HE2vMkBFZrWGb5wjW3FlKKos72kh3CIiD7WdtXNPEIWWlwr4p/W0RS749iQyOHeENZl+eFg== X-Received: by 2002:a05:600c:548e:b0:3df:db20:b0ae with SMTP id iv14-20020a05600c548e00b003dfdb20b0aemr8765331wmb.17.1678138112033; Mon, 06 Mar 2023 13:28:32 -0800 (PST) Received: from ?IPV6:2a01:c22:7bf4:7d00:9590:4142:18ea:aa32? (dynamic-2a01-0c22-7bf4-7d00-9590-4142-18ea-aa32.c22.pool.telefonica.de. [2a01:c22:7bf4:7d00:9590:4142:18ea:aa32]) by smtp.googlemail.com with ESMTPSA id x8-20020a1c7c08000000b003eb2e33f327sm21485042wmc.2.2023.03.06.13.28.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 06 Mar 2023 13:28:31 -0800 (PST) Message-ID: Date: Mon, 6 Mar 2023 22:28:06 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: [PATCH net-next 6/6] r8169: remove ASPM restrictions now that ASPM is disabled during NAPI poll Content-Language: en-US From: Heiner Kallweit To: Paolo Abeni , Jakub Kicinski , David Miller , Eric Dumazet , Realtek linux nic maintainers Cc: "netdev@vger.kernel.org" , Simon Horman , Kai-Heng Feng , =?utf-8?q?Holger_Hoffst=C3=A4t?= =?utf-8?q?te?= References: In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Now that ASPM is disabled during NAPI poll, we can remove all ASPM restrictions. This allows for higher power savings if the network isn't fully loaded. Reviewed-by: Simon Horman Tested-by: Kai-Heng Feng Tested-by: Holger Hoffstätte Signed-off-by: Heiner Kallweit --- drivers/net/ethernet/realtek/r8169_main.c | 27 +---------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index 2897b9bf2..6563e4c6a 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -620,7 +620,6 @@ struct rtl8169_private { int cfg9346_usage_count; unsigned supports_gmii:1; - unsigned aspm_manageable:1; dma_addr_t counters_phys_addr; struct rtl8169_counters *counters; struct rtl8169_tc_offsets tc_offset; @@ -2744,8 +2743,7 @@ static void rtl_hw_aspm_clkreq_enable(struct rtl8169_private *tp, bool enable) if (tp->mac_version < RTL_GIGA_MAC_VER_32) return; - /* Don't enable ASPM in the chip if OS can't control ASPM */ - if (enable && tp->aspm_manageable) { + if (enable) { rtl_mod_config5(tp, 0, ASPM_en); rtl_mod_config2(tp, 0, ClkReqEn); @@ -5221,16 +5219,6 @@ static void rtl_init_mac_address(struct rtl8169_private *tp) rtl_rar_set(tp, mac_addr); } -/* register is set if system vendor successfully tested ASPM 1.2 */ -static bool rtl_aspm_is_safe(struct rtl8169_private *tp) -{ - if (tp->mac_version >= RTL_GIGA_MAC_VER_61 && - r8168_mac_ocp_read(tp, 0xc0b2) & 0xf) - return true; - - return false; -} - static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) { struct rtl8169_private *tp; @@ -5302,19 +5290,6 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) tp->mac_version = chipset; - /* Disable ASPM L1 as that cause random device stop working - * problems as well as full system hangs for some PCIe devices users. - * Chips from RTL8168h partially have issues with L1.2, but seem - * to work fine with L1 and L1.1. - */ - if (rtl_aspm_is_safe(tp)) - rc = 0; - else if (tp->mac_version >= RTL_GIGA_MAC_VER_46) - rc = pci_disable_link_state(pdev, PCIE_LINK_STATE_L1_2); - else - rc = pci_disable_link_state(pdev, PCIE_LINK_STATE_L1); - tp->aspm_manageable = !rc; - tp->dash_type = rtl_check_dash(tp); tp->cp_cmd = RTL_R16(tp, CPlusCmd) & CPCMD_MASK;