Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp1303758rdg; Fri, 11 Aug 2023 17:43:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEUgZPPLBfLa6l4wrdtR3Mt1WEuqqmk/sUBovCMEPTgJrCPOxA2dqHT3DoG5K384DFU0fz/ X-Received: by 2002:a17:906:3098:b0:99b:d2a9:9a01 with SMTP id 24-20020a170906309800b0099bd2a99a01mr3314965ejv.0.1691800998477; Fri, 11 Aug 2023 17:43:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691800998; cv=none; d=google.com; s=arc-20160816; b=KZbN074nOu4g025tuUSTClfPmmdHY2GzZ5IpURv45CcE2ngVb5ARyhVLosNBN3+8tY yJM3qL+ldxFWS2Lzq62LydtlWT64XLzPTRvXnU5TUIOQfH8TjXIzaId4o1H+84FLG4ba kQAld4IAUNXqMc6iGjZpmPVKD/aigwGCpoJNSIRaqbViIJW/5mEHw22+BAH+gK75iPtQ cdDETPU4mHe3kfx+gvZKEs7ndcy6M2xxS+Xt3PT3naGZIrIjXi3GfdEdAgbrc/n/dZIO JAI2AKvEnLlglaJTzdgcTgSrCNCrAF8lKj3imivVFESgQ4V4tp/I/PnixEkFQkvAr2mM QUPA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=xCGub4yUdKZFD9WM9TtKFKsNg2bW2F2AATXkBlBNwKw=; fh=XBo3ofHtcIyEqkKMSuk83kKBHzk+DizRYCSdbMjhEn8=; b=FdyrLEqy6GykmLLQSU3B1tJNtbb7qN0ohtaUT6K2kMJOUuz11wBC1MWQgg6cO/b9XJ LUzp5t87arWluXdnpE8Gp3vkvLtuZrYTpA5I0I1kODtY27562HtNpgE5Lgn3k3h1hD9F 3jLqXwT4VMzc/sqYcUxZzVPhsY/8Xge59wNrnMlx89rKqsSNGoHhhz5wPep5QfDPCX8L N4Rl/q7c3j4zaGsxEesS+gj+xszinYqNWWIqFBtTeYxNYqyb1TksfooHPGiwU5GXBSsi ubehXEH2QvkQlf6ukzsrE+e38wzUicvkz/OrCmM53cSehxK/jPc3Entl0v6nE6QY9Phh ZVSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=X767ZYlc; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m12-20020a1709062acc00b0099454cbf77csi4559449eje.750.2023.08.11.17.42.53; Fri, 11 Aug 2023 17:43:18 -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=@gmail.com header.s=20221208 header.b=X767ZYlc; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234085AbjHKXXj (ORCPT + 99 others); Fri, 11 Aug 2023 19:23:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233314AbjHKXXi (ORCPT ); Fri, 11 Aug 2023 19:23:38 -0400 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 588301736; Fri, 11 Aug 2023 16:23:33 -0700 (PDT) Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-686f19b6dd2so1900759b3a.2; Fri, 11 Aug 2023 16:23:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691796212; x=1692401012; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=xCGub4yUdKZFD9WM9TtKFKsNg2bW2F2AATXkBlBNwKw=; b=X767ZYlcbS3EoQOJvTBekfZYqrHzEKhMOQ7+NkI7u1wNqgq6mYWZr0rLqZ9lMQ5glH 5xoaWtVApDyAPVO990O5TjGb/4WRTWRXFyuOBJPZNvzxLJQKsLUQ3EGvNfTG8alaIcue aVesSk00V6etTnLOjX6n1u7sdFd0P2imr2rpaPrO6662BiEL6oa/zYLCd7eAeUYROX1Q jHn43hs/cGyThOHj4PiKxvJBOXKUnhJZocInIhLycRTV/Xtn1ypFPIhjJRvRlVZ73WOS pflo4XlFULs/Q21kP8HWs5IAKHQG1rzu3060IBay7NoMF/CKMC/fynvVwCdbeAr2Eccp OgaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691796212; x=1692401012; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=xCGub4yUdKZFD9WM9TtKFKsNg2bW2F2AATXkBlBNwKw=; b=jDm9dvubJ0tdIPDKuCadMEBjH59/KuMBPrY2YBuz4LYqKFdQxXRZqSvb4+UXQWvMY6 SAYYf7TJ8kSsyk/E28YpdPf6R3UBkZ2nfOKriCwfZ7TK5SaoUoydLLtFnzSXXzxqIozv 6Aco80rB1j5Jl8m6xnPX5dLzIKpU65IY/t4qMJHewpBHLYvHRq5aGog/iheap1Lzw2rB U6e+7yXgEdF9E6B/+gh1ijPNPDpDWbcjvwN2V3Y1m3GJUyJvtW+1br4i1C/l/enZfNkK IYykjX5W16u2ZZQX+NusDJlGZgrlyDooukESIfZ7hFSvTGnUQtpJHNB6G3ysQmI12+cL GbuA== X-Gm-Message-State: AOJu0YzZqhADRBOvSfugkJVQzmLk/490GDlVw7fxIiiaSq3rA0/4Hv1q 6HBnyuZEGzBzXZnCn8OMS2NqUBgU+AUzGQ== X-Received: by 2002:a05:6a20:12c7:b0:13b:a2c9:922e with SMTP id v7-20020a056a2012c700b0013ba2c9922emr3873337pzg.27.1691796212580; Fri, 11 Aug 2023 16:23:32 -0700 (PDT) Received: from alfred-laptop.ims.dom ([69.178.150.39]) by smtp.gmail.com with ESMTPSA id c10-20020aa781ca000000b006828e49c04csm3855525pfn.75.2023.08.11.16.23.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Aug 2023 16:23:32 -0700 (PDT) From: Alfred Lee To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: andrew@lunn.ch, olteanv@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, sgarzare@redhat.com, AVKrasnov@sberdevices.ru, Alfred Lee Subject: [PATCH net] net: dsa: mv88e6xxx: Wait for EEPROM done before HW reset Date: Fri, 11 Aug 2023 16:23:10 -0700 Message-ID: <20230811232310.21124-1-l00g33k@gmail.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS 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 If the switch is reset during active EEPROM transactions, as in just after an SoC reset after power up, the I2C bus transaction may be cut short leaving the EEPROM internal I2C state machine in the wrong state. When the switch is reset again, the bad state machine state may result in data being read from the wrong memory location causing the switch to enter unexpect mode rendering it inoperational. Signed-off-by: Alfred Lee Fixes: 8abbffd27ced ("net: dsa: mv88e6xxx: Wait for EEPROM done after HW reset") --- drivers/net/dsa/mv88e6xxx/chip.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index c7d51a539451..7af2f08a62f1 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -3034,6 +3034,14 @@ static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip) /* If there is a GPIO connected to the reset pin, toggle it */ if (gpiod) { + /* If the switch has just been reset and not yet completed + * loading EEPROM, the reset may interrupt the I2C transaction + * mid-byte, causing the first EEPROM read after the reset + * from the wrong location resulting in the switch booting + * to wrong mode and inoperable. + */ + mv88e6xxx_g1_wait_eeprom_done(chip); + gpiod_set_value_cansleep(gpiod, 1); usleep_range(10000, 20000); gpiod_set_value_cansleep(gpiod, 0); -- 2.41.0