Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1188861lql; Tue, 12 Mar 2024 09:36:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUzzjMSgsNF42KEa9cPvHdBSBpsQpWVZGWF4kg1AwYu68HgrS9fvOWKuYW29S9uPMHsMJ3+27TuJ144rSF8hriQu2jan5dxXLdkKlMZxg== X-Google-Smtp-Source: AGHT+IEOLrd7ZJWcVcBasfo6fmGTVZLo6FbxQrwg0cIthACSEbKbn30kEY4oNa3rNIRY85DyfOtW X-Received: by 2002:ac8:5a15:0:b0:42e:ef7c:29a4 with SMTP id n21-20020ac85a15000000b0042eef7c29a4mr14197752qta.50.1710261387406; Tue, 12 Mar 2024 09:36:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710261387; cv=pass; d=google.com; s=arc-20160816; b=CXcbMVcHOY4JSDwMSYfGxsiyNT1LFw1kscCxIBQJfVE4oa1NwPN3mA6dspHz6tnpf7 Gn+KSJAImSdDZnjEKztuuj6hjXfGYxp6KMtz4gASB3i/Y5VYrU434AjseYM42dOnG0pQ HpC3kfqDWrC9kmW6Tp7soX6wzFL9cJS3Sqmz0uGuI4D3YuxBwEG4zOot84pueVgj7HlO IfyS0mVNGYR/rBMJT6Hz9Hx45Euf6KUH9P0dUMMercj4btqGvsA1tI57/Dkio0mrwTAo Ucapq+iwAhfVKeF87IOKFYjOPB31MplktMAZlyaiZF4+7eKM1Vfl4Sztbp8LiD3XhfpA UaeQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:message-id:references:in-reply-to:subject:cc:to:from :date:content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:dkim-signature; bh=yg+g+abNrGcwEzQSWBbG2h+JPGpvEcqsYIaVOBM+AUA=; fh=gFgK6fPwftuDEvVR20Og5LPAYwBZFKQzm2fsuM7uvCU=; b=0OLmIm6PKJtcLV8ZVpkKAwRmM/5hiA7Nf61FQGW/Ffs2vrCJxSOEGXlLWht7tKIDGm Tzxefb/VSGRI1doGqZsZLMXVLf2zbFgX2MLwoLojS98f+UfJXlI7cjCg6y52Ye/eQlTr b0qB1da2pQVG6M0jcTDowwfpCf60zHrMDe1ugn/dEIIZtJD76wyGsPZealCZtcUiHu10 jOPXYYAYD8ydW6c+CCJ4wXUqnSZTLtAAgDlmaNDEpUHwLMyacaRgEPSXgPAYFpEurPBL mD41n8PuKWjBaenDhgGGe0b18GGWRbcuXjqN2vZ3YonU31sCCsXMGF+fIu5nY6mI2uRN M5IQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@risingedge.co.za header.s=xneelo header.b=oy6s3xtd; arc=pass (i=1 spf=pass spfdomain=risingedge.co.za dkim=pass dkdomain=risingedge.co.za); spf=pass (google.com: domain of linux-kernel+bounces-100521-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-100521-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id o10-20020a05622a044a00b0042f159fa534si8125930qtx.124.2024.03.12.09.36.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 09:36:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-100521-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@risingedge.co.za header.s=xneelo header.b=oy6s3xtd; arc=pass (i=1 spf=pass spfdomain=risingedge.co.za dkim=pass dkdomain=risingedge.co.za); spf=pass (google.com: domain of linux-kernel+bounces-100521-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-100521-linux.lists.archive=gmail.com@vger.kernel.org" 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id CE1961C209B2 for ; Tue, 12 Mar 2024 16:36:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CED4F7E59E; Tue, 12 Mar 2024 16:36:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=risingedge.co.za header.i=@risingedge.co.za header.b="oy6s3xtd" Received: from outgoing6.flk.host-h.net (outgoing6.flk.host-h.net [188.40.0.77]) (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 1CBD87C091; Tue, 12 Mar 2024 16:35:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=188.40.0.77 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710261365; cv=none; b=ce6PJanakhdxhYX0kmMnkwxPUk/ryQhWSfQOzu7mLdv4rB9XnN1EmG7VeEerbaVcOSeRWkC+6cqAk/h2EaxoXYSXlMEHAwU1FhnWRPGdgW1u98lvbENECleIbRoUFjZswUs9vh1Al/0m3EGuHlo8Nq8QjhPYrCQRdtiam6jBTAc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710261365; c=relaxed/simple; bh=h0m6V52SrJe1v2wSyxARFMDVuZtknqDrGF7IJd8CboE=; h=MIME-Version:Content-Type:Date:From:To:Cc:Subject:In-Reply-To: References:Message-ID; b=fC6c1lzo4aoXih6+NITgLjDJZkKqLPQHxkkVwz2NpVD+2MjNF2NxWzuuzVhOGClNtAVj587DxH7CmEvdSA5vi4qgLYhDG62zUppoy8id0mchg2iVJzTW1drTMVX7W1ZhJKim1pXyuhHGNqYAkwJJ1mNpB520ZR3jSBpGqeC6nHs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=risingedge.co.za; spf=pass smtp.mailfrom=risingedge.co.za; dkim=pass (2048-bit key) header.d=risingedge.co.za header.i=@risingedge.co.za header.b=oy6s3xtd; arc=none smtp.client-ip=188.40.0.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=risingedge.co.za Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=risingedge.co.za DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=risingedge.co.za; s=xneelo; h=Message-ID:References:In-Reply-To:Subject:Cc: To:From:Date:Content-Transfer-Encoding:Content-Type:MIME-Version:reply-to: sender:bcc; bh=yg+g+abNrGcwEzQSWBbG2h+JPGpvEcqsYIaVOBM+AUA=; b=oy6s3xtd7jDtGp 6RPb1fsedIa8PfieDnwpdvgYnnczVWLLrzOAQzhyGUwfduVZbZDsS+yrEvgA0HDclaUMieAQRVn9/ H7XKezlmXa83mffFgtPLjzZDO2FiGPa1xuyDZ4bjqfiz3XbKzMTxfNuWvhLcvTiHV72LDMtxyhyeL 2whpDNtHlKk89s1WmLKSEgsDMZrfqYnblmj84LfBWsfWTmOXAyCgBL+8XtxRgkvBk8A3XbJ4ijESZ rL8GyZ5auxRApC6T097AoG+7oZZG6RbE1KFVqpMzKSDfEudsvVorEI+q8ZpjU2dJNdfG+Gf06KrM6 o9JMgRLlDbOd/cNfgu4w==; Received: from www31.flk1.host-h.net ([188.40.1.173]) by antispam2-flk1.host-h.net with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rk56N-007QAO-TD; Tue, 12 Mar 2024 18:35:47 +0200 Received: from roundcubeweb1.flk1.host-h.net ([138.201.244.33] helo=webmail9.konsoleh.co.za) by www31.flk1.host-h.net with esmtpa (Exim 4.92) (envelope-from ) id 1rk56H-0004yq-Ib; Tue, 12 Mar 2024 18:35:37 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Tue, 12 Mar 2024 18:35:37 +0200 From: Justin Swartz To: =?UTF-8?Q?Ar=C4=B1n=C3=A7_=C3=9CNAL?= Cc: Daniel Golle , DENG Qingfang , Sean Wang , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: Re: [PATCH] net: dsa: mt7530: disable LEDs before reset In-Reply-To: <9a7c29b51575083201b963638bdb9fa5@risingedge.co.za> References: <20240305043952.21590-1-justin.swartz@risingedge.co.za> <6064ba52-2470-4c56-958c-35632187f148@arinc9.com> <1bfd93f1-36d5-436e-818e-2ebdcf475b44@arinc9.com> <0439f80319127b6a4a9c19108bcc0065@risingedge.co.za> <6df6db7e-7842-4194-b429-ab7443a18ccb@arinc9.com> <9a7c29b51575083201b963638bdb9fa5@risingedge.co.za> Message-ID: X-Sender: justin.swartz@risingedge.co.za User-Agent: Roundcube Webmail/1.3.17 X-Authenticated-Sender: justin.swartz@risingedge.co.za X-Virus-Scanned: Clear X-SpamExperts-Domain: risingedge.co.za X-SpamExperts-Username: Authentication-Results: host-h.net; auth=pass (login) smtp.auth=@risingedge.co.za X-SpamExperts-Outgoing-Class: ham X-SpamExperts-Outgoing-Evidence: Combined (0.06) X-Recommended-Action: accept X-Filter-ID: Pt3MvcO5N4iKaDQ5O6lkdGlMVN6RH8bjRMzItlySaT+lUXMrY4PnmjnViZCjXhQaPUtb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PBsmpIto2O4JO2fx1gIuNHgi11AwJSTGCrOFs22K1ZnDqAw3gLmOBPHazhChxq9nGW aSi6bFHidB1VgzDzDZn/+QEiRQv+PVjjwa+Z5RFCOMRmYvGVP5J/K7tDFQHNyAqzdfFYVDBYJee7 gx/u82RtU9UW3dl9fwt0Tdq4PMjNsqE0mVfWLKEgol9rYV4JEcNP1rJoln/cD8h/RIvkzXRTCYvX WLQhlD92+1l+zHfJg1FMwntsduNBxKPaTpE5L8d4VqFy6yKUFQtzhTlGiGL9B0nAIzS3VGMYMsaD t/vlLode8ZEQhyUpJRaYI785W4/hIIDSVMZhrIoAWTF5tIdhy/UIEBYDcZg+Q8UhuRLyBn1+pvlH hV6a5QjptwQBGybQyDQ2/GYwPjlMcE57ESN6G+kn87CtwPdB/10jfVNpDbYnXJdSRQj8460WHJib IxmU2pb4i4DTkMZeMiNI9JSIyUbtnrlbG4BI8o81FOo91axhCaqPShJzgHH7y4ZfQxML X-Report-Abuse-To: spam@antispamquarantine.host-h.net On 2024-03-12 17:25, Justin Swartz wrote: > On 2024-03-12 16:06, Arınç ÜNAL wrote: >> On 12.03.2024 15:01, Justin Swartz wrote: >>> Arınç >>> >>> On 2024-03-12 04:41, Arınç ÜNAL wrote: >>>> Wouldn't it be a better idea to increase the delay between >>>> reset_control_assert() and reset_control_deassert(), and >>>> gpiod_set_value_cansleep(priv->reset, 0) and >>>> gpiod_set_value_cansleep(priv->reset, 1) instead of disabling the >>>> LED >>>> controller and delaying before reset? >>> >>> I've done some additional tests to see what the difference would be >>> between increasing the reset hold period vs. disabling the LEDs then >>> sleeping before reset. >>> >>> >>> I wanted to know: >>> >>> When an active link is present on Port 3 at boot, what are the >>> minimum, maximum and average periods between ESW_P3_LED_0 >>> going low and the signal inversion that seems to co-incide with >>> reset_control_deassert() for each approach? >>> >>> >>> I created two patches: >>> >>> WITH INCREASED RESET DELAY >>> >>> As I submitted a patch that added an intended 1000 - 1100 usec delay >>> before reset, I thought it would be fair to increase the reset hold >>> period by the same value. >>> >>> ---%--- >>> --- a/drivers/net/dsa/mt7530.c >>> +++ b/drivers/net/dsa/mt7530.c >>> @@ -2243,11 +2243,11 @@ mt7530_setup(struct dsa_switch *ds) >>>          */ >>>         if (priv->mcm) { >>>                 reset_control_assert(priv->rstc); >>> -               usleep_range(1000, 1100); >>> +               usleep_range(2000, 2200); >>>                 reset_control_deassert(priv->rstc); >>>         } else { >>>                 gpiod_set_value_cansleep(priv->reset, 0); >>> -               usleep_range(1000, 1100); >>> +               usleep_range(2000, 2200); >>>                 gpiod_set_value_cansleep(priv->reset, 1); >>>         } >>> ---%--- >>> >>> >>> DISABLE LEDS BEFORE RESET >>> >>> Reset hold period unchanged from the intended 1000 - 1100 usec. >>> >>> ---%--- >>> --- a/drivers/net/dsa/mt7530.c >>> +++ b/drivers/net/dsa/mt7530.c >>> @@ -2238,6 +2238,12 @@ mt7530_setup(struct dsa_switch *ds) >>>                 } >>>         } >>> >>> +       /* Disable LEDs before reset to prevent the MT7530 sampling a >>> +        * potentially incorrect HT_XTAL_FSEL value. >>> +        */ >>> +       mt7530_write(priv, MT7530_LED_EN, 0); >>> +       usleep_range(1000, 1100); >>> + >>>         /* Reset whole chip through gpio pin or memory-mapped >>> registers for >>>          * different type of hardware >>>          */ >>> ---%--- >>> >>> >>> I ran 20 tests per patch, applied exclusively. 40 tests in total. >>> >>>      <-- ESW_P3_LED_0 Low Period before Reset Deassertion --> >>> >>>   TEST    WITH INCREASED RESET DELAY    DISABLE LEDS BEFORE RESET >>>      #                        (usec)                       (usec) >>> ------------------------------------------------------------------- >>>      1                           182                         4790 >>>      2                           370                         3470 >>>      3                           240                         4635 >>>      4                          1475                         4850 >>>      5                            70                         4775 >>>      6                          2730                         4575 >>>      7                          3180                         4565 >>>      8                           265                         5650 >>>      9                           270                         4690 >>>     10                          1525                         4450 >>>     11                          3210                         4735 >>>     12                           120                         4690 >>>     13                           185                         4625 >>>     14                           305                         7020 >>>     15                          2975                         4720 >>>     16                           245                         4675 >>>     17                           350                         4740 >>>     18                            80                        17920 >>>     19                           150                        17665 >>>     20                           100                         4620 >>> >>>    Min                            70                         3470 >>>    Max                          3210                        17920 >>> >>> Mean                           270                         4720 > -1s/ Mean/Median/ > >>>    Avg                       923.421                     6161.579 >>> >>> >>> Every test resulted in a 40MHz HT_XTAL_FSEL, but after seeing 70 usec >>> and 80 usec periods I wondered how many more tests it may take before >>> an 25MHz HT_XTAL_FSEL appears. >>> >>> I was also surprised by the 17920 usec and 17665 usec periods listed >>> under the DISABLED LEDS BEFORE RESET column. Nothing unusual seemed >>> to be happening, at least as far as the kernel message output was >>> concerned. >>> >>> What do you make of these results? >> >> What I see is setting ESW_P3_LED_0 low via reset assertion is much >> more >> efficient than doing so by setting the LED controller off. So I'd >> prefer >> increasing the delay between assertion and reassertion. For example, >> the >> Realtek DSA subdriver has a much more generous delay. 25ms after reset >> assertion [1]. >> >> Looking at your results, 2000 - 2200 usec delay still seems too close, >> so >> let's agree on an amount that will ensure that boards in any >> circumstances >> will have these pins back to the bootstrapping configuration before >> reset >> deassertion. What about 5000 - 5100 usec? > > TEST ESW_P3_LED_0 LOW PERIOD >      #                     (usec) > ---------------------------------- > 1 5410 > 2 5440 > 3 4375 > 4 5490 > 5 5475 > 6 4335 > 7 4370 > 8 5435 > 9 4205 > 10 4335 > 11 3750 > 12 3170 > 13 4395 > 14 4375 > 15 3515 > 16 4335 > 17 4220 > 18 4175 > 19 4175 > 20 4350 > > Min 3170 > Max 5490 > > Median 4342.500 > Avg 4466.500 > > Looks reasonable to me. I had messed up the Median/Average calculation with the data I had pasted earlier after copying and pasting formulas without double checking how they had been affected. So here's the table again, now with the 5000 - 5100 usec test run tacked on for easier comparison: 2000 usec 5000 usec - 2200 usec DISABLE LEDS - 5100 usec TEST RESET HOLD BEFORE RESET RESET HOLD # (usec) (usec) (usec) -------------------------------------------------------- 1 182 4790 5410 2 370 3470 5440 3 240 4635 4375 4 1475 4850 5490 5 70 4775 5475 6 2730 4575 4335 7 3180 4565 4370 8 265 5650 5435 9 270 4690 4205 10 1525 4450 4335 11 3210 4735 3750 12 120 4690 3170 13 185 4625 4395 14 305 7020 4375 15 2975 4720 3515 16 245 4675 4335 17 350 4740 4220 18 80 17920 4175 19 150 17665 4175 20 100 4620 4350 Min 70 3470 3170 Max 3210 17920 5490 Median 267.500 4705 4342.500 Avg 901.350 6093 4466.500 >> [1] >> https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/tree/drivers/net/dsa/realtek/rtl83xx.c#n205 >> >> Arınç