From patchwork Mon May 22 12:00:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Horatiu Vultur X-Patchwork-Id: 97347 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1392107vqo; Mon, 22 May 2023 05:02:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Bt1nCKDntJwDhALPzKKDpvQNIaDW/XyVrKcrtmM/OQc5kAzIDnquHDv13incZmCG0GGQu X-Received: by 2002:a17:902:ab4e:b0:1ae:4ddd:9961 with SMTP id ij14-20020a170902ab4e00b001ae4ddd9961mr10863518plb.20.1684756929619; Mon, 22 May 2023 05:02:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684756929; cv=none; d=google.com; s=arc-20160816; b=qqXe/ZcPcjeHXmQqQjXO+iS5wtb1s6Ii7Sli/HtzVBYh7dHZ60TcrwmR7xcuQYrSlh TwpW1YxR5WFrAkcncqpGTy/tFvosbRULYM+8U80t6W54O1gy4ISUx5vfBeAksUT1fayM uWsVYd0g/wVHKco3DYKcOGoeKNes7QkhFELxsyv4bQBM4UxypHWB5fSRAp8uG5TtGlzW JyWIUNnB1uwlLRz/qtY4hjpVH0A41CWeTfBwgeau9sStbijWvlUXB0k/oiXYeu5CATAo ev2hEejh4BCncBt+72shgK2tTu6QH+qmGW3t5SY7UIzDKt5VT1noDe5SxghfQDiAp1l6 1Ppw== 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=YgX0G5IkuTc540uwNCTKHtFibXKZQveDwJYKPZ6q354=; b=PqtqekIujhjqfqBrB1t10xxs6/F7ehLF3oX62flMEFD6RObt7kLKbVJQhs7XnmlRBx vq9Fid6BaSUUTWwMp1l4E2/j6XjUxR/Jjw9MGHZqrvFwjGe0r9N7f34B4f+nVg7LEGN4 W1h74CTZdTQYMs/pwXnLYkgPLYyiogZ0DylhztlBiQVmj9MQP1bKc3a8dmRSXHsz0H2U dyLnqf0IlcIaRavgw5ZsIruoL+aNIlcNW5j+uVlZbD4lSxc2CASq6zPkBM1XQU+i6pXb rgPr1VdEk24ERd+ZOZZI3Ta2ywE83W9MKrjq7duxqdeYHm4xMxLly12P+7wL+TCg2CB8 MJUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=vhS3TCLf; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h11-20020a170902b94b00b001afb057c053si494889pls.64.2023.05.22.05.01.53; Mon, 22 May 2023 05:02:09 -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=@microchip.com header.s=mchp header.b=vhS3TCLf; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233639AbjEVMBS (ORCPT + 99 others); Mon, 22 May 2023 08:01:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233695AbjEVMBN (ORCPT ); Mon, 22 May 2023 08:01:13 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 201A111A; Mon, 22 May 2023 05:01:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1684756861; x=1716292861; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=hMOSXMNyvb3N9ByVdDgsFv/uLjADIsqKyzVsX4y12vs=; b=vhS3TCLfS0fqh+Rzv7jMmfP3i4bKMpyW8gSb4xVYGOi/nsHMWLkJQ45B uhJW1lKi8H4m4Q0THJg3T2jBTAPqDdKLzXfrxGi73gFKE2QydpXv/eSwL P7V01nWGC/f/ifs7rKuS0JjU63rqWVH+1lZ/Xnmg9uy38qlzl/Tax+f/S KLUrJF+SQWOOpJZlS5IcMpGkUvP1IkCoPKRliDykox3VrBVLiEAZg8Eht pXfDQNDPjJuV87QTIAKoOzW/6kiPfVKEcBdKnhBQKQ+/yi2HYFisJ0NWP qsmYH09qrmrWI7JDAnQ+zhw1lB0Zbuw+/NJN24cL8BRDIjq/iXl0DUxrT w==; X-IronPort-AV: E=Sophos;i="6.00,184,1681196400"; d="scan'208";a="212452990" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 22 May 2023 05:01:01 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Mon, 22 May 2023 05:00:57 -0700 Received: from soft-dev3-1.microsemi.net (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Mon, 22 May 2023 05:00:56 -0700 From: Horatiu Vultur To: , CC: , , , , , Horatiu Vultur Subject: [PATCH net] lan966x: Fix unloading/loading of the driver Date: Mon, 22 May 2023 14:00:38 +0200 Message-ID: <20230522120038.3749026-1-horatiu.vultur@microchip.com> X-Mailer: git-send-email 2.38.0 MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766595682507596263?= X-GMAIL-MSGID: =?utf-8?q?1766595682507596263?= It was noticing that after a while when unloading/loading the driver and sending traffic through the switch, it would stop working. It would stop forwarding any traffic and the only way to get out of this was to do a power cycle of the board. The root cause seems to be that the switch core is initialized twice. Apparently initializing twice the switch core disturbs the pointers in the queue systems in the HW, so after a while it would stop sending the traffic. Unfortunetly, it is not possible to use a reset of the switch here, because the reset line is connected to multiple devices like MDIO, SGPIO, FAN, etc. So then all the devices will get reseted when the network driver will be loaded. So the fix is to check if the core is initialized already and if that is the case don't initialize it again. Fixes: db8bcaad5393 ("net: lan966x: add the basic lan966x driver") Signed-off-by: Horatiu Vultur Reviewed-by: Simon Horman --- drivers/net/ethernet/microchip/lan966x/lan966x_main.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c index 5f01b21acdd1b..f6931dfb3e68e 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c @@ -1039,6 +1039,16 @@ static int lan966x_reset_switch(struct lan966x *lan966x) reset_control_reset(switch_reset); + /* Don't reinitialize the switch core, if it is already initialized. In + * case it is initialized twice, some pointers inside the queue system + * in HW will get corrupted and then after a while the queue system gets + * full and no traffic is passing through the switch. The issue is seen + * when loading and unloading the driver and sending traffic through the + * switch. + */ + if (lan_rd(lan966x, SYS_RESET_CFG) & SYS_RESET_CFG_CORE_ENA) + return 0; + lan_wr(SYS_RESET_CFG_CORE_ENA_SET(0), lan966x, SYS_RESET_CFG); lan_wr(SYS_RAM_INIT_RAM_INIT_SET(1), lan966x, SYS_RAM_INIT); ret = readx_poll_timeout(lan966x_ram_init, lan966x,