Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2742038pxb; Mon, 31 Jan 2022 03:22:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJyxwaCMNHUn2VriaYTSvimlvKoET+H4q2R5+1nJxont2Jw2sy1wtvDvOD9IUJ5kjwdUSWXA X-Received: by 2002:a17:906:43c4:: with SMTP id j4mr16829346ejn.679.1643628166935; Mon, 31 Jan 2022 03:22:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643628166; cv=none; d=google.com; s=arc-20160816; b=Kie5kjjz/VNWuUZFLfCWSCtijTYxBVrSV9R5uAv7aGeThRJS45YK4U1Oo2o/d9r5qq e7UL28Fi6GFVYAQz+0WUw+IeFotMLVyxzttkjcf54hg9asiVOsU/kjTsk6wTCwS5hSQy ul/oE6EhjeReG/JXlaTrYAr8zi0WVn6bPPz7fiOyocGU7Q6EpCOoDn4ynVpgYd2+4KLO xqcW4YdebuBycaV2EfaTCRG8sjRm8afh9Fts5F0KNVBQTQlJ4Vqx3omfzu0KdmmiwlJQ 0QTWKdSzO2oFzHiBWr/VMvQ3gHyla/dvldwxMFJ74EgWZkm7lmlAC4hwGDotCWWpbyEj tTIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ThL5B3SxUa7qxAOrbzfcl7naTiKrbrgrI94+8lWwPms=; b=SJr0/gylzYYf5DZ/9QbyI40Cjx/Vb+rKzwg88BTOEKXKmTJPWzlLmZVsUEgPF2R1rK l5PNUmC/tqEcclJvZF9UClcIpfhOltyf90sFH6xBNXPj2TjQcOvD4mK997CXEmG8dIr3 K6jP+DDriTaEMKIWw5UuEWF6zCbdtNKj4J6HuzRoKEMR6EiLtctLPq+c+H3du3kftC2g iuNrBXASM7PVp6Ct4R5LHE265QBVQIysi+XJXvQPFUxv64oAaLHWWkPetp2V4l74m6EK fBVK1YfBZlQFNkd1aX0fIufIo2v2Fxr3QIyQm1iUTdDvpKXZFw8xLjfgqAc2+XwJTdQr O3iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b="RBFksZ1/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m9si4827634edd.66.2022.01.31.03.22.21; Mon, 31 Jan 2022 03:22:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b="RBFksZ1/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343534AbiA1RRb (ORCPT + 99 others); Fri, 28 Jan 2022 12:17:31 -0500 Received: from vps0.lunn.ch ([185.16.172.187]:60638 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237031AbiA1RRa (ORCPT ); Fri, 28 Jan 2022 12:17:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=ThL5B3SxUa7qxAOrbzfcl7naTiKrbrgrI94+8lWwPms=; b=RBFksZ1/XbrW4de45UCM4rl41F hXWBlKHI3PMZ4oDkc8yRK1nCjlIyrQmKxYcQuT/LhBFvtIkeOKeDi1pjTXaRT2XA7jrq8JX2fq04M amBBaM8ptflnIEZ2QkPcgM+31R8Dm0P77UmHloNn7Y/ZJ5KU4P5HLMjle5uP8OsvF4dw=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1nDUsD-003CdP-Bm; Fri, 28 Jan 2022 18:17:21 +0100 Date: Fri, 28 Jan 2022 18:17:21 +0100 From: Andrew Lunn To: Tobias Waldekranz Cc: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org, David.Laight@aculab.com, Vivien Didelot , Florian Fainelli , Vladimir Oltean , linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 net-next 1/2] net: dsa: mv88e6xxx: Improve performance of busy bit polling Message-ID: References: <20220128162650.2510062-1-tobias@waldekranz.com> <20220128162650.2510062-2-tobias@waldekranz.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220128162650.2510062-2-tobias@waldekranz.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 28, 2022 at 05:26:49PM +0100, Tobias Waldekranz wrote: > Avoid a long delay when a busy bit is still set and has to be polled > again. > > Measurements on a system with 2 Opals (6097F) and one Agate (6352) > show that even with this much tighter loop, we have about a 50% chance > of the bit being cleared on the first poll, all other accesses see the > bit being cleared on the second poll. > > On a standard MDIO bus running MDC at 2.5MHz, a single access with 32 > bits of preamble plus 32 bits of data takes 64*(1/2.5MHz) = 25.6us. > > This means that mv88e6xxx_smi_direct_wait took 26us + CPU overhead in > the fast scenario, but 26us + 1500us + 26us + CPU overhead in the slow > case - bringing the average close to 1ms. > > With this change in place, the slow case is closer to 2*26us + CPU > overhead, with the average well below 100us - a 10x improvement. > > This translates to real-world winnings. On a 3-chip 20-port system, > the modprobe time drops by 88%: > > Before: > > root@coronet:~# time modprobe mv88e6xxx > real 0m 15.99s > user 0m 0.00s > sys 0m 1.52s > > After: > > root@coronet:~# time modprobe mv88e6xxx > real 0m 2.21s > user 0m 0.00s > sys 0m 1.54s > > Signed-off-by: Tobias Waldekranz Reviewed-by: Andrew Lunn Andrew