Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1495404pxp; Thu, 10 Mar 2022 06:36:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJzhwfStTk/+8Mruc8N4QyFPP5rWWkqf0Jc9iaQvZ2jixg534794guw98q3LFxipDMhCYb1e X-Received: by 2002:a17:907:9485:b0:6db:331:591e with SMTP id dm5-20020a170907948500b006db0331591emr4401454ejc.478.1646922965941; Thu, 10 Mar 2022 06:36:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646922965; cv=none; d=google.com; s=arc-20160816; b=AyA3A0w1dSwuxKpvIL2Y2PL0xD45AnXxN3R75Pe5gZ0bnxGGk8qVU/CC7nSH3h7l5V HBM1j44y+Ng/vSM3c+3a1vEqVz0HygYGrvusVRPSM2UHNVpDaLX/RSpAo9cMTbUV5KiK K+fRtU5vAg6nIQa8k+pyO7aTMw/7IDfi0ZYL1WfOR48llguwgRoYILSAfq6JnteJ7Jgk b9w3ZuKOcCAf9r0mvTNBOBuffUH+lWvAD8TqoDXRjMn6I8D+PpVyvdBgSeaWAVGujrWn TozkGvh7gcD8E5+oCsBAiBXn7Qre+8Gogm9NQtqQTTb4qNlARfbLff3cCqLYAMujjWZT dQ0g== 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=rkmJFE5O1lrwsmXjWOGCeqPxWsj9wKerfoDAR9Ry8wM=; b=W1O7Kot4iuzdLVEuDMqy7sKPdagwuxWQIDdxnlLumqPRuzQ2gsq2mCc19LraIcy24P MAwgVQX01rCQSQ5eDVJqiG4LuDpoOAR3oeFcROXWDx3Ol1YkGayTJuRKTrAZMlQL0Pvx zyuY5VYVI1UZ8VXortAjIwP018jX8R1V78oh1/PM4AmkDpPKppjzEnJeLp+2MoZu5PNz Sl7I7aGYGc5Vaf7S1Vc+c+fasRgvgAV5XQIw+tmXXG7ETnZxHipVXlpYGlBZkIRnUav1 kGnJTk8cY73GcjWc3gW5AIqVhteQdJkmP65pr1UDT2uEwl5XFA6+ViETCcBE4Yqg2Nb0 3QZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@microchip.com header.s=mchp header.b=BdN5dhV4; 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ji15-20020a170907980f00b006db41df2ecasi3717869ejc.635.2022.03.10.06.35.41; Thu, 10 Mar 2022 06:36:05 -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=fail header.i=@microchip.com header.s=mchp header.b=BdN5dhV4; 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238478AbiCIWDb (ORCPT + 99 others); Wed, 9 Mar 2022 17:03:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229946AbiCIWD3 (ORCPT ); Wed, 9 Mar 2022 17:03:29 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E58A649CB0; Wed, 9 Mar 2022 14:02:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1646863345; x=1678399345; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=9+Y+W6kPpAhOBsTIr7uplKjRx92r1AT6ix+u1mTH2hM=; b=BdN5dhV4N0WwLDIEZ6bsv/aETPS9ZYvuCrl4UV30Zh5eVtEH40T5OMfg wpkIZyajzEf5frYesVogZMJ1vjSqzog6PcNXarvFLkkZnj4RBh5PwOCkj gZiFKy3QZEL9UuX+AENUR76cU1YGhSee9moAkfv6rrbZzwJYuQC2N6UHK RhO1uqG7KoGKHGLeZtD10e3Rw9HAyqsSFTIpKOwAncsO7wYCB7fvMz4iM PrlShOw9vbIMRsfnWQlmLUqHqOwv58btvywROzn0lxGUg2YQ7fzDPkaRT SAdchBLma3w4p4v3/JPE334GEJkE00CeMerkKpJpNJ0WiU6mZiJ76nryd Q==; X-IronPort-AV: E=Sophos;i="5.90,168,1643698800"; d="scan'208";a="155874789" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 09 Mar 2022 15:02:24 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Wed, 9 Mar 2022 15:02:23 -0700 Received: from localhost (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Wed, 9 Mar 2022 15:02:22 -0700 Date: Wed, 9 Mar 2022 23:05:16 +0100 From: Horatiu Vultur To: Andrew Lunn CC: , , , , Subject: Re: [PATCH net-next] net: lan966x: Improve the CPU TX bitrate. Message-ID: <20220309220516.smxhbtikbvctlkeh@soft-dev3-1.localhost> References: <20220308165727.4088656-1-horatiu.vultur@microchip.com> <20220308223000.vwdc6tk6wa53x64c@soft-dev3-1.localhost> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,T_SCC_BODY_TEXT_LINE, T_SPF_TEMPERROR 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 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. > > iopoll does another check of the status before deciding to return > -ETIMEDOUT or O.K. > > If you decide to simply check the status directly after the write, i > suggest you then use readx_poll_timeout_atomic() if you do need to > poll. > > Andrew -- /Horatiu