Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1020796pxp; Wed, 9 Mar 2022 18:52:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJzoxpMqhLqgej/ptT63nFKUQiPy0PEucwUWwQG05VpMRwL+LQLdFhf2IPjLkNtGWmr3+W9c X-Received: by 2002:a17:907:7208:b0:6db:7c8b:9798 with SMTP id dr8-20020a170907720800b006db7c8b9798mr1883669ejc.725.1646880731066; Wed, 09 Mar 2022 18:52:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646880731; cv=none; d=google.com; s=arc-20160816; b=xEaRJD9cby0bWSmkarvtJdKTeAVDzulO6jBroSU9drKKkhUjNUUyHr28msojp0IOaD XEhq4v29MAPg9sfaO40MsbWALlllApE5+7NKJRFqaOvHwceJ4a/LRxRmX+1L6j32Jhvu eELu0UKf4auIc12Rwg6uTb50hhayHBRy7QAUTDbQpeO9adIhXsmULp+dcUSFxLWL5PSf g9wZs6Pg6Sl2n58jjEQxE1VJy9KNmGGnbHV/Ust9TVz3a8DGzqqCjSVOSh4G6bF1dqJB JZQQg56asMftM52OCjyhP2SX6T4MpP8Zan+F6Og1MNWEKMLm36K0wAoEBl5XQqenATH1 Fgvw== 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=qkSw8hFepbS/+lTKiAiHCLoo8HAGpSWpJ3J4XSJ2/aQ=; b=Uy9ETJU5TppB1tIKso83rkrg4FWXgSvzbPYlDZdct9rFV0rfbZU2e/RdrVH06pq5F9 W08qlxPiQ7n8SuA3ohORPLpMgPmi2yuXdGaSKMEDOBHj/0mnaEqMtee3EAHmRcrjUsDq bUxMj0gt3n3Yun2c8mWjfkzea15SKxA0PvXYMsEf71XL4LExhu0sGwR0yqz8vbScVku8 C3R0S2FrHuhnHUYF0DeWzyCC6qrXS35ohB4iMLZx4U7QegsN4k5aR1RL9sLH8/+xRbNJ UJQk6kZ1bQYRtGF78zmjJMGg/UwdskiTfP8zwaAVxIFiWKRDcD0PAgJglcdJQ6yKskLl HdtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=NgwZf8pA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e26-20020a50ec9a000000b00415a08307cbsi2677105edr.382.2022.03.09.18.51.02; Wed, 09 Mar 2022 18:52:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=NgwZf8pA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238999AbiCJAiL (ORCPT + 99 others); Wed, 9 Mar 2022 19:38:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239124AbiCJAiG (ORCPT ); Wed, 9 Mar 2022 19:38:06 -0500 Received: from vps0.lunn.ch (vps0.lunn.ch [185.16.172.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC4F511EF1B; Wed, 9 Mar 2022 16:37:05 -0800 (PST) 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=qkSw8hFepbS/+lTKiAiHCLoo8HAGpSWpJ3J4XSJ2/aQ=; b=NgwZf8pABSXEAREtCZ5A0GPZeh 0pqAIZgLqe9RaJebDPGZT5iu/UrxJWB0fQPQ3jAqT5NpCASIlahl8tuss8BvunFNULc3b1P9c4S8e GHlvxc3DuregtawaU8CkNnblPsxCmtJ6WkEjGeYS4ja7Y9PGgEXDweHzsm+eGhlBsucs=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1nS6ne-00A3wA-TX; Thu, 10 Mar 2022 01:37:02 +0100 Date: Thu, 10 Mar 2022 01:37:02 +0100 From: Andrew Lunn To: Horatiu Vultur Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, UNGLinuxDriver@microchip.com, davem@davemloft.net, kuba@kernel.org Subject: Re: [PATCH net-next] net: lan966x: Improve the CPU TX bitrate. Message-ID: References: <20220308165727.4088656-1-horatiu.vultur@microchip.com> <20220308223000.vwdc6tk6wa53x64c@soft-dev3-1.localhost> <20220309220516.smxhbtikbvctlkeh@soft-dev3-1.localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220309220516.smxhbtikbvctlkeh@soft-dev3-1.localhost> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 Wed, Mar 09, 2022 at 11:05:16PM +0100, Horatiu Vultur wrote: > The 03/09/2022 14:11, Andrew Lunn wrote: > > > > On Tue, Mar 08, 2022 at 11:30:00PM +0100, Horatiu Vultur wrote: > > > The 03/08/2022 22:36, Andrew Lunn wrote: > > > > > > > > > static int lan966x_port_inj_ready(struct lan966x *lan966x, u8 grp) > > > > > { > > > > > - u32 val; > > > > > + unsigned long time = jiffies + usecs_to_jiffies(READL_TIMEOUT_US); > > > > > + int ret = 0; > > > > > > > > > > - return readx_poll_timeout_atomic(lan966x_port_inj_status, lan966x, val, > > > > > - QS_INJ_STATUS_FIFO_RDY_GET(val) & BIT(grp), > > > > > - READL_SLEEP_US, READL_TIMEOUT_US); > > > > > + while (!(lan_rd(lan966x, QS_INJ_STATUS) & > > > > > + QS_INJ_STATUS_FIFO_RDY_SET(BIT(grp)))) { > > > > > + if (time_after(jiffies, time)) { > > > > > + ret = -ETIMEDOUT; > > > > > + break; > > > > > + } > > > > > > > > Did you try setting READL_SLEEP_US to 0? readx_poll_timeout_atomic() > > > > explicitly supports that. > > > > > > I have tried but it didn't improve. It was the same as before. > > > > The reason i recommend ipoll.h is that your implementation has the > > usual bug, which iopoll does not have. Since you are using _atomic() > > it is less of an issue, but it still exists. > > > > while (!(lan_rd(lan966x, QS_INJ_STATUS) & > > QS_INJ_STATUS_FIFO_RDY_SET(BIT(grp)))) { > > > > Say you take an interrupt here > > > > if (time_after(jiffies, time)) { > > ret = -ETIMEDOUT; > > break; > > } > > > > > > The interrupt takes a while, so that by the time you get to > > time_after(), you have reached your timeout. So -ETIMEDOUT is > > returned. But in fact, the hardware has done its thing, and if you > > where to read the status the bit would be set, and you should actually > > return O.K, not an error. > > That is a good catch and really nice explanation! > Then if I add also the check at the end, then it should be also OK. You are then just repeating code which is already in the core. That is generally not liked. If you find reading the status once works 99% of the time, then i suggest you call readx_poll_timeout_atomic() when the status does indicate you need to poll. Andrew