Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3464893rdb; Wed, 13 Sep 2023 12:53:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFusxqkJAg8JdzvCtkIieUrzpf8T4YGieGlqALx/BeBIACP5cBAvyDlgD8f48j+j5yuPY0U X-Received: by 2002:a05:6870:1495:b0:1bf:6ec:dd4d with SMTP id k21-20020a056870149500b001bf06ecdd4dmr3913254oab.28.1694634786938; Wed, 13 Sep 2023 12:53:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694634786; cv=none; d=google.com; s=arc-20160816; b=Q/Y0uW8t+MXC4kIHytao1DlKDMeT4lP1oSJbp+V+70kV54zkYxNHi+vL+pTBRxktB/ W3o/ueme9r/I6da6cBBWxhqcb9JaOxvIqUz6R7dXyGemo4TZF/5KsomXkaUDqFwJr/JD wmjWWK2v80Lgy6hGuVfjs7JDpuGIlzEuHelz7++KI+TPXDl64vN3awWozh/00P+n5XeO IbMsqh6/imbzE8nfb5CqUwwv2iHplqmw1ooblgH7iD4d5XQYYEkifhhTGcqJ8Asn7OJx vuJYl0J76aaqv89zMw9CwHV8M+DfW/rAx1vBeXVSK8sJZuPmMC135C51+lND7NJIGnK2 Hjkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bnLlBCmtmpQwQX7mUFEwOLmXNNLfxSSVf+nmIrWyOZs=; fh=30kAl1g9AkxuEgeaYxsvI/0nj7uz2Q8n1xb6SNv7Q9s=; b=kITmoP/64Xy21SOYsIFnEkYA3ENM5VVY3qDncdEb/dCMinaoqeyhIkJUs/+LcY+uC/ pWhSSw0zO06FdPDdWa4ufIbeJyDl3r/k2lvSkEO5EymjakR+8YMcdFWv4f6OHhn/GTI4 TgrOAzEi0UIVcHJd4kyQq/4CYB486lhsVuGd8aD/O9stzZBCsI8WhB4HQXDYStk0RGHV BpT/YzDW2ZpOBDxD+yntdQZR2n1r2qN71oy1z+/+izjWQHgtn8IRIQ1sPUDzTeKQP+Gk DQFDtwkagW71Rs7e6ThXYA9Fb0ac3uG6PWb5VjchVuW3S1GqR2RDr6XbuS84crYj2d+G ErFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=EYSrpED2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id l71-20020a63914a000000b005740e906e55si9450376pge.37.2023.09.13.12.53.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 12:53:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=EYSrpED2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id E7A9D8153D16; Tue, 12 Sep 2023 05:26:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.8 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235113AbjILM0a (ORCPT + 99 others); Tue, 12 Sep 2023 08:26:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235140AbjILM0N (ORCPT ); Tue, 12 Sep 2023 08:26:13 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E20AC10E3; Tue, 12 Sep 2023 05:26:08 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-502b1bbe5c3so4277767e87.1; Tue, 12 Sep 2023 05:26:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694521567; x=1695126367; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bnLlBCmtmpQwQX7mUFEwOLmXNNLfxSSVf+nmIrWyOZs=; b=EYSrpED2Cj87rwpIj26QLhbqEhLfgTWxmFxunudHer/hmDZkZy9DTJDmuh6LZh5wRZ kKpLbwF0mYSMO/GiKr2WWuNFYPs2M1t8xf2aNf0VhcEpUNgIsOS7dB4Ipy/WdjkO1KwA 58e17DgoSo5bQGUfqbrHi4luJuCrusUGNC94FqYEEy6DeY08O4OedEP/gQkgHtonRSxf Bpurbv22SQmU4NaCjNYhHJZFTmlmGB4BklTVbdrqZfbM+uUI7aaXD7M+VUyMIJhO+xBY VGUVo2OA/twMS4E71NKIsA04wxUFQXUstFAZOGpGYSfX5ptTly2p7ncx8JpGaf0GajMb EwCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694521567; x=1695126367; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bnLlBCmtmpQwQX7mUFEwOLmXNNLfxSSVf+nmIrWyOZs=; b=jBpc5nZC6pdPjNWGKlC1PZU540ud55MqC5LQVEb4MMgDrKGMRdUIns0krt8IV2RvTO dRR89kV/IgImZAoWbJQTrixaBlRkSNyqwgIfs62G4yNjtxXOE4uPctYIqO+qZFDZUzsG D9kBFrJSKRSpYtDtC8Mx/rihsd4tP3Pe+LBGzL0Ib8cW/QNGmyVNdCW8s5Nj+RNQitVo Q/DGauUQ+gtmFllOdT//7sqb4vIRx9RTInIKm3JK9BlzH6uVE0f8OnURKpXgABgEckGh +Hw/qftOK4bLCgUYp0O/uS/BUxtxECqTnRkNJN+A/BlGI41+s16Bu/KB9SN9mT+4UvXN OVHQ== X-Gm-Message-State: AOJu0Yz72mpFT6IOO+AbpQCEBi+h0FbdcEWVOp75ZDZe2zDKr7bZiXxL V/eEhf3A704xr44ywOTUFuWlnXbpdt2ecw== X-Received: by 2002:a05:6512:15a3:b0:501:c1d4:cf68 with SMTP id bp35-20020a05651215a300b00501c1d4cf68mr12169998lfb.15.1694521566405; Tue, 12 Sep 2023 05:26:06 -0700 (PDT) Received: from WBEC325.dom.local ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id g21-20020ac25395000000b004fe333128c0sm1737327lfh.242.2023.09.12.05.26.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 05:26:06 -0700 (PDT) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: Dan Carpenter , Simon Horman , Pawel Dembicki , Russell King , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel@vger.kernel.org Subject: [PATCH net-next v3 1/8] net: dsa: vsc73xx: use read_poll_timeout instead delay loop Date: Tue, 12 Sep 2023 14:21:55 +0200 Message-Id: <20230912122201.3752918-2-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230912122201.3752918-1-paweldembicki@gmail.com> References: <20230912122201.3752918-1-paweldembicki@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 12 Sep 2023 05:26:29 -0700 (PDT) This commit switches delay loop to read_poll_timeout macro during Arbiter empty check in adjust link function. As Russel King suggested: "This [change] avoids the issue that on the last iteration, the code reads the register, test it, find the condition that's being waiting for is false, _then_ waits and end up printing the error message - that last wait is rather useless, and as the arbiter state isn't checked after waiting, it could be that we had success during the last wait." It also remove one short msleep delay. Suggested-by: Russell King Signed-off-by: Pawel Dembicki Reviewed-by: Andrew Lunn --- v3: - Add "Reviewed-by" to commit message only v2: - introduced patch drivers/net/dsa/vitesse-vsc73xx-core.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/net/dsa/vitesse-vsc73xx-core.c b/drivers/net/dsa/vitesse-vsc73xx-core.c index 4f09e7438f3b..b117c0c18e36 100644 --- a/drivers/net/dsa/vitesse-vsc73xx-core.c +++ b/drivers/net/dsa/vitesse-vsc73xx-core.c @@ -779,7 +779,7 @@ static void vsc73xx_adjust_link(struct dsa_switch *ds, int port, * after a PHY or the CPU port comes up or down. */ if (!phydev->link) { - int maxloop = 10; + int ret, err; dev_dbg(vsc->dev, "port %d: went down\n", port); @@ -794,19 +794,16 @@ static void vsc73xx_adjust_link(struct dsa_switch *ds, int port, VSC73XX_ARBDISC, BIT(port), BIT(port)); /* Wait until queue is empty */ - vsc73xx_read(vsc, VSC73XX_BLOCK_ARBITER, 0, - VSC73XX_ARBEMPTY, &val); - while (!(val & BIT(port))) { - msleep(1); - vsc73xx_read(vsc, VSC73XX_BLOCK_ARBITER, 0, - VSC73XX_ARBEMPTY, &val); - if (--maxloop == 0) { - dev_err(vsc->dev, - "timeout waiting for block arbiter\n"); - /* Continue anyway */ - break; - } - } + ret = read_poll_timeout(vsc73xx_read, err, + err < 0 || (val & BIT(port)), + 1000, 10000, false, + vsc, VSC73XX_BLOCK_ARBITER, 0, + VSC73XX_ARBEMPTY, &val); + if (ret) + dev_err(vsc->dev, + "timeout waiting for block arbiter\n"); + else if (err < 0) + dev_err(vsc->dev, "error reading arbiter\n"); /* Put this port into reset */ vsc73xx_write(vsc, VSC73XX_BLOCK_MAC, port, VSC73XX_MAC_CFG, -- 2.34.1