Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 CA4B84F403F; Thu, 17 Sep 2026 17:44:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789667082; cv=none; b=J1ozXsY2/IEakr+FYTo4Ki0gvwKOCXPO82DvHt9MDGfSyOOM1C5SCRnrNmz4TazRIH051s4Z/5yCwk80wgU8BjT0d/jcV34kCz33Ms76QngeQAgxcjBhdaCuypycSXtmzJLeGbiQOvXmftd6q1eNK2MCedr+lIGGndNyOW7Zc5o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789667082; c=relaxed/simple; bh=lx5pwA53tiEeDe+D6RXIwfd0jp4Y5yZJQA0VQXfvrJ0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=n1dE2HtbdfwJzsq5CNzTRBFy9EB7iHs7P9fzIg1HRj4D9fhQ0x+fbYqDSkjvoIlctYEE8hSKc6MLVgNkSTzfJ+Vja+JC++A/4+Zz1wlM8ew0P6YmSJgXOa7Wpo91XyWMxYzg2kdGDbU3TKeSIBsNVA5dgz+PQNE2CEZnoeCRhqM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=nI3QxXff; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="nI3QxXff" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A6421F000FF; Thu, 17 Sep 2026 17:44:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789667080; bh=VtxM9oCLSScM3oISe0reNp0IvrUUHnaZ3j4ZqjVdJTw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=nI3QxXffXzH4jiI+lnQEQie66GYC0V86H9rX1xidNfyzvQ1IhN5HwgvFB4ov6LW1G uFsYWbSK3yEMFrMtAY/JtxjKSlLWY1XtJPC0ckTTj3eI58LYlJej3vGHDx47JsvaWP VSON0Ftrwz7gPMIsGdCRN4CRHC3Glx5h1jU4zRE0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?Th=C3=A9o=20Lebrun?= , Vadim Fedorenko , Runyu Xiao , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.18 1221/1250] net: macb: initialize PTP state before registering clock Date: Thu, 17 Sep 2026 16:16:56 +0100 Message-ID: <20260917151625.380692180@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260917151551.901433442@linuxfoundation.org> References: <20260917151551.901433442@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Runyu Xiao [ Upstream commit e1406330d70e56dd44fa6fbafc86e77e5c80c122 ] gem_ptp_init() registers the PTP clock before initializing bp->tsu_clk_lock and the TSU hardware. Since ptp_clock_register() publishes the PTP character device, userspace may invoke PTP callbacks before the lock and hardware are ready. In addition, gem_ptp_init() is called from both the interface open and resume paths. Reinitializing tsu_clk_lock there can reset the lock while timestamp processing is using it. This race is theoretical and has not been observed in practice. Initialize tsu_clk_lock once during probe and initialize the TSU before registering the PTP clock. Fixes: ab91f0a9b5f4 ("net: macb: Add hardware PTP support") Cc: stable@vger.kernel.org Link: https://lore.kernel.org/netdev/20260904030439.3994047-1-runyu.xiao@seu.edu.cn/ Reviewed-by: Théo Lebrun Reviewed-by: Vadim Fedorenko Signed-off-by: Runyu Xiao Link: https://patch.msgid.link/20260908103924.607033-1-runyu.xiao@seu.edu.cn Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/cadence/macb_main.c | 1 + drivers/net/ethernet/cadence/macb_ptp.c | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -5657,6 +5657,7 @@ static int macb_probe(struct platform_de } spin_lock_init(&bp->lock); spin_lock_init(&bp->stats_lock); + spin_lock_init(&bp->tsu_clk_lock); /* setup capabilities */ macb_configure_caps(bp, macb_config); --- a/drivers/net/ethernet/cadence/macb_ptp.c +++ b/drivers/net/ethernet/cadence/macb_ptp.c @@ -332,6 +332,7 @@ void gem_ptp_init(struct net_device *net bp->tsu_rate = bp->ptp_info->get_tsu_rate(bp); bp->ptp_clock_info.max_adj = bp->ptp_info->get_ptp_max_adj(); gem_ptp_init_timer(bp); + gem_ptp_init_tsu(bp); bp->ptp_clock = ptp_clock_register(&bp->ptp_clock_info, &netdev->dev); if (IS_ERR(bp->ptp_clock)) { pr_err("ptp clock register failed: %ld\n", @@ -343,10 +344,6 @@ void gem_ptp_init(struct net_device *net return; } - spin_lock_init(&bp->tsu_clk_lock); - - gem_ptp_init_tsu(bp); - dev_info(&bp->pdev->dev, "%s ptp clock registered.\n", GEM_PTP_TIMER_NAME); }