Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp3190050rdb; Tue, 6 Feb 2024 09:34:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IH/YVJ38oSZnU9elH5zpBjURPylKim/OTV7JAvwzIdYQSiDxutilYIuKCHZNMal3sbbGcBN X-Received: by 2002:a17:906:8a57:b0:a29:4267:ac9 with SMTP id gx23-20020a1709068a5700b00a2942670ac9mr2166604ejc.52.1707240896945; Tue, 06 Feb 2024 09:34:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707240896; cv=pass; d=google.com; s=arc-20160816; b=HHaw4VJQrtkVM5qox73G8rflVMEfHZ1uMsnEdwEHIsl7rmLDaLqkrnVtmpvnV+26xt AoxhfXHeBXzOaYTCn2EweAwod/oQwCKoTAF37BhFBAcEtZbyLxlMrz44kq6neiQ6Dn5T 0TlwFypXzDAjv85iIQrZX69ovHpImmU6NAx7fkCkFppMqerDeGtC9mtLEGzHmY81cZ1e /H/ZAT5ZjIdU2iFt+YCr8AuJzlaQCpOBLUGXaB3dfPy2w+nYryBb7VXyw2M4GrWtjO/5 X2RXKpfBBb0dzWd7jkJZI2v0nBkEsPK5mRNd4tKL7PiGdI7ogdg4j17HarX7JvrPFfFq BXPw== 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:to:from:dkim-signature; bh=f9ktY0liDe4oFr0FI8er2FX43RIFT8krH3jH7tSCLC8=; fh=Tb6G4H8BHmcEuLma9zEIjy50N659tQ1Z7jbPdGuo6jU=; b=ZE5hEiahHe1DzvSWxWjHNDNgX1XYY75VFxxjGm6ptXPeKHiOLC1HzWxcIFWORZ4xoa 1DfCkUlafsrMyfpLFAqUAB0A2qO6pdfpwcmCNOI9o/CRVpETsYaOcv3zI1sRBHoJws/a uHZxSyzKGmSlSI/Eyi6GkfBTclg6EPsoXjeD4keBvbumA0D2pOaQPzvLr5jnw4hx4X2z M/NnU1a/zZoPFBHQ8PPPjGiwD/G1LWeU2D9UPlwjgcQMNAX9QH9vvxqmBXmBvP/Cy7Er s4oETxZEmWxkLcN1MFMim0ypkHKvjavAR/+aUKEQHpVFucSxVLr++0XqPyyaS3f075pp ubjw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=V5AgS47d; 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-55388-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55388-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=1; AJvYcCWg/IKwxYF+nfst9uL1SILAIwAsknxuqabL4Px36S77SINF4FQbmdtKv1ygZC2IDbdQRLuEK+X5zLxqFMo3vMebF9NoBaYsFc1nGcrstQ== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id hb14-20020a170906b88e00b00a37b7d35f56si1313145ejb.16.2024.02.06.09.34.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 09:34:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55388-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=V5AgS47d; 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-55388-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55388-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 83BE21F2755B for ; Tue, 6 Feb 2024 17:34:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AD84B1758F; Tue, 6 Feb 2024 17:33:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="V5AgS47d" Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 D19761426E; Tue, 6 Feb 2024 17:33:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707240787; cv=none; b=TEShTPO67NXizj/s9QnpycaiH0XNn88VoLxiMEm2ltoITrOYELz1ZdmqHItTnSn53BLRBVylX4ONTsAVhQ0mo/yTKc05VDJj65PZuCsXX8KzKLwvBtp//tYcF08fLRpgYwzSeRdb3nsVRBbI3V4+xsg2ENh5xUOtzKuB9oR8b8I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707240787; c=relaxed/simple; bh=GfIE22OybaPa3DRd0WpoTsg7iaxG7t9NSj5FJLsMdVE=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kOStpf7uQO0WVLdQ4tcDRXvW8hluX0jxFhrkeHf/vJb6r8WSUyDJLJrnxveVR+BJH/NaXl8pIdaLWklkqSWOWgd78ZjLyyPngVJ00ydWzBoiuKogJAnQ1TRF0QJ77LQOyFZ/fPxSiUHoUOiGURLonzzkvEsaHLAI+YT9sjyto0U= 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=V5AgS47d; arc=none smtp.client-ip=209.85.128.54 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-wm1-f54.google.com with SMTP id 5b1f17b1804b1-40fc52c2ae4so41420745e9.3; Tue, 06 Feb 2024 09:33:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707240784; x=1707845584; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=f9ktY0liDe4oFr0FI8er2FX43RIFT8krH3jH7tSCLC8=; b=V5AgS47dE0YQ9VIPCO84Zv+BuymMykVRfWmdmtWMBron0blIuK1QLIo/wXIOUpMmNi J0bHUMJSo+DCgoVKj3fG983WohpGyJ8sm2hqGutp2+7MaUbS6Crk49Yy/ZIvtZ7W68VE oPMQNaT0d84qNG7zc6Z0G7iDwPlRrNxzAeo0y4oicHynb5DdqZzfDAaSTRppmLn4vgak Kv2OYqRNbEiGM+goPXM7MVVOpkGAvY2SdF9Yle/GL3uRYkyG5T9pM2KgaKD2fINiWSGB HplADSrKDSlaHID499mPocNGYNkKSwE2ajfg3qWScDroHMfbgFzVapF9fiMVQquTyOiN XJOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707240784; x=1707845584; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=f9ktY0liDe4oFr0FI8er2FX43RIFT8krH3jH7tSCLC8=; b=T/x15cw/S+O0Hs7hdmMZRuu17xekag2VUaO/U33OkZbEr0Z5OFv2Ir+I5qq+Bpg+zg LEYRPr+IRRzWAQ9VU2DYhza5BTKD0G4q7gw8n/omq68hoyFKLN8Uc0uBT2zkNiHoydvQ LPsvWICEuCRnNXd9dg7UigYMGDIS0tOtclomEuNxJMXVCOrj5t1MMJRTH04iytimKYW2 zLtwqoHBpjJVrgf1GEh+NJoFH66bH80cdgiQruaWt77ZYGCzPuWHx0Uj49p47vkFFs3C TFzPdX5kzDUzpO1wqmpn3ym6+GoPKH87+uRokJzL0V+/yZMHpLPUqpAv+fh9Kw9pihOV dQDg== X-Gm-Message-State: AOJu0YwxscUaB9MpCIuV84WM5JcFOM2+cQ80NvzFkO0xGm1Qqa3+/G6v We11HvEZPPRYXRB4ftnu2YUD1vgdGAFJ4VkYHH4kubVUo/VNyh5Z X-Received: by 2002:a05:600c:354d:b0:40f:d3da:85cf with SMTP id i13-20020a05600c354d00b0040fd3da85cfmr2754650wmq.8.1707240783927; Tue, 06 Feb 2024 09:33:03 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCX+MB19xzCAzIriGYNzEELPb3JpNFynCloU7S3gPgqQ8tnwvzzVkYC5N1tCNw6sT/z4XoeekTXsXXcC+AIkRsvx3ubvP5OvPvkYGMn/2KRYrF5bp2NpIH2GjKfQHPIEPdKRu9Nd0dtEIpJVobSRI6kqRepGGw/9hzRxNfhWhFJ4oBxv8N3hw+zSKPWoP4RvDNNZOSKDYL4jR0ccQDC5Z++dscCcMirEA8gL7iKVon73anKMIRKe+ZzNZ8uJvoEA5aLaNvtSiwfPxreC6tqmwyASfSXsO48zNUo4U1l+xsMHCBzVx2ZImphHbb58dWIkR06I0ARWpty91iNWY2j/EMjfVI+IoTnDOY3o3XQeQDuk/MFuabp0YyqEGVLFH1H9EeSNqCKeqJBS0KKsrR92S+/bZuL2dxa3ir9JGyyzPAtsg0GpwCApXLjFwi6gSad8BE7Kup3k/Yi1EOF26UrXItq67fd8Xti4uh4DNw1f3a2Oq5gcAVCDfChcZw0sClaVTFYgR/8VEa9VBEwc7DHdxTQAnCfgPJ8+n79WKZbXVrp4KP7VLJvmWGRi/FBldorwj4YwJssFWoiaNpCHrA/9NIkt7MAJeXOf7/JD4Q4Hr8ambqv2gEy2QW96DOeeExM6aUDJkugQG/z+CMAixpMVqIY4i0Y8OQRFcSWQseN4NKUm3l2fkddRFw== Received: from localhost.localdomain (93-34-89-13.ip49.fastwebnet.it. [93.34.89.13]) by smtp.googlemail.com with ESMTPSA id l14-20020a05600c4f0e00b0040fc56712e8sm2621215wmq.17.2024.02.06.09.33.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 09:33:02 -0800 (PST) From: Christian Marangi To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bjorn Andersson , Konrad Dybcio , Andrew Lunn , Heiner Kallweit , Russell King , Florian Fainelli , Broadcom internal kernel review list , Christian Marangi , Robert Marko , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [net-next PATCH v7 06/10] net: phy: provide whether link has changed in c37_read_status Date: Tue, 6 Feb 2024 18:31:09 +0100 Message-ID: <20240206173115.7654-7-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240206173115.7654-1-ansuelsmth@gmail.com> References: <20240206173115.7654-1-ansuelsmth@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 Some PHY driver might require additional regs call after genphy_c37_read_status() is called. Expand genphy_c37_read_status to provide a bool wheather the link has changed or not to permit PHY driver to skip additional regs call if nothing has changed. Every user of genphy_c37_read_status() is updated with the new additional bool. Signed-off-by: Christian Marangi --- drivers/net/phy/broadcom.c | 3 ++- drivers/net/phy/phy_device.c | 11 +++++++++-- drivers/net/phy/qcom/at803x.c | 3 ++- include/linux/phy.h | 2 +- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c index 312a8bb35d78..370e4ed45098 100644 --- a/drivers/net/phy/broadcom.c +++ b/drivers/net/phy/broadcom.c @@ -665,10 +665,11 @@ static int bcm54616s_config_aneg(struct phy_device *phydev) static int bcm54616s_read_status(struct phy_device *phydev) { struct bcm54616s_phy_priv *priv = phydev->priv; + bool changed; int err; if (priv->mode_1000bx_en) - err = genphy_c37_read_status(phydev); + err = genphy_c37_read_status(phydev, &changed); else err = genphy_read_status(phydev); diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 9014ac3c0fc8..861b09cff3f7 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -2617,12 +2617,15 @@ EXPORT_SYMBOL(genphy_read_status); /** * genphy_c37_read_status - check the link status and update current link state * @phydev: target phy_device struct + * @changed: pointer where to store if link changed * * Description: Check the link, then figure out the current state * by comparing what we advertise with what the link partner * advertises. This function is for Clause 37 1000Base-X mode. + * + * If link has changed, @changed is set to true, false otherwise. */ -int genphy_c37_read_status(struct phy_device *phydev) +int genphy_c37_read_status(struct phy_device *phydev, bool *changed) { int lpa, err, old_link = phydev->link; @@ -2632,9 +2635,13 @@ int genphy_c37_read_status(struct phy_device *phydev) return err; /* why bother the PHY if nothing can have changed */ - if (phydev->autoneg == AUTONEG_ENABLE && old_link && phydev->link) + if (phydev->autoneg == AUTONEG_ENABLE && old_link && phydev->link) { + *changed = false; return 0; + } + /* Signal link has changed */ + *changed = true; phydev->duplex = DUPLEX_UNKNOWN; phydev->pause = 0; phydev->asym_pause = 0; diff --git a/drivers/net/phy/qcom/at803x.c b/drivers/net/phy/qcom/at803x.c index 3e3ee4c1d4bc..4717c59d51d0 100644 --- a/drivers/net/phy/qcom/at803x.c +++ b/drivers/net/phy/qcom/at803x.c @@ -912,9 +912,10 @@ static int at8031_config_intr(struct phy_device *phydev) static int at8031_read_status(struct phy_device *phydev) { struct at803x_priv *priv = phydev->priv; + bool changed; if (priv->is_1000basex) - return genphy_c37_read_status(phydev); + return genphy_c37_read_status(phydev, &changed); return at803x_read_status(phydev); } diff --git a/include/linux/phy.h b/include/linux/phy.h index f8ce8a757ed0..e9aaa0dfe675 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1876,7 +1876,7 @@ int genphy_write_mmd_unsupported(struct phy_device *phdev, int devnum, /* Clause 37 */ int genphy_c37_config_aneg(struct phy_device *phydev); -int genphy_c37_read_status(struct phy_device *phydev); +int genphy_c37_read_status(struct phy_device *phydev, bool *changed); /* Clause 45 PHY */ int genphy_c45_restart_aneg(struct phy_device *phydev); -- 2.43.0