Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp3299414lfo; Mon, 23 May 2022 01:04:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyGR7kjXKo5zHjMsZ5KjLxU978Z1O13WY1nkWuEiZb7vaRBBtpg684EsO+tA2/i41D8NDg X-Received: by 2002:a05:6a00:1f0d:b0:518:3c8d:78b1 with SMTP id be13-20020a056a001f0d00b005183c8d78b1mr21900913pfb.23.1653293063577; Mon, 23 May 2022 01:04:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653293063; cv=none; d=google.com; s=arc-20160816; b=pbv/i60tcQRyj/rUEzUIxFurfD/VztPjFbMkSAVFc2ZBxEnCFkTKd2WaBaxragLqGJ YKG+UMj6WpC5SxrMoZQiqonuRfrVIQKkqwAOPmRr+l+62QbwAuaWxn7VEOn1PhvyStiQ 2lkE7wrKUASlw4YhcPzzwe1sMcWBmpeCzWjp3dbP8liopukBLOoDUWMfp1duH6+UAqIY 5kDIIiauzLTNFR20k+euCuRAf7D0ragBAcc9fU2zzafERlkZcgAyfyPE6SEf2hSu4Zfx TjD5Ji1X4EDz6HIfRu36XNOGvV5iP847BRvrrxf5H/bFZpYpOPi/vvBNRGoaAoTdQ7FF ftpw== 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=r96J06AA/hx9f6lJVo/su3KBEml3SMC6atekdO73IQM=; b=Bs1HtQWHd0Z6LUCCKCHPn+vzjOqCWoBZvgHcx/V9EsZ0sSWPs+cxP+ra4Hd6wh4Ra3 exgZ3qLXGAOJzGNCEq6ik6R0oCFv0FhDyqQLqcqZa8OS+2Y/3C0hgLVOBFhBq+vyYJeF InAXi1Hta4XQbFTkZnej4CNFMJlKAcVhgMeE+LRaaTcsjmg6qvertmxhpPWT/GeKtuiM 8SBhoVoYfrfkvP9rVLfiYHaCfwcaYncdw33CDCSpPokBmkSdiFf/F8DrikAUbpbkpsWy 3iuw5u6IKW3wCycdGC/QIapnrF3qSF9sY6eyJ/Gm8gyEhAV6z9vl+oZ/bDTrlXJMxlIF 308g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=DA7AJxCs; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id o15-20020a17090ac70f00b001d2865c095fsi10596837pjt.61.2022.05.23.01.04.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 01:04:23 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=DA7AJxCs; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 895F54B4FD; Mon, 23 May 2022 00:07:52 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244632AbiEUO3R (ORCPT + 99 others); Sat, 21 May 2022 10:29:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235561AbiEUO3P (ORCPT ); Sat, 21 May 2022 10:29:15 -0400 Received: from vps0.lunn.ch (vps0.lunn.ch [185.16.172.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E13FE3AA5E; Sat, 21 May 2022 07:29:14 -0700 (PDT) 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=r96J06AA/hx9f6lJVo/su3KBEml3SMC6atekdO73IQM=; b=DA7AJxCsP7mGwECk9LimTyPCeq mGKgm41gxsuHHV7QhgBYxPT8DUmPSCyenxJ71/uLaEg5vufk0igLqeQ+OZFcnaYb6Aq2PRGmnwkq5 NN1bQ+lQmxVO8nAmtFk7J0Y/KM7jdI/Q7Nw67nC4GQgYTJUkYAdwWLLSO0ym/EyuljdE=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1nsPZq-003lku-2S; Sat, 21 May 2022 15:55:30 +0200 Date: Sat, 21 May 2022 15:55:30 +0200 From: Andrew Lunn To: Pavel Skripkin Cc: vladimir.oltean@nxp.com, claudiu.manoil@nxp.com, alexandre.belloni@bootlin.com, UNGLinuxDriver@microchip.com, kuba@kernel.org, clement.leger@bootlin.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] net: ocelot: fix wrong time_after usage Message-ID: References: <20220520213115.7832-1-paskripkin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220520213115.7832-1-paskripkin@gmail.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, May 21, 2022 at 12:31:15AM +0300, Pavel Skripkin wrote: > Accidentally noticed, that this driver is the only user of > while (time_after(jiffies...)). > > It looks like typo, because likely this while loop will finish after 1st > iteration, because time_after() returns true when 1st argument _is after_ > 2nd one. > > There is one possible problem with this poll loop: the scheduler could put > the thread to sleep, and it does not get woken up for > OCELOT_FDMA_CH_SAFE_TIMEOUT_US. During that time, the hardware has done > its thing, but you exit the while loop and return -ETIMEDOUT. > > Fix it by using sane poll API that avoids all problems described above > > Fixes: 753a026cfec1 ("net: ocelot: add FDMA support") > Suggested-by: Andrew Lunn > Signed-off-by: Pavel Skripkin > --- > > I can't say if 0 is a good choise for 5th readx_poll_timeout() argument, > so this patch is build-tested only. > Testing and suggestions are welcomed! If you had the hardware, i would suggest you profile how often it does complete on the first iteration. And when it does not complete on the first iteration, how many more iterations it needs. Tobias made an interesting observation with the mv88e6xxx switch. He found that two tight polls was enough 99% of the time. Putting a sleep in there doubles the time it took to setup the switch. So he ended up with a hybrid of open coded polling twice, followed by iopoll with a timer value set. That was with a heavily used poll function. How often is this function used? No point in overly optimising this if it is not used much. Andrew