Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp200003rdh; Tue, 13 Feb 2024 14:08:27 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUN7X1/iwWu5q31fOedgaSEU3oVP5TII1fk5oDuUOR9jWxm0iI/CVkg3Qsm/SVuAXd1tEbGtRwJ+HGrgJRg6f2NDuqAIOPtp9JjulPiKA== X-Google-Smtp-Source: AGHT+IGSVusfqs/fxhSUMmn73qdQnnTwnva0U0mmt3tOBEtFMyXYPBSjLHdqcWlMDoX0axsghXdJ X-Received: by 2002:a17:906:e05:b0:a3c:e549:eb49 with SMTP id l5-20020a1709060e0500b00a3ce549eb49mr432213eji.70.1707862106972; Tue, 13 Feb 2024 14:08:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707862106; cv=pass; d=google.com; s=arc-20160816; b=X6Nv6YjYHF39jomHEAaucUaDylQmvM2rW6AVpO9AO+0fzS5I6tAAAHE0uP1txmjWrF JenxLhMGiIQYMgjqJOF20HfiwlwbbP9jNSaUDFBTGYCOXPgX1L8DnK2smq2f+zsgmAZk 1jjrV/3uPNuTNhvFYtdVODsvhdN96z20qTKlCsnjw8YaOmAg5H/Wxc0xd3/p/IzxRvhp ZIrdypXVXrrPsTA7vUbpb2D8CyAkvtGuzuoD5KlWLC2stLbHYeaQyr5MgrJaDDUGjkyn HyN+htpgMMI1NZH3EDUO7VVrPZCrGya2k9Iwcv9F95kSKhozrdT0FbXS1MGTofco4ufa YuwA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=silDmACUiIN4OlWaMhBDDBG9aJpm66HeXuSytRzPWjU=; fh=GvvWebHs5ud7vqexnT5l1Xs/elCTmB48MU9zU0B545Q=; b=lthMCe4zaElenR7/MG/wwQDnqs2EClnMb/MuHW+l6XIVoE8LiTVe4XtWZbfLldcO3L 2bMD6zq5DwLJrHJwdij3MPm7Nmh+Gdlygsb0qJD7uc92Z7H8RPV92FzTwaY1chqDXXpd h7MS/2DsiXbXyoBqWEPe3ReokfpTiXKcMZomo8H5JTd9MDO5N2g/7Q1IfETf1xNZlLLn NnmbmelbXz5Z42mRA9yqIBpi/sWBxegoq2Q8DeNt4i4n4F4R5ExEwY5/H3xGcaX3to2x uV2TV5fyZSi3B+76rJyGWoY0T8e27V9+2SZcVDoM1imEaId8kAaw04ByR9A2fU1a+M7z fzDQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=jXwLVOO6; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-64420-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64420-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=2; AJvYcCW8sMvbJGk2NQFGNhMBDAgcDZEHF0KzW9EgEvqA/w00eusDRPRRBymFwycyshWiWxak/fpaL5TLxqZv2D1ME2kZrOOTSpp7vhv8gWHlQw== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id gg7-20020a170906e28700b00a3d3a600f28si84342ejb.444.2024.02.13.14.08.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 14:08:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64420-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=jXwLVOO6; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-64420-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64420-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id DD1971F291AD for ; Tue, 13 Feb 2024 22:07:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7BF2262813; Tue, 13 Feb 2024 22:05:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jXwLVOO6" Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10BA16217F; Tue, 13 Feb 2024 22:04:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707861902; cv=none; b=ipKMfI2ucwY7kPXyvrk1aGVt05wunZuwSHDIaXwCUJESUQqIGCpuPWW85OethdYQ1NReRdzbZEGbSAxQdN0UhiUNTetowgsNHMCk2oEniRRFSpXWuxT3IjWVbP2ZDmRyPu+5i5XeWAcEPMa3PSZ4VbuPGsnUl1nwZgNv3kR4lxg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707861902; c=relaxed/simple; bh=yNXlZ++7NAGaOX0YYjxHAN+47k2zU7Fw/VvDET7htxY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BmgwyV5A8cCsfEge+beTXBVN8eUBDTTqIt6x3A5CGBfKuTY33WjLc1GTF8M5sLH9lc9J1h3LkScHZYbZ3umUtpxdFJuuCOHqzn7x9zhXzQLBWemBImZsIiPKFDLTyLPm1F68g+OfW6noSg988oY9HBmSwrD7VJSKopxZIyiqWJE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=jXwLVOO6; arc=none smtp.client-ip=209.85.218.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a3c1a6c10bbso421905266b.3; Tue, 13 Feb 2024 14:04:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707861898; x=1708466698; 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=silDmACUiIN4OlWaMhBDDBG9aJpm66HeXuSytRzPWjU=; b=jXwLVOO6EOauyFKCsoWBBdPtHNxyhAYfovuE8UflP7BObmCfpNI1v7sOQAJLEPj8s9 Oba80e+noQlVz1a9oWnTOSdO+5TZJb7bUN39nFrBUtTJMk9YQTU7fMxEopEJgrO6r4f8 wbFLmWWn6lvXo1HrJisq4CfslYGqnYg2z5J0cb1EcLUDPyBr/MeA+b1EbIqHtNhnxhh+ XASmlWZazy15XVzWXdBrtX0OengYrnY9BdSs9VxFx0xUSSxTqRwqBq+KqDbsqq1TtXy3 7cbsyw2oEPfm69BSY2JQy9rGr/0gL8jKqaILwMASEOnH9q49dbY2Oc+JxtDrZQurYc7S qlzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707861898; x=1708466698; 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=silDmACUiIN4OlWaMhBDDBG9aJpm66HeXuSytRzPWjU=; b=VejM2BBvn3mUeI7kPl/x+AmCCmOd/Pu9IU8+mzBdSkr9oPiz2Pjb4xK5gGpf2IGdM+ RvygogrHGixEKcCdy4oMqVUd/KGTPldOx/ckFy5M4vxL+auHyZE1uL2fqW6j3Zs7Dy9J 9Z/vGdJyrwBINYNd23ow7neDHJHcYGmhJpFyrtWLdw72v+KikfuMyBcvMslFHLUVSryW ErnWEum+JceEZxq6VNGwoOEETy/egPSQIbKPPYG62dTjPXmHOQu21srtofALyjORNhOQ lo6Ad1IC2LNGaQCvh1QfsQ5ZJW6eon4Os79Y5CT0Sdce+9z6Tl2pgozYI5NBqOUL8C4p ylBQ== X-Forwarded-Encrypted: i=1; AJvYcCW5ixz+1kLO/h/FD+RcMQpXSciQA8raUm3Yo9ZHLZ4ZWW8vH2ljYFqlvoynATHi5SAHv3duwoEOXl+O/7acgsRruVlet6aIFcvURotH X-Gm-Message-State: AOJu0YxSK/XlVSMyNKXjUgo8tCvWZykU6vhW3aXtCXql9GUhg8fct0ei 9Gzc5g6wxNgxK8KRhwNcECWJhDyfsbvsTHIYSL2/nAGWLQgONDPofEsh1EnnYJ4= X-Received: by 2002:a17:906:3942:b0:a39:6c07:d31c with SMTP id g2-20020a170906394200b00a396c07d31cmr421164eje.25.1707861897737; Tue, 13 Feb 2024 14:04:57 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCW2XgLzqsfLyjsePJy8TDVdmG1U/m0sZ2DzjH2daoQnPowSsVcGQ6863Gp850N7ma9gdoUnjdSurb74OPKWC+WV/3vEH5gVhcoqgKTJb4cXdn9J8VAuZNw8c4TKVbo08QGtvvRqNGyAQIPB9aXd7RGYZ/5hD1MlqnjRF90+6v3Nxo4rE+EiWw7ZlA6ZabpArjDY1G0Vo/G9lbSNZzW7M3cDPE8G3BrdJXfHDN01JWQ31UQ3+LnoSuS4yMR+Fu9l6KwB98eg4Y/VDfvfrcZ3ZdaCN+eQr4NByJAqnDk+I7SL4O+3Wk+IjgBh/rUBBV93GB3BGS1IBG/LxqbImiRXmegYczs7ZoBfFTjP2lT0n7Yd7U0c3KaCbsg7aFt7t3kMfvLxPRIU9wPKMEBszbKj0xVqThhLrn6sqHqWTsOTVsW9ErEWzkdNO2KyfXs6IQmekXXr5t/Lsvr6Dw== Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id p12-20020a170906b20c00b00a3bdf8ae86asm1706800ejz.10.2024.02.13.14.04.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 14:04:57 -0800 (PST) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: linus.walleij@linaro.org, Pawel Dembicki , Russell King , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, linux-kernel@vger.kernel.org Subject: [PATCH net-next v4 01/15] net: dsa: vsc73xx: use read_poll_timeout instead delay loop Date: Tue, 13 Feb 2024 23:03:14 +0100 Message-Id: <20240213220331.239031-2-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240213220331.239031-1-paweldembicki@gmail.com> References: <20240213220331.239031-1-paweldembicki@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- v4: - Resend patch 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 ae70eac3be28..8b2219404601 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