From patchwork Mon Mar 11 13:51:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Elad Nachman X-Patchwork-Id: 13588777 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 5CB3E3FB93; Mon, 11 Mar 2024 13:51:39 +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=1710165100; cv=none; b=XbN9dzEre09d4HCfownM35s/4eluJC92HQ1j6sso11NtburaJw5TArZGNfT+Y7pdgISH4WdOjaxfyj3RE3KSJpPcTpxAREerKwMZ8XjSdZXwKL13WEgNDMrYm0gOKYQ7enPctnPSeXFDMPX6ODGNYAeAnMa1RbMNUsVWVZ9cglQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710165100; c=relaxed/simple; bh=jIvXgTVERW9CaTKVGFWK56Sf/4a1N9B1WtixmIi5Psw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PFTo4oOsWojhhznnJyuetoqRzv+uY/Y/GeI+feg+4UwDbS1jXeQ7zSUzbQpIibMosSgfy5SC1VdgkvjkVeCIUHxEzlt+TntLQ3kXB7BbeWlJaod5jBMEzBvGaQNPYhVsNmwemSlncgzuZqS9bZpjzmQbzByKIC29QLcitIrWCFY= 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=GHxOO/kw; 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="GHxOO/kw" 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 42B7FYFD019486; Mon, 11 Mar 2024 06:51: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=qqv6s1uHynI5uyK+i77N2z44izpumiOywvM8AV4dU60=; b=GHx OO/kwzIkXq+nVBUaWiZmOclLP3DtosHmeSMkLawZf33OnjbRUOlmmXZ2B6UF60Py Zc3GNzz944naAVkGpEostIFSGrz6r8dTCUHdDjAkjXIB4xuAv9uc5V33cMzzkWb4 uvjJaG5MFodYXjWbTGsgmXVhO/EBB6b6xfazEVoEdApwuqCbTysR7TbqHumrUPFN 9ANlVdhUV3Nw8Gt1COoGxNbJGyVpOMze8hHyi7o0ZPhd0071sA+UELQGkX1eOlOs J3yYSoGBXp0tUfYahCZryOVAzOtaaFGiT/CEEmkGPQU3bySf/ogjlARFaYdNCS+a R859Ynx0v7VBFLSAqmw== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3wswdcs2dk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Mar 2024 06:51:23 -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.12; Mon, 11 Mar 2024 06:51:21 -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.12 via Frontend Transport; Mon, 11 Mar 2024 06:51:21 -0700 Received: from dc3lp-swdev041.marvell.com (dc3lp-swdev041.marvell.com [10.6.60.191]) by maili.marvell.com (Postfix) with ESMTP id 49E7C3F7051; Mon, 11 Mar 2024 06:51:19 -0700 (PDT) From: Elad Nachman To: , , , , , , , , , , CC: Subject: [PATCH 1/3] net: marvell: prestera: fix driver reload Date: Mon, 11 Mar 2024 15:51:10 +0200 Message-ID: <20240311135112.2642491-2-enachman@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240311135112.2642491-1-enachman@marvell.com> References: <20240311135112.2642491-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-ORIG-GUID: 7OHnlc4gS-M_iqFxc07GZjgAIKAwSx55 X-Proofpoint-GUID: 7OHnlc4gS-M_iqFxc07GZjgAIKAwSx55 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-11_08,2024-03-06_01,2023-05-22_02 X-Patchwork-Delegate: kuba@kernel.org From: Elad Nachman Driver rmmod after insmod would fail because of the following issues: 1. API call to reset the switch HW and restart the firmware CPU firmware code loading was missing in driver removal code handler. 2. Timeout waiting for the firmware CPU firmware loader code to start was too small. Fix by adding API call to reset the switch HW and restart the firmware CPU firmware code loading when handling the driver removal procedure, increase the timeout waiting for this restart operation from 5 to 30 seconds. Reported-by: Köry Maincent Closes: https://lore.kernel.org/netdev/20240208101005.29e8c7f3@kmaincent-XPS-13-7390/T/ Signed-off-by: Elad Nachman Tested-by: Kory Maincent --- 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 ++- drivers/net/ethernet/marvell/prestera/prestera_pci.c | 7 ++++++- 4 files changed, 17 insertions(+), 2 deletions(-) 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); } diff --git a/drivers/net/ethernet/marvell/prestera/prestera_pci.c b/drivers/net/ethernet/marvell/prestera/prestera_pci.c index 35857dc19542..b75a263ad8cb 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 prestera 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_SECS 30 #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_SECS * MSEC_PER_SEC); if (err) { dev_err(fw->dev.dev, "waiting for FW loader is timed out"); return err; From patchwork Mon Mar 11 13:51:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elad Nachman X-Patchwork-Id: 13588778 X-Patchwork-Delegate: kuba@kernel.org Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) (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 B737D3FB94; Mon, 11 Mar 2024 13:51:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.148.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710165101; cv=none; b=e5X94sKqzlzOYrdaXHwRwLvgwb2e3vcc7q1MoUCQyLJUUZ0kU7P3OnSJg8WBGFYlLJhcaDe753KgUYLKuByrhE5QHK9pRrBShGUFKVxD3+JX8PyO4wKPuqGKGw9Qu8t3JhzKMee7YVUemQVVIj/yrZgaaAMOQgWcR/kWiUt0lHc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710165101; c=relaxed/simple; bh=S2AMHNhdH85sm9sQuLoX7BN3+6rRCcOQkDC+PX93YvU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bzywI5B/9HJk26PRfJ67+6w/opbE+9RP+zEVvfxB13787Xu0vVIYpIAO+t58yOVVGhMv3KU+zp/2RTr1Ik2wv0GpYDkX5/PvAy1/nDKmo5NQCC+2b/LSxVD7ICNKMEP/kq9KlDQg4iE7gVQvOenZufwTk0xjCYEP+w/3vJdWXN4= 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=MLG6BxtV; arc=none smtp.client-ip=67.231.148.174 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="MLG6BxtV" Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 42B9mVFk015528; Mon, 11 Mar 2024 06:51: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=QOCLYC5BOQiDAq5ve6bOeoIDhTRVpXigGs5XH4/P9Ts=; b=MLG 6BxtVk6SHuAyH0lwvxlUlDKswg6EvfUOZjRH0emj9IeeO9hqMvda1lTh4f1AIo4+ ECRvtWNKFjhPuhL5GpMqDqRlE9JH+qkDo4Vp2uFTllS2qXgQWnkVs2ShHRypQazI O6TyBylFZle6lxFqydbk8eYQyFs9T6YnfWrT6OtMKQQTHtiWK066CLTuGtnBxDX+ L1RXKiOAfUctnvOrxoHGM0mLDp5t7HhcgEDF9DN3ilkxqJ/2dOUCLKFGegqPTRJA gsLuP+ypgAN6DW9eA66sVo/ujdE7Po8TAGQcy6AzhkTCLwuEet/5YyH8UDAr7T/t I+tFg36F8N0jeOyYmYQ== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3wsynb0nh1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Mar 2024 06:51: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.12; Mon, 11 Mar 2024 06:51:25 -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.12 via Frontend Transport; Mon, 11 Mar 2024 06:51:25 -0700 Received: from dc3lp-swdev041.marvell.com (dc3lp-swdev041.marvell.com [10.6.60.191]) by maili.marvell.com (Postfix) with ESMTP id 8BF193F7051; Mon, 11 Mar 2024 06:51:22 -0700 (PDT) From: Elad Nachman To: , , , , , , , , , , CC: Subject: [PATCH 2/3] net: marvell: prestera: fix memory use after free Date: Mon, 11 Mar 2024 15:51:11 +0200 Message-ID: <20240311135112.2642491-3-enachman@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240311135112.2642491-1-enachman@marvell.com> References: <20240311135112.2642491-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: 7vofUwBK2AyhoU-nGnRe9J_pqQtkfj8v X-Proofpoint-ORIG-GUID: 7vofUwBK2AyhoU-nGnRe9J_pqQtkfj8v 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-11_08,2024-03-06_01,2023-05-22_02 X-Patchwork-Delegate: kuba@kernel.org From: Elad Nachman Prestera driver routing module cleanup process would release memory and then reference it again, and eventually free it again. Remove the redundant first memory free call. All such double free calls were detected using KASAN. Signed-off-by: Elad Nachman --- 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 Mon Mar 11 13:51:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elad Nachman X-Patchwork-Id: 13588779 X-Patchwork-Delegate: kuba@kernel.org Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) (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 4019C3FE46; Mon, 11 Mar 2024 13:51:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.148.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710165103; cv=none; b=a7qQp+WHFKzaOUpmNaXZFIv4Agm+XZDqDvMcF0vwuCX2oNtrjboxyqm9xIVx5g4ZSJBmZb04GCmvyQm+ICrVq7fqQ+9dNPyfQdWZNqEJV2lcOLyPr8eywnkL6IlggHetCrseIqV7qeL83hNcJ5ySjxe4LUUGlst/Qo3INRWrTks= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710165103; c=relaxed/simple; bh=3hi9Jqa8kSUrQrsnJ6TZgy7vYP+c7vAyo7eY7XqI/dU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=W9+Lop9jQSXZM4RyQuavLtunlbqXpnRW4XRHxXcBtolpzrwtrJX2AydGR1Woe6hZrt8alwOYl9Y+dAXpRWN9C9ByZG4QdhA6px7a4nWQl3IywY85w+IGrMtjEDzscmWYkhJwJiZD4NpOy4Pq5CoCt8Cwz3Fwo+S+54RVNCAm8Ac= 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=FM9lTZva; arc=none smtp.client-ip=67.231.148.174 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="FM9lTZva" Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 42B9mtR2016550; Mon, 11 Mar 2024 06:51:30 -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=1NPiW0fpbleW62FOBFXlYCKmD7f8dUdE+QJBKyg2EBw=; b=FM9 lTZva+7wtboH74X/SqImsgGByklUmkvIx6Qh3D6y45UPufMDjScownycFnf14YD4 vyTI7CXLkE4RO+8dj/e6vIB1XtPbJIP6X/bYyQPV+jMYbJuxsN67M9Y5xw683T9R mOsS9y9Hfqx5mTmjm4WY/CincvHFwEiGmHGYTle8Y6g2lpX24GH33sq1J/Bfnueh JxU0AQJymZiTqNn5sQfW3Rls2hBWr1hcMzxcAmLziaDYjfblcEneO2EStQE2MmzZ Dtau2Sn+uA40qlfAsgXfX8d4voAIOyGkRzjdhid8thlXZB3ao6t9cP17EAEOWVhp IA8Kf6bJk8AVxiufeOg== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3wsynb0nh6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Mar 2024 06:51:30 -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.12; Mon, 11 Mar 2024 06:51:28 -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.12 via Frontend Transport; Mon, 11 Mar 2024 06:51:28 -0700 Received: from dc3lp-swdev041.marvell.com (dc3lp-swdev041.marvell.com [10.6.60.191]) by maili.marvell.com (Postfix) with ESMTP id C83AD3F7044; Mon, 11 Mar 2024 06:51:25 -0700 (PDT) From: Elad Nachman To: , , , , , , , , , , CC: Subject: [PATCH 3/3] net: marvell: prestera: force good base mac Date: Mon, 11 Mar 2024 15:51:12 +0200 Message-ID: <20240311135112.2642491-4-enachman@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240311135112.2642491-1-enachman@marvell.com> References: <20240311135112.2642491-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: X9qogWKBaT25Hod6WDXxWD4QmQyFTs7n X-Proofpoint-ORIG-GUID: X9qogWKBaT25Hod6WDXxWD4QmQyFTs7n 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-11_08,2024-03-06_01,2023-05-22_02 X-Patchwork-Delegate: kuba@kernel.org From: Elad Nachman Since each switchport MAC address uses the switch base mac address and adds the physical port number to it, Force the last byte of the switch base mac address to be at least 128, so when adding to it, we will not wrap around the previous (more significant) mac address byte, resulting in a warning message. Signed-off-by: Elad Nachman --- drivers/net/ethernet/marvell/prestera/prestera_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/marvell/prestera/prestera_main.c b/drivers/net/ethernet/marvell/prestera/prestera_main.c index bcaa8ea27b49..e17b1a24fe18 100644 --- a/drivers/net/ethernet/marvell/prestera/prestera_main.c +++ b/drivers/net/ethernet/marvell/prestera/prestera_main.c @@ -859,7 +859,9 @@ static int prestera_switch_set_base_mac_addr(struct prestera_switch *sw) if (sw->np) 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); + do { + eth_random_addr(sw->base_mac); + } while (sw->base_mac[5] > 0x80); dev_info(prestera_dev(sw), "using random base mac address\n"); }