Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp31144rdb; Mon, 22 Jan 2024 10:56:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IFVaNH6126zLkC6tGw9jIJA/2D1ilz2wu0yC++gz4/ELZPlX7952U8FzIF9hxkLfgB7H4Eb X-Received: by 2002:a05:6402:1a30:b0:559:d2db:2407 with SMTP id be16-20020a0564021a3000b00559d2db2407mr150412edb.29.1705949786820; Mon, 22 Jan 2024 10:56:26 -0800 (PST) Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id u18-20020a509512000000b0055a68f50164si3689426eda.563.2024.01.22.10.56.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 10:56:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-33957-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-33957-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-33957-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=hotmail.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 6785A1F2CADB for ; Mon, 22 Jan 2024 18:50:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 264AA3E464; Mon, 22 Jan 2024 18:18:15 +0000 (UTC) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2030.outbound.protection.outlook.com [40.92.89.30]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E7F33D99D; Mon, 22 Jan 2024 18:18:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.92.89.30 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705947494; cv=fail; b=S8VBDXn4/NZx6Xr1RlIqNU9Q0uymWnrHj0TR1JQ2a6tH5fhXGZObQb9tiKzbNfL/TgMXE2NbxtSfQHupLUgUaXdS0InsrDPdKw6xp7WBs2q74y+aD+XIApM4vjdA34hktCzDj8Jg6VnFTeMEptSUcFE2DgO+yBx9a+nLB16n8NY= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705947494; c=relaxed/simple; bh=EMiSC84lyuwtmR+OGCOdBDqs9tOMzITBxYcojCrJtRo=; h=Message-ID:Date:Subject:From:To:References:In-Reply-To: Content-Type:MIME-Version; b=S8OlXrNstIAeHUG4ZzsHQiWmCo2GNULK81plUdxbs1fWpXYAFFeaa2mvrXAIwappMovxSnNXiA4cWTxj7i9VydY+BMb/c2E+Zoxo17to/UOLgNKfDXb5bTr5GZgEV8iMin5iBV4TSzbpcnE9N7OD07lpJN/or9Lo+hd8hacoiII= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=hotmail.de; spf=pass smtp.mailfrom=hotmail.de; arc=fail smtp.client-ip=40.92.89.30 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=hotmail.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hotmail.de ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T8W68C7afj0q3lR0oSA7Uj3wFbTPtNigqBEQT4/5MYzIUoSSzowQU/PMypMotfEk0m293AoRuyimyhESAE+Sto3Vs8yVZpBsrRZGLR1H9lJJn06tw4o4U1xV7tzVHLnZEW0QztPJ3tmUQtLWQnkLPPrGxeVhZP7kxO6tGe01cb8cJTXVjHAjSl7xvIBP+ScVv9FVjEgFJtojmx1cArSyYvDLyVP184mdVG7kBub5Eszcsfw8CwYD7aZwSGb5EwyjXM8zQgjEUxT4++XyadWanPMhXM1/psH2dY4xsvm61wXCniXTpjU+mouvpwF9H1ftjO63gI8A2uhLSNFfzimLww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=IEfiwqS1GXTi25zXS/pUdzFI5o8tyC1bEjhcGGvfEFg=; b=iA0Ni9ZNA3gRJKr6DEawaO4pnzQBna6O9WeIur/HewmBHNlbE8u+0KUZ2/1/ur+vPS5045JZ5K8jUPr+COV9DbInVB8aT6Vif2OBnBqELjLOHea3bk/O94FWcxtZKDLeMor2aa930eYFEWr1Dw53NOK//zD/KF5xQR9LG3vZeatoeW0QhKY73BC8GU49n/hG1xKaH1sk6PSYq3B5zjm4Cq5uiWJFH6o7JZUKGRZ3yanaX65H4QHpBMq+jSxDGvc/CW1x9ha0i2u5Y22GIm44Qh92rKavEHeV0Oo8h3WAWT8he2Ez8vQr/MIGTB3P2loY2PpabjyFVYc9GrIuWzpJFQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from AS8P193MB1285.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:333::21) by PAXP193MB2201.EURP193.PROD.OUTLOOK.COM (2603:10a6:102:22c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.36; Mon, 22 Jan 2024 18:18:09 +0000 Received: from AS8P193MB1285.EURP193.PROD.OUTLOOK.COM ([fe80::897e:cfd5:b29b:c611]) by AS8P193MB1285.EURP193.PROD.OUTLOOK.COM ([fe80::897e:cfd5:b29b:c611%6]) with mapi id 15.20.7202.031; Mon, 22 Jan 2024 18:18:09 +0000 Message-ID: Date: Mon, 22 Jan 2024 19:19:09 +0100 User-Agent: Mozilla Thunderbird Subject: [PATCH net v3] net: stmmac: Wait a bit for the reset to take effect Content-Language: en-US From: Bernd Edlinger To: Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, "linux-kernel@vger.kernel.org" , Jiri Pirko , Andrew Morton , Serge Semin References: In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-TMN: [BAtjC9paNT0X5pFntVxz3mvUexhCEIZMOud0jdfa7Dq8UnEEn/KyIF/tP6MprThn] X-ClientProxiedBy: FR5P281CA0058.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:f0::14) To AS8P193MB1285.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:333::21) X-Microsoft-Original-Message-ID: <03e90c5c-ed34-4d0f-aafa-b8f3165ecd1c@hotmail.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P193MB1285:EE_|PAXP193MB2201:EE_ X-MS-Office365-Filtering-Correlation-Id: 99098321-45b1-41b2-0415-08dc1b767cb4 X-MS-Exchange-SLBlob-MailProps: obhAqMD0nT+gBgqCImLTqb4mdYBvtNPTyonupf3OileFmXaQWuz3XEOFAjLVItD233Qv3HfMLCzS1dctlXGrb/FF3jVjUGzAS25jFdxOpSybby7lIpkRnYYm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G93YlpnSllFeXJLRFFkZUQvQ1Mydko1M2p5NzRh?= =?utf-8?B?YlhXS1BjampTMlV3aCtjajBKL0lNa0orTWNCditDdFMxUWtvYjJBa1VHdXkz?= =?utf-8?B?eGNDbE5QZFI0ZkhHMkROVmVoS0Fya0RNdFc1WTNBUHN5elprb0NqRTFjc25a?= =?utf-8?B?WHdhdVFiM21BM3RXcjJzSzBacHZBMTdaNTZsSkZJb3QzZ3F5K1lBL09kVi9M?= =?utf-8?B?MVBYbjBKQWFVamdjMmpKbE5ITTVDNmZhN21UMkcybldaTnNUZmVPTDRHcTNT?= =?utf-8?Q?qagNqlGriF+MXSpsY8=3D?= X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-80ceb.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: 99098321-45b1-41b2-0415-08dc1b767cb4 X-MS-Exchange-CrossTenant-AuthSource: AS8P193MB1285.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2024 18:18:09.6200 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXP193MB2201 otherwise the synopsys_id value may be read out wrong, because the GMAC_VERSION register might still be in reset state, for at least 1 us after the reset is de-asserted. Add a wait for 10 us before continuing to be on the safe side. > From what have you got that delay value? Just try and error, with very old linux versions and old gcc versions the synopsys_id was read out correctly most of the time (but not always), with recent linux versions and recnet gcc versions it was read out wrongly most of the time, but again not always. I don't have access to the VHDL code in question, so I cannot tell why it takes so long to get the correct values, I also do not have more than a few hardware samples, so I cannot tell how long this timeout must be in worst case. Experimentally I can tell that the register is read several times as zero immediately after the reset is de-asserted, also adding several no-ops is not enough, adding a printk is enough, also udelay(1) seems to be enough but I tried that not very often, and I have not access to many hardware samples to be 100% sure about the necessary delay. And since the udelay here is only executed once per device instance, it seems acceptable to delay the boot for 10 us. BTW: my hardware's synopsys id is 0x37. Fixes: c5e4ddbdfa11 ("net: stmmac: Add support for optional reset control") Signed-off-by: Bernd Edlinger Reviewed-by: Jiri Pirko --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 3 +++ 1 file changed, 3 insertions(+) v2: rebased to v6.7, retested and updated the commit message as suggested Serge Semins review comment: https://lore.kernel.org/lkml/b4mpa62b2juln47374x6xxnbozb7fcfgztrc5ounk4tvscs3wg@mixnvsoqno7j/ and retained Jiri Pirkos Reviwed-by from: https://lore.kernel.org/lkml/ZT+Zq4j9iQj1+Xai@nanopsycho/ v3: addressed review comments. Thanks Bernd. diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index a0e46369ae15..b334eb16da23 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -7542,6 +7542,9 @@ int stmmac_dvr_probe(struct device *device, dev_err(priv->device, "unable to bring out of ahb reset: %pe\n", ERR_PTR(ret)); + /* Wait a bit for the reset to take effect */ + udelay(10); + /* Init MAC and get the capabilities */ ret = stmmac_hw_init(priv); if (ret) -- 2.39.2