From patchwork Mon Sep 23 20:26:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Shenwei Wang X-Patchwork-Id: 13809961 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DD981CF9C6F for ; Mon, 23 Sep 2024 20:27:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version: Content-Transfer-Encoding:Content-Type:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=XsFWuFPHEuGXtwrNoNYoFEcb8XyclW9WHWBmuh889K8=; b=gypB/CAF8/dfAu1KALdo4CGE9F UKifNSJ/jRSk/mNa7oMZWZwn5r+1hsX/YpcYIlx2L/t4zsX5yLAPQYXc4F4qawHsuQh/r9RrpsGK2 iqXm1Bn51jXO6GDDj7EHXBoAQAoVsMe+OXuh9oXT3ISVnDsTdkpKyraJe8vuCdsiTLApQkZkHaUAW lpTSMB7Pi94OWtIZlQ1S8RXreGdK1J/3Pk+49Nsafkc85+zq6RfmvoHfSBLCKrb5lyt3THJNjJ0cf n0Dp3+E6XimnSOfCqpUqYyf+2l5cG8+afuAVYOrOASqRV9C9caNvQqL8577rZeZO5OmL54A6zJur4 tSfhv7ng==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sspet-00000000Rju-1INO; Mon, 23 Sep 2024 20:27:47 +0000 Received: from mail-northeuropeazlp170120003.outbound.protection.outlook.com ([2a01:111:f403:c200::3] helo=DU2PR03CU002.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sspdl-00000000Rcp-3ISi for linux-arm-kernel@lists.infradead.org; Mon, 23 Sep 2024 20:26:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=gAUyXT8L9i1Jz3ePD1hk0maJ6/s7gOU4r/54ww+AhWGM0mHOByQ6k6qU29cSEco78yMyQXgz7QLTupdiHZ9WgV8LzUm9Pue0FdQrD0JmaT8moOHAVPedNqX+0n9A0Dj8AeOQrefrQGBRxiCSo6A+iGuzk8adz1XcfzrR+DmwFEKlKywgsrWlU35ZKzmj3saXSiU7vO1vn78nXX2TCuPyXAmZqxyDuH2GQaNIEigcPhG5lh6P6QijDOCtquynj/WH9u6nl0y12RaUNk0hjdMKpBcZLzlmbOL7P8GQUZ6KZaOdoUrtgh3nJO9XaeQpkRK+rHUvdWeQVBSQ8pnZbagd/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XsFWuFPHEuGXtwrNoNYoFEcb8XyclW9WHWBmuh889K8=; b=S1WZK+wMkzbKpWXGhRHLOQjSbWmaGdpiLj0gavetZEI1yq2JU//qiJUn13RDGBkJ8FqTOoBK2FmEaDtmB4SEerh/8AE00vf8Ae1sFcuPNNt24mQGZvcafRAKpI7E0V7O8fpwWjwiNYK1LVuXdEW0yJLIYSUpXyoiH0ghwB3d8QJF0Se98HKhqLkL256UNeVxIKS6hJpEDSPTcSUDVrtOrBIMtMEmRS/KpZaO1yUEPr0yO9GEqffvke78kYJHtW+iicas3skxJwBqSo/yqQBkvcBRsZn/RIsnH/PPpUEouk1kDiHKiDglzLfiKKu5zU2/pGrh8tr6i2DlJJsrrEHEQQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XsFWuFPHEuGXtwrNoNYoFEcb8XyclW9WHWBmuh889K8=; b=RotayVLB4SVNYB/kuyr16U/5nggfchlZDwoAh3A6I4d96JUd8fUxbmUljkUPNVkzVDEJ7cz3P5vQLgShF2jHQDh/6/8doTY+zRKqp0NTB2rDiqSJLT51RIS8tw3XMKCZdyCgZEuJdrZyNkvonmOA+AYcF08VRSIfxPOP+gyIsnwneE5s/hXmQrPtbyAEj6IA9i8NS4x2eUoUSASwcUP+guAgd4dPILFNeIQyR4EC6LOwKJghtq+0OEg9cu1hbFRSa0e442UUY1GNTSQjSd0Q2/PmusgSCFcIm/VIGN8inWViKWoFoF7CyJ4UFrzZ1Wr5uQXxmOtoVdF3b+vwMZ6Rxg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9185.eurprd04.prod.outlook.com (2603:10a6:102:231::11) by PA4PR04MB7567.eurprd04.prod.outlook.com (2603:10a6:102:e5::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.25; Mon, 23 Sep 2024 20:26:24 +0000 Received: from PAXPR04MB9185.eurprd04.prod.outlook.com ([fe80::21bf:975e:f24d:1612]) by PAXPR04MB9185.eurprd04.prod.outlook.com ([fe80::21bf:975e:f24d:1612%3]) with mapi id 15.20.7939.022; Mon, 23 Sep 2024 20:26:24 +0000 From: Shenwei Wang To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , horms@kernel.org Cc: Alexandre Torgue , Jose Abreu , Ong Boon Leong , Wong Vee Khee , Chuah Kim Tatt , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev, linux-imx@nxp.com, Shenwei Wang , Andrew Lunn , Serge Semin Subject: [PATCH v3 net] net: stmmac: dwmac4: extend timeout for VLAN Tag register busy bit check Date: Mon, 23 Sep 2024 15:26:02 -0500 Message-Id: <20240923202602.506066-1-shenwei.wang@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SJ0PR05CA0081.namprd05.prod.outlook.com (2603:10b6:a03:332::26) To PAXPR04MB9185.eurprd04.prod.outlook.com (2603:10a6:102:231::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9185:EE_|PA4PR04MB7567:EE_ X-MS-Office365-Filtering-Correlation-Id: d48173f2-e8f1-4a24-d860-08dcdc0dfe8a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|52116014|376014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?bkD5WGP3Xpkk0LS+BXxWhW75bxuG6Vx?= =?utf-8?q?tbrLPiCQ3oo0WYfY6K1/XXElCN8Kyy2RTkaOIHIuGgn6LIynM7KcwuyHr+03Scg7j?= =?utf-8?q?edsAVUTbzc8HA1gnVctR0lBZi5kzGRYgeIOvIWzEYC+qlCjc4B1+2SlGRYj99JTqg?= =?utf-8?q?02XwpWJA6kqMscQCrIcssSnmE7vAWEn0pPtxB76/UI0iGHO2hG5ViFWRm/9oYnPM9?= =?utf-8?q?eh483ZPZD5hqBR4SMwlwwCV+MOJaMjGpInBeeuddKmH3aQGEBC/6COrXUsxfDik2c?= =?utf-8?q?4eTZ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?q?FoQvJc5Rlp4lIxK6AD6c/WD2mf8SbT0meRtEBzHlx6EdkLTxuPbZwLvXiFaMhFbbG?= =?utf-8?q?JA+CGCE9JORLy7yeXQypCuxcPhZRQfDcB68sOdyuBuEOcFO8B3wnJmJqnDwBF94Fd?= =?utf-8?q?EejAcKOdVNgAtSv4iTBa4HP1h1tQxpF8F1g=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9185.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(52116014)(376014)(7416014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?wOJu9vg5wpFq0xtxmXQlRaJPtH65?= =?utf-8?q?zgCWkEXfbKU4tF86cnh/IxcpEo5IR9jnpBm3I1m//vsm7i3JnnQkOCep5nCs5QkLP?= =?utf-8?q?WGcLfTkHi/druQn3qNQrS+HUQhWQpwagq6aOWmOACPr+9Fv1Toi/Ugq3WYkga+cYg?= =?utf-8?q?h3bHJ58nOSMudBn8x0dtse1jgwPhOa+NMa2SJ0mw2/Q+DUulYFIZMqvCfMTvHyvmf?= =?utf-8?q?4TZcicvVFff6Q6vvqgParg8x+3beRSeyJHse0STcHgufBz0KnV+MuFXK7iJONTSkR?= =?utf-8?q?msCcGSp73ReLhEkEHmKD2g/2ssIEzDYG8tHdFokzSbU9wpf+toudH7zqwD7CUu8ft?= =?utf-8?q?m9Ta8r6z74dMDg9UlrVXhKl93CqcAJ4FkUdwLyP+el37em0HN4bLOWRUOGQ93tM1+?= =?utf-8?q?QqCl+CbK1PcfcmeJmBlWyTMZVB+s7IKw2T5eQsEMBciBpIWKFEUFVP86adZvbLxjR?= =?utf-8?q?1DC3NpXkiGX/I9wXgiJMgrch8JZelyUoMfDxm/9AT7+qtZGZTTEitksD4iFHGRY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OVVB4Zgunoz+Vh/H7V6W5p93tQ/E80k/iGe1xrrGScohIgEBMDzShZZ6dec?= =?utf-8?q?Qj9s7Uitl1Wb9z3R1m6axeLBVaYItckNPpGY3YitvcnTOJnz0BrXgf/z8PlZ34eHV?= =?utf-8?q?tAwGFGyYWuH9?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d48173f2-e8f1-4a24-d860-08dcdc0dfe8a X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9185.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2024 20:26:24.4125 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: grdxQdAoLRCaQXyIhHdIod67qvVMk/rZ4coJPzYXhbku9qQGm+yyfy/lRY8kmkqPXteP14ZHat0ZmZBn0jvSNw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7567 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240923_132637_882985_C3E80AAC X-CRM114-Status: GOOD ( 15.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Increase the timeout for checking the busy bit of the VLAN Tag register from 10µs to 500ms. This change is necessary to accommodate scenarios where Energy Efficient Ethernet (EEE) is enabled. Overnight testing revealed that when EEE is active, the busy bit can remain set for up to approximately 300ms. The new 500ms timeout provides a safety margin. Fixes: ed64639bc1e0 ("net: stmmac: Add support for VLAN Rx filtering") Signed-off-by: Shenwei Wang Reviewed-by: Andrew Lunn Reviewed-by: Serge Semin Reported-by: is fine most of the time as well, but ask for permission if --- Changes in V3: - re-org the error-check flow per Serge's review. Changes in v2: - replace the udelay with readl_poll_timeout per Simon's review. --- .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) -- 2.34.1 diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index a1858f083eef..0d27dd71b43e 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "stmmac.h" #include "stmmac_pcs.h" #include "dwmac4.h" @@ -471,7 +472,7 @@ static int dwmac4_write_vlan_filter(struct net_device *dev, u8 index, u32 data) { void __iomem *ioaddr = (void __iomem *)dev->base_addr; - int i, timeout = 10; + int ret; u32 val; if (index >= hw->num_vlan) @@ -487,16 +488,15 @@ static int dwmac4_write_vlan_filter(struct net_device *dev, writel(val, ioaddr + GMAC_VLAN_TAG); - for (i = 0; i < timeout; i++) { - val = readl(ioaddr + GMAC_VLAN_TAG); - if (!(val & GMAC_VLAN_TAG_CTRL_OB)) - return 0; - udelay(1); + ret = readl_poll_timeout(ioaddr + GMAC_VLAN_TAG, val, + !(val & GMAC_VLAN_TAG_CTRL_OB), + 1000, 500000); //Timeout 500ms + if (ret) { + netdev_err(dev, "Timeout accessing MAC_VLAN_Tag_Filter\n"); + return -EBUSY; } - netdev_err(dev, "Timeout accessing MAC_VLAN_Tag_Filter\n"); - - return -EBUSY; + return 0; } static int dwmac4_add_hw_vlan_rx_fltr(struct net_device *dev,