Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp1452411pxb; Sat, 23 Apr 2022 07:05:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGxacdymPCYBVcrJoQZda/cQpQVVqd6L1S78gOXPYvXCDWnFiAuIrguFkt/N1L9QR34uTh X-Received: by 2002:aa7:83c2:0:b0:505:723f:6ace with SMTP id j2-20020aa783c2000000b00505723f6acemr10285555pfn.86.1650722754259; Sat, 23 Apr 2022 07:05:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650722754; cv=none; d=google.com; s=arc-20160816; b=W3BrLIIJfnZtbYFHHtvVzGkgsQKuhPRG1a+a/tU0bW0+/HKz7YeClrQLXSDLAY9TFI w1zgedmLRNUoOiCRnhE/O1W9zvsK/rE0crWZxAoDRMYyt56BfALt1VJforhEEVkS4msC QVPhZow0W/gmKblzOfn7hhCuKRDPB8MG141i70MPsanDD1uEm3lePk0rQNCQKWvkuADx FnQxqUfuRNh8zw2Xo9P/Fq5cJl0AwBUbDjnV7GwL9yQ00r5WYcN1cSyoDeN72+J2MbHl QzURN1LayoDrJM4SnpnKSIUEcJcCRAutcTvb3wfU5lGaCbs3U9VsdMDvN+xxxVJ+lF3x s5Dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding:subject :cc:to:from:message-id:date:dkim-signature; bh=VDVJNwQC9G2do4EJBoyXwI4wMV7uzIa5s7Tu2i6+M9E=; b=Ojk/YYbzEAaiWCyVx6kBVVwN+wkU+psv/6MiRYxBPbHkbGntSB6oeZN4oWaiYyDv8I UwlirkOmGBGX4hU6Eizx2ZGQlpJ097SD0b6R/jEYmDXnddskCHNS4U4LMTXWKixm+ILv fX/tSr0i2RpNG7jQ+NdUy5wnl+NEO/tIdBpzsT49d3kgps4kkhfbM6QOu/9Nytbsd7TL S/1KOa9SY+0JIDYUsFD2OncerTWrUTddNGM/B0d+bKcxJVrCQT9QAInp60VSZgNgU+xb deC+tb6AKElDLUp5TnHMr2sd4ECav92i/40+mIh0w+6XXvT1BHWghOmhLT9JhJlX6Cqj xTTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nathanrossi.com header.s=google header.b=Bs7f1pBU; 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=pass (p=NONE sp=NONE dis=NONE) header.from=nathanrossi.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x20-20020a63f714000000b003aa8fffe77bsi5639147pgh.737.2022.04.23.07.05.37; Sat, 23 Apr 2022 07:05:54 -0700 (PDT) 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=pass header.i=@nathanrossi.com header.s=google header.b=Bs7f1pBU; 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=pass (p=NONE sp=NONE dis=NONE) header.from=nathanrossi.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235524AbiDWNXl (ORCPT + 99 others); Sat, 23 Apr 2022 09:23:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233341AbiDWNXj (ORCPT ); Sat, 23 Apr 2022 09:23:39 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9039021ED2C for ; Sat, 23 Apr 2022 06:20:42 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id j8so16792280pll.11 for ; Sat, 23 Apr 2022 06:20:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nathanrossi.com; s=google; h=date:message-id:from:to:cc:subject:content-transfer-encoding :mime-version; bh=VDVJNwQC9G2do4EJBoyXwI4wMV7uzIa5s7Tu2i6+M9E=; b=Bs7f1pBUxrJOx1Rb0toQohquDrucGeqqkWPzhxTr0mv7EinNNsw0MMLSNPa43FrUFM +9yozL9+zmGAsy9gJyXXz7JT2iiCwXz6u/lDiCdSKwZLAOQ5HkjG6jQ+74XMKwL8zONf huUa6t0LQkVgxjk88rh+Tz5Xg/LF7OqsLkjGR/W1qvyDQ2uahuRAV28vCgxe4F0b+mCL +Tk/vFbZ5JLjtrBae/XeNDRiUo2aNZs67iorzLeCRG37QbxtaOBMTnE6Ov8BE+eipYe8 SpmhZdkBBMkmSrAEG2MzlPNbnYesRhFAap9dBoOAI1uY0hcsBBO6wiQrV9A9V4tUhz6r 8K5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:from:to:cc:subject :content-transfer-encoding:mime-version; bh=VDVJNwQC9G2do4EJBoyXwI4wMV7uzIa5s7Tu2i6+M9E=; b=m2X369wkRecYxlWqgPEER/Fnn/uZmsqrxp7OpZ0UlVqCqRf4/dQ/j9vOrytbqP+0eS wvtx+gF5BsnrWtKArPO4xLXUPfEkUjWDKwhRCwGkXYIIv2TJV1nWrWRk1Y+fK40hCpqL 7o8rIWyLeRxjE6mGoTA6vp1H6gmpHMXjFyoe7K3+gQmOlhutc1nf2UTBUiChfyIoFMh+ aOX36vxTM3Io+9eiA3bNNL+JDyCPaYIFT+lwtZJGyx/B56FodA28gjqfnFa/yUrko+Uh uTQ5itY6VtMR5EiNYyoUw03++/J3Yyfx0FBBMnADK1bAduPdbK9sFcI0ICSR/9QNH1W7 8Sxg== X-Gm-Message-State: AOAM532k/7+kw5UO+AZJx1kmH4FlrpgT5X+0EvzK9pupTV71fmvxL4rv Vvt62pv6NHkdgpl8+GJDFS9UPw== X-Received: by 2002:a17:902:ea53:b0:15b:1bb8:ac9e with SMTP id r19-20020a170902ea5300b0015b1bb8ac9emr9132837plg.45.1650720042137; Sat, 23 Apr 2022 06:20:42 -0700 (PDT) Received: from [127.0.1.1] (117-20-68-98.751444.bne.nbn.aussiebb.net. [117.20.68.98]) by smtp.gmail.com with UTF8SMTPSA id f19-20020a17090a639300b001d81a30c437sm2024788pjj.50.2022.04.23.06.20.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Apr 2022 06:20:41 -0700 (PDT) Date: Sat, 23 Apr 2022 13:20:35 +0000 Message-Id: <20220423132035.238704-1-nathan@nathanrossi.com> From: Nathan Rossi To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Nathan Rossi , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , Paolo Abeni Subject: [PATCH] net: dsa: mv88e6xxx: Skip cmode writable for mv88e6*41 if unchanged Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 mv88e6341_port_set_cmode function always calls the set writable regardless of whether the current cmode is different from the desired cmode. This is problematic for specific configurations of the mv88e6341 and mv88e6141 (in single chip adddressing mode?) where the hidden registers are not accessible. This causes the set_cmode_writable to fail, and causes teardown of the switch despite the cmode already being configured in the correct mode (via external configuration). This change adds checking of the current cmode compared to the desired mode and returns if already in the desired mode. This skips the set_cmode_writable setup if the port is already configured in the desired mode, avoiding any issues with access of hidden registers. Signed-off-by: Nathan Rossi --- drivers/net/dsa/mv88e6xxx/port.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/net/dsa/mv88e6xxx/port.c b/drivers/net/dsa/mv88e6xxx/port.c index 795b312876..f2e9c8cae3 100644 --- a/drivers/net/dsa/mv88e6xxx/port.c +++ b/drivers/net/dsa/mv88e6xxx/port.c @@ -713,6 +713,7 @@ int mv88e6341_port_set_cmode(struct mv88e6xxx_chip *chip, int port, phy_interface_t mode) { int err; + u8 cmode = chip->ports[port].cmode; if (port != 5) return -EOPNOTSUPP; @@ -724,6 +725,23 @@ int mv88e6341_port_set_cmode(struct mv88e6xxx_chip *chip, int port, case PHY_INTERFACE_MODE_XAUI: case PHY_INTERFACE_MODE_RXAUI: return -EINVAL; + + /* Check before setting writable. Such that on devices that are already + * correctly configured, no attempt is made to make the cmode writable + * as it may fail. + */ + case PHY_INTERFACE_MODE_1000BASEX: + if (cmode == MV88E6XXX_PORT_STS_CMODE_1000BASEX) + return 0; + break; + case PHY_INTERFACE_MODE_SGMII: + if (cmode == MV88E6XXX_PORT_STS_CMODE_SGMII) + return 0; + break; + case PHY_INTERFACE_MODE_2500BASEX: + if (cmode == MV88E6XXX_PORT_STS_CMODE_2500BASEX) + return 0; + break; default: break; } --- 2.35.2