From patchwork Sat Feb 25 21:44:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 13152271 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 25436C64EC7 for ; Sat, 25 Feb 2023 21:47:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229558AbjBYVrq (ORCPT ); Sat, 25 Feb 2023 16:47:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229536AbjBYVrp (ORCPT ); Sat, 25 Feb 2023 16:47:45 -0500 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 071B015559 for ; Sat, 25 Feb 2023 13:47:44 -0800 (PST) Received: by mail-wm1-x332.google.com with SMTP id c18so1970549wmr.3 for ; Sat, 25 Feb 2023 13:47:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=NsaTFkT0zxCztwBusggP7k2Pfzh0LdcT5o8TgXJsooU=; b=YC7oUjd1DCJz3IBVYlEuFXzRfIuzRfFwl1o17LZqepMXNl08opvzA0C0LF4Ol1l2zp hJZzFF2hq8uCxFYdSf6adK6TRWBPF7S3Av3Y0w8HnL9NKosBJVFMJqWBqA/e4EGYqexr S4TMpOXae9TxAA8JQfad1Q4FuDTTjlfgIjSo+GL8J91gXufk8ORg/Xi6Kd2U2qX1jMp9 XSrKNCA4umaR8pAv1tcRlVghDlUYoUPcDm4uSLkq7jNHSceippqKjBXYUtmrt8vkAWHw FNod8m0ZwAPa7W1eFwaTzJ3/DHRa2DQn5EFJNkyJkKOEPmJ9PRAWb49r0nYI2ffb5KQi YB5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=NsaTFkT0zxCztwBusggP7k2Pfzh0LdcT5o8TgXJsooU=; b=opKuNwPud+kBcugeYB9tgcf2lYNukjOcJUi/yQ2/8HmVEZZ354ttDiGW/lGQU6WRHA piWxgOPDUee6ykYvnn0EK8Snyf8LubjgAPXKe28cZx4xjVi087S5DLCJ+YPNGjJ+5QnX bZlPdjIUt/kX4rmgESNNj8csC29WqyjmT//fz8l4XCXCq9cGkJZo01BkPiTcjX6KCFQS ye/AfSawqDT4OCeS7y/o9WLn1QigNjG8E7qzm5CyD46Po9SJg8IC8pf+LqnYKpqz1ID4 1FqXhBxI/iXASKA+ehvw8JG1hoP1AOIEHlzpq6X6TlJMOYra/j0lOBTNMpentqogD+iJ xGOw== X-Gm-Message-State: AO0yUKUw+aNna4JA9Zi5EgURL5cah3DD31CpIma+hMKOWjXWXbMIBkVM cgfK2BnOqbSMl4SGMKMzwn2pABE9FQI= X-Google-Smtp-Source: AK7set/k5Z1hgWu/dRsdHgG5H43igKyumGX7qSEoJ5IY9AWhfRmaJHFDpkSXSJV7OZtJW3NLPQeSCg== X-Received: by 2002:a05:600c:3088:b0:3d3:49db:9b25 with SMTP id g8-20020a05600c308800b003d349db9b25mr16367507wmn.26.1677361662349; Sat, 25 Feb 2023 13:47:42 -0800 (PST) Received: from ?IPV6:2a01:c22:7715:8b00:51a3:9e62:de37:8c49? (dynamic-2a01-0c22-7715-8b00-51a3-9e62-de37-8c49.c22.pool.telefonica.de. [2a01:c22:7715:8b00:51a3:9e62:de37:8c49]) by smtp.googlemail.com with ESMTPSA id c16-20020a05600c0ad000b003e214803343sm7314109wmr.46.2023.02.25.13.47.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 25 Feb 2023 13:47:41 -0800 (PST) Message-ID: <9508a76f-8f83-9579-a46f-742d486a6cac@gmail.com> Date: Sat, 25 Feb 2023 22:44:10 +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 RFC 1/6] r8169: use spinlock to protect mac ocp register access Content-Language: en-US From: Heiner Kallweit To: Kai-Heng Feng , Paolo Abeni , Jakub Kicinski , David Miller , Eric Dumazet , Realtek linux nic maintainers Cc: "netdev@vger.kernel.org" References: In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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 protext access to mac ocp registers. 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 Sat Feb 25 21:44:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 13152272 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 D81DCC7EE2E for ; Sat, 25 Feb 2023 21:47:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229615AbjBYVrs (ORCPT ); Sat, 25 Feb 2023 16:47:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229536AbjBYVrr (ORCPT ); Sat, 25 Feb 2023 16:47:47 -0500 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6038215565 for ; Sat, 25 Feb 2023 13:47:45 -0800 (PST) Received: by mail-wm1-x32b.google.com with SMTP id ay29-20020a05600c1e1d00b003e9f4c2b623so4661868wmb.3 for ; Sat, 25 Feb 2023 13:47:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=Fs6Ye0Y7lLqTDKrmf5OausJVY8USxG33uLTz6DKiW+k=; b=AtF91Oqt6BZsg+tt7Ui2tNWj+53d2zp2USOiOVogh+pDGQ3arKK2vuNHsIOR4DGzPN YigIm72I37fAnGJzq4zN0WDUcIBekzOEJ/Mz3zm2UvxnY3Eln8tqSCwFeSMW/A90pH17 2r5y/5FKVv1yJ6fVthtWN9RyrOZS5XnXMzaa9YVeIV2gV0C9fj3xu2iswFBZGCoa65Gb wOaTq9EpzcsEDTidP5ugsV8T7wl7XuYEMMtFUMzKD2IqX2nJfKf+Mm2joh62gKOqVusM Dp4dfv7lRnLzOouZYWbPwpO+nsg9BBLq1/GfRLrO9d0tpi3/sK1s/7TinLeBKhvExsaA 4hYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=Fs6Ye0Y7lLqTDKrmf5OausJVY8USxG33uLTz6DKiW+k=; b=fzQ/FB3+E+AearAbbUgWGOgRii3JuD0jZ3ygKnPFK4ep7Dhis+jpeXoWbJNObVFiF9 OB52zu6MjdOFAoN/d3N33famLV3I9dUPnTQUqQngiCNX0qglLL0fT52HF89MhlShmDQS 1TMuJc6M6xtl9PBnVqqkfj3rbed0aAWNd8iZliDJ6U8vgbse1F6MVYv+yz5LS/Uug9ph 5VUkG1V1LuISSVsjeC1JQ/KcWERkmHh+To65sKlyM9uMo6cpVXmIYidcEJVzY8CiEy9s JFjGTd8mvfTyTPZMB4wwkJjdaJV34A8tF25sugxBn+MMJf+EjwQr2jX9KTFr5/LGmiFl zScA== X-Gm-Message-State: AO0yUKUxWsJCqwvVv+WCjHI1DY+1I0HH/QfUj3S725diXkckjkELikrq JgUDOfIECKcVXP15lAw158o= X-Google-Smtp-Source: AK7set/iLkzJz5rf8s5/qgB3UmS8WMDqJ4q0lH6BJK0N/mAepm0A4AvVCO8o4j0zXoJpCRFOd+1NvA== X-Received: by 2002:a05:600c:4b28:b0:3e2:9b4:4303 with SMTP id i40-20020a05600c4b2800b003e209b44303mr15951313wmp.19.1677361663688; Sat, 25 Feb 2023 13:47:43 -0800 (PST) Received: from ?IPV6:2a01:c22:7715:8b00:51a3:9e62:de37:8c49? (dynamic-2a01-0c22-7715-8b00-51a3-9e62-de37-8c49.c22.pool.telefonica.de. [2a01:c22:7715:8b00:51a3:9e62:de37:8c49]) by smtp.googlemail.com with ESMTPSA id m21-20020a7bcb95000000b003e21f959453sm3830016wmi.32.2023.02.25.13.47.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 25 Feb 2023 13:47:43 -0800 (PST) Message-ID: <4efb7dcc-0e7c-8873-9a8c-fc681ef30b33@gmail.com> Date: Sat, 25 Feb 2023 22:44:50 +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 RFC 2/6] r8169: use spinlock to protect access to registers Config2 and Config5 Content-Language: en-US From: Heiner Kallweit To: Kai-Heng Feng , Paolo Abeni , Jakub Kicinski , David Miller , Eric Dumazet , Realtek linux nic maintainers Cc: "netdev@vger.kernel.org" References: In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC For disabling ASPM during NAPI poll we'll have to access both registers in atomic context. Use a spinlock to protect access. 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 Sat Feb 25 21:45:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 13152273 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 C770DC7EE2D for ; Sat, 25 Feb 2023 21:47:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229619AbjBYVrt (ORCPT ); Sat, 25 Feb 2023 16:47:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229577AbjBYVrr (ORCPT ); Sat, 25 Feb 2023 16:47:47 -0500 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73B3815559 for ; Sat, 25 Feb 2023 13:47:46 -0800 (PST) Received: by mail-wm1-x32e.google.com with SMTP id r19-20020a05600c459300b003eb3e2a5e7bso2775wmo.0 for ; Sat, 25 Feb 2023 13:47:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=ArGXE4ImnTj0mcvzPwtJoM4Jm+yvRjjF/GU16UDwiWc=; b=ISvD8mtQezdmktQmaYt6Q3NEzuiNIaybsi8d9I0HjVXxKv28bOTt7XhZcwLCphsuXv rnlIpbDyBrQVtie0/6dMiujlhhaZAGJElsapNokNrAYrvOaJj6PM9FGrElsquu41fefn d+Li1SN3zwrOR8g6WYGFBhAwNOZJH4JUxWZUW3u9BI5pRvFgba1gCUw91lMklNJoAJkf j2Log6HuL7csKPzGHSZXgDMguAXaH2liVSaywtNJ53zGbSFDZDXctL/Yu8aUlcRNssSG WoVbJrQXUVIo68ggnDyROAiiuLEJbdkZdLGfLb3q/jIS7ByGXXQxorxIZpV712iL+sUX tkiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=ArGXE4ImnTj0mcvzPwtJoM4Jm+yvRjjF/GU16UDwiWc=; b=Mxp618XQx0xLqfAAQ89PgALNrNkvT8mnWPzEqt3I99MwPPFQW82zZAZjUEFQAfil2f I/HubAAaV1WGrRoVokl0D7ZWnqhhQQHm9ZXqli1PY42AqPZcLLew3ipk03k+R4CAFF0T a2H/v9STUr0bRlvGs1hkKy4taZwLRwoxMP+HyjAKhmoMsTXK/b+l+y9z/4g+oFrvVf/p Uw+A1jn8sIB3Ab515bTcludkkb4jFOJ3O6EZZqfLtSK7a6gWsnAvhdthvTZgpRotfgIl gD5qP0K0sN5h8+/GxoQ46wA+KowOvjFU5nAq4jEr37GL7TsUsxiSjn0Yyq5MksLgRfVK N6Aw== X-Gm-Message-State: AO0yUKVjR+BYdTo2rCTfCogwPBiA1PjMnZsSjAa8FHVsa4YmpK8eCMPk IIpJck0pBvUXobWKWzgwX1I= X-Google-Smtp-Source: AK7set9G5dZWmXHAna/e4OZgYDPxkAxmIncMPbXywLTupIcpYtRNBiXW0KmDfwKx4LWoQ5GQfFAl/Q== X-Received: by 2002:a05:600c:755:b0:3eb:3b7e:7b97 with SMTP id j21-20020a05600c075500b003eb3b7e7b97mr188752wmn.30.1677361664917; Sat, 25 Feb 2023 13:47:44 -0800 (PST) Received: from ?IPV6:2a01:c22:7715:8b00:51a3:9e62:de37:8c49? (dynamic-2a01-0c22-7715-8b00-51a3-9e62-de37-8c49.c22.pool.telefonica.de. [2a01:c22:7715:8b00:51a3:9e62:de37:8c49]) by smtp.googlemail.com with ESMTPSA id g9-20020a056000118900b002c794495f6fsm2659791wrx.117.2023.02.25.13.47.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 25 Feb 2023 13:47:44 -0800 (PST) Message-ID: Date: Sat, 25 Feb 2023 22:45:28 +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 RFC 3/6] r8169: enable cfg9346 config register access in atomic context Content-Language: en-US From: Heiner Kallweit To: Kai-Heng Feng , Paolo Abeni , Jakub Kicinski , David Miller , Eric Dumazet , Realtek linux nic maintainers Cc: "netdev@vger.kernel.org" References: In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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. 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 Sat Feb 25 21:46:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 13152274 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 D9A34C64EC7 for ; Sat, 25 Feb 2023 21:47:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229628AbjBYVrv (ORCPT ); Sat, 25 Feb 2023 16:47:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229536AbjBYVrt (ORCPT ); Sat, 25 Feb 2023 16:47:49 -0500 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB0A016AEB for ; Sat, 25 Feb 2023 13:47:47 -0800 (PST) Received: by mail-wm1-x334.google.com with SMTP id p26so1964654wmc.4 for ; Sat, 25 Feb 2023 13:47:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=XZ0wcNd8yHxm+yQ6j8mxrrOX8gL8+IfMQlDnuGgN7EQ=; b=PRRhPeaLRo2COntuhoue+gn1LYH9gPFd0PZ0KWaDMwkcBhsyAuv1EFlDJMqz9xTbUw I8dBAeDCqTcQ8riA/EjAjWflSy+kv/bSXxblk5eM1MBLT8T9tpQfCDRT3moyQRS2DGM5 e4BmxyQJtBijA2U6SO+OjJ9XOBoZZuHI8eMPKQ5qR3ic7RzhfVHPtA2tWD0+vX3ed7eu dhQN93pWskpcNqBKGRTK2fghtpiG8n+GNOqJQ52gjaFRtj9FYcVXrIUduVFU/nWLUFJH Di8gwq/D6RE7Z+HDM7EHnUvfbI5KcM9gXt2nfPytMqcqPZuGBB2JqgFbUbfdtEzZVtIo OsZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=XZ0wcNd8yHxm+yQ6j8mxrrOX8gL8+IfMQlDnuGgN7EQ=; b=lGlhSMRrd4978tDKGzZLgfVi3JB1q71gkYq1wKVKGdAJVOAwBYanRsToYhxAIR/YhB g2TgM4ATrh2MqfIO/qz0Z6UHYyj/Siy6b/GfcuWA+0vakkeagK/GiT+r7uXOtPdY7QD4 R1TkLhCJZ8ptC3ntYHdwgN7q+bZw1cWdgolnF5DT1qvQSJS2p8zvCR2Q4i/Ruz3anxwk P6rxLq0AzUlrpu9pITOa7XzkxNsCKmAuM34toFA+22Zly1rSc1IM2WpL9c4FQLTdN2/N n+zxFN3fWlFzRuAvvTobTFyGWJrBYecqlgvX3K8ruYUHwCuvy69KVJMohCaRhCM+OrTj +4cA== X-Gm-Message-State: AO0yUKWl8FPtBlgQSpCng/TOXhs34nA7MPRZ0st6hm42sQPxgNVOgU/b 5U0Dm+Zo9IT3uR3vIkS1Wy8= X-Google-Smtp-Source: AK7set/8HuT70SEC4UVq2RE//M8xp5YFm7W1Kpe/Az26SzxmBuM1hibTZWdbCt1Vn2FKsUAGzij63w== X-Received: by 2002:a05:600c:ccc:b0:3df:db20:b0ae with SMTP id fk12-20020a05600c0ccc00b003dfdb20b0aemr3130675wmb.17.1677361666086; Sat, 25 Feb 2023 13:47:46 -0800 (PST) Received: from ?IPV6:2a01:c22:7715:8b00:51a3:9e62:de37:8c49? (dynamic-2a01-0c22-7715-8b00-51a3-9e62-de37-8c49.c22.pool.telefonica.de. [2a01:c22:7715:8b00:51a3:9e62:de37:8c49]) by smtp.googlemail.com with ESMTPSA id p13-20020a1c544d000000b003e208cec49bsm13324759wmi.3.2023.02.25.13.47.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 25 Feb 2023 13:47:45 -0800 (PST) Message-ID: Date: Sat, 25 Feb 2023 22:46:05 +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 RFC 4/6] r8169: prepare rtl_hw_aspm_clkreq_enable for usage in atomic context Content-Language: en-US From: Heiner Kallweit To: Kai-Heng Feng , Paolo Abeni , Jakub Kicinski , David Miller , Eric Dumazet , Realtek linux nic maintainers Cc: "netdev@vger.kernel.org" References: In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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. 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 Sat Feb 25 21:46:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 13152275 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 B9A6CC7EE2D for ; Sat, 25 Feb 2023 21:48:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229677AbjBYVsA (ORCPT ); Sat, 25 Feb 2023 16:48:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229622AbjBYVru (ORCPT ); Sat, 25 Feb 2023 16:47:50 -0500 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDFDA17CCA for ; Sat, 25 Feb 2023 13:47:48 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id p8so2547709wrt.12 for ; Sat, 25 Feb 2023 13:47:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=BfPBypnUp662Wa/T+fbE80zBYw474TJLsUpPffFo5wU=; b=HXtOCe2dxv5q825BHDyLTWxtwzQ/PlYbkORbGsQAz03mjoH7Npm6QNGERIm15tjpv+ oBzVT9H+M1gFlTnepCpwfJeVeLUw2zQeY1R8EIcrzjGBehXgMAUrMbIpmsJIq37/eR64 ntpmKy1sEggupGkQoCb9x/MklMCPatmaoYMuCPAk6H+9RjDRdm84DkokDekXnI9QAj8y IufECu5yICLbaz744m11admOQOo/c7qEFCUgSVereX5lP9cZq4I6VL/jUE7i36qomXGr XL3jPe7Zw+AP7RehC41GcYgvGXhPQm646CEyUPQLb3i5RnKoqZMKQLlMfaejzbJ8GCvx BvXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=BfPBypnUp662Wa/T+fbE80zBYw474TJLsUpPffFo5wU=; b=W8fZh8Gm6cAjdcf2dmWazKzVhF4RvaRvLOkLXHYyQMDKVck6DPiMXMP01dK+LJOOgd GVwa4aOIJQ4lNJJlJRonIMc+vC8bLkTO8O08eVA5G6heT/efSWKJdxTOfouMzxZ6T1WQ yNouDgLCJFCjprApVHqct5u2kTwUBD9xy0Nn21dgSMW8Krp+KhQ5bV8aTihBis9u3vvz 2+i3gmpJI5+HYIav+pIMpyVh8f94cQs5+dMB1eGZqwcycFjPoBX3e1FkdqzAtSq+KvcT BswshWVMFVgJ6tU/XCHPLQTo7kAXawKxbcggz07dwXesI8bZfIg2FWdnq6xZL6nQwpQu cBBg== X-Gm-Message-State: AO0yUKUmQ5ACKanU+nabxOj05TeCPJCWmYC8OS9OilEfYDIJB29NWwBN hz4J8GrCkAeaBjLvrFD+AYQWjE7TF1s= X-Google-Smtp-Source: AK7set9MUl662BbXbkCz350Kl7SepTkmNI6urVSFGtGTKXKMNmmjZxeljJ1dhQSWQZruyr7PhxwzVA== X-Received: by 2002:adf:f292:0:b0:2c7:1b4b:d729 with SMTP id k18-20020adff292000000b002c71b4bd729mr5949184wro.65.1677361667306; Sat, 25 Feb 2023 13:47:47 -0800 (PST) Received: from ?IPV6:2a01:c22:7715:8b00:51a3:9e62:de37:8c49? (dynamic-2a01-0c22-7715-8b00-51a3-9e62-de37-8c49.c22.pool.telefonica.de. [2a01:c22:7715:8b00:51a3:9e62:de37:8c49]) by smtp.googlemail.com with ESMTPSA id p13-20020a1c544d000000b003e208cec49bsm13324856wmi.3.2023.02.25.13.47.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 25 Feb 2023 13:47:46 -0800 (PST) Message-ID: Date: Sat, 25 Feb 2023 22:46:46 +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 RFC 5/6] r8169: disable ASPM during NAPI poll Content-Language: en-US From: Heiner Kallweit To: Kai-Heng Feng , Paolo Abeni , Jakub Kicinski , David Miller , Eric Dumazet , Realtek linux nic maintainers Cc: "netdev@vger.kernel.org" References: In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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. 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 Sat Feb 25 21:47:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 13152276 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 7FC8CC64EC7 for ; Sat, 25 Feb 2023 21:48:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229746AbjBYVsB (ORCPT ); Sat, 25 Feb 2023 16:48:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229656AbjBYVr7 (ORCPT ); Sat, 25 Feb 2023 16:47:59 -0500 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81AE51990 for ; Sat, 25 Feb 2023 13:47:49 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id k37so2010740wms.0 for ; Sat, 25 Feb 2023 13:47:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=gCW7PNbp1TQ75eLDJ0N6qAwIQwus+fQp1Mf718gWsF0=; b=nr2Ya1Ap0RpMwffZiQ582202zYZLI2VBAj+Sbm7R8QRS+wuJcjsJr18r4U/OiYEl4U iLHQXyt9O9mjZe9GdPOIaxeXLRAp6oXdvVoNEtxodEnQt9r/uwqnCOPL9T1nbx4rMNOv DbgvX5QeJi7mJfmSx2/HO8W/hwqSf/LrFN5JWhIVcaDMCCGQEOVEt9dl5BrZduqUM37E Z9dkhMsB4thkoHI55xfk2twXSsKscgAWfnFcBg39BVgBpDweW0Of7EJ4rVn+qEvyEejR hcAANsocUgZeQN4ITjlyhqJD9z9pKhni0RBAWreQPAi0U0b4D+tC0/wyO6WPEpqqM/SY P2OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=gCW7PNbp1TQ75eLDJ0N6qAwIQwus+fQp1Mf718gWsF0=; b=xpk8NyK4RT1iuAsZFA0hKysqakOAXxCLs3LfsrfDBs2l5Bk7UqW6dszz3iJa/VnhKS VrshgkyZeapm7xa/N2wbqY79k74TCdg3PKnivjYaDdjW3vP8A8KBKUFTZUmoYoB8tSjq crZmVoPuycfoHaPWIo1FNklTXTd1CcMy/crK9bRR8q+YKTxIfvPoOzWKWPfk39J/s4vW +Y8m+QuEEWBYr8TWHtgMDYoR5rz2jYjs7Mll+SZRkLV3zRgfPmpkkG8MsZ12NQlCgW2b eSCSUCuCWCaOIcUX6X57FM86pD6b5DXWYw7QiOsoJLJu3Nr61Qn7TN2oWUsmHsyYNE2q OEZA== X-Gm-Message-State: AO0yUKXHo3LOk359s1a7jJTzi4G9TVIRDDZPCFX8Lo6jiTY37DRFCPPm y1JVX1+V5BGv63O2SMfFfQQ= X-Google-Smtp-Source: AK7set/fDBf9M72qeDAIytb1vPfgrfGZhYW+XV0WMfwC3hqbWABuZK2wVoOfE7Aw5A+xfq8aJramxQ== X-Received: by 2002:a05:600c:1609:b0:3eb:39e7:35fe with SMTP id m9-20020a05600c160900b003eb39e735femr352922wmn.30.1677361668486; Sat, 25 Feb 2023 13:47:48 -0800 (PST) Received: from ?IPV6:2a01:c22:7715:8b00:51a3:9e62:de37:8c49? (dynamic-2a01-0c22-7715-8b00-51a3-9e62-de37-8c49.c22.pool.telefonica.de. [2a01:c22:7715:8b00:51a3:9e62:de37:8c49]) by smtp.googlemail.com with ESMTPSA id p13-20020a1c544d000000b003e208cec49bsm13324947wmi.3.2023.02.25.13.47.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 25 Feb 2023 13:47:48 -0800 (PST) Message-ID: <2d61ba5a-9a2c-28c3-4a1b-a81a3f34af3d@gmail.com> Date: Sat, 25 Feb 2023 22:47:32 +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 RFC 6/6] r8169: remove ASPM restrictions now that ASPM is disabled during NAPI poll Content-Language: en-US From: Heiner Kallweit To: Kai-Heng Feng , Paolo Abeni , Jakub Kicinski , David Miller , Eric Dumazet , Realtek linux nic maintainers Cc: "netdev@vger.kernel.org" References: In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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. 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;