Received: by 2002:a05:6520:1682:b0:147:d1a0:b502 with SMTP id ck2csp5597352lkb; Mon, 11 Oct 2021 09:39:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzg/9FIztrCTZGDKWhscHvvpgFDNjynRB3Ddkl9tCMTOPbcqdraKn+I8k+YxwyOxgTSkU0 X-Received: by 2002:a05:6402:1d52:: with SMTP id dz18mr32055788edb.49.1633970397555; Mon, 11 Oct 2021 09:39:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633970397; cv=none; d=google.com; s=arc-20160816; b=U+gEQuDSrooKWbfO1ASQEt0SWgm4Vxc/hkfR0KRYJGYKi9XAnhCUzKdh3E71Dx4ddH ilDB4OsZ6T7kZyEWIRNWPp2rM4rkblX/4cfrJsVWQDjjqapIWz/afxCoof7rHiEBwDIV ykf0FN517C9vFilAUoASx8adW3kH5LaIqAXLfcIW1ZDQ6UcAofrMi9kjqSLQpV/lZY3K PYPQo1PqwSkh1C+fr75f83+X7fBKrWn5ohWqEkUoahwrhHQfJRpvmzjYxKsC0/fQE9TT dvEDWd8xULtxuvLvscO1FcPqA/jihNkG33lVkNcFr+9qSOmiUscQDxFt0UaOVrAOb5Jx fLzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from:dkim-signature; bh=IkKF1Ul6s+mIj34dxznpMYVOcEWKCsEw1mlJ7TAdqjE=; b=lCQeXBwKHoQHMp5Bk84ta3ha02cRHi4oryiAGm656uQy3vIZ0iCZpEYV0Q3JHr628p dj9Kf74Taua345v6ILG6gIgHtgTm223Me3i7Hun0oCmrlpf1PsP2wcpdUjDkJHM7cOHR bTdZr6tySG3cGrlcPoSfnWugatdJIAJx401r0ax21LdN/RCwfUBsqB8EpsBDs99VOl2r ImgztTFsB+waGhnG+A5mZKXf0t1a53/jCCz6iWUDpDvEogDv2oAj4z/pm3TlIqcl/E6y NHqLMVBqFur9AVStQP4pF/h08cWCVA/coxwWXKfIOVs/aYyUxo7+UoKpelEzBFJgkJ3j eUwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mind.be header.s=google header.b=MoBAqQVF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i10si11501094edb.111.2021.10.11.09.39.31; Mon, 11 Oct 2021 09:39:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@mind.be header.s=google header.b=MoBAqQVF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236636AbhJKOeG (ORCPT + 99 others); Mon, 11 Oct 2021 10:34:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231717AbhJKOeA (ORCPT ); Mon, 11 Oct 2021 10:34:00 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D92CCC0612E1 for ; Mon, 11 Oct 2021 07:27:48 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id r18so68693791edv.12 for ; Mon, 11 Oct 2021 07:27:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mind.be; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=IkKF1Ul6s+mIj34dxznpMYVOcEWKCsEw1mlJ7TAdqjE=; b=MoBAqQVF5Ya+tSlDL2xABuAKYw18mCy05no5OzZ5mXNwobaiM3js/UZmGvqv2kezSW u5uoN8qpaW1M6tLYibfPzzjiSaiGDZpeKAwc6oYFULYTXfAJ4BmYVqEVv3B+VdO0y3H0 zs68M3A1znS4dYf1CXNo8SisZ3wVNr0u445YQnVpaVR9KRskUQDtRdeS0BM0Nxh81dMq 4a5/XBGTag29rX8Wem9SgmSUL+8eGYZ3Ij4NayBhTmV9Km8j79fTVu4NsRnOto0tFM1h 77LJ+DkQXYLABEtefD3WuT2K98Ul7Rd7dhhPy4v8pqb9eSfsIG8IMGcnGZyXJxPrx/IS gtkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=IkKF1Ul6s+mIj34dxznpMYVOcEWKCsEw1mlJ7TAdqjE=; b=KGSFm4L3UmOLHfJxfoYr48Kctvet8GnFNcf9XRcEF206vTYNvy1o28b63O7LbgeKkw YJprfGfi0yKsgrJ9uVyVoxGHrl3bBvP/76WRNhmlaLVeX8G3C+ajPsvGUlkHLn6KAMsU NK9Qn4WNZSg5PAktGJAK8wIwj5EJtvOBdPzduroN/RzqZKe3uIBjGSbeZxvt3uk+epM3 ULOXCC5GOGGwiP0MvwpMscTOp7euqwoCyFEAQzlc0z63k0SsUmwOsH37PK3RFzU/ip/o xvP7v8B3zGy9etz7IszegYKdPkBd/wHcc6hs/7MaL+cnHnKIINR8zqBLTegNPB36LIjR eiwQ== X-Gm-Message-State: AOAM5303hBb11VOXUng8/TIBHy7OmQuqW7n90yp/4NKm4YvKddibjf86 sx0hZq6PTgqrfaSmLdrwlwhqIg== X-Received: by 2002:a50:bf0f:: with SMTP id f15mr41310513edk.43.1633962467437; Mon, 11 Oct 2021 07:27:47 -0700 (PDT) Received: from dtpc.gsp-berlin.local (78-22-137-109.access.telenet.be. [78.22.137.109]) by smtp.gmail.com with ESMTPSA id x16sm3565129ejj.8.2021.10.11.07.27.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Oct 2021 07:27:47 -0700 (PDT) From: Maarten Zanders Cc: maarten.zanders@mind.be, Maarten Zanders , Maxime Chevallier , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , Russell King , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] net: dsa: mv88e6xxx: don't use PHY_DETECT on internal PHY's Date: Mon, 11 Oct 2021 16:27:20 +0200 Message-Id: <20211011142720.42642-1-maarten.zanders@mind.be> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org mv88e6xxx_port_ppu_updates() interpretes data in the PORT_STS register incorrectly for internal ports (ie no PPU). In these cases, the PHY_DETECT bit indicates link status. This results in forcing the MAC state whenever the PHY link goes down which is not intended. As a side effect, LED's configured to show link status stay lit even though the physical link is down. Add a check in mac_link_down and mac_link_up to see if it concerns an external port and only then, look at PPU status. Fixes: 5d5b231da7ac (net: dsa: mv88e6xxx: use PHY_DETECT in mac_link_up/mac_link_down) Reported-by: Maarten Zanders Reviewed-by: Maxime Chevallier Signed-off-by: Maarten Zanders --- drivers/net/dsa/mv88e6xxx/chip.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index ee3f32d1cf46..f5ce05d78e11 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -726,9 +726,13 @@ static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port, ops = chip->info->ops; mv88e6xxx_reg_lock(chip); - if ((!mv88e6xxx_port_ppu_updates(chip, port) || - mode == MLO_AN_FIXED) && ops->port_sync_link) + /* Internal PHYs propagate their configuration directly to the MAC. + * External PHYs depend on whether the PPU is enabled for this port. + */ + if (((!mv88e6xxx_phy_is_internal(ds, port) && + !mv88e6xxx_port_ppu_updates(chip, port)) || + mode == MLO_AN_FIXED) && ops->port_sync_link) err = ops->port_sync_link(chip, port, mode, false); mv88e6xxx_reg_unlock(chip); @@ -750,7 +754,12 @@ static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port, ops = chip->info->ops; mv88e6xxx_reg_lock(chip); - if (!mv88e6xxx_port_ppu_updates(chip, port) || mode == MLO_AN_FIXED) { + /* Internal PHYs propagate their configuration directly to the MAC. + * External PHYs depend on whether the PPU is enabled for this port. + */ + if ((!mv88e6xxx_phy_is_internal(ds, port) && + !mv88e6xxx_port_ppu_updates(chip, port)) || + mode == MLO_AN_FIXED) { /* FIXME: for an automedia port, should we force the link * down here - what if the link comes up due to "other" media * while we're bringing the port up, how is the exclusivity -- 2.25.1