From patchwork Wed Mar 20 17:20:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Elad Nachman X-Patchwork-Id: 13598041 X-Patchwork-Delegate: kuba@kernel.org Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B48146A031; Wed, 20 Mar 2024 17:20:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.156.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710955245; cv=none; b=UIAmqAFu9nh1RrAwmGv+lhDdm19xgMesu/KRlrF7ulvoAEQj6EN3aTfb6WfGqaBem4LTkMvbnmHoitiFrdiotYBsgJAHxsHDUkmr4h6wUvAu4fVk86vW697kP8Ee1lKqqew85l4LyP3f06O5NvUJrVWkNyL0bGEm/bu5QKtyFfk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710955245; c=relaxed/simple; bh=Lu3PAsV8idIwc1WpiGaF9N5iGw2xyESicAA7I+XC6Kk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NnPI9llzk3M1InH4CqILjISTJCMRmBrcAEmM7RhuyY/RxbOr9sZhQ/aWMMVNPH/JsY5LF3kRNaEbqvV2V8XsgBZJMcT2V1hbTWPPX2G7g2Vdq2niTqnAW6ky8j5V7nvxtOaUWXpDd2dGpqbq10IhLyJX9KIeW0bjYlr+be1LyOU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=none smtp.helo=mx0b-0016f401.pphosted.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=i4SQz4g8; arc=none smtp.client-ip=67.231.156.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.helo=mx0b-0016f401.pphosted.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="i4SQz4g8" Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 42KFJHDd003970; Wed, 20 Mar 2024 10:20:19 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s= pfpt0220; bh=L951DHMxIyS3n0VafEIzeSBEdcc343kBJS7IpV0atm8=; b=i4S Qz4g8sjNpQhLutpN8UgOdcitpEaGx4wL4mObTqoX3w3yYxc7kn8f8NgJxWZnxAAr XiOTDm+MvHNmwcKoKdIe0lrIgW94Wxmff03AWRgdZZ/nwFaLNduo9ZdnV6L/N+f6 Z0Eylcs2WwgdwZMjahdtHf7E9pEBrIjWkh88Xkgku5/XC4onSesr7QEWo/+djmEv XynBq1ZURFEToL8LIypf71EpCKrTiwaMcWQ31Rv5/tJRyJFpsSvhr2dRMH/Mn4aK fY2+czWy9aLnrc2rmg+EtNi0uRGF2bUKbNfmrLY1ZzeN7PM2FpI2IAs/doUfD9Sx eq8vERu6iG/6PZyORQw== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3wxka52e32-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Mar 2024 10:20:19 -0700 (PDT) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.32; Wed, 20 Mar 2024 10:20:18 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1258.32 via Frontend Transport; Wed, 20 Mar 2024 10:20:18 -0700 Received: from dc3lp-swdev041.marvell.com (dc3lp-swdev041.marvell.com [10.6.60.191]) by maili.marvell.com (Postfix) with ESMTP id 2E0073F705E; Wed, 20 Mar 2024 10:20:14 -0700 (PDT) From: Elad Nachman To: , , , , , , , , , , , , CC: Subject: [PATCH v2 1/5] net: marvell: prestera: fix driver reload Date: Wed, 20 Mar 2024 19:20:04 +0200 Message-ID: <20240320172008.2989693-2-enachman@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240320172008.2989693-1-enachman@marvell.com> References: <20240320172008.2989693-1-enachman@marvell.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: _0HuwkLqTzIZVh0y6Nbj9GFNvDspLIym X-Proofpoint-ORIG-GUID: _0HuwkLqTzIZVh0y6Nbj9GFNvDspLIym X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-20_10,2024-03-18_03,2023-05-22_02 X-Patchwork-Delegate: kuba@kernel.org From: Elad Nachman Driver rmmod after insmod would fail because API call to reset the switch HW and restart the firmware CPU code loading procedure was missing in driver removal code handler. Firmware reset and reload is needed as the firmware termination will make the firmware loader change its state machine to the firmware loading state, and thus will be able to load new firmware, which is done at the beginning of the probing of the prestera_pci module. Without this reset, the firmware loader will stay in the wrong state, causing the next firmware loading phase in the probe to fail. Fix by adding API call to reset the switch HW and restart the firmware CPU firmware code loading when handling the driver removal procedure. Reported-by: Köry Maincent Closes: https://lore.kernel.org/netdev/20240208101005.29e8c7f3@kmaincent-XPS-13-7390/T/ Fixes: 501ef3066c89 ("net: marvell: prestera: Add driver for Prestera family ASIC devices") Tested-by: Kory Maincent Signed-off-by: Elad Nachman --- drivers/net/ethernet/marvell/prestera/prestera_hw.c | 8 ++++++++ drivers/net/ethernet/marvell/prestera/prestera_hw.h | 1 + drivers/net/ethernet/marvell/prestera/prestera_main.c | 3 ++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/marvell/prestera/prestera_hw.c b/drivers/net/ethernet/marvell/prestera/prestera_hw.c index fc6f7d2746e8..08de8b498e0a 100644 --- a/drivers/net/ethernet/marvell/prestera/prestera_hw.c +++ b/drivers/net/ethernet/marvell/prestera/prestera_hw.c @@ -21,6 +21,7 @@ enum prestera_cmd_type_t { PRESTERA_CMD_TYPE_SWITCH_INIT = 0x1, PRESTERA_CMD_TYPE_SWITCH_ATTR_SET = 0x2, + PRESTERA_CMD_TYPE_SWITCH_RESET = 0x4, PRESTERA_CMD_TYPE_PORT_ATTR_SET = 0x100, PRESTERA_CMD_TYPE_PORT_ATTR_GET = 0x101, @@ -1087,6 +1088,13 @@ void prestera_hw_switch_fini(struct prestera_switch *sw) WARN_ON(!list_empty(&sw->event_handlers)); } +int prestera_hw_switch_reset(struct prestera_switch *sw) +{ + struct prestera_msg_common_req req; + + return prestera_cmd(sw, PRESTERA_CMD_TYPE_SWITCH_RESET, &req.cmd, sizeof(req)); +} + int prestera_hw_switch_ageing_set(struct prestera_switch *sw, u32 ageing_ms) { struct prestera_msg_switch_attr_req req = { diff --git a/drivers/net/ethernet/marvell/prestera/prestera_hw.h b/drivers/net/ethernet/marvell/prestera/prestera_hw.h index 0a929279e1ce..86217bea2ca0 100644 --- a/drivers/net/ethernet/marvell/prestera/prestera_hw.h +++ b/drivers/net/ethernet/marvell/prestera/prestera_hw.h @@ -150,6 +150,7 @@ struct prestera_neigh_info; /* Switch API */ int prestera_hw_switch_init(struct prestera_switch *sw); +int prestera_hw_switch_reset(struct prestera_switch *sw); void prestera_hw_switch_fini(struct prestera_switch *sw); int prestera_hw_switch_ageing_set(struct prestera_switch *sw, u32 ageing_ms); int prestera_hw_switch_mac_set(struct prestera_switch *sw, const char *mac); diff --git a/drivers/net/ethernet/marvell/prestera/prestera_main.c b/drivers/net/ethernet/marvell/prestera/prestera_main.c index 4fb886c57cd7..bcaa8ea27b49 100644 --- a/drivers/net/ethernet/marvell/prestera/prestera_main.c +++ b/drivers/net/ethernet/marvell/prestera/prestera_main.c @@ -1444,7 +1444,7 @@ static int prestera_switch_init(struct prestera_switch *sw) err_router_init: prestera_netdev_event_handler_unregister(sw); prestera_hw_switch_fini(sw); - + prestera_hw_switch_reset(sw); return err; } @@ -1463,6 +1463,7 @@ static void prestera_switch_fini(struct prestera_switch *sw) prestera_router_fini(sw); prestera_netdev_event_handler_unregister(sw); prestera_hw_switch_fini(sw); + prestera_hw_switch_reset(sw); of_node_put(sw->np); } From patchwork Wed Mar 20 17:20:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Elad Nachman X-Patchwork-Id: 13598039 X-Patchwork-Delegate: kuba@kernel.org Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4F8276A014; Wed, 20 Mar 2024 17:20:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.156.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710955244; cv=none; b=Fs93PM3+VI4h3mx4o0ULlrDo6brBUptLO1yRjNydhbaen7a91HBZtI9VIWnfeKn0gmMH4PgnCySD65axL5m8wHIQ8yl96PvIZ4g/49SAXzx568Usf0p4+sdVqjVQA+BLXPI+6AwbwKYuQB0wY4eoVQTf0umLts7QYgO660ZbK/Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710955244; c=relaxed/simple; bh=/606eP2z2/2P76YRuiGFsmoave4pKqy70yn+c+cgOqs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Cu8Pux4HOQjMqylH16uYMdGHnuD18UtctQLdYzxPgRmaWKkF2+lyUsMd6lQ68/XqHlJ6NSSFDZS92WBzums21G8I056lY5bW9hYuad/oZ8WaygfmIt9Ov/7IQfICT55Zamen8Ia9V7SoxfHT3XX80v/gnMFwj5TqVJ1NVfi+AKU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=none smtp.helo=mx0b-0016f401.pphosted.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=eu0CNpb6; arc=none smtp.client-ip=67.231.156.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.helo=mx0b-0016f401.pphosted.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="eu0CNpb6" Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 42KFAhqJ003418; Wed, 20 Mar 2024 10:20:23 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s= pfpt0220; bh=GuDypbNjlvBbfQVbDBTBAICh1XOtnfNIJ5il1Xye/So=; b=eu0 CNpb6iqhG/TDxX+fCy31mCWNYtGeXdfugbGAzF79IbC0TjSW6zt409cSoegEOBD7 scNsurnbA/MX847CosPw//+50v1zAjIhL+zHEBky38l+RgsSKXcek8O5jyDPbM5H b5MYf0ldDHcqPIHayWdrVYzC4wWMV6Iiauk4aEu0ntTE2mRK9phqwBTaI4oS7+y+ dEhWLo6GGnQTkZxc4mJtTuT8oy90ftDOYMkWCxoHwYk+V3UoY2hrGRA6JnXOW2fv W+EpHNf4L2UKB+CjliHEvUjwy/CYcGXWNgpdrdXSvAJqr16aL55zr9VVpNe19IbN hYgoX5iUw6ZD43LPI/A== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3wxka52e38-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Mar 2024 10:20:23 -0700 (PDT) Received: from DC6WP-EXCH02.marvell.com (10.76.176.209) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.32; Wed, 20 Mar 2024 10:20:22 -0700 Received: from maili.marvell.com (10.69.176.80) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server id 15.2.1258.32 via Frontend Transport; Wed, 20 Mar 2024 10:20:22 -0700 Received: from dc3lp-swdev041.marvell.com (dc3lp-swdev041.marvell.com [10.6.60.191]) by maili.marvell.com (Postfix) with ESMTP id E007A3F7051; Wed, 20 Mar 2024 10:20:18 -0700 (PDT) From: Elad Nachman To: , , , , , , , , , , , , CC: Subject: [PATCH v2 2/5] net: marvell: prestera: enlarge fw restart time Date: Wed, 20 Mar 2024 19:20:05 +0200 Message-ID: <20240320172008.2989693-3-enachman@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240320172008.2989693-1-enachman@marvell.com> References: <20240320172008.2989693-1-enachman@marvell.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: mrIRt4thHQ8kevDmX95toSMu1m7rpiO4 X-Proofpoint-ORIG-GUID: mrIRt4thHQ8kevDmX95toSMu1m7rpiO4 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-20_10,2024-03-18_03,2023-05-22_02 X-Patchwork-Delegate: kuba@kernel.org From: Elad Nachman Increase firmware restart timeout, as current timeout value of 5 seconds was too small, in actual life it can take up to 30 seconds for firmware to shutdown and for the firmware loader to shift to the ready to receive firmware code state. Reported-by: Köry Maincent Closes: https://lore.kernel.org/netdev/20240208101005.29e8c7f3@kmaincent-XPS-13-7390/T/ Fixes: 4c2703dfd7fa ("net: marvell: prestera: Add PCI interface support") Tested-by: Kory Maincent Signed-off-by: Elad Nachman --- drivers/net/ethernet/marvell/prestera/prestera_pci.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/marvell/prestera/prestera_pci.c b/drivers/net/ethernet/marvell/prestera/prestera_pci.c index 35857dc19542..2caa33d195ab 100644 --- a/drivers/net/ethernet/marvell/prestera/prestera_pci.c +++ b/drivers/net/ethernet/marvell/prestera/prestera_pci.c @@ -24,6 +24,11 @@ #define PRESTERA_FW_ARM64_PATH_FMT "mrvl/prestera/mvsw_prestera_fw_arm64-v%u.%u.img" #define PRESTERA_FW_HDR_MAGIC 0x351D9D06 +/* Timeout waiting for firmware CPU to reboot and restart + * the firmware loading software layer, hence becoming + * ready for the next firmware downloading phase: + */ +#define PRESTERA_FW_READY_TIMEOUT_MS 30000 #define PRESTERA_FW_DL_TIMEOUT_MS 50000 #define PRESTERA_FW_BLK_SZ 1024 @@ -765,7 +770,7 @@ static int prestera_fw_load(struct prestera_fw *fw) err = prestera_ldr_wait_reg32(fw, PRESTERA_LDR_READY_REG, PRESTERA_LDR_READY_MAGIC, - 5 * MSEC_PER_SEC); + PRESTERA_FW_READY_TIMEOUT_MS); if (err) { dev_err(fw->dev.dev, "waiting for FW loader is timed out"); return err; From patchwork Wed Mar 20 17:20:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elad Nachman X-Patchwork-Id: 13598043 X-Patchwork-Delegate: kuba@kernel.org Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B61706A35F; Wed, 20 Mar 2024 17:20:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.156.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710955247; cv=none; b=SE/wwIjmb7MTMdCFWqNTp62OoizPxkg0LJIhrOVL3pKIo8yosDlhTRhgwjT9l4zQHlvkOAn/mScUnPIsy/yVgRKXs+byhEYnKvbFxjjO3Wbbzrv7UIRQiW2XnWZMJS10a1mZh/n/oFzFJZLlAonjhzf2vGssNTR2NTHqls0k1cE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710955247; c=relaxed/simple; bh=poPQEITnyrIDULNTnvjDHS0Cg6w/a22EvIAT6aLzFWM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=D75kUBJpr+gg8CoUez7VBjfKVwxNFt+39TH5IUJeyv/nEkcHP5lBCHs6qxiF1/qeg1vW4On5QUHelxZWxMe/ExF78uSzXxm3jIrN2Ww4Runp7r0EXGHkFQ1OiGlW8J2lPEBts73RLR6wEMVT3gyfoIBwM2ZQAs52dAcUd2YW4Hw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=none smtp.helo=mx0b-0016f401.pphosted.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=MIDLcd7U; arc=none smtp.client-ip=67.231.156.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.helo=mx0b-0016f401.pphosted.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="MIDLcd7U" Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 42KFJHDe003970; Wed, 20 Mar 2024 10:20:27 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= pfpt0220; bh=1uT73EtgrEIN+G8RFHbk37HPotPJFAnZS5+C5PYjCtM=; b=MID Lcd7UGUNaPQ5ICGO4Kcnna57iZXBEDAm5RIiOdiBXrkcUctpQ1zPRysP/YDa79cN NW8HMH7KkP6gTMHSK3v3JbvNRXCStWzOG8NvTN+8xHVEqIAVFDoeplHDM4ZptnXD B4IxdAtOMBz6ljSTff1RiVAQD31b4iaQm9i9mnUsJcK8l76rbqsWVXp6QUPCWUgG dh8L0nNoxDeM7w3znIhQoNKxSP0fE7uYhhpMZJbYHCisVWvKo2AW9VVE0bejFQ8Z dUB2CkuIr/HeYdryoXcklylODH3yO+n2mtonQCsRsihepUkhDwUmljOdSsLpJzzg f57UoT71DUba1YvzRwA== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3wxka52e3f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Mar 2024 10:20:26 -0700 (PDT) Received: from DC6WP-EXCH02.marvell.com (10.76.176.209) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.32; Wed, 20 Mar 2024 10:20:26 -0700 Received: from maili.marvell.com (10.69.176.80) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server id 15.2.1258.32 via Frontend Transport; Wed, 20 Mar 2024 10:20:26 -0700 Received: from dc3lp-swdev041.marvell.com (dc3lp-swdev041.marvell.com [10.6.60.191]) by maili.marvell.com (Postfix) with ESMTP id 8A9625B692A; Wed, 20 Mar 2024 10:20:22 -0700 (PDT) From: Elad Nachman To: , , , , , , , , , , , , CC: Subject: [PATCH v2 3/5] net: marvell: prestera: fix memory use after free Date: Wed, 20 Mar 2024 19:20:06 +0200 Message-ID: <20240320172008.2989693-4-enachman@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240320172008.2989693-1-enachman@marvell.com> References: <20240320172008.2989693-1-enachman@marvell.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: NrP0FnnWxeoTIjyEfaMx2OvyMnZFL6qO X-Proofpoint-ORIG-GUID: NrP0FnnWxeoTIjyEfaMx2OvyMnZFL6qO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-20_10,2024-03-18_03,2023-05-22_02 X-Patchwork-Delegate: kuba@kernel.org From: Elad Nachman Prestera driver routing module cleanup process would release memory, then reference it again and eventually free it again the second time. Remove the redundant first memory free call. All such double free calls were detected using KASAN. Fixes: 4394fbcb78cf ("net: marvell: prestera: handle fib notifications") Signed-off-by: Elad Nachman Reviewed-by: Andrew Lunn --- drivers/net/ethernet/marvell/prestera/prestera_router.c | 1 - drivers/net/ethernet/marvell/prestera/prestera_router_hw.c | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/net/ethernet/marvell/prestera/prestera_router.c b/drivers/net/ethernet/marvell/prestera/prestera_router.c index de317179a7dc..2da04a17efad 100644 --- a/drivers/net/ethernet/marvell/prestera/prestera_router.c +++ b/drivers/net/ethernet/marvell/prestera/prestera_router.c @@ -1638,7 +1638,6 @@ void prestera_router_fini(struct prestera_switch *sw) prestera_k_arb_abort(sw); kfree(sw->router->nhgrp_hw_state_cache); - rhashtable_destroy(&sw->router->kern_fib_cache_ht); prestera_router_hw_fini(sw); kfree(sw->router); sw->router = NULL; diff --git a/drivers/net/ethernet/marvell/prestera/prestera_router_hw.c b/drivers/net/ethernet/marvell/prestera/prestera_router_hw.c index 02faaea2aefa..254107f664b4 100644 --- a/drivers/net/ethernet/marvell/prestera/prestera_router_hw.c +++ b/drivers/net/ethernet/marvell/prestera/prestera_router_hw.c @@ -102,7 +102,6 @@ void prestera_router_hw_fini(struct prestera_switch *sw) prestera_fib_node_destroy_ht_cb, sw); WARN_ON(!list_empty(&sw->router->vr_list)); WARN_ON(!list_empty(&sw->router->rif_entry_list)); - rhashtable_destroy(&sw->router->fib_ht); rhashtable_destroy(&sw->router->nexthop_group_ht); rhashtable_destroy(&sw->router->nh_neigh_ht); } From patchwork Wed Mar 20 17:20:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elad Nachman X-Patchwork-Id: 13598042 X-Patchwork-Delegate: kuba@kernel.org Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EBA7D6A326; Wed, 20 Mar 2024 17:20:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.156.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710955246; cv=none; b=obvWX9JgU0fNeifCmcrchaaCLTpHwIQlfdMFd6Otm+nQVFRSxv4tmyQsKqPNQnHC/xtSSSzovj2Iq9aFiSUIDNOKO/TVNl7HLX8rLXhJqzr5iCJTGo/CLzNritc2VpO+wmZcO1ZyvflkkBIXw67bPZWie5FT/kgxzIeO2jdkCpY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710955246; c=relaxed/simple; bh=BnBdnBUe4XaArwHjwRXi2KQIzBfK+Sut+of7NENF5lU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=g5d414/E6FLuYqjsVh+GnjHPd5SNGE9O7eQXjYcqKRwYsMqQdAfrYdndHMBzRWKeggqOf/D835nOlRkTiGUY7Oo4pO41f5RKwwEWiMnSMMEvfL7hmThrniam0uUJ5um+Y7YfecOMhUCdRfXKn90d8KmI2R/9y1y/Bu8e7OO0Lhc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=none smtp.helo=mx0b-0016f401.pphosted.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=itBkJnTU; arc=none smtp.client-ip=67.231.156.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.helo=mx0b-0016f401.pphosted.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="itBkJnTU" Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 42KFIWm9003494; Wed, 20 Mar 2024 10:20:31 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= pfpt0220; bh=C2fd2iktPU965blDdrMdyZ78vxK2GQivfgnP62HESJo=; b=itB kJnTU/YtISP1UCxsr+IixsGRc1Tlf/ymgrT+AsdLeen4w0uCqgIZnCri246Ojhfk jr3tt11pAV1eA+cVfFh5QEU341EuFaVu7ABc5RKo1/W3s/dTtQE29yJhVOqOIJmq 200Xfm7DpV5KqHY6dixSb/0GvqNcJEZFHpanRpEnpJB6IKKxrIMlKj+c4vKOsWAX HhR//YDBhoh3MsARAu7WuHKGaKmE+e3SeqlHuB033Ar/5SIqzkafK8+nGJdwu1PF iKW00p1Lnj9TG3GSFSzHdAqmYAMYgeCkUy0NSJIkg9uztQ/T6yYzfgVIhwWznUdq rUehgDTEOuLMz5B4D7Q== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3wxka52e3r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Mar 2024 10:20:31 -0700 (PDT) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.32; Wed, 20 Mar 2024 10:20:29 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1258.32 via Frontend Transport; Wed, 20 Mar 2024 10:20:29 -0700 Received: from dc3lp-swdev041.marvell.com (dc3lp-swdev041.marvell.com [10.6.60.191]) by maili.marvell.com (Postfix) with ESMTP id 35E675B692D; Wed, 20 Mar 2024 10:20:26 -0700 (PDT) From: Elad Nachman To: , , , , , , , , , , , , CC: Subject: [PATCH v2 4/5] net: marvell: prestera: force good base mac Date: Wed, 20 Mar 2024 19:20:07 +0200 Message-ID: <20240320172008.2989693-5-enachman@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240320172008.2989693-1-enachman@marvell.com> References: <20240320172008.2989693-1-enachman@marvell.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: bEMz6VlC1jVdV3F1ZW_H65e9b02namqt X-Proofpoint-ORIG-GUID: bEMz6VlC1jVdV3F1ZW_H65e9b02namqt X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-20_10,2024-03-18_03,2023-05-22_02 X-Patchwork-Delegate: kuba@kernel.org From: Elad Nachman The switching ASIC router HW unit MAC Source Address is configured with 40-bits of MAC base address in its registers (done in the firmware code), requiring all ports doing L3 routing in HW to have the same upper 40-bit MAC address. Since each switchport MAC address uses the switch base mac address and then adds the physical port number to it, Force the last byte of the switch base mac address to be at most 127, so when adding to it, we will not wrap around the previous (more significant) mac address byte, resulting in a warning message. Fixes: 501ef3066c89 ("net: marvell: prestera: Add driver for Prestera family ASIC devices") Signed-off-by: Elad Nachman Reviewed-by: Andrew Lunn --- drivers/net/ethernet/marvell/prestera/prestera_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/marvell/prestera/prestera_main.c b/drivers/net/ethernet/marvell/prestera/prestera_main.c index bcaa8ea27b49..87d8fc4162b3 100644 --- a/drivers/net/ethernet/marvell/prestera/prestera_main.c +++ b/drivers/net/ethernet/marvell/prestera/prestera_main.c @@ -860,6 +860,7 @@ static int prestera_switch_set_base_mac_addr(struct prestera_switch *sw) ret = of_get_mac_address(sw->np, sw->base_mac); if (!is_valid_ether_addr(sw->base_mac) || ret) { eth_random_addr(sw->base_mac); + sw->base_mac[5] &= 0x7f; dev_info(prestera_dev(sw), "using random base mac address\n"); } From patchwork Wed Mar 20 17:20:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Elad Nachman X-Patchwork-Id: 13598044 X-Patchwork-Delegate: kuba@kernel.org Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A5FBB6CDD7; Wed, 20 Mar 2024 17:20:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.156.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710955249; cv=none; b=mk+LAyhBbedRRAUW7EjrX6R8AdMLcCX8jU4UALn7NyGSHpCmKRTQOHHHfeNdiN/WBRv0d83D3rXBOXIMHU3mfdFdXoj5lwf4i3ic2DR8474z+jK8AS4kj92jd5fEn37pjIfU05bDM0tIDRXthPk5XFmUOD5ds4New/AT1mJu27c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710955249; c=relaxed/simple; bh=q3Eoe3HwZcr+BKmfzkyBcxUaWH/JJnCtsp+8KtLyrc0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=D1Gymk5JxmAoDFNs9x30vdABCz8Ip+HmXp4WocOT4UKfcwkJK9+CSUfqR5uedL4UjlWR+XJpZLKhLXl3US5GnbJtzy2Px6HgKgfzu2EBxkC1yme1G8AentxuCHCgaE3IWAw2Z07ACC9lHQMZLQ+qGt4OyH6F+1Hy4qowdqNoN4g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=none smtp.helo=mx0b-0016f401.pphosted.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=GV68HtCk; arc=none smtp.client-ip=67.231.156.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.helo=mx0b-0016f401.pphosted.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="GV68HtCk" Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 42KFCX8S003415; Wed, 20 Mar 2024 10:20:34 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s= pfpt0220; bh=sW9PW9x2tpq78PgTkORMNKTzi6wA1fKqdpwgJEf8NNs=; b=GV6 8HtCknu3vaB3j4kcCo1TPQlIrcR8YimvTDeNwPXZhlxWEtO1Ipi1yT1Eidnth6PH Abj1ZyIUahSHcWZGt0peJgtNGCptYtZBLvUdqiB5X0eM0RrHgcmeiIB6QnuZoCtw 2j8xAO76ouAcEjAwICnWTvu0+ce5/BDDO3vBjVhKGWcm2pNtLnEycIyhrAhf3tuk HwFy2XDHFBfXyZ1azcuyVx8FbiNrCootfr+t4UQiI/aTKBf7R1uoopwazLxjbK3P 7d+ymrkUSHjo8EmEOBKFOTl6BCRfxPF7CbfwMCrFxH8D0AvyKYF1jgm8cLRnQHPR hw/rO37KVjLXkhIZlcQ== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3wxka52e43-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Mar 2024 10:20:34 -0700 (PDT) Received: from DC6WP-EXCH02.marvell.com (10.76.176.209) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.32; Wed, 20 Mar 2024 10:20:33 -0700 Received: from maili.marvell.com (10.69.176.80) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server id 15.2.1258.32 via Frontend Transport; Wed, 20 Mar 2024 10:20:33 -0700 Received: from dc3lp-swdev041.marvell.com (dc3lp-swdev041.marvell.com [10.6.60.191]) by maili.marvell.com (Postfix) with ESMTP id D86A65B692A; Wed, 20 Mar 2024 10:20:29 -0700 (PDT) From: Elad Nachman To: , , , , , , , , , , , , CC: Subject: [PATCH v2 5/5] net: marvell: prestera: unbind sfp port on exit Date: Wed, 20 Mar 2024 19:20:08 +0200 Message-ID: <20240320172008.2989693-6-enachman@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240320172008.2989693-1-enachman@marvell.com> References: <20240320172008.2989693-1-enachman@marvell.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: wApieGSGS-BxHIsYjFagktKnev62dGE5 X-Proofpoint-ORIG-GUID: wApieGSGS-BxHIsYjFagktKnev62dGE5 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-20_10,2024-03-18_03,2023-05-22_02 X-Patchwork-Delegate: kuba@kernel.org From: Elad Nachman Call unbinding of the sfp port when ports are released, This will call phylink_destroy() to cleanup and destroy the phylink instance, needed to unregister SFP and free used memory, which will otherwise leak. Reported-by: Köry Maincent Closes: https://lore.kernel.org/lkml/20240312164526.4a0e242a@kmaincent-XPS-13-7390/ Fixes: 501ef3066c89 ("net: marvell: prestera: Add driver for Prestera family ASIC devices") Signed-off-by: Elad Nachman Reviewed-by: Andrew Lunn --- drivers/net/ethernet/marvell/prestera/prestera_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/marvell/prestera/prestera_main.c b/drivers/net/ethernet/marvell/prestera/prestera_main.c index 87d8fc4162b3..20c0ebb52af8 100644 --- a/drivers/net/ethernet/marvell/prestera/prestera_main.c +++ b/drivers/net/ethernet/marvell/prestera/prestera_main.c @@ -756,6 +756,7 @@ static void prestera_port_destroy(struct prestera_port *port) cancel_delayed_work_sync(&port->cached_hw_stats.caching_dw); unregister_netdev(dev); prestera_port_list_del(port); + prestera_port_sfp_unbind(port); prestera_devlink_port_unregister(port); free_netdev(dev); }